Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d223f8de8 | |||
| 380658dcf9 |
@@ -17,11 +17,11 @@ namespace DumpTruck.DrawingObjects
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина окна
|
/// Ширина окна
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int _pictureWidth;
|
public int _pictureWidth;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота окна
|
/// Высота окна
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int _pictureHeight;
|
public int _pictureHeight;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Левая координата прорисовки грузовика
|
/// Левая координата прорисовки грузовика
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -56,7 +56,7 @@ namespace DumpTruck.DrawingObjects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int GetHeight => _truckHeight;
|
public int GetHeight => _truckHeight;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение объекта IMoveableObject из объекта DrawingTruck
|
/// Получение объекта IMoveableObject из объекта DrawningCar
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IMoveableObject GetMoveableObject => new DrawningObjectTruck(this);
|
public IMoveableObject GetMoveableObject => new DrawningObjectTruck(this);
|
||||||
|
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ namespace DumpTruck.Entities
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Цвет кузова
|
/// Цвет кузова
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color DumpBoxColor { get; private set; }
|
public Color DumpBoxColor { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Цвет тента
|
/// Цвет тента
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color TentColor { get; private set; }
|
public Color TentColor { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace DumpTruck.Entities
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Основной цвет
|
/// Основной цвет
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color BodyColor { get; private set; }
|
public Color BodyColor { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Шаг
|
/// Шаг
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -70,14 +70,14 @@ namespace DumpTruck
|
|||||||
ColorDialog secondDialog = new();
|
ColorDialog secondDialog = new();
|
||||||
if (secondDialog.ShowDialog() == DialogResult.OK)
|
if (secondDialog.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
dumpBoxColor = secondDialog.Color;
|
dumpBoxColor = secondDialog.Color;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color tentColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
Color tentColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||||
ColorDialog thirdDialog = new();
|
ColorDialog thirdDialog = new();
|
||||||
if (thirdDialog.ShowDialog() == DialogResult.OK)
|
if (thirdDialog.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
tentColor = thirdDialog.Color;
|
tentColor = thirdDialog.Color;
|
||||||
}
|
}
|
||||||
|
|
||||||
_drawingTruck = new DrawingDumpTruck(random.Next(100, 300), random.Next(1000, 3000),
|
_drawingTruck = new DrawingDumpTruck(random.Next(100, 300), random.Next(1000, 3000),
|
||||||
|
|||||||
164
DumpTruck/FormTruckCollection.Designer.cs
generated
164
DumpTruck/FormTruckCollection.Designer.cs
generated
@@ -1,41 +1,48 @@
|
|||||||
namespace DumpTruck
|
namespace DumpTruck
|
||||||
{
|
{
|
||||||
partial class FormTruckCollection
|
partial class FormTruckCollection
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer components = null;
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing && (components != null))
|
if (disposing && (components != null))
|
||||||
{
|
{
|
||||||
components.Dispose();
|
components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required method for Designer support - do not modify
|
/// Required method for Designer support - do not modify
|
||||||
/// the contents of this method with the code editor.
|
/// the contents of this method with the code editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.panelTools = new System.Windows.Forms.Panel();
|
this.panelTools = new System.Windows.Forms.Panel();
|
||||||
|
this.panelStorages = new System.Windows.Forms.Panel();
|
||||||
|
this.labelStorages = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxStorageName = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonDelObject = new System.Windows.Forms.Button();
|
||||||
|
this.buttonAddObject = new System.Windows.Forms.Button();
|
||||||
|
this.listBoxStorages = new System.Windows.Forms.ListBox();
|
||||||
|
this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox();
|
||||||
this.buttonRefreshCollection = new System.Windows.Forms.Button();
|
this.buttonRefreshCollection = new System.Windows.Forms.Button();
|
||||||
this.labelTools = new System.Windows.Forms.Label();
|
this.labelTools = new System.Windows.Forms.Label();
|
||||||
this.buttonRemoveTruck = new System.Windows.Forms.Button();
|
this.buttonRemoveTruck = new System.Windows.Forms.Button();
|
||||||
this.buttonAddTruck = new System.Windows.Forms.Button();
|
this.buttonAddTruck = new System.Windows.Forms.Button();
|
||||||
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
|
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
|
||||||
this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox();
|
|
||||||
this.panelTools.SuspendLayout();
|
this.panelTools.SuspendLayout();
|
||||||
|
this.panelStorages.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
@@ -43,6 +50,7 @@
|
|||||||
//
|
//
|
||||||
this.panelTools.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
this.panelTools.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.panelTools.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
this.panelTools.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.panelTools.Controls.Add(this.panelStorages);
|
||||||
this.panelTools.Controls.Add(this.maskedTextBoxNumber);
|
this.panelTools.Controls.Add(this.maskedTextBoxNumber);
|
||||||
this.panelTools.Controls.Add(this.buttonRefreshCollection);
|
this.panelTools.Controls.Add(this.buttonRefreshCollection);
|
||||||
this.panelTools.Controls.Add(this.labelTools);
|
this.panelTools.Controls.Add(this.labelTools);
|
||||||
@@ -53,9 +61,74 @@
|
|||||||
this.panelTools.Size = new System.Drawing.Size(203, 445);
|
this.panelTools.Size = new System.Drawing.Size(203, 445);
|
||||||
this.panelTools.TabIndex = 0;
|
this.panelTools.TabIndex = 0;
|
||||||
//
|
//
|
||||||
|
// panelStorages
|
||||||
|
//
|
||||||
|
this.panelStorages.Controls.Add(this.labelStorages);
|
||||||
|
this.panelStorages.Controls.Add(this.textBoxStorageName);
|
||||||
|
this.panelStorages.Controls.Add(this.buttonDelObject);
|
||||||
|
this.panelStorages.Controls.Add(this.buttonAddObject);
|
||||||
|
this.panelStorages.Controls.Add(this.listBoxStorages);
|
||||||
|
this.panelStorages.Location = new System.Drawing.Point(3, 18);
|
||||||
|
this.panelStorages.Name = "panelStorages";
|
||||||
|
this.panelStorages.Size = new System.Drawing.Size(200, 221);
|
||||||
|
this.panelStorages.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// labelStorages
|
||||||
|
//
|
||||||
|
this.labelStorages.AutoSize = true;
|
||||||
|
this.labelStorages.Location = new System.Drawing.Point(25, 0);
|
||||||
|
this.labelStorages.Name = "labelStorages";
|
||||||
|
this.labelStorages.Size = new System.Drawing.Size(52, 15);
|
||||||
|
this.labelStorages.TabIndex = 4;
|
||||||
|
this.labelStorages.Text = "Наборы";
|
||||||
|
//
|
||||||
|
// textBoxStorageName
|
||||||
|
//
|
||||||
|
this.textBoxStorageName.Location = new System.Drawing.Point(25, 26);
|
||||||
|
this.textBoxStorageName.Name = "textBoxStorageName";
|
||||||
|
this.textBoxStorageName.Size = new System.Drawing.Size(150, 23);
|
||||||
|
this.textBoxStorageName.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// buttonDelObject
|
||||||
|
//
|
||||||
|
this.buttonDelObject.Location = new System.Drawing.Point(25, 185);
|
||||||
|
this.buttonDelObject.Name = "buttonDelObject";
|
||||||
|
this.buttonDelObject.Size = new System.Drawing.Size(150, 23);
|
||||||
|
this.buttonDelObject.TabIndex = 2;
|
||||||
|
this.buttonDelObject.Text = "Удалить набор";
|
||||||
|
this.buttonDelObject.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDelObject.Click += new System.EventHandler(this.buttonDelObject_Click);
|
||||||
|
//
|
||||||
|
// buttonAddObject
|
||||||
|
//
|
||||||
|
this.buttonAddObject.Location = new System.Drawing.Point(25, 56);
|
||||||
|
this.buttonAddObject.Name = "buttonAddObject";
|
||||||
|
this.buttonAddObject.Size = new System.Drawing.Size(150, 23);
|
||||||
|
this.buttonAddObject.TabIndex = 1;
|
||||||
|
this.buttonAddObject.Text = "Добавить набор";
|
||||||
|
this.buttonAddObject.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAddObject.Click += new System.EventHandler(this.buttonAddObject_Click);
|
||||||
|
//
|
||||||
|
// listBoxStorages
|
||||||
|
//
|
||||||
|
this.listBoxStorages.FormattingEnabled = true;
|
||||||
|
this.listBoxStorages.ItemHeight = 15;
|
||||||
|
this.listBoxStorages.Location = new System.Drawing.Point(25, 85);
|
||||||
|
this.listBoxStorages.Name = "listBoxStorages";
|
||||||
|
this.listBoxStorages.Size = new System.Drawing.Size(150, 94);
|
||||||
|
this.listBoxStorages.TabIndex = 0;
|
||||||
|
this.listBoxStorages.SelectedIndexChanged += new System.EventHandler(this.ListBoxObjects_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// maskedTextBoxNumber
|
||||||
|
//
|
||||||
|
this.maskedTextBoxNumber.Location = new System.Drawing.Point(28, 302);
|
||||||
|
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||||
|
this.maskedTextBoxNumber.Size = new System.Drawing.Size(150, 23);
|
||||||
|
this.maskedTextBoxNumber.TabIndex = 4;
|
||||||
|
//
|
||||||
// buttonRefreshCollection
|
// buttonRefreshCollection
|
||||||
//
|
//
|
||||||
this.buttonRefreshCollection.Location = new System.Drawing.Point(25, 168);
|
this.buttonRefreshCollection.Location = new System.Drawing.Point(28, 395);
|
||||||
this.buttonRefreshCollection.Name = "buttonRefreshCollection";
|
this.buttonRefreshCollection.Name = "buttonRefreshCollection";
|
||||||
this.buttonRefreshCollection.Size = new System.Drawing.Size(150, 30);
|
this.buttonRefreshCollection.Size = new System.Drawing.Size(150, 30);
|
||||||
this.buttonRefreshCollection.TabIndex = 3;
|
this.buttonRefreshCollection.TabIndex = 3;
|
||||||
@@ -75,7 +148,7 @@
|
|||||||
//
|
//
|
||||||
// buttonRemoveTruck
|
// buttonRemoveTruck
|
||||||
//
|
//
|
||||||
this.buttonRemoveTruck.Location = new System.Drawing.Point(25, 109);
|
this.buttonRemoveTruck.Location = new System.Drawing.Point(28, 336);
|
||||||
this.buttonRemoveTruck.Name = "buttonRemoveTruck";
|
this.buttonRemoveTruck.Name = "buttonRemoveTruck";
|
||||||
this.buttonRemoveTruck.Size = new System.Drawing.Size(150, 30);
|
this.buttonRemoveTruck.Size = new System.Drawing.Size(150, 30);
|
||||||
this.buttonRemoveTruck.TabIndex = 2;
|
this.buttonRemoveTruck.TabIndex = 2;
|
||||||
@@ -85,7 +158,7 @@
|
|||||||
//
|
//
|
||||||
// buttonAddTruck
|
// buttonAddTruck
|
||||||
//
|
//
|
||||||
this.buttonAddTruck.Location = new System.Drawing.Point(25, 30);
|
this.buttonAddTruck.Location = new System.Drawing.Point(28, 257);
|
||||||
this.buttonAddTruck.Name = "buttonAddTruck";
|
this.buttonAddTruck.Name = "buttonAddTruck";
|
||||||
this.buttonAddTruck.Size = new System.Drawing.Size(150, 30);
|
this.buttonAddTruck.Size = new System.Drawing.Size(150, 30);
|
||||||
this.buttonAddTruck.TabIndex = 1;
|
this.buttonAddTruck.TabIndex = 1;
|
||||||
@@ -101,13 +174,6 @@
|
|||||||
this.pictureBoxCollection.TabIndex = 1;
|
this.pictureBoxCollection.TabIndex = 1;
|
||||||
this.pictureBoxCollection.TabStop = false;
|
this.pictureBoxCollection.TabStop = false;
|
||||||
//
|
//
|
||||||
// maskedTextBoxNumber
|
|
||||||
//
|
|
||||||
this.maskedTextBoxNumber.Location = new System.Drawing.Point(25, 75);
|
|
||||||
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
|
||||||
this.maskedTextBoxNumber.Size = new System.Drawing.Size(150, 23);
|
|
||||||
this.maskedTextBoxNumber.TabIndex = 4;
|
|
||||||
//
|
|
||||||
// FormTruckCollection
|
// FormTruckCollection
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
@@ -119,19 +185,27 @@
|
|||||||
this.Text = "FormTruckCollection";
|
this.Text = "FormTruckCollection";
|
||||||
this.panelTools.ResumeLayout(false);
|
this.panelTools.ResumeLayout(false);
|
||||||
this.panelTools.PerformLayout();
|
this.panelTools.PerformLayout();
|
||||||
|
this.panelStorages.ResumeLayout(false);
|
||||||
|
this.panelStorages.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Panel panelTools;
|
private Panel panelTools;
|
||||||
private Button buttonAddTruck;
|
private Button buttonAddTruck;
|
||||||
private Label labelTools;
|
private Label labelTools;
|
||||||
private Button buttonRefreshCollection;
|
private Button buttonRefreshCollection;
|
||||||
private Button buttonRemoveTruck;
|
private Button buttonRemoveTruck;
|
||||||
private PictureBox pictureBoxCollection;
|
private PictureBox pictureBoxCollection;
|
||||||
private MaskedTextBox maskedTextBoxNumber;
|
private MaskedTextBox maskedTextBoxNumber;
|
||||||
|
private Panel panelStorages;
|
||||||
|
private Button buttonDelObject;
|
||||||
|
private Button buttonAddObject;
|
||||||
|
private ListBox listBoxStorages;
|
||||||
|
private Label labelStorages;
|
||||||
|
private TextBox textBoxStorageName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,65 +13,163 @@ using DumpTruck.MovementStrategy;
|
|||||||
|
|
||||||
namespace DumpTruck
|
namespace DumpTruck
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Форма для работы с набором объектов класса DrawingTruck
|
/// Форма для работы с набором объектов класса DrawingTruck
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class FormTruckCollection : Form
|
public partial class FormTruckCollection : Form
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Набор объектов
|
/// Набор объектов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly TrucksGenericCollection<DrawingTruck, DrawningObjectTruck> _trucks;
|
private readonly TrucksGenericStorage _storage;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FormTruckCollection()
|
public FormTruckCollection()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_trucks = new TrucksGenericCollection<DrawingTruck, DrawningObjectTruck>(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
_storage = new TrucksGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonAddTruck_Click(object sender, EventArgs e)
|
private void ReloadObjects()
|
||||||
{
|
{
|
||||||
FormDumpTruck form = new();
|
int index = listBoxStorages.SelectedIndex;
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
listBoxStorages.Items.Clear();
|
||||||
|
for (int i = 0; i < _storage.Keys.Count; i++)
|
||||||
{
|
{
|
||||||
if (_trucks + form.SelectedTruck != -1)
|
listBoxStorages.Items.Add(_storage.Keys[i]);
|
||||||
{
|
}
|
||||||
MessageBox.Show("Объект добавлен");
|
if (listBoxStorages.Items.Count > 0 && (index == -1 || index
|
||||||
pictureBoxCollection.Image = _trucks.ShowTrucks();
|
>= listBoxStorages.Items.Count))
|
||||||
}
|
{
|
||||||
else
|
listBoxStorages.SelectedIndex = 0;
|
||||||
{
|
}
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
else if (listBoxStorages.Items.Count > 0 && index > -1 &&
|
||||||
}
|
index < listBoxStorages.Items.Count)
|
||||||
|
{
|
||||||
|
listBoxStorages.SelectedIndex = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
private void buttonRemoveTruck_Click(object sender, EventArgs e)
|
/// Добавление набора в коллекцию
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void buttonAddObject_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
||||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
{
|
||||||
|
MessageBox.Show("Не все данные заполнены", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_storage.AddSet(textBoxStorageName.Text);
|
||||||
|
ReloadObjects();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Выбор набора
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ListBoxObjects_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowTrucks();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление набора
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void buttonDelObject_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
if (MessageBox.Show($"Удалить объект { listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo,MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
if (_trucks - pos)
|
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
_storage.DelSet(listBoxStorages.SelectedItem.ToString() ?? string.Empty);
|
||||||
pictureBoxCollection.Image = _trucks.ShowTrucks();
|
ReloadObjects();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddTruck(DrawingTruck truck)
|
||||||
|
{
|
||||||
|
truck._pictureWidth = pictureBoxCollection.Width;
|
||||||
|
truck._pictureHeight = pictureBoxCollection.Height;
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (obj + truck != -1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBoxCollection.Image = obj.ShowTrucks();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonRefreshCollection_Click(object sender, EventArgs e)
|
private void buttonAddTruck_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
pictureBoxCollection.Image = _trucks.ShowTrucks();
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var formTruckConfig = new FormTruckConfig();
|
||||||
|
formTruckConfig.AddEvent(AddTruck);
|
||||||
|
formTruckConfig.Show();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private void buttonRemoveTruck_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _storage[listBoxStorages.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 (obj - pos != null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект удален");
|
||||||
|
pictureBoxCollection.Image = obj.ShowTrucks();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось удалить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonRefreshCollection_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pictureBoxCollection.Image = obj.ShowTrucks();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
405
DumpTruck/FormTruckConfig.Designer.cs
generated
Normal file
405
DumpTruck/FormTruckConfig.Designer.cs
generated
Normal file
@@ -0,0 +1,405 @@
|
|||||||
|
namespace DumpTruck
|
||||||
|
{
|
||||||
|
partial class FormTruckConfig
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.groupBoxParameters = new System.Windows.Forms.GroupBox();
|
||||||
|
this.labelModifiedObject = new System.Windows.Forms.Label();
|
||||||
|
this.labelSimpleObject = new System.Windows.Forms.Label();
|
||||||
|
this.groupBoxColors = new System.Windows.Forms.GroupBox();
|
||||||
|
this.panelPurple = new System.Windows.Forms.Panel();
|
||||||
|
this.panelBlack = new System.Windows.Forms.Panel();
|
||||||
|
this.panelGray = new System.Windows.Forms.Panel();
|
||||||
|
this.panelWhite = new System.Windows.Forms.Panel();
|
||||||
|
this.panelYellow = new System.Windows.Forms.Panel();
|
||||||
|
this.panelBlue = new System.Windows.Forms.Panel();
|
||||||
|
this.panelGreen = new System.Windows.Forms.Panel();
|
||||||
|
this.panelRed = new System.Windows.Forms.Panel();
|
||||||
|
this.checkBoxTent = new System.Windows.Forms.CheckBox();
|
||||||
|
this.checkBoxDumpBox = new System.Windows.Forms.CheckBox();
|
||||||
|
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.labelWeight = new System.Windows.Forms.Label();
|
||||||
|
this.labelSpeed = new System.Windows.Forms.Label();
|
||||||
|
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
|
||||||
|
this.PanelObject = new System.Windows.Forms.Panel();
|
||||||
|
this.labelTentColor = new System.Windows.Forms.Label();
|
||||||
|
this.labelDumpBoxColor = new System.Windows.Forms.Label();
|
||||||
|
this.labelBaseColor = new System.Windows.Forms.Label();
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.groupBoxParameters.SuspendLayout();
|
||||||
|
this.groupBoxColors.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
|
||||||
|
this.PanelObject.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBoxParameters
|
||||||
|
//
|
||||||
|
this.groupBoxParameters.Controls.Add(this.labelModifiedObject);
|
||||||
|
this.groupBoxParameters.Controls.Add(this.labelSimpleObject);
|
||||||
|
this.groupBoxParameters.Controls.Add(this.groupBoxColors);
|
||||||
|
this.groupBoxParameters.Controls.Add(this.checkBoxTent);
|
||||||
|
this.groupBoxParameters.Controls.Add(this.checkBoxDumpBox);
|
||||||
|
this.groupBoxParameters.Controls.Add(this.numericUpDownWeight);
|
||||||
|
this.groupBoxParameters.Controls.Add(this.numericUpDownSpeed);
|
||||||
|
this.groupBoxParameters.Controls.Add(this.labelWeight);
|
||||||
|
this.groupBoxParameters.Controls.Add(this.labelSpeed);
|
||||||
|
this.groupBoxParameters.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.groupBoxParameters.Name = "groupBoxParameters";
|
||||||
|
this.groupBoxParameters.Size = new System.Drawing.Size(463, 246);
|
||||||
|
this.groupBoxParameters.TabIndex = 0;
|
||||||
|
this.groupBoxParameters.TabStop = false;
|
||||||
|
this.groupBoxParameters.Text = "Параметры";
|
||||||
|
//
|
||||||
|
// labelModifiedObject
|
||||||
|
//
|
||||||
|
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.labelModifiedObject.Location = new System.Drawing.Point(335, 158);
|
||||||
|
this.labelModifiedObject.Name = "labelModifiedObject";
|
||||||
|
this.labelModifiedObject.Size = new System.Drawing.Size(100, 23);
|
||||||
|
this.labelModifiedObject.TabIndex = 8;
|
||||||
|
this.labelModifiedObject.Text = "Продвинутый";
|
||||||
|
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
|
||||||
|
//
|
||||||
|
// labelSimpleObject
|
||||||
|
//
|
||||||
|
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.labelSimpleObject.Location = new System.Drawing.Point(229, 158);
|
||||||
|
this.labelSimpleObject.Name = "labelSimpleObject";
|
||||||
|
this.labelSimpleObject.Size = new System.Drawing.Size(100, 23);
|
||||||
|
this.labelSimpleObject.TabIndex = 7;
|
||||||
|
this.labelSimpleObject.Text = "Простой";
|
||||||
|
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
|
||||||
|
//
|
||||||
|
// groupBoxColors
|
||||||
|
//
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelPurple);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelBlack);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelGray);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelWhite);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelYellow);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelBlue);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelGreen);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelRed);
|
||||||
|
this.groupBoxColors.Location = new System.Drawing.Point(229, 38);
|
||||||
|
this.groupBoxColors.Name = "groupBoxColors";
|
||||||
|
this.groupBoxColors.Size = new System.Drawing.Size(206, 100);
|
||||||
|
this.groupBoxColors.TabIndex = 6;
|
||||||
|
this.groupBoxColors.TabStop = false;
|
||||||
|
this.groupBoxColors.Text = "Цвета";
|
||||||
|
//
|
||||||
|
// panelPurple
|
||||||
|
//
|
||||||
|
this.panelPurple.BackColor = System.Drawing.Color.Purple;
|
||||||
|
this.panelPurple.Location = new System.Drawing.Point(136, 55);
|
||||||
|
this.panelPurple.Name = "panelPurple";
|
||||||
|
this.panelPurple.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.panelPurple.TabIndex = 2;
|
||||||
|
this.panelPurple.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||||
|
//
|
||||||
|
// panelBlack
|
||||||
|
//
|
||||||
|
this.panelBlack.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.panelBlack.Location = new System.Drawing.Point(100, 55);
|
||||||
|
this.panelBlack.Name = "panelBlack";
|
||||||
|
this.panelBlack.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.panelBlack.TabIndex = 2;
|
||||||
|
this.panelBlack.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||||
|
//
|
||||||
|
// panelGray
|
||||||
|
//
|
||||||
|
this.panelGray.BackColor = System.Drawing.Color.Gray;
|
||||||
|
this.panelGray.Location = new System.Drawing.Point(64, 55);
|
||||||
|
this.panelGray.Name = "panelGray";
|
||||||
|
this.panelGray.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.panelGray.TabIndex = 2;
|
||||||
|
this.panelGray.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||||
|
//
|
||||||
|
// panelWhite
|
||||||
|
//
|
||||||
|
this.panelWhite.BackColor = System.Drawing.Color.White;
|
||||||
|
this.panelWhite.Location = new System.Drawing.Point(28, 55);
|
||||||
|
this.panelWhite.Name = "panelWhite";
|
||||||
|
this.panelWhite.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.panelWhite.TabIndex = 2;
|
||||||
|
this.panelWhite.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||||
|
//
|
||||||
|
// panelYellow
|
||||||
|
//
|
||||||
|
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
|
||||||
|
this.panelYellow.Location = new System.Drawing.Point(136, 19);
|
||||||
|
this.panelYellow.Name = "panelYellow";
|
||||||
|
this.panelYellow.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.panelYellow.TabIndex = 2;
|
||||||
|
this.panelYellow.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||||
|
//
|
||||||
|
// panelBlue
|
||||||
|
//
|
||||||
|
this.panelBlue.BackColor = System.Drawing.Color.Blue;
|
||||||
|
this.panelBlue.Location = new System.Drawing.Point(100, 19);
|
||||||
|
this.panelBlue.Name = "panelBlue";
|
||||||
|
this.panelBlue.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.panelBlue.TabIndex = 1;
|
||||||
|
this.panelBlue.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||||
|
//
|
||||||
|
// panelGreen
|
||||||
|
//
|
||||||
|
this.panelGreen.BackColor = System.Drawing.Color.Green;
|
||||||
|
this.panelGreen.Location = new System.Drawing.Point(64, 19);
|
||||||
|
this.panelGreen.Name = "panelGreen";
|
||||||
|
this.panelGreen.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.panelGreen.TabIndex = 1;
|
||||||
|
this.panelGreen.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||||
|
//
|
||||||
|
// panelRed
|
||||||
|
//
|
||||||
|
this.panelRed.BackColor = System.Drawing.Color.Red;
|
||||||
|
this.panelRed.Location = new System.Drawing.Point(28, 19);
|
||||||
|
this.panelRed.Name = "panelRed";
|
||||||
|
this.panelRed.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.panelRed.TabIndex = 0;
|
||||||
|
this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||||
|
//
|
||||||
|
// checkBoxTent
|
||||||
|
//
|
||||||
|
this.checkBoxTent.AutoSize = true;
|
||||||
|
this.checkBoxTent.Location = new System.Drawing.Point(23, 158);
|
||||||
|
this.checkBoxTent.Name = "checkBoxTent";
|
||||||
|
this.checkBoxTent.Size = new System.Drawing.Size(155, 19);
|
||||||
|
this.checkBoxTent.TabIndex = 5;
|
||||||
|
this.checkBoxTent.Text = "Признак наличия тента";
|
||||||
|
this.checkBoxTent.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxDumpBox
|
||||||
|
//
|
||||||
|
this.checkBoxDumpBox.AutoSize = true;
|
||||||
|
this.checkBoxDumpBox.Location = new System.Drawing.Point(23, 119);
|
||||||
|
this.checkBoxDumpBox.Name = "checkBoxDumpBox";
|
||||||
|
this.checkBoxDumpBox.Size = new System.Drawing.Size(162, 19);
|
||||||
|
this.checkBoxDumpBox.TabIndex = 4;
|
||||||
|
this.checkBoxDumpBox.Text = "Признак наличия кузова";
|
||||||
|
this.checkBoxDumpBox.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// numericUpDownWeight
|
||||||
|
//
|
||||||
|
this.numericUpDownWeight.Location = new System.Drawing.Point(71, 62);
|
||||||
|
this.numericUpDownWeight.Maximum = new decimal(new int[] {
|
||||||
|
1000,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
this.numericUpDownWeight.Minimum = new decimal(new int[] {
|
||||||
|
100,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
this.numericUpDownWeight.Name = "numericUpDownWeight";
|
||||||
|
this.numericUpDownWeight.Size = new System.Drawing.Size(82, 23);
|
||||||
|
this.numericUpDownWeight.TabIndex = 3;
|
||||||
|
this.numericUpDownWeight.Value = new decimal(new int[] {
|
||||||
|
100,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
//
|
||||||
|
// numericUpDownSpeed
|
||||||
|
//
|
||||||
|
this.numericUpDownSpeed.Location = new System.Drawing.Point(71, 19);
|
||||||
|
this.numericUpDownSpeed.Maximum = new decimal(new int[] {
|
||||||
|
1000,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
this.numericUpDownSpeed.Minimum = new decimal(new int[] {
|
||||||
|
100,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||||
|
this.numericUpDownSpeed.Size = new System.Drawing.Size(82, 23);
|
||||||
|
this.numericUpDownSpeed.TabIndex = 2;
|
||||||
|
this.numericUpDownSpeed.Value = new decimal(new int[] {
|
||||||
|
100,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
//
|
||||||
|
// labelWeight
|
||||||
|
//
|
||||||
|
this.labelWeight.AutoSize = true;
|
||||||
|
this.labelWeight.Location = new System.Drawing.Point(6, 64);
|
||||||
|
this.labelWeight.Name = "labelWeight";
|
||||||
|
this.labelWeight.Size = new System.Drawing.Size(26, 15);
|
||||||
|
this.labelWeight.TabIndex = 1;
|
||||||
|
this.labelWeight.Text = "Вес";
|
||||||
|
//
|
||||||
|
// labelSpeed
|
||||||
|
//
|
||||||
|
this.labelSpeed.AutoSize = true;
|
||||||
|
this.labelSpeed.Location = new System.Drawing.Point(6, 19);
|
||||||
|
this.labelSpeed.Name = "labelSpeed";
|
||||||
|
this.labelSpeed.Size = new System.Drawing.Size(59, 15);
|
||||||
|
this.labelSpeed.TabIndex = 0;
|
||||||
|
this.labelSpeed.Text = "Скорость";
|
||||||
|
//
|
||||||
|
// pictureBoxObject
|
||||||
|
//
|
||||||
|
this.pictureBoxObject.Location = new System.Drawing.Point(46, 56);
|
||||||
|
this.pictureBoxObject.Name = "pictureBoxObject";
|
||||||
|
this.pictureBoxObject.Size = new System.Drawing.Size(226, 131);
|
||||||
|
this.pictureBoxObject.TabIndex = 1;
|
||||||
|
this.pictureBoxObject.TabStop = false;
|
||||||
|
//
|
||||||
|
// PanelObject
|
||||||
|
//
|
||||||
|
this.PanelObject.AllowDrop = true;
|
||||||
|
this.PanelObject.Controls.Add(this.labelTentColor);
|
||||||
|
this.PanelObject.Controls.Add(this.labelDumpBoxColor);
|
||||||
|
this.PanelObject.Controls.Add(this.labelBaseColor);
|
||||||
|
this.PanelObject.Controls.Add(this.pictureBoxObject);
|
||||||
|
this.PanelObject.Location = new System.Drawing.Point(481, 12);
|
||||||
|
this.PanelObject.Name = "PanelObject";
|
||||||
|
this.PanelObject.Size = new System.Drawing.Size(307, 196);
|
||||||
|
this.PanelObject.TabIndex = 2;
|
||||||
|
this.PanelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
|
||||||
|
this.PanelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
|
||||||
|
//
|
||||||
|
// labelTentColor
|
||||||
|
//
|
||||||
|
this.labelTentColor.AllowDrop = true;
|
||||||
|
this.labelTentColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.labelTentColor.Location = new System.Drawing.Point(202, 13);
|
||||||
|
this.labelTentColor.Name = "labelTentColor";
|
||||||
|
this.labelTentColor.Size = new System.Drawing.Size(70, 40);
|
||||||
|
this.labelTentColor.TabIndex = 4;
|
||||||
|
this.labelTentColor.Text = "Цвет тента";
|
||||||
|
this.labelTentColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
this.labelTentColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelTentColor_DragDrop);
|
||||||
|
this.labelTentColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter);
|
||||||
|
//
|
||||||
|
// labelDumpBoxColor
|
||||||
|
//
|
||||||
|
this.labelDumpBoxColor.AllowDrop = true;
|
||||||
|
this.labelDumpBoxColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.labelDumpBoxColor.Location = new System.Drawing.Point(124, 13);
|
||||||
|
this.labelDumpBoxColor.Name = "labelDumpBoxColor";
|
||||||
|
this.labelDumpBoxColor.Size = new System.Drawing.Size(70, 40);
|
||||||
|
this.labelDumpBoxColor.TabIndex = 3;
|
||||||
|
this.labelDumpBoxColor.Text = "Цвет кузова";
|
||||||
|
this.labelDumpBoxColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
this.labelDumpBoxColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelDumpBoxColor_DragDrop);
|
||||||
|
this.labelDumpBoxColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter);
|
||||||
|
//
|
||||||
|
// labelBaseColor
|
||||||
|
//
|
||||||
|
this.labelBaseColor.AllowDrop = true;
|
||||||
|
this.labelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.labelBaseColor.Location = new System.Drawing.Point(46, 13);
|
||||||
|
this.labelBaseColor.Name = "labelBaseColor";
|
||||||
|
this.labelBaseColor.Size = new System.Drawing.Size(70, 40);
|
||||||
|
this.labelBaseColor.TabIndex = 2;
|
||||||
|
this.labelBaseColor.Text = "Основной цвет";
|
||||||
|
this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
this.labelBaseColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelBaseColor_DragDrop);
|
||||||
|
this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter);
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(527, 221);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(100, 30);
|
||||||
|
this.buttonAdd.TabIndex = 0;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(653, 221);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(100, 30);
|
||||||
|
this.buttonCancel.TabIndex = 3;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// FormTruckConfig
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 271);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonAdd);
|
||||||
|
this.Controls.Add(this.PanelObject);
|
||||||
|
this.Controls.Add(this.groupBoxParameters);
|
||||||
|
this.Name = "FormTruckConfig";
|
||||||
|
this.Text = "Создание объекта";
|
||||||
|
this.groupBoxParameters.ResumeLayout(false);
|
||||||
|
this.groupBoxParameters.PerformLayout();
|
||||||
|
this.groupBoxColors.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
|
||||||
|
this.PanelObject.ResumeLayout(false);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox groupBoxParameters;
|
||||||
|
private Label labelModifiedObject;
|
||||||
|
private Label labelSimpleObject;
|
||||||
|
private GroupBox groupBoxColors;
|
||||||
|
private Panel panelPurple;
|
||||||
|
private Panel panelBlack;
|
||||||
|
private Panel panelGray;
|
||||||
|
private Panel panelWhite;
|
||||||
|
private Panel panelYellow;
|
||||||
|
private Panel panelBlue;
|
||||||
|
private Panel panelGreen;
|
||||||
|
private Panel panelRed;
|
||||||
|
private CheckBox checkBoxTent;
|
||||||
|
private CheckBox checkBoxDumpBox;
|
||||||
|
private NumericUpDown numericUpDownWeight;
|
||||||
|
private NumericUpDown numericUpDownSpeed;
|
||||||
|
private Label labelWeight;
|
||||||
|
private Label labelSpeed;
|
||||||
|
private PictureBox pictureBoxObject;
|
||||||
|
private Panel PanelObject;
|
||||||
|
private Label labelDumpBoxColor;
|
||||||
|
private Label labelBaseColor;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Label labelTentColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
177
DumpTruck/FormTruckConfig.cs
Normal file
177
DumpTruck/FormTruckConfig.cs
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using DumpTruck.DrawingObjects;
|
||||||
|
using DumpTruck.Entities;
|
||||||
|
|
||||||
|
namespace DumpTruck
|
||||||
|
{
|
||||||
|
public partial class FormTruckConfig : Form
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Переменная-выбранный грузовик
|
||||||
|
/// </summary>
|
||||||
|
DrawingTruck? _truck = null;
|
||||||
|
/// <summary>
|
||||||
|
/// Событие
|
||||||
|
/// </summary>
|
||||||
|
private event Action<DrawingTruck>? EventAddTruck;
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public FormTruckConfig()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelGray.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelRed.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||||
|
buttonCancel.Click += (object sender, EventArgs e) => Close();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Отрисовать грузовик
|
||||||
|
/// </summary>
|
||||||
|
private void DrawTruck()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_truck?.SetPosition(5, 5);
|
||||||
|
_truck?.DrawTransport(gr);
|
||||||
|
pictureBoxObject.Image = bmp;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление события
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ev">Привязанный метод</param>
|
||||||
|
public void AddEvent(Action<DrawingTruck> ev)
|
||||||
|
{
|
||||||
|
if (EventAddTruck == null)
|
||||||
|
{
|
||||||
|
EventAddTruck = ev;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EventAddTruck += ev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Передаем информацию при нажатии на Label
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Действия при приеме перетаскиваемой информации
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||||
|
{
|
||||||
|
case "labelSimpleObject":
|
||||||
|
_truck = new DrawingTruck((int)numericUpDownSpeed.Value,
|
||||||
|
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
||||||
|
pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
case "labelModifiedObject":
|
||||||
|
_truck = new DrawingDumpTruck((int)numericUpDownSpeed.Value,
|
||||||
|
(int)numericUpDownWeight.Value, Color.White, checkBoxTent.Checked,
|
||||||
|
checkBoxDumpBox.Checked, Color.Black, Color.Gray, pictureBoxObject.Width,
|
||||||
|
pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawTruck();
|
||||||
|
}
|
||||||
|
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void labelColor_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void labelBaseColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_truck != null)
|
||||||
|
{
|
||||||
|
if (e.Data.GetDataPresent(typeof(Color)))
|
||||||
|
{
|
||||||
|
_truck.EntityTruck.BodyColor = (Color)e.Data.GetData(typeof(Color));
|
||||||
|
}
|
||||||
|
DrawTruck();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void labelDumpBoxColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_truck != null && _truck.EntityTruck is EntityDumpTruck entityDumpTruck)
|
||||||
|
{
|
||||||
|
if (e.Data.GetDataPresent(typeof(Color)))
|
||||||
|
{
|
||||||
|
entityDumpTruck.DumpBoxColor = (Color)e.Data.GetData(typeof(Color));
|
||||||
|
}
|
||||||
|
DrawTruck();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void labelTentColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_truck != null && _truck.EntityTruck is EntityDumpTruck entityDumpTruck)
|
||||||
|
{
|
||||||
|
if (e.Data.GetDataPresent(typeof(Color)))
|
||||||
|
{
|
||||||
|
entityDumpTruck.TentColor = (Color)e.Data.GetData(typeof(Color));
|
||||||
|
}
|
||||||
|
DrawTruck();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление грузовика
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
EventAddTruck?.Invoke(_truck);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
DumpTruck/FormTruckConfig.resx
Normal file
60
DumpTruck/FormTruckConfig.resx
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
@@ -16,25 +16,30 @@ namespace DumpTruck.Generics
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Массив объектов, которые храним
|
/// Массив объектов, которые храним
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly T?[] _places;
|
private readonly List<T?> _places;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Количество объектов в массиве
|
/// Количество объектов в массиве
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Count => _places.Length;
|
public int Count => _places.Count;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Максимальное количество объектов в списке
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="count"></param>
|
private readonly int _maxCount;
|
||||||
public SetGeneric(int count)
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="count"></param>
|
||||||
|
public SetGeneric(int count)
|
||||||
{
|
{
|
||||||
_places = new T?[count];
|
_maxCount = count;
|
||||||
|
_places = new List<T?>(count);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в набор
|
/// Добавление объекта в набор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="truck">Добавляемый грузовик</param>
|
/// <param name="truck">Добавляемый грузовик</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int Insert(T truck)
|
public int Insert(T truck)
|
||||||
{
|
{
|
||||||
return Insert(truck, 0);
|
return Insert(truck, 0);
|
||||||
}
|
}
|
||||||
@@ -46,25 +51,8 @@ namespace DumpTruck.Generics
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int Insert(T truck, int position)
|
public int Insert(T truck, int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count) return -1;
|
if (position < 0 || position > Count || Count >= _maxCount) return -1;
|
||||||
|
_places.Insert(position, truck);
|
||||||
int index = -1;
|
|
||||||
for (int i = position; i < Count; i++)
|
|
||||||
{
|
|
||||||
if (_places[i] == null)
|
|
||||||
{
|
|
||||||
index = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (index < 0) return -1;
|
|
||||||
|
|
||||||
for (int i = index; i > position; i--)
|
|
||||||
{
|
|
||||||
_places[i] = _places[i - 1];
|
|
||||||
}
|
|
||||||
_places[position] = truck;
|
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -75,18 +63,44 @@ namespace DumpTruck.Generics
|
|||||||
public bool Remove(int position)
|
public bool Remove(int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count) return false;
|
if (position < 0 || position >= Count) return false;
|
||||||
_places[position] = null;
|
_places.RemoveAt(position);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Получение объекта из набора по позиции
|
/// <summary>
|
||||||
/// </summary>
|
/// Получение объекта из набора по позиции
|
||||||
/// <param name="position"></param>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <param name="position"></param>
|
||||||
public T? Get(int position)
|
/// <returns></returns>
|
||||||
{
|
public T? this[int position]
|
||||||
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Проход по списку
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IEnumerable<T?> GetTrucks(int? maxTrucks = null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _places.Count; ++i)
|
||||||
|
{
|
||||||
|
yield return _places[i];
|
||||||
|
if (maxTrucks.HasValue && i == maxTrucks.Value)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using DumpTruck.DrawingObjects;
|
using DumpTruck.DrawingObjects;
|
||||||
@@ -65,35 +64,35 @@ namespace DumpTruck.Generics
|
|||||||
}
|
}
|
||||||
return collect._collection.Insert(obj);
|
return collect._collection.Insert(obj);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перегрузка оператора вычитания
|
/// Перегрузка оператора вычитания
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="collect"></param>
|
/// <param name="collect"></param>
|
||||||
/// <param name="pos"></param>
|
/// <param name="pos"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool operator -(TrucksGenericCollection<T, U> collect, int pos)
|
public static T? operator -(TrucksGenericCollection<T, U> collect, int pos)
|
||||||
{
|
{
|
||||||
T? obj = collect._collection.Get(pos);
|
T? obj = collect._collection[pos];
|
||||||
if (obj != null)
|
if (obj != null)
|
||||||
{
|
{
|
||||||
return collect._collection.Remove(pos);
|
collect._collection.Remove(pos);
|
||||||
}
|
}
|
||||||
return false;
|
return obj;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение объекта IMoveableObject
|
/// Получение объекта IMoveableObject
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="pos"></param>
|
/// <param name="pos"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public U? GetU(int pos)
|
public U? GetU(int pos)
|
||||||
{
|
{
|
||||||
return (U?)_collection.Get(pos)?.GetMoveableObject;
|
return (U?)_collection[pos]?.GetMoveableObject;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вывод всего набора объектов
|
/// Вывод всего набора объектов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Bitmap ShowTrucks()
|
public Bitmap ShowTrucks()
|
||||||
{
|
{
|
||||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
@@ -127,15 +126,15 @@ namespace DumpTruck.Generics
|
|||||||
/// <param name="g"></param>
|
/// <param name="g"></param>
|
||||||
private void DrawObjects(Graphics g)
|
private void DrawObjects(Graphics g)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _collection.Count; i++)
|
int index = 0;
|
||||||
{
|
foreach (var truck in _collection.GetTrucks())
|
||||||
T? obj = _collection.Get(i);
|
{
|
||||||
|
if (truck != null)
|
||||||
if (obj != null)
|
|
||||||
{
|
{
|
||||||
obj.SetPosition(i % (_pictureWidth / _placeSizeWidth) * _placeSizeWidth, i / (_pictureWidth / _placeSizeWidth) * _placeSizeHeight);
|
truck.SetPosition(index % (_pictureWidth / _placeSizeWidth) * _placeSizeWidth, index / (_pictureWidth / _placeSizeWidth) * _placeSizeHeight);
|
||||||
obj.DrawTransport(g);
|
truck.DrawTransport(g);
|
||||||
}
|
}
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
74
DumpTruck/Generics/TrucksGenericStorage.cs
Normal file
74
DumpTruck/Generics/TrucksGenericStorage.cs
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DumpTruck.DrawingObjects;
|
||||||
|
using DumpTruck.MovementStrategy;
|
||||||
|
|
||||||
|
namespace DumpTruck.Generics
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Класс для хранения коллекции
|
||||||
|
/// </summary>
|
||||||
|
internal class TrucksGenericStorage
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Словарь (хранилище)
|
||||||
|
/// </summary>
|
||||||
|
readonly Dictionary<string, TrucksGenericCollection<DrawingTruck, DrawningObjectTruck>> _truckStorages;
|
||||||
|
/// <summary>
|
||||||
|
/// Возвращение списка названий наборов
|
||||||
|
/// </summary>
|
||||||
|
public List<string> Keys => _truckStorages.Keys.ToList();
|
||||||
|
/// <summary>
|
||||||
|
/// Ширина окна отрисовки
|
||||||
|
/// </summary>
|
||||||
|
private readonly int _pictureWidth;
|
||||||
|
/// <summary>
|
||||||
|
/// Высота окна отрисовки
|
||||||
|
/// </summary>
|
||||||
|
private readonly int _pictureHeight;
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pictureWidth"></param>
|
||||||
|
/// <param name="pictureHeight"></param>
|
||||||
|
public TrucksGenericStorage(int pictureWidth, int pictureHeight)
|
||||||
|
{
|
||||||
|
_truckStorages = new Dictionary<string, TrucksGenericCollection<DrawingTruck, DrawningObjectTruck>>();
|
||||||
|
_pictureWidth = pictureWidth;
|
||||||
|
_pictureHeight = pictureHeight;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление набора
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название набора</param>
|
||||||
|
public void AddSet(string name)
|
||||||
|
{
|
||||||
|
if (!_truckStorages.ContainsKey(name)) _truckStorages.Add(name, new TrucksGenericCollection<DrawingTruck, DrawningObjectTruck>(_pictureWidth, _pictureHeight));
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление набора
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название набора</param>
|
||||||
|
public void DelSet(string name)
|
||||||
|
{
|
||||||
|
if (_truckStorages.ContainsKey(name)) _truckStorages.Remove(name);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Доступ к набору
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ind"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public TrucksGenericCollection<DrawingTruck, DrawningObjectTruck>?
|
||||||
|
this[string ind]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_truckStorages.ContainsKey(ind)) return _truckStorages[ind];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user