lab5
This commit is contained in:
parent
219fd8b30d
commit
8f36025e6b
@ -60,5 +60,10 @@ namespace DumpTruck.DrawningObjects
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetAdditionalColor(Color color)
|
||||||
|
{
|
||||||
|
(EntityTruck as EntityDumpTruck).SetAdditionalColor(color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,11 @@ namespace DumpTruck.DrawningObjects
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина окна
|
/// Ширина окна
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int _pictureWidth;
|
public int _pictureWidth;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота окна
|
/// Высота окна
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int _pictureHeight;
|
public int _pictureHeight;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Левая координата прорисовки автомобиля
|
/// Левая координата прорисовки автомобиля
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -224,5 +224,10 @@ namespace DumpTruck.DrawningObjects
|
|||||||
g.DrawEllipse(penBlack, _startPosX + 22, _startPosY + 35, 20, 20);
|
g.DrawEllipse(penBlack, _startPosX + 22, _startPosY + 35, 20, 20);
|
||||||
g.DrawEllipse(penBlack, _startPosX + 80, _startPosY + 35, 20, 20);
|
g.DrawEllipse(penBlack, _startPosX + 80, _startPosY + 35, 20, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetBodyColor(Color color)
|
||||||
|
{
|
||||||
|
EntityTruck.SetBodyColor(color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,5 +39,10 @@ namespace DumpTruck.Entities
|
|||||||
BodyKit = bodyKit;
|
BodyKit = bodyKit;
|
||||||
Tent = tent;
|
Tent = tent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetAdditionalColor(Color color)
|
||||||
|
{
|
||||||
|
AdditionalColor = color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,5 +40,10 @@ namespace DumpTruck.Entities
|
|||||||
Weight = weight;
|
Weight = weight;
|
||||||
BodyColor = bodyColor;
|
BodyColor = bodyColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetBodyColor(Color color)
|
||||||
|
{
|
||||||
|
BodyColor = color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
DumpTruck/DumpTruck/FormDumpTruck.Designer.cs
generated
8
DumpTruck/DumpTruck/FormDumpTruck.Designer.cs
generated
@ -65,7 +65,7 @@
|
|||||||
// buttonLeft
|
// buttonLeft
|
||||||
//
|
//
|
||||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
//buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
|
buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
|
||||||
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
buttonLeft.Location = new Point(770, 426);
|
buttonLeft.Location = new Point(770, 426);
|
||||||
buttonLeft.Name = "buttonLeft";
|
buttonLeft.Name = "buttonLeft";
|
||||||
@ -77,7 +77,7 @@
|
|||||||
// buttonUp
|
// buttonUp
|
||||||
//
|
//
|
||||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
//buttonUp.BackgroundImage = Properties.Resources.arrowUp;
|
buttonUp.BackgroundImage = Properties.Resources.arrowUp;
|
||||||
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
buttonUp.Location = new Point(806, 390);
|
buttonUp.Location = new Point(806, 390);
|
||||||
buttonUp.Name = "buttonUp";
|
buttonUp.Name = "buttonUp";
|
||||||
@ -89,7 +89,7 @@
|
|||||||
// buttonDown
|
// buttonDown
|
||||||
//
|
//
|
||||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
//buttonDown.BackgroundImage = Properties.Resources.arrowDown;
|
buttonDown.BackgroundImage = Properties.Resources.arrowDown;
|
||||||
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
buttonDown.Location = new Point(806, 426);
|
buttonDown.Location = new Point(806, 426);
|
||||||
buttonDown.Name = "buttonDown";
|
buttonDown.Name = "buttonDown";
|
||||||
@ -101,7 +101,7 @@
|
|||||||
// buttonRight
|
// buttonRight
|
||||||
//
|
//
|
||||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
//buttonRight.BackgroundImage = Properties.Resources.arrowRight;
|
buttonRight.BackgroundImage = Properties.Resources.arrowRight;
|
||||||
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
buttonRight.Location = new Point(842, 426);
|
buttonRight.Location = new Point(842, 426);
|
||||||
buttonRight.Name = "buttonRight";
|
buttonRight.Name = "buttonRight";
|
||||||
|
@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
@ -51,32 +52,39 @@ namespace DumpTruck
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddTruck(DrawningTruck truck)
|
||||||
private void buttonAddTruck_Click(object sender, EventArgs e)
|
|
||||||
{
|
{
|
||||||
|
truck._pictureWidth = pictureBoxCollection.Width;
|
||||||
|
truck._pictureHeight = pictureBoxCollection.Height;
|
||||||
|
|
||||||
if (listBoxStorages.SelectedIndex == -1)
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
|
||||||
string.Empty];
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FormDumpTruck form = new();
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (obj + truck != -1)
|
||||||
{
|
{
|
||||||
if (obj + form.selectedTruck != -1)
|
MessageBox.Show("Объект добавлен");
|
||||||
{
|
pictureBoxCollection.Image = obj.ShowTrucks();
|
||||||
MessageBox.Show("Объект добавлен");
|
|
||||||
pictureBoxCollection.Image = obj.ShowTrucks();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAddTruck_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var formTruckConfig = new FormTruckConfig();
|
||||||
|
formTruckConfig.AddEvent(AddTruck);
|
||||||
|
formTruckConfig.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonRemoveTruck_Click(object sender, EventArgs e)
|
private void buttonRemoveTruck_Click(object sender, EventArgs e)
|
||||||
|
364
DumpTruck/DumpTruck/FormTruckConfig.Designer.cs
generated
Normal file
364
DumpTruck/DumpTruck/FormTruckConfig.Designer.cs
generated
Normal file
@ -0,0 +1,364 @@
|
|||||||
|
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()
|
||||||
|
{
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
labelModifiedObject = new Label();
|
||||||
|
labelSimpleObject = new Label();
|
||||||
|
groupBox2 = new GroupBox();
|
||||||
|
panelPurple = new Panel();
|
||||||
|
panelBlack = new Panel();
|
||||||
|
panelGray = new Panel();
|
||||||
|
panelWhite = new Panel();
|
||||||
|
panelYellow = new Panel();
|
||||||
|
panelBlue = new Panel();
|
||||||
|
panelGreen = new Panel();
|
||||||
|
panelRed = new Panel();
|
||||||
|
checkBoxTent = new CheckBox();
|
||||||
|
checkBoxBodyKit = new CheckBox();
|
||||||
|
numericUpDownWeight = new NumericUpDown();
|
||||||
|
numericUpDownSpeed = new NumericUpDown();
|
||||||
|
label2 = new Label();
|
||||||
|
label1 = new Label();
|
||||||
|
panelObject = new Panel();
|
||||||
|
pictureBoxObject = new PictureBox();
|
||||||
|
labelAdditionalColor = new Label();
|
||||||
|
labelColor = new Label();
|
||||||
|
buttonOk = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
groupBox2.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||||
|
panelObject.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Controls.Add(labelModifiedObject);
|
||||||
|
groupBox1.Controls.Add(labelSimpleObject);
|
||||||
|
groupBox1.Controls.Add(groupBox2);
|
||||||
|
groupBox1.Controls.Add(checkBoxTent);
|
||||||
|
groupBox1.Controls.Add(checkBoxBodyKit);
|
||||||
|
groupBox1.Controls.Add(numericUpDownWeight);
|
||||||
|
groupBox1.Controls.Add(numericUpDownSpeed);
|
||||||
|
groupBox1.Controls.Add(label2);
|
||||||
|
groupBox1.Controls.Add(label1);
|
||||||
|
groupBox1.Location = new Point(12, 12);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Size = new Size(444, 196);
|
||||||
|
groupBox1.TabIndex = 0;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "Параметры";
|
||||||
|
//
|
||||||
|
// labelModifiedObject
|
||||||
|
//
|
||||||
|
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelModifiedObject.Location = new Point(344, 156);
|
||||||
|
labelModifiedObject.Name = "labelModifiedObject";
|
||||||
|
labelModifiedObject.Size = new Size(94, 23);
|
||||||
|
labelModifiedObject.TabIndex = 8;
|
||||||
|
labelModifiedObject.Text = "Продвинутый";
|
||||||
|
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||||
|
//
|
||||||
|
// labelSimpleObject
|
||||||
|
//
|
||||||
|
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelSimpleObject.Location = new Point(238, 156);
|
||||||
|
labelSimpleObject.Name = "labelSimpleObject";
|
||||||
|
labelSimpleObject.Size = new Size(100, 23);
|
||||||
|
labelSimpleObject.TabIndex = 7;
|
||||||
|
labelSimpleObject.Text = "Простой";
|
||||||
|
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||||
|
//
|
||||||
|
// groupBox2
|
||||||
|
//
|
||||||
|
groupBox2.Controls.Add(panelPurple);
|
||||||
|
groupBox2.Controls.Add(panelBlack);
|
||||||
|
groupBox2.Controls.Add(panelGray);
|
||||||
|
groupBox2.Controls.Add(panelWhite);
|
||||||
|
groupBox2.Controls.Add(panelYellow);
|
||||||
|
groupBox2.Controls.Add(panelBlue);
|
||||||
|
groupBox2.Controls.Add(panelGreen);
|
||||||
|
groupBox2.Controls.Add(panelRed);
|
||||||
|
groupBox2.Location = new Point(238, 22);
|
||||||
|
groupBox2.Name = "groupBox2";
|
||||||
|
groupBox2.Size = new Size(200, 127);
|
||||||
|
groupBox2.TabIndex = 6;
|
||||||
|
groupBox2.TabStop = false;
|
||||||
|
groupBox2.Text = "Цвета";
|
||||||
|
//
|
||||||
|
// panelPurple
|
||||||
|
//
|
||||||
|
panelPurple.BackColor = Color.Purple;
|
||||||
|
panelPurple.Location = new Point(137, 70);
|
||||||
|
panelPurple.Name = "panelPurple";
|
||||||
|
panelPurple.Size = new Size(33, 32);
|
||||||
|
panelPurple.TabIndex = 1;
|
||||||
|
panelPurple.MouseDown += panelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelBlack
|
||||||
|
//
|
||||||
|
panelBlack.BackColor = Color.Black;
|
||||||
|
panelBlack.Location = new Point(98, 70);
|
||||||
|
panelBlack.Name = "panelBlack";
|
||||||
|
panelBlack.Size = new Size(33, 32);
|
||||||
|
panelBlack.TabIndex = 1;
|
||||||
|
panelBlack.MouseDown += panelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelGray
|
||||||
|
//
|
||||||
|
panelGray.BackColor = Color.Gray;
|
||||||
|
panelGray.Location = new Point(59, 70);
|
||||||
|
panelGray.Name = "panelGray";
|
||||||
|
panelGray.Size = new Size(33, 32);
|
||||||
|
panelGray.TabIndex = 1;
|
||||||
|
panelGray.MouseDown += panelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelWhite
|
||||||
|
//
|
||||||
|
panelWhite.BackColor = Color.White;
|
||||||
|
panelWhite.Location = new Point(20, 70);
|
||||||
|
panelWhite.Name = "panelWhite";
|
||||||
|
panelWhite.Size = new Size(33, 32);
|
||||||
|
panelWhite.TabIndex = 1;
|
||||||
|
panelWhite.MouseDown += panelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelYellow
|
||||||
|
//
|
||||||
|
panelYellow.BackColor = Color.Yellow;
|
||||||
|
panelYellow.Location = new Point(137, 32);
|
||||||
|
panelYellow.Name = "panelYellow";
|
||||||
|
panelYellow.Size = new Size(33, 32);
|
||||||
|
panelYellow.TabIndex = 1;
|
||||||
|
panelYellow.MouseDown += panelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelBlue
|
||||||
|
//
|
||||||
|
panelBlue.BackColor = Color.Blue;
|
||||||
|
panelBlue.Location = new Point(98, 32);
|
||||||
|
panelBlue.Name = "panelBlue";
|
||||||
|
panelBlue.Size = new Size(33, 32);
|
||||||
|
panelBlue.TabIndex = 1;
|
||||||
|
panelBlue.MouseDown += panelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelGreen
|
||||||
|
//
|
||||||
|
panelGreen.BackColor = Color.Green;
|
||||||
|
panelGreen.Location = new Point(59, 32);
|
||||||
|
panelGreen.Name = "panelGreen";
|
||||||
|
panelGreen.Size = new Size(33, 32);
|
||||||
|
panelGreen.TabIndex = 1;
|
||||||
|
panelGreen.MouseDown += panelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelRed
|
||||||
|
//
|
||||||
|
panelRed.BackColor = Color.Red;
|
||||||
|
panelRed.Location = new Point(20, 32);
|
||||||
|
panelRed.Name = "panelRed";
|
||||||
|
panelRed.Size = new Size(33, 32);
|
||||||
|
panelRed.TabIndex = 0;
|
||||||
|
panelRed.MouseDown += panelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// checkBoxTent
|
||||||
|
//
|
||||||
|
checkBoxTent.AutoSize = true;
|
||||||
|
checkBoxTent.Location = new Point(15, 156);
|
||||||
|
checkBoxTent.Name = "checkBoxTent";
|
||||||
|
checkBoxTent.Size = new Size(155, 19);
|
||||||
|
checkBoxTent.TabIndex = 5;
|
||||||
|
checkBoxTent.Text = "Признак наличия тента";
|
||||||
|
checkBoxTent.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxBodyKit
|
||||||
|
//
|
||||||
|
checkBoxBodyKit.AutoSize = true;
|
||||||
|
checkBoxBodyKit.Location = new Point(15, 117);
|
||||||
|
checkBoxBodyKit.Name = "checkBoxBodyKit";
|
||||||
|
checkBoxBodyKit.Size = new Size(162, 19);
|
||||||
|
checkBoxBodyKit.TabIndex = 4;
|
||||||
|
checkBoxBodyKit.Text = "Признак наличия кузова";
|
||||||
|
checkBoxBodyKit.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// numericUpDownWeight
|
||||||
|
//
|
||||||
|
numericUpDownWeight.Location = new Point(83, 77);
|
||||||
|
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||||
|
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
numericUpDownWeight.Name = "numericUpDownWeight";
|
||||||
|
numericUpDownWeight.Size = new Size(120, 23);
|
||||||
|
numericUpDownWeight.TabIndex = 3;
|
||||||
|
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// numericUpDownSpeed
|
||||||
|
//
|
||||||
|
numericUpDownSpeed.Location = new Point(83, 31);
|
||||||
|
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||||
|
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||||
|
numericUpDownSpeed.Size = new Size(120, 23);
|
||||||
|
numericUpDownSpeed.TabIndex = 2;
|
||||||
|
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(15, 79);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(29, 15);
|
||||||
|
label2.TabIndex = 1;
|
||||||
|
label2.Text = "Вес:";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(15, 33);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(62, 15);
|
||||||
|
label1.TabIndex = 0;
|
||||||
|
label1.Text = "Скорость:";
|
||||||
|
//
|
||||||
|
// panelObject
|
||||||
|
//
|
||||||
|
panelObject.AllowDrop = true;
|
||||||
|
panelObject.Controls.Add(pictureBoxObject);
|
||||||
|
panelObject.Controls.Add(labelAdditionalColor);
|
||||||
|
panelObject.Controls.Add(labelColor);
|
||||||
|
panelObject.Location = new Point(462, 12);
|
||||||
|
panelObject.Name = "panelObject";
|
||||||
|
panelObject.Size = new Size(214, 175);
|
||||||
|
panelObject.TabIndex = 2;
|
||||||
|
panelObject.DragDrop += PanelObject_DragDrop;
|
||||||
|
panelObject.DragEnter += PanelObject_DragEnter;
|
||||||
|
//
|
||||||
|
// pictureBoxObject
|
||||||
|
//
|
||||||
|
pictureBoxObject.Location = new Point(13, 50);
|
||||||
|
pictureBoxObject.Name = "pictureBoxObject";
|
||||||
|
pictureBoxObject.Size = new Size(188, 122);
|
||||||
|
pictureBoxObject.TabIndex = 10;
|
||||||
|
pictureBoxObject.TabStop = false;
|
||||||
|
//
|
||||||
|
// labelAdditionalColor
|
||||||
|
//
|
||||||
|
labelAdditionalColor.AllowDrop = true;
|
||||||
|
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelAdditionalColor.Location = new Point(107, 9);
|
||||||
|
labelAdditionalColor.Name = "labelAdditionalColor";
|
||||||
|
labelAdditionalColor.Size = new Size(94, 38);
|
||||||
|
labelAdditionalColor.TabIndex = 9;
|
||||||
|
labelAdditionalColor.Text = "Доп. цвет";
|
||||||
|
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelAdditionalColor.DragDrop += labelColor_DragDrop;
|
||||||
|
labelAdditionalColor.DragEnter += labelColor_DragEnter;
|
||||||
|
//
|
||||||
|
// labelColor
|
||||||
|
//
|
||||||
|
labelColor.AllowDrop = true;
|
||||||
|
labelColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelColor.Location = new Point(13, 9);
|
||||||
|
labelColor.Name = "labelColor";
|
||||||
|
labelColor.Size = new Size(88, 38);
|
||||||
|
labelColor.TabIndex = 8;
|
||||||
|
labelColor.Text = "Цвет";
|
||||||
|
labelColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelColor.DragDrop += labelColor_DragDrop;
|
||||||
|
labelColor.DragEnter += labelColor_DragEnter;
|
||||||
|
//
|
||||||
|
// buttonOk
|
||||||
|
//
|
||||||
|
buttonOk.Location = new Point(475, 193);
|
||||||
|
buttonOk.Name = "buttonOk";
|
||||||
|
buttonOk.Size = new Size(75, 23);
|
||||||
|
buttonOk.TabIndex = 3;
|
||||||
|
buttonOk.Text = "Добавить";
|
||||||
|
buttonOk.UseVisualStyleBackColor = true;
|
||||||
|
buttonOk.Click += buttonOk_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(588, 193);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(75, 23);
|
||||||
|
buttonCancel.TabIndex = 4;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// FormTruckConfig
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(690, 227);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonOk);
|
||||||
|
Controls.Add(panelObject);
|
||||||
|
Controls.Add(groupBox1);
|
||||||
|
Name = "FormTruckConfig";
|
||||||
|
Text = "Создание объекта";
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
groupBox1.PerformLayout();
|
||||||
|
groupBox2.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||||
|
panelObject.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private GroupBox groupBox2;
|
||||||
|
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 checkBoxBodyKit;
|
||||||
|
private NumericUpDown numericUpDownWeight;
|
||||||
|
private NumericUpDown numericUpDownSpeed;
|
||||||
|
private Label label2;
|
||||||
|
private Label label1;
|
||||||
|
private Label labelModifiedObject;
|
||||||
|
private Label labelSimpleObject;
|
||||||
|
private Panel panelObject;
|
||||||
|
private Label labelAdditionalColor;
|
||||||
|
private Label labelColor;
|
||||||
|
private Button buttonOk;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private PictureBox pictureBoxObject;
|
||||||
|
}
|
||||||
|
}
|
172
DumpTruck/DumpTruck/FormTruckConfig.cs
Normal file
172
DumpTruck/DumpTruck/FormTruckConfig.cs
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
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.DrawningObjects;
|
||||||
|
|
||||||
|
namespace DumpTruck
|
||||||
|
{
|
||||||
|
public partial class FormTruckConfig : Form
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Переменная-выбранная машина
|
||||||
|
/// </summary>
|
||||||
|
DrawningTruck? _truck = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Событие
|
||||||
|
/// </summary>
|
||||||
|
private event Action<DrawningTruck> 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 += (sender, 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<DrawningTruck> 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void panelColor_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void labelColor_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data?.GetDataPresent(typeof(Color)) ?? 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 DrawningTruck((int)numericUpDownSpeed.Value,
|
||||||
|
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
||||||
|
pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
case "labelModifiedObject":
|
||||||
|
_truck = new DrawningDumpTruck((int)numericUpDownSpeed.Value,
|
||||||
|
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxBodyKit.Checked,
|
||||||
|
checkBoxTent.Checked, pictureBoxObject.Width,
|
||||||
|
pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawTruck();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void labelColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_truck == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||||
|
switch (((Label)sender).Name)
|
||||||
|
{
|
||||||
|
case "labelColor":
|
||||||
|
_truck.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
break;
|
||||||
|
case "labelAdditionalColor":
|
||||||
|
if (!(_truck is DrawningDumpTruck))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
(_truck as DrawningDumpTruck).SetAdditionalColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawTruck();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление машины
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void buttonOk_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
EventAddTruck?.Invoke(_truck);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
DumpTruck/DumpTruck/FormTruckConfig.resx
Normal file
120
DumpTruck/DumpTruck/FormTruckConfig.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<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>
|
Loading…
Reference in New Issue
Block a user