diff --git a/Bus/Bus/Direction.cs b/Bus/Bus/Direction.cs
index 64530e7..74f4c53 100644
--- a/Bus/Bus/Direction.cs
+++ b/Bus/Bus/Direction.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Bus
{
- internal enum Direction
+ public enum Direction
{
None = 0,
Up = 1,
diff --git a/Bus/Bus/DrawingBus.cs b/Bus/Bus/DrawingBus.cs
index c9591ae..f8924a1 100644
--- a/Bus/Bus/DrawingBus.cs
+++ b/Bus/Bus/DrawingBus.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Bus
{
- internal class DrawingBus
+ public class DrawingBus
{
public EntityBus Bus { get; protected set; }
protected float _startPosX;
@@ -91,7 +91,8 @@ namespace Bus
//кузов
Brush br = new SolidBrush(Bus?.BodyColor ?? Color.Black);
- g.FillRectangle(br, _startPosX+11, _startPosY+11, 149, 49);
+ g.FillRectangle(br, _startPosX+ 11, _startPosY + 11, 149, 49);
+
//колеса
Brush brBlack = new SolidBrush(Color.Black);
g.FillEllipse(brBlack, _startPosX + 20, _startPosY + 50, 20, 20);
diff --git a/Bus/Bus/DrawingSportBus.cs b/Bus/Bus/DrawingSportBus.cs
index b1ebefb..aca2b36 100644
--- a/Bus/Bus/DrawingSportBus.cs
+++ b/Bus/Bus/DrawingSportBus.cs
@@ -26,13 +26,10 @@ namespace Bus
if (sportBus.BodyKit)
{
Brush br = new SolidBrush(Bus?.BodyColor ?? Color.Black);
- Brush fireBrush = new SolidBrush(Color.Red);
Pen pen1 = new(Color.Black);
+
g.DrawRectangle(pen1, _startPosX + 20, _startPosY, 150, 50);
g.FillRectangle(br, _startPosX + 21, _startPosY+1, 149, 49);
-
-
-
}
_startPosX += 10;
@@ -44,10 +41,10 @@ namespace Bus
if (sportBus.Sportline)
{
Brush brBlue = new SolidBrush(Color.LightBlue);
- g.FillRectangle(brBlue, _startPosX + 30, _startPosY + 5, 10, 14);
+ g.FillRectangle(dopBrush, _startPosX + 30, _startPosY + 5, 10, 14);
g.DrawRectangle(pen, _startPosX + 29, _startPosY + 4, 10, 15);
- g.FillRectangle(brBlue, _startPosX + 60, _startPosY + 5, 10, 14);
+ g.FillRectangle(dopBrush, _startPosX + 60, _startPosY + 5, 10, 14);
g.DrawRectangle(pen, _startPosX + 59, _startPosY + 4, 10, 15);
}
diff --git a/Bus/Bus/EntityBus.cs b/Bus/Bus/EntityBus.cs
index d69a43a..b1789d9 100644
--- a/Bus/Bus/EntityBus.cs
+++ b/Bus/Bus/EntityBus.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Bus
{
- internal class EntityBus
+ public class EntityBus
{
public int Speed { get; private set; }
public float Weight { get; private set; }
diff --git a/Bus/Bus/EntitySportBus.cs b/Bus/Bus/EntitySportBus.cs
index cdc78e8..21b2b44 100644
--- a/Bus/Bus/EntitySportBus.cs
+++ b/Bus/Bus/EntitySportBus.cs
@@ -9,6 +9,7 @@ namespace Bus
internal class EntitySportBus : EntityBus
{
public Color DopColor { get; private set; }
+ public Color DopColor1 { get; private set; }
public bool BodyKit { get; private set; }
public bool Wing { get; private set; }
public bool Sportline { get; private set; }
@@ -17,6 +18,7 @@ namespace Bus
base(speed, weight, bodyColor)
{
DopColor = dopColor;
+ DopColor1 = bodyColor;
BodyKit = bodyKit = true;
Wing = wing = true;
Sportline = sportline = true;
diff --git a/Bus/Bus/FormBus.Designer.cs b/Bus/Bus/FormBus.Designer.cs
index 57ee227..872f760 100644
--- a/Bus/Bus/FormBus.Designer.cs
+++ b/Bus/Bus/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.buttonSelectedBus = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBus)).BeginInit();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
@@ -154,11 +155,22 @@
this.buttonCreateModif.UseVisualStyleBackColor = true;
this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
//
+ // buttonSelectedBus
+ //
+ this.buttonSelectedBus.Location = new System.Drawing.Point(592, 386);
+ this.buttonSelectedBus.Name = "buttonSelectedBus";
+ this.buttonSelectedBus.Size = new System.Drawing.Size(94, 29);
+ this.buttonSelectedBus.TabIndex = 8;
+ this.buttonSelectedBus.Text = "Выбрать";
+ this.buttonSelectedBus.UseVisualStyleBackColor = true;
+ this.buttonSelectedBus.Click += new System.EventHandler(this.ButtonSelectedBus_Click);
+ //
// FormBus
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(827, 455);
+ this.Controls.Add(this.buttonSelectedBus);
this.Controls.Add(this.buttonCreateModif);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonDown);
@@ -191,5 +203,6 @@
private Button buttonDown;
private Button buttonRight;
private Button buttonCreateModif;
+ private Button buttonSelectedBus;
}
}
\ No newline at end of file
diff --git a/Bus/Bus/FormBus.cs b/Bus/Bus/FormBus.cs
index 6a98108..b0137a3 100644
--- a/Bus/Bus/FormBus.cs
+++ b/Bus/Bus/FormBus.cs
@@ -5,6 +5,8 @@ namespace Bus
private DrawingBus _bus;
+ public DrawingBus SelectedBus { get; private set; }
+
public FormBus()
{
InitializeComponent();
@@ -31,7 +33,13 @@ namespace Bus
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
- _bus = new DrawingBus(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
+ Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
+ ColorDialog dialog = new();
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ color = dialog.Color;
+ }
+ _bus = new DrawingBus(rnd.Next(100, 300), rnd.Next(1000, 2000), color);
SetData();
Draw();
}
@@ -65,12 +73,32 @@ namespace Bus
private void ButtonCreateModif_Click(object sender, EventArgs e)
{
Random rnd = new();
- _bus = new DrawingSportBus(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)),
+
+ Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
+ ColorDialog dialog = new();
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ color = dialog.Color;
+ }
+
+ Color dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
+ ColorDialog dialogDop = new();
+ if (dialogDop.ShowDialog() == DialogResult.OK)
+ {
+ dopColor = dialogDop.Color;
+ }
+
+ _bus = new DrawingSportBus(rnd.Next(100, 300), rnd.Next(1000, 2000), color, dopColor,
Convert.ToBoolean(rnd.Next(0, 1)), Convert.ToBoolean(rnd.Next(0,1)), Convert.ToBoolean(rnd.Next(0,1)));
+
SetData();
Draw();
}
+
+ private void ButtonSelectedBus_Click(object sender, EventArgs e)
+ {
+ SelectedBus = _bus;
+ DialogResult = DialogResult.OK;
+ }
}
}
\ No newline at end of file
diff --git a/Bus/Bus/FormMap.Designer.cs b/Bus/Bus/FormMap.Designer.cs
deleted file mode 100644
index 5e989ab..0000000
--- a/Bus/Bus/FormMap.Designer.cs
+++ /dev/null
@@ -1,209 +0,0 @@
-namespace Bus
-{
- partial class FormMap
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.pictureBoxBus = new System.Windows.Forms.PictureBox();
- this.statusStrip1 = 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.buttonLeft = new System.Windows.Forms.Button();
- this.buttonDown = new System.Windows.Forms.Button();
- this.buttonRight = new System.Windows.Forms.Button();
- this.buttonCreateModif = new System.Windows.Forms.Button();
- this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBus)).BeginInit();
- this.statusStrip1.SuspendLayout();
- this.SuspendLayout();
- //
- // pictureBoxBus
- //
- 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(827, 429);
- this.pictureBoxBus.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
- this.pictureBoxBus.TabIndex = 0;
- this.pictureBoxBus.TabStop = false;
- //
- // statusStrip1
- //
- this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
- this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.toolStripStatusLabelSpeed,
- this.toolStripStatusLabelWeight,
- this.toolStripStatusLabelBodyColor});
- this.statusStrip1.Location = new System.Drawing.Point(0, 429);
- this.statusStrip1.Name = "statusStrip1";
- this.statusStrip1.Size = new System.Drawing.Size(827, 26);
- this.statusStrip1.TabIndex = 1;
- this.statusStrip1.Text = "statusStrip1";
- //
- // toolStripStatusLabelSpeed
- //
- this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
- this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(76, 20);
- this.toolStripStatusLabelSpeed.Text = "Скорость:";
- //
- // toolStripStatusLabelWeight
- //
- this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
- this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(36, 20);
- this.toolStripStatusLabelWeight.Text = "Вес:";
- //
- // toolStripStatusLabelBodyColor
- //
- this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
- this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(45, 20);
- 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(11, 384);
- this.buttonCreate.Name = "buttonCreate";
- this.buttonCreate.Size = new System.Drawing.Size(94, 29);
- 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::Bus.Properties.Resources.Frame_3;
- this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonUp.Location = new System.Drawing.Point(744, 346);
- this.buttonUp.Name = "buttonUp";
- this.buttonUp.Size = new System.Drawing.Size(40, 40);
- this.buttonUp.TabIndex = 3;
- this.buttonUp.UseVisualStyleBackColor = true;
- this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
- //
- // buttonLeft
- //
- this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonLeft.BackgroundImage = global::Bus.Properties.Resources.Frame_6;
- this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonLeft.Location = new System.Drawing.Point(704, 386);
- this.buttonLeft.Name = "buttonLeft";
- this.buttonLeft.Size = new System.Drawing.Size(40, 40);
- this.buttonLeft.TabIndex = 4;
- this.buttonLeft.UseVisualStyleBackColor = true;
- this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
- //
- // buttonDown
- //
- this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonDown.BackgroundImage = global::Bus.Properties.Resources.Frame_5;
- this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonDown.Location = new System.Drawing.Point(744, 386);
- this.buttonDown.Name = "buttonDown";
- this.buttonDown.Size = new System.Drawing.Size(40, 40);
- this.buttonDown.TabIndex = 5;
- this.buttonDown.UseVisualStyleBackColor = true;
- this.buttonDown.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::Bus.Properties.Resources.Frame_4;
- this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonRight.Location = new System.Drawing.Point(784, 386);
- this.buttonRight.Name = "buttonRight";
- this.buttonRight.Size = new System.Drawing.Size(40, 40);
- this.buttonRight.TabIndex = 6;
- this.buttonRight.UseVisualStyleBackColor = true;
- this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
- //
- // buttonCreateModif
- //
- this.buttonCreateModif.Location = new System.Drawing.Point(111, 384);
- this.buttonCreateModif.Name = "buttonCreateModif";
- this.buttonCreateModif.Size = new System.Drawing.Size(141, 29);
- this.buttonCreateModif.TabIndex = 7;
- this.buttonCreateModif.Text = "Модификация";
- this.buttonCreateModif.UseVisualStyleBackColor = true;
- this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_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(9, 8);
- this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
- this.comboBoxSelectorMap.Size = new System.Drawing.Size(151, 28);
- this.comboBoxSelectorMap.TabIndex = 8;
- this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
- //
- // FormMap
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(827, 455);
- 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.statusStrip1);
- this.Name = "FormMap";
- this.Text = "Карта";
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBus)).EndInit();
- this.statusStrip1.ResumeLayout(false);
- this.statusStrip1.PerformLayout();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private PictureBox pictureBoxBus;
- private StatusStrip statusStrip1;
- 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 ComboBox comboBoxSelectorMap;
- }
-}
\ No newline at end of file
diff --git a/Bus/Bus/FormMap.cs b/Bus/Bus/FormMap.cs
deleted file mode 100644
index f1ee503..0000000
--- a/Bus/Bus/FormMap.cs
+++ /dev/null
@@ -1,90 +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 Bus
-{
- public partial class FormMap : Form
- {
- private AbstractMap _abstractMap;
-
- public FormMap()
- {
- InitializeComponent();
- _abstractMap = new SimpleMap();
- }
-
- private void SetData(DrawingBus 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 DrawingObjectBus(bus));
- }
-
-
- private void ButtonCreate_Click(object sender, EventArgs e)
- {
- Random rnd = new();
- var bus = new DrawingBus(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
- SetData(bus);
-
- }
- 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 bus = new DrawingSportBus(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, 1)), Convert.ToBoolean(rnd.Next(0, 1)), Convert.ToBoolean(rnd.Next(0, 1)));
- SetData(bus);
-
- }
-
- private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
- {
- switch (comboBoxSelectorMap.Text)
- {
- case "Простая карта":
- _abstractMap = new SimpleMap();
- break;
- case "Ёще одна карта":
- _abstractMap = new MyMap();
- break;
- }
- }
- }
-}
diff --git a/Bus/Bus/FormMapWithSetDoubleDeckerBus.Designer.cs b/Bus/Bus/FormMapWithSetDoubleDeckerBus.Designer.cs
new file mode 100644
index 0000000..4a7771e
--- /dev/null
+++ b/Bus/Bus/FormMapWithSetDoubleDeckerBus.Designer.cs
@@ -0,0 +1,214 @@
+namespace Bus
+{
+ partial class FormMapWithSetDoubleDeckerBus
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.buttonRight = new System.Windows.Forms.Button();
+ this.buttonDown = new System.Windows.Forms.Button();
+ this.buttonLeft = new System.Windows.Forms.Button();
+ this.buttonUp = new System.Windows.Forms.Button();
+ this.buttonShowOnMap = new System.Windows.Forms.Button();
+ this.buttonShowStorage = new System.Windows.Forms.Button();
+ this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
+ this.buttonRemoveBus = new System.Windows.Forms.Button();
+ this.buttonAddBus = new System.Windows.Forms.Button();
+ this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
+ this.pictureBox = new System.Windows.Forms.PictureBox();
+ this.groupBox1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
+ this.SuspendLayout();
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.buttonRight);
+ this.groupBox1.Controls.Add(this.buttonDown);
+ this.groupBox1.Controls.Add(this.buttonLeft);
+ this.groupBox1.Controls.Add(this.buttonUp);
+ this.groupBox1.Controls.Add(this.buttonShowOnMap);
+ this.groupBox1.Controls.Add(this.buttonShowStorage);
+ this.groupBox1.Controls.Add(this.maskedTextBoxPosition);
+ this.groupBox1.Controls.Add(this.buttonRemoveBus);
+ 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(550, 0);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(250, 450);
+ this.groupBox1.TabIndex = 0;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Инструменты";
+ //
+ // buttonRight
+ //
+ this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonRight.BackgroundImage = global::Bus.Properties.Resources.Frame_4;
+ this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonRight.Location = new System.Drawing.Point(95, 398);
+ this.buttonRight.Name = "buttonRight";
+ this.buttonRight.Size = new System.Drawing.Size(40, 40);
+ this.buttonRight.TabIndex = 10;
+ this.buttonRight.UseVisualStyleBackColor = true;
+ this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonDown
+ //
+ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonDown.BackgroundImage = global::Bus.Properties.Resources.Frame_5;
+ this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonDown.Location = new System.Drawing.Point(55, 398);
+ this.buttonDown.Name = "buttonDown";
+ this.buttonDown.Size = new System.Drawing.Size(40, 40);
+ this.buttonDown.TabIndex = 9;
+ this.buttonDown.UseVisualStyleBackColor = true;
+ this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonLeft
+ //
+ this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonLeft.BackgroundImage = global::Bus.Properties.Resources.Frame_6;
+ this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonLeft.Location = new System.Drawing.Point(15, 398);
+ this.buttonLeft.Name = "buttonLeft";
+ this.buttonLeft.Size = new System.Drawing.Size(40, 40);
+ this.buttonLeft.TabIndex = 8;
+ this.buttonLeft.UseVisualStyleBackColor = true;
+ this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonUp
+ //
+ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonUp.BackgroundImage = global::Bus.Properties.Resources.Frame_3;
+ this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonUp.Location = new System.Drawing.Point(55, 358);
+ this.buttonUp.Name = "buttonUp";
+ this.buttonUp.Size = new System.Drawing.Size(40, 40);
+ this.buttonUp.TabIndex = 7;
+ this.buttonUp.UseVisualStyleBackColor = true;
+ this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonShowOnMap
+ //
+ this.buttonShowOnMap.Location = new System.Drawing.Point(6, 281);
+ this.buttonShowOnMap.Name = "buttonShowOnMap";
+ this.buttonShowOnMap.Size = new System.Drawing.Size(193, 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, 246);
+ this.buttonShowStorage.Name = "buttonShowStorage";
+ this.buttonShowStorage.Size = new System.Drawing.Size(193, 29);
+ this.buttonShowStorage.TabIndex = 4;
+ this.buttonShowStorage.Text = "Посмотреть хранилище";
+ this.buttonShowStorage.UseVisualStyleBackColor = true;
+ this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
+ //
+ // maskedTextBoxPosition
+ //
+ this.maskedTextBoxPosition.Location = new System.Drawing.Point(6, 122);
+ this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
+ this.maskedTextBoxPosition.Size = new System.Drawing.Size(100, 27);
+ this.maskedTextBoxPosition.TabIndex = 11;
+ //
+ // buttonRemoveBus
+ //
+ this.buttonRemoveBus.Location = new System.Drawing.Point(6, 155);
+ this.buttonRemoveBus.Name = "buttonRemoveBus";
+ this.buttonRemoveBus.Size = new System.Drawing.Size(151, 32);
+ this.buttonRemoveBus.TabIndex = 2;
+ this.buttonRemoveBus.Text = "Удалить автобус";
+ this.buttonRemoveBus.UseVisualStyleBackColor = true;
+ this.buttonRemoveBus.Click += new System.EventHandler(this.ButtonRemoveBus_Click);
+ //
+ // buttonAddBus
+ //
+ this.buttonAddBus.Location = new System.Drawing.Point(6, 83);
+ this.buttonAddBus.Name = "buttonAddBus";
+ this.buttonAddBus.Size = new System.Drawing.Size(151, 33);
+ this.buttonAddBus.TabIndex = 1;
+ this.buttonAddBus.Text = "Добавить автобус";
+ this.buttonAddBus.UseVisualStyleBackColor = true;
+ this.buttonAddBus.Click += new System.EventHandler(this.ButtonAddBus_Click);
+ //
+ // comboBoxSelectorMap
+ //
+ this.comboBoxSelectorMap.FormattingEnabled = true;
+ this.comboBoxSelectorMap.Items.AddRange(new object[] {
+ "Простая карта",
+ "Водная карта"});
+ this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 26);
+ this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
+ this.comboBoxSelectorMap.Size = new System.Drawing.Size(151, 28);
+ 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(550, 450);
+ this.pictureBox.TabIndex = 1;
+ this.pictureBox.TabStop = false;
+ //
+ // FormMapWithSetDoubleDeckerBus
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.pictureBox);
+ this.Controls.Add(this.groupBox1);
+ this.Name = "FormMapWithSetDoubleDeckerBus";
+ this.Text = "Автобус";
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private GroupBox groupBox1;
+ private PictureBox pictureBox;
+ private Button buttonShowOnMap;
+ private Button buttonShowStorage;
+ private MaskedTextBox maskedTextBoxPosition;
+ private Button buttonRemoveBus;
+ private Button buttonAddBus;
+ private ComboBox comboBoxSelectorMap;
+ private Button buttonRight;
+ private Button buttonDown;
+ private Button buttonLeft;
+ private Button buttonUp;
+ }
+}
\ No newline at end of file
diff --git a/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs b/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs
new file mode 100644
index 0000000..f10d972
--- /dev/null
+++ b/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs
@@ -0,0 +1,149 @@
+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 Bus
+{
+ public partial class FormMapWithSetDoubleDeckerBus : Form
+ {
+ private MapWithSetDoubleDeckerBusGeneric _mapBusCollectionGeneric;
+
+ //DrawingBus SelectedBus { get; private set; }
+
+ public FormMapWithSetDoubleDeckerBus()
+ {
+ InitializeComponent();
+ AbstractMap map = new SimpleMap();
+ _mapBusCollectionGeneric = new MapWithSetDoubleDeckerBusGeneric(
+ pictureBox.Width, pictureBox.Height, map);
+
+ }
+
+ 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)
+ {
+ _mapBusCollectionGeneric = new MapWithSetDoubleDeckerBusGeneric(pictureBox.Width, pictureBox.Height, map);
+ }
+
+ else
+ {
+ _mapBusCollectionGeneric = null;
+ }
+ }
+
+ private void ButtonAddBus_Click(object sender, EventArgs e)
+ {
+ if (_mapBusCollectionGeneric == null)
+ {
+ return;
+ }
+ FormBus form = new();
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.SelectedBus == null)
+ {
+ MessageBox.Show("Сначала создайте объект");
+ return;
+ }
+
+ DrawingObjectBus bus = new(form.SelectedBus);
+
+ if (_mapBusCollectionGeneric + bus != -1)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBox.Image = _mapBusCollectionGeneric.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 (_mapBusCollectionGeneric - pos != null)
+ {
+ MessageBox.Show("Объект удален");
+ pictureBox.Image = _mapBusCollectionGeneric.ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось удалить объект");
+ }
+ }
+
+ private void ButtonShowStorage_Click(object sender, EventArgs e)
+ {
+ if (_mapBusCollectionGeneric == null)
+ {
+ return;
+ }
+ pictureBox.Image = _mapBusCollectionGeneric.ShowSet();
+ }
+
+ private void ButtonShowOnMap_Click(object sender, EventArgs e)
+ {
+ if (_mapBusCollectionGeneric == null)
+ {
+ return;
+ }
+ pictureBox.Image = _mapBusCollectionGeneric.ShowOnMap();
+ }
+
+ private void ButtonMove_Click(object sender, EventArgs e)
+ {
+ if (_mapBusCollectionGeneric == 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 = _mapBusCollectionGeneric.MoveObject(dir);
+ }
+ }
+}
diff --git a/Bus/Bus/FormMap.resx b/Bus/Bus/FormMapWithSetDoubleDeckerBus.resx
similarity index 93%
rename from Bus/Bus/FormMap.resx
rename to Bus/Bus/FormMapWithSetDoubleDeckerBus.resx
index 5cb320f..f298a7b 100644
--- a/Bus/Bus/FormMap.resx
+++ b/Bus/Bus/FormMapWithSetDoubleDeckerBus.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/Bus/Bus/MapWithSetDoubleDeckerBusGeneric.cs b/Bus/Bus/MapWithSetDoubleDeckerBusGeneric.cs
new file mode 100644
index 0000000..83cb173
--- /dev/null
+++ b/Bus/Bus/MapWithSetDoubleDeckerBusGeneric.cs
@@ -0,0 +1,146 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Bus
+{
+ internal class MapWithSetDoubleDeckerBusGeneric
+ where T : class, IDrawingObject
+ where U : AbstractMap
+ {
+ private readonly int _pictureWidth;
+ private readonly int _pictureHeight;
+ private readonly int _placeSizeWidth = 210;
+ private readonly int _placeSizeHeight = 90;
+ private readonly SetDoubleDeckerBusGeneric _setBus;
+ private readonly U _map;
+
+ public MapWithSetDoubleDeckerBusGeneric(int picWidth, int picHeight, U map)
+ {
+ int width = picWidth / _placeSizeWidth;
+ int height = picHeight / _placeSizeHeight;
+ _setBus = new SetDoubleDeckerBusGeneric(width * height);
+ _pictureWidth = picWidth;
+ _pictureHeight = picHeight;
+ _map = map;
+ }
+
+ public static int operator +(MapWithSetDoubleDeckerBusGeneric map, T bus)
+ {
+ return map._setBus.Insert(bus);
+ }
+
+ public static T operator -(MapWithSetDoubleDeckerBusGeneric map, int position)
+ {
+ return map._setBus.Remove(position);
+ }
+
+ public Bitmap ShowSet()
+ {
+ Bitmap bmp = new(_pictureWidth, _pictureHeight);
+ Graphics gr = Graphics.FromImage(bmp);
+ DrawBackground(gr);
+ DrawBus(gr);
+ return bmp;
+ }
+
+ public Bitmap ShowOnMap()
+ {
+ Shaking();
+ for (int i = 0; i< _setBus.Count; i++)
+ {
+ var bus = _setBus.Get(i);
+ if (bus != null)
+ {
+ return _map.CreateMap(_pictureWidth, _pictureHeight, bus);
+ }
+ }
+ return new(_pictureWidth, _pictureHeight);
+ }
+
+ public Bitmap MoveObject(Direction direction)
+ {
+ if (_map != null)
+ {
+ return _map.MoveObject(direction);
+ }
+ return new(_pictureWidth, _pictureHeight);
+ }
+
+ private void Shaking()
+ {
+ int j = _setBus.Count - 1;
+ for (int i = 0; i<_setBus.Count;i++)
+ {
+ if(_setBus.Get(i) == null)
+ {
+ for(; j > i; j--)
+ {
+ var bus = _setBus.Get(j);
+ if (bus != null)
+ {
+ _setBus.Insert(bus, i);
+ _setBus.Remove(j);
+ break;
+ }
+ }
+ if (j <= i)
+ {
+ return;
+ }
+ }
+ }
+ }
+
+ 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);
+ }
+ }
+
+ private void DrawBus(Graphics g)
+ {
+ int width = _pictureWidth / _placeSizeWidth;
+ int height = _pictureHeight / _placeSizeHeight;
+
+ int currentWidth = width - 1;
+ int currentHeight = 0;
+
+ for (int i = 0; i < _setBus.Count; i++)
+ {
+ _setBus.Get(i)?.SetObject(currentWidth * _placeSizeWidth,
+ currentHeight * _placeSizeHeight,
+ _pictureWidth, _pictureHeight);
+ _setBus.Get(i)?.DrawingObject(g);
+
+ if (currentWidth > 0)
+ currentWidth--;
+ else
+ {
+ currentWidth = width - 1;
+ currentHeight++;
+ }
+ if (currentHeight > height) return;
+ }
+ }
+ }
+}
diff --git a/Bus/Bus/Program.cs b/Bus/Bus/Program.cs
index eab9d18..265ea7c 100644
--- a/Bus/Bus/Program.cs
+++ b/Bus/Bus/Program.cs
@@ -11,7 +11,7 @@ namespace Bus
// 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 FormMapWithSetDoubleDeckerBus());
}
}
}
\ No newline at end of file
diff --git a/Bus/Bus/SetDoubleDeckerBusGeneric.cs b/Bus/Bus/SetDoubleDeckerBusGeneric.cs
new file mode 100644
index 0000000..70c05f7
--- /dev/null
+++ b/Bus/Bus/SetDoubleDeckerBusGeneric.cs
@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Bus
+{
+ internal class SetDoubleDeckerBusGeneric
+ where T : class
+ {
+ private readonly T[] _places;
+ public int Count => _places.Length;
+ private int BusPlaces = 0;
+
+ public SetDoubleDeckerBusGeneric(int count)
+ {
+ _places = new T[count];
+ }
+
+ public int Insert(T bus)
+ {
+ return Insert(bus, 0);
+ }
+
+ public int Insert(T bus, int position)
+ {
+ if (position < 0 || position >= _places.Length || BusPlaces == _places.Length)
+ {
+ return -1;
+ }
+ BusPlaces++;
+ while (_places[position] != null)
+ {
+ for (int i = _places.Length - 1; i > 0; --i)
+ {
+ if (_places[i] == null && _places[i - 1] != null)
+ {
+ _places[i] = _places[i - 1];
+ _places[i - 1] = null;
+ }
+ }
+ }
+ _places[position] = bus;
+ return position;
+ }
+
+ public T Remove(int position)
+ {
+ if (position < 0 || position >= _places.Length) return null;
+ T savedBus = _places[position];
+ _places[position] = null;
+ return savedBus;
+ }
+
+ public T Get(int position)
+ {
+ if (position < 0 || position >= _places.Length) return null;
+ return _places[position];
+ }
+ }
+}