diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormElectricLocomotive.Designer.cs b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormElectricLocomotive.Designer.cs index 5b886c3..81c4234 100644 --- a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormElectricLocomotive.Designer.cs +++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormElectricLocomotive.Designer.cs @@ -47,7 +47,7 @@ this.pictureBoxElectricLocomotive.Location = new System.Drawing.Point(0, 0); this.pictureBoxElectricLocomotive.Margin = new System.Windows.Forms.Padding(2); this.pictureBoxElectricLocomotive.Name = "pictureBoxElectricLocomotive"; - this.pictureBoxElectricLocomotive.Size = new System.Drawing.Size(994, 520); + this.pictureBoxElectricLocomotive.Size = new System.Drawing.Size(870, 572); this.pictureBoxElectricLocomotive.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.pictureBoxElectricLocomotive.TabIndex = 0; this.pictureBoxElectricLocomotive.TabStop = false; @@ -56,10 +56,10 @@ // this.buttonCreateElectricLocomotive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.buttonCreateElectricLocomotive.Font = new System.Drawing.Font("Candara Light", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.buttonCreateElectricLocomotive.Location = new System.Drawing.Point(13, 442); + this.buttonCreateElectricLocomotive.Location = new System.Drawing.Point(11, 514); this.buttonCreateElectricLocomotive.Margin = new System.Windows.Forms.Padding(2); this.buttonCreateElectricLocomotive.Name = "buttonCreateElectricLocomotive"; - this.buttonCreateElectricLocomotive.Size = new System.Drawing.Size(218, 64); + this.buttonCreateElectricLocomotive.Size = new System.Drawing.Size(191, 48); this.buttonCreateElectricLocomotive.TabIndex = 1; this.buttonCreateElectricLocomotive.Text = "Создать электролокомотив"; this.buttonCreateElectricLocomotive.UseVisualStyleBackColor = true; @@ -70,10 +70,10 @@ this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonLeft.BackgroundImage = global::ProjectElectricLocomotive.Properties.Resources.arrowLeft; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonLeft.Location = new System.Drawing.Point(878, 481); + this.buttonLeft.Location = new System.Drawing.Point(768, 543); this.buttonLeft.Margin = new System.Windows.Forms.Padding(2); this.buttonLeft.Name = "buttonLeft"; - this.buttonLeft.Size = new System.Drawing.Size(24, 24); + this.buttonLeft.Size = new System.Drawing.Size(21, 18); this.buttonLeft.TabIndex = 2; this.buttonLeft.UseVisualStyleBackColor = true; this.buttonLeft.Click += new System.EventHandler(this.buttonMove_Click); @@ -83,10 +83,10 @@ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonUp.BackgroundImage = global::ProjectElectricLocomotive.Properties.Resources.arrowUP; this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonUp.Location = new System.Drawing.Point(915, 442); + this.buttonUp.Location = new System.Drawing.Point(801, 514); this.buttonUp.Margin = new System.Windows.Forms.Padding(2); this.buttonUp.Name = "buttonUp"; - this.buttonUp.Size = new System.Drawing.Size(24, 24); + this.buttonUp.Size = new System.Drawing.Size(21, 18); this.buttonUp.TabIndex = 3; this.buttonUp.UseVisualStyleBackColor = true; this.buttonUp.Click += new System.EventHandler(this.buttonMove_Click); @@ -96,10 +96,10 @@ this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonRight.BackgroundImage = global::ProjectElectricLocomotive.Properties.Resources.arrowRight; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonRight.Location = new System.Drawing.Point(950, 481); + this.buttonRight.Location = new System.Drawing.Point(831, 543); this.buttonRight.Margin = new System.Windows.Forms.Padding(2); this.buttonRight.Name = "buttonRight"; - this.buttonRight.Size = new System.Drawing.Size(24, 24); + this.buttonRight.Size = new System.Drawing.Size(21, 18); this.buttonRight.TabIndex = 4; this.buttonRight.UseVisualStyleBackColor = true; this.buttonRight.Click += new System.EventHandler(this.buttonMove_Click); @@ -109,10 +109,10 @@ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonDown.BackgroundImage = global::ProjectElectricLocomotive.Properties.Resources.arrowDown; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonDown.Location = new System.Drawing.Point(915, 481); + this.buttonDown.Location = new System.Drawing.Point(801, 543); this.buttonDown.Margin = new System.Windows.Forms.Padding(2); this.buttonDown.Name = "buttonDown"; - this.buttonDown.Size = new System.Drawing.Size(24, 24); + this.buttonDown.Size = new System.Drawing.Size(21, 18); this.buttonDown.TabIndex = 5; this.buttonDown.UseVisualStyleBackColor = true; this.buttonDown.Click += new System.EventHandler(this.buttonMove_Click); @@ -125,20 +125,20 @@ this.comboBoxStrategy.Items.AddRange(new object[] { "MoveToCenter", "MoveToRightCorner"}); - this.comboBoxStrategy.Location = new System.Drawing.Point(846, 10); + this.comboBoxStrategy.Location = new System.Drawing.Point(740, 8); this.comboBoxStrategy.Margin = new System.Windows.Forms.Padding(2); this.comboBoxStrategy.Name = "comboBoxStrategy"; - this.comboBoxStrategy.Size = new System.Drawing.Size(129, 28); + this.comboBoxStrategy.Size = new System.Drawing.Size(113, 23); this.comboBoxStrategy.TabIndex = 6; // // buttonCreateLocomotive // this.buttonCreateLocomotive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.buttonCreateLocomotive.Font = new System.Drawing.Font("Candara Light", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.buttonCreateLocomotive.Location = new System.Drawing.Point(266, 442); + this.buttonCreateLocomotive.Location = new System.Drawing.Point(233, 514); this.buttonCreateLocomotive.Margin = new System.Windows.Forms.Padding(2); this.buttonCreateLocomotive.Name = "buttonCreateLocomotive"; - this.buttonCreateLocomotive.Size = new System.Drawing.Size(218, 64); + this.buttonCreateLocomotive.Size = new System.Drawing.Size(191, 48); this.buttonCreateLocomotive.TabIndex = 7; this.buttonCreateLocomotive.Text = "Создать локомотив"; this.buttonCreateLocomotive.UseVisualStyleBackColor = true; @@ -148,10 +148,10 @@ // this.buttonStep.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.buttonStep.Font = new System.Drawing.Font("Candara Light", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.buttonStep.Location = new System.Drawing.Point(863, 52); + this.buttonStep.Location = new System.Drawing.Point(755, 39); this.buttonStep.Margin = new System.Windows.Forms.Padding(2); this.buttonStep.Name = "buttonStep"; - this.buttonStep.Size = new System.Drawing.Size(100, 45); + this.buttonStep.Size = new System.Drawing.Size(88, 34); this.buttonStep.TabIndex = 8; this.buttonStep.Text = "Шаг"; this.buttonStep.UseVisualStyleBackColor = true; @@ -161,10 +161,10 @@ // this.ButtonSelect_Locomotive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.ButtonSelect_Locomotive.Font = new System.Drawing.Font("Candara Light", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.ButtonSelect_Locomotive.Location = new System.Drawing.Point(863, 113); + this.ButtonSelect_Locomotive.Location = new System.Drawing.Point(755, 85); this.ButtonSelect_Locomotive.Margin = new System.Windows.Forms.Padding(2); this.ButtonSelect_Locomotive.Name = "ButtonSelect_Locomotive"; - this.ButtonSelect_Locomotive.Size = new System.Drawing.Size(100, 61); + this.ButtonSelect_Locomotive.Size = new System.Drawing.Size(88, 46); this.ButtonSelect_Locomotive.TabIndex = 9; this.ButtonSelect_Locomotive.Text = "Выбор локо"; this.ButtonSelect_Locomotive.UseVisualStyleBackColor = true; @@ -172,9 +172,9 @@ // // FormElectricLocomotive // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(994, 520); + this.ClientSize = new System.Drawing.Size(870, 572); this.Controls.Add(this.ButtonSelect_Locomotive); this.Controls.Add(this.buttonStep); this.Controls.Add(this.buttonCreateLocomotive); diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.Designer.cs b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.Designer.cs index 562433d..fe4e41c 100644 --- a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.Designer.cs +++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.Designer.cs @@ -28,56 +28,55 @@ /// private void InitializeComponent() { - this.Instruments = new System.Windows.Forms.Panel(); + this.components = new System.ComponentModel.Container(); this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox(); this.ButtonRefreshCollection = new System.Windows.Forms.Button(); this.ButtonRemoveLocomotive = new System.Windows.Forms.Button(); this.ButtonAddLocomotive = new System.Windows.Forms.Button(); this.pictureBoxCollections = new System.Windows.Forms.PictureBox(); - this.Instruments.SuspendLayout(); + this.textBoxStorageName = new System.Windows.Forms.TextBox(); + this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components); + this.bindingSource2 = new System.Windows.Forms.BindingSource(this.components); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.listBoxStorage = new System.Windows.Forms.ListBox(); + this.ButtonAddObject = new System.Windows.Forms.Button(); + this.ButtonRemoveObject = new System.Windows.Forms.Button(); + this.Instruments = new System.Windows.Forms.GroupBox(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollections)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.bindingSource2)).BeginInit(); + this.groupBox1.SuspendLayout(); + this.Instruments.SuspendLayout(); this.SuspendLayout(); // - // Instruments - // - this.Instruments.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.Instruments.AutoSize = true; - this.Instruments.Controls.Add(this.maskedTextBoxNumber); - this.Instruments.Controls.Add(this.ButtonRefreshCollection); - this.Instruments.Controls.Add(this.ButtonRemoveLocomotive); - this.Instruments.Controls.Add(this.ButtonAddLocomotive); - this.Instruments.Location = new System.Drawing.Point(435, -40); - this.Instruments.Name = "Instruments"; - this.Instruments.Size = new System.Drawing.Size(191, 451); - this.Instruments.TabIndex = 0; - // // maskedTextBoxNumber // - this.maskedTextBoxNumber.Location = new System.Drawing.Point(42, 123); + this.maskedTextBoxNumber.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.maskedTextBoxNumber.Location = new System.Drawing.Point(38, 532); this.maskedTextBoxNumber.Mask = "0"; this.maskedTextBoxNumber.Name = "maskedTextBoxNumber"; - this.maskedTextBoxNumber.Size = new System.Drawing.Size(125, 27); + this.maskedTextBoxNumber.Size = new System.Drawing.Size(149, 27); this.maskedTextBoxNumber.TabIndex = 4; // // ButtonRefreshCollection // - this.ButtonRefreshCollection.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.ButtonRefreshCollection.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.ButtonRefreshCollection.Font = new System.Drawing.Font("Candara Light", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.ButtonRefreshCollection.Location = new System.Drawing.Point(29, 249); + this.ButtonRefreshCollection.Location = new System.Drawing.Point(38, 665); this.ButtonRefreshCollection.Name = "ButtonRefreshCollection"; - this.ButtonRefreshCollection.Size = new System.Drawing.Size(150, 36); + this.ButtonRefreshCollection.Size = new System.Drawing.Size(150, 41); this.ButtonRefreshCollection.TabIndex = 2; this.ButtonRefreshCollection.Text = "Обновить все"; this.ButtonRefreshCollection.UseVisualStyleBackColor = true; - this.ButtonRefreshCollection.Click += new System.EventHandler(this.ButtonRefreshCollection_Click); // // ButtonRemoveLocomotive // - this.ButtonRemoveLocomotive.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.ButtonRemoveLocomotive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.ButtonRemoveLocomotive.Font = new System.Drawing.Font("Candara Light", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.ButtonRemoveLocomotive.Location = new System.Drawing.Point(29, 179); + this.ButtonRemoveLocomotive.Location = new System.Drawing.Point(38, 592); this.ButtonRemoveLocomotive.Name = "ButtonRemoveLocomotive"; - this.ButtonRemoveLocomotive.Size = new System.Drawing.Size(150, 36); + this.ButtonRemoveLocomotive.Size = new System.Drawing.Size(150, 44); this.ButtonRemoveLocomotive.TabIndex = 1; this.ButtonRemoveLocomotive.Text = "Удалить локо"; this.ButtonRemoveLocomotive.UseVisualStyleBackColor = true; @@ -85,11 +84,11 @@ // // ButtonAddLocomotive // - this.ButtonAddLocomotive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.ButtonAddLocomotive.Anchor = System.Windows.Forms.AnchorStyles.Top; this.ButtonAddLocomotive.Font = new System.Drawing.Font("Candara Light", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.ButtonAddLocomotive.Location = new System.Drawing.Point(29, 52); + this.ButtonAddLocomotive.Location = new System.Drawing.Point(38, 461); this.ButtonAddLocomotive.Name = "ButtonAddLocomotive"; - this.ButtonAddLocomotive.Size = new System.Drawing.Size(150, 36); + this.ButtonAddLocomotive.Size = new System.Drawing.Size(150, 39); this.ButtonAddLocomotive.TabIndex = 0; this.ButtonAddLocomotive.Text = "Добавить локо"; this.ButtonAddLocomotive.UseVisualStyleBackColor = true; @@ -97,37 +96,122 @@ // // pictureBoxCollections // - this.pictureBoxCollections.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.pictureBoxCollections.Location = new System.Drawing.Point(-3, -2); + this.pictureBoxCollections.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pictureBoxCollections.Location = new System.Drawing.Point(-1, 5); this.pictureBoxCollections.Name = "pictureBoxCollections"; - this.pictureBoxCollections.Size = new System.Drawing.Size(458, 373); + this.pictureBoxCollections.Size = new System.Drawing.Size(798, 721); this.pictureBoxCollections.TabIndex = 1; this.pictureBoxCollections.TabStop = false; // + // textBoxStorageName + // + this.textBoxStorageName.Location = new System.Drawing.Point(31, 43); + this.textBoxStorageName.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.textBoxStorageName.Name = "textBoxStorageName"; + this.textBoxStorageName.Size = new System.Drawing.Size(149, 27); + this.textBoxStorageName.TabIndex = 5; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.listBoxStorage); + this.groupBox1.Controls.Add(this.ButtonAddObject); + this.groupBox1.Controls.Add(this.ButtonRemoveObject); + this.groupBox1.Controls.Add(this.textBoxStorageName); + this.groupBox1.Location = new System.Drawing.Point(7, 29); + this.groupBox1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.groupBox1.Size = new System.Drawing.Size(216, 395); + this.groupBox1.TabIndex = 5; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Наборы"; + // + // listBoxStorage + // + this.listBoxStorage.FormattingEnabled = true; + this.listBoxStorage.ItemHeight = 20; + this.listBoxStorage.Location = new System.Drawing.Point(31, 163); + this.listBoxStorage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.listBoxStorage.Name = "listBoxStorage"; + this.listBoxStorage.Size = new System.Drawing.Size(149, 124); + this.listBoxStorage.TabIndex = 9; + this.listBoxStorage.SelectedIndexChanged += new System.EventHandler(this.listBoxStorage_SelectedIndexChanged); + // + // ButtonAddObject + // + this.ButtonAddObject.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.ButtonAddObject.Font = new System.Drawing.Font("Candara Light", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.ButtonAddObject.Location = new System.Drawing.Point(31, 96); + this.ButtonAddObject.Name = "ButtonAddObject"; + this.ButtonAddObject.Size = new System.Drawing.Size(150, 39); + this.ButtonAddObject.TabIndex = 7; + this.ButtonAddObject.Text = "Добавить набор"; + this.ButtonAddObject.UseVisualStyleBackColor = true; + this.ButtonAddObject.Click += new System.EventHandler(this.ButtonAddObject_Click); + // + // ButtonRemoveObject + // + this.ButtonRemoveObject.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.ButtonRemoveObject.Font = new System.Drawing.Font("Candara Light", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.ButtonRemoveObject.Location = new System.Drawing.Point(31, 325); + this.ButtonRemoveObject.Name = "ButtonRemoveObject"; + this.ButtonRemoveObject.Size = new System.Drawing.Size(150, 44); + this.ButtonRemoveObject.TabIndex = 8; + this.ButtonRemoveObject.Text = "Удалить набор"; + this.ButtonRemoveObject.UseVisualStyleBackColor = true; + this.ButtonRemoveObject.Click += new System.EventHandler(this.ButtonRemoveObject_Click); + // + // Instruments + // + this.Instruments.Controls.Add(this.ButtonRefreshCollection); + this.Instruments.Controls.Add(this.groupBox1); + this.Instruments.Controls.Add(this.maskedTextBoxNumber); + this.Instruments.Controls.Add(this.ButtonAddLocomotive); + this.Instruments.Controls.Add(this.ButtonRemoveLocomotive); + this.Instruments.Location = new System.Drawing.Point(797, 5); + this.Instruments.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.Instruments.Name = "Instruments"; + this.Instruments.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.Instruments.Size = new System.Drawing.Size(229, 721); + this.Instruments.TabIndex = 6; + this.Instruments.TabStop = false; + this.Instruments.Text = "Инструменты"; + // // FormLocomotiveCollections // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(626, 370); - this.Controls.Add(this.pictureBoxCollections); + this.ClientSize = new System.Drawing.Size(1033, 724); this.Controls.Add(this.Instruments); + this.Controls.Add(this.pictureBoxCollections); this.Name = "FormLocomotiveCollections"; this.Text = "Набор локомотивов"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollections)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.bindingSource2)).EndInit(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); this.Instruments.ResumeLayout(false); this.Instruments.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollections)).EndInit(); this.ResumeLayout(false); - this.PerformLayout(); } #endregion - - private Panel Instruments; private Button ButtonRefreshCollection; private Button ButtonRemoveLocomotive; private Button ButtonAddLocomotive; private PictureBox pictureBoxCollections; private MaskedTextBox maskedTextBoxNumber; + private GroupBox groupBox1; + private TextBox textBoxStorageName; + private BindingSource bindingSource1; + private BindingSource bindingSource2; + private ListBox listBoxStorage; + private Button ButtonAddObject; + private Button ButtonRemoveObject; + private GroupBox Instruments; } } \ No newline at end of file diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.cs b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.cs index c5de85b..e58d54b 100644 --- a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.cs +++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.cs @@ -17,25 +17,85 @@ namespace ProjectElectricLocomotive { public partial class FormLocomotiveCollections : Form { - private readonly LocomotiveGenericCollection _locomotives; + private readonly LocomotiveGenericStorage _storage; + //private readonly LocomotiveGenericCollection _locomotives; public FormLocomotiveCollections() { InitializeComponent(); - _locomotives = new LocomotiveGenericCollection(pictureBoxCollections.Width, - pictureBoxCollections.Height); + _storage = new LocomotiveGenericStorage(pictureBoxCollections.Width, pictureBoxCollections.Height); + } + + /// + /// Заполнение listBoxObjects + /// + private void ReloadObjects() + { + int index = listBoxStorage.SelectedIndex; + + listBoxStorage.Items.Clear(); + for (int i = 0; i < _storage.Keys.Count; i++) + { + listBoxStorage.Items.Add(_storage.Keys[i]); + } + if (listBoxStorage.Items.Count > 0 && (index == -1 || index >= listBoxStorage.Items.Count)) + { + listBoxStorage.SelectedIndex = 0; + } + else if (listBoxStorage.Items.Count > 0 && index > -1 && index < listBoxStorage.Items.Count) + { + listBoxStorage.SelectedIndex = index; + } + } + + private void ButtonAddObject_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxStorageName.Text)) + { + MessageBox.Show("Не всё заполнено", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _storage.AddSet(textBoxStorageName.Text); + ReloadObjects(); + } + + private void listBoxStorage_SelectedIndexChanged(object sender, EventArgs e) + { + pictureBoxCollections.Image = _storage[listBoxStorage.SelectedItem?.ToString() ?? string.Empty]?.ShowLocomotives(); + } + + private void ButtonRemoveObject_Click(object sender, EventArgs e) + { + if (listBoxStorage.SelectedIndex == -1) + { + return; + } + if (MessageBox.Show($"Удалить объект {listBoxStorage.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, + MessageBoxIcon.Question) == DialogResult.Yes) + { + _storage.DelSet(listBoxStorage.SelectedItem.ToString() ?? string.Empty); + ReloadObjects(); + } } private void ButtonAddLocomotive_Click(object sender, EventArgs e) { - if (_locomotives == null) return; + + if (listBoxStorage.SelectedIndex == -1) return; + + var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty]; + if (obj == null) + { + return; + } + FormElectricLocomotive form = new(); if (form.ShowDialog() == DialogResult.OK) { //проверяем, удалось ли нам загрузить объект - if (_locomotives + form.SelectedLocomotive != -1) + if (obj + form.SelectedLocomotive > -1) { MessageBox.Show("Объект добавлен"); - pictureBoxCollections.Image = _locomotives.ShowLocomotives(); + pictureBoxCollections.Image = obj.ShowLocomotives(); } else { @@ -46,15 +106,22 @@ namespace ProjectElectricLocomotive private void ButtonRemoveLocomotive_Click(object sender, EventArgs e) { + if (listBoxStorage.SelectedIndex == -1) return; + var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty]; + if (obj == null) + { + return; + } + if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } int pos = Convert.ToInt32(maskedTextBoxNumber.Text); - if (_locomotives - pos != null) + if (obj - pos != null) { MessageBox.Show("Объект удален"); - pictureBoxCollections.Image = _locomotives.ShowLocomotives(); + pictureBoxCollections.Image = obj.ShowLocomotives(); } else { @@ -64,7 +131,13 @@ namespace ProjectElectricLocomotive private void ButtonRefreshCollection_Click(object sender, EventArgs e) { - pictureBoxCollections.Image = _locomotives.ShowLocomotives(); + if (listBoxStorage.SelectedIndex == -1) return; + var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty]; + if (obj == null) + { + return; + } + pictureBoxCollections.Image = obj.ShowLocomotives(); } } } diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.resx b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.resx index 1af7de1..4d89b60 100644 --- a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.resx +++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.resx @@ -1,64 +1,4 @@ - - - + @@ -117,4 +57,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 154, 17 + + + 25 + \ No newline at end of file diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/LocomotiveGenericCollection.cs b/ProjectElectricLocomotive/ProjectElectricLocomotive/LocomotiveGenericCollection.cs index 67d182e..cb58d4b 100644 --- a/ProjectElectricLocomotive/ProjectElectricLocomotive/LocomotiveGenericCollection.cs +++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/LocomotiveGenericCollection.cs @@ -32,7 +32,7 @@ namespace ProjectElectricLocomotive.Generics } /// Перегрузка оператора сложения - public static int operator +(LocomotiveGenericCollection collect, T loco) + public static int operator +(LocomotiveGenericCollection collect, T? loco) { if (loco == null) { @@ -42,15 +42,20 @@ namespace ProjectElectricLocomotive.Generics } /// Перегрузка оператора вычитания - public static T operator -(LocomotiveGenericCollection collect, int pos) + public static T? operator -(LocomotiveGenericCollection collect, int pos) { - return collect._collection.Remove(pos); + T? obj = collect._collection[pos]; + if (obj != null) + { + collect._collection.Remove(pos); + } + return obj; } // получение объекта imoveableObj public U? GetU(int pos) { - return (U?)_collection.Get(pos)?.GetMoveableObject; + return (U?)_collection[pos]?.GetMoveableObject; } /// Вывод всего набора объектов @@ -82,13 +87,12 @@ namespace ProjectElectricLocomotive.Generics int WidthObjCount = _pictureWidth / _placeSizeWidth; for (int i = 0; i < _collection.Count; i++) { - T? type = _collection.Get(i); + T? type = _collection[i]; if (type != null) { type.SetPosition( (int)(i / HeightObjCount * _placeSizeWidth), - (HeightObjCount - 1) * _placeSizeHeight - (int)(i % HeightObjCount * _placeSizeHeight) - ); + (HeightObjCount - 1) * _placeSizeHeight - (int)(i % HeightObjCount * _placeSizeHeight)); type?.DrawTransport(g); } } diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/LocomotiveGenericStorage.cs b/ProjectElectricLocomotive/ProjectElectricLocomotive/LocomotiveGenericStorage.cs new file mode 100644 index 0000000..e2830cd --- /dev/null +++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/LocomotiveGenericStorage.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ProjectElectricLocomotive.DrawingObjects; +using ProjectElectricLocomotive.MovementStrategy; + +namespace ProjectElectricLocomotive.Generics +{ + internal class LocomotiveGenericStorage + { + /// + /// Словарь (хранилище) + /// + readonly Dictionary> _locomotivesStorage; + + /// + /// Возвращение списка названий наборов + /// + public List Keys => _locomotivesStorage.Keys.ToList(); + + + private readonly int _pictureWidth; + + private readonly int _pictureHeight; + + /// + /// Конструктор + /// + /// + /// + public LocomotiveGenericStorage(int pictureWidth, int pictureHeight) + { + _locomotivesStorage = new Dictionary>(); + _pictureWidth = pictureWidth; + _pictureHeight = pictureHeight; + } + /// + /// Добавление набора + /// + /// Название набора + public void AddSet(string name) + { + if (!_locomotivesStorage.ContainsKey(name)) + { + _locomotivesStorage.Add(name, new LocomotiveGenericCollection(_pictureWidth, _pictureHeight)); + } + } + + /// + /// Удаление набора + /// + /// Название набора + public void DelSet(string name) + { + if (_locomotivesStorage.ContainsKey(name)) + { + _locomotivesStorage.Remove(name); + } + } + + + /// + /// Доступ к набору + /// + /// + /// + public LocomotiveGenericCollection? + this[string ind] + { + get + { + // TODO Продумать логику получения набора + if (_locomotivesStorage.ContainsKey(ind)) + { + return _locomotivesStorage[ind]; + } + return null; + } + } + } +} diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/SetGeneric.cs b/ProjectElectricLocomotive/ProjectElectricLocomotive/SetGeneric.cs index 3b43fb2..026eba2 100644 --- a/ProjectElectricLocomotive/ProjectElectricLocomotive/SetGeneric.cs +++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/SetGeneric.cs @@ -8,11 +8,17 @@ namespace ProjectElectricLocomotive.Generics { internal class SetGeneric where T : class { - private readonly T[] _places; - public int Count => _places.Length; + + private readonly List _places; + + public int Count => _places.Count; + + /// Максимальное количество объектов в списке + private readonly int _maxCount; public SetGeneric(int count) { - _places = new T[count]; + _maxCount = count; + _places = new List(count); } /// Добавление объекта в набор @@ -23,54 +29,48 @@ namespace ProjectElectricLocomotive.Generics public int Insert(T loco, int position) { - int NoEmpty = 0, temp = 0; - for (int i = position; i < Count; i++) - { - if (_places[i] != null) NoEmpty++; - } - if (NoEmpty == Count - position - 1) return -1; - - if (position < Count && position >= 0) - { - for (int j = position; j < Count; j++) - { - if (_places[j] == null) - { - temp = j; - break; - } - } - // shift right - for (int i = temp; i > position; i--) - { - _places[i] = _places[i - 1]; - } - _places[position] = loco; - return position; - } - return -1; - // TODO проверка позиции - // TODO проверка, что элемент массива по этой позиции пустой, если нет, то - // проверка, что после вставляемого элемента в массиве есть пустой элемент // + if (position < 0 || position >= _maxCount) return -1; + _places.Insert(position, loco); + return position; } - public T Remove(int position) + public T? Remove(int position) { - // TODO проверка позиции - // TODO удаление объекта из массива, присвоив элементу массива значение null if (position >= Count || position < 0) return null; - T tmp = _places[position]; + T? tmp = _places[position]; _places[position] = null; return tmp; } - //Получение объекта из набора по позиции - public T Get(int position) + + public T? this[int position] { - // TODO проверка позиции - if (position < 0 || position >= Count) return null; - return _places[position]; + get + { + if (position < 0 || position >= Count) return null; + return _places[position]; + } + set + { + if (position < 0 || position >= Count || Count == _maxCount) return; + _places.Insert(position, value); + } + } + /// + /// Проход по списку + /// + /// + public IEnumerable GetLocomotives(int? maxLocos = null) + { + for (int i = 0; i < _places.Count; ++i) + { + yield return _places[i]; + if (maxLocos.HasValue && i == maxLocos.Value) + { + yield break; + } + } } } }