diff --git a/HoistingCrane/HoistingCrane/FormHoistingCrane.Designer.cs b/HoistingCrane/HoistingCrane/FormHoistingCrane.Designer.cs
index a85331e..6418a51 100644
--- a/HoistingCrane/HoistingCrane/FormHoistingCrane.Designer.cs
+++ b/HoistingCrane/HoistingCrane/FormHoistingCrane.Designer.cs
@@ -2,9 +2,15 @@
{
partial class FormHoistingCrane
{
+ ///
+ /// 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))
@@ -15,6 +21,11 @@
}
#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.buttonUp = new System.Windows.Forms.Button();
@@ -22,15 +33,19 @@
this.buttonRight = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.buttonCreate = new System.Windows.Forms.Button();
- this.statusStrip1 = new System.Windows.Forms.StatusStrip();
+ 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.pictureBoxHoistingCrane = new System.Windows.Forms.PictureBox();
- this.statusStrip1.SuspendLayout();
+ this.buttonCreateModify = new System.Windows.Forms.Button();
+ this.buttonSelect = new System.Windows.Forms.Button();
+ this.statusStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxHoistingCrane)).BeginInit();
this.SuspendLayout();
-
+ //
+ // buttonUp
+ //
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUp.BackgroundImage = global::HoistingCrane.Properties.Resources.up;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
@@ -40,7 +55,9 @@
this.buttonUp.TabIndex = 0;
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::HoistingCrane.Properties.Resources.left;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
@@ -50,7 +67,9 @@
this.buttonLeft.TabIndex = 1;
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.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::HoistingCrane.Properties.Resources.right;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
@@ -60,7 +79,9 @@
this.buttonRight.TabIndex = 2;
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::HoistingCrane.Properties.Resources.down;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
@@ -70,7 +91,9 @@
this.buttonDown.TabIndex = 3;
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
-
+ //
+ // 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";
@@ -79,51 +102,87 @@
this.buttonCreate.Text = "Создать";
this.buttonCreate.UseVisualStyleBackColor = true;
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
-
- this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ //
+ // statusStrip
+ //
+ this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabelSpeed,
this.toolStripStatusLabelWeight,
this.toolStripStatusLabelBodyColor});
- this.statusStrip1.Location = new System.Drawing.Point(0, 428);
- this.statusStrip1.Name = "statusStrip1";
- this.statusStrip1.Size = new System.Drawing.Size(800, 22);
- this.statusStrip1.TabIndex = 5;
- this.statusStrip1.Text = "statusStrip1";
-
+ 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 = 5;
+ this.statusStrip.Text = "statusStrip";
+ //
+ // 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 = "Цвет:";
-
+ //
+ // pictureBoxHoistingCrane
+ //
this.pictureBoxHoistingCrane.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxHoistingCrane.Location = new System.Drawing.Point(0, 0);
this.pictureBoxHoistingCrane.Name = "pictureBoxHoistingCrane";
- this.pictureBoxHoistingCrane.Size = new System.Drawing.Size(800, 450);
+ this.pictureBoxHoistingCrane.Size = new System.Drawing.Size(800, 428);
+ this.pictureBoxHoistingCrane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBoxHoistingCrane.TabIndex = 6;
this.pictureBoxHoistingCrane.TabStop = false;
this.pictureBoxHoistingCrane.Click += new System.EventHandler(this.pictureBoxHoistingCrane_Click);
+ this.pictureBoxHoistingCrane.Resize += new System.EventHandler(this.PictureBoxHoistingCrane_Resize);
+ //
+ // buttonCreateModify
+ //
+ this.buttonCreateModify.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.buttonCreateModify.Location = new System.Drawing.Point(93, 393);
+ this.buttonCreateModify.Name = "buttonCreateModify";
+ this.buttonCreateModify.Size = new System.Drawing.Size(100, 23);
+ this.buttonCreateModify.TabIndex = 7;
+ this.buttonCreateModify.Text = "Модификация";
+ this.buttonSelect.Location = new System.Drawing.Point(551, 390);
+ this.buttonSelect.Name = "buttonSelect";
+ this.buttonSelect.Size = new System.Drawing.Size(75, 23);
+ this.buttonSelect.TabIndex = 8;
+ this.buttonSelect.Text = "Выбрать";
+ this.buttonSelect.UseVisualStyleBackColor = true;
+ this.buttonSelect.Click += new System.EventHandler(this.ButtonSelect_Click);
+ //
+ this.buttonCreateModify.UseVisualStyleBackColor = true;
+ this.buttonCreateModify.Click += new System.EventHandler(this.ButtonCreateModify_Click);
+ //
+ // FormHoistingCrane
+ //
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.statusStrip1);
+ this.Controls.Add(this.buttonSelect);
+ this.Controls.Add(this.buttonCreateModify);
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.pictureBoxHoistingCrane);
+ this.Controls.Add(this.statusStrip);
this.Name = "FormHoistingCrane";
this.Text = "Подъёмный кран";
- this.statusStrip1.ResumeLayout(false);
- this.statusStrip1.PerformLayout();
+ this.statusStrip.ResumeLayout(false);
+ this.statusStrip.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxHoistingCrane)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -131,15 +190,18 @@
}
#endregion
+
private Button buttonUp;
private Button buttonLeft;
private Button buttonRight;
private Button buttonDown;
private Button buttonCreate;
- private StatusStrip statusStrip1;
+ private StatusStrip statusStrip;
private ToolStripStatusLabel toolStripStatusLabelSpeed;
private ToolStripStatusLabel toolStripStatusLabelWeight;
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
private PictureBox pictureBoxHoistingCrane;
+ private Button buttonCreateModify;
+ private Button buttonSelect;
}
}
\ No newline at end of file
diff --git a/HoistingCrane/HoistingCrane/FormHoistingCrane.cs b/HoistingCrane/HoistingCrane/FormHoistingCrane.cs
index 6c738b9..a31b615 100644
--- a/HoistingCrane/HoistingCrane/FormHoistingCrane.cs
+++ b/HoistingCrane/HoistingCrane/FormHoistingCrane.cs
@@ -2,7 +2,7 @@
{
public partial class FormHoistingCrane : Form
{
- private DrawingHoistingCrane _hoistingCrane;
+ private DrawingHoistingCrane _HoistingCrane;
public DrawingHoistingCrane SelectedHoistingCrane { get; private set; }
public FormHoistingCrane()
{
@@ -13,17 +13,17 @@
{
Bitmap bmp = new(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
Graphics gr = Graphics.FromImage(bmp);
- _hoistingCrane?.DrawTransport(gr);
+ _HoistingCrane?.DrawTransport(gr);
pictureBoxHoistingCrane.Image = bmp;
}
private void SetData()
{
Random rnd = new();
- _hoistingCrane.SetPosition(rnd.Next(80, 100), rnd.Next(80, 100), pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
- toolStripStatusLabelSpeed.Text = $"Скорость: {_hoistingCrane.HoistingCrane.Speed}";
- toolStripStatusLabelWeight.Text = $"Вес: {_hoistingCrane.HoistingCrane.Weight}";
- toolStripStatusLabelBodyColor.Text = $"Цвет:{_hoistingCrane.HoistingCrane.BodyColor.Name}";
+ _HoistingCrane.SetPosition(rnd.Next(80, 100), rnd.Next(80, 100), pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
+ toolStripStatusLabelSpeed.Text = $"Скорость: {_HoistingCrane.HoistingCrane.Speed}";
+ toolStripStatusLabelWeight.Text = $"Вес: {_HoistingCrane.HoistingCrane.Weight}";
+ toolStripStatusLabelBodyColor.Text = $"Цвет:{_HoistingCrane.HoistingCrane.BodyColor.Name}";
}
private void ButtonCreate_Click(object sender, EventArgs e)
@@ -36,7 +36,7 @@
{
color = dialog.Color;
}
- _hoistingCrane = new DrawingHoistingCrane(rnd.Next(30, 100), rnd.Next(300, 500), color);
+ _HoistingCrane = new DrawingHoistingCrane(rnd.Next(30, 100), rnd.Next(300, 500), color);
SetData();
Draw();
}
@@ -47,16 +47,16 @@
switch (name)
{
case "buttonUp":
- _hoistingCrane?.MoveTransport(Direction.Up);
+ _HoistingCrane?.MoveTransport(Direction.Up);
break;
case "buttonDown":
- _hoistingCrane?.MoveTransport(Direction.Down);
+ _HoistingCrane?.MoveTransport(Direction.Down);
break;
case "buttonLeft":
- _hoistingCrane?.MoveTransport(Direction.Left);
+ _HoistingCrane?.MoveTransport(Direction.Left);
break;
case "buttonRight":
- _hoistingCrane?.MoveTransport(Direction.Right);
+ _HoistingCrane?.MoveTransport(Direction.Right);
break;
}
Draw();
@@ -64,7 +64,7 @@
private void PictureBoxHoistingCrane_Resize(object sender, EventArgs e)
{
- _hoistingCrane?.ChangeBorders(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
+ _HoistingCrane?.ChangeBorders(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
Draw();
}
@@ -85,7 +85,7 @@
{
advancedSelectedColor = dialogDop.Color;
}
- _hoistingCrane = new DrawingAdvancedHoistingCrane(rnd.Next(30, 100), rnd.Next(300, 500),
+ _HoistingCrane = new DrawingAdvancedHoistingCrane(rnd.Next(30, 100), rnd.Next(300, 500),
selectedColor, advancedSelectedColor, Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
SetData();
Draw();
@@ -97,13 +97,8 @@
}
private void ButtonSelect_Click(object sender, EventArgs e)
{
- SelectedHoistingCrane = _hoistingCrane;
+ SelectedHoistingCrane = _HoistingCrane;
DialogResult = DialogResult.OK;
}
- private void pictureBoxHoistingCrane_Resize(object sender, EventArgs e)
- {
- _hoistingCrane?.ChangeBorders(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
- Draw();
- }
}
}
\ No newline at end of file
diff --git a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.Designer.cs b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.Designer.cs
new file mode 100644
index 0000000..554be16
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.Designer.cs
@@ -0,0 +1,231 @@
+namespace HoistingCrane
+{
+ partial class FormMapWithSetHoistingCrane
+ {
+ ///
+ /// Required designer variable.
+ ///
+ ///
+ /// 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.groupBoxTools = new System.Windows.Forms.GroupBox();
+ this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
+ this.buttonRemoveHoistingCrane = new System.Windows.Forms.Button();
+ this.buttonShowStorage = new System.Windows.Forms.Button();
+ this.buttonDown = new System.Windows.Forms.Button();
+ this.buttonRight = 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.buttonAddHoistingCrane = new System.Windows.Forms.Button();
+ this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
+ this.pictureBox = new System.Windows.Forms.PictureBox();
+ this.groupBoxTools.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
+ this.SuspendLayout();
+ //
+ // groupBoxTools
+ //
+ this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
+ this.groupBoxTools.Controls.Add(this.buttonRemoveHoistingCrane);
+ this.groupBoxTools.Controls.Add(this.buttonShowStorage);
+ this.groupBoxTools.Controls.Add(this.buttonDown);
+ this.groupBoxTools.Controls.Add(this.buttonRight);
+ this.groupBoxTools.Controls.Add(this.buttonLeft);
+ this.groupBoxTools.Controls.Add(this.buttonUp);
+ this.groupBoxTools.Controls.Add(this.buttonShowOnMap);
+ this.groupBoxTools.Controls.Add(this.buttonAddHoistingCrane);
+ this.groupBoxTools.Controls.Add(this.comboBoxSelectorMap);
+ this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
+ this.groupBoxTools.Location = new System.Drawing.Point(811, 0);
+ this.groupBoxTools.Name = "groupBoxTools";
+ this.groupBoxTools.Size = new System.Drawing.Size(204, 554);
+ this.groupBoxTools.TabIndex = 0;
+ this.groupBoxTools.TabStop = false;
+ this.groupBoxTools.Text = "Инструменты";
+ //
+ // maskedTextBoxPosition
+ //
+ this.maskedTextBoxPosition.Location = new System.Drawing.Point(17, 166);
+ this.maskedTextBoxPosition.Mask = "00";
+ this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
+ this.maskedTextBoxPosition.Size = new System.Drawing.Size(175, 23);
+ this.maskedTextBoxPosition.TabIndex = 2;
+ this.maskedTextBoxPosition.ValidatingType = typeof(int);
+ //
+ // buttonRemoveHoistingCrane
+ //
+ this.buttonRemoveHoistingCrane.Location = new System.Drawing.Point(17, 195);
+ this.buttonRemoveHoistingCrane.Name = "buttonRemoveHoistingCrane";
+ this.buttonRemoveHoistingCrane.Size = new System.Drawing.Size(175, 35);
+ this.buttonRemoveHoistingCrane.TabIndex = 3;
+ this.buttonRemoveHoistingCrane.Text = "Удалить подъёмный кран";
+ this.buttonRemoveHoistingCrane.UseVisualStyleBackColor = true;
+ this.buttonRemoveHoistingCrane.Click += new System.EventHandler(this.ButtonRemoveHoistingCrane_Click);
+ //
+ // buttonShowStorage
+ //
+ this.buttonShowStorage.Location = new System.Drawing.Point(17, 287);
+ this.buttonShowStorage.Name = "buttonShowStorage";
+ this.buttonShowStorage.Size = new System.Drawing.Size(175, 35);
+ this.buttonShowStorage.TabIndex = 4;
+ this.buttonShowStorage.Text = "Посмотреть хранилище";
+ this.buttonShowStorage.UseVisualStyleBackColor = true;
+ this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
+ //
+ // buttonDown
+ //
+ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonDown.BackgroundImage = global::HoistingCrane.Properties.Resources.down;
+ this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonDown.Location = new System.Drawing.Point(91, 504);
+ this.buttonDown.Name = "buttonDown";
+ this.buttonDown.Size = new System.Drawing.Size(30, 30);
+ this.buttonDown.TabIndex = 10;
+ 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::HoistingCrane.Properties.Resources.right;
+ this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonRight.Location = new System.Drawing.Point(127, 504);
+ this.buttonRight.Name = "buttonRight";
+ this.buttonRight.Size = new System.Drawing.Size(30, 30);
+ this.buttonRight.TabIndex = 9;
+ this.buttonRight.UseVisualStyleBackColor = true;
+ this.buttonRight.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::HoistingCrane.Properties.Resources.left;
+ this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonLeft.Location = new System.Drawing.Point(55, 504);
+ this.buttonLeft.Name = "buttonLeft";
+ this.buttonLeft.Size = new System.Drawing.Size(30, 30);
+ 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::HoistingCrane.Properties.Resources.up;
+ this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonUp.Location = new System.Drawing.Point(91, 468);
+ this.buttonUp.Name = "buttonUp";
+ this.buttonUp.Size = new System.Drawing.Size(30, 30);
+ 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(17, 391);
+ this.buttonShowOnMap.Name = "buttonShowOnMap";
+ this.buttonShowOnMap.Size = new System.Drawing.Size(175, 35);
+ this.buttonShowOnMap.TabIndex = 5;
+ this.buttonShowOnMap.Text = "Посмотреть карту";
+ this.buttonShowOnMap.UseVisualStyleBackColor = true;
+ this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
+ //
+ // buttonAddHoistingCrane
+ //
+ this.buttonAddHoistingCrane.Location = new System.Drawing.Point(17, 106);
+ this.buttonAddHoistingCrane.Name = "buttonAddWarship";
+ this.buttonAddHoistingCrane.Size = new System.Drawing.Size(175, 35);
+ this.buttonAddHoistingCrane.TabIndex = 1;
+ this.buttonAddHoistingCrane.Text = "Добавить подъёмный кран";
+ this.buttonAddHoistingCrane.UseVisualStyleBackColor = true;
+ this.buttonAddHoistingCrane.Click += new System.EventHandler(this.ButtonAddHoistingCrane_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(17, 32);
+ this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
+ this.comboBoxSelectorMap.Size = new System.Drawing.Size(175, 23);
+ 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(811, 554);
+ this.pictureBox.TabIndex = 1;
+ this.pictureBox.TabStop = false;
+ this.pictureBox.Click += new System.EventHandler(this.pictureBox_Click);
+ //
+ // FormMapWithSetHoistingCrane
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(1015, 554);
+ this.Controls.Add(this.pictureBox);
+ this.Controls.Add(this.groupBoxTools);
+ this.Name = "FormMapWithSetHoistingCrane";
+ this.Text = "Карта с набором объектов";
+ this.groupBoxTools.ResumeLayout(false);
+ this.groupBoxTools.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private GroupBox groupBoxTools;
+ private PictureBox pictureBox;
+ private ComboBox comboBoxSelectorMap;
+ private Button buttonShowOnMap;
+ private Button buttonAddHoistingCrane;
+ private Button buttonDown;
+ private Button buttonRight;
+ private Button buttonLeft;
+ private Button buttonUp;
+ private Button buttonShowStorage;
+ private Button buttonRemoveHoistingCrane;
+ private MaskedTextBox maskedTextBoxPosition;
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs
new file mode 100644
index 0000000..8784862
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs
@@ -0,0 +1,139 @@
+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 HoistingCrane
+{
+ public partial class FormMapWithSetHoistingCrane : Form
+ {
+
+ private MapWithSetHoistingCraneGeneric _mapHoistingCraneCollectionGeneric;
+
+ public FormMapWithSetHoistingCrane()
+ {
+ InitializeComponent();
+ }
+
+ private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ AbstractMap map = null;
+ switch (comboBoxSelectorMap.Text)
+ {
+ case "Первая карта":
+ map = new SimpleMap();
+ break;
+ case "Вторая карта":
+ map = new SecondMap();
+ break;
+ }
+ if (map != null)
+ {
+ _mapHoistingCraneCollectionGeneric = new MapWithSetHoistingCraneGeneric(
+ pictureBox.Width, pictureBox.Height, map);
+ }
+ else
+ {
+ _mapHoistingCraneCollectionGeneric = null;
+ }
+ }
+
+ private void ButtonAddHoistingCrane_Click(object sender, EventArgs e)
+ {
+ if (_mapHoistingCraneCollectionGeneric == null)
+ {
+ return;
+ }
+ FormHoistingCrane form = new();
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ DrawingObjectHoistingCrane hoistingCrane = new(form.SelectedHoistingCrane);
+ if (_mapHoistingCraneCollectionGeneric + hoistingCrane == 1)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBox.Image = _mapHoistingCraneCollectionGeneric.ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
+ }
+
+ private void ButtonRemoveHoistingCrane_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 (_mapHoistingCraneCollectionGeneric - pos == null)
+ {
+ MessageBox.Show("Объект удален");
+ pictureBox.Image = _mapHoistingCraneCollectionGeneric.ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось удалить объект");
+ }
+ }
+
+ private void ButtonShowStorage_Click(object sender, EventArgs e)
+ {
+ if (_mapHoistingCraneCollectionGeneric == null)
+ {
+ return;
+ }
+ pictureBox.Image = _mapHoistingCraneCollectionGeneric.ShowSet();
+ }
+
+ private void ButtonShowOnMap_Click(object sender, EventArgs e)
+ {
+ if (_mapHoistingCraneCollectionGeneric == null)
+ {
+ return;
+ }
+ pictureBox.Image = _mapHoistingCraneCollectionGeneric.ShowOnMap();
+ }
+
+ private void ButtonMove_Click(object sender, EventArgs e)
+ {
+ if (_mapHoistingCraneCollectionGeneric == null)
+ {
+ return;
+ }
+ string name = ((Button)sender)?.Name ?? string.Empty;
+ Direction enums = Direction.None;
+ switch (name)
+ {
+ case "buttonUp":
+ enums = Direction.Up;
+ break;
+ case "buttonDown":
+ enums = Direction.Down;
+ break;
+ case "buttonLeft":
+ enums = Direction.Left;
+ break;
+ case "buttonRight":
+ enums = Direction.Right;
+ break;
+ }
+ pictureBox.Image = _mapHoistingCraneCollectionGeneric.MoveObject(enums);
+ }
+
+ private void pictureBox_Click(object sender, EventArgs e)
+ {
+
+ }
+ }
+}
diff --git a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.resx b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs b/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs
new file mode 100644
index 0000000..5ab5352
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs
@@ -0,0 +1,137 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HoistingCrane
+{
+ internal class MapWithSetHoistingCraneGeneric
+ where T : class, IDrawingObject
+ where U : AbstractMap
+ {
+ private readonly int _pictureWidth;
+ private readonly int _pictureHeight;
+ private readonly int _placeSizeWidth = 200;
+ private readonly int _placeSizeHeight = 120;
+ private readonly SetHoistingCraneGeneric _setHoistingCrane;
+ private readonly U _map;
+
+ public MapWithSetHoistingCraneGeneric(int picWidth, int picHeight, U map)
+ {
+ int width = picWidth / _placeSizeWidth;
+ int height = picHeight / _placeSizeHeight;
+ _setHoistingCrane = new SetHoistingCraneGeneric(width * height);
+ _pictureWidth = picWidth;
+ _pictureHeight = picHeight;
+ _map = map;
+ }
+
+ public static int operator +(MapWithSetHoistingCraneGeneric map, T bulldozer)
+ {
+ return map._setHoistingCrane.Insert(bulldozer);
+ }
+
+ public static T operator -(MapWithSetHoistingCraneGeneric map, int position)
+ {
+ return map._setHoistingCrane.Remove(position);
+ }
+
+ public Bitmap ShowSet()
+ {
+ Bitmap bmp = new(_pictureWidth, _pictureWidth);
+ Graphics gr = Graphics.FromImage(bmp);
+ DrawBackground(gr);
+ DrawBulldozers(gr);
+ return bmp;
+ }
+
+ public Bitmap ShowOnMap()
+ {
+ Shaking();
+ for (int i = 0; i < _setHoistingCrane.Count; i++)
+ {
+ var bulldozer = _setHoistingCrane.Get(i);
+ if (bulldozer != null)
+ {
+ return _map.CreateMap(_pictureWidth, _pictureHeight, bulldozer);
+ }
+ }
+ return new(_pictureWidth, _pictureHeight);
+ }
+
+ public Bitmap MoveObject(Direction direction)
+ {
+ if (_map != null)
+ {
+ return _map.MoveObject(direction);
+ }
+ return new(_pictureWidth, _pictureHeight);
+ }
+
+ public void Shaking()
+ {
+ int j = _setHoistingCrane.Count - 1;
+ for (int i = 0; i < _setHoistingCrane.Count; i++)
+ {
+ if (_setHoistingCrane.Get(i) == null)
+ {
+ for (; j > i; j--)
+ {
+ var warship = _setHoistingCrane.Get(j);
+ if (warship != null)
+ {
+ _setHoistingCrane.Insert(warship, i);
+ _setHoistingCrane.Remove(j);
+ break;
+ }
+ }
+ if (j <= i)
+ {
+ return;
+ }
+ }
+ }
+ }
+
+ private void DrawBackground(Graphics gr)
+ {
+ Pen pen = new(Color.Black, 3);
+ for (int i = 0; i <= _pictureWidth / _placeSizeWidth; i++)
+ {
+ for (int j = 0; j <= _pictureHeight / _placeSizeHeight + 1; ++j)
+ {//линия разметки места
+ gr.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth, j * _placeSizeHeight);
+ }
+ gr.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, (_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
+ }
+ }
+
+ private void DrawBulldozers(Graphics gr)
+ {
+ int heightEl = _pictureHeight / _placeSizeHeight;
+ int widthEl = _pictureWidth / _placeSizeWidth;
+ int curWidth = 3;
+ int curHeight = 3;
+
+ for (int i = 0; i < _setHoistingCrane.Count; i++)
+ {
+ if (curHeight < 0)
+ {
+ return;
+ }
+ _setHoistingCrane.Get(i)?.SetObject(curWidth * _placeSizeWidth + 10,
+ curHeight * _placeSizeHeight + 10, _pictureWidth, _pictureHeight);
+ _setHoistingCrane.Get(i)?.DrawingObject(gr);
+
+ if (curWidth == 0)
+ {
+ curWidth = 3;
+ curHeight--;
+ continue;
+ }
+ curWidth--;
+ }
+ }
+ }
+}
diff --git a/HoistingCrane/HoistingCrane/Program.cs b/HoistingCrane/HoistingCrane/Program.cs
index aaa3628..8b6d8ae 100644
--- a/HoistingCrane/HoistingCrane/Program.cs
+++ b/HoistingCrane/HoistingCrane/Program.cs
@@ -11,7 +11,7 @@ namespace HoistingCrane
// 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 FormMapWithSetHoistingCrane());
}
}
}
\ No newline at end of file
diff --git a/HoistingCrane/HoistingCrane/SetHoistingCraneGeneric.cs b/HoistingCrane/HoistingCrane/SetHoistingCraneGeneric.cs
new file mode 100644
index 0000000..32f00d6
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/SetHoistingCraneGeneric.cs
@@ -0,0 +1,83 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HoistingCrane
+{
+ internal class SetHoistingCraneGeneric
+ where T : class
+ {
+ public readonly T[] _places;
+
+ public int Count => _places.Length;
+
+ public SetHoistingCraneGeneric(int count)
+ {
+ _places = new T[count];
+ }
+
+ public int Insert(T hoistingCrane)
+ {
+ return Insert(hoistingCrane, 0);
+ }
+
+ public int Insert(T hoistingCrane, int position)
+ {
+ int emptypos = -1;
+ if (position >= Count && position < 0)
+ {
+ return -1;
+ }
+
+ if (_places[position] == null)
+ {
+ _places[position] = hoistingCrane;
+ return 1;
+ }
+
+ for (int i = position; i < Count; i++)
+ {
+ if (_places[i] == null)
+ {
+ emptypos = i;
+ break;
+ }
+ }
+
+ if (emptypos != -1)
+ {
+ for (int i = emptypos; i > position; i--)
+ {
+ _places[i] = _places[i - 1];
+ }
+ _places[position] = hoistingCrane;
+ return 1;
+ }
+
+ return -1;
+ }
+
+ public T Remove(int position)
+ {
+ if (position < Count && position >= 0 && _places[position] != null)
+ {
+ _places[position] = null;
+ T removed = _places[position];
+ return removed;
+ }
+
+ return null;
+ }
+
+ public T Get(int position)
+ {
+ if (position >= Count && position < 0)
+ {
+ return null;
+ }
+ return _places[position];
+ }
+ }
+}