PIbd-21. Kryukov A.I. Lab work 05 base #20
@ -5,9 +5,9 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectExcavator.Entities;
|
||||
|
||||
namespace ProjectExcavator.DrawningObjects
|
||||
namespace ProjectExcavator
|
||||
{
|
||||
public class DrawningExcavarorBodyKits : DrawningExcavator
|
||||
public class DrawningExcavatorBodyKits : DrawningExcavator
|
||||
{
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
@ -20,7 +20,7 @@ namespace ProjectExcavator.DrawningObjects
|
||||
/// <param name="bucket">Признак наличия антикрыла</param>
|
||||
/// <param name="width">Ширина картинки</param>
|
||||
/// <param name="height">Высота картинки</param>
|
||||
public DrawningExcavarorBodyKits(int speed, double weight,
|
||||
public DrawningExcavatorBodyKits(int speed, double weight,
|
||||
Color bodyColor, Color additionalColor,
|
||||
bool bodyKit, bool bucket,
|
||||
int width, int height) :
|
||||
|
@ -6,10 +6,10 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectExcavator.DrawningObjects
|
||||
namespace ProjectExcavator
|
||||
{
|
||||
public class DrawningExcavator
|
||||
{
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
@ -21,11 +21,11 @@ namespace ProjectExcavator.DrawningObjects
|
||||
/// <summary>
|
||||
/// Ширина окна
|
||||
/// </summary>
|
||||
private int _pictureWidth;
|
||||
public int _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна
|
||||
/// </summary>
|
||||
private int _pictureHeight;
|
||||
public int _pictureHeight;
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки экскаватора
|
||||
/// </summary>
|
||||
@ -68,12 +68,12 @@ namespace ProjectExcavator.DrawningObjects
|
||||
public DrawningExcavator(int speed, double weight, Color bodyColor, int
|
||||
width, int height)
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
if (_pictureHeight < _excavatorHeight || _pictureWidth < _excavatorWidth)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
}
|
||||
EntityExcavator = new EntityExcavator(speed, weight, bodyColor);
|
||||
}
|
||||
/// <summary>
|
||||
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectExcavator.DrawningObjects;
|
||||
|
||||
|
||||
namespace ProjectExcavator.MovementStrategy
|
||||
{
|
||||
|
@ -20,6 +20,10 @@ namespace ProjectExcavator.Entities
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
public void setBodyColor(Color color)
|
||||
{
|
||||
BodyColor = color;
|
||||
}
|
||||
/// <summary>
|
||||
/// Шаг перемещения экскаватора
|
||||
/// </summary>
|
||||
|
@ -18,6 +18,10 @@ namespace ProjectExcavator.Entities
|
||||
/// Дополнительный цвет (для опциональных элементов)
|
||||
/// </summary>
|
||||
public Color AdditionalColor { get; private set; }
|
||||
public void setAdditionalColor(Color color)
|
||||
{
|
||||
AdditionalColor = color;
|
||||
}
|
||||
/// <summary>
|
||||
/// признак наличия вспомогательных опор
|
||||
/// </summary>
|
||||
|
@ -1,4 +1,4 @@
|
||||
using ProjectExcavator.DrawningObjects;
|
||||
using ProjectExcavator;
|
||||
using ProjectExcavator.MovementStrategy;
|
||||
using System.Drawing;
|
||||
|
||||
@ -106,7 +106,7 @@ namespace ProjectExcavator
|
||||
{
|
||||
dopcolor = dopDialog.Color;
|
||||
}
|
||||
_drawnigExcavator = new DrawningExcavarorBodyKits(random.Next(100, 300),
|
||||
_drawnigExcavator = new DrawningExcavatorBodyKits(random.Next(100, 300),
|
||||
random.Next(1000, 3000),
|
||||
color,
|
||||
dopcolor,
|
||||
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectExcavator.MovementStrategy;
|
||||
using ProjectExcavator.DrawningObjects;
|
||||
using ProjectExcavator;
|
||||
using ProjectExcavator.Generic;
|
||||
|
||||
namespace ProjectExcavator.Generic
|
||||
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectExcavator.DrawningObjects;
|
||||
using ProjectExcavator;
|
||||
using ProjectExcavator.Generic;
|
||||
using ProjectExcavator.MovementStrategy;
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
using ProjectExcavator.DrawningObjects;
|
||||
using ProjectExcavator;
|
||||
using ProjectExcavator.Generic;
|
||||
using ProjectExcavator.MovementStrategy;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
@ -14,8 +14,7 @@ using System.Windows.Forms;
|
||||
namespace ProjectExcavator
|
||||
{
|
||||
public partial class FormExcavatorCollection : Form
|
||||
{
|
||||
private readonly ExcavatorGenericCollection<DrawningExcavator, DrawningObjectExcavator> _excavators;
|
||||
{
|
||||
/// <summary>
|
||||
/// Набор объектов
|
||||
/// </summary>
|
||||
@ -85,6 +84,27 @@ pictureBoxCollection.Height);
|
||||
ReloadObjects();
|
||||
}
|
||||
}
|
||||
private void AddExcavator(DrawningExcavator excavator)
|
||||
{
|
||||
if(listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if((obj + excavator) != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowExcavator();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAddExcavator_Click(object sender, EventArgs e)
|
||||
{
|
||||
@ -97,19 +117,9 @@ pictureBoxCollection.Height);
|
||||
{
|
||||
return;
|
||||
}
|
||||
ExcavatorForm form = new ExcavatorForm();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if ((obj + form.SelectedExcavator) != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowExcavator();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
FormExcavatorConfig form = new FormExcavatorConfig();
|
||||
form.Show();
|
||||
form.AddEvent(AddExcavator);
|
||||
}
|
||||
|
||||
private void buttonRemoveExcavator_Click(object sender, EventArgs e)
|
||||
|
364
ProjectExcavator/ProjectExcavator/FormExcavatorConfig.Designer.cs
generated
Normal file
364
ProjectExcavator/ProjectExcavator/FormExcavatorConfig.Designer.cs
generated
Normal file
@ -0,0 +1,364 @@
|
||||
namespace ProjectExcavator
|
||||
{
|
||||
partial class FormExcavatorConfig
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
groupBoxParameters = new GroupBox();
|
||||
labelModifiedObject = new Label();
|
||||
labelSimpleObject = new Label();
|
||||
groupBoxColors = new GroupBox();
|
||||
panelOrange = new Panel();
|
||||
panelSilver = new Panel();
|
||||
panelYellow = new Panel();
|
||||
panelCyan = new Panel();
|
||||
panelBlue = new Panel();
|
||||
panelFuchsia = new Panel();
|
||||
panelLime = new Panel();
|
||||
panelRed = new Panel();
|
||||
checkBoxBodyKits = new CheckBox();
|
||||
checkBoxBacket = new CheckBox();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
labelWeight = new Label();
|
||||
labelSpeed = new Label();
|
||||
pictureBoxObject = new PictureBox();
|
||||
panel9 = new Panel();
|
||||
labelColor = new Label();
|
||||
labelAdditionalColor = new Label();
|
||||
buttonAdd = new Button();
|
||||
buttonCansel = new Button();
|
||||
groupBoxParameters.SuspendLayout();
|
||||
groupBoxColors.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||
panel9.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxParameters
|
||||
//
|
||||
groupBoxParameters.Controls.Add(labelModifiedObject);
|
||||
groupBoxParameters.Controls.Add(labelSimpleObject);
|
||||
groupBoxParameters.Controls.Add(groupBoxColors);
|
||||
groupBoxParameters.Controls.Add(checkBoxBodyKits);
|
||||
groupBoxParameters.Controls.Add(checkBoxBacket);
|
||||
groupBoxParameters.Controls.Add(numericUpDownWeight);
|
||||
groupBoxParameters.Controls.Add(numericUpDownSpeed);
|
||||
groupBoxParameters.Controls.Add(labelWeight);
|
||||
groupBoxParameters.Controls.Add(labelSpeed);
|
||||
groupBoxParameters.Location = new Point(12, 12);
|
||||
groupBoxParameters.Name = "groupBoxParameters";
|
||||
groupBoxParameters.Size = new Size(266, 426);
|
||||
groupBoxParameters.TabIndex = 0;
|
||||
groupBoxParameters.TabStop = false;
|
||||
groupBoxParameters.Text = "Параметры";
|
||||
//
|
||||
// labelModifiedObject
|
||||
//
|
||||
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelModifiedObject.Location = new Point(128, 383);
|
||||
labelModifiedObject.Name = "labelModifiedObject";
|
||||
labelModifiedObject.Size = new Size(97, 29);
|
||||
labelModifiedObject.TabIndex = 9;
|
||||
labelModifiedObject.Text = "Продвинутый";
|
||||
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelSimpleObject.Location = new Point(12, 383);
|
||||
labelSimpleObject.Name = "labelSimpleObject";
|
||||
labelSimpleObject.Size = new Size(99, 29);
|
||||
labelSimpleObject.TabIndex = 1;
|
||||
labelSimpleObject.Text = "Простой";
|
||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// groupBoxColors
|
||||
//
|
||||
groupBoxColors.Controls.Add(panelOrange);
|
||||
groupBoxColors.Controls.Add(panelSilver);
|
||||
groupBoxColors.Controls.Add(panelYellow);
|
||||
groupBoxColors.Controls.Add(panelCyan);
|
||||
groupBoxColors.Controls.Add(panelBlue);
|
||||
groupBoxColors.Controls.Add(panelFuchsia);
|
||||
groupBoxColors.Controls.Add(panelLime);
|
||||
groupBoxColors.Controls.Add(panelRed);
|
||||
groupBoxColors.Location = new Point(6, 235);
|
||||
groupBoxColors.Name = "groupBoxColors";
|
||||
groupBoxColors.Size = new Size(234, 119);
|
||||
groupBoxColors.TabIndex = 8;
|
||||
groupBoxColors.TabStop = false;
|
||||
groupBoxColors.Text = "Цвета";
|
||||
//
|
||||
// panelOrange
|
||||
//
|
||||
panelOrange.BackColor = Color.FromArgb(255, 128, 0);
|
||||
panelOrange.Location = new Point(6, 68);
|
||||
panelOrange.Name = "panelOrange";
|
||||
panelOrange.Size = new Size(40, 40);
|
||||
panelOrange.TabIndex = 2;
|
||||
panelOrange.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelSilver
|
||||
//
|
||||
panelSilver.BackColor = Color.Silver;
|
||||
panelSilver.Location = new Point(65, 68);
|
||||
panelSilver.Name = "panelSilver";
|
||||
panelSilver.Size = new Size(40, 40);
|
||||
panelSilver.TabIndex = 2;
|
||||
panelSilver.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
panelYellow.BackColor = Color.Yellow;
|
||||
panelYellow.Location = new Point(122, 68);
|
||||
panelYellow.Name = "panelYellow";
|
||||
panelYellow.Size = new Size(40, 40);
|
||||
panelYellow.TabIndex = 2;
|
||||
panelYellow.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelCyan
|
||||
//
|
||||
panelCyan.BackColor = Color.Cyan;
|
||||
panelCyan.Location = new Point(179, 68);
|
||||
panelCyan.Name = "panelCyan";
|
||||
panelCyan.Size = new Size(40, 40);
|
||||
panelCyan.TabIndex = 2;
|
||||
panelCyan.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
panelBlue.BackColor = Color.Blue;
|
||||
panelBlue.Location = new Point(179, 22);
|
||||
panelBlue.Name = "panelBlue";
|
||||
panelBlue.Size = new Size(40, 40);
|
||||
panelBlue.TabIndex = 2;
|
||||
panelBlue.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelFuchsia
|
||||
//
|
||||
panelFuchsia.BackColor = Color.Fuchsia;
|
||||
panelFuchsia.Location = new Point(122, 22);
|
||||
panelFuchsia.Name = "panelFuchsia";
|
||||
panelFuchsia.Size = new Size(40, 40);
|
||||
panelFuchsia.TabIndex = 2;
|
||||
panelFuchsia.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelLime
|
||||
//
|
||||
panelLime.BackColor = Color.Lime;
|
||||
panelLime.Location = new Point(65, 22);
|
||||
panelLime.Name = "panelLime";
|
||||
panelLime.Size = new Size(40, 40);
|
||||
panelLime.TabIndex = 2;
|
||||
panelLime.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
panelRed.BackColor = Color.Red;
|
||||
panelRed.Location = new Point(6, 22);
|
||||
panelRed.Name = "panelRed";
|
||||
panelRed.Size = new Size(40, 40);
|
||||
panelRed.TabIndex = 1;
|
||||
panelRed.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// checkBoxBodyKits
|
||||
//
|
||||
checkBoxBodyKits.AutoSize = true;
|
||||
checkBoxBodyKits.Location = new Point(6, 137);
|
||||
checkBoxBodyKits.Name = "checkBoxBodyKits";
|
||||
checkBoxBodyKits.Size = new Size(256, 19);
|
||||
checkBoxBodyKits.TabIndex = 7;
|
||||
checkBoxBodyKits.Text = "Признак наличия вспомогательных опор";
|
||||
checkBoxBodyKits.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxBacket
|
||||
//
|
||||
checkBoxBacket.AutoSize = true;
|
||||
checkBoxBacket.Location = new Point(6, 112);
|
||||
checkBoxBacket.Name = "checkBoxBacket";
|
||||
checkBoxBacket.Size = new Size(162, 19);
|
||||
checkBoxBacket.TabIndex = 6;
|
||||
checkBoxBacket.Text = "Признак наличия ковша";
|
||||
checkBoxBacket.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(74, 59);
|
||||
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(45, 23);
|
||||
numericUpDownWeight.TabIndex = 3;
|
||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
numericUpDownSpeed.Location = new Point(74, 30);
|
||||
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(45, 23);
|
||||
numericUpDownSpeed.TabIndex = 2;
|
||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
labelWeight.AutoSize = true;
|
||||
labelWeight.Location = new Point(6, 61);
|
||||
labelWeight.Name = "labelWeight";
|
||||
labelWeight.Size = new Size(29, 15);
|
||||
labelWeight.TabIndex = 1;
|
||||
labelWeight.Text = "Вес:";
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
labelSpeed.AutoSize = true;
|
||||
labelSpeed.Location = new Point(6, 32);
|
||||
labelSpeed.Name = "labelSpeed";
|
||||
labelSpeed.Size = new Size(62, 15);
|
||||
labelSpeed.TabIndex = 0;
|
||||
labelSpeed.Text = "Скорость:";
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
pictureBoxObject.Location = new Point(16, 15);
|
||||
pictureBoxObject.Name = "pictureBoxObject";
|
||||
pictureBoxObject.Size = new Size(466, 317);
|
||||
pictureBoxObject.TabIndex = 1;
|
||||
pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// panel9
|
||||
//
|
||||
panel9.AllowDrop = true;
|
||||
panel9.Controls.Add(pictureBoxObject);
|
||||
panel9.Location = new Point(291, 44);
|
||||
panel9.Name = "panel9";
|
||||
panel9.Size = new Size(495, 349);
|
||||
panel9.TabIndex = 2;
|
||||
panel9.DragDrop += PanelObject_DragDrop;
|
||||
panel9.DragEnter += PanelObject_DragEnter;
|
||||
//
|
||||
// labelColor
|
||||
//
|
||||
labelColor.AllowDrop = true;
|
||||
labelColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelColor.Location = new Point(346, 12);
|
||||
labelColor.Name = "labelColor";
|
||||
labelColor.Size = new Size(150, 23);
|
||||
labelColor.TabIndex = 3;
|
||||
labelColor.Text = "Цвет";
|
||||
labelColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelColor.DragDrop += labelColor_DragDrop;
|
||||
labelColor.DragEnter += labelColor_DragEnter;
|
||||
//
|
||||
// labelAdditionalColor
|
||||
//
|
||||
labelAdditionalColor.AllowDrop = true;
|
||||
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelAdditionalColor.Location = new Point(539, 12);
|
||||
labelAdditionalColor.Name = "labelAdditionalColor";
|
||||
labelAdditionalColor.Size = new Size(150, 23);
|
||||
labelAdditionalColor.TabIndex = 4;
|
||||
labelAdditionalColor.Text = "Дополнительный цвет";
|
||||
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelAdditionalColor.DragDrop += labelColor_DragDrop;
|
||||
labelAdditionalColor.DragEnter += labelColor_DragEnter;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(316, 412);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(84, 24);
|
||||
buttonAdd.TabIndex = 5;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += ButtonOk_Click;
|
||||
//
|
||||
// buttonCansel
|
||||
//
|
||||
buttonCansel.Location = new Point(423, 412);
|
||||
buttonCansel.Name = "buttonCansel";
|
||||
buttonCansel.Size = new Size(84, 24);
|
||||
buttonCansel.TabIndex = 6;
|
||||
buttonCansel.Text = "Отменить";
|
||||
buttonCansel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormExcavatorConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(buttonCansel);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(labelAdditionalColor);
|
||||
Controls.Add(labelColor);
|
||||
Controls.Add(panel9);
|
||||
Controls.Add(groupBoxParameters);
|
||||
Name = "FormExcavatorConfig";
|
||||
Text = "Создание объекта";
|
||||
groupBoxParameters.ResumeLayout(false);
|
||||
groupBoxParameters.PerformLayout();
|
||||
groupBoxColors.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||
panel9.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxParameters;
|
||||
private Label labelWeight;
|
||||
private Label labelSpeed;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private GroupBox groupBoxColors;
|
||||
private CheckBox checkBoxBodyKits;
|
||||
private CheckBox checkBoxBacket;
|
||||
private Panel panelRed;
|
||||
private Panel panelOrange;
|
||||
private Panel panelSilver;
|
||||
private Panel panelYellow;
|
||||
private Panel panelCyan;
|
||||
private Panel panelBlue;
|
||||
private Panel panelFuchsia;
|
||||
private Panel panelLime;
|
||||
private Label labelModifiedObject;
|
||||
private Label labelSimpleObject;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Panel panel9;
|
||||
private Label labelColor;
|
||||
private Label labelAdditionalColor;
|
||||
private Button buttonAdd;
|
||||
private Button buttonCansel;
|
||||
}
|
||||
}
|
160
ProjectExcavator/ProjectExcavator/FormExcavatorConfig.cs
Normal file
160
ProjectExcavator/ProjectExcavator/FormExcavatorConfig.cs
Normal file
@ -0,0 +1,160 @@
|
||||
using ProjectExcavator;
|
||||
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 System;
|
||||
using ProjectExcavator.Entities;
|
||||
|
||||
namespace ProjectExcavator
|
||||
{
|
||||
public partial class FormExcavatorConfig : Form
|
||||
{
|
||||
readonly Color defaultColor;
|
||||
DrawningExcavator? _excavator;
|
||||
private event Action<DrawningExcavator> EventAddExcavator;
|
||||
public FormExcavatorConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelBlue.MouseDown += panelColor_MouseDown;
|
||||
panelCyan.MouseDown += panelColor_MouseDown;
|
||||
panelFuchsia.MouseDown += panelColor_MouseDown;
|
||||
panelLime.MouseDown += panelColor_MouseDown;
|
||||
panelOrange.MouseDown += panelColor_MouseDown;
|
||||
panelRed.MouseDown += panelColor_MouseDown;
|
||||
panelYellow.MouseDown += panelColor_MouseDown;
|
||||
panelSilver.MouseDown += panelColor_MouseDown;
|
||||
defaultColor = labelColor.BackColor;
|
||||
buttonCansel.Click += (s, e) => Close();
|
||||
|
||||
}
|
||||
private void DrawExcavator()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_excavator?.SetPosition(5, 5);
|
||||
_excavator?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
/// </summary>
|
||||
/// Добавление события
|
||||
/// </summary>
|
||||
/// <param name="ev">Привязанный метод</param>
|
||||
internal void AddEvent(Action<DrawningExcavator> ev)
|
||||
{
|
||||
if (EventAddExcavator == null)
|
||||
{
|
||||
EventAddExcavator = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddExcavator += 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":
|
||||
_excavator = new DrawningExcavator((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
||||
pictureBoxObject.Height);
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
_excavator = new DrawningExcavatorBodyKits((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxBodyKits.Checked,
|
||||
checkBoxBacket.Checked, pictureBoxObject.Width,
|
||||
pictureBoxObject.Height);
|
||||
break;
|
||||
}
|
||||
labelColor.BackColor = defaultColor;
|
||||
labelAdditionalColor.BackColor = defaultColor;
|
||||
DrawExcavator();
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление экскаватора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddExcavator?.Invoke(_excavator);
|
||||
Close();
|
||||
}
|
||||
|
||||
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 labelColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_excavator == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
switch (((Label)sender).Name)
|
||||
{
|
||||
case "labelColor":
|
||||
_excavator.EntityExcavator.setBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||
break;
|
||||
case "labelAdditionalColor":
|
||||
if (_excavator is not DrawningExcavatorBodyKits)
|
||||
{
|
||||
return;
|
||||
}
|
||||
(_excavator.EntityExcavator as EntityExcavatorBodyKits).setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
|
||||
break;
|
||||
}
|
||||
DrawExcavator();
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectExcavator/ProjectExcavator/FormExcavatorConfig.resx
Normal file
120
ProjectExcavator/ProjectExcavator/FormExcavatorConfig.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