diff --git a/ProjectBulldozer/Drawning/DrawingBulldozer.cs b/ProjectBulldozer/Drawning/DrawingBulldozer.cs
index 7525965..0a71a4c 100644
--- a/ProjectBulldozer/Drawning/DrawingBulldozer.cs
+++ b/ProjectBulldozer/Drawning/DrawingBulldozer.cs
@@ -4,7 +4,7 @@ namespace ProjectBulldozer.Drawning
public class DrawingBulldozer : DrawingTractor
{
public DrawingBulldozer(int speed, double weight, Color bodyColor, Color additionalColor,
- bool horns, bool seifBatteries, int width, int height) : base(speed, weight, bodyColor, width, height, 140, 130)
+ bool horns, bool seifBatteries, int width, int height) : base(speed, weight, bodyColor, width, height, 120, 110)
{
if (EntityTractor != null)
{
@@ -18,22 +18,23 @@ namespace ProjectBulldozer.Drawning
{
return;
}
-
Pen pen = new(Color.Black);
Brush blackBrush = new SolidBrush(Color.Black);
Brush windows = new SolidBrush(Color.LightBlue);
Brush bodyColor = new SolidBrush(Bulldozer.BodyColor);
Brush additionalColor = new SolidBrush(Bulldozer.AdditionalColor);
Brush grayBrush = new SolidBrush(Color.Gray);
- //otval
- Point[] Otval =
- {
+ //otval
+ Point[] Otval =
+ {
new Point(_startPosX + 118, _startPosY + 50),
new Point(_startPosX + 148, _startPosY + 111),
new Point(_startPosX+ 118, _startPosY + 111),
+
+
};
- g.FillPolygon(additionalColor, Otval);
- g.DrawPolygon(pen, Otval);
+ g.FillPolygon(additionalColor, Otval);
+ g.DrawPolygon(pen, Otval);
//гусеницы
Brush gg = new SolidBrush(Color.LightGray);
g.FillEllipse(gg, _startPosX + 16, _startPosY + 65, 101, 63);
diff --git a/ProjectBulldozer/Entities/EntityBulldozer.cs b/ProjectBulldozer/Entities/EntityBulldozer.cs
index 78c1da4..149ee6e 100644
--- a/ProjectBulldozer/Entities/EntityBulldozer.cs
+++ b/ProjectBulldozer/Entities/EntityBulldozer.cs
@@ -1,16 +1,15 @@
-using System;
-namespace ProjectBulldozer.Entities
+namespace ProjectBulldozer.Entities
{
public class EntityBulldozer : EntityTractor
{
public Color AdditionalColor { get; private set; }
- public bool Otval { get; private set; }
+ public bool Horns { get; private set; }
public bool SeifBatteries { get; private set; }
- public EntityBulldozer(int speed, double weight, Color bodyColor, Color additionalColor, bool otval,
+ public EntityBulldozer(int speed, double weight, Color bodyColor, Color additionalColor, bool horns,
bool seifBatteries) : base(speed, weight, bodyColor)
{
AdditionalColor = additionalColor;
- Otval = otval;
+ Horns = horns;
SeifBatteries = seifBatteries;
}
}
diff --git a/ProjectBulldozer/FormBulldozer.Designer.cs b/ProjectBulldozer/FormBulldozer.Designer.cs
index d314ac0..a543a34 100644
--- a/ProjectBulldozer/FormBulldozer.Designer.cs
+++ b/ProjectBulldozer/FormBulldozer.Designer.cs
@@ -4,6 +4,11 @@ namespace Bulldozer
partial class FormBulldozer
{
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))
@@ -13,8 +18,13 @@ namespace Bulldozer
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()
{
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormBulldozer));
pictureBoxBulldozer = new PictureBox();
buttonCreateBulldozer = new Button();
buttonLeft = new Button();
@@ -34,7 +44,7 @@ namespace Bulldozer
pictureBoxBulldozer.Location = new Point(0, 0);
pictureBoxBulldozer.Margin = new Padding(2);
pictureBoxBulldozer.Name = "pictureBoxBulldozer";
- pictureBoxBulldozer.Size = new Size(870, 390);
+ pictureBoxBulldozer.Size = new Size(870, 572);
pictureBoxBulldozer.SizeMode = PictureBoxSizeMode.AutoSize;
pictureBoxBulldozer.TabIndex = 0;
pictureBoxBulldozer.TabStop = false;
@@ -42,24 +52,24 @@ namespace Bulldozer
// buttonCreateBulldozer
//
buttonCreateBulldozer.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreateBulldozer.Location = new Point(11, 332);
+ buttonCreateBulldozer.Location = new Point(20, 514);
buttonCreateBulldozer.Margin = new Padding(2);
buttonCreateBulldozer.Name = "buttonCreateBulldozer";
- buttonCreateBulldozer.Size = new Size(95, 48);
+ buttonCreateBulldozer.Size = new Size(88, 48);
buttonCreateBulldozer.TabIndex = 1;
- buttonCreateBulldozer.Text = "Создать булльдозер";
+ buttonCreateBulldozer.Text = "Создать бульдозер";
buttonCreateBulldozer.UseVisualStyleBackColor = true;
buttonCreateBulldozer.Click += buttonCreateBulldozer_Click;
//
// buttonLeft
//
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
- buttonLeft.BackgroundImage = ProjectBulldozer.Properties.Resources.left1;
+ buttonLeft.BackgroundImage = (Image)resources.GetObject("buttonLeft.BackgroundImage");
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
- buttonLeft.Location = new Point(767, 353);
+ buttonLeft.Location = new Point(732, 522);
buttonLeft.Margin = new Padding(2);
buttonLeft.Name = "buttonLeft";
- buttonLeft.Size = new Size(30, 27);
+ buttonLeft.Size = new Size(40, 33);
buttonLeft.TabIndex = 2;
buttonLeft.UseVisualStyleBackColor = true;
buttonLeft.Click += buttonMove_Click;
@@ -67,12 +77,12 @@ namespace Bulldozer
// buttonUp
//
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
- buttonUp.BackgroundImage = ProjectBulldozer.Properties.Resources.up1;
+ buttonUp.BackgroundImage = (Image)resources.GetObject("buttonUp.BackgroundImage");
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
- buttonUp.Location = new Point(801, 320);
+ buttonUp.Location = new Point(776, 485);
buttonUp.Margin = new Padding(2);
buttonUp.Name = "buttonUp";
- buttonUp.Size = new Size(34, 28);
+ buttonUp.Size = new Size(40, 33);
buttonUp.TabIndex = 3;
buttonUp.UseVisualStyleBackColor = true;
buttonUp.Click += buttonMove_Click;
@@ -80,12 +90,12 @@ namespace Bulldozer
// buttonRight
//
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
- buttonRight.BackgroundImage = ProjectBulldozer.Properties.Resources.right1;
+ buttonRight.BackgroundImage = (Image)resources.GetObject("buttonRight.BackgroundImage");
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
- buttonRight.Location = new Point(837, 353);
+ buttonRight.Location = new Point(819, 522);
buttonRight.Margin = new Padding(2);
buttonRight.Name = "buttonRight";
- buttonRight.Size = new Size(28, 26);
+ buttonRight.Size = new Size(40, 33);
buttonRight.TabIndex = 4;
buttonRight.UseVisualStyleBackColor = true;
buttonRight.Click += buttonMove_Click;
@@ -93,12 +103,12 @@ namespace Bulldozer
// buttonDown
//
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
- buttonDown.BackgroundImage = ProjectBulldozer.Properties.Resources.down1;
+ buttonDown.BackgroundImage = (Image)resources.GetObject("buttonDown.BackgroundImage");
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
- buttonDown.Location = new Point(801, 353);
+ buttonDown.Location = new Point(776, 522);
buttonDown.Margin = new Padding(2);
buttonDown.Name = "buttonDown";
- buttonDown.Size = new Size(32, 27);
+ buttonDown.Size = new Size(40, 33);
buttonDown.TabIndex = 5;
buttonDown.UseVisualStyleBackColor = true;
buttonDown.Click += buttonMove_Click;
@@ -108,7 +118,7 @@ namespace Bulldozer
comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxStrategy.FormattingEnabled = true;
- comboBoxStrategy.Items.AddRange(new object[] { "К центру", "В угол" });
+ comboBoxStrategy.Items.AddRange(new object[] { "В центр", "В угол" });
comboBoxStrategy.Location = new Point(740, 8);
comboBoxStrategy.Margin = new Padding(2);
comboBoxStrategy.Name = "comboBoxStrategy";
@@ -119,10 +129,10 @@ namespace Bulldozer
// buttonCreateTractor
//
buttonCreateTractor.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreateTractor.Location = new Point(122, 332);
+ buttonCreateTractor.Location = new Point(122, 514);
buttonCreateTractor.Margin = new Padding(2);
buttonCreateTractor.Name = "buttonCreateTractor";
- buttonCreateTractor.Size = new Size(81, 47);
+ buttonCreateTractor.Size = new Size(88, 48);
buttonCreateTractor.TabIndex = 7;
buttonCreateTractor.Text = "Создать трактор";
buttonCreateTractor.UseVisualStyleBackColor = true;
@@ -134,7 +144,7 @@ namespace Bulldozer
buttonStep.Location = new Point(755, 39);
buttonStep.Margin = new Padding(2);
buttonStep.Name = "buttonStep";
- buttonStep.Size = new Size(88, 20);
+ buttonStep.Size = new Size(88, 28);
buttonStep.TabIndex = 8;
buttonStep.Text = "Шаг";
buttonStep.UseVisualStyleBackColor = true;
@@ -143,10 +153,10 @@ namespace Bulldozer
// ButtonSelect_Tractor
//
ButtonSelect_Tractor.Anchor = AnchorStyles.Top | AnchorStyles.Right;
- ButtonSelect_Tractor.Location = new Point(755, 63);
+ ButtonSelect_Tractor.Location = new Point(755, 71);
ButtonSelect_Tractor.Margin = new Padding(2);
ButtonSelect_Tractor.Name = "ButtonSelect_Tractor";
- ButtonSelect_Tractor.Size = new Size(88, 23);
+ ButtonSelect_Tractor.Size = new Size(88, 28);
ButtonSelect_Tractor.TabIndex = 9;
ButtonSelect_Tractor.Text = "Выбрать";
ButtonSelect_Tractor.UseVisualStyleBackColor = true;
@@ -156,7 +166,7 @@ namespace Bulldozer
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(870, 390);
+ ClientSize = new Size(870, 572);
Controls.Add(ButtonSelect_Tractor);
Controls.Add(buttonStep);
Controls.Add(buttonCreateTractor);
@@ -175,11 +185,6 @@ namespace Bulldozer
ResumeLayout(false);
PerformLayout();
}
- private void comboBoxStrategy_SelectedIndexChanged(object sender, EventArgs e)
- {
- throw new NotImplementedException();
- }
-
#endregion
private PictureBox pictureBoxBulldozer;
private Button buttonCreateBulldozer;
@@ -191,5 +196,6 @@ namespace Bulldozer
private Button buttonCreateTractor;
private Button buttonStep;
private Button ButtonSelect_Tractor;
+ private EventHandler comboBoxStrategy_SelectedIndexChanged;
}
}
\ No newline at end of file
diff --git a/ProjectBulldozer/FormBulldozer.cs b/ProjectBulldozer/FormBulldozer.cs
index c3156d6..ba2a569 100644
--- a/ProjectBulldozer/FormBulldozer.cs
+++ b/ProjectBulldozer/FormBulldozer.cs
@@ -1,7 +1,9 @@
using ProjectBulldozer;
using ProjectBulldozer.Drawning;
-using ProjectBulldozer.Generics;
using ProjectBulldozer.MovementStrategy;
+using System;
+using System.Windows.Forms;
+
namespace Bulldozer
{
public partial class FormBulldozer : Form
@@ -30,7 +32,9 @@ namespace Bulldozer
{
Random random = new Random();
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
+
ColorDialog colorDialog = new ColorDialog();
+
if (colorDialog.ShowDialog() == DialogResult.OK)
{
color = colorDialog.Color;
diff --git a/ProjectBulldozer/FormBulldozerCollections.Designer.cs b/ProjectBulldozer/FormBulldozerCollections.Designer.cs
index c2d85cc..2c66f61 100644
--- a/ProjectBulldozer/FormBulldozerCollections.Designer.cs
+++ b/ProjectBulldozer/FormBulldozerCollections.Designer.cs
@@ -1,8 +1,16 @@
-namespace ProjectBulldozer
+
+namespace ProjectBulldozer
{
partial class FormTractorCollections
{
+ ///
+ /// 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))
@@ -11,62 +19,62 @@
}
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()
{
- Instruments = new Panel();
+ components = new System.ComponentModel.Container();
maskedTextBoxNumber = new MaskedTextBox();
ButtonRefreshCollection = new Button();
ButtonRemoveTractor = new Button();
ButtonAddTractor = new Button();
pictureBoxCollections = new PictureBox();
- Instruments.SuspendLayout();
+ textBoxStorageName = new TextBox();
+ bindingSource1 = new BindingSource(components);
+ bindingSource2 = new BindingSource(components);
+ groupBox1 = new GroupBox();
+ listBoxStorage = new ListBox();
+ ButtonAddObject = new Button();
+ ButtonRemoveObject = new Button();
+ Instruments = new GroupBox();
((System.ComponentModel.ISupportInitialize)pictureBoxCollections).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)bindingSource1).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)bindingSource2).BeginInit();
+ groupBox1.SuspendLayout();
+ Instruments.SuspendLayout();
SuspendLayout();
//
- // Instruments
- //
- Instruments.Anchor = AnchorStyles.Right;
- Instruments.AutoSize = true;
- Instruments.Controls.Add(maskedTextBoxNumber);
- Instruments.Controls.Add(ButtonRefreshCollection);
- Instruments.Controls.Add(ButtonAddTractor);
- Instruments.Controls.Add(ButtonRemoveTractor);
- Instruments.Location = new Point(588, 11);
- Instruments.Margin = new Padding(3, 2, 3, 2);
- Instruments.Name = "Instruments";
- Instruments.Size = new Size(150, 456);
- Instruments.TabIndex = 0;
- //
// maskedTextBoxNumber
//
- maskedTextBoxNumber.Location = new Point(15, 51);
+ maskedTextBoxNumber.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ maskedTextBoxNumber.Location = new Point(33, 399);
maskedTextBoxNumber.Margin = new Padding(3, 2, 3, 2);
maskedTextBoxNumber.Mask = "0";
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
- maskedTextBoxNumber.Size = new Size(119, 23);
+ maskedTextBoxNumber.Size = new Size(131, 23);
maskedTextBoxNumber.TabIndex = 4;
//
// ButtonRefreshCollection
//
- ButtonRefreshCollection.Anchor = AnchorStyles.Right;
- ButtonRefreshCollection.Location = new Point(3, 175);
+ ButtonRefreshCollection.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ ButtonRefreshCollection.Location = new Point(33, 499);
ButtonRefreshCollection.Margin = new Padding(3, 2, 3, 2);
ButtonRefreshCollection.Name = "ButtonRefreshCollection";
- ButtonRefreshCollection.Size = new Size(131, 27);
+ ButtonRefreshCollection.Size = new Size(131, 31);
ButtonRefreshCollection.TabIndex = 2;
- ButtonRefreshCollection.Text = "Обновить ";
+ ButtonRefreshCollection.Text = "Обновить все";
ButtonRefreshCollection.UseVisualStyleBackColor = true;
- ButtonRefreshCollection.Click += ButtonRefreshCollection_Click;
//
// ButtonRemoveTractor
//
- ButtonRemoveTractor.Anchor = AnchorStyles.Right;
- ButtonRemoveTractor.Location = new Point(3, 133);
+ ButtonRemoveTractor.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ ButtonRemoveTractor.Location = new Point(33, 444);
ButtonRemoveTractor.Margin = new Padding(3, 2, 3, 2);
ButtonRemoveTractor.Name = "ButtonRemoveTractor";
- ButtonRemoveTractor.Size = new Size(131, 27);
+ ButtonRemoveTractor.Size = new Size(131, 33);
ButtonRemoveTractor.TabIndex = 1;
ButtonRemoveTractor.Text = "Удалить объект";
ButtonRemoveTractor.UseVisualStyleBackColor = true;
@@ -74,11 +82,11 @@
//
// ButtonAddTractor
//
- ButtonAddTractor.Anchor = AnchorStyles.Top | AnchorStyles.Right;
- ButtonAddTractor.Location = new Point(6, 20);
+ ButtonAddTractor.Anchor = AnchorStyles.Top;
+ ButtonAddTractor.Location = new Point(33, 346);
ButtonAddTractor.Margin = new Padding(3, 2, 3, 2);
ButtonAddTractor.Name = "ButtonAddTractor";
- ButtonAddTractor.Size = new Size(128, 27);
+ ButtonAddTractor.Size = new Size(131, 29);
ButtonAddTractor.TabIndex = 0;
ButtonAddTractor.Text = "Добавить объект";
ButtonAddTractor.UseVisualStyleBackColor = true;
@@ -86,41 +94,117 @@
//
// pictureBoxCollections
//
- pictureBoxCollections.Anchor = AnchorStyles.Left;
- pictureBoxCollections.Location = new Point(12, 11);
+ pictureBoxCollections.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ pictureBoxCollections.Location = new Point(4, 4);
pictureBoxCollections.Margin = new Padding(3, 2, 3, 2);
pictureBoxCollections.Name = "pictureBoxCollections";
- pictureBoxCollections.Size = new Size(570, 456);
+ pictureBoxCollections.Size = new Size(693, 541);
pictureBoxCollections.TabIndex = 1;
pictureBoxCollections.TabStop = false;
- pictureBoxCollections.Click += pictureBoxCollections_Click;
+ //
+ // textBoxStorageName
+ //
+ textBoxStorageName.Location = new Point(27, 32);
+ textBoxStorageName.Name = "textBoxStorageName";
+ textBoxStorageName.Size = new Size(131, 23);
+ textBoxStorageName.TabIndex = 5;
+ textBoxStorageName.TextChanged += textBoxStorageName_TextChanged;
+ //
+ // groupBox1
+ //
+ groupBox1.Controls.Add(listBoxStorage);
+ groupBox1.Controls.Add(ButtonAddObject);
+ groupBox1.Controls.Add(ButtonRemoveObject);
+ groupBox1.Controls.Add(textBoxStorageName);
+ groupBox1.Location = new Point(6, 22);
+ groupBox1.Name = "groupBox1";
+ groupBox1.Size = new Size(189, 296);
+ groupBox1.TabIndex = 5;
+ groupBox1.TabStop = false;
+ groupBox1.Text = "Наборы";
+ //
+ // listBoxStorage
+ //
+ listBoxStorage.FormattingEnabled = true;
+ listBoxStorage.ItemHeight = 15;
+ listBoxStorage.Location = new Point(27, 122);
+ listBoxStorage.Name = "listBoxStorage";
+ listBoxStorage.Size = new Size(131, 94);
+ listBoxStorage.TabIndex = 9;
+ listBoxStorage.SelectedIndexChanged += listBoxStorage_SelectedIndexChanged;
+ //
+ // ButtonAddObject
+ //
+ ButtonAddObject.Anchor = AnchorStyles.Top;
+ ButtonAddObject.Location = new Point(27, 72);
+ ButtonAddObject.Margin = new Padding(3, 2, 3, 2);
+ ButtonAddObject.Name = "ButtonAddObject";
+ ButtonAddObject.Size = new Size(131, 29);
+ ButtonAddObject.TabIndex = 7;
+ ButtonAddObject.Text = "Добавить набор";
+ ButtonAddObject.UseVisualStyleBackColor = true;
+ ButtonAddObject.Click += ButtonAddObject_Click;
+ //
+ // ButtonRemoveObject
+ //
+ ButtonRemoveObject.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ ButtonRemoveObject.Location = new Point(27, 244);
+ ButtonRemoveObject.Margin = new Padding(3, 2, 3, 2);
+ ButtonRemoveObject.Name = "ButtonRemoveObject";
+ ButtonRemoveObject.Size = new Size(131, 33);
+ ButtonRemoveObject.TabIndex = 8;
+ ButtonRemoveObject.Text = "Удалить набор";
+ ButtonRemoveObject.UseVisualStyleBackColor = true;
+ ButtonRemoveObject.Click += ButtonRemoveObject_Click;
+ //
+ // Instruments
+ //
+ Instruments.Controls.Add(ButtonRefreshCollection);
+ Instruments.Controls.Add(groupBox1);
+ Instruments.Controls.Add(maskedTextBoxNumber);
+ Instruments.Controls.Add(ButtonAddTractor);
+ Instruments.Controls.Add(ButtonRemoveTractor);
+ Instruments.Location = new Point(697, 4);
+ Instruments.Name = "Instruments";
+ Instruments.Size = new Size(200, 541);
+ Instruments.TabIndex = 6;
+ Instruments.TabStop = false;
+ Instruments.Text = "Инструменты";
//
// FormTractorCollections
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(748, 478);
- Controls.Add(pictureBoxCollections);
+ ClientSize = new Size(904, 543);
Controls.Add(Instruments);
+ Controls.Add(pictureBoxCollections);
Margin = new Padding(3, 2, 3, 2);
Name = "FormTractorCollections";
- Text = "Набор трактороов";
+ Text = "Набор локомотивов";
+ ((System.ComponentModel.ISupportInitialize)pictureBoxCollections).EndInit();
+ ((System.ComponentModel.ISupportInitialize)bindingSource1).EndInit();
+ ((System.ComponentModel.ISupportInitialize)bindingSource2).EndInit();
+ groupBox1.ResumeLayout(false);
+ groupBox1.PerformLayout();
Instruments.ResumeLayout(false);
Instruments.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)pictureBoxCollections).EndInit();
ResumeLayout(false);
- PerformLayout();
- }
- private void pictureBoxCollections_Click(object sender, EventArgs e)
- {
- throw new NotImplementedException();
}
+
#endregion
- private Panel Instruments;
private Button ButtonRefreshCollection;
private Button ButtonRemoveTractor;
private Button ButtonAddTractor;
private PictureBox pictureBoxCollections;
private MaskedTextBox maskedTextBoxNumber;
+ private GroupBox groupBox1;
+ private TextBox textBoxStorageName;
+ private BindingSource bindingSource1;
+ private BindingSource bindingSource2;
+ private ListBox listBoxStorage;
+ private Button ButtonAddObject;
+ private Button ButtonRemoveObject;
+ private GroupBox Instruments;
+ private EventHandler textBoxStorageName_TextChanged;
}
}
\ No newline at end of file
diff --git a/ProjectBulldozer/FormBulldozerCollections.cs b/ProjectBulldozer/FormBulldozerCollections.cs
index 7b080fa..00c2fd7 100644
--- a/ProjectBulldozer/FormBulldozerCollections.cs
+++ b/ProjectBulldozer/FormBulldozerCollections.cs
@@ -1,29 +1,79 @@
using Bulldozer;
-using ProjectBulldozer.Drawning;
using ProjectBulldozer.Generics;
-using ProjectBulldozer.MovementStrategy;
namespace ProjectBulldozer
{
public partial class FormTractorCollections : Form
{
- private readonly TractorGenericCollection _Tractors;
+ private readonly TractorGenericStorage _storage;
+ //private readonly TractorGenericCollection _Tractors;
public FormTractorCollections()
{
InitializeComponent();
- _Tractors = new TractorGenericCollection(pictureBoxCollections.Width,
- pictureBoxCollections.Height);
+ _storage = new TractorGenericStorage(pictureBoxCollections.Width, pictureBoxCollections.Height);
+ }
+ private void ReloadObjects()
+ {
+ int index = listBoxStorage.SelectedIndex;
+
+ listBoxStorage.Items.Clear();
+ for (int i = 0; i < _storage.Keys.Count; i++)
+ {
+ listBoxStorage.Items.Add(_storage.Keys[i]);
+ }
+ if (listBoxStorage.Items.Count > 0 && (index == -1 || index >= listBoxStorage.Items.Count))
+ {
+ listBoxStorage.SelectedIndex = 0;
+ }
+ else if (listBoxStorage.Items.Count > 0 && index > -1 && index < listBoxStorage.Items.Count)
+ {
+ listBoxStorage.SelectedIndex = index;
+ }
+ }
+ private void ButtonAddObject_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxStorageName.Text))
+ {
+ MessageBox.Show("Не всё заполнено", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _storage.AddSet(textBoxStorageName.Text);
+ ReloadObjects();
+ }
+ private void listBoxStorage_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ pictureBoxCollections.Image = _storage[listBoxStorage.SelectedItem?.ToString() ?? string.Empty]?.ShowTractors();
+ }
+ private void ButtonRemoveObject_Click(object sender, EventArgs e)
+ {
+ if (listBoxStorage.SelectedIndex == -1)
+ {
+ return;
+ }
+ if (MessageBox.Show($"Удалить объект {listBoxStorage.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo,
+ MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ _storage.DelSet(listBoxStorage.SelectedItem.ToString() ?? string.Empty);
+ ReloadObjects();
+ }
}
private void ButtonAddTractor_Click(object sender, EventArgs e)
{
- if (_Tractors == null) return;
+
+ if (listBoxStorage.SelectedIndex == -1) return;
+
+ var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
+ if (obj == null)
+ {
+ return;
+ }
FormBulldozer form = new();
if (form.ShowDialog() == DialogResult.OK)
{
//проверяем, удалось ли нам загрузить объект
- if (_Tractors + form.SelectedTractor != -1)
+ if (obj + form.SelectedTractor > -1)
{
MessageBox.Show("Объект добавлен");
- pictureBoxCollections.Image = _Tractors.ShowTractors();
+ pictureBoxCollections.Image = obj.ShowTractors();
}
else
{
@@ -33,15 +83,22 @@ namespace ProjectBulldozer
}
private void ButtonRemoveTractor_Click(object sender, EventArgs e)
{
+ if (listBoxStorage.SelectedIndex == -1) return;
+ var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
+ if (obj == null)
+ {
+ return;
+ }
+
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
- if (_Tractors - pos != null)
+ if (obj - pos != null)
{
MessageBox.Show("Объект удален");
- pictureBoxCollections.Image = _Tractors.ShowTractors();
+ pictureBoxCollections.Image = obj.ShowTractors();
}
else
{
@@ -50,7 +107,13 @@ namespace ProjectBulldozer
}
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
{
- pictureBoxCollections.Image = _Tractors.ShowTractors();
+ if (listBoxStorage.SelectedIndex == -1) return;
+ var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
+ if (obj == null)
+ {
+ return;
+ }
+ pictureBoxCollections.Image = obj.ShowTractors();
}
}
}
diff --git a/ProjectBulldozer/Generics/BulldozerGenericCollection.cs b/ProjectBulldozer/Generics/BulldozerGenericCollection.cs
index e19cec2..1aa774d 100644
--- a/ProjectBulldozer/Generics/BulldozerGenericCollection.cs
+++ b/ProjectBulldozer/Generics/BulldozerGenericCollection.cs
@@ -1,14 +1,15 @@
-using ProjectBulldozer.MovementStrategy;
-using ProjectBulldozer.Drawning;
+using ProjectBulldozer.Drawning;
+using ProjectBulldozer.MovementStrategy;
+
namespace ProjectBulldozer.Generics
{
internal class TractorGenericCollection where T : DrawingTractor where U : IMoveableObject
{
- //ширина /высота окна
+ //ширина/высота окна
private readonly int _pictureWidth;
private readonly int _pictureHeight;
- //ширина /высота занимаемого места
- private readonly int _placeSizeWidth = 170;
+ //ширина/высота занимаемого места
+ private readonly int _placeSizeWidth = 150;
private readonly int _placeSizeHeight = 130;
/// Набор объектов
private readonly SetGeneric _collection;
@@ -23,7 +24,7 @@ namespace ProjectBulldozer.Generics
_collection = new SetGeneric(width * height);
}
/// Перегрузка оператора сложения
- public static int operator +(TractorGenericCollection collect, T tract)
+ public static int operator +(TractorGenericCollection collect, T? tract)
{
if (tract == null)
{
@@ -31,24 +32,20 @@ namespace ProjectBulldozer.Generics
}
return collect._collection.Insert(tract);
}
- public static bool operator -(TractorGenericCollection collect, int
- pos)
+ /// Перегрузка оператора вычитания
+ public static T? operator -(TractorGenericCollection collect, int pos)
{
- T obj = collect._collection.Get(pos);
+ T? obj = collect._collection[pos];
if (obj != null)
{
- return collect.Remove(pos);
+ collect._collection.Remove(pos);
}
- return false;
- }
- private bool Remove(int pos)
- {
- throw new NotImplementedException();
+ return obj;
}
// получение объекта imoveableObj
public U? GetU(int pos)
{
- return (U?)_collection.Get(pos)?.GetMoveableObject;
+ return (U?)_collection[pos]?.GetMoveableObject;
}
/// Вывод всего набора объектов
public Bitmap ShowTractors()
@@ -72,21 +69,29 @@ namespace ProjectBulldozer.Generics
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
}
}
+
private void DrawObjects(Graphics g)
{
- int HeightObjCount = _pictureHeight / _placeSizeHeight;
- int WidthObjCount = _pictureWidth / _placeSizeWidth;
+ int width = _pictureWidth / _placeSizeWidth;
+ int height = _pictureHeight / _placeSizeHeight;
for (int i = 0; i < _collection.Count; i++)
{
- T t = _collection.Get(i);
- if (t != null)
- {
- {
- t.SetPosition(((_collection.Count - i - 1) % (_pictureWidth / _placeSizeWidth)) * _placeSizeWidth, (_collection.Count - i - 1) / (_pictureWidth / _placeSizeWidth) * _placeSizeHeight);
- t.DrawTransport(g);
- }
- }
+ // Получение объекта
+ var obj = _collection[i];
+ // Установка позиции
+ obj?.SetPosition(
+ (int)((width - 1) * _placeSizeWidth - (i % width * _placeSizeWidth)),
+ (int)((height - 1) * _placeSizeHeight - (i / width * _placeSizeHeight))
+ );
+ // Прорисовка объекта
+ obj?.DrawTransport(g);
}
}
}
-}
+ }
+
+
+
+
+
+
diff --git a/ProjectBulldozer/Generics/SetGeneric.cs b/ProjectBulldozer/Generics/SetGeneric.cs
index fd209d9..85feb5c 100644
--- a/ProjectBulldozer/Generics/SetGeneric.cs
+++ b/ProjectBulldozer/Generics/SetGeneric.cs
@@ -2,11 +2,14 @@
{
internal class SetGeneric where T : class
{
- private readonly T[] _places;
- public int Count => _places.Length;
+ private readonly List _places;
+ public int Count => _places.Count;
+ /// Максимальное количество объектов в списке
+ private readonly int _maxCount;
public SetGeneric(int count)
{
- _places = new T[count];
+ _maxCount = count;
+ _places = new List(count);
}
/// Добавление объекта в набор
public int Insert(T tract)
@@ -15,49 +18,42 @@
}
public int Insert(T tract, int position)
{
- int NoEmpty = 0, temp = 0;
- for (int i = position; i < Count; i++)
- {
- if (_places[i] != null) NoEmpty++;
- }
- if (NoEmpty == Count - position - 1) return -1;
-
- if (position < Count && position >= 0)
- {
- for (int j = position; j < Count; j++)
- {
- if (_places[j] == null)
- {
- temp = j;
- break;
- }
- }
- // shift right
- for (int i = temp; i > position; i--)
- {
- _places[i] = _places[i - 1];
- }
- _places[position] = tract;
- return position;
- }
- return -1;
+ if (position < 0 || position >= _maxCount) return -1;
+ _places.Insert(position, tract);
+ return position;
}
-
public T? Remove(int position)
{
if (position >= Count || position < 0)
return null;
- T tmp = _places[position];
+ T? tmp = _places[position];
_places[position] = null;
return tmp;
}
- //Получение объекта из набора по позиции
- public T? Get(int position)
+ public T? this[int position]
{
- // TODO проверка позиции
- if (position < 0 || position >= Count) return null;
- return _places[position];
+ get
+ {
+ if (position < 0 || position >= Count) return null;
+ return _places[position];
+ }
+ set
+ {
+ if (position < 0 || position >= Count || Count == _maxCount) return;
+ _places.Insert(position, value);
+ }
+ }
+ public IEnumerable GetTractors(int? maxTracts = null)
+ {
+ for (int i = 0; i < _places.Count; ++i)
+ {
+ yield return _places[i];
+ if (maxTracts.HasValue && i == maxTracts.Value)
+ {
+ yield break;
+ }
+ }
}
}
}
diff --git a/ProjectBulldozer/Generics/Status.cs b/ProjectBulldozer/Generics/Status.cs
index 9bdd170..f7a5668 100644
--- a/ProjectBulldozer/Generics/Status.cs
+++ b/ProjectBulldozer/Generics/Status.cs
@@ -1,4 +1,4 @@
-namespace ProjectBulldozer.Generics
+namespace ProjectBulldozer.MovementStrategy
{
public enum Status
{
diff --git a/ProjectBulldozer/Generics/TractorGenericStorage.cs b/ProjectBulldozer/Generics/TractorGenericStorage.cs
new file mode 100644
index 0000000..873d9bf
--- /dev/null
+++ b/ProjectBulldozer/Generics/TractorGenericStorage.cs
@@ -0,0 +1,44 @@
+using ProjectBulldozer.Drawning;
+using ProjectBulldozer.MovementStrategy;
+namespace ProjectBulldozer.Generics
+{
+ internal class TractorGenericStorage
+ {
+ readonly Dictionary> _TractorsStorage;
+ public List Keys => _TractorsStorage.Keys.ToList();
+ private readonly int _pictureWidth;
+ private readonly int _pictureHeight;
+ public TractorGenericStorage(int pictureWidth, int pictureHeight)
+ {
+ _TractorsStorage = new Dictionary>();
+ _pictureWidth = pictureWidth;
+ _pictureHeight = pictureHeight;
+ }
+ public void AddSet(string name)
+ {
+ if (!_TractorsStorage.ContainsKey(name))
+ {
+ _TractorsStorage.Add(name, new TractorGenericCollection(_pictureWidth, _pictureHeight));
+ }
+ }
+ public void DelSet(string name)
+ {
+ if (_TractorsStorage.ContainsKey(name))
+ {
+ _TractorsStorage.Remove(name);
+ }
+ }
+ public TractorGenericCollection?
+ this[string ind]
+ {
+ get
+ {
+ if (_TractorsStorage.ContainsKey(ind))
+ {
+ return _TractorsStorage[ind];
+ }
+ return null;
+ }
+ }
+ }
+}
diff --git a/ProjectBulldozer/MovementStrategy/AbstractStrategy.cs b/ProjectBulldozer/MovementStrategy/AbstractStrategy.cs
index d965778..621fce6 100644
--- a/ProjectBulldozer/MovementStrategy/AbstractStrategy.cs
+++ b/ProjectBulldozer/MovementStrategy/AbstractStrategy.cs
@@ -1,6 +1,4 @@
-using ProjectBulldozer.Generics;
-
-namespace ProjectBulldozer.MovementStrategy
+namespace ProjectBulldozer.MovementStrategy
{
public abstract class AbstractStrategy
{
@@ -10,6 +8,7 @@ namespace ProjectBulldozer.MovementStrategy
protected int FieldWidth { get; private set; }
protected int FieldHeight { get; private set; }
public Status GetStatus() { return _state; }
+
public void SetData(IMoveableObject moveableObject, int width, int height)
{
if (moveableObject == null)
@@ -22,7 +21,6 @@ namespace ProjectBulldozer.MovementStrategy
FieldWidth = width;
FieldHeight = height;
}
-
public void MakeStep()
{
if (_state != Status.InProgress)
diff --git a/ProjectBulldozer/MovementStrategy/DrawingObjectTractor.cs b/ProjectBulldozer/MovementStrategy/DrawingObjectTractor.cs
index 58193b2..f3eae94 100644
--- a/ProjectBulldozer/MovementStrategy/DrawingObjectTractor.cs
+++ b/ProjectBulldozer/MovementStrategy/DrawingObjectTractor.cs
@@ -1,9 +1,11 @@
-using ProjectBulldozer.Drawning;
-namespace ProjectBulldozer.MovementStrategy
+using Bulldozer;
+using ProjectBulldozer.MovementStrategy;
+namespace ProjectBulldozer.Drawning
{
public class DrawingObjectTractor : IMoveableObject
{
private readonly DrawingTractor? _drawningTractor = null;
+
public DrawingObjectTractor(DrawingTractor drawningTractor)
{
_drawningTractor = drawningTractor;
diff --git a/ProjectBulldozer/MovementStrategy/IMoveableObject.cs b/ProjectBulldozer/MovementStrategy/IMoveableObject.cs
index 139c7de..93b1c98 100644
--- a/ProjectBulldozer/MovementStrategy/IMoveableObject.cs
+++ b/ProjectBulldozer/MovementStrategy/IMoveableObject.cs
@@ -1,4 +1,5 @@
-namespace ProjectBulldozer.MovementStrategy
+using Bulldozer;
+namespace ProjectBulldozer.MovementStrategy
{
public interface IMoveableObject
{