diff --git a/DoubleDeckerBus/DoubleDeckerBus/Direction.cs b/DoubleDeckerBus/DoubleDeckerBus/Direction.cs
index cbae840..b005a07 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/Direction.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/Direction.cs
@@ -9,7 +9,7 @@ namespace DoubleDeckerBus
///
/// Направление перемещения
///
- internal enum Direction
+ public enum Direction
{
None=0,
Up = 1,
diff --git a/DoubleDeckerBus/DoubleDeckerBus/DrawningBus.cs b/DoubleDeckerBus/DoubleDeckerBus/DrawningBus.cs
index 5fbe44e..413c3be 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/DrawningBus.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/DrawningBus.cs
@@ -9,7 +9,7 @@ namespace DoubleDeckerBus
///
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
///
- internal class DrawningBus
+ public class DrawningBus
{
///
/// Класс-сущность
diff --git a/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs b/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs
index 74ace8c..5bb39ad 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs
@@ -9,7 +9,7 @@ namespace DoubleDeckerBus
///
/// Класс-сущность "Автобус"
///
- internal class EntityBus
+ public class EntityBus
{
///
/// Скорость
diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormBus.Designer.cs b/DoubleDeckerBus/DoubleDeckerBus/FormBus.Designer.cs
index e83ef61..3ca7a32 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/FormBus.Designer.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/FormBus.Designer.cs
@@ -39,6 +39,7 @@
this.buttonDown = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonCreateModif = new System.Windows.Forms.Button();
+ this.buttonSelectBus = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBus)).BeginInit();
this.statusStrip.SuspendLayout();
this.SuspendLayout();
@@ -151,11 +152,22 @@
this.buttonCreateModif.UseVisualStyleBackColor = true;
this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
//
+ // buttonSelectBus
+ //
+ this.buttonSelectBus.Location = new System.Drawing.Point(562, 390);
+ this.buttonSelectBus.Name = "buttonSelectBus";
+ this.buttonSelectBus.Size = new System.Drawing.Size(104, 23);
+ this.buttonSelectBus.TabIndex = 8;
+ this.buttonSelectBus.Text = "Выбрать";
+ this.buttonSelectBus.UseVisualStyleBackColor = true;
+ this.buttonSelectBus.Click += new System.EventHandler(this.ButtonSelectBus_Click);
+ //
// FormBus
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonSelectBus);
this.Controls.Add(this.buttonCreateModif);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonDown);
@@ -187,5 +199,6 @@
private Button buttonDown;
private Button buttonRight;
private Button buttonCreateModif;
+ private Button buttonSelectBus;
}
}
\ No newline at end of file
diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs b/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs
index 9a1b3c1..48e887e 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs
@@ -7,6 +7,8 @@ namespace DoubleDeckerBus
{
InitializeComponent();
}
+
+ public DrawningBus SelectedCar { get; private set; }
private void Draw()
{
Bitmap bmp = new(pictureBoxBus.Width, pictureBoxBus.Height);
@@ -97,5 +99,12 @@ namespace DoubleDeckerBus
SetData();
Draw();
}
+
+ private void ButtonSelectBus_Click(object sender, EventArgs e)
+ {
+ SelectedCar = _bus;
+ DialogResult = DialogResult.OK;
+ }
+
}
}
\ No newline at end of file
diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormMap.cs b/DoubleDeckerBus/DoubleDeckerBus/FormMap.cs
deleted file mode 100644
index 94e2deb..0000000
--- a/DoubleDeckerBus/DoubleDeckerBus/FormMap.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace DoubleDeckerBus
-{
- public partial class FormMap : Form
- {
- private AbstractMap _abstractMap;
- public FormMap()
- {
- InitializeComponent();
- _abstractMap = new SimpleMap();
- comboBoxSelectorMap.Text = "Простая карта";
- }
- ///
- /// Заполнение информации по объекту
- ///
- ///
- private void SetData(DrawningBus bus)
- {
- toolStripStatusLabelSpeed.Text = $"Скорость: {bus.Bus.Speed}";
- toolStripStatusLabelWeight.Text = $"Вес: {bus.Bus.Weight}";
- toolStripStatusLabelBodyColor.Text = $"Цвет:" + $"{bus.Bus.BodyColor.Name}"; pictureBoxBus.Image = _abstractMap.CreateMap(pictureBoxBus.Width,pictureBoxBus.Height,new DrawningObjectBus(bus));
- }
- ///
- /// Обработка нажатия кнопки "Создать"
- ///
- ///
- ///
- private void ButtonCreate_Click(object sender, EventArgs e)
- {
- Random rnd = new();
- var car = new DrawningBus(rnd.Next(100, 300), rnd.Next(1000, 2000),
- Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
- SetData(car);
- }
- ///
- /// Изменение размеров формы
- ///
- ///
- ///
- private void ButtonMove_Click(object sender, EventArgs e)
- {
- //получаем имя кнопки
- string name = ((Button)sender)?.Name ?? string.Empty;
- Direction dir = Direction.None;
- switch (name)
- {
- case "buttonUp":
- dir = Direction.Up;
- break;
- case "buttonDown":
- dir = Direction.Down;
- break;
- case "buttonLeft":
- dir = Direction.Left;
- break;
- case "buttonRight":
- dir = Direction.Right;
- break;
- }
- pictureBoxBus.Image = _abstractMap?.MoveObject(dir);
- }
- ///
- /// Обработка нажатия кнопки "Модификация"
- ///
- ///
- ///
- private void ButtonCreateModif_Click(object sender, EventArgs e)
- {
- Random rnd = new();
- var car = new DrawningDoubleDeckerBus(rnd.Next(100, 300), rnd.Next(1000,2000),
- Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0,256)),
- Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0,256)),
- Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0,2)), Convert.ToBoolean(rnd.Next(0, 2)));
- SetData(car);
- }
- ///
- /// Смена карты
- ///
- ///
- ///
- private void ComboBoxSelectorMap_SelectedIndexChanged(object sender,EventArgs e)
- {
- switch (comboBoxSelectorMap.Text)
- {
- case "Простая карта":
- _abstractMap = new SimpleMap();
- break;
- case "Моя карта":
- _abstractMap = new MyMap();
- break;
- }
- }
- }
-}
diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormMap.Designer.cs b/DoubleDeckerBus/DoubleDeckerBus/FormMapWithSetBuses.Designer.cs
similarity index 50%
rename from DoubleDeckerBus/DoubleDeckerBus/FormMap.Designer.cs
rename to DoubleDeckerBus/DoubleDeckerBus/FormMapWithSetBuses.Designer.cs
index d2196bf..bfd2975 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/FormMap.Designer.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/FormMapWithSetBuses.Designer.cs
@@ -1,6 +1,6 @@
namespace DoubleDeckerBus
{
- partial class FormMap
+ partial class FormMapWithSetBuses
{
///
/// Required designer variable.
@@ -28,179 +28,188 @@
///
private void InitializeComponent()
{
- this.pictureBoxBus = new System.Windows.Forms.PictureBox();
- this.statusStrip = new System.Windows.Forms.StatusStrip();
- this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
- this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
- this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
- this.buttonCreate = new System.Windows.Forms.Button();
- this.buttonUp = new System.Windows.Forms.Button();
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
this.buttonLeft = new System.Windows.Forms.Button();
- this.buttonDown = new System.Windows.Forms.Button();
+ this.buttonUp = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
- this.buttonCreateModif = new System.Windows.Forms.Button();
+ this.buttonDown = new System.Windows.Forms.Button();
+ this.buttonShowOnMap = new System.Windows.Forms.Button();
+ this.buttonShowStorage = new System.Windows.Forms.Button();
+ this.buttonRemoveBus = new System.Windows.Forms.Button();
+ this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
+ this.buttonAddBus = new System.Windows.Forms.Button();
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBus)).BeginInit();
- this.statusStrip.SuspendLayout();
+ this.pictureBox = new System.Windows.Forms.PictureBox();
+ this.groupBox1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
this.SuspendLayout();
//
- // pictureBoxBus
+ // groupBox1
//
- this.pictureBoxBus.Dock = System.Windows.Forms.DockStyle.Fill;
- this.pictureBoxBus.Location = new System.Drawing.Point(0, 0);
- this.pictureBoxBus.Name = "pictureBoxBus";
- this.pictureBoxBus.Size = new System.Drawing.Size(800, 428);
- this.pictureBoxBus.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
- this.pictureBoxBus.TabIndex = 0;
- this.pictureBoxBus.TabStop = false;
- //
- // statusStrip
- //
- this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.toolStripStatusLabelSpeed,
- this.toolStripStatusLabelWeight,
- this.toolStripStatusLabelBodyColor});
- this.statusStrip.Location = new System.Drawing.Point(0, 428);
- this.statusStrip.Name = "statusStrip";
- this.statusStrip.Size = new System.Drawing.Size(800, 22);
- this.statusStrip.TabIndex = 1;
- //
- // toolStripStatusLabelSpeed
- //
- this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
- this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(62, 17);
- this.toolStripStatusLabelSpeed.Text = "Скорость:";
- //
- // toolStripStatusLabelWeight
- //
- this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
- this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(29, 17);
- this.toolStripStatusLabelWeight.Text = "Вес:";
- //
- // toolStripStatusLabelBodyColor
- //
- this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
- this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(36, 17);
- this.toolStripStatusLabelBodyColor.Text = "Цвет:";
- //
- // buttonCreate
- //
- this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.buttonCreate.Location = new System.Drawing.Point(12, 393);
- this.buttonCreate.Name = "buttonCreate";
- this.buttonCreate.Size = new System.Drawing.Size(75, 23);
- this.buttonCreate.TabIndex = 2;
- this.buttonCreate.Text = "Создать";
- this.buttonCreate.UseVisualStyleBackColor = true;
- this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
- //
- // buttonUp
- //
- this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonUp.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Up;
- this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonUp.Location = new System.Drawing.Point(722, 350);
- this.buttonUp.Name = "buttonUp";
- this.buttonUp.Size = new System.Drawing.Size(30, 30);
- this.buttonUp.TabIndex = 3;
- this.buttonUp.UseVisualStyleBackColor = true;
- this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
+ this.groupBox1.Controls.Add(this.buttonLeft);
+ this.groupBox1.Controls.Add(this.buttonUp);
+ this.groupBox1.Controls.Add(this.buttonRight);
+ this.groupBox1.Controls.Add(this.buttonDown);
+ this.groupBox1.Controls.Add(this.buttonShowOnMap);
+ this.groupBox1.Controls.Add(this.buttonShowStorage);
+ this.groupBox1.Controls.Add(this.buttonRemoveBus);
+ this.groupBox1.Controls.Add(this.maskedTextBoxPosition);
+ this.groupBox1.Controls.Add(this.buttonAddBus);
+ this.groupBox1.Controls.Add(this.comboBoxSelectorMap);
+ this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
+ this.groupBox1.Location = new System.Drawing.Point(600, 0);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(200, 450);
+ this.groupBox1.TabIndex = 0;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Инструменты";
//
// buttonLeft
//
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonLeft.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Left;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonLeft.Location = new System.Drawing.Point(686, 386);
+ this.buttonLeft.Location = new System.Drawing.Point(52, 408);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
- this.buttonLeft.TabIndex = 4;
+ this.buttonLeft.TabIndex = 9;
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
//
- // buttonDown
+ // buttonUp
//
- this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonDown.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Down;
- this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonDown.Location = new System.Drawing.Point(722, 386);
- this.buttonDown.Name = "buttonDown";
- this.buttonDown.Size = new System.Drawing.Size(30, 30);
- this.buttonDown.TabIndex = 5;
- this.buttonDown.UseVisualStyleBackColor = true;
- this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
+ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonUp.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Up;
+ this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonUp.Location = new System.Drawing.Point(88, 372);
+ this.buttonUp.Name = "buttonUp";
+ this.buttonUp.Size = new System.Drawing.Size(30, 30);
+ this.buttonUp.TabIndex = 8;
+ this.buttonUp.UseVisualStyleBackColor = true;
+ this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonRight
//
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRight.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Right;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonRight.Location = new System.Drawing.Point(758, 386);
+ this.buttonRight.Location = new System.Drawing.Point(124, 408);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(30, 30);
- this.buttonRight.TabIndex = 6;
+ this.buttonRight.TabIndex = 7;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
//
- // buttonCreateModif
+ // buttonDown
//
- this.buttonCreateModif.Location = new System.Drawing.Point(93, 393);
- this.buttonCreateModif.Name = "buttonCreateModif";
- this.buttonCreateModif.Size = new System.Drawing.Size(104, 23);
- this.buttonCreateModif.TabIndex = 7;
- this.buttonCreateModif.Text = "Модификация";
- this.buttonCreateModif.UseVisualStyleBackColor = true;
- this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
+ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonDown.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Down;
+ this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonDown.Location = new System.Drawing.Point(88, 408);
+ this.buttonDown.Name = "buttonDown";
+ this.buttonDown.Size = new System.Drawing.Size(30, 30);
+ this.buttonDown.TabIndex = 6;
+ this.buttonDown.UseVisualStyleBackColor = true;
+ this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonShowOnMap
+ //
+ this.buttonShowOnMap.Location = new System.Drawing.Point(6, 302);
+ this.buttonShowOnMap.Name = "buttonShowOnMap";
+ this.buttonShowOnMap.Size = new System.Drawing.Size(188, 29);
+ 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(6, 235);
+ this.buttonShowStorage.Name = "buttonShowStorage";
+ this.buttonShowStorage.Size = new System.Drawing.Size(188, 30);
+ this.buttonShowStorage.TabIndex = 4;
+ this.buttonShowStorage.Text = "Посмотреть хранилище";
+ this.buttonShowStorage.UseVisualStyleBackColor = true;
+ this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
+ //
+ // buttonRemoveBus
+ //
+ this.buttonRemoveBus.Location = new System.Drawing.Point(6, 150);
+ this.buttonRemoveBus.Name = "buttonRemoveBus";
+ this.buttonRemoveBus.Size = new System.Drawing.Size(188, 28);
+ this.buttonRemoveBus.TabIndex = 3;
+ this.buttonRemoveBus.Text = "Удалить автобус";
+ this.buttonRemoveBus.UseVisualStyleBackColor = true;
+ this.buttonRemoveBus.Click += new System.EventHandler(this.ButtonRemoveBus_Click);
+ //
+ // maskedTextBoxPosition
+ //
+ this.maskedTextBoxPosition.Location = new System.Drawing.Point(6, 121);
+ this.maskedTextBoxPosition.Mask = "00";
+ this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
+ this.maskedTextBoxPosition.Size = new System.Drawing.Size(188, 23);
+ this.maskedTextBoxPosition.TabIndex = 2;
+ //
+ // buttonAddBus
+ //
+ this.buttonAddBus.Location = new System.Drawing.Point(6, 73);
+ this.buttonAddBus.Name = "buttonAddBus";
+ this.buttonAddBus.Size = new System.Drawing.Size(188, 28);
+ this.buttonAddBus.TabIndex = 1;
+ this.buttonAddBus.Text = "Добавить автобус";
+ this.buttonAddBus.UseVisualStyleBackColor = true;
+ this.buttonAddBus.Click += new System.EventHandler(this.ButtonAddBus_Click);
//
// comboBoxSelectorMap
//
- this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSelectorMap.FormattingEnabled = true;
this.comboBoxSelectorMap.Items.AddRange(new object[] {
"Простая карта",
"Моя карта"});
- this.comboBoxSelectorMap.Location = new System.Drawing.Point(12, 12);
+ this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 22);
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
- this.comboBoxSelectorMap.Size = new System.Drawing.Size(121, 23);
- this.comboBoxSelectorMap.TabIndex = 8;
+ this.comboBoxSelectorMap.Size = new System.Drawing.Size(188, 23);
+ this.comboBoxSelectorMap.TabIndex = 0;
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
//
- // FormMap
+ // 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, 450);
+ this.pictureBox.TabIndex = 1;
+ this.pictureBox.TabStop = false;
+ //
+ // FormMapWithSetBuses
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
- this.Controls.Add(this.comboBoxSelectorMap);
- this.Controls.Add(this.buttonCreateModif);
- this.Controls.Add(this.buttonRight);
- this.Controls.Add(this.buttonDown);
- this.Controls.Add(this.buttonLeft);
- this.Controls.Add(this.buttonUp);
- this.Controls.Add(this.buttonCreate);
- this.Controls.Add(this.pictureBoxBus);
- this.Controls.Add(this.statusStrip);
- this.Name = "FormMap";
- this.Text = "FormMap";
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBus)).EndInit();
- this.statusStrip.ResumeLayout(false);
- this.statusStrip.PerformLayout();
+ this.Controls.Add(this.pictureBox);
+ this.Controls.Add(this.groupBox1);
+ this.Name = "FormMapWithSetBuses";
+ this.Text = "Карта с набором объектов";
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.ResumeLayout(false);
- this.PerformLayout();
}
#endregion
- private PictureBox pictureBoxBus;
- private StatusStrip statusStrip;
- private ToolStripStatusLabel toolStripStatusLabelSpeed;
- private ToolStripStatusLabel toolStripStatusLabelWeight;
- private ToolStripStatusLabel toolStripStatusLabelBodyColor;
- private Button buttonCreate;
- private Button buttonUp;
- private Button buttonLeft;
- private Button buttonDown;
- private Button buttonRight;
- private Button buttonCreateModif;
+
+ private GroupBox groupBox1;
+ private PictureBox pictureBox;
private ComboBox comboBoxSelectorMap;
+ private Button buttonAddBus;
+ private MaskedTextBox maskedTextBoxPosition;
+ private Button buttonRemoveBus;
+ private Button buttonShowStorage;
+ private Button buttonShowOnMap;
+ private Button buttonLeft;
+ private Button buttonUp;
+ private Button buttonRight;
+ private Button buttonDown;
}
}
\ No newline at end of file
diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormMapWithSetBuses.cs b/DoubleDeckerBus/DoubleDeckerBus/FormMapWithSetBuses.cs
new file mode 100644
index 0000000..9b162cd
--- /dev/null
+++ b/DoubleDeckerBus/DoubleDeckerBus/FormMapWithSetBuses.cs
@@ -0,0 +1,165 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using static System.Windows.Forms.DataFormats;
+
+namespace DoubleDeckerBus
+{
+ public partial class FormMapWithSetBuses : Form
+ {
+ ///
+ /// Объект от класса карты с набором объектов
+ ///
+ private MapWithSetBusesGeneric _mapBusesCollectionGeneric;
+ ///
+ /// Конструктор
+ ///
+ public FormMapWithSetBuses()
+ {
+ InitializeComponent();
+ }
+ ///
+ /// Выбор карты
+ ///
+ ///
+ ///
+ private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ AbstractMap map = null;
+ switch (comboBoxSelectorMap.Text)
+ {
+ case "Простая карта":
+ map = new SimpleMap();
+ break;
+ case "Моя карта":
+ map = new MyMap();
+ break;
+ }
+ if (map != null)
+ {
+ _mapBusesCollectionGeneric = new
+ MapWithSetBusesGeneric(pictureBox.Width, pictureBox.Height, map);
+ }
+ else
+ {
+ _mapBusesCollectionGeneric = null;
+ }
+ }
+ ///
+ /// Добавление объекта
+ ///
+ ///
+ ///
+ private void ButtonAddBus_Click(object sender, EventArgs e)
+ {
+ if (_mapBusesCollectionGeneric == null)
+ {
+ return;
+ }
+ FormBus form = new();
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ DrawningObjectBus bus = new(form.SelectedCar);
+ if (_mapBusesCollectionGeneric + bus !=-1)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBox.Image = _mapBusesCollectionGeneric.ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
+ }
+ ///
+ /// Удаление объекта
+ ///
+ ///
+ ///
+ private void ButtonRemoveBus_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
+ {
+ return;
+ }
+ if (MessageBox.Show("Удалить объект?", "Удаление",
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
+ {
+ return;
+ }
+ int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
+ if (_mapBusesCollectionGeneric - pos!=null)
+ {
+ MessageBox.Show("Объект удален");
+ pictureBox.Image = _mapBusesCollectionGeneric.ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось удалить объект");
+ }
+ }
+ ///
+ /// Вывод набора
+ ///
+ ///
+ ///
+ private void ButtonShowStorage_Click(object sender, EventArgs e)
+ {
+ if (_mapBusesCollectionGeneric == null)
+ {
+ return;
+ }
+ pictureBox.Image = _mapBusesCollectionGeneric.ShowSet();
+ }
+ ///
+ /// Вывод карты
+ ///
+ ///
+ ///
+ private void ButtonShowOnMap_Click(object sender, EventArgs e)
+ {
+ if (_mapBusesCollectionGeneric == null)
+ {
+ return;
+ }
+ pictureBox.Image = _mapBusesCollectionGeneric.ShowOnMap();
+ }
+ ///
+ /// Перемещение
+ ///
+ ///
+ ///
+ private void ButtonMove_Click(object sender, EventArgs e)
+ {
+ if (_mapBusesCollectionGeneric == null)
+ {
+ return;
+ }
+ //получаем имя кнопки
+ string name = ((Button)sender)?.Name ?? string.Empty;
+ Direction dir = Direction.None;
+ switch (name)
+ {
+ case "buttonUp":
+ dir = Direction.Up;
+ break;
+ case "buttonDown":
+ dir = Direction.Down;
+ break;
+ case "buttonLeft":
+ dir = Direction.Left;
+ break;
+ case "buttonRight":
+ dir = Direction.Right;
+ break;
+ }
+ pictureBox.Image = _mapBusesCollectionGeneric.MoveObject(dir);
+ }
+ }
+}
diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormMap.resx b/DoubleDeckerBus/DoubleDeckerBus/FormMapWithSetBuses.resx
similarity index 93%
rename from DoubleDeckerBus/DoubleDeckerBus/FormMap.resx
rename to DoubleDeckerBus/DoubleDeckerBus/FormMapWithSetBuses.resx
index 2c0949d..f298a7b 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/FormMap.resx
+++ b/DoubleDeckerBus/DoubleDeckerBus/FormMapWithSetBuses.resx
@@ -57,7 +57,4 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- 17, 17
-
\ No newline at end of file
diff --git a/DoubleDeckerBus/DoubleDeckerBus/MapWithSetBusesGeneric.cs b/DoubleDeckerBus/DoubleDeckerBus/MapWithSetBusesGeneric.cs
index 3a2dada..1ad5045 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/MapWithSetBusesGeneric.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/MapWithSetBusesGeneric.cs
@@ -21,11 +21,11 @@ namespace DoubleDeckerBus
///
/// Размер занимаемого объектом места (ширина)
///
- private readonly int _placeSizeWidth = 210;
+ private readonly int _placeSizeWidth = 240;
///
/// Размер занимаемого объектом места (высота)
///
- private readonly int _placeSizeHeight = 90;
+ private readonly int _placeSizeHeight = 92;
///
/// Набор объектов
///
@@ -145,21 +145,12 @@ namespace DoubleDeckerBus
private void DrawBackground(Graphics g)
{
Pen pen = new(Color.Black, 3);
- Brush pointColor = new SolidBrush(Color.Orange);
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
{
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
{
+ //линия рамзетки места
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
- g.DrawLine(pen, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight,
- i * _placeSizeWidth + _placeSizeWidth / 2, (int)((j * _placeSizeHeight) - (40)));
-
- g.FillPolygon(pointColor, new Point[] {
- new Point(i * _placeSizeWidth + _placeSizeWidth / 2, (int)((j * _placeSizeHeight) - (40))),
- new Point(i * _placeSizeWidth + _placeSizeWidth / 2 - 10, (int)((j * _placeSizeHeight) - (50))),
- new Point(i * _placeSizeWidth + _placeSizeWidth / 2, (int)((j * _placeSizeHeight) - (60))),
- new Point(i * _placeSizeWidth + _placeSizeWidth / 2 + 10, (int)((j * _placeSizeHeight) - (50)))
- });
}
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, (_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
}
@@ -170,28 +161,20 @@ namespace DoubleDeckerBus
///
private void DrawBuses(Graphics g)
{
- int width = _pictureWidth / _placeSizeWidth;
- int height = _pictureHeight / _placeSizeHeight;
-
- int currentWidth = width - 1;
- int currentHeight = 0;
+ int xPosition = 10;
+ int yPosition = _pictureHeight / _placeSizeHeight - 1;
for (int i = 0; i < _setBuses.Count; i++)
{
-
- _setBuses.Get(i)?.SetObject(currentWidth * _placeSizeWidth,
- currentHeight * _placeSizeHeight,
- _pictureWidth, _pictureHeight);
+ _setBuses.Get(i)?.SetObject(xPosition, yPosition, _pictureWidth, _pictureHeight);
_setBuses.Get(i)?.DrawningObject(g);
- if (currentWidth > 0)
- currentWidth--;
- else
+ xPosition += _placeSizeWidth;
+ if (xPosition + _placeSizeWidth > _pictureWidth)
{
- currentWidth = width - 1;
- currentHeight++;
+ yPosition += _placeSizeHeight;
+ xPosition = 10;
}
- if (currentHeight > height) return;
}
}
}
diff --git a/DoubleDeckerBus/DoubleDeckerBus/Program.cs b/DoubleDeckerBus/DoubleDeckerBus/Program.cs
index 7d6fd56..66c3e0d 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/Program.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/Program.cs
@@ -11,7 +11,7 @@ namespace DoubleDeckerBus
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new FormMap());
+ Application.Run(new FormMapWithSetBuses());
}
}
}
\ No newline at end of file