Завершено задание преподавателя

This commit is contained in:
Arklightning 2022-11-11 20:54:35 +04:00
parent 79b94442ae
commit 297e7446a6
4 changed files with 192 additions and 162 deletions

View File

@ -136,8 +136,9 @@ namespace Trolleybus
} }
Pen pen = new Pen(Color.Black); Pen pen = new Pen(Color.Black);
Brush brBlue = new SolidBrush(Color.LightBlue); Brush brBlue = new SolidBrush(Color.LightBlue);
Brush dBlue = new SolidBrush(Color.DarkBlue);
Brush bWhite = new SolidBrush(Color.White); Brush bWhite = new SolidBrush(Color.White);
Brush br = new SolidBrush(Trolleybus?.BodyColor ?? Color.Black);
g.FillRectangle(br, _startPosX, _startPosY, 200, 50);
g.DrawRectangle(pen, _startPosX, _startPosY, 200, 50); g.DrawRectangle(pen, _startPosX, _startPosY, 200, 50);
g.DrawRectangle(pen, _startPosX + 100, _startPosY + 10, 20, 40); g.DrawRectangle(pen, _startPosX + 100, _startPosY + 10, 20, 40);
Pen WinBlue = new Pen(Color.Blue); Pen WinBlue = new Pen(Color.Blue);

View File

@ -29,6 +29,12 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.buttonDeleteMap = new System.Windows.Forms.Button();
this.listBoxMaps = new System.Windows.Forms.ListBox();
this.buttonAddMap = new System.Windows.Forms.Button();
this.textBoxNewMapName = new System.Windows.Forms.TextBox();
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
this.buttonLeft = new System.Windows.Forms.Button(); this.buttonLeft = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button(); this.buttonRight = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button(); this.buttonDown = new System.Windows.Forms.Button();
@ -38,16 +44,10 @@
this.buttonRemoveTrolleybus = new System.Windows.Forms.Button(); this.buttonRemoveTrolleybus = new System.Windows.Forms.Button();
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox(); this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
this.buttonAddTrolleybus = new System.Windows.Forms.Button(); this.buttonAddTrolleybus = new System.Windows.Forms.Button();
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
this.pictureBox = new System.Windows.Forms.PictureBox(); this.pictureBox = new System.Windows.Forms.PictureBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.textBoxNewMapName = new System.Windows.Forms.TextBox();
this.buttonAddMap = new System.Windows.Forms.Button();
this.listBoxMaps = new System.Windows.Forms.ListBox();
this.buttonDeleteMap = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
this.groupBox2.SuspendLayout(); this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// groupBox1 // groupBox1
@ -63,125 +63,15 @@
this.groupBox1.Controls.Add(this.maskedTextBoxPosition); this.groupBox1.Controls.Add(this.maskedTextBoxPosition);
this.groupBox1.Controls.Add(this.buttonAddTrolleybus); this.groupBox1.Controls.Add(this.buttonAddTrolleybus);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right; this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
this.groupBox1.Location = new System.Drawing.Point(600, 0); this.groupBox1.Location = new System.Drawing.Point(900, 0);
this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBox1.Name = "groupBox1"; this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(200, 648); this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBox1.Size = new System.Drawing.Size(300, 997);
this.groupBox1.TabIndex = 0; this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "Инструменты"; this.groupBox1.Text = "Инструменты";
// //
// buttonLeft
//
this.buttonLeft.BackgroundImage = global::Trolleybus.Properties.Resources.left30;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonLeft.Location = new System.Drawing.Point(80, 605);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(32, 31);
this.buttonLeft.TabIndex = 9;
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonRight
//
this.buttonRight.BackgroundImage = global::Trolleybus.Properties.Resources.right30;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonRight.Location = new System.Drawing.Point(156, 605);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(32, 31);
this.buttonRight.TabIndex = 8;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonDown
//
this.buttonDown.BackgroundImage = global::Trolleybus.Properties.Resources.down30;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonDown.Location = new System.Drawing.Point(118, 605);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(32, 31);
this.buttonDown.TabIndex = 7;
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonUp
//
this.buttonUp.BackgroundImage = global::Trolleybus.Properties.Resources.up30;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonUp.Location = new System.Drawing.Point(118, 568);
this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(32, 31);
this.buttonUp.TabIndex = 6;
this.buttonUp.UseVisualStyleBackColor = true;
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonShowOnMap
//
this.buttonShowOnMap.Location = new System.Drawing.Point(7, 511);
this.buttonShowOnMap.Name = "buttonShowOnMap";
this.buttonShowOnMap.Size = new System.Drawing.Size(181, 23);
this.buttonShowOnMap.TabIndex = 5;
this.buttonShowOnMap.Text = "Посмотреть карту";
this.buttonShowOnMap.UseVisualStyleBackColor = true;
this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
//
// buttonShowStorage
//
this.buttonShowStorage.Location = new System.Drawing.Point(7, 471);
this.buttonShowStorage.Name = "buttonShowStorage";
this.buttonShowStorage.Size = new System.Drawing.Size(181, 23);
this.buttonShowStorage.TabIndex = 4;
this.buttonShowStorage.Text = "Посмотреть хранилище";
this.buttonShowStorage.UseVisualStyleBackColor = true;
this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
//
// buttonRemoveTrolleybus
//
this.buttonRemoveTrolleybus.Location = new System.Drawing.Point(6, 425);
this.buttonRemoveTrolleybus.Name = "buttonRemoveTrolleybus";
this.buttonRemoveTrolleybus.Size = new System.Drawing.Size(182, 23);
this.buttonRemoveTrolleybus.TabIndex = 3;
this.buttonRemoveTrolleybus.Text = "Удалить троллейбус";
this.buttonRemoveTrolleybus.UseVisualStyleBackColor = true;
this.buttonRemoveTrolleybus.Click += new System.EventHandler(this.ButtonRemoveTrolleybus_Click);
//
// maskedTextBoxPosition
//
this.maskedTextBoxPosition.Location = new System.Drawing.Point(7, 383);
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
this.maskedTextBoxPosition.Size = new System.Drawing.Size(181, 20);
this.maskedTextBoxPosition.TabIndex = 2;
//
// buttonAddTrolleybus
//
this.buttonAddTrolleybus.Location = new System.Drawing.Point(7, 340);
this.buttonAddTrolleybus.Name = "buttonAddTrolleybus";
this.buttonAddTrolleybus.Size = new System.Drawing.Size(181, 23);
this.buttonAddTrolleybus.TabIndex = 1;
this.buttonAddTrolleybus.Text = "Добавить троллейбус";
this.buttonAddTrolleybus.UseVisualStyleBackColor = true;
this.buttonAddTrolleybus.Click += new System.EventHandler(this.ButtonAddTrolleybus_Click);
//
// comboBoxSelectorMap
//
this.comboBoxSelectorMap.FormattingEnabled = true;
this.comboBoxSelectorMap.Items.AddRange(new object[] {
"Простая карта",
"Сложная карта"});
this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 44);
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
this.comboBoxSelectorMap.Size = new System.Drawing.Size(169, 21);
this.comboBoxSelectorMap.TabIndex = 0;
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
//
// pictureBox
//
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox.Location = new System.Drawing.Point(0, 0);
this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(600, 648);
this.pictureBox.TabIndex = 1;
this.pictureBox.TabStop = false;
//
// groupBox2 // groupBox2
// //
this.groupBox2.Controls.Add(this.buttonDeleteMap); this.groupBox2.Controls.Add(this.buttonDeleteMap);
@ -189,60 +79,194 @@
this.groupBox2.Controls.Add(this.buttonAddMap); this.groupBox2.Controls.Add(this.buttonAddMap);
this.groupBox2.Controls.Add(this.textBoxNewMapName); this.groupBox2.Controls.Add(this.textBoxNewMapName);
this.groupBox2.Controls.Add(this.comboBoxSelectorMap); this.groupBox2.Controls.Add(this.comboBoxSelectorMap);
this.groupBox2.Location = new System.Drawing.Point(6, 19); this.groupBox2.Location = new System.Drawing.Point(9, 29);
this.groupBox2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBox2.Name = "groupBox2"; this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(181, 287); this.groupBox2.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBox2.Size = new System.Drawing.Size(272, 442);
this.groupBox2.TabIndex = 2; this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false; this.groupBox2.TabStop = false;
this.groupBox2.Text = "Карты"; this.groupBox2.Text = "Карты";
// //
// textBoxNewMapName // buttonDeleteMap
// //
this.textBoxNewMapName.Location = new System.Drawing.Point(7, 18); this.buttonDeleteMap.Location = new System.Drawing.Point(10, 314);
this.textBoxNewMapName.Name = "textBoxNewMapName"; this.buttonDeleteMap.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.textBoxNewMapName.Size = new System.Drawing.Size(168, 20); this.buttonDeleteMap.Name = "buttonDeleteMap";
this.textBoxNewMapName.TabIndex = 1; this.buttonDeleteMap.Size = new System.Drawing.Size(252, 35);
// this.buttonDeleteMap.TabIndex = 4;
// buttonAddMap this.buttonDeleteMap.Text = "Удалить Карту";
// this.buttonDeleteMap.UseVisualStyleBackColor = true;
this.buttonAddMap.Location = new System.Drawing.Point(7, 72); this.buttonDeleteMap.Click += new System.EventHandler(this.ButtonDeleteMap_Click);
this.buttonAddMap.Name = "buttonAddMap";
this.buttonAddMap.Size = new System.Drawing.Size(168, 23);
this.buttonAddMap.TabIndex = 2;
this.buttonAddMap.Text = "Добавить Карту";
this.buttonAddMap.UseVisualStyleBackColor = true;
// //
// listBoxMaps // listBoxMaps
// //
this.listBoxMaps.FormattingEnabled = true; this.listBoxMaps.FormattingEnabled = true;
this.listBoxMaps.Location = new System.Drawing.Point(7, 102); this.listBoxMaps.ItemHeight = 20;
this.listBoxMaps.Location = new System.Drawing.Point(10, 157);
this.listBoxMaps.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.listBoxMaps.Name = "listBoxMaps"; this.listBoxMaps.Name = "listBoxMaps";
this.listBoxMaps.Size = new System.Drawing.Size(168, 95); this.listBoxMaps.Size = new System.Drawing.Size(250, 144);
this.listBoxMaps.TabIndex = 3; this.listBoxMaps.TabIndex = 3;
this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.ListBoxMaps_SelectedIndexChanged);
// //
// buttonDeleteMap // buttonAddMap
// //
this.buttonDeleteMap.Location = new System.Drawing.Point(7, 204); this.buttonAddMap.Location = new System.Drawing.Point(10, 111);
this.buttonDeleteMap.Name = "buttonDeleteMap"; this.buttonAddMap.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.buttonDeleteMap.Size = new System.Drawing.Size(168, 23); this.buttonAddMap.Name = "buttonAddMap";
this.buttonDeleteMap.TabIndex = 4; this.buttonAddMap.Size = new System.Drawing.Size(252, 35);
this.buttonDeleteMap.Text = "Удалить Карту"; this.buttonAddMap.TabIndex = 2;
this.buttonDeleteMap.UseVisualStyleBackColor = true; this.buttonAddMap.Text = "Добавить Карту";
this.buttonAddMap.UseVisualStyleBackColor = true;
this.buttonAddMap.Click += new System.EventHandler(this.ButtonAddMap_Click);
//
// textBoxNewMapName
//
this.textBoxNewMapName.Location = new System.Drawing.Point(10, 28);
this.textBoxNewMapName.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.textBoxNewMapName.Name = "textBoxNewMapName";
this.textBoxNewMapName.Size = new System.Drawing.Size(250, 26);
this.textBoxNewMapName.TabIndex = 1;
//
// comboBoxSelectorMap
//
this.comboBoxSelectorMap.FormattingEnabled = true;
this.comboBoxSelectorMap.Items.AddRange(new object[] {
"Простая карта",
"Сложная карта"});
this.comboBoxSelectorMap.Location = new System.Drawing.Point(9, 68);
this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
this.comboBoxSelectorMap.Size = new System.Drawing.Size(252, 28);
this.comboBoxSelectorMap.TabIndex = 0;
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
//
// buttonLeft
//
this.buttonLeft.BackgroundImage = global::Trolleybus.Properties.Resources.left30;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonLeft.Location = new System.Drawing.Point(120, 931);
this.buttonLeft.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(48, 48);
this.buttonLeft.TabIndex = 9;
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonRight
//
this.buttonRight.BackgroundImage = global::Trolleybus.Properties.Resources.right30;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonRight.Location = new System.Drawing.Point(234, 931);
this.buttonRight.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(48, 48);
this.buttonRight.TabIndex = 8;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonDown
//
this.buttonDown.BackgroundImage = global::Trolleybus.Properties.Resources.down30;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonDown.Location = new System.Drawing.Point(177, 931);
this.buttonDown.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(48, 48);
this.buttonDown.TabIndex = 7;
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonUp
//
this.buttonUp.BackgroundImage = global::Trolleybus.Properties.Resources.up30;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonUp.Location = new System.Drawing.Point(177, 874);
this.buttonUp.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(48, 48);
this.buttonUp.TabIndex = 6;
this.buttonUp.UseVisualStyleBackColor = true;
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonShowOnMap
//
this.buttonShowOnMap.Location = new System.Drawing.Point(10, 786);
this.buttonShowOnMap.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.buttonShowOnMap.Name = "buttonShowOnMap";
this.buttonShowOnMap.Size = new System.Drawing.Size(272, 35);
this.buttonShowOnMap.TabIndex = 5;
this.buttonShowOnMap.Text = "Посмотреть карту";
this.buttonShowOnMap.UseVisualStyleBackColor = true;
this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
//
// buttonShowStorage
//
this.buttonShowStorage.Location = new System.Drawing.Point(10, 725);
this.buttonShowStorage.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.buttonShowStorage.Name = "buttonShowStorage";
this.buttonShowStorage.Size = new System.Drawing.Size(272, 35);
this.buttonShowStorage.TabIndex = 4;
this.buttonShowStorage.Text = "Посмотреть хранилище";
this.buttonShowStorage.UseVisualStyleBackColor = true;
this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
//
// buttonRemoveTrolleybus
//
this.buttonRemoveTrolleybus.Location = new System.Drawing.Point(9, 654);
this.buttonRemoveTrolleybus.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.buttonRemoveTrolleybus.Name = "buttonRemoveTrolleybus";
this.buttonRemoveTrolleybus.Size = new System.Drawing.Size(273, 35);
this.buttonRemoveTrolleybus.TabIndex = 3;
this.buttonRemoveTrolleybus.Text = "Удалить троллейбус";
this.buttonRemoveTrolleybus.UseVisualStyleBackColor = true;
this.buttonRemoveTrolleybus.Click += new System.EventHandler(this.ButtonRemoveTrolleybus_Click);
//
// maskedTextBoxPosition
//
this.maskedTextBoxPosition.Location = new System.Drawing.Point(10, 589);
this.maskedTextBoxPosition.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
this.maskedTextBoxPosition.Size = new System.Drawing.Size(270, 26);
this.maskedTextBoxPosition.TabIndex = 2;
//
// buttonAddTrolleybus
//
this.buttonAddTrolleybus.Location = new System.Drawing.Point(10, 523);
this.buttonAddTrolleybus.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.buttonAddTrolleybus.Name = "buttonAddTrolleybus";
this.buttonAddTrolleybus.Size = new System.Drawing.Size(272, 35);
this.buttonAddTrolleybus.TabIndex = 1;
this.buttonAddTrolleybus.Text = "Добавить троллейбус";
this.buttonAddTrolleybus.UseVisualStyleBackColor = true;
this.buttonAddTrolleybus.Click += new System.EventHandler(this.ButtonAddTrolleybus_Click);
//
// pictureBox
//
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox.Location = new System.Drawing.Point(0, 0);
this.pictureBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(900, 997);
this.pictureBox.TabIndex = 1;
this.pictureBox.TabStop = false;
// //
// FormMapWithSetTrolleybus // FormMapWithSetTrolleybus
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 648); this.ClientSize = new System.Drawing.Size(1200, 997);
this.Controls.Add(this.pictureBox); this.Controls.Add(this.pictureBox);
this.Controls.Add(this.groupBox1); this.Controls.Add(this.groupBox1);
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Name = "FormMapWithSetTrolleybus"; this.Name = "FormMapWithSetTrolleybus";
this.Text = "FormMapWithSetTrolleybus"; this.Text = "FormMapWithSetTrolleybus";
this.groupBox1.ResumeLayout(false); this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout(); this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.groupBox2.ResumeLayout(false); this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout(); this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
} }

View File

@ -38,6 +38,11 @@ namespace Trolleybus
listBoxMaps.Items.Add(_mapsCollection.Keys[i]); listBoxMaps.Items.Add(_mapsCollection.Keys[i]);
} }
foreach (string map in _mapsCollection.Keys)
{
listBoxMaps.Items.Add(map);
}
if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count)) if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count))
{ {
listBoxMaps.SelectedIndex = 0; listBoxMaps.SelectedIndex = 0;
@ -153,7 +158,7 @@ namespace Trolleybus
/// <param name="e"></param> /// <param name="e"></param>
private void ButtonShowStorage_Click(object sender, EventArgs e) private void ButtonShowStorage_Click(object sender, EventArgs e)
{ {
if (listBoxMaps.SelectedIndex == -1) if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty] == null)
{ {
return; return;
} }
@ -185,23 +190,23 @@ namespace Trolleybus
} }
//получаем имя кнопки //получаем имя кнопки
string name = ((Button)sender)?.Name ?? string.Empty; string name = ((Button)sender)?.Name ?? string.Empty;
Direction enums = Direction.None; Direction dir = Direction.None;
switch (name) switch (name)
{ {
case "buttonsUp": case "buttonUp":
enums = Direction.Up; dir = Direction.Up;
break; break;
case "buttonsDown": case "buttonDown":
enums = Direction.Down; dir = Direction.Down;
break; break;
case "buttonsLeft": case "buttonLeft":
enums = Direction.Left; dir = Direction.Left;
break; break;
case "buttonsRight": case "buttonRight":
enums = Direction.Right; dir = Direction.Right;
break; break;
} }
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(enums); pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
} }
} }
} }

View File

@ -169,7 +169,7 @@ namespace Trolleybus
{ {
if (countInRow >= _pictureWidth / (_placeSizeWidth + 30)) if (countInRow >= _pictureWidth / (_placeSizeWidth + 30))
{ {
xForLocomotive = _pictureWidth - _placeSizeWidth + 40; xForLocomotive = _pictureWidth - 2 * _placeSizeWidth + 60;
yForLocomotive += _placeSizeHeight; yForLocomotive += _placeSizeHeight;
countInRow = 0; countInRow = 0;
} }