This commit is contained in:
KirillFilippow 2023-12-06 18:54:22 +04:00
parent aa766d5f54
commit 689ec4a5ce
11 changed files with 744 additions and 27 deletions

View File

@ -7,7 +7,8 @@ using static ProjectContainerShip.Direction;
using static System.Windows.Forms.VisualStyles.VisualStyleElement; using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace ProjectContainerShip.MovementStrategy namespace ProjectContainerShip.MovementStrategy
{/// <summary> {
/// <summary>
/// Класс-стратегия перемещения объекта /// Класс-стратегия перемещения объекта
/// </summary> /// </summary>
public abstract class AbstractStrategy public abstract class AbstractStrategy

View File

@ -38,16 +38,24 @@ namespace ProjectContainerShip.DrawningObjects
return; return;
} }
Brush additionalBrush = new SolidBrush(containerShip.AdditionalColor); Brush additionalBrush = new SolidBrush(containerShip.AdditionalColor);
// Контейнер if (containerShip.Container)
{
g.FillRectangle(additionalBrush, _startPosX + 55, _startPosY + 7, 35, 5); g.FillRectangle(additionalBrush, _startPosX + 55, _startPosY + 7, 35, 5);
}
//кран //кран
if (containerShip.Crane)
{
Brush brBl = new SolidBrush(Color.Black); Brush brBl = new SolidBrush(Color.Black);
g.FillRectangle(brBl, _startPosX + 110, _startPosY + 0, 3, 12); g.FillRectangle(brBl, _startPosX + 110, _startPosY + 0, 3, 12);
g.FillRectangle(brBl, _startPosX + 105, _startPosY + 1, 20, 2); g.FillRectangle(brBl, _startPosX + 105, _startPosY + 1, 20, 2);
}
// несколько контенеров // несколько контенеров
if (containerShip.Container)
{
g.FillRectangle(additionalBrush, _startPosX + 55, _startPosY + 2, 35, 5); g.FillRectangle(additionalBrush, _startPosX + 55, _startPosY + 2, 35, 5);
g.FillRectangle(additionalBrush, _startPosX + 135, _startPosY + 7, 35, 5); g.FillRectangle(additionalBrush, _startPosX + 135, _startPosY + 7, 35, 5);
g.FillRectangle(additionalBrush, _startPosX + 135, _startPosY + 2, 35, 5); g.FillRectangle(additionalBrush, _startPosX + 135, _startPosY + 2, 35, 5);
}
base.DrawTransport(g); base.DrawTransport(g);
} }
} }

View File

@ -97,6 +97,7 @@ namespace ProjectContainerShip.DrawningObjects
else _startPosX = 0; else _startPosX = 0;
if ((y > 0) && (y < _pictureHeight)) if ((y > 0) && (y < _pictureHeight))
_startPosY = y; _startPosY = y;
else _startPosY = 0; else _startPosY = 0;
_startPosX = x; _startPosX = x;
_startPosY = y; _startPosY = y;
@ -181,7 +182,7 @@ namespace ProjectContainerShip.DrawningObjects
{ {
return; return;
} }
Brush bodyBrush = new SolidBrush(EntityShip.BodyColor); Brush bodyColor = new SolidBrush(EntityShip.BodyColor);
//границы корабля //границы корабля
Brush brRd = new SolidBrush(Color.Red); Brush brRd = new SolidBrush(Color.Red);
Point point1 = new Point(_startPosX, _startPosY + 12); Point point1 = new Point(_startPosX, _startPosY + 12);
@ -189,10 +190,10 @@ namespace ProjectContainerShip.DrawningObjects
Point point3 = new Point(_startPosX + 175, _startPosY + 35); Point point3 = new Point(_startPosX + 175, _startPosY + 35);
Point point4 = new Point(_startPosX + 200, _startPosY + 12); Point point4 = new Point(_startPosX + 200, _startPosY + 12);
Point[] curvePoints1 = { point1, point2, point3, point4 }; Point[] curvePoints1 = { point1, point2, point3, point4 };
g.FillPolygon(brRd, curvePoints1); g.FillPolygon(bodyColor, curvePoints1);
//граница палубы //граница палубы
Brush brBlue = new SolidBrush(Color.Blue); Brush brBlue = new SolidBrush(Color.Blue);
g.FillRectangle(bodyBrush, _startPosX + 35, _startPosY + 0, 16, 12); g.FillRectangle(bodyColor, _startPosX + 35, _startPosY + 0, 16, 12);
} }
} }
} }

View File

@ -12,7 +12,7 @@ namespace ProjectContainerShip.Entities
/// <summary> /// <summary>
/// Дополнительный цвет (для опциональных элементов) /// Дополнительный цвет (для опциональных элементов)
/// </summary> /// </summary>
public Color AdditionalColor { get; private set; } public Color AdditionalColor { get; set; }
/// <summary> /// <summary>
/// Признак (опция) наличия крана /// Признак (опция) наличия крана
/// </summary> /// </summary>
@ -21,6 +21,7 @@ namespace ProjectContainerShip.Entities
/// Признак (опция) наличия дополнительных контейнеров /// Признак (опция) наличия дополнительных контейнеров
/// </summary> /// </summary>
public bool Container { get; private set; } public bool Container { get; private set; }
/// <summary> /// <summary>
/// Инициализация полей объекта-класса контейнеровоза /// Инициализация полей объекта-класса контейнеровоза
/// </summary> /// </summary>
@ -28,8 +29,8 @@ namespace ProjectContainerShip.Entities
/// <param name="weight">Вес </param> /// <param name="weight">Вес </param>
/// <param name="bodyColor">Основной цвет</param> /// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param> /// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="Crane">Признак наличия труб</param> /// <param name="crane">Признак наличия труб</param>
/// <param name="Container">Признак наличия топлива</param> /// <param name="container">Признак наличия топлива</param>
public EntityContainerShip(int speed, double weight, Color bodyColor, Color additionalColor, bool crane, bool container) : base(speed, weight, bodyColor) public EntityContainerShip(int speed, double weight, Color bodyColor, Color additionalColor, bool crane, bool container) : base(speed, weight, bodyColor)
{ {
AdditionalColor = additionalColor; AdditionalColor = additionalColor;

View File

@ -19,7 +19,7 @@ namespace ProjectContainerShip
/// <summary> /// <summary>
/// Основной цвет /// Основной цвет
/// </summary> /// </summary>
public Color BodyColor { get; private set; } public Color BodyColor { get; set; }
/// <summary> /// <summary>
/// Шаг перемещения корабля /// Шаг перемещения корабля
/// </summary> /// </summary>

View File

@ -114,10 +114,11 @@ namespace ProjectContainerShip
{ {
return; return;
} }
FormContainerShip form = new(); var form = new FormContainerConfig();
if (form.ShowDialog() == DialogResult.OK) form.AddEvent(deleg =>
{ {
if (obj + form.SelectedShip) bool SelectedShip = (obj + deleg);
if (SelectedShip)
{ {
MessageBox.Show("Объект добавлен"); MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowContainer(); pictureBoxCollection.Image = obj.ShowContainer();
@ -126,7 +127,8 @@ namespace ProjectContainerShip
{ {
MessageBox.Show("Не удалось добавить объект"); MessageBox.Show("Не удалось добавить объект");
} }
} });
form.Show();
} }
/// <summary> /// <summary>
/// Удаление объекта из набора /// Удаление объекта из набора

View File

@ -0,0 +1,392 @@
namespace ProjectContainerShip
{
partial class FormContainerConfig
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
groupBox1 = new GroupBox();
labelModifiedObject = new Label();
labelSimpleObject = new Label();
groupBox2 = new GroupBox();
panelPurple = new Panel();
panelYellow = new Panel();
panelBlack = new Panel();
panelBlue = new Panel();
panelGray = new Panel();
panelGreen = new Panel();
panelWhite = new Panel();
panelRed = new Panel();
checkBoxContainer = new CheckBox();
checkBoxCrane = new CheckBox();
numericUpDownWeight = new NumericUpDown();
numericUpDownSpeed = new NumericUpDown();
label2 = new Label();
label1 = new Label();
panelColor = new Panel();
labelDopColor = new Label();
labelBaseColor = new Label();
pictureBoxObject = new PictureBox();
ButtonOk = new Button();
buttonCancel = new Button();
groupBox1.SuspendLayout();
groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
panelColor.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
SuspendLayout();
//
// groupBox1
//
groupBox1.Controls.Add(labelModifiedObject);
groupBox1.Controls.Add(labelSimpleObject);
groupBox1.Controls.Add(groupBox2);
groupBox1.Controls.Add(checkBoxContainer);
groupBox1.Controls.Add(checkBoxCrane);
groupBox1.Controls.Add(numericUpDownWeight);
groupBox1.Controls.Add(numericUpDownSpeed);
groupBox1.Controls.Add(label2);
groupBox1.Controls.Add(label1);
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(519, 304);
groupBox1.TabIndex = 0;
groupBox1.TabStop = false;
groupBox1.Text = "Параметры";
//
// labelModifiedObject
//
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
labelModifiedObject.Location = new Point(358, 195);
labelModifiedObject.Name = "labelModifiedObject";
labelModifiedObject.Size = new Size(110, 35);
labelModifiedObject.TabIndex = 8;
labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
labelModifiedObject.Click += labelModifiedObject_Click;
labelModifiedObject.MouseDown += LabelObject_MouseDown;
//
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(246, 195);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(99, 35);
labelSimpleObject.TabIndex = 7;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
labelSimpleObject.MouseDown += LabelObject_MouseDown;
//
// groupBox2
//
groupBox2.Controls.Add(panelPurple);
groupBox2.Controls.Add(panelYellow);
groupBox2.Controls.Add(panelBlack);
groupBox2.Controls.Add(panelBlue);
groupBox2.Controls.Add(panelGray);
groupBox2.Controls.Add(panelGreen);
groupBox2.Controls.Add(panelWhite);
groupBox2.Controls.Add(panelRed);
groupBox2.Location = new Point(246, 43);
groupBox2.Margin = new Padding(3, 4, 3, 4);
groupBox2.Name = "groupBox2";
groupBox2.Padding = new Padding(3, 4, 3, 4);
groupBox2.Size = new Size(211, 141);
groupBox2.TabIndex = 6;
groupBox2.TabStop = false;
groupBox2.Text = "Цвета";
//
// panelPurple
//
panelPurple.BackColor = Color.FromArgb(192, 0, 192);
panelPurple.Location = new Point(159, 84);
panelPurple.Margin = new Padding(3, 4, 3, 4);
panelPurple.Name = "panelPurple";
panelPurple.Size = new Size(40, 40);
panelPurple.TabIndex = 7;
panelPurple.MouseDown += panelColor_MouseDown;
//
// panelYellow
//
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(159, 29);
panelYellow.Margin = new Padding(3, 4, 3, 4);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(40, 40);
panelYellow.TabIndex = 3;
panelYellow.MouseDown += panelColor_MouseDown;
//
// panelBlack
//
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(112, 84);
panelBlack.Margin = new Padding(3, 4, 3, 4);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(40, 40);
panelBlack.TabIndex = 6;
panelBlack.MouseDown += panelColor_MouseDown;
//
// panelBlue
//
panelBlue.BackColor = Color.Blue;
panelBlue.Location = new Point(112, 29);
panelBlue.Margin = new Padding(3, 4, 3, 4);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(40, 40);
panelBlue.TabIndex = 2;
panelBlue.MouseDown += panelColor_MouseDown;
//
// panelGray
//
panelGray.BackColor = Color.Gray;
panelGray.Location = new Point(65, 84);
panelGray.Margin = new Padding(3, 4, 3, 4);
panelGray.Name = "panelGray";
panelGray.Size = new Size(40, 40);
panelGray.TabIndex = 5;
panelGray.MouseDown += panelColor_MouseDown;
//
// panelGreen
//
panelGreen.BackColor = Color.FromArgb(0, 192, 0);
panelGreen.Location = new Point(65, 29);
panelGreen.Margin = new Padding(3, 4, 3, 4);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(40, 40);
panelGreen.TabIndex = 1;
panelGreen.MouseDown += panelColor_MouseDown;
//
// panelWhite
//
panelWhite.BackColor = Color.White;
panelWhite.Location = new Point(18, 84);
panelWhite.Margin = new Padding(3, 4, 3, 4);
panelWhite.Name = "panelWhite";
panelWhite.Size = new Size(40, 40);
panelWhite.TabIndex = 4;
panelWhite.MouseDown += panelColor_MouseDown;
//
// panelRed
//
panelRed.BackColor = Color.Red;
panelRed.Location = new Point(18, 29);
panelRed.Margin = new Padding(3, 4, 3, 4);
panelRed.Name = "panelRed";
panelRed.Size = new Size(40, 40);
panelRed.TabIndex = 0;
panelRed.MouseDown += panelColor_MouseDown;
//
// checkBoxContainer
//
checkBoxContainer.AutoSize = true;
checkBoxContainer.Location = new Point(11, 229);
checkBoxContainer.Margin = new Padding(3, 4, 3, 4);
checkBoxContainer.Name = "checkBoxContainer";
checkBoxContainer.Size = new Size(199, 24);
checkBoxContainer.TabIndex = 5;
checkBoxContainer.Text = "Признак наличия крана";
checkBoxContainer.UseVisualStyleBackColor = true;
checkBoxContainer.CheckedChanged += checkBoxBodyKit_CheckedChanged;
//
// checkBoxCrane
//
checkBoxCrane.AutoSize = true;
checkBoxCrane.Location = new Point(11, 261);
checkBoxCrane.Margin = new Padding(3, 4, 3, 4);
checkBoxCrane.Name = "checkBoxCrane";
checkBoxCrane.Size = new Size(249, 24);
checkBoxCrane.TabIndex = 4;
checkBoxCrane.Text = "Признак наличия котнейнеров";
checkBoxCrane.UseVisualStyleBackColor = true;
checkBoxCrane.CheckedChanged += checkBoxCrane_CheckedChanged;
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(87, 80);
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(83, 27);
numericUpDownWeight.TabIndex = 3;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownWeight.ValueChanged += numericUpDownWeight_ValueChanged;
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(87, 41);
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(83, 27);
numericUpDownSpeed.TabIndex = 2;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownSpeed.ValueChanged += numericUpDownSpeed_ValueChanged;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(11, 83);
label2.Name = "label2";
label2.Size = new Size(36, 20);
label2.TabIndex = 1;
label2.Text = "Вес:";
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(11, 44);
label1.Name = "label1";
label1.Size = new Size(76, 20);
label1.TabIndex = 0;
label1.Text = "Скорость:";
//
// panelColor
//
panelColor.AllowDrop = true;
panelColor.Controls.Add(labelDopColor);
panelColor.Controls.Add(labelBaseColor);
panelColor.Controls.Add(pictureBoxObject);
panelColor.Location = new Point(539, 16);
panelColor.Margin = new Padding(3, 4, 3, 4);
panelColor.Name = "panelColor";
panelColor.Size = new Size(315, 245);
panelColor.TabIndex = 1;
panelColor.DragDrop += PanelObject_DragDrop;
panelColor.DragEnter += PanelObject_DragEnter;
//
// labelDopColor
//
labelDopColor.AllowDrop = true;
labelDopColor.BorderStyle = BorderStyle.FixedSingle;
labelDopColor.Location = new Point(187, 13);
labelDopColor.Name = "labelDopColor";
labelDopColor.Size = new Size(114, 38);
labelDopColor.TabIndex = 2;
labelDopColor.Text = "Доп. цвет";
labelDopColor.TextAlign = ContentAlignment.MiddleCenter;
labelDopColor.DragDrop += LabelDopColor_DragDrop;
labelDopColor.DragEnter += LabelColor_DragEnter;
labelDopColor.MouseDown += LabelObject_MouseDown;
//
// labelBaseColor
//
labelBaseColor.AllowDrop = true;
labelBaseColor.BorderStyle = BorderStyle.FixedSingle;
labelBaseColor.Location = new Point(14, 13);
labelBaseColor.Name = "labelBaseColor";
labelBaseColor.Size = new Size(114, 38);
labelBaseColor.TabIndex = 2;
labelBaseColor.Text = "Цвет";
labelBaseColor.TextAlign = ContentAlignment.MiddleCenter;
labelBaseColor.DragDrop += LabelBaseColor_DragDrop;
labelBaseColor.DragEnter += LabelColor_DragEnter;
labelBaseColor.MouseDown += LabelObject_MouseDown;
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(14, 61);
pictureBoxObject.Margin = new Padding(3, 4, 3, 4);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(288, 169);
pictureBoxObject.TabIndex = 0;
pictureBoxObject.TabStop = false;
//
// ButtonOk
//
ButtonOk.Location = new Point(553, 277);
ButtonOk.Margin = new Padding(3, 4, 3, 4);
ButtonOk.Name = "ButtonOk";
ButtonOk.Size = new Size(114, 43);
ButtonOk.TabIndex = 2;
ButtonOk.Text = "Добавить";
ButtonOk.UseVisualStyleBackColor = true;
ButtonOk.Click += ButtonOk_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(727, 277);
buttonCancel.Margin = new Padding(3, 4, 3, 4);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(114, 43);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
//
// FormContainerConfig
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(914, 336);
Controls.Add(buttonCancel);
Controls.Add(ButtonOk);
Controls.Add(panelColor);
Controls.Add(groupBox1);
Margin = new Padding(3, 4, 3, 4);
Name = "FormContainerConfig";
Text = "FormSelfPropelledArtilleryUnitConfig";
groupBox1.ResumeLayout(false);
groupBox1.PerformLayout();
groupBox2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
panelColor.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
ResumeLayout(false);
}
#endregion
private GroupBox groupBox1;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private Label label2;
private Label label1;
private GroupBox groupBox2;
private CheckBox checkBoxContainer;
private CheckBox checkBoxCrane;
private Panel panelPurple;
private Panel panelYellow;
private Panel panelBlack;
private Panel panelBlue;
private Panel panelGray;
private Panel panelGreen;
private Panel panelWhite;
private Panel panelRed;
private Label labelSimpleObject;
private Label labelModifiedObject;
private Panel panelColor;
private PictureBox pictureBoxObject;
private Label labelDopColor;
private Label labelBaseColor;
private Button ButtonOk;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,191 @@
using ProjectContainerShip.DrawningObjects;
using ProjectContainerShip.Entities;
using ProjectContainerShip;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
namespace ProjectContainerShip
{
/// <summary>
/// Форма создания объекта
/// </summary>
public partial class FormContainerConfig : Form
{
/// <summary>
/// Переменная-выбранный корабль
/// </summary>
DrawningShip? _ship = null;
/// <summary>
/// Событие
/// </summary>
private event Action<DrawningShip> EventAddShip;
/// <summary>
/// Конструктор
/// </summary>
public FormContainerConfig()
{
InitializeComponent();
panelBlack.MouseDown += panelColor_MouseDown;
panelPurple.MouseDown += panelColor_MouseDown;
panelGray.MouseDown += panelColor_MouseDown;
panelGreen.MouseDown += panelColor_MouseDown;
panelRed.MouseDown += panelColor_MouseDown;
panelWhite.MouseDown += panelColor_MouseDown;
panelYellow.MouseDown += panelColor_MouseDown;
panelBlue.MouseDown += panelColor_MouseDown;
buttonCancel.Click += (sender, e) => Close();
}
/// <summary>
/// Отрисовать контейнеровоз
/// </summary>
private void DrawShip()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_ship?.SetPosition(5, 5);
_ship?.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
/// <summary>
/// Добавление события
/// </summary>
/// <param name="ev">Привязанный метод</param>
public void AddEvent(Action<DrawningShip> ev)
{
if (EventAddShip == null)
{
EventAddShip = new Action<DrawningShip>(ev);
}
else
{
EventAddShip += 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":
_ship = new DrawningShip((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
pictureBoxObject.Height);
break;
case "labelModifiedObject":
_ship = new DrawningContainerShip((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxContainer.Checked,
checkBoxCrane.Checked, pictureBoxObject.Width, pictureBoxObject.Height);
break;
}
DrawShip();
}
/// <summary>
/// Отправляем цвет с панели
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void panelColor_MouseDown(object sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
}
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
{
if (_ship != null)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
_ship.EntityShip.BodyColor = (Color)e.Data.GetData(typeof(Color));
}
DrawShip();
}
}
private void LabelColor_DragEnter(object sender, DragEventArgs e)
{
if (_ship != null && _ship.EntityShip is EntityContainerShip entityustabat)
{
labelDopColor.AllowDrop = true;
}
else
labelDopColor.AllowDrop = false;
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
{
if (_ship != null && _ship.EntityShip is EntityContainerShip entityContainerShip)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
entityContainerShip.AdditionalColor = (Color)e.Data.GetData(typeof(Color));
}
DrawShip();
}
}
/// <summary>
/// Добавление корабля
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonOk_Click(object sender, EventArgs e)
{
EventAddShip?.Invoke(_ship);
Close();
}
private void checkBoxBodyKit_CheckedChanged(object sender, EventArgs e)
{
}
private void labelModifiedObject_Click(object sender, EventArgs e)
{
}
private void numericUpDownSpeed_ValueChanged(object sender, EventArgs e)
{
}
private void numericUpDownWeight_ValueChanged(object sender, EventArgs e)
{
}
private void checkBoxCrane_CheckedChanged(object sender, EventArgs e)
{
}
}
}

View 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>

View File

@ -59,3 +59,4 @@ namespace ProjectContainerShip.MovementStrategy
} }