lab5 done
This commit is contained in:
parent
58840fe2e9
commit
a3476e7c7e
@ -36,6 +36,10 @@ namespace Sailboat
|
|||||||
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
|
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
|
||||||
BodyColor = bodyColor;
|
BodyColor = bodyColor;
|
||||||
}
|
}
|
||||||
|
public void ChangeBaseColor(Color newBaseColor)
|
||||||
|
{
|
||||||
|
BodyColor = newBaseColor;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
Sailboat/BoatDelegate.cs
Normal file
10
Sailboat/BoatDelegate.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Sailboat
|
||||||
|
{
|
||||||
|
public delegate void BoatDelegate(DrawingBoat boat);
|
||||||
|
}
|
@ -29,8 +29,13 @@ namespace Sailboat
|
|||||||
private void btn_create_Click(object sender, EventArgs e)
|
private void btn_create_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_boat = new DrawingBoat(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
ColorDialog dialog = new();
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
_boat = new DrawingBoat(rnd.Next(100, 300), rnd.Next(1000, 2000), color);
|
||||||
_boat.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
_boat.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
||||||
pictureBoxBoat.Width, pictureBoxBoat.Height);
|
pictureBoxBoat.Width, pictureBoxBoat.Height);
|
||||||
SetData();
|
SetData();
|
||||||
@ -44,11 +49,22 @@ namespace Sailboat
|
|||||||
private void btn_create_sailboat_Click(object sender, EventArgs e)
|
private void btn_create_sailboat_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_boat = new DrawingSailboat(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
ColorDialog dialog = new();
|
||||||
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
_boat.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
{
|
||||||
pictureBoxBoat.Width, pictureBoxBoat.Height);
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
Color edgeColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
|
ColorDialog dialogDop = new();
|
||||||
|
if (dialogDop.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
edgeColor = dialogDop.Color;
|
||||||
|
}
|
||||||
|
_boat = new DrawingSailboat(rnd.Next(100, 300), rnd.Next(1000, 2000), color, edgeColor,
|
||||||
|
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||||
|
_boat.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
||||||
|
pictureBoxBoat.Width, pictureBoxBoat.Height);
|
||||||
SetData();
|
SetData();
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,10 @@ namespace Sailboat
|
|||||||
/// <param name="bodyColor">Цвет кузова</param>
|
/// <param name="bodyColor">Цвет кузова</param>
|
||||||
/// <param name="sail">Признак наличия паруса</param>
|
/// <param name="sail">Признак наличия паруса</param>
|
||||||
/// <param name="extendedBody">Признак наличия усиленного корпуса</param>
|
/// <param name="extendedBody">Признак наличия усиленного корпуса</param>
|
||||||
public DrawingSailboat(int speed, float weight, Color bodyColor, bool sail, bool extendedBody) :
|
public DrawingSailboat(int speed, float weight, Color bodyColor, Color edgeColor, bool sail, bool extendedBody) :
|
||||||
base(speed, weight, bodyColor, 80, 135)
|
base(speed, weight, bodyColor, 80, 135)
|
||||||
{
|
{
|
||||||
Boat = new Sailboat(speed, weight, bodyColor, sail, extendedBody);
|
Boat = new Sailboat(speed, weight, bodyColor, edgeColor, sail, extendedBody);
|
||||||
}
|
}
|
||||||
public override void DrawTransport(Graphics g)
|
public override void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
@ -33,7 +33,7 @@ namespace Sailboat
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
Brush brush = new SolidBrush(Color.Black);
|
Brush brush = new SolidBrush(sailboat.EdgeColor);
|
||||||
|
|
||||||
_startPosY += 40;
|
_startPosY += 40;
|
||||||
_startPosX += 20;
|
_startPosX += 20;
|
||||||
|
353
Sailboat/FormBoatConfig.Designer.cs
generated
Normal file
353
Sailboat/FormBoatConfig.Designer.cs
generated
Normal file
@ -0,0 +1,353 @@
|
|||||||
|
|
||||||
|
namespace Sailboat
|
||||||
|
{
|
||||||
|
partial class FormBoatConfig
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.labelSailboat = new System.Windows.Forms.Label();
|
||||||
|
this.labelBoat = new System.Windows.Forms.Label();
|
||||||
|
this.groupBoxColors = new System.Windows.Forms.GroupBox();
|
||||||
|
this.panelPurple = new System.Windows.Forms.Panel();
|
||||||
|
this.panelBlack = new System.Windows.Forms.Panel();
|
||||||
|
this.panelGray = new System.Windows.Forms.Panel();
|
||||||
|
this.panelYellow = new System.Windows.Forms.Panel();
|
||||||
|
this.panelBlue = new System.Windows.Forms.Panel();
|
||||||
|
this.panelRed = new System.Windows.Forms.Panel();
|
||||||
|
this.panelGreen = new System.Windows.Forms.Panel();
|
||||||
|
this.panelWhite = new System.Windows.Forms.Panel();
|
||||||
|
this.checkBoxSail = new System.Windows.Forms.CheckBox();
|
||||||
|
this.checkBoxExtendedBody = new System.Windows.Forms.CheckBox();
|
||||||
|
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.labelWeight = new System.Windows.Forms.Label();
|
||||||
|
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.labelSpeed = new System.Windows.Forms.Label();
|
||||||
|
this.panelObject = new System.Windows.Forms.Panel();
|
||||||
|
this.labelDopColor = new System.Windows.Forms.Label();
|
||||||
|
this.labelBaseColor = new System.Windows.Forms.Label();
|
||||||
|
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonOK = new System.Windows.Forms.Button();
|
||||||
|
this.groupBox1.SuspendLayout();
|
||||||
|
this.groupBoxColors.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
|
||||||
|
this.panelObject.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
this.groupBox1.Controls.Add(this.labelSailboat);
|
||||||
|
this.groupBox1.Controls.Add(this.labelBoat);
|
||||||
|
this.groupBox1.Controls.Add(this.groupBoxColors);
|
||||||
|
this.groupBox1.Controls.Add(this.checkBoxSail);
|
||||||
|
this.groupBox1.Controls.Add(this.checkBoxExtendedBody);
|
||||||
|
this.groupBox1.Controls.Add(this.numericUpDownWeight);
|
||||||
|
this.groupBox1.Controls.Add(this.labelWeight);
|
||||||
|
this.groupBox1.Controls.Add(this.numericUpDownSpeed);
|
||||||
|
this.groupBox1.Controls.Add(this.labelSpeed);
|
||||||
|
this.groupBox1.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.groupBox1.Name = "groupBox1";
|
||||||
|
this.groupBox1.Size = new System.Drawing.Size(645, 262);
|
||||||
|
this.groupBox1.TabIndex = 0;
|
||||||
|
this.groupBox1.TabStop = false;
|
||||||
|
this.groupBox1.Text = "Параметры";
|
||||||
|
//
|
||||||
|
// labelSailboat
|
||||||
|
//
|
||||||
|
this.labelSailboat.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.labelSailboat.Location = new System.Drawing.Point(512, 190);
|
||||||
|
this.labelSailboat.Name = "labelSailboat";
|
||||||
|
this.labelSailboat.Size = new System.Drawing.Size(117, 53);
|
||||||
|
this.labelSailboat.TabIndex = 8;
|
||||||
|
this.labelSailboat.Text = "Продвинутый";
|
||||||
|
this.labelSailboat.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
this.labelSailboat.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelObject_MouseDown);
|
||||||
|
//
|
||||||
|
// labelBoat
|
||||||
|
//
|
||||||
|
this.labelBoat.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.labelBoat.Location = new System.Drawing.Point(379, 190);
|
||||||
|
this.labelBoat.Name = "labelBoat";
|
||||||
|
this.labelBoat.Size = new System.Drawing.Size(106, 53);
|
||||||
|
this.labelBoat.TabIndex = 7;
|
||||||
|
this.labelBoat.Text = "Простой";
|
||||||
|
this.labelBoat.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
this.labelBoat.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelObject_MouseDown);
|
||||||
|
//
|
||||||
|
// groupBoxColors
|
||||||
|
//
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelPurple);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelBlack);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelGray);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelYellow);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelBlue);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelRed);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelGreen);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelWhite);
|
||||||
|
this.groupBoxColors.Location = new System.Drawing.Point(379, 27);
|
||||||
|
this.groupBoxColors.Name = "groupBoxColors";
|
||||||
|
this.groupBoxColors.Size = new System.Drawing.Size(250, 150);
|
||||||
|
this.groupBoxColors.TabIndex = 6;
|
||||||
|
this.groupBoxColors.TabStop = false;
|
||||||
|
this.groupBoxColors.Text = "Цвета";
|
||||||
|
//
|
||||||
|
// panelPurple
|
||||||
|
//
|
||||||
|
this.panelPurple.BackColor = System.Drawing.Color.Purple;
|
||||||
|
this.panelPurple.Location = new System.Drawing.Point(175, 83);
|
||||||
|
this.panelPurple.Name = "panelPurple";
|
||||||
|
this.panelPurple.Size = new System.Drawing.Size(50, 50);
|
||||||
|
this.panelPurple.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// panelBlack
|
||||||
|
//
|
||||||
|
this.panelBlack.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.panelBlack.Location = new System.Drawing.Point(119, 83);
|
||||||
|
this.panelBlack.Name = "panelBlack";
|
||||||
|
this.panelBlack.Size = new System.Drawing.Size(50, 50);
|
||||||
|
this.panelBlack.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// panelGray
|
||||||
|
//
|
||||||
|
this.panelGray.BackColor = System.Drawing.Color.Gray;
|
||||||
|
this.panelGray.Location = new System.Drawing.Point(63, 83);
|
||||||
|
this.panelGray.Name = "panelGray";
|
||||||
|
this.panelGray.Size = new System.Drawing.Size(50, 50);
|
||||||
|
this.panelGray.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelYellow
|
||||||
|
//
|
||||||
|
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
|
||||||
|
this.panelYellow.Location = new System.Drawing.Point(175, 27);
|
||||||
|
this.panelYellow.Name = "panelYellow";
|
||||||
|
this.panelYellow.Size = new System.Drawing.Size(50, 50);
|
||||||
|
this.panelYellow.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// panelBlue
|
||||||
|
//
|
||||||
|
this.panelBlue.BackColor = System.Drawing.Color.Blue;
|
||||||
|
this.panelBlue.Location = new System.Drawing.Point(119, 26);
|
||||||
|
this.panelBlue.Name = "panelBlue";
|
||||||
|
this.panelBlue.Size = new System.Drawing.Size(50, 50);
|
||||||
|
this.panelBlue.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// panelRed
|
||||||
|
//
|
||||||
|
this.panelRed.BackColor = System.Drawing.Color.Red;
|
||||||
|
this.panelRed.Location = new System.Drawing.Point(7, 27);
|
||||||
|
this.panelRed.Name = "panelRed";
|
||||||
|
this.panelRed.Size = new System.Drawing.Size(50, 50);
|
||||||
|
this.panelRed.TabIndex = 2;
|
||||||
|
this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseDown);
|
||||||
|
//
|
||||||
|
// panelGreen
|
||||||
|
//
|
||||||
|
this.panelGreen.BackColor = System.Drawing.Color.Green;
|
||||||
|
this.panelGreen.Location = new System.Drawing.Point(63, 26);
|
||||||
|
this.panelGreen.Name = "panelGreen";
|
||||||
|
this.panelGreen.Size = new System.Drawing.Size(50, 50);
|
||||||
|
this.panelGreen.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelWhite
|
||||||
|
//
|
||||||
|
this.panelWhite.BackColor = System.Drawing.Color.White;
|
||||||
|
this.panelWhite.Location = new System.Drawing.Point(7, 83);
|
||||||
|
this.panelWhite.Name = "panelWhite";
|
||||||
|
this.panelWhite.Size = new System.Drawing.Size(50, 50);
|
||||||
|
this.panelWhite.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// checkBoxSail
|
||||||
|
//
|
||||||
|
this.checkBoxSail.AutoSize = true;
|
||||||
|
this.checkBoxSail.Location = new System.Drawing.Point(21, 190);
|
||||||
|
this.checkBoxSail.Name = "checkBoxSail";
|
||||||
|
this.checkBoxSail.Size = new System.Drawing.Size(206, 24);
|
||||||
|
this.checkBoxSail.TabIndex = 5;
|
||||||
|
this.checkBoxSail.Text = "Признак наличия паруса";
|
||||||
|
this.checkBoxSail.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxExtendedBody
|
||||||
|
//
|
||||||
|
this.checkBoxExtendedBody.AutoSize = true;
|
||||||
|
this.checkBoxExtendedBody.Location = new System.Drawing.Point(21, 143);
|
||||||
|
this.checkBoxExtendedBody.Name = "checkBoxExtendedBody";
|
||||||
|
this.checkBoxExtendedBody.Size = new System.Drawing.Size(283, 24);
|
||||||
|
this.checkBoxExtendedBody.TabIndex = 4;
|
||||||
|
this.checkBoxExtendedBody.Text = "Признак наличия усиления корпуса";
|
||||||
|
this.checkBoxExtendedBody.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// numericUpDownWeight
|
||||||
|
//
|
||||||
|
this.numericUpDownWeight.Location = new System.Drawing.Point(113, 93);
|
||||||
|
this.numericUpDownWeight.Name = "numericUpDownWeight";
|
||||||
|
this.numericUpDownWeight.Size = new System.Drawing.Size(150, 27);
|
||||||
|
this.numericUpDownWeight.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// labelWeight
|
||||||
|
//
|
||||||
|
this.labelWeight.AutoSize = true;
|
||||||
|
this.labelWeight.Location = new System.Drawing.Point(21, 95);
|
||||||
|
this.labelWeight.Name = "labelWeight";
|
||||||
|
this.labelWeight.Size = new System.Drawing.Size(33, 20);
|
||||||
|
this.labelWeight.TabIndex = 2;
|
||||||
|
this.labelWeight.Text = "Вес";
|
||||||
|
//
|
||||||
|
// numericUpDownSpeed
|
||||||
|
//
|
||||||
|
this.numericUpDownSpeed.Location = new System.Drawing.Point(113, 40);
|
||||||
|
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||||
|
this.numericUpDownSpeed.Size = new System.Drawing.Size(150, 27);
|
||||||
|
this.numericUpDownSpeed.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// labelSpeed
|
||||||
|
//
|
||||||
|
this.labelSpeed.AutoSize = true;
|
||||||
|
this.labelSpeed.Location = new System.Drawing.Point(21, 40);
|
||||||
|
this.labelSpeed.Name = "labelSpeed";
|
||||||
|
this.labelSpeed.Size = new System.Drawing.Size(73, 20);
|
||||||
|
this.labelSpeed.TabIndex = 0;
|
||||||
|
this.labelSpeed.Text = "Скорость";
|
||||||
|
//
|
||||||
|
// 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(663, 23);
|
||||||
|
this.panelObject.Name = "panelObject";
|
||||||
|
this.panelObject.Size = new System.Drawing.Size(305, 203);
|
||||||
|
this.panelObject.TabIndex = 2;
|
||||||
|
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(168, 12);
|
||||||
|
this.labelDopColor.Name = "labelDopColor";
|
||||||
|
this.labelDopColor.Size = new System.Drawing.Size(106, 50);
|
||||||
|
this.labelDopColor.TabIndex = 9;
|
||||||
|
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.labelBaseColor_DragEnter);
|
||||||
|
//
|
||||||
|
// labelBaseColor
|
||||||
|
//
|
||||||
|
this.labelBaseColor.AllowDrop = true;
|
||||||
|
this.labelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.labelBaseColor.Location = new System.Drawing.Point(27, 12);
|
||||||
|
this.labelBaseColor.Name = "labelBaseColor";
|
||||||
|
this.labelBaseColor.Size = new System.Drawing.Size(106, 50);
|
||||||
|
this.labelBaseColor.TabIndex = 8;
|
||||||
|
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);
|
||||||
|
//
|
||||||
|
// pictureBoxObject
|
||||||
|
//
|
||||||
|
this.pictureBoxObject.Location = new System.Drawing.Point(16, 68);
|
||||||
|
this.pictureBoxObject.Name = "pictureBoxObject";
|
||||||
|
this.pictureBoxObject.Size = new System.Drawing.Size(271, 118);
|
||||||
|
this.pictureBoxObject.TabIndex = 0;
|
||||||
|
this.pictureBoxObject.TabStop = false;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(664, 233);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(141, 29);
|
||||||
|
this.buttonCancel.TabIndex = 3;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// buttonOK
|
||||||
|
//
|
||||||
|
this.buttonOK.Location = new System.Drawing.Point(831, 233);
|
||||||
|
this.buttonOK.Name = "buttonOK";
|
||||||
|
this.buttonOK.Size = new System.Drawing.Size(137, 29);
|
||||||
|
this.buttonOK.TabIndex = 4;
|
||||||
|
this.buttonOK.Text = "ОК";
|
||||||
|
this.buttonOK.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
|
||||||
|
//
|
||||||
|
// FormBoatConfig
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(1255, 313);
|
||||||
|
this.Controls.Add(this.buttonOK);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.panelObject);
|
||||||
|
this.Controls.Add(this.groupBox1);
|
||||||
|
this.Name = "FormBoatConfig";
|
||||||
|
this.Text = "Создание объекта";
|
||||||
|
this.groupBox1.ResumeLayout(false);
|
||||||
|
this.groupBox1.PerformLayout();
|
||||||
|
this.groupBoxColors.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
|
||||||
|
this.panelObject.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.GroupBox groupBox1;
|
||||||
|
private System.Windows.Forms.CheckBox checkBoxSail;
|
||||||
|
private System.Windows.Forms.CheckBox checkBoxExtendedBody;
|
||||||
|
private System.Windows.Forms.NumericUpDown numericUpDownWeight;
|
||||||
|
private System.Windows.Forms.Label labelWeight;
|
||||||
|
private System.Windows.Forms.NumericUpDown numericUpDownSpeed;
|
||||||
|
private System.Windows.Forms.Label labelSpeed;
|
||||||
|
private System.Windows.Forms.GroupBox groupBoxColors;
|
||||||
|
private System.Windows.Forms.Panel panelBlack;
|
||||||
|
private System.Windows.Forms.Panel panelGray;
|
||||||
|
private System.Windows.Forms.Panel panelYellow;
|
||||||
|
private System.Windows.Forms.Panel panelBlue;
|
||||||
|
private System.Windows.Forms.Panel panelRed;
|
||||||
|
private System.Windows.Forms.Panel panelGreen;
|
||||||
|
private System.Windows.Forms.Panel panelWhite;
|
||||||
|
private System.Windows.Forms.Panel panelPurple;
|
||||||
|
private System.Windows.Forms.Label labelSailboat;
|
||||||
|
private System.Windows.Forms.Label labelBoat;
|
||||||
|
private System.Windows.Forms.Panel panelObject;
|
||||||
|
private System.Windows.Forms.Label labelDopColor;
|
||||||
|
private System.Windows.Forms.Label labelBaseColor;
|
||||||
|
private System.Windows.Forms.PictureBox pictureBoxObject;
|
||||||
|
private System.Windows.Forms.Button buttonCancel;
|
||||||
|
private System.Windows.Forms.Button buttonOK;
|
||||||
|
}
|
||||||
|
}
|
118
Sailboat/FormBoatConfig.cs
Normal file
118
Sailboat/FormBoatConfig.cs
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
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 Sailboat
|
||||||
|
{
|
||||||
|
public partial class FormBoatConfig : Form
|
||||||
|
{
|
||||||
|
DrawingBoat _boat = null;
|
||||||
|
private event BoatDelegate EventAddBoat;
|
||||||
|
public FormBoatConfig()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
panelBlack.MouseDown += panelColor_MouseDown;
|
||||||
|
panelWhite.MouseDown += panelColor_MouseDown;
|
||||||
|
panelGreen.MouseDown += panelColor_MouseDown;
|
||||||
|
panelYellow.MouseDown += panelColor_MouseDown;
|
||||||
|
panelRed.MouseDown += panelColor_MouseDown;
|
||||||
|
panelBlue.MouseDown += panelColor_MouseDown;
|
||||||
|
panelPurple.MouseDown += panelColor_MouseDown;
|
||||||
|
panelGray.MouseDown += panelColor_MouseDown;
|
||||||
|
buttonCancel.Click += (s, e) => Close();
|
||||||
|
}
|
||||||
|
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, 5, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
_boat?.DrawTransport(gr);
|
||||||
|
pictureBoxObject.Image = bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void labelObject_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 "labelBoat":
|
||||||
|
_boat = new DrawingBoat((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White);
|
||||||
|
break;
|
||||||
|
case "labelSailboat":
|
||||||
|
_boat = new DrawingSailboat((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black,
|
||||||
|
checkBoxSail.Checked, checkBoxExtendedBody.Checked);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawBoat();
|
||||||
|
}
|
||||||
|
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
_boat?.Boat.ChangeBaseColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
DrawBoat();
|
||||||
|
}
|
||||||
|
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_boat?.Boat is Sailboat sailboat)
|
||||||
|
{
|
||||||
|
sailboat.ChangeDopColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
DrawBoat();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void buttonOK_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
EventAddBoat?.Invoke(_boat);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
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 panelColor_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
Sailboat/FormBoatConfig.resx
Normal file
60
Sailboat/FormBoatConfig.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<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>
|
@ -50,31 +50,9 @@ namespace Sailboat
|
|||||||
|
|
||||||
private void btn_add_boat_Click(object sender, EventArgs e)
|
private void btn_add_boat_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
var formBoatConfig = new FormBoatConfig();
|
||||||
{
|
formBoatConfig.AddEvent(InsertBoatCheck);
|
||||||
return;
|
formBoatConfig.Show();
|
||||||
}
|
|
||||||
BoatForm form = new();
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (form.SelectedBoat == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Вы не создали объект");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawingObjectBoat 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("Не удалось добавить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btn_remove_boat_Click(object sender, EventArgs e)
|
private void btn_remove_boat_Click(object sender, EventArgs e)
|
||||||
@ -178,5 +156,22 @@ namespace Sailboat
|
|||||||
ReloadMaps();
|
ReloadMaps();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void InsertBoatCheck(DrawingBoat _boat)
|
||||||
|
{
|
||||||
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DrawingObjectBoat boat = new(_boat);
|
||||||
|
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + boat >= 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@ namespace Sailboat
|
|||||||
/// Признак наличия паруса
|
/// Признак наличия паруса
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Sail { get; private set; }
|
public bool Sail { get; private set; }
|
||||||
|
|
||||||
|
public Color EdgeColor { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Инициализация свойств
|
/// Инициализация свойств
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -25,11 +27,16 @@ namespace Sailboat
|
|||||||
/// <param name="bodyColor">Цвет кузова</param>
|
/// <param name="bodyColor">Цвет кузова</param>
|
||||||
/// <param name="sail">Признак наличия паруса</param>
|
/// <param name="sail">Признак наличия паруса</param>
|
||||||
/// <param name="extendedBody">Признак наличия усиленного корпуса</param>
|
/// <param name="extendedBody">Признак наличия усиленного корпуса</param>
|
||||||
public Sailboat(int speed, float weight, Color bodyColor, bool sail, bool extendedBody) :
|
public Sailboat(int speed, float weight, Color bodyColor, Color edgeColor, bool sail, bool extendedBody) :
|
||||||
base(speed, weight, bodyColor)
|
base(speed, weight, bodyColor)
|
||||||
{
|
{
|
||||||
|
EdgeColor = edgeColor;
|
||||||
Sail = sail;
|
Sail = sail;
|
||||||
ExtendedBody = extendedBody;
|
ExtendedBody = extendedBody;
|
||||||
}
|
}
|
||||||
|
public void ChangeDopColor(Color newEdgeColor)
|
||||||
|
{
|
||||||
|
EdgeColor = newEdgeColor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user