This commit is contained in:
Максим Егоров 2024-05-05 22:45:24 +03:00
parent e0a52ea60c
commit 1d71499845
4 changed files with 205 additions and 168 deletions

View File

@ -28,142 +28,138 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
pictureBoxCollection = new PictureBox(); this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
panelTools = new Panel(); this.panelTools = new System.Windows.Forms.Panel();
panelCollection = new Panel(); this.panelCollection = new System.Windows.Forms.Panel();
buttonDelObject = new Button(); this.buttonDelObject = new System.Windows.Forms.Button();
listBoxStorages = new ListBox(); this.listBoxStorages = new System.Windows.Forms.ListBox();
buttonAddObject = new Button(); this.buttonAddObject = new System.Windows.Forms.Button();
textBoxStorageName = new TextBox(); this.textBoxStorageName = new System.Windows.Forms.TextBox();
maskedTextBoxNumber = new MaskedTextBox(); this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox();
buttonRefreshCollection = new Button(); this.buttonRefreshCollection = new System.Windows.Forms.Button();
buttonRemoveBoat = new Button(); this.buttonRemoveBoat = new System.Windows.Forms.Button();
buttonAddBoat = new Button(); this.buttonAddBoat = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit(); this.menuStrip = new System.Windows.Forms.MenuStrip();
panelTools.SuspendLayout(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
panelCollection.SuspendLayout(); this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
SuspendLayout(); this.SaveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
this.panelTools.SuspendLayout();
this.panelCollection.SuspendLayout();
this.menuStrip.SuspendLayout();
this.SuspendLayout();
// //
// pictureBoxCollection // pictureBoxCollection
// //
pictureBoxCollection.Location = new Point(0, 0); this.pictureBoxCollection.Location = new System.Drawing.Point(0, 0);
pictureBoxCollection.Margin = new Padding(3, 2, 3, 2); this.pictureBoxCollection.Name = "pictureBoxCollection";
pictureBoxCollection.Name = "pictureBoxCollection"; this.pictureBoxCollection.Size = new System.Drawing.Size(750, 600);
pictureBoxCollection.Size = new Size(750, 600); this.pictureBoxCollection.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
pictureBoxCollection.SizeMode = PictureBoxSizeMode.AutoSize; this.pictureBoxCollection.TabIndex = 0;
pictureBoxCollection.TabIndex = 0; this.pictureBoxCollection.TabStop = false;
pictureBoxCollection.TabStop = false;
pictureBoxCollection.Click += pictureBoxCollection_Click;
// //
// panelTools // panelTools
// //
panelTools.BackColor = SystemColors.ScrollBar; this.panelTools.BackColor = System.Drawing.SystemColors.ScrollBar;
panelTools.Controls.Add(panelCollection); this.panelTools.Controls.Add(this.panelCollection);
panelTools.Controls.Add(maskedTextBoxNumber); this.panelTools.Controls.Add(this.maskedTextBoxNumber);
panelTools.Controls.Add(buttonRefreshCollection); this.panelTools.Controls.Add(this.buttonRefreshCollection);
panelTools.Controls.Add(buttonRemoveBoat); this.panelTools.Controls.Add(this.buttonRemoveBoat);
panelTools.Controls.Add(buttonAddBoat); this.panelTools.Controls.Add(this.buttonAddBoat);
panelTools.Location = new Point(639, 20); this.panelTools.Controls.Add(this.menuStrip);
panelTools.Margin = new Padding(3, 2, 3, 2); this.panelTools.Location = new System.Drawing.Point(756, 0);
panelTools.Name = "panelTools"; this.panelTools.Name = "panelTools";
panelTools.Size = new Size(183, 441); this.panelTools.Size = new System.Drawing.Size(209, 722);
panelTools.TabIndex = 1; this.panelTools.TabIndex = 1;
panelTools.Paint += panelTools_Paint;
// //
// panelCollection // panelCollection
// //
panelCollection.BackColor = SystemColors.AppWorkspace; this.panelCollection.BackColor = System.Drawing.SystemColors.AppWorkspace;
panelCollection.Controls.Add(buttonDelObject); this.panelCollection.Controls.Add(this.buttonDelObject);
panelCollection.Controls.Add(listBoxStorages); this.panelCollection.Controls.Add(this.listBoxStorages);
panelCollection.Controls.Add(buttonAddObject); this.panelCollection.Controls.Add(this.buttonAddObject);
panelCollection.Controls.Add(textBoxStorageName); this.panelCollection.Controls.Add(this.textBoxStorageName);
panelCollection.Location = new Point(14, 11); this.panelCollection.Location = new System.Drawing.Point(20, 166);
panelCollection.Margin = new Padding(3, 2, 3, 2); this.panelCollection.Name = "panelCollection";
panelCollection.Name = "panelCollection"; this.panelCollection.Size = new System.Drawing.Size(181, 287);
panelCollection.Size = new Size(158, 215); this.panelCollection.TabIndex = 4;
panelCollection.TabIndex = 4;
// //
// buttonDelObject // buttonDelObject
// //
buttonDelObject.Location = new Point(10, 172); this.buttonDelObject.Location = new System.Drawing.Point(12, 230);
buttonDelObject.Margin = new Padding(3, 2, 3, 2); this.buttonDelObject.Name = "buttonDelObject";
buttonDelObject.Name = "buttonDelObject"; this.buttonDelObject.Size = new System.Drawing.Size(154, 34);
buttonDelObject.Size = new Size(135, 26); this.buttonDelObject.TabIndex = 5;
buttonDelObject.TabIndex = 5; this.buttonDelObject.Text = "Удалить набор";
buttonDelObject.Text = "Удалить набор"; this.buttonDelObject.UseVisualStyleBackColor = true;
buttonDelObject.UseVisualStyleBackColor = true; this.buttonDelObject.Click += new System.EventHandler(this.buttonDelObject_Click);
buttonDelObject.Click += buttonDelObject_Click;
// //
// listBoxStorages // listBoxStorages
// //
listBoxStorages.FormattingEnabled = true; this.listBoxStorages.FormattingEnabled = true;
listBoxStorages.ItemHeight = 15; this.listBoxStorages.ItemHeight = 20;
listBoxStorages.Location = new Point(10, 76); this.listBoxStorages.Location = new System.Drawing.Point(12, 102);
listBoxStorages.Margin = new Padding(3, 2, 3, 2); this.listBoxStorages.Name = "listBoxStorages";
listBoxStorages.Name = "listBoxStorages"; this.listBoxStorages.Size = new System.Drawing.Size(154, 104);
listBoxStorages.Size = new Size(135, 79); this.listBoxStorages.TabIndex = 6;
listBoxStorages.TabIndex = 6; this.listBoxStorages.SelectedIndexChanged += new System.EventHandler(this.ListBoxObjects_SelectedIndexChanged);
listBoxStorages.SelectedIndexChanged += ListBoxObjects_SelectedIndexChanged;
// //
// buttonAddObject // buttonAddObject
// //
buttonAddObject.Location = new Point(10, 46); this.buttonAddObject.Location = new System.Drawing.Point(12, 62);
buttonAddObject.Margin = new Padding(3, 2, 3, 2); this.buttonAddObject.Name = "buttonAddObject";
buttonAddObject.Name = "buttonAddObject"; this.buttonAddObject.Size = new System.Drawing.Size(154, 34);
buttonAddObject.Size = new Size(135, 26); this.buttonAddObject.TabIndex = 5;
buttonAddObject.TabIndex = 5; this.buttonAddObject.Text = "Добавить набор";
buttonAddObject.Text = "Добавить набор"; this.buttonAddObject.UseVisualStyleBackColor = true;
buttonAddObject.UseVisualStyleBackColor = true; this.buttonAddObject.Click += new System.EventHandler(this.buttonAddObject_Click);
buttonAddObject.Click += buttonAddObject_Click;
// //
// textBoxStorageName // textBoxStorageName
// //
textBoxStorageName.Location = new Point(25, 22); this.textBoxStorageName.Location = new System.Drawing.Point(29, 29);
textBoxStorageName.Margin = new Padding(3, 2, 3, 2); this.textBoxStorageName.Name = "textBoxStorageName";
textBoxStorageName.Name = "textBoxStorageName"; this.textBoxStorageName.Size = new System.Drawing.Size(125, 27);
textBoxStorageName.Size = new Size(110, 23); this.textBoxStorageName.TabIndex = 0;
textBoxStorageName.TabIndex = 0;
// //
// maskedTextBoxNumber // maskedTextBoxNumber
// //
maskedTextBoxNumber.Location = new Point(39, 312); this.maskedTextBoxNumber.Location = new System.Drawing.Point(49, 567);
maskedTextBoxNumber.Margin = new Padding(3, 2, 3, 2); this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
maskedTextBoxNumber.Name = "maskedTextBoxNumber"; this.maskedTextBoxNumber.Size = new System.Drawing.Size(125, 27);
maskedTextBoxNumber.Size = new Size(110, 23); this.maskedTextBoxNumber.TabIndex = 3;
maskedTextBoxNumber.TabIndex = 3;
// //
// buttonRefreshCollection // buttonRefreshCollection
// //
buttonRefreshCollection.Location = new Point(14, 398); this.buttonRefreshCollection.Location = new System.Drawing.Point(20, 682);
buttonRefreshCollection.Margin = new Padding(3, 2, 3, 2); this.buttonRefreshCollection.Name = "buttonRefreshCollection";
buttonRefreshCollection.Name = "buttonRefreshCollection"; this.buttonRefreshCollection.Size = new System.Drawing.Size(180, 34);
buttonRefreshCollection.Size = new Size(158, 26); this.buttonRefreshCollection.TabIndex = 2;
buttonRefreshCollection.TabIndex = 2; this.buttonRefreshCollection.Text = "Обновить коллекцию";
buttonRefreshCollection.Text = "Обновить коллекцию"; this.buttonRefreshCollection.UseVisualStyleBackColor = true;
buttonRefreshCollection.UseVisualStyleBackColor = true; this.buttonRefreshCollection.Click += new System.EventHandler(this.buttonRefreshCollection_Click);
buttonRefreshCollection.Click += buttonRefreshCollection_Click;
// //
// buttonRemoveBoat // buttonRemoveBoat
// //
buttonRemoveBoat.Location = new Point(15, 352); this.buttonRemoveBoat.Location = new System.Drawing.Point(21, 620);
buttonRemoveBoat.Margin = new Padding(3, 2, 3, 2); this.buttonRemoveBoat.Name = "buttonRemoveBoat";
buttonRemoveBoat.Name = "buttonRemoveBoat"; this.buttonRemoveBoat.Size = new System.Drawing.Size(180, 34);
buttonRemoveBoat.Size = new Size(158, 26); this.buttonRemoveBoat.TabIndex = 1;
buttonRemoveBoat.TabIndex = 1; this.buttonRemoveBoat.Text = "Удалить лодку";
buttonRemoveBoat.Text = "Удалить лодку"; this.buttonRemoveBoat.UseVisualStyleBackColor = true;
buttonRemoveBoat.UseVisualStyleBackColor = true; this.buttonRemoveBoat.Click += new System.EventHandler(this.buttonRemoveBoat_Click);
buttonRemoveBoat.Click += buttonRemoveBoat_Click;
// //
// buttonAddBoat // buttonAddBoat
// //
buttonAddBoat.Location = new Point(14, 254); this.buttonAddBoat.Location = new System.Drawing.Point(20, 490);
buttonAddBoat.Margin = new Padding(3, 2, 3, 2); this.buttonAddBoat.Name = "buttonAddBoat";
buttonAddBoat.Name = "buttonAddBoat"; this.buttonAddBoat.Size = new System.Drawing.Size(180, 34);
buttonAddBoat.Size = new Size(158, 26); this.buttonAddBoat.TabIndex = 0;
buttonAddBoat.TabIndex = 0; this.buttonAddBoat.Text = "Добавить лодку";
buttonAddBoat.Text = "Добавить лодку"; this.buttonAddBoat.UseVisualStyleBackColor = true;
buttonAddBoat.UseVisualStyleBackColor = true; this.buttonAddBoat.Click += new System.EventHandler(this.buttonAddBoat_Click);
buttonAddBoat.Click += buttonAddBoat_Click;
// //
// menuStrip // menuStrip
// //
@ -215,21 +211,24 @@
// //
// FormBoatCollection // FormBoatCollection
// //
AutoScaleDimensions = new SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
ClientSize = new Size(834, 546); this.ClientSize = new System.Drawing.Size(969, 728);
Controls.Add(panelTools); this.Controls.Add(this.panelTools);
Controls.Add(pictureBoxCollection); this.Controls.Add(this.pictureBoxCollection);
Margin = new Padding(3, 2, 3, 2); this.MainMenuStrip = this.menuStrip;
Name = "FormBoatCollection"; this.Name = "FormBoatCollection";
Text = "FormBoatCollection"; this.Text = "FormBoatCollection";
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
panelTools.ResumeLayout(false); this.panelTools.ResumeLayout(false);
panelTools.PerformLayout(); this.panelTools.PerformLayout();
panelCollection.ResumeLayout(false); this.panelCollection.ResumeLayout(false);
panelCollection.PerformLayout(); this.panelCollection.PerformLayout();
ResumeLayout(false); this.menuStrip.ResumeLayout(false);
PerformLayout(); this.menuStrip.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
} }
#endregion #endregion
@ -252,7 +251,5 @@
private ToolStripMenuItem LoadToolStripMenuItem; private ToolStripMenuItem LoadToolStripMenuItem;
private OpenFileDialog openFileDialog; private OpenFileDialog openFileDialog;
private SaveFileDialog saveFileDialog; private SaveFileDialog saveFileDialog;
private EventHandler SaveToolStripMenuItem_Click;
private EventHandler LoadToolStripMenuItem_Click;
} }
} }

View File

@ -48,6 +48,23 @@ namespace Sailboat
} }
private void buttonAddBoat_Click(object sender, EventArgs e) private void buttonAddBoat_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
var formBoatConfig = new FormBoatConfig();
formBoatConfig.AddEvent(AddBoat);
formBoatConfig.Show();
}
private void AddBoat(DrawingBoat drawingBoat)
{ {
if (listBoxStorages.SelectedIndex == -1) if (listBoxStorages.SelectedIndex == -1)
{ {
@ -59,11 +76,8 @@ namespace Sailboat
{ {
return; return;
} }
FormBoatConfig form = new FormBoatConfig(pictureBoxCollection.Width, pictureBoxCollection.Height);
form.Show(); if (obj + drawingBoat)
Action<DrawingBoat>? boatDelegate = new((plane) =>
{
if (obj + plane)
{ {
MessageBox.Show("Объект добавлен"); MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowBoats(); pictureBoxCollection.Image = obj.ShowBoats();
@ -72,8 +86,6 @@ namespace Sailboat
{ {
MessageBox.Show("Не удалось добавить объект"); MessageBox.Show("Не удалось добавить объект");
} }
});
form.AddEvent(boatDelegate);
} }
private void buttonRemoveBoat_Click(object sender, EventArgs e) private void buttonRemoveBoat_Click(object sender, EventArgs e)
@ -146,7 +158,7 @@ namespace Sailboat
{ {
return; return;
} }
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) if (MessageBox.Show($"Удалить объект { listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{ {
_storage.DelSet(listBoxStorages.SelectedItem.ToString() _storage.DelSet(listBoxStorages.SelectedItem.ToString()
?? string.Empty); ?? string.Empty);
@ -154,14 +166,40 @@ namespace Sailboat
} }
} }
private void panelTools_Paint(object sender, PaintEventArgs e) private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
{ {
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
if (_storage.SaveData(saveFileDialog.FileName))
{
MessageBox.Show("Сохранение прошло успешно",
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Не сохранилось", "Результат",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
} }
private void pictureBoxCollection_Click(object sender, EventArgs e) private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
{ {
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
if (_storage.LoadData(openFileDialog.FileName))
{
MessageBox.Show("Загрузка прошла успешно",
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
else
{
MessageBox.Show("Не загрузилось", "Результат",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
ReloadObjects();
}
} }
} }

View File

@ -176,7 +176,7 @@
this.labelModifiedObject.TabIndex = 8; this.labelModifiedObject.TabIndex = 8;
this.labelModifiedObject.Text = "Продвинутый"; this.labelModifiedObject.Text = "Продвинутый";
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LableObject_MouseDown); this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
// //
// labelSimpleObject // labelSimpleObject
// //
@ -187,7 +187,7 @@
this.labelSimpleObject.TabIndex = 7; this.labelSimpleObject.TabIndex = 7;
this.labelSimpleObject.Text = "Простой"; this.labelSimpleObject.Text = "Простой";
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LableObject_MouseDown); this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
// //
// checkBoxSail // checkBoxSail
// //
@ -326,7 +326,7 @@
this.buttonOk.TabIndex = 3; this.buttonOk.TabIndex = 3;
this.buttonOk.Text = "Добавить"; this.buttonOk.Text = "Добавить";
this.buttonOk.UseVisualStyleBackColor = true; this.buttonOk.UseVisualStyleBackColor = true;
this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click); this.buttonOk.Click += new System.EventHandler(this.ButtonOk_Click);
// //
// buttonCancel // buttonCancel
// //

View File

@ -1,6 +1,4 @@
using Sailboat.DrawingObjects; using System;
using Sailboat.Entities;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
@ -10,18 +8,19 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using Sailboat.DrawingObjects;
using Sailboat.Generics;
using Sailboat.MovementStrategy;
using Sailboat.Entities;
namespace Sailboat namespace Sailboat
{ {
public partial class FormBoatConfig : Form public partial class FormBoatConfig : Form
{ {
DrawingBoat? _boat = null; DrawingBoat? _boat = null;
private event Action<DrawingBoat>? EventAddBoat; private event Action <DrawingBoat>? EventAddBoat;
public int _pictureWidth { get; private set; } public FormBoatConfig()
public int _pictureHeight { get; private set; }
public FormBoatConfig(int pictureWidth, int pictureHeight)
{ {
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
InitializeComponent(); InitializeComponent();
panelBlack.MouseDown += PanelColor_MouseDown; panelBlack.MouseDown += PanelColor_MouseDown;
panelPurple.MouseDown += PanelColor_MouseDown; panelPurple.MouseDown += PanelColor_MouseDown;
@ -54,21 +53,18 @@ namespace Sailboat
EventAddBoat += ev; EventAddBoat += ev;
} }
} }
private void PanelColor_MouseDown(object sender, MouseEventArgs e) private void PanelColor_MouseDown(object sender, MouseEventArgs e)
{ {
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy); (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
} }
private void LableObject_MouseDown(object sender, MouseEventArgs e) private void LabelObject_MouseDown(object sender, MouseEventArgs e)
{ {
(sender as Label)?.DoDragDrop((sender as Label)?.Name, (sender as Label)?.DoDragDrop((sender as Label)?.Name,
DragDropEffects.Move | DragDropEffects.Copy); DragDropEffects.Move | DragDropEffects.Copy);
} }
private void PanelObject_DragEnter(object sender, DragEventArgs e) private void PanelObject_DragEnter(object sender, DragEventArgs e)
{ {
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false) if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
{ {
e.Effect = DragDropEffects.Copy; e.Effect = DragDropEffects.Copy;
@ -85,29 +81,34 @@ namespace Sailboat
{ {
case "labelSimpleObject": case "labelSimpleObject":
_boat = new DrawingBoat((int)numericUpDownSpeed.Value, _boat = new DrawingBoat((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, _pictureWidth, _pictureHeight); (int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
pictureBoxObject.Height);
break; break;
case "labelModifiedObject": case "labelModifiedObject":
_boat = new DrawingSailboat((int)numericUpDownSpeed.Value, _boat = new DrawingSailboat((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxHull.Checked, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxHull.Checked,
checkBoxSail.Checked, _pictureWidth, _pictureHeight); checkBoxSail.Checked, pictureBoxObject.Width,
pictureBoxObject.Height);
break; break;
} }
DrawBoat(); DrawBoat();
} }
private void LabelColor_DragDrop(object sender, DragEventArgs e) private void LabelColor_DragDrop(object sender, DragEventArgs e)
{ {
if (_boat?.EntityBoat == null) if (_boat == null)
return; return;
Color bodyColor = (Color)e.Data.GetData(typeof(Color)); switch (((Label)sender).Name)
_boat.EntityBoat.ChangeColor(bodyColor);
DrawBoat();
}
private void addColorLabel_DragDrop(object sender, DragEventArgs e)
{ {
if ((_boat?.EntityBoat == null) || (_boat is DrawingSailboat == false)) case "labelColor":
_boat.EntityBoat.setBodyColor((Color)e.Data.GetData(typeof(Color)));
break;
case "labelAddColor":
if (!(_boat is DrawingSailboat))
return; return;
((EntitySailboat)_boat.EntityBoat).ChangeAddColor((Color)e.Data.GetData(typeof(Color))); (_boat.EntityBoat as EntitySailboat).setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
break;
}
DrawBoat(); DrawBoat();
} }
private void LabelColor_DragEnter(object sender, DragEventArgs e) private void LabelColor_DragEnter(object sender, DragEventArgs e)
@ -121,7 +122,8 @@ namespace Sailboat
e.Effect = DragDropEffects.None; e.Effect = DragDropEffects.None;
} }
} }
private void buttonOk_Click(object sender, EventArgs e)
private void ButtonOk_Click(object sender, EventArgs e)
{ {
EventAddBoat?.Invoke(_boat); EventAddBoat?.Invoke(_boat);
Close(); Close();