PIbd-21 Bakalskaya E.D. LabWork04 Base #6

Closed
ekallin wants to merge 4 commits from LabWork04 into LabWork03
7 changed files with 247 additions and 89 deletions
Showing only changes of commit ede2388115 - Show all commits

View File

@ -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);

View File

@ -28,68 +28,66 @@
/// </summary>
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(815, 0);
this.Instruments.Name = "Instruments";
this.Instruments.Size = new System.Drawing.Size(233, 596);
this.Instruments.TabIndex = 0;
//
// maskedTextBoxNumber
//
this.maskedTextBoxNumber.Location = new System.Drawing.Point(55, 124);
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(42, 326);
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(42, 254);
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;
this.ButtonRemoveLocomotive.Click += new System.EventHandler(this.ButtonRemoveLocomotive_Click);
//
// 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(42, 41);
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 +95,122 @@
//
// pictureBoxCollections
//
this.pictureBoxCollections.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.pictureBoxCollections.Location = new System.Drawing.Point(-3, 0);
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(821, 596);
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(1048, 593);
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;
}
}

View File

@ -17,25 +17,85 @@ namespace ProjectElectricLocomotive
{
public partial class FormLocomotiveCollections : Form
{
private readonly LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive> _locomotives;
private readonly LocomotiveGenericStorage _storage;
//private readonly LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive> _locomotives;
public FormLocomotiveCollections()
{
InitializeComponent();
_locomotives = new LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>(pictureBoxCollections.Width,
pictureBoxCollections.Height);
_storage = new LocomotiveGenericStorage(pictureBoxCollections.Width, pictureBoxCollections.Height);
}
/// <summary>
/// Заполнение listBoxObjects
/// </summary>
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
{
@ -44,17 +104,25 @@ 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 +132,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();
}
}
}

View File

@ -57,4 +57,13 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="bindingSource1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="bindingSource2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>154, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
</metadata>
</root>

View File

@ -32,7 +32,7 @@ namespace ProjectElectricLocomotive.Generics
}
/// Перегрузка оператора сложения
public static int operator +(LocomotiveGenericCollection<T, U> collect, T loco)
public static int operator +(LocomotiveGenericCollection<T, U> collect, T? loco)
{
if (loco == null)
{
@ -42,7 +42,7 @@ namespace ProjectElectricLocomotive.Generics
}
/// Перегрузка оператора вычитания
public static T operator -(LocomotiveGenericCollection<T, U> collect, int pos)
public static T? operator -(LocomotiveGenericCollection<T, U> collect, int pos)
{
T? obj = collect._collection[pos];
if (obj != null)
@ -50,7 +50,6 @@ namespace ProjectElectricLocomotive.Generics
collect._collection.Remove(pos);
}
return obj;
//return collect._collection.Remove(pos);
}
// получение объекта imoveableObj
@ -93,8 +92,7 @@ namespace ProjectElectricLocomotive.Generics
{
type.SetPosition(
(int)(i / HeightObjCount * _placeSizeWidth),
(HeightObjCount - 1) * _placeSizeHeight - (int)(i % HeightObjCount * _placeSizeHeight)
);
(HeightObjCount - 1) * _placeSizeHeight - (int)(i % HeightObjCount * _placeSizeHeight));
type?.DrawTransport(g);
}
}

View File

@ -54,7 +54,7 @@ namespace ProjectElectricLocomotive.Generics
/// <param name="name">Название набора</param>
public void DelSet(string name)
{
if (!_locomotivesStorage.ContainsKey(name))
if (_locomotivesStorage.ContainsKey(name))
{
_locomotivesStorage.Remove(name);
}

View File

@ -29,7 +29,10 @@ namespace ProjectElectricLocomotive.Generics
public int Insert(T loco, int position)
{
int NoEmpty = 0, temp = 0;
if (position < 0 || position >= _maxCount) return -1;
_places.Insert(position, loco);
return position;
/* int NoEmpty = 0, temp = 0;
for (int i = position; i < Count; i++)
{
if (_places[i] != null) NoEmpty++;
@ -54,15 +57,15 @@ namespace ProjectElectricLocomotive.Generics
_places[position] = loco;
return position;
}
return -1;
return -1;*/
}
public T Remove(int position)
public T? Remove(int position)
{
if (position >= Count || position < 0)
return null;
T tmp = _places[position];
T? tmp = _places[position];
_places[position] = null;
return tmp;
}
@ -77,9 +80,8 @@ namespace ProjectElectricLocomotive.Generics
}
set
{
if (position < 0 || position >= Count) return;
if(value == null) return;
_places[position] = value;
if (position < 0 || position >= Count || Count == _maxCount) return;
_places.Insert(position, value);
// TODO проверка позиции
// TODO проверка свободных мест в списке
// TODO вставка в список по позиции
@ -89,7 +91,7 @@ namespace ProjectElectricLocomotive.Generics
/// Проход по списку
/// </summary>
/// <returns></returns>
public IEnumerable<T?> GetCars(int? maxLocos = null)
public IEnumerable<T?> GetLocomotives(int? maxLocos = null)
{
for (int i = 0; i < _places.Count; ++i)
{
@ -100,13 +102,5 @@ namespace ProjectElectricLocomotive.Generics
}
}
}
//Получение объекта из набора по позиции
/* public T Get(int position)
{
// TODO проверка позиции
if (position < 0 || position >= Count) return null;
return _places[position];
}*/
}
}