From 1f66a0689be9fa0ba60694061131995c5d8f62e2 Mon Sep 17 00:00:00 2001 From: tellsense Date: Sun, 29 Oct 2023 19:44:58 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormElectricLocomotive.Designer.cs | 2 - .../FormElectricLocomotive.cs | 11 ------ .../FormLocomotiveCollection.Designer.cs | 4 -- .../FormLocomotiveCollection.cs | 11 ------ .../ElectricLocomotive/SetGeneric.cs | 38 +++++++++---------- 5 files changed, 19 insertions(+), 47 deletions(-) diff --git a/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.Designer.cs b/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.Designer.cs index a44ff89..e0ab159 100644 --- a/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.Designer.cs +++ b/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.Designer.cs @@ -132,7 +132,6 @@ namespace ElectricLocomotive comboBoxStrategy.Name = "comboBoxStrategy"; comboBoxStrategy.Size = new Size(151, 23); comboBoxStrategy.TabIndex = 6; - comboBoxStrategy.SelectedIndexChanged += comboBoxStrategy_SelectedIndexChanged; // // buttonCreateLocomotive // @@ -189,7 +188,6 @@ namespace ElectricLocomotive Name = "FormElectricLocomotive"; StartPosition = FormStartPosition.CenterScreen; Text = "ElectricLocomotive"; - Load += ElectricLocomotive_Load; ((System.ComponentModel.ISupportInitialize)pictureBoxElectricLocomotive).EndInit(); ResumeLayout(false); PerformLayout(); diff --git a/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.cs index cee1fea..3f4d731 100644 --- a/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.cs +++ b/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.cs @@ -123,17 +123,6 @@ namespace ElectricLocomotive _abstractStrategy = null; } } - private void comboBoxStrategy_SelectedIndexChanged(object sender, EventArgs e) - { - - } - private void pictureBoxElectricLocomotive_Click(object sender, EventArgs e) - { - - } - private void ElectricLocomotive_Load(object sender, EventArgs e) - { - } private void ButtonSelectLocomotive_Click(object sender, EventArgs e) { SelectedLocomotive = _drawingLocomotive; diff --git a/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.Designer.cs b/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.Designer.cs index e829010..fc46811 100644 --- a/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.Designer.cs +++ b/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.Designer.cs @@ -54,7 +54,6 @@ panelLocomotiveCollection.Size = new Size(208, 448); panelLocomotiveCollection.TabIndex = 0; panelLocomotiveCollection.Tag = "Инструменты"; - panelLocomotiveCollection.Paint += panelLocomotiveCollection_Paint; // // maskedTextBoxNumber // @@ -109,7 +108,6 @@ LabelOnPanel.Size = new Size(83, 15); LabelOnPanel.TabIndex = 4; LabelOnPanel.Text = "Инструменты"; - LabelOnPanel.Click += LabelOnPanel_Click; // // FormLocomotiveCollection // @@ -120,13 +118,11 @@ Controls.Add(panelLocomotiveCollection); Name = "FormLocomotiveCollection"; Text = "Набор локомотивов"; - Load += FormLocomotiveCollection_Load; panelLocomotiveCollection.ResumeLayout(false); panelLocomotiveCollection.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit(); ResumeLayout(false); } - #endregion private Panel panelLocomotiveCollection; diff --git a/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.cs b/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.cs index cda95cd..37e92c1 100644 --- a/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.cs +++ b/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.cs @@ -60,16 +60,5 @@ namespace ProjectElectricLocomotive { pictureBoxCollection.Image = _locomotives.ShowLocomotives(); } - private void FormLocomotiveCollection_Load(object sender, EventArgs e) - { - } - private void LabelOnPanel_Click(object sender, EventArgs e) - { - - } - private void panelLocomotiveCollection_Paint(object sender, PaintEventArgs e) - { - - } } } diff --git a/ElectricLocomotive/ElectricLocomotive/SetGeneric.cs b/ElectricLocomotive/ElectricLocomotive/SetGeneric.cs index 89b6709..7ce9c5b 100644 --- a/ElectricLocomotive/ElectricLocomotive/SetGeneric.cs +++ b/ElectricLocomotive/ElectricLocomotive/SetGeneric.cs @@ -17,45 +17,45 @@ namespace ProjectElectricLocomotive.Generics _maxCount = count; _places = new List(count); } - public bool Insert(T locomotive) + public int Insert(T locomotive) { - // TODO вставка в начало набора - return true; + return Insert(locomotive, 0); } - public bool Insert(T locomotive, int position) + public int Insert(T locomotive, int position) { - // TODO проверка позиции - // TODO проверка, что есть место для вставки - // TODO вставка по позиции - _places[position] = locomotive; - return true; + if (position < 0 || position >= _maxCount) return -1; + _places.Insert(position, locomotive); + return position; } - public bool Remove(int position) + public T? Remove(int position) { - // TODO проверка позиции - // TODO удаление объекта из списка - return true; + if (position >= Count || position < 0) + { + return null; + } + T? tmp = _places[position]; + _places[position] = null; + return tmp; } public T? this[int position] { get { - // TODO проверка позиции + if (position < 0 || position >= Count) return null; return _places[position]; } set { - // TODO проверка позиции - // TODO проверка свободных мест в списке - // TODO вставка в список по позиции + if (position < 0 || position >= Count || Count == _maxCount) return; + _places.Insert(position, value); } } - public IEnumerable GetLocos(int? maxLocos = null) + public IEnumerable GetLocomotives(int? maxLocomotives = null) { for (int i = 0; i < _places.Count; ++i) { yield return _places[i]; - if (maxLocos.HasValue && i == maxLocos.Value) + if (maxLocomotives.HasValue && i == maxLocomotives.Value) { yield break; }