diff --git a/LocomativeProject/LocomativeProject/Drawnings/DrawningBaseLocomotive.cs b/LocomativeProject/LocomativeProject/Drawnings/DrawningBaseLocomotive.cs
index aa6b85a..2105806 100644
--- a/LocomativeProject/LocomativeProject/Drawnings/DrawningBaseLocomotive.cs
+++ b/LocomativeProject/LocomativeProject/Drawnings/DrawningBaseLocomotive.cs
@@ -7,7 +7,7 @@ namespace LocomativeProject.Drawnings
///
/// Класс-сущность
///
- public EntityBaseLocomotive? _EntityLocomotive { get; protected set; }
+ public EntityBaseLocomotive? _EntityBaseLocomotive { get; protected set; }
///
/// Ширина окна
@@ -79,7 +79,7 @@ namespace LocomativeProject.Drawnings
/// Основной цвет
public DrawningBaseLocomotive(int speed, double weight, Color bodyColor) : this()
{
- _EntityLocomotive = new EntityBaseLocomotive(speed, weight, bodyColor);
+ _EntityBaseLocomotive = new EntityBaseLocomotive(speed, weight, bodyColor);
}
///
/// Конструктор для наследников
@@ -156,7 +156,7 @@ namespace LocomativeProject.Drawnings
/// невозможно
public bool MoveTransport(DirectionType direction)
{
- if (_EntityLocomotive == null || !_startPosX.HasValue ||
+ if (_EntityBaseLocomotive == null || !_startPosX.HasValue ||
!_startPosY.HasValue)
{
return false;
@@ -165,30 +165,30 @@ namespace LocomativeProject.Drawnings
{
//влево
case DirectionType.Left:
- if (_startPosX.Value - _EntityLocomotive.Step > 0)
+ if (_startPosX.Value - _EntityBaseLocomotive.Step > 0)
{
- _startPosX -= (int)_EntityLocomotive.Step;
+ _startPosX -= (int)_EntityBaseLocomotive.Step;
}
return true;
//вверх
case DirectionType.Up:
- if (_startPosY.Value - _EntityLocomotive.Step > 0)
+ if (_startPosY.Value - _EntityBaseLocomotive.Step > 0)
{
- _startPosY -= (int)_EntityLocomotive.Step;
+ _startPosY -= (int)_EntityBaseLocomotive.Step;
}
return true;
// вправо
case DirectionType.Right:
- if (_startPosX.Value + _drawningBaseLocomotiveWidth + _EntityLocomotive.Step < _pictureWidth)
+ if (_startPosX.Value + _drawningBaseLocomotiveWidth + _EntityBaseLocomotive.Step < _pictureWidth)
{
- _startPosX += (int)_EntityLocomotive.Step;
+ _startPosX += (int)_EntityBaseLocomotive.Step;
}
return true;
//вниз
case DirectionType.Down:
- if (_startPosY.Value + _drawningBaseLocomotiveHeight + _EntityLocomotive.Step < _pictureHeight)
+ if (_startPosY.Value + _drawningBaseLocomotiveHeight + _EntityBaseLocomotive.Step < _pictureHeight)
{
- _startPosY += (int)_EntityLocomotive.Step;
+ _startPosY += (int)_EntityBaseLocomotive.Step;
}
return true;
default:
@@ -224,12 +224,12 @@ namespace LocomativeProject.Drawnings
///
public virtual void DrawTransport(Graphics g)
{
- if (_EntityLocomotive == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ if (_EntityBaseLocomotive == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
Pen pen = new(Color.Black);
- Brush bodyBrush = new SolidBrush(_EntityLocomotive.BodyColor);
+ Brush bodyBrush = new SolidBrush(_EntityBaseLocomotive.BodyColor);
Brush blackBrush = new SolidBrush(Color.Black);
Brush whiteBrush = new SolidBrush(Color.White);
//границы тепловоза
diff --git a/LocomativeProject/LocomativeProject/Drawnings/DrawningLocomotive.cs b/LocomativeProject/LocomativeProject/Drawnings/DrawningLocomotive.cs
index 799084a..0e3a3b5 100644
--- a/LocomativeProject/LocomativeProject/Drawnings/DrawningLocomotive.cs
+++ b/LocomativeProject/LocomativeProject/Drawnings/DrawningLocomotive.cs
@@ -16,12 +16,12 @@ namespace LocomotiveProject.Drawnings
/// Признак наличия топливного отсека
public DrawningLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, bool exehaustPipe, bool fuelCompartment) : base(120, 60)
{
- _EntityLocomotive = new EntityLocomotive(speed, weight, bodyColor, additionalColor, exehaustPipe, fuelCompartment);
+ _EntityBaseLocomotive = new EntityLocomotive(speed, weight, bodyColor, additionalColor, exehaustPipe, fuelCompartment);
}
public override void DrawTransport(Graphics g)
{
- if (_EntityLocomotive == null || _EntityLocomotive is not EntityLocomotive entityLocomotive || !_startPosX.HasValue || !_startPosY.HasValue)
+ if (_EntityBaseLocomotive == null || _EntityBaseLocomotive is not EntityLocomotive entityLocomotive || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
diff --git a/LocomativeProject/LocomativeProject/Entities/EntityBaseLocomotive.cs b/LocomativeProject/LocomativeProject/Entities/EntityBaseLocomotive.cs
index d47fd0c..d013cec 100644
--- a/LocomativeProject/LocomativeProject/Entities/EntityBaseLocomotive.cs
+++ b/LocomativeProject/LocomativeProject/Entities/EntityBaseLocomotive.cs
@@ -17,6 +17,12 @@
/// Основной цвет
///
public Color BodyColor { get; private set; }
+ ///
+ /// Установка основого цвета
+ ///
+ ///
+ public void setBodyColor(Color bodyColor) { BodyColor = bodyColor; }
+
///
/// Шаг перемещения тепловоза
///
diff --git a/LocomativeProject/LocomativeProject/Entities/EntityLocomotive.cs b/LocomativeProject/LocomativeProject/Entities/EntityLocomotive.cs
index 9f79e8e..93b27ea 100644
--- a/LocomativeProject/LocomativeProject/Entities/EntityLocomotive.cs
+++ b/LocomativeProject/LocomativeProject/Entities/EntityLocomotive.cs
@@ -4,8 +4,16 @@ namespace LocomotiveProject.Entities
{
public class EntityLocomotive : EntityBaseLocomotive
{
+ ///
+ /// Дополнительный цвет
+ ///
public Color AdditionalColor { get; private set; }
///
+ /// Задать доп цвет
+ ///
+ ///
+ public void setAdditionalColor(Color color) { AdditionalColor = color; }
+ ///
/// Признак (опция) наличие трубы
///
public bool ExehaustPipe { get; private set; }
diff --git a/LocomativeProject/LocomativeProject/FormCruiserConfig.Designer.cs b/LocomativeProject/LocomativeProject/FormCruiserConfig.Designer.cs
new file mode 100644
index 0000000..3f358cf
--- /dev/null
+++ b/LocomativeProject/LocomativeProject/FormCruiserConfig.Designer.cs
@@ -0,0 +1,353 @@
+namespace LocomotiveProject
+{
+ partial class FormLocomotiveConfig
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ groupBoxConfig = new GroupBox();
+ groupBoxColors = new GroupBox();
+ panelPurple = new Panel();
+ panelYellow = new Panel();
+ panelBlack = new Panel();
+ panelBlue = new Panel();
+ panelGray = new Panel();
+ panelRed = new Panel();
+ panelGreen = new Panel();
+ panelWhite = new Panel();
+ checkBoxHelipad = new CheckBox();
+ checkBoxRocketMine = new CheckBox();
+ numericUpDownWeight = new NumericUpDown();
+ labelWeight = new Label();
+ numericUpDownSpeed = new NumericUpDown();
+ labelSpeed = new Label();
+ labelModifiedObject = new Label();
+ labelSimpleObject = new Label();
+ pictureBoxObject = new PictureBox();
+ buttonAdd = new Button();
+ buttonCancel = new Button();
+ panelObject = new Panel();
+ labelAdditionalColor = new Label();
+ labelBodyColor = new Label();
+ groupBoxConfig.SuspendLayout();
+ groupBoxColors.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
+ panelObject.SuspendLayout();
+ SuspendLayout();
+ //
+ // groupBoxConfig
+ //
+ groupBoxConfig.Controls.Add(groupBoxColors);
+ groupBoxConfig.Controls.Add(checkBoxHelipad);
+ groupBoxConfig.Controls.Add(checkBoxRocketMine);
+ groupBoxConfig.Controls.Add(numericUpDownWeight);
+ groupBoxConfig.Controls.Add(labelWeight);
+ groupBoxConfig.Controls.Add(numericUpDownSpeed);
+ groupBoxConfig.Controls.Add(labelSpeed);
+ groupBoxConfig.Controls.Add(labelModifiedObject);
+ groupBoxConfig.Controls.Add(labelSimpleObject);
+ groupBoxConfig.Dock = DockStyle.Left;
+ groupBoxConfig.Location = new Point(0, 0);
+ groupBoxConfig.Name = "groupBoxConfig";
+ groupBoxConfig.Size = new Size(581, 213);
+ groupBoxConfig.TabIndex = 0;
+ groupBoxConfig.TabStop = false;
+ groupBoxConfig.Text = "Параметры";
+ //
+ // groupBoxColors
+ //
+ groupBoxColors.Controls.Add(panelPurple);
+ groupBoxColors.Controls.Add(panelYellow);
+ groupBoxColors.Controls.Add(panelBlack);
+ groupBoxColors.Controls.Add(panelBlue);
+ groupBoxColors.Controls.Add(panelGray);
+ groupBoxColors.Controls.Add(panelRed);
+ groupBoxColors.Controls.Add(panelGreen);
+ groupBoxColors.Controls.Add(panelWhite);
+ groupBoxColors.Location = new Point(402, 44);
+ groupBoxColors.Name = "groupBoxColors";
+ groupBoxColors.Size = new Size(142, 109);
+ groupBoxColors.TabIndex = 8;
+ groupBoxColors.TabStop = false;
+ groupBoxColors.Text = "Цвета";
+ //
+ // panelPurple
+ //
+ panelPurple.BackColor = Color.Purple;
+ panelPurple.Location = new Point(102, 67);
+ panelPurple.Name = "panelPurple";
+ panelPurple.Size = new Size(26, 27);
+ panelPurple.TabIndex = 1;
+ //
+ // panelYellow
+ //
+ panelYellow.BackColor = Color.Yellow;
+ panelYellow.Location = new Point(102, 22);
+ panelYellow.Name = "panelYellow";
+ panelYellow.Size = new Size(26, 27);
+ panelYellow.TabIndex = 1;
+ //
+ // panelBlack
+ //
+ panelBlack.BackColor = Color.Black;
+ panelBlack.Location = new Point(70, 67);
+ panelBlack.Name = "panelBlack";
+ panelBlack.Size = new Size(26, 27);
+ panelBlack.TabIndex = 1;
+ //
+ // panelBlue
+ //
+ panelBlue.BackColor = Color.Blue;
+ panelBlue.Location = new Point(70, 22);
+ panelBlue.Name = "panelBlue";
+ panelBlue.Size = new Size(26, 27);
+ panelBlue.TabIndex = 1;
+ //
+ // panelGray
+ //
+ panelGray.BackColor = Color.Gray;
+ panelGray.Location = new Point(38, 67);
+ panelGray.Name = "panelGray";
+ panelGray.Size = new Size(26, 27);
+ panelGray.TabIndex = 1;
+ //
+ // panelRed
+ //
+ panelRed.BackColor = Color.Red;
+ panelRed.Location = new Point(6, 22);
+ panelRed.Name = "panelRed";
+ panelRed.Size = new Size(26, 27);
+ panelRed.TabIndex = 1;
+ //
+ // panelGreen
+ //
+ panelGreen.BackColor = Color.Green;
+ panelGreen.Location = new Point(38, 22);
+ panelGreen.Name = "panelGreen";
+ panelGreen.Size = new Size(26, 27);
+ panelGreen.TabIndex = 1;
+ //
+ // panelWhite
+ //
+ panelWhite.BackColor = Color.White;
+ panelWhite.Location = new Point(6, 67);
+ panelWhite.Name = "panelWhite";
+ panelWhite.Size = new Size(26, 27);
+ panelWhite.TabIndex = 0;
+ //
+ // checkBoxHelipad
+ //
+ checkBoxHelipad.AutoSize = true;
+ checkBoxHelipad.Location = new Point(6, 119);
+ checkBoxHelipad.Name = "checkBoxHelipad";
+ checkBoxHelipad.Size = new Size(256, 19);
+ checkBoxHelipad.TabIndex = 7;
+ checkBoxHelipad.Text = "Признак наличие вертолетной площадки";
+ checkBoxHelipad.UseVisualStyleBackColor = true;
+ //
+ // checkBoxRocketMine
+ //
+ checkBoxRocketMine.AutoSize = true;
+ checkBoxRocketMine.Location = new Point(6, 94);
+ checkBoxRocketMine.Name = "checkBoxRocketMine";
+ checkBoxRocketMine.Size = new Size(217, 19);
+ checkBoxRocketMine.TabIndex = 6;
+ checkBoxRocketMine.Text = "Признак наличие ракетной шахты";
+ checkBoxRocketMine.UseVisualStyleBackColor = true;
+ //
+ // numericUpDownWeight
+ //
+ numericUpDownWeight.Location = new Point(76, 55);
+ numericUpDownWeight.Name = "numericUpDownWeight";
+ numericUpDownWeight.Size = new Size(97, 23);
+ numericUpDownWeight.TabIndex = 5;
+ numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // labelWeight
+ //
+ labelWeight.AutoSize = true;
+ labelWeight.Location = new Point(27, 57);
+ labelWeight.Name = "labelWeight";
+ labelWeight.Size = new Size(26, 15);
+ labelWeight.TabIndex = 4;
+ labelWeight.Text = "Вес";
+ //
+ // numericUpDownSpeed
+ //
+ numericUpDownSpeed.Location = new Point(76, 22);
+ numericUpDownSpeed.Name = "numericUpDownSpeed";
+ numericUpDownSpeed.Size = new Size(97, 23);
+ numericUpDownSpeed.TabIndex = 3;
+ numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // labelSpeed
+ //
+ labelSpeed.AutoSize = true;
+ labelSpeed.Location = new Point(11, 24);
+ labelSpeed.Name = "labelSpeed";
+ labelSpeed.Size = new Size(59, 15);
+ labelSpeed.TabIndex = 2;
+ labelSpeed.Text = "Скорость";
+ //
+ // labelModifiedObject
+ //
+ labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
+ labelModifiedObject.Location = new Point(475, 181);
+ labelModifiedObject.Name = "labelModifiedObject";
+ labelModifiedObject.Size = new Size(100, 23);
+ labelModifiedObject.TabIndex = 1;
+ labelModifiedObject.Text = "Продвинутый";
+ labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
+ labelModifiedObject.MouseDown += LabelObject_MouseDown;
+ //
+ // labelSimpleObject
+ //
+ labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
+ labelSimpleObject.Location = new Point(369, 181);
+ labelSimpleObject.Name = "labelSimpleObject";
+ labelSimpleObject.Size = new Size(100, 23);
+ labelSimpleObject.TabIndex = 0;
+ labelSimpleObject.Text = "Обычный";
+ labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
+ labelSimpleObject.MouseDown += LabelObject_MouseDown;
+ //
+ // pictureBoxObject
+ //
+ pictureBoxObject.Location = new Point(3, 33);
+ pictureBoxObject.Name = "pictureBoxObject";
+ pictureBoxObject.Size = new Size(198, 125);
+ pictureBoxObject.TabIndex = 1;
+ pictureBoxObject.TabStop = false;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(604, 178);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(75, 23);
+ buttonAdd.TabIndex = 2;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(713, 178);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 3;
+ buttonCancel.Text = "Отменить";
+ buttonCancel.UseVisualStyleBackColor = true;
+ //
+ // panelObject
+ //
+ panelObject.AllowDrop = true;
+ panelObject.Controls.Add(labelAdditionalColor);
+ panelObject.Controls.Add(labelBodyColor);
+ panelObject.Controls.Add(pictureBoxObject);
+ panelObject.Location = new Point(587, 11);
+ panelObject.Name = "panelObject";
+ panelObject.Size = new Size(205, 161);
+ panelObject.TabIndex = 4;
+ panelObject.DragDrop += PanelObject_DragDrop;
+ panelObject.DragEnter += PanelObject_DragEnter;
+ //
+ // labelAdditionalColor
+ //
+ labelAdditionalColor.AllowDrop = true;
+ labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
+ labelAdditionalColor.Location = new Point(133, 5);
+ labelAdditionalColor.Name = "labelAdditionalColor";
+ labelAdditionalColor.Size = new Size(69, 23);
+ labelAdditionalColor.TabIndex = 3;
+ labelAdditionalColor.Text = "Доп.Цвет";
+ labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
+ labelAdditionalColor.DragDrop += LabelAdditionalColor_DragDrop;
+ labelAdditionalColor.DragEnter += LabelAdditionalColor_DragEnter;
+ //
+ // labelBodyColor
+ //
+ labelBodyColor.AllowDrop = true;
+ labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
+ labelBodyColor.Location = new Point(3, 5);
+ labelBodyColor.Name = "labelBodyColor";
+ labelBodyColor.Size = new Size(69, 23);
+ labelBodyColor.TabIndex = 2;
+ labelBodyColor.Text = "Цвет";
+ labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
+ labelBodyColor.DragDrop += LabelBodyColor_DragDrop;
+ labelBodyColor.DragEnter += LabelBodyColor_DragEnter;
+ //
+ // FormLocomotiveConfig
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 213);
+ Controls.Add(panelObject);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonAdd);
+ Controls.Add(groupBoxConfig);
+ Name = "FormLocomotiveConfig";
+ Text = "Создание объекта";
+ groupBoxConfig.ResumeLayout(false);
+ groupBoxConfig.PerformLayout();
+ groupBoxColors.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 groupBoxConfig;
+ private Label labelModifiedObject;
+ private Label labelSimpleObject;
+ private CheckBox checkBoxRocketMine;
+ private NumericUpDown numericUpDownWeight;
+ private Label labelWeight;
+ private NumericUpDown numericUpDownSpeed;
+ private Label labelSpeed;
+ private CheckBox checkBoxHelipad;
+ private GroupBox groupBoxColors;
+ private Panel panelPurple;
+ private Panel panelYellow;
+ private Panel panelBlack;
+ private Panel panelBlue;
+ private Panel panelGray;
+ private Panel panelRed;
+ private Panel panelGreen;
+ private Panel panelWhite;
+ private PictureBox pictureBoxObject;
+ private Button buttonAdd;
+ private Button buttonCancel;
+ private Panel panelObject;
+ private Label labelAdditionalColor;
+ private Label labelBodyColor;
+ }
+}
\ No newline at end of file
diff --git a/LocomativeProject/LocomativeProject/FormCruiserConfig.cs b/LocomativeProject/LocomativeProject/FormCruiserConfig.cs
new file mode 100644
index 0000000..3109a8b
--- /dev/null
+++ b/LocomativeProject/LocomativeProject/FormCruiserConfig.cs
@@ -0,0 +1,167 @@
+using LocomativeProject.Drawnings;
+using LocomotiveProject.Drawnings;
+using LocomotiveProject.Entities;
+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;
+
+namespace LocomotiveProject;
+///
+/// Форма конфигурации объекта
+///
+public partial class FormLocomotiveConfig : Form
+{
+ ///
+ /// объект - прорисовка круизера
+ ///
+ private DrawningBaseLocomotive? _BaseLocomotive;
+ ///
+ /// событе для передачи объекта
+ ///
+ public event LocomotiveDelegate? _LocomotiveDelegate;
+ ///
+ /// Конструктор
+ ///
+ public FormLocomotiveConfig()
+ {
+ InitializeComponent();
+ panelRed.MouseDown += Panel_MouseDown;
+ panelGreen.MouseDown += Panel_MouseDown;
+ panelBlue.MouseDown += Panel_MouseDown;
+ panelYellow.MouseDown += Panel_MouseDown;
+ panelGray.MouseDown += Panel_MouseDown;
+ panelBlack.MouseDown += Panel_MouseDown;
+ panelPurple.MouseDown += Panel_MouseDown;
+ panelWhite.MouseDown += Panel_MouseDown;
+ buttonCancel.Click += (sender, e) => Close();
+ }
+ ///
+ /// привязка метода к событию
+ ///
+ ///
+ public void AddEvent(LocomotiveDelegate LocomotiveDelegate)
+ {
+ _LocomotiveDelegate += LocomotiveDelegate;
+ }
+ ///
+ /// Прорисовка обьекта
+ ///
+ public void DrawObject()
+ {
+ Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
+ Graphics g = Graphics.FromImage(bmp);
+ _BaseLocomotive?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
+ _BaseLocomotive?.SetPosition(5, 5);
+ _BaseLocomotive?.DrawTransport(g);
+ pictureBoxObject.Image = bmp;
+ }
+ ///
+ /// Передаем информацию при нажатии на Label
+ ///
+ ///
+ ///
+ private void LabelObject_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+ ///
+ /// Действия при приеме перетаскиваемой информации
+ ///
+ ///
+ ///
+ 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 PanelObject_DragDrop(object? sender, DragEventArgs e)
+ {
+ switch (e.Data?.GetData(DataFormats.Text).ToString())
+ {
+ case "labelSimpleObject":
+ _BaseLocomotive = new DrawningBaseLocomotive((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
+ break;
+ case "labelModifiedObject":
+ _BaseLocomotive = new DrawningLocomotive((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White, Color.Black,
+ checkBoxRocketMine.Checked, checkBoxHelipad.Checked);
+ break;
+ }
+ DrawObject();
+ }
+
+ private void Panel_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ private void LabelBodyColor_DragDrop(object sender, DragEventArgs e)
+ {
+ if (_BaseLocomotive != null)
+ {
+ _BaseLocomotive._EntityBaseLocomotive.setBodyColor((Color)e.Data.GetData(typeof(Color)));
+ DrawObject();
+ }
+ }
+
+ private void LabelBodyColor_DragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(typeof(Color)))
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+
+ private void LabelAdditionalColor_DragDrop(object sender, DragEventArgs e)
+ {
+ if (_BaseLocomotive._EntityBaseLocomotive is EntityLocomotive entityLocomotive)
+ {
+ entityLocomotive.setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
+ }
+ DrawObject();
+ }
+
+ private void LabelAdditionalColor_DragEnter(object sender, DragEventArgs e)
+ {
+ if (_BaseLocomotive is DrawningBaseLocomotive)
+ {
+ if (e.Data.GetDataPresent(typeof(Color)))
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+ }
+ ///
+ /// Передача объекта
+ ///
+ ///
+ ///
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ if (_BaseLocomotive != null) { _LocomotiveDelegate?.Invoke(_BaseLocomotive); Close(); }
+ }
+}
diff --git a/LocomativeProject/LocomativeProject/LocomotiveProjectCollection.resx b/LocomativeProject/LocomativeProject/FormCruiserConfig.resx
similarity index 100%
rename from LocomativeProject/LocomativeProject/LocomotiveProjectCollection.resx
rename to LocomativeProject/LocomativeProject/FormCruiserConfig.resx
diff --git a/LocomativeProject/LocomativeProject/LocomotiveProjectCollection.Designer.cs b/LocomativeProject/LocomativeProject/FormLocomotiveCollection.Designer.cs
similarity index 92%
rename from LocomativeProject/LocomativeProject/LocomotiveProjectCollection.Designer.cs
rename to LocomativeProject/LocomativeProject/FormLocomotiveCollection.Designer.cs
index 3f82068..4dcfabe 100644
--- a/LocomativeProject/LocomativeProject/LocomotiveProjectCollection.Designer.cs
+++ b/LocomativeProject/LocomativeProject/FormLocomotiveCollection.Designer.cs
@@ -1,6 +1,6 @@
namespace LocomativeProject
{
- partial class LocomotiveProjectCollection
+ partial class FormLocomotiveCollection
{
///
/// Required designer variable.
@@ -30,7 +30,6 @@
{
groupBox1 = new GroupBox();
panelCompany = new Panel();
- buttonModifLocomotive = new Button();
buttonAddLocomotive = new Button();
maskedTextBox = new MaskedTextBox();
buttonRefresh = new Button();
@@ -69,7 +68,6 @@
//
// panelCompany
//
- panelCompany.Controls.Add(buttonModifLocomotive);
panelCompany.Controls.Add(buttonAddLocomotive);
panelCompany.Controls.Add(maskedTextBox);
panelCompany.Controls.Add(buttonRefresh);
@@ -82,16 +80,6 @@
panelCompany.Size = new Size(174, 232);
panelCompany.TabIndex = 9;
//
- // buttonModifLocomotive
- //
- buttonModifLocomotive.Location = new Point(15, 38);
- buttonModifLocomotive.Name = "buttonModifLocomotive";
- buttonModifLocomotive.Size = new Size(150, 43);
- buttonModifLocomotive.TabIndex = 2;
- buttonModifLocomotive.Text = "Добавление модиф поезда";
- buttonModifLocomotive.UseVisualStyleBackColor = true;
- buttonModifLocomotive.Click += ButtonModifLocomotive_Click;
- //
// buttonAddLocomotive
//
buttonAddLocomotive.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
@@ -99,7 +87,7 @@
buttonAddLocomotive.Name = "buttonAddLocomotive";
buttonAddLocomotive.Size = new Size(150, 26);
buttonAddLocomotive.TabIndex = 1;
- buttonAddLocomotive.Text = "Добавление поезда";
+ buttonAddLocomotive.Text = "Добавление локомотива";
buttonAddLocomotive.UseVisualStyleBackColor = true;
buttonAddLocomotive.Click += ButtonAddLocomotive_Click;
//
@@ -128,7 +116,7 @@
buttonRemoveLocomotive.Name = "buttonRemoveLocomotive";
buttonRemoveLocomotive.Size = new Size(150, 23);
buttonRemoveLocomotive.TabIndex = 4;
- buttonRemoveLocomotive.Text = "Удалить поезд";
+ buttonRemoveLocomotive.Text = "Удалить локомотив";
buttonRemoveLocomotive.UseVisualStyleBackColor = true;
buttonRemoveLocomotive.Click += ButtonRemoveLocomotive_Click;
//
@@ -255,15 +243,15 @@
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
- // LocomotiveProjectCollection
+ // FormLocomotiveCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1092, 581);
Controls.Add(pictureBox);
Controls.Add(groupBox1);
- Name = "LocomotiveProjectCollection";
- Text = "Коллекция Крейсеров";
+ Name = "FormLocomotiveCollection";
+ Text = "Коллекция Локомотивов";
groupBox1.ResumeLayout(false);
panelCompany.ResumeLayout(false);
panelCompany.PerformLayout();
@@ -278,7 +266,6 @@
private GroupBox groupBox1;
private ComboBox comboBoxSelectorCompany;
private Button buttonAddLocomotive;
- private Button buttonModifLocomotive;
private Button buttonRemoveLocomotive;
private MaskedTextBox maskedTextBox;
private PictureBox pictureBox;
diff --git a/LocomativeProject/LocomativeProject/LocomotiveProjectCollection.cs b/LocomativeProject/LocomativeProject/FormLocomotiveCollection.cs
similarity index 84%
rename from LocomativeProject/LocomativeProject/LocomotiveProjectCollection.cs
rename to LocomativeProject/LocomativeProject/FormLocomotiveCollection.cs
index 01d612b..e75be7a 100644
--- a/LocomativeProject/LocomativeProject/LocomotiveProjectCollection.cs
+++ b/LocomativeProject/LocomativeProject/FormLocomotiveCollection.cs
@@ -1,7 +1,4 @@
using LocomativeProject.Drawnings;
-using LocomotiveProject;
-using LocomotiveProject.CollectionGenericObjects;
-using LocomotiveProject.Drawnings;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -11,10 +8,13 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using LocomotiveProject.CollectionGenericObjects;
+using LocomotiveProject.Drawnings;
+using LocomotiveProject;
namespace LocomativeProject;
-public partial class LocomotiveProjectCollection : Form
+public partial class FormLocomotiveCollection : Form
{
///
/// Хранилище коллекций
@@ -27,7 +27,7 @@ public partial class LocomotiveProjectCollection : Form
///
/// Консруктор
///
- public LocomotiveProjectCollection()
+ public FormLocomotiveCollection()
{
InitializeComponent();
_storageCollection = new();
@@ -52,23 +52,24 @@ public partial class LocomotiveProjectCollection : Form
return;
}
Random rnd = new();
- DrawningBaseLocomotive DrawningBaseLocomotive;
+ DrawningBaseLocomotive drawningBaseLocomotive;
switch (type)
{
case nameof(DrawningBaseLocomotive):
- DrawningBaseLocomotive = new DrawningBaseLocomotive(rnd.Next(100, 300), rnd.Next(1000, 3000), GetColor(rnd));
+ drawningBaseLocomotive = new DrawningBaseLocomotive(rnd.Next(100, 300), rnd.Next(1000, 3000), GetColor(rnd));
break;
case nameof(DrawningLocomotive):
- DrawningBaseLocomotive = new DrawningLocomotive(rnd.Next(100, 300), rnd.Next(1000, 3000), GetColor(rnd), GetColor(rnd),
+ drawningBaseLocomotive = new DrawningLocomotive(rnd.Next(100, 300), rnd.Next(1000, 3000), GetColor(rnd), GetColor(rnd),
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
break;
default:
return;
}
- if (_company + DrawningBaseLocomotive != -1)
+ if (_company + drawningBaseLocomotive != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
+
}
else
{
@@ -91,17 +92,36 @@ public partial class LocomotiveProjectCollection : Form
return color;
}
///
- /// Кнопка создания обычного крейсера
+ /// Кнопка добавления крейсера
///
///
///
- private void ButtonAddLocomotive_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBaseLocomotive));
+ private void ButtonAddLocomotive_Click(object sender, EventArgs e)
+ {
+ FormLocomotiveConfig form = new FormLocomotiveConfig();
+ form.Show();
+ form.AddEvent(setLocomotive);
+ }
///
- /// Кнопка создания модиф крейсера
+ /// Добавление автомобиля в коллекцию
///
- ///
- ///
- private void ButtonModifLocomotive_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningLocomotive));
+ ///
+ private void setLocomotive(DrawningBaseLocomotive Locomotive)
+ {
+ if (_company == null || Locomotive == null)
+ {
+ return;
+ }
+ if (_company + Locomotive != -1)
+ {
+ MessageBox.Show("объект добавлен");
+ pictureBox.Image= _company.Show();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавлять объект");
+ }
+ }
///
/// Кнопка удаления Крейсера
///
@@ -143,11 +163,11 @@ public partial class LocomotiveProjectCollection : Form
{
return;
}
- DrawningBaseLocomotive baseLocomotive = null;
+ DrawningBaseLocomotive BaseLocomotive = null;
int counter = 100;
- while (baseLocomotive == null)
+ while (BaseLocomotive == null)
{
- baseLocomotive = _company.GetRandomObject();
+ BaseLocomotive = _company.GetRandomObject();
counter--;
if (counter <= 0)
{
@@ -155,12 +175,12 @@ public partial class LocomotiveProjectCollection : Form
}
}
- if (baseLocomotive == null)
+ if (BaseLocomotive == null)
{
return;
}
- LocomotiveProjectForm form = new() { SetLocomotive = baseLocomotive };
+ LocomotiveProjectForm form = new() { SetLocomotive = BaseLocomotive };
form.ShowDialog();
}
@@ -171,8 +191,11 @@ public partial class LocomotiveProjectCollection : Form
///
private void ButtonRefresh_Click(object sender, EventArgs e)
{
- if (_company != null)
- pictureBox.Image = _company.Show();
+ if (_company == null)
+ {
+ return;
+ }
+ pictureBox.Image = _company.Show();
}
///
///
diff --git a/LocomativeProject/LocomativeProject/FormLocomotiveCollection.resx b/LocomativeProject/LocomativeProject/FormLocomotiveCollection.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/LocomativeProject/LocomativeProject/FormLocomotiveCollection.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/LocomativeProject/LocomativeProject/LocomotiveDelegate.cs b/LocomativeProject/LocomativeProject/LocomotiveDelegate.cs
new file mode 100644
index 0000000..17a30ef
--- /dev/null
+++ b/LocomativeProject/LocomativeProject/LocomotiveDelegate.cs
@@ -0,0 +1,13 @@
+using LocomativeProject.Drawnings;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace LocomotiveProject;
+///
+/// Делегат передачи объекта класса-прорисовки
+///
+///
+public delegate void LocomotiveDelegate(DrawningBaseLocomotive Locomotive);
\ No newline at end of file
diff --git a/LocomativeProject/LocomativeProject/MovementStrategy/MoveableLocomotive.cs b/LocomativeProject/LocomativeProject/MovementStrategy/MoveableLocomotive.cs
index 4138772..3fdef5b 100644
--- a/LocomativeProject/LocomativeProject/MovementStrategy/MoveableLocomotive.cs
+++ b/LocomativeProject/LocomativeProject/MovementStrategy/MoveableLocomotive.cs
@@ -24,7 +24,7 @@ public class MoveableLocomotive : IMoveableObject
{
get
{
- if (_locomotive == null || _locomotive._EntityLocomotive == null || !_locomotive.GetPosX.HasValue || !_locomotive.GetPosY.HasValue)
+ if (_locomotive == null || _locomotive._EntityBaseLocomotive == null || !_locomotive.GetPosX.HasValue || !_locomotive.GetPosY.HasValue)
{
return null;
}
@@ -32,11 +32,11 @@ public class MoveableLocomotive : IMoveableObject
}
}
- public int GetStep => (int)(_locomotive?._EntityLocomotive?.Step ?? 0);
+ public int GetStep => (int)(_locomotive?._EntityBaseLocomotive?.Step ?? 0);
public bool TryMoveObject(MovementDirection direction)
{
- if (_locomotive == null || _locomotive._EntityLocomotive == null)
+ if (_locomotive == null || _locomotive._EntityBaseLocomotive == null)
{
return false;
}
diff --git a/LocomativeProject/LocomativeProject/Program.cs b/LocomativeProject/LocomativeProject/Program.cs
index 2732666..3d8c3c8 100644
--- a/LocomativeProject/LocomativeProject/Program.cs
+++ b/LocomativeProject/LocomativeProject/Program.cs
@@ -13,7 +13,7 @@ namespace LocomotiveProject
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new LocomotiveProjectCollection());
+ Application.Run(new FormLocomotiveCollection());
}
}
}
\ No newline at end of file