diff --git a/MotorBoat/MotorBoat/BoatDelegate.cs b/MotorBoat/MotorBoat/BoatDelegate.cs new file mode 100644 index 0000000..873b741 --- /dev/null +++ b/MotorBoat/MotorBoat/BoatDelegate.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorBoat +{ + public delegate void BoatDelegate(DrawningBoat boat); +} diff --git a/MotorBoat/MotorBoat/DrawningBoat.cs b/MotorBoat/MotorBoat/DrawningBoat.cs index 2f072b5..ab4f165 100644 --- a/MotorBoat/MotorBoat/DrawningBoat.cs +++ b/MotorBoat/MotorBoat/DrawningBoat.cs @@ -128,5 +128,9 @@ namespace MotorBoat { return (_startPosX, _startPosY, _startPosX + _boatWidth, _startPosY + _boatHeight); } + public void SetBodyColor(Color color) + { + (Boat as EntityBoat).setColor(color); + } } } diff --git a/MotorBoat/MotorBoat/DrawningMotorBoat.cs b/MotorBoat/MotorBoat/DrawningMotorBoat.cs index 4988ec3..b16a8fe 100644 --- a/MotorBoat/MotorBoat/DrawningMotorBoat.cs +++ b/MotorBoat/MotorBoat/DrawningMotorBoat.cs @@ -89,7 +89,11 @@ namespace MotorBoat }; g.FillPolygon(dopBrush, points); g.DrawPolygon(pen, points); - } - } + } + } + public void SetExtraColor(Color color) + { + (Boat as EntityMotorBoat).DopColor = color; + } } } diff --git a/MotorBoat/MotorBoat/EntityBoat.cs b/MotorBoat/MotorBoat/EntityBoat.cs index 58a4e38..6706ebb 100644 --- a/MotorBoat/MotorBoat/EntityBoat.cs +++ b/MotorBoat/MotorBoat/EntityBoat.cs @@ -20,5 +20,9 @@ namespace MotorBoat Weight = weight <= 0 ? rnd.Next(40, 70) : weight; BodyColor = bodyColor; } + public void setColor(Color color) + { + BodyColor = color; + } } } diff --git a/MotorBoat/MotorBoat/EntityMotorBoat.cs b/MotorBoat/MotorBoat/EntityMotorBoat.cs index e05cd37..b242f98 100644 --- a/MotorBoat/MotorBoat/EntityMotorBoat.cs +++ b/MotorBoat/MotorBoat/EntityMotorBoat.cs @@ -8,7 +8,7 @@ namespace MotorBoat { internal class EntityMotorBoat : EntityBoat { - public Color DopColor { get; private set; } + public Color DopColor { get; set; } public bool BodyKit { get; private set; } public bool Wing { get; private set; } public bool SportLine { get; private set; } diff --git a/MotorBoat/MotorBoat/FormBoatConfig.Designer.cs b/MotorBoat/MotorBoat/FormBoatConfig.Designer.cs new file mode 100644 index 0000000..ea21ed9 --- /dev/null +++ b/MotorBoat/MotorBoat/FormBoatConfig.Designer.cs @@ -0,0 +1,411 @@ +namespace MotorBoat +{ + partial class FormBoatConfig + { + /// + /// 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.groupBox1 = new System.Windows.Forms.GroupBox(); + this.checkBoxBackside = new System.Windows.Forms.CheckBox(); + this.labelHardObject = new System.Windows.Forms.Label(); + this.labelSimpleObject = new System.Windows.Forms.Label(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.panelWhite = new System.Windows.Forms.Panel(); + this.panelYellow = new System.Windows.Forms.Panel(); + this.panelGray = new System.Windows.Forms.Panel(); + this.panelBlue = new System.Windows.Forms.Panel(); + this.panelGreen = new System.Windows.Forms.Panel(); + this.panelPurple = new System.Windows.Forms.Panel(); + this.panelRed = new System.Windows.Forms.Panel(); + this.panelBlack = new System.Windows.Forms.Panel(); + this.checkBoxSide = new System.Windows.Forms.CheckBox(); + this.checkBoxNose = new System.Windows.Forms.CheckBox(); + this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.pictureBoxObject = new System.Windows.Forms.PictureBox(); + this.panelobject = new System.Windows.Forms.Panel(); + this.LabelDopColor = new System.Windows.Forms.Label(); + this.LabelBaseColor = new System.Windows.Forms.Label(); + this.buttonOk = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit(); + this.panelobject.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.checkBoxBackside); + this.groupBox1.Controls.Add(this.labelHardObject); + this.groupBox1.Controls.Add(this.labelSimpleObject); + this.groupBox1.Controls.Add(this.groupBox2); + this.groupBox1.Controls.Add(this.checkBoxSide); + this.groupBox1.Controls.Add(this.checkBoxNose); + this.groupBox1.Controls.Add(this.numericUpDownWeight); + this.groupBox1.Controls.Add(this.numericUpDownSpeed); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Location = new System.Drawing.Point(12, 12); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(470, 201); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Параметры"; + // + // checkBoxBackside + // + this.checkBoxBackside.AutoSize = true; + this.checkBoxBackside.Location = new System.Drawing.Point(6, 170); + this.checkBoxBackside.Name = "checkBoxBackside"; + this.checkBoxBackside.Size = new System.Drawing.Size(115, 19); + this.checkBoxBackside.TabIndex = 10; + this.checkBoxBackside.Text = "Боковые стойки"; + this.checkBoxBackside.UseVisualStyleBackColor = true; + // + // labelHardObject + // + this.labelHardObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelHardObject.Location = new System.Drawing.Point(334, 166); + this.labelHardObject.Name = "labelHardObject"; + this.labelHardObject.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.labelHardObject.Size = new System.Drawing.Size(100, 23); + this.labelHardObject.TabIndex = 9; + this.labelHardObject.Text = "Продвинутый"; + this.labelHardObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelHardObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelSimpleObject_MouseDown); + // + // labelSimpleObject + // + this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelSimpleObject.Location = new System.Drawing.Point(228, 166); + this.labelSimpleObject.Name = "labelSimpleObject"; + this.labelSimpleObject.Size = new System.Drawing.Size(100, 23); + this.labelSimpleObject.TabIndex = 8; + this.labelSimpleObject.Text = "Простой"; + this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelSimpleObject_MouseDown); + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.panelWhite); + this.groupBox2.Controls.Add(this.panelYellow); + this.groupBox2.Controls.Add(this.panelGray); + this.groupBox2.Controls.Add(this.panelBlue); + this.groupBox2.Controls.Add(this.panelGreen); + this.groupBox2.Controls.Add(this.panelPurple); + this.groupBox2.Controls.Add(this.panelRed); + this.groupBox2.Controls.Add(this.panelBlack); + this.groupBox2.Location = new System.Drawing.Point(216, 22); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(228, 130); + this.groupBox2.TabIndex = 7; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Цвета"; + // + // panelWhite + // + this.panelWhite.AllowDrop = true; + this.panelWhite.BackColor = System.Drawing.Color.White; + this.panelWhite.Location = new System.Drawing.Point(167, 78); + this.panelWhite.Name = "panelWhite"; + this.panelWhite.Size = new System.Drawing.Size(43, 44); + this.panelWhite.TabIndex = 3; + this.panelWhite.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelYellow + // + this.panelYellow.AllowDrop = true; + this.panelYellow.BackColor = System.Drawing.Color.Yellow; + this.panelYellow.Location = new System.Drawing.Point(167, 28); + this.panelYellow.Name = "panelYellow"; + this.panelYellow.Size = new System.Drawing.Size(43, 44); + this.panelYellow.TabIndex = 1; + this.panelYellow.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelGray + // + this.panelGray.AllowDrop = true; + this.panelGray.BackColor = System.Drawing.Color.Gray; + this.panelGray.Location = new System.Drawing.Point(118, 78); + this.panelGray.Name = "panelGray"; + this.panelGray.Size = new System.Drawing.Size(43, 44); + this.panelGray.TabIndex = 4; + this.panelGray.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelBlue + // + this.panelBlue.AllowDrop = true; + this.panelBlue.BackColor = System.Drawing.Color.Blue; + this.panelBlue.Location = new System.Drawing.Point(69, 78); + this.panelBlue.Name = "panelBlue"; + this.panelBlue.Size = new System.Drawing.Size(43, 44); + this.panelBlue.TabIndex = 5; + this.panelBlue.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelGreen + // + this.panelGreen.AllowDrop = true; + this.panelGreen.BackColor = System.Drawing.Color.Green; + this.panelGreen.Location = new System.Drawing.Point(118, 28); + this.panelGreen.Name = "panelGreen"; + this.panelGreen.Size = new System.Drawing.Size(43, 44); + this.panelGreen.TabIndex = 1; + this.panelGreen.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelPurple + // + this.panelPurple.AllowDrop = true; + this.panelPurple.BackColor = System.Drawing.Color.Purple; + this.panelPurple.Location = new System.Drawing.Point(20, 78); + this.panelPurple.Name = "panelPurple"; + this.panelPurple.Size = new System.Drawing.Size(43, 44); + this.panelPurple.TabIndex = 2; + this.panelPurple.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelRed + // + this.panelRed.AllowDrop = true; + this.panelRed.BackColor = System.Drawing.Color.Red; + this.panelRed.Location = new System.Drawing.Point(69, 28); + this.panelRed.Name = "panelRed"; + this.panelRed.Size = new System.Drawing.Size(43, 44); + this.panelRed.TabIndex = 1; + this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelBlack + // + this.panelBlack.AllowDrop = true; + this.panelBlack.BackColor = System.Drawing.Color.Black; + this.panelBlack.Location = new System.Drawing.Point(20, 28); + this.panelBlack.Name = "panelBlack"; + this.panelBlack.Size = new System.Drawing.Size(43, 44); + this.panelBlack.TabIndex = 0; + this.panelBlack.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // checkBoxSide + // + this.checkBoxSide.AutoSize = true; + this.checkBoxSide.Location = new System.Drawing.Point(6, 145); + this.checkBoxSide.Name = "checkBoxSide"; + this.checkBoxSide.Size = new System.Drawing.Size(92, 19); + this.checkBoxSide.TabIndex = 5; + this.checkBoxSide.Text = "Острый нос"; + this.checkBoxSide.UseVisualStyleBackColor = true; + // + // checkBoxNose + // + this.checkBoxNose.AutoSize = true; + this.checkBoxNose.Location = new System.Drawing.Point(6, 120); + this.checkBoxNose.Name = "checkBoxNose"; + this.checkBoxNose.Size = new System.Drawing.Size(116, 19); + this.checkBoxNose.TabIndex = 4; + this.checkBoxNose.Text = "Усеченные бока"; + this.checkBoxNose.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + this.numericUpDownWeight.Location = new System.Drawing.Point(74, 71); + this.numericUpDownWeight.Maximum = new decimal(new int[] { + 70, + 0, + 0, + 0}); + this.numericUpDownWeight.Minimum = new decimal(new int[] { + 40, + 0, + 0, + 0}); + this.numericUpDownWeight.Name = "numericUpDownWeight"; + this.numericUpDownWeight.Size = new System.Drawing.Size(120, 23); + this.numericUpDownWeight.TabIndex = 3; + this.numericUpDownWeight.Value = new decimal(new int[] { + 50, + 0, + 0, + 0}); + // + // numericUpDownSpeed + // + this.numericUpDownSpeed.Location = new System.Drawing.Point(74, 42); + this.numericUpDownSpeed.Maximum = new decimal(new int[] { + 150, + 0, + 0, + 0}); + this.numericUpDownSpeed.Minimum = new decimal(new int[] { + 50, + 0, + 0, + 0}); + 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}); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(6, 73); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(29, 15); + this.label2.TabIndex = 1; + this.label2.Text = "Вес:"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(6, 44); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(62, 15); + this.label1.TabIndex = 0; + this.label1.Text = "Скорость:"; + // + // pictureBoxObject + // + this.pictureBoxObject.Location = new System.Drawing.Point(12, 42); + this.pictureBoxObject.Name = "pictureBoxObject"; + this.pictureBoxObject.Size = new System.Drawing.Size(212, 122); + this.pictureBoxObject.TabIndex = 1; + this.pictureBoxObject.TabStop = false; + // + // panelobject + // + this.panelobject.AllowDrop = true; + this.panelobject.Controls.Add(this.LabelDopColor); + this.panelobject.Controls.Add(this.LabelBaseColor); + this.panelobject.Controls.Add(this.pictureBoxObject); + this.panelobject.Location = new System.Drawing.Point(525, 12); + this.panelobject.Name = "panelobject"; + this.panelobject.Size = new System.Drawing.Size(238, 172); + this.panelobject.TabIndex = 10; + this.panelobject.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelobject_DragDrop); + this.panelobject.DragEnter += new System.Windows.Forms.DragEventHandler(this.panelobject_DragEnter); + // + // LabelDopColor + // + this.LabelDopColor.AllowDrop = true; + this.LabelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.LabelDopColor.Location = new System.Drawing.Point(124, 9); + this.LabelDopColor.Name = "LabelDopColor"; + this.LabelDopColor.Size = new System.Drawing.Size(100, 23); + this.LabelDopColor.TabIndex = 3; + this.LabelDopColor.Text = "Доп.цвет"; + this.LabelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.LabelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragDrop); + this.LabelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragEnter); + // + // LabelBaseColor + // + this.LabelBaseColor.AllowDrop = true; + this.LabelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.LabelBaseColor.Location = new System.Drawing.Point(12, 9); + this.LabelBaseColor.Name = "LabelBaseColor"; + this.LabelBaseColor.Size = new System.Drawing.Size(100, 23); + this.LabelBaseColor.TabIndex = 2; + this.LabelBaseColor.Text = "Цвет"; + this.LabelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.LabelBaseColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragDrop); + this.LabelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragEnter); + // + // buttonOk + // + this.buttonOk.Location = new System.Drawing.Point(537, 190); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 11; + this.buttonOk.Text = "Добавить"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(674, 190); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(75, 23); + this.button2.TabIndex = 12; + this.button2.Text = "Отмена"; + this.button2.UseVisualStyleBackColor = true; + // + // FormBoatConfig + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(783, 221); + this.Controls.Add(this.button2); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.panelobject); + this.Controls.Add(this.groupBox1); + this.Name = "FormBoatConfig"; + this.Text = "FormLocomotiveConfig"; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit(); + this.panelobject.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private GroupBox groupBox1; + private Label labelHardObject; + private Label labelSimpleObject; + private GroupBox groupBox2; + private Panel panelWhite; + private Panel panelYellow; + private Panel panelGray; + private Panel panelBlue; + private Panel panelGreen; + private Panel panelPurple; + private Panel panelRed; + private Panel panelBlack; + private CheckBox checkBoxSide; + private CheckBox checkBoxNose; + private NumericUpDown numericUpDownWeight; + private NumericUpDown numericUpDownSpeed; + private Label label2; + private Label label1; + private PictureBox pictureBoxObject; + private Panel panelobject; + private Label LabelDopColor; + private Label LabelBaseColor; + private Button buttonOk; + private Button button2; + private CheckBox checkBoxBackside; + } +} \ No newline at end of file diff --git a/MotorBoat/MotorBoat/FormBoatConfig.cs b/MotorBoat/MotorBoat/FormBoatConfig.cs new file mode 100644 index 0000000..88844a5 --- /dev/null +++ b/MotorBoat/MotorBoat/FormBoatConfig.cs @@ -0,0 +1,139 @@ +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 MotorBoat +{ + public partial class FormBoatConfig : Form + { + private event BoatDelegate EventAddBoat; + DrawningBoat _boat = null; + public FormBoatConfig() + { + 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; + } + + public void AddEvent(BoatDelegate ev) + { + if (EventAddBoat == null) + { + EventAddBoat = new BoatDelegate(ev); + } + else + { + EventAddBoat += ev; + } + } + + private void DrawBoat() + { + Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); + _boat?.SetPosition(5, 135, pictureBoxObject.Width, + pictureBoxObject.Height); + _boat?.DrawTransport(gr); + pictureBoxObject.Image = bmp; + } + + private void labelSimpleObject_MouseDown(object sender, MouseEventArgs e) + { + (sender as Label).DoDragDrop((sender as Label).Name,DragDropEffects.Move | DragDropEffects.Copy); + + } + + private void panelobject_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.Text)) + { + 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": + { + _boat = new DrawningBoat((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White); + } + break; + case "labelHardObject": + { + _boat = new DrawningMotorBoat((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxNose.Checked, checkBoxSide.Checked, checkBoxBackside.Checked); + } + break; + } + DrawBoat(); + } + + private void buttonOk_Click(object sender, EventArgs e) + { + EventAddBoat?.Invoke(_boat); + Close(); + } + + private void PanelColor_MouseDown(object sender, MouseEventArgs e) + { + (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy); + } + + private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) + { + _boat.SetBodyColor((Color)e.Data.GetData(typeof(Color))); + DrawBoat(); + } + + private void LabelDopColor_DragDrop(object sender, DragEventArgs e) + { + if(_boat is not DrawningMotorBoat MotorBoat) + { + return; + } + MotorBoat.SetExtraColor((Color)e.Data.GetData(typeof(Color))); + DrawBoat(); + } + + private void LabelBaseColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + private void LabelDopColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + } +} diff --git a/MotorBoat/MotorBoat/FormBoatConfig.resx b/MotorBoat/MotorBoat/FormBoatConfig.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/MotorBoat/MotorBoat/FormBoatConfig.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/MotorBoat/MotorBoat/FormMapWithSetBoats.Designer.cs b/MotorBoat/MotorBoat/FormMapWithSetBoats.Designer.cs index 1d9d8ba..44e533b 100644 --- a/MotorBoat/MotorBoat/FormMapWithSetBoats.Designer.cs +++ b/MotorBoat/MotorBoat/FormMapWithSetBoats.Designer.cs @@ -237,7 +237,7 @@ this.Controls.Add(this.pictureBox); this.Controls.Add(this.groupBoxTools); this.Name = "FormMapWithSetBoats"; - this.Text = "FormMapWithSetBoats"; + this.Text = "Лодка"; this.groupBoxTools.ResumeLayout(false); this.groupBoxTools.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); diff --git a/MotorBoat/MotorBoat/FormMapWithSetBoats.cs b/MotorBoat/MotorBoat/FormMapWithSetBoats.cs index 00ef65f..757820c 100644 --- a/MotorBoat/MotorBoat/FormMapWithSetBoats.cs +++ b/MotorBoat/MotorBoat/FormMapWithSetBoats.cs @@ -12,6 +12,9 @@ namespace MotorBoat { public partial class FormMapWithSetBoats : Form { + /// + /// Объект от класса карты с набором объектов + /// private MapWithSetBoatsGeneric _mapShipCollectionGeneric; private readonly Dictionary _mapDict = new() { @@ -20,6 +23,9 @@ namespace MotorBoat {"Морская карта",new SeaMap() } }; private readonly MapsCollection _mapsCollection; + /// + /// Конструктор + /// public FormMapWithSetBoats() { InitializeComponent(); @@ -36,9 +42,8 @@ namespace MotorBoat int index = ListBoxMaps.SelectedIndex; ListBoxMaps.Items.Clear(); - for (int i = 0; i < _mapsCollection.Keys.Count; i++) + foreach (var list in _mapsCollection.Keys) { - string? list = _mapsCollection.Keys[i]; ListBoxMaps.Items.Add(list); } @@ -78,30 +83,48 @@ namespace MotorBoat _mapShipCollectionGeneric = null; } } + /// + /// Выбор карты + /// + /// + /// + + /// + /// Добавление объекта + /// + /// + /// private void ButtonAddBoat_Click(object sender, EventArgs e) + { + var FormBoatConfig = new FormBoatConfig(); + FormBoatConfig.AddEvent(new(AddBoat)); + FormBoatConfig.Show(); + + } + + public void AddBoat(DrawningBoat boat) { if (ListBoxMaps.SelectedIndex == -1) { return; } - FormBoat form = new(); - if (form.ShowDialog() == DialogResult.OK) + + if (_mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawningObjectBoat(boat) != -1) { - DrawningObjectBoat boat = new(form.SelectedBoat); - if (_mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? - string.Empty] + boat !=-1) - { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = - _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } + MessageBox.Show("Object is added"); + pictureBox.Image = _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + } + else + { + MessageBox.Show("Unable to add object"); } } + /// + /// Удаление объекта + /// + /// + /// private void ButtonRemoveBoat_Click(object sender, EventArgs e) { if (ListBoxMaps.SelectedIndex == -1) @@ -127,6 +150,11 @@ namespace MotorBoat MessageBox.Show("Не удалось удалить объект"); } } + /// + /// Вывод набора + /// + /// + /// private void ButtonShowStorage_Click(object sender, EventArgs e) { if (ListBoxMaps.SelectedIndex == -1) @@ -135,6 +163,11 @@ namespace MotorBoat } pictureBox.Image = _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } + /// + /// Вывод карты + /// + /// + /// private void ButtonShowOnMap_Click(object sender, EventArgs e) { if (ListBoxMaps.SelectedIndex == -1) @@ -143,6 +176,11 @@ namespace MotorBoat } pictureBox.Image = _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap(); } + /// + /// Перемещение + /// + /// + /// private void ButtonMove_Click(object sender, EventArgs e) { if (ListBoxMaps.SelectedIndex == -1)