Готовая 5 лабораторная
This commit is contained in:
parent
25a690a85e
commit
129ed2e33c
382
RoadTrain/FormTrainConfig.Designer.cs
generated
Normal file
382
RoadTrain/FormTrainConfig.Designer.cs
generated
Normal file
@ -0,0 +1,382 @@
|
|||||||
|
namespace RoadTrain
|
||||||
|
{
|
||||||
|
partial class FormTrainConfig
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
panelWhite = new Panel();
|
||||||
|
panelGray = new Panel();
|
||||||
|
panelBlack = new Panel();
|
||||||
|
panelPurple = new Panel();
|
||||||
|
panelYellow = new Panel();
|
||||||
|
panelBlue = new Panel();
|
||||||
|
panelGreen = new Panel();
|
||||||
|
panelRed = new Panel();
|
||||||
|
checkBoxSweepingBrush = new CheckBox();
|
||||||
|
checkBoxWaterContainer = new CheckBox();
|
||||||
|
numericUpDownWeight = new NumericUpDown();
|
||||||
|
numericUpDownSpeed = new NumericUpDown();
|
||||||
|
labelWeight = new Label();
|
||||||
|
labelSpeed = new Label();
|
||||||
|
pictureBoxObject = new PictureBox();
|
||||||
|
panelObject = new Panel();
|
||||||
|
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();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||||
|
panelObject.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Controls.Add(labelModifiedObject);
|
||||||
|
groupBox1.Controls.Add(labelSimpleObject);
|
||||||
|
groupBox1.Controls.Add(groupBox2);
|
||||||
|
groupBox1.Controls.Add(checkBoxSweepingBrush);
|
||||||
|
groupBox1.Controls.Add(checkBoxWaterContainer);
|
||||||
|
groupBox1.Controls.Add(numericUpDownWeight);
|
||||||
|
groupBox1.Controls.Add(numericUpDownSpeed);
|
||||||
|
groupBox1.Controls.Add(labelWeight);
|
||||||
|
groupBox1.Controls.Add(labelSpeed);
|
||||||
|
groupBox1.Location = new Point(14, 16);
|
||||||
|
groupBox1.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Padding = new Padding(3, 4, 3, 4);
|
||||||
|
groupBox1.Size = new Size(677, 309);
|
||||||
|
groupBox1.TabIndex = 0;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "Параметры";
|
||||||
|
//
|
||||||
|
// labelModifiedObject
|
||||||
|
//
|
||||||
|
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelModifiedObject.Location = new Point(525, 221);
|
||||||
|
labelModifiedObject.Name = "labelModifiedObject";
|
||||||
|
labelModifiedObject.Size = new Size(107, 46);
|
||||||
|
labelModifiedObject.TabIndex = 8;
|
||||||
|
labelModifiedObject.Text = "Продвинутый";
|
||||||
|
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||||
|
//
|
||||||
|
// labelSimpleObject
|
||||||
|
//
|
||||||
|
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelSimpleObject.Location = new Point(403, 221);
|
||||||
|
labelSimpleObject.Name = "labelSimpleObject";
|
||||||
|
labelSimpleObject.Size = new Size(100, 46);
|
||||||
|
labelSimpleObject.TabIndex = 7;
|
||||||
|
labelSimpleObject.Text = "Простой";
|
||||||
|
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelSimpleObject.UseCompatibleTextRendering = true;
|
||||||
|
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||||
|
//
|
||||||
|
// groupBox2
|
||||||
|
//
|
||||||
|
groupBox2.Controls.Add(panelWhite);
|
||||||
|
groupBox2.Controls.Add(panelGray);
|
||||||
|
groupBox2.Controls.Add(panelBlack);
|
||||||
|
groupBox2.Controls.Add(panelPurple);
|
||||||
|
groupBox2.Controls.Add(panelYellow);
|
||||||
|
groupBox2.Controls.Add(panelBlue);
|
||||||
|
groupBox2.Controls.Add(panelGreen);
|
||||||
|
groupBox2.Controls.Add(panelRed);
|
||||||
|
groupBox2.Location = new Point(379, 36);
|
||||||
|
groupBox2.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
groupBox2.Name = "groupBox2";
|
||||||
|
groupBox2.Padding = new Padding(3, 4, 3, 4);
|
||||||
|
groupBox2.Size = new Size(270, 163);
|
||||||
|
groupBox2.TabIndex = 6;
|
||||||
|
groupBox2.TabStop = false;
|
||||||
|
groupBox2.Text = "Цвета";
|
||||||
|
//
|
||||||
|
// panelWhite
|
||||||
|
//
|
||||||
|
panelWhite.BackColor = Color.White;
|
||||||
|
panelWhite.Location = new Point(24, 100);
|
||||||
|
panelWhite.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panelWhite.Name = "panelWhite";
|
||||||
|
panelWhite.Size = new Size(41, 47);
|
||||||
|
panelWhite.TabIndex = 0;
|
||||||
|
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelGray
|
||||||
|
//
|
||||||
|
panelGray.BackColor = Color.Silver;
|
||||||
|
panelGray.Location = new Point(83, 100);
|
||||||
|
panelGray.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panelGray.Name = "panelGray";
|
||||||
|
panelGray.Size = new Size(41, 47);
|
||||||
|
panelGray.TabIndex = 0;
|
||||||
|
panelGray.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelBlack
|
||||||
|
//
|
||||||
|
panelBlack.BackColor = Color.Black;
|
||||||
|
panelBlack.Location = new Point(146, 100);
|
||||||
|
panelBlack.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panelBlack.Name = "panelBlack";
|
||||||
|
panelBlack.Size = new Size(41, 47);
|
||||||
|
panelBlack.TabIndex = 0;
|
||||||
|
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelPurple
|
||||||
|
//
|
||||||
|
panelPurple.BackColor = Color.Purple;
|
||||||
|
panelPurple.Location = new Point(206, 100);
|
||||||
|
panelPurple.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panelPurple.Name = "panelPurple";
|
||||||
|
panelPurple.Size = new Size(41, 47);
|
||||||
|
panelPurple.TabIndex = 0;
|
||||||
|
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelYellow
|
||||||
|
//
|
||||||
|
panelYellow.BackColor = Color.Yellow;
|
||||||
|
panelYellow.Location = new Point(206, 32);
|
||||||
|
panelYellow.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panelYellow.Name = "panelYellow";
|
||||||
|
panelYellow.Size = new Size(41, 47);
|
||||||
|
panelYellow.TabIndex = 0;
|
||||||
|
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelBlue
|
||||||
|
//
|
||||||
|
panelBlue.BackColor = Color.FromArgb(0, 0, 192);
|
||||||
|
panelBlue.Location = new Point(146, 32);
|
||||||
|
panelBlue.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panelBlue.Name = "panelBlue";
|
||||||
|
panelBlue.Size = new Size(41, 47);
|
||||||
|
panelBlue.TabIndex = 0;
|
||||||
|
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelGreen
|
||||||
|
//
|
||||||
|
panelGreen.BackColor = Color.FromArgb(0, 192, 0);
|
||||||
|
panelGreen.Location = new Point(83, 32);
|
||||||
|
panelGreen.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panelGreen.Name = "panelGreen";
|
||||||
|
panelGreen.Size = new Size(41, 47);
|
||||||
|
panelGreen.TabIndex = 0;
|
||||||
|
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelRed
|
||||||
|
//
|
||||||
|
panelRed.BackColor = Color.Red;
|
||||||
|
panelRed.Location = new Point(24, 32);
|
||||||
|
panelRed.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panelRed.Name = "panelRed";
|
||||||
|
panelRed.Size = new Size(41, 47);
|
||||||
|
panelRed.TabIndex = 0;
|
||||||
|
panelRed.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// checkBoxSweepingBrush
|
||||||
|
//
|
||||||
|
checkBoxSweepingBrush.AutoSize = true;
|
||||||
|
checkBoxSweepingBrush.Location = new Point(41, 204);
|
||||||
|
checkBoxSweepingBrush.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
checkBoxSweepingBrush.Name = "checkBoxSweepingBrush";
|
||||||
|
checkBoxSweepingBrush.Size = new Size(200, 24);
|
||||||
|
checkBoxSweepingBrush.TabIndex = 5;
|
||||||
|
checkBoxSweepingBrush.Text = "Признак наличия щетки";
|
||||||
|
checkBoxSweepingBrush.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxWaterContainer
|
||||||
|
//
|
||||||
|
checkBoxWaterContainer.AutoSize = true;
|
||||||
|
checkBoxWaterContainer.Location = new Point(41, 153);
|
||||||
|
checkBoxWaterContainer.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
checkBoxWaterContainer.Name = "checkBoxWaterContainer";
|
||||||
|
checkBoxWaterContainer.Size = new Size(298, 24);
|
||||||
|
checkBoxWaterContainer.TabIndex = 4;
|
||||||
|
checkBoxWaterContainer.Text = "Признак наличия контейнера с водой";
|
||||||
|
checkBoxWaterContainer.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// numericUpDownWeight
|
||||||
|
//
|
||||||
|
numericUpDownWeight.Location = new Point(151, 81);
|
||||||
|
numericUpDownWeight.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
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(126, 27);
|
||||||
|
numericUpDownWeight.TabIndex = 3;
|
||||||
|
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// numericUpDownSpeed
|
||||||
|
//
|
||||||
|
numericUpDownSpeed.Location = new Point(151, 33);
|
||||||
|
numericUpDownSpeed.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
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(126, 27);
|
||||||
|
numericUpDownSpeed.TabIndex = 2;
|
||||||
|
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// labelWeight
|
||||||
|
//
|
||||||
|
labelWeight.AutoSize = true;
|
||||||
|
labelWeight.Location = new Point(41, 84);
|
||||||
|
labelWeight.Name = "labelWeight";
|
||||||
|
labelWeight.Size = new Size(36, 20);
|
||||||
|
labelWeight.TabIndex = 1;
|
||||||
|
labelWeight.Text = "Вес:";
|
||||||
|
//
|
||||||
|
// labelSpeed
|
||||||
|
//
|
||||||
|
labelSpeed.AutoSize = true;
|
||||||
|
labelSpeed.Location = new Point(21, 36);
|
||||||
|
labelSpeed.Name = "labelSpeed";
|
||||||
|
labelSpeed.Size = new Size(76, 20);
|
||||||
|
labelSpeed.TabIndex = 0;
|
||||||
|
labelSpeed.Text = "Скорость:";
|
||||||
|
//
|
||||||
|
// pictureBoxObject
|
||||||
|
//
|
||||||
|
pictureBoxObject.Location = new Point(54, 61);
|
||||||
|
pictureBoxObject.Name = "pictureBoxObject";
|
||||||
|
pictureBoxObject.Size = new Size(190, 144);
|
||||||
|
pictureBoxObject.TabIndex = 1;
|
||||||
|
pictureBoxObject.TabStop = false;
|
||||||
|
//
|
||||||
|
// panelObject
|
||||||
|
//
|
||||||
|
panelObject.AllowDrop = true;
|
||||||
|
panelObject.Controls.Add(labelAdditionalColor);
|
||||||
|
panelObject.Controls.Add(labelColor);
|
||||||
|
panelObject.Controls.Add(pictureBoxObject);
|
||||||
|
panelObject.Location = new Point(697, 20);
|
||||||
|
panelObject.Name = "panelObject";
|
||||||
|
panelObject.Size = new Size(288, 233);
|
||||||
|
panelObject.TabIndex = 2;
|
||||||
|
panelObject.DragDrop += PanelObject_DragDrop;
|
||||||
|
panelObject.DragEnter += PanelObject_DragEnter;
|
||||||
|
//
|
||||||
|
// labelAdditionalColor
|
||||||
|
//
|
||||||
|
labelAdditionalColor.AllowDrop = true;
|
||||||
|
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelAdditionalColor.Location = new Point(160, 11);
|
||||||
|
labelAdditionalColor.Name = "labelAdditionalColor";
|
||||||
|
labelAdditionalColor.Size = new Size(84, 41);
|
||||||
|
labelAdditionalColor.TabIndex = 3;
|
||||||
|
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(54, 11);
|
||||||
|
labelColor.Name = "labelColor";
|
||||||
|
labelColor.Size = new Size(79, 41);
|
||||||
|
labelColor.TabIndex = 2;
|
||||||
|
labelColor.Text = "Цвет";
|
||||||
|
labelColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelColor.DragDrop += labelColor_DragDrop;
|
||||||
|
labelColor.DragEnter += labelColor_DragEnter;
|
||||||
|
//
|
||||||
|
// ButtonOk
|
||||||
|
//
|
||||||
|
ButtonOk.Location = new Point(712, 276);
|
||||||
|
ButtonOk.Name = "ButtonOk";
|
||||||
|
ButtonOk.Size = new Size(101, 36);
|
||||||
|
ButtonOk.TabIndex = 3;
|
||||||
|
ButtonOk.Text = "Добавить";
|
||||||
|
ButtonOk.UseVisualStyleBackColor = true;
|
||||||
|
ButtonOk.Click += ButtonOk_Click;
|
||||||
|
//
|
||||||
|
// ButtonCancel
|
||||||
|
//
|
||||||
|
ButtonCancel.Location = new Point(871, 276);
|
||||||
|
ButtonCancel.Name = "ButtonCancel";
|
||||||
|
ButtonCancel.Size = new Size(102, 36);
|
||||||
|
ButtonCancel.TabIndex = 4;
|
||||||
|
ButtonCancel.Text = "Отмена";
|
||||||
|
ButtonCancel.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// FormTrainConfig
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(1015, 341);
|
||||||
|
Controls.Add(ButtonCancel);
|
||||||
|
Controls.Add(ButtonOk);
|
||||||
|
Controls.Add(panelObject);
|
||||||
|
Controls.Add(groupBox1);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormTrainConfig";
|
||||||
|
Text = "FormTrainConfig";
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
groupBox1.PerformLayout();
|
||||||
|
groupBox2.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||||
|
panelObject.ResumeLayout(false);
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private Label labelSpeed;
|
||||||
|
private NumericUpDown numericUpDownWeight;
|
||||||
|
private NumericUpDown numericUpDownSpeed;
|
||||||
|
private Label labelWeight;
|
||||||
|
private CheckBox checkBoxWaterContainer;
|
||||||
|
private CheckBox checkBoxSweepingBrush;
|
||||||
|
private GroupBox groupBox2;
|
||||||
|
private Panel panelWhite;
|
||||||
|
private Panel panelGray;
|
||||||
|
private Panel panelBlack;
|
||||||
|
private Panel panelPurple;
|
||||||
|
private Panel panelYellow;
|
||||||
|
private Panel panelBlue;
|
||||||
|
private Panel panelGreen;
|
||||||
|
private Panel panelRed;
|
||||||
|
private Label labelModifiedObject;
|
||||||
|
private Label labelSimpleObject;
|
||||||
|
private PictureBox pictureBoxObject;
|
||||||
|
private Panel panelObject;
|
||||||
|
private Label labelAdditionalColor;
|
||||||
|
private Label labelColor;
|
||||||
|
private Button ButtonOk;
|
||||||
|
private Button ButtonCancel;
|
||||||
|
}
|
||||||
|
}
|
170
RoadTrain/FormTrainConfig.cs
Normal file
170
RoadTrain/FormTrainConfig.cs
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
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 RoadTrain.MovementStrategy;
|
||||||
|
using RoadTrain.DrawningObjects;
|
||||||
|
|
||||||
|
namespace RoadTrain
|
||||||
|
{
|
||||||
|
public partial class FormTrainConfig : Form
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Переменная-выбранный пеозд
|
||||||
|
/// </summary>
|
||||||
|
DrawningRoadTrain? _train = null;
|
||||||
|
/// <summary>
|
||||||
|
/// Событие
|
||||||
|
/// </summary>
|
||||||
|
private event Action<DrawningRoadTrain> EventAddTrain;
|
||||||
|
public FormTrainConfig()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
ButtonCancel.Click += (s, e) => Close();
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Отрисовать машину
|
||||||
|
/// </summary>
|
||||||
|
private void DrawTrain()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_train?.SetPosition(5, 5);
|
||||||
|
_train?.DrawTransport(gr);
|
||||||
|
pictureBoxObject.Image = bmp;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление события
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ev">Привязанный метод</param>
|
||||||
|
public void AddEvent(Action<DrawningRoadTrain> ev)
|
||||||
|
{
|
||||||
|
if (EventAddTrain == null)
|
||||||
|
{
|
||||||
|
EventAddTrain = ev;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EventAddTrain += 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":
|
||||||
|
_train = new DrawningRoadTrain((int)numericUpDownSpeed.Value,
|
||||||
|
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
||||||
|
pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
case "labelModifiedObject":
|
||||||
|
_train = new DrawningTrain((int)numericUpDownSpeed.Value,
|
||||||
|
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxWaterContainer.Checked,
|
||||||
|
checkBoxSweepingBrush.Checked, pictureBoxObject.Width,
|
||||||
|
pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonOk_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
EventAddTrain?.Invoke(_train);
|
||||||
|
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 (_train == null)
|
||||||
|
return;
|
||||||
|
((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||||
|
switch (((Label)sender).Name)
|
||||||
|
{
|
||||||
|
case "labelColor":
|
||||||
|
_train.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
break;
|
||||||
|
case "labelAdditionalColor":
|
||||||
|
if (!(_train is DrawningTrain))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
(_train as DrawningTrain).SetAdditionalColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawTrain();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//case "labelSimpleObject":
|
||||||
|
// obj = new DrawningRoadTrain((int)numericUpDownSpeed.Value,
|
||||||
|
// (int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
||||||
|
// pictureBoxObject.Height);
|
||||||
|
// break;
|
||||||
|
//case "labelModifiedObject":
|
||||||
|
// obj = new DrawningTrain((int)numericUpDownSpeed.Value,
|
||||||
|
// (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxWaterContainer.Checked,
|
||||||
|
// checkBoxSweepingBrush.Checked, pictureBoxObject.Width,
|
||||||
|
// pictureBoxObject.Height);
|
||||||
|
// break;
|
120
RoadTrain/FormTrainConfig.resx
Normal file
120
RoadTrain/FormTrainConfig.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