diff --git a/Warship/Warship/DrawingAdvancedWarship.cs b/Warship/Warship/DrawingAdvancedWarship.cs
index e8c3fe7..95d9612 100644
--- a/Warship/Warship/DrawingAdvancedWarship.cs
+++ b/Warship/Warship/DrawingAdvancedWarship.cs
@@ -67,5 +67,10 @@ namespace Warship
g.DrawLine(pen, _startPosX +10, _startPosY + 30 - 5, _startPosX + 20, _startPosY + 30 - 5);
}
}
+
+ public void SetModifColor(Color modifColor)
+ {
+ ((EntityAdvancedWarship)Warship).DopColor = modifColor;
+ }
}
}
diff --git a/Warship/Warship/DrawingWarship.cs b/Warship/Warship/DrawingWarship.cs
index d985f58..0d0c294 100644
--- a/Warship/Warship/DrawingWarship.cs
+++ b/Warship/Warship/DrawingWarship.cs
@@ -27,6 +27,11 @@ namespace Warship
_warshipHeight = warshipHeight;
}
+ public void SetColor(Color color)
+ {
+ Warship.BodyColor = color;
+ }
+
public void SetPosition(int x, int y, int width, int height)
{
diff --git a/Warship/Warship/EntityAdvancedWarship.cs b/Warship/Warship/EntityAdvancedWarship.cs
index 527e776..83ea10b 100644
--- a/Warship/Warship/EntityAdvancedWarship.cs
+++ b/Warship/Warship/EntityAdvancedWarship.cs
@@ -8,7 +8,7 @@ namespace Warship
{
internal class EntityAdvancedWarship : EntityWarship
{
- public Color DopColor { get; private set; }
+ public Color DopColor { get; set; }
public bool Helipad { get;private set; }
public bool Antenna { get; private set; }
public bool Missile { get; private set; }
diff --git a/Warship/Warship/EntityWarship.cs b/Warship/Warship/EntityWarship.cs
index b4d0daa..486f2db 100644
--- a/Warship/Warship/EntityWarship.cs
+++ b/Warship/Warship/EntityWarship.cs
@@ -10,7 +10,7 @@ namespace Warship
{
public int Speed { get; private set; }
public float Weight { get; private set; }
- public Color BodyColor { get; private set; }
+ public Color BodyColor { get; set; }
public int Step => (int)(Speed * 2000 / Weight);
public EntityWarship(int speed, float weight, Color bodyColor)
diff --git a/Warship/Warship/FormMapWithSetWarships.cs b/Warship/Warship/FormMapWithSetWarships.cs
index b477fbe..3e56eef 100644
--- a/Warship/Warship/FormMapWithSetWarships.cs
+++ b/Warship/Warship/FormMapWithSetWarships.cs
@@ -51,23 +51,25 @@ namespace Warship
private void ButtonAddWarship_Click(object sender, EventArgs e)
{
- if (listBoxMaps.SelectedIndex==-1)
+ var formWarshipConfig = new FormWarshipConfig();
+ formWarshipConfig.AddEvent(AddWarshipOnMap);
+ formWarshipConfig.Show();
+ }
+ private void AddWarshipOnMap(DrawingWarship drawingWarship)
+ {
+ if (listBoxMaps.SelectedIndex == -1)
{
return;
}
- FormWarship form = new();
- if (form.ShowDialog() == DialogResult.OK)
+ DrawingObjectWarship warship = new(drawingWarship);
+ if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + warship != -1)
{
- DrawingObjectWarship warship = new(form.SelectedWarship);
- if (_mapsCollection[listBoxMaps.SelectedItem?.ToString()??string.Empty]+warship!=-1)
- {
- MessageBox.Show("Объект добавлен");
- pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
- }
- else
- {
- MessageBox.Show("Не удалось добавить объект");
- }
+ MessageBox.Show("Объект добавлен");
+ pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
}
}
diff --git a/Warship/Warship/FormWarshipConfig.Designer.cs b/Warship/Warship/FormWarshipConfig.Designer.cs
new file mode 100644
index 0000000..54b7c0d
--- /dev/null
+++ b/Warship/Warship/FormWarshipConfig.Designer.cs
@@ -0,0 +1,374 @@
+namespace Warship
+{
+ partial class FormWarshipConfig
+ {
+ ///
+ /// 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()
+ {
+ this.GroupBoxConfig = new System.Windows.Forms.GroupBox();
+ this.LabelAdvancedWarship = new System.Windows.Forms.Label();
+ this.LabelBasicWarship = new System.Windows.Forms.Label();
+ this.GroupBoxColors = new System.Windows.Forms.GroupBox();
+ this.PanelSilver = new System.Windows.Forms.Panel();
+ this.PanelRed = new System.Windows.Forms.Panel();
+ this.PanelBlue = new System.Windows.Forms.Panel();
+ this.PanelCyan = new System.Windows.Forms.Panel();
+ this.PanelLime = new System.Windows.Forms.Panel();
+ this.PanelFuchsia = new System.Windows.Forms.Panel();
+ this.PanelYellow = new System.Windows.Forms.Panel();
+ this.PanelOrange = new System.Windows.Forms.Panel();
+ this.CheckBoxMissile = new System.Windows.Forms.CheckBox();
+ this.CheckBoxAntenna = new System.Windows.Forms.CheckBox();
+ this.CheckBoxHelipad = new System.Windows.Forms.CheckBox();
+ this.NumericUpDownWeight = new System.Windows.Forms.NumericUpDown();
+ this.NumericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
+ this.LabelWeight = new System.Windows.Forms.Label();
+ this.LabelSpeed = new System.Windows.Forms.Label();
+ this.PictureBoxWarship = new System.Windows.Forms.PictureBox();
+ this.PanelWarship = new System.Windows.Forms.Panel();
+ this.LabelModifColor = new System.Windows.Forms.Label();
+ this.LabelBodyColor = new System.Windows.Forms.Label();
+ this.ButtomAdd = new System.Windows.Forms.Button();
+ this.ButtonCancel = new System.Windows.Forms.Button();
+ this.GroupBoxConfig.SuspendLayout();
+ this.GroupBoxColors.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.NumericUpDownWeight)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.NumericUpDownSpeed)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.PictureBoxWarship)).BeginInit();
+ this.PanelWarship.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // GroupBoxConfig
+ //
+ this.GroupBoxConfig.Controls.Add(this.LabelAdvancedWarship);
+ this.GroupBoxConfig.Controls.Add(this.LabelBasicWarship);
+ this.GroupBoxConfig.Controls.Add(this.GroupBoxColors);
+ this.GroupBoxConfig.Controls.Add(this.CheckBoxMissile);
+ this.GroupBoxConfig.Controls.Add(this.CheckBoxAntenna);
+ this.GroupBoxConfig.Controls.Add(this.CheckBoxHelipad);
+ this.GroupBoxConfig.Controls.Add(this.NumericUpDownWeight);
+ this.GroupBoxConfig.Controls.Add(this.NumericUpDownSpeed);
+ this.GroupBoxConfig.Controls.Add(this.LabelWeight);
+ this.GroupBoxConfig.Controls.Add(this.LabelSpeed);
+ this.GroupBoxConfig.Location = new System.Drawing.Point(12, 12);
+ this.GroupBoxConfig.Name = "GroupBoxConfig";
+ this.GroupBoxConfig.Size = new System.Drawing.Size(596, 241);
+ this.GroupBoxConfig.TabIndex = 0;
+ this.GroupBoxConfig.TabStop = false;
+ this.GroupBoxConfig.Text = "Параметры: ";
+ //
+ // LabelAdvancedWarship
+ //
+ this.LabelAdvancedWarship.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.LabelAdvancedWarship.Location = new System.Drawing.Point(452, 183);
+ this.LabelAdvancedWarship.Name = "LabelAdvancedWarship";
+ this.LabelAdvancedWarship.Size = new System.Drawing.Size(123, 41);
+ this.LabelAdvancedWarship.TabIndex = 9;
+ this.LabelAdvancedWarship.Text = "Продвинутый корабль";
+ this.LabelAdvancedWarship.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.LabelAdvancedWarship.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelWarship_MouseDown);
+ //
+ // LabelBasicWarship
+ //
+ this.LabelBasicWarship.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.LabelBasicWarship.Location = new System.Drawing.Point(321, 183);
+ this.LabelBasicWarship.Name = "LabelBasicWarship";
+ this.LabelBasicWarship.Size = new System.Drawing.Size(125, 41);
+ this.LabelBasicWarship.TabIndex = 8;
+ this.LabelBasicWarship.Text = "Обычный корабль";
+ this.LabelBasicWarship.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.LabelBasicWarship.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelWarship_MouseDown);
+ //
+ // GroupBoxColors
+ //
+ this.GroupBoxColors.Controls.Add(this.PanelSilver);
+ this.GroupBoxColors.Controls.Add(this.PanelRed);
+ this.GroupBoxColors.Controls.Add(this.PanelBlue);
+ this.GroupBoxColors.Controls.Add(this.PanelCyan);
+ this.GroupBoxColors.Controls.Add(this.PanelLime);
+ this.GroupBoxColors.Controls.Add(this.PanelFuchsia);
+ this.GroupBoxColors.Controls.Add(this.PanelYellow);
+ this.GroupBoxColors.Controls.Add(this.PanelOrange);
+ this.GroupBoxColors.Location = new System.Drawing.Point(321, 24);
+ this.GroupBoxColors.Name = "GroupBoxColors";
+ this.GroupBoxColors.Size = new System.Drawing.Size(254, 144);
+ this.GroupBoxColors.TabIndex = 7;
+ this.GroupBoxColors.TabStop = false;
+ this.GroupBoxColors.Text = "Цвета: ";
+ //
+ // PanelSilver
+ //
+ this.PanelSilver.BackColor = System.Drawing.Color.Silver;
+ this.PanelSilver.Location = new System.Drawing.Point(191, 78);
+ this.PanelSilver.Name = "PanelSilver";
+ this.PanelSilver.Size = new System.Drawing.Size(44, 45);
+ this.PanelSilver.TabIndex = 1;
+ //
+ // PanelRed
+ //
+ this.PanelRed.BackColor = System.Drawing.Color.Red;
+ this.PanelRed.Location = new System.Drawing.Point(136, 78);
+ this.PanelRed.Name = "PanelRed";
+ this.PanelRed.Size = new System.Drawing.Size(46, 45);
+ this.PanelRed.TabIndex = 1;
+ //
+ // PanelBlue
+ //
+ this.PanelBlue.BackColor = System.Drawing.Color.Blue;
+ this.PanelBlue.Location = new System.Drawing.Point(79, 78);
+ this.PanelBlue.Name = "PanelBlue";
+ this.PanelBlue.Size = new System.Drawing.Size(46, 45);
+ this.PanelBlue.TabIndex = 1;
+ //
+ // PanelCyan
+ //
+ this.PanelCyan.BackColor = System.Drawing.Color.Cyan;
+ this.PanelCyan.Location = new System.Drawing.Point(20, 78);
+ this.PanelCyan.Name = "PanelCyan";
+ this.PanelCyan.Size = new System.Drawing.Size(48, 45);
+ this.PanelCyan.TabIndex = 1;
+ //
+ // PanelLime
+ //
+ this.PanelLime.BackColor = System.Drawing.Color.Lime;
+ this.PanelLime.Location = new System.Drawing.Point(191, 24);
+ this.PanelLime.Name = "PanelLime";
+ this.PanelLime.Size = new System.Drawing.Size(44, 45);
+ this.PanelLime.TabIndex = 1;
+ //
+ // PanelFuchsia
+ //
+ this.PanelFuchsia.BackColor = System.Drawing.Color.Fuchsia;
+ this.PanelFuchsia.Location = new System.Drawing.Point(136, 24);
+ this.PanelFuchsia.Name = "PanelFuchsia";
+ this.PanelFuchsia.Size = new System.Drawing.Size(46, 45);
+ this.PanelFuchsia.TabIndex = 1;
+ //
+ // PanelYellow
+ //
+ this.PanelYellow.BackColor = System.Drawing.Color.Yellow;
+ this.PanelYellow.Location = new System.Drawing.Point(79, 24);
+ this.PanelYellow.Name = "PanelYellow";
+ this.PanelYellow.Size = new System.Drawing.Size(46, 45);
+ this.PanelYellow.TabIndex = 1;
+ //
+ // PanelOrange
+ //
+ this.PanelOrange.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
+ this.PanelOrange.Location = new System.Drawing.Point(20, 24);
+ this.PanelOrange.Name = "PanelOrange";
+ this.PanelOrange.Size = new System.Drawing.Size(48, 45);
+ this.PanelOrange.TabIndex = 0;
+ //
+ // CheckBoxMissile
+ //
+ this.CheckBoxMissile.AutoSize = true;
+ this.CheckBoxMissile.Location = new System.Drawing.Point(42, 205);
+ this.CheckBoxMissile.Name = "CheckBoxMissile";
+ this.CheckBoxMissile.Size = new System.Drawing.Size(200, 19);
+ this.CheckBoxMissile.TabIndex = 6;
+ this.CheckBoxMissile.Text = "Признак наличия боевых ракет";
+ this.CheckBoxMissile.UseVisualStyleBackColor = true;
+ //
+ // CheckBoxAntenna
+ //
+ this.CheckBoxAntenna.AutoSize = true;
+ this.CheckBoxAntenna.Location = new System.Drawing.Point(42, 168);
+ this.CheckBoxAntenna.Name = "CheckBoxAntenna";
+ this.CheckBoxAntenna.Size = new System.Drawing.Size(173, 19);
+ this.CheckBoxAntenna.TabIndex = 5;
+ this.CheckBoxAntenna.Text = "Признак наличия антенны";
+ this.CheckBoxAntenna.UseVisualStyleBackColor = true;
+ //
+ // CheckBoxHelipad
+ //
+ this.CheckBoxHelipad.AutoSize = true;
+ this.CheckBoxHelipad.Location = new System.Drawing.Point(42, 129);
+ this.CheckBoxHelipad.Name = "CheckBoxHelipad";
+ this.CheckBoxHelipad.Size = new System.Drawing.Size(256, 19);
+ this.CheckBoxHelipad.TabIndex = 4;
+ this.CheckBoxHelipad.Text = "Признак наличия вертолетной площадки";
+ this.CheckBoxHelipad.UseVisualStyleBackColor = true;
+ //
+ // NumericUpDownWeight
+ //
+ this.NumericUpDownWeight.Location = new System.Drawing.Point(113, 78);
+ this.NumericUpDownWeight.Name = "NumericUpDownWeight";
+ this.NumericUpDownWeight.Size = new System.Drawing.Size(120, 23);
+ this.NumericUpDownWeight.TabIndex = 3;
+ this.NumericUpDownWeight.Value = new decimal(new int[] {
+ 100,
+ 0,
+ 0,
+ 0});
+ //
+ // NumericUpDownSpeed
+ //
+ this.NumericUpDownSpeed.Location = new System.Drawing.Point(113, 41);
+ this.NumericUpDownSpeed.Name = "NumericUpDownSpeed";
+ this.NumericUpDownSpeed.Size = new System.Drawing.Size(120, 23);
+ this.NumericUpDownSpeed.TabIndex = 2;
+ this.NumericUpDownSpeed.Value = new decimal(new int[] {
+ 100,
+ 0,
+ 0,
+ 0});
+ //
+ // LabelWeight
+ //
+ this.LabelWeight.AutoSize = true;
+ this.LabelWeight.Location = new System.Drawing.Point(42, 80);
+ this.LabelWeight.Name = "LabelWeight";
+ this.LabelWeight.Size = new System.Drawing.Size(32, 15);
+ this.LabelWeight.TabIndex = 1;
+ this.LabelWeight.Text = "Вес: ";
+ //
+ // LabelSpeed
+ //
+ this.LabelSpeed.AutoSize = true;
+ this.LabelSpeed.Location = new System.Drawing.Point(42, 43);
+ this.LabelSpeed.Name = "LabelSpeed";
+ this.LabelSpeed.Size = new System.Drawing.Size(65, 15);
+ this.LabelSpeed.TabIndex = 0;
+ this.LabelSpeed.Text = "Скорость: ";
+ //
+ // PictureBoxWarship
+ //
+ this.PictureBoxWarship.Location = new System.Drawing.Point(29, 53);
+ this.PictureBoxWarship.Name = "PictureBoxWarship";
+ this.PictureBoxWarship.Size = new System.Drawing.Size(240, 136);
+ this.PictureBoxWarship.TabIndex = 1;
+ this.PictureBoxWarship.TabStop = false;
+ //
+ // PanelWarship
+ //
+ this.PanelWarship.AllowDrop = true;
+ this.PanelWarship.Controls.Add(this.LabelModifColor);
+ this.PanelWarship.Controls.Add(this.LabelBodyColor);
+ this.PanelWarship.Controls.Add(this.PictureBoxWarship);
+ this.PanelWarship.Location = new System.Drawing.Point(621, 20);
+ this.PanelWarship.Name = "PanelWarship";
+ this.PanelWarship.Size = new System.Drawing.Size(298, 197);
+ this.PanelWarship.TabIndex = 2;
+ this.PanelWarship.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelWarship_DragDrop);
+ this.PanelWarship.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelWarship_DragEnter);
+ //
+ // LabelModifColor
+ //
+ this.LabelModifColor.AllowDrop = true;
+ this.LabelModifColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.LabelModifColor.Location = new System.Drawing.Point(153, 8);
+ this.LabelModifColor.Name = "LabelModifColor";
+ this.LabelModifColor.Size = new System.Drawing.Size(116, 38);
+ this.LabelModifColor.TabIndex = 3;
+ this.LabelModifColor.Text = "Цвет модификаций корабля";
+ this.LabelModifColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.LabelModifColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelModifColor_DragDrop);
+ this.LabelModifColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelModifColor_DragEnter);
+ //
+ // LabelBodyColor
+ //
+ this.LabelBodyColor.AllowDrop = true;
+ this.LabelBodyColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.LabelBodyColor.Location = new System.Drawing.Point(29, 8);
+ this.LabelBodyColor.Name = "LabelBodyColor";
+ this.LabelBodyColor.Size = new System.Drawing.Size(118, 38);
+ this.LabelBodyColor.TabIndex = 2;
+ this.LabelBodyColor.Text = "Цвет корпуса корабля";
+ this.LabelBodyColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.LabelBodyColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelBodyColor_DragDrop);
+ this.LabelBodyColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelBodyColor_DragEnter);
+ //
+ // ButtomAdd
+ //
+ this.ButtomAdd.Location = new System.Drawing.Point(685, 227);
+ this.ButtomAdd.Name = "ButtomAdd";
+ this.ButtomAdd.Size = new System.Drawing.Size(83, 27);
+ this.ButtomAdd.TabIndex = 3;
+ this.ButtomAdd.Text = "Добавить";
+ this.ButtomAdd.UseVisualStyleBackColor = true;
+ this.ButtomAdd.Click += new System.EventHandler(this.ButtomAdd_Click);
+ //
+ // ButtonCancel
+ //
+ this.ButtonCancel.Location = new System.Drawing.Point(783, 227);
+ this.ButtonCancel.Name = "ButtonCancel";
+ this.ButtonCancel.Size = new System.Drawing.Size(79, 27);
+ this.ButtonCancel.TabIndex = 4;
+ this.ButtonCancel.Text = "Отмена";
+ this.ButtonCancel.UseVisualStyleBackColor = true;
+ //
+ // FormWarshipConfig
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(935, 266);
+ this.Controls.Add(this.ButtonCancel);
+ this.Controls.Add(this.ButtomAdd);
+ this.Controls.Add(this.PanelWarship);
+ this.Controls.Add(this.GroupBoxConfig);
+ this.Name = "FormWarshipConfig";
+ this.Text = "Создание корабля";
+ this.GroupBoxConfig.ResumeLayout(false);
+ this.GroupBoxConfig.PerformLayout();
+ this.GroupBoxColors.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.NumericUpDownWeight)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.NumericUpDownSpeed)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.PictureBoxWarship)).EndInit();
+ this.PanelWarship.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private GroupBox GroupBoxConfig;
+ private Label LabelAdvancedWarship;
+ private Label LabelBasicWarship;
+ private GroupBox GroupBoxColors;
+ private Panel PanelSilver;
+ private Panel PanelRed;
+ private Panel PanelBlue;
+ private Panel PanelCyan;
+ private Panel PanelLime;
+ private Panel PanelFuchsia;
+ private Panel PanelYellow;
+ private Panel PanelOrange;
+ private CheckBox CheckBoxMissile;
+ private CheckBox CheckBoxAntenna;
+ private CheckBox CheckBoxHelipad;
+ private NumericUpDown NumericUpDownWeight;
+ private NumericUpDown NumericUpDownSpeed;
+ private Label LabelWeight;
+ private Label LabelSpeed;
+ private PictureBox PictureBoxWarship;
+ private Panel PanelWarship;
+ private Label LabelModifColor;
+ private Label LabelBodyColor;
+ private Button ButtomAdd;
+ private Button ButtonCancel;
+ }
+}
\ No newline at end of file
diff --git a/Warship/Warship/FormWarshipConfig.cs b/Warship/Warship/FormWarshipConfig.cs
new file mode 100644
index 0000000..5f69c56
--- /dev/null
+++ b/Warship/Warship/FormWarshipConfig.cs
@@ -0,0 +1,137 @@
+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 Warship
+{
+ public partial class FormWarshipConfig : Form
+ {
+ DrawingWarship _warship = null;
+ private event WarshipDelegate EventAddWarship;
+ public FormWarshipConfig()
+ {
+ 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;
+ PanelSilver.MouseDown += PanelColor_MouseDown;
+ PanelYellow.MouseDown += PanelColor_MouseDown;
+ ButtonCancel.Click += (sender, e) => Close();
+ }
+
+ private void DrawWarship()
+ {
+ Bitmap bmp = new(PictureBoxWarship.Width,PictureBoxWarship.Height);
+ Graphics gr =Graphics.FromImage(bmp);
+ _warship?.SetPosition(5, 5, PictureBoxWarship.Width, PictureBoxWarship.Height);
+ _warship?.DrawTransport(gr);
+ PictureBoxWarship.Image = bmp;
+ }
+
+ public void AddEvent(WarshipDelegate ev)
+ {
+ if (EventAddWarship == null)
+ {
+ EventAddWarship = new WarshipDelegate(ev);
+ }
+ else
+ {
+ EventAddWarship += ev;
+ }
+ }
+
+ private void LabelWarship_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ private void PanelWarship_DragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(DataFormats.Text))
+ {
+ e.Effect=DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+
+ private void PanelWarship_DragDrop(object sender, DragEventArgs e)
+ {
+ switch (e.Data.GetData(DataFormats.Text).ToString())
+ {
+ case "LabelBasicWarship":
+ _warship = new DrawingWarship((int)NumericUpDownSpeed.Value, (int)NumericUpDownWeight.Value, Color.White);
+ break;
+ case "LabelAdvancedWarship":
+ _warship = new DrawingAdvancedWarship((int)NumericUpDownSpeed.Value, (int)NumericUpDownWeight.Value, Color.White, Color.Black, CheckBoxHelipad.Checked, CheckBoxAntenna.Checked, CheckBoxMissile.Checked);
+ break;
+ }
+ DrawWarship();
+ }
+
+ private void PanelColor_MouseDown(object sender,MouseEventArgs e)
+ {
+ (sender as Control).DoDragDrop((sender as Control).BackColor,DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ 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 LabelModifColor_DragEnter(object sender, DragEventArgs e)
+ {
+ if (_warship is DrawingAdvancedWarship)
+ {
+ if (e.Data.GetDataPresent(typeof(Color)))
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+ }
+
+ private void LabelBodyColor_DragDrop(object sender, DragEventArgs e)
+ {
+ Color BodyColor = (Color)e.Data.GetData(typeof(Color));
+ _warship.SetColor(BodyColor);
+ DrawWarship();
+ }
+
+ private void LabelModifColor_DragDrop(object sender, DragEventArgs e)
+ {
+ Color ModifColor = (Color)e.Data.GetData(typeof(Color));
+ if(_warship is DrawingAdvancedWarship AdvancedWarship)
+ {
+ AdvancedWarship.SetModifColor(ModifColor);
+ DrawWarship();
+ }
+ }
+
+ private void ButtomAdd_Click(object sender, EventArgs e)
+ {
+ EventAddWarship?.Invoke(_warship);
+ Close();
+ }
+ }
+}
diff --git a/Warship/Warship/FormWarshipConfig.resx b/Warship/Warship/FormWarshipConfig.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/Warship/Warship/FormWarshipConfig.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/Warship/Warship/WarshipDelegate.cs b/Warship/Warship/WarshipDelegate.cs
new file mode 100644
index 0000000..90ff8a5
--- /dev/null
+++ b/Warship/Warship/WarshipDelegate.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Warship
+{
+ public delegate void WarshipDelegate(DrawingWarship warship);
+}