lab5
This commit is contained in:
parent
7a57f00e6e
commit
bac06ec21f
@ -119,9 +119,11 @@ namespace speed_Boat.Generics
|
||||
int width_Col = _pictureWidth / _placeSizeWidth;//количество колонок в окне прорисовки
|
||||
foreach (var boat in _collection.GetBoats())
|
||||
{
|
||||
boat.screenWidth = _pictureWidth;
|
||||
boat.screenHeight = _pictureHeight;
|
||||
if(boat != null)
|
||||
{
|
||||
boat.SetPosition(col * _placeSizeWidth, i / width_Col * _placeSizeHeight);
|
||||
boat.SetPosition(col * _placeSizeWidth, (i / width_Col) * _placeSizeHeight);
|
||||
col++;
|
||||
if (col > 2)
|
||||
col = 0;
|
||||
|
@ -28,17 +28,25 @@ namespace SpeedBoatLab.Drawings
|
||||
{
|
||||
return;
|
||||
}
|
||||
Point[] points;
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new SolidBrush(speedBoat.SecondColor);
|
||||
|
||||
#region Координаты защитного стекла
|
||||
Point g1 = new Point(startXCoord + 70, startYCoord + 25);
|
||||
Point g2 = new Point(startXCoord + 80, startYCoord + 20);
|
||||
Point g3 = new Point(startXCoord + 80, startYCoord + 60);
|
||||
Point g4 = new Point(startXCoord + 70, startYCoord + 55);
|
||||
Point[] pointsGlass = { g1, g2, g3, g4 };
|
||||
#endregion
|
||||
base.DrawTransport(g);
|
||||
|
||||
//Защитное стекло
|
||||
if (speedBoat.isProtectedGlass)
|
||||
{
|
||||
points = new Point[]
|
||||
{
|
||||
new Point(startXCoord + 70, startYCoord + 25),
|
||||
new Point(startXCoord + 80, startYCoord + 20),
|
||||
new Point(startXCoord + 80, startYCoord + 60),
|
||||
new Point(startXCoord + 70, startYCoord + 55)
|
||||
};
|
||||
g.FillPolygon(additionalBrush, points);
|
||||
g.DrawPolygon(pen, points);
|
||||
}
|
||||
//мотор
|
||||
if (speedBoat.isMotor)
|
||||
{
|
||||
@ -46,16 +54,10 @@ namespace SpeedBoatLab.Drawings
|
||||
|
||||
g.FillRectangle(additionalBrush, startXCoord + 10, startYCoord + 30, widthBoat - 90, heightBoat - 60);
|
||||
}
|
||||
|
||||
//защитное стекло
|
||||
if (speedBoat.isProtectedGlass)
|
||||
{
|
||||
g.DrawPolygon(pen, pointsGlass);
|
||||
|
||||
g.FillPolygon(new SolidBrush(Color.Aqua), pointsGlass);
|
||||
}
|
||||
|
||||
base.DrawTransport(g);
|
||||
}
|
||||
public void SetExtraColor(Color color)
|
||||
{
|
||||
(_entityBoat as EntitySpeedboat).SecondColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,9 @@ namespace SpeedBoatLab.Entity
|
||||
Weight = weight;
|
||||
MainColor = mainColor;
|
||||
}
|
||||
|
||||
public void setColor(Color newBaseColor)
|
||||
{
|
||||
MainColor = newBaseColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace SpeedBoatLab.Entity
|
||||
/// <summary>
|
||||
/// Доп. цвет
|
||||
/// </summary>
|
||||
public Color SecondColor { get; private set; }
|
||||
public Color SecondColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Параметры катера
|
||||
@ -37,5 +37,9 @@ namespace SpeedBoatLab.Entity
|
||||
isProtectedGlass = _isProtectedGlass;
|
||||
SecondColor = secondColor;
|
||||
}
|
||||
public void ChangeDopColor(Color newDopColor)
|
||||
{
|
||||
SecondColor = newDopColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ using System.Windows.Forms;
|
||||
using SpeedBoatLab.Drawings;
|
||||
using speed_Boat.Generics;
|
||||
using speed_Boat.MovementStrategy;
|
||||
|
||||
using speed_Boat;
|
||||
|
||||
namespace SpeedBoatLab
|
||||
{
|
||||
@ -75,7 +75,7 @@ namespace SpeedBoatLab
|
||||
private void storageListBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxCollection.Image =
|
||||
_storage[storagesListBox.SelectedItem?.ToString() ?? string.Empty]?.ShowBoats();
|
||||
_storage[storagesListBox.SelectedItem?.ToString() ?? string.Empty]?.ShowBoats();
|
||||
}
|
||||
///<storage>
|
||||
/// Удаление набора
|
||||
@ -94,12 +94,20 @@ namespace SpeedBoatLab
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddBoat_Click(object sender, EventArgs e)
|
||||
{
|
||||
var FormBoatConfig = new FormBoatConfig();
|
||||
FormBoatConfig.AddEvent(new(AddBoat));
|
||||
FormBoatConfig.Show();
|
||||
}
|
||||
|
||||
public void AddBoat(DrawingBoat? boat)
|
||||
{
|
||||
if (storagesListBox.SelectedIndex == -1)
|
||||
{
|
||||
@ -110,19 +118,14 @@ namespace SpeedBoatLab
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FormSpeedBoat form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
if (obj + boat)
|
||||
{
|
||||
if (obj + form.SelectedBoat)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowBoats();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowBoats();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
|
389
speed_Boat/speed_Boat/FormBoatConfig.Designer.cs
generated
Normal file
389
speed_Boat/speed_Boat/FormBoatConfig.Designer.cs
generated
Normal file
@ -0,0 +1,389 @@
|
||||
namespace speed_Boat
|
||||
{
|
||||
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()
|
||||
{
|
||||
groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
labelModifyedObject = new System.Windows.Forms.Label();
|
||||
labelSimpleObject = new System.Windows.Forms.Label();
|
||||
checkBoxIsProtectedGlass = new System.Windows.Forms.CheckBox();
|
||||
checkBoxIsMotor = new System.Windows.Forms.CheckBox();
|
||||
groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
panelWhite = new System.Windows.Forms.Panel();
|
||||
panelYellow = new System.Windows.Forms.Panel();
|
||||
panelGray = new System.Windows.Forms.Panel();
|
||||
panelBlue = new System.Windows.Forms.Panel();
|
||||
panelGreen = new System.Windows.Forms.Panel();
|
||||
panelPurple = new System.Windows.Forms.Panel();
|
||||
panelRed = new System.Windows.Forms.Panel();
|
||||
panelBlack = new System.Windows.Forms.Panel();
|
||||
numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
|
||||
numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
|
||||
label2 = new System.Windows.Forms.Label();
|
||||
label1 = new System.Windows.Forms.Label();
|
||||
panelobject = new System.Windows.Forms.Panel();
|
||||
LabelDopColor = new System.Windows.Forms.Label();
|
||||
LabelBaseColor = new System.Windows.Forms.Label();
|
||||
pictureBoxObject = new System.Windows.Forms.PictureBox();
|
||||
buttonCancel = new System.Windows.Forms.Button();
|
||||
buttonOk = new System.Windows.Forms.Button();
|
||||
groupBox1.SuspendLayout();
|
||||
groupBox2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
panelobject.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Controls.Add(labelModifyedObject);
|
||||
groupBox1.Controls.Add(labelSimpleObject);
|
||||
groupBox1.Controls.Add(checkBoxIsProtectedGlass);
|
||||
groupBox1.Controls.Add(checkBoxIsMotor);
|
||||
groupBox1.Controls.Add(groupBox2);
|
||||
groupBox1.Controls.Add(numericUpDownWeight);
|
||||
groupBox1.Controls.Add(numericUpDownSpeed);
|
||||
groupBox1.Controls.Add(label2);
|
||||
groupBox1.Controls.Add(label1);
|
||||
groupBox1.Location = new System.Drawing.Point(12, 12);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new System.Drawing.Size(316, 426);
|
||||
groupBox1.TabIndex = 0;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Параметры";
|
||||
//
|
||||
// labelModifyedObject
|
||||
//
|
||||
labelModifyedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
labelModifyedObject.Location = new System.Drawing.Point(156, 370);
|
||||
labelModifyedObject.Name = "labelModifyedObject";
|
||||
labelModifyedObject.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||
labelModifyedObject.Size = new System.Drawing.Size(114, 30);
|
||||
labelModifyedObject.TabIndex = 12;
|
||||
labelModifyedObject.Text = "Продвинутый";
|
||||
labelModifyedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
labelModifyedObject.MouseDown += labelSimpleObject_MouseDown;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
labelSimpleObject.Location = new System.Drawing.Point(35, 370);
|
||||
labelSimpleObject.Name = "labelSimpleObject";
|
||||
labelSimpleObject.Size = new System.Drawing.Size(114, 30);
|
||||
labelSimpleObject.TabIndex = 11;
|
||||
labelSimpleObject.Text = "Простой";
|
||||
labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
labelSimpleObject.MouseDown += labelSimpleObject_MouseDown;
|
||||
//
|
||||
// checkBoxIsProtectedGlass
|
||||
//
|
||||
checkBoxIsProtectedGlass.AutoSize = true;
|
||||
checkBoxIsProtectedGlass.Location = new System.Drawing.Point(20, 152);
|
||||
checkBoxIsProtectedGlass.Name = "checkBoxIsProtectedGlass";
|
||||
checkBoxIsProtectedGlass.Size = new System.Drawing.Size(281, 24);
|
||||
checkBoxIsProtectedGlass.TabIndex = 10;
|
||||
checkBoxIsProtectedGlass.Text = "Признак наличия защитного стекла";
|
||||
checkBoxIsProtectedGlass.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxIsMotor
|
||||
//
|
||||
checkBoxIsMotor.AutoSize = true;
|
||||
checkBoxIsMotor.Location = new System.Drawing.Point(20, 122);
|
||||
checkBoxIsMotor.Name = "checkBoxIsMotor";
|
||||
checkBoxIsMotor.Size = new System.Drawing.Size(210, 24);
|
||||
checkBoxIsMotor.TabIndex = 9;
|
||||
checkBoxIsMotor.Text = "Признак наличия мотора";
|
||||
checkBoxIsMotor.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
groupBox2.Controls.Add(panelWhite);
|
||||
groupBox2.Controls.Add(panelYellow);
|
||||
groupBox2.Controls.Add(panelGray);
|
||||
groupBox2.Controls.Add(panelBlue);
|
||||
groupBox2.Controls.Add(panelGreen);
|
||||
groupBox2.Controls.Add(panelPurple);
|
||||
groupBox2.Controls.Add(panelRed);
|
||||
groupBox2.Controls.Add(panelBlack);
|
||||
groupBox2.Location = new System.Drawing.Point(20, 183);
|
||||
groupBox2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
groupBox2.Name = "groupBox2";
|
||||
groupBox2.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
groupBox2.Size = new System.Drawing.Size(261, 173);
|
||||
groupBox2.TabIndex = 8;
|
||||
groupBox2.TabStop = false;
|
||||
groupBox2.Text = "Цвета";
|
||||
//
|
||||
// panelWhite
|
||||
//
|
||||
panelWhite.AllowDrop = true;
|
||||
panelWhite.BackColor = System.Drawing.Color.White;
|
||||
panelWhite.Location = new System.Drawing.Point(191, 104);
|
||||
panelWhite.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
panelWhite.Name = "panelWhite";
|
||||
panelWhite.Size = new System.Drawing.Size(50, 50);
|
||||
panelWhite.TabIndex = 3;
|
||||
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
panelYellow.AllowDrop = true;
|
||||
panelYellow.BackColor = System.Drawing.Color.Yellow;
|
||||
panelYellow.Location = new System.Drawing.Point(191, 37);
|
||||
panelYellow.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
panelYellow.Name = "panelYellow";
|
||||
panelYellow.Size = new System.Drawing.Size(50, 50);
|
||||
panelYellow.TabIndex = 1;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelGray
|
||||
//
|
||||
panelGray.AllowDrop = true;
|
||||
panelGray.BackColor = System.Drawing.Color.Gray;
|
||||
panelGray.Location = new System.Drawing.Point(135, 104);
|
||||
panelGray.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
panelGray.Name = "panelGray";
|
||||
panelGray.Size = new System.Drawing.Size(50, 50);
|
||||
panelGray.TabIndex = 4;
|
||||
panelGray.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
panelBlue.AllowDrop = true;
|
||||
panelBlue.BackColor = System.Drawing.Color.Blue;
|
||||
panelBlue.Location = new System.Drawing.Point(79, 104);
|
||||
panelBlue.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
panelBlue.Name = "panelBlue";
|
||||
panelBlue.Size = new System.Drawing.Size(50, 50);
|
||||
panelBlue.TabIndex = 5;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
panelGreen.AllowDrop = true;
|
||||
panelGreen.BackColor = System.Drawing.Color.Green;
|
||||
panelGreen.Location = new System.Drawing.Point(135, 37);
|
||||
panelGreen.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
panelGreen.Name = "panelGreen";
|
||||
panelGreen.Size = new System.Drawing.Size(50, 50);
|
||||
panelGreen.TabIndex = 1;
|
||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelPurple
|
||||
//
|
||||
panelPurple.AllowDrop = true;
|
||||
panelPurple.BackColor = System.Drawing.Color.Purple;
|
||||
panelPurple.Location = new System.Drawing.Point(23, 104);
|
||||
panelPurple.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
panelPurple.Name = "panelPurple";
|
||||
panelPurple.Size = new System.Drawing.Size(50, 50);
|
||||
panelPurple.TabIndex = 2;
|
||||
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
panelRed.AllowDrop = true;
|
||||
panelRed.BackColor = System.Drawing.Color.Red;
|
||||
panelRed.Location = new System.Drawing.Point(79, 37);
|
||||
panelRed.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
panelRed.Name = "panelRed";
|
||||
panelRed.Size = new System.Drawing.Size(50, 50);
|
||||
panelRed.TabIndex = 1;
|
||||
panelRed.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
panelBlack.AllowDrop = true;
|
||||
panelBlack.BackColor = System.Drawing.Color.Black;
|
||||
panelBlack.Location = new System.Drawing.Point(23, 37);
|
||||
panelBlack.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
panelBlack.Name = "panelBlack";
|
||||
panelBlack.Size = new System.Drawing.Size(50, 50);
|
||||
panelBlack.TabIndex = 0;
|
||||
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new System.Drawing.Point(98, 77);
|
||||
numericUpDownWeight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
numericUpDownWeight.Name = "numericUpDownWeight";
|
||||
numericUpDownWeight.Size = new System.Drawing.Size(137, 27);
|
||||
numericUpDownWeight.TabIndex = 7;
|
||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
numericUpDownSpeed.Location = new System.Drawing.Point(98, 38);
|
||||
numericUpDownSpeed.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||
numericUpDownSpeed.Size = new System.Drawing.Size(137, 27);
|
||||
numericUpDownSpeed.TabIndex = 6;
|
||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new System.Drawing.Point(20, 79);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new System.Drawing.Size(36, 20);
|
||||
label2.TabIndex = 5;
|
||||
label2.Text = "Вес:";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new System.Drawing.Point(20, 41);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new System.Drawing.Size(76, 20);
|
||||
label1.TabIndex = 4;
|
||||
label1.Text = "Скорость:";
|
||||
//
|
||||
// panelobject
|
||||
//
|
||||
panelobject.AllowDrop = true;
|
||||
panelobject.Controls.Add(LabelDopColor);
|
||||
panelobject.Controls.Add(LabelBaseColor);
|
||||
panelobject.Controls.Add(pictureBoxObject);
|
||||
panelobject.Location = new System.Drawing.Point(334, 22);
|
||||
panelobject.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
panelobject.Name = "panelobject";
|
||||
panelobject.Size = new System.Drawing.Size(272, 346);
|
||||
panelobject.TabIndex = 11;
|
||||
panelobject.DragDrop += panelobject_DragDrop;
|
||||
panelobject.DragEnter += panelobject_DragEnter;
|
||||
//
|
||||
// LabelDopColor
|
||||
//
|
||||
LabelDopColor.AllowDrop = true;
|
||||
LabelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
LabelDopColor.Location = new System.Drawing.Point(142, 21);
|
||||
LabelDopColor.Name = "LabelDopColor";
|
||||
LabelDopColor.Size = new System.Drawing.Size(114, 30);
|
||||
LabelDopColor.TabIndex = 3;
|
||||
LabelDopColor.Text = "Доп.цвет";
|
||||
LabelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
LabelDopColor.DragDrop += LabelDopColor_DragDrop;
|
||||
LabelDopColor.DragEnter += LabelDopColor_DragEnter;
|
||||
//
|
||||
// LabelBaseColor
|
||||
//
|
||||
LabelBaseColor.AllowDrop = true;
|
||||
LabelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
LabelBaseColor.Location = new System.Drawing.Point(14, 21);
|
||||
LabelBaseColor.Name = "LabelBaseColor";
|
||||
LabelBaseColor.Size = new System.Drawing.Size(114, 30);
|
||||
LabelBaseColor.TabIndex = 2;
|
||||
LabelBaseColor.Text = "Цвет";
|
||||
LabelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
LabelBaseColor.DragDrop += LabelBaseColor_DragDrop;
|
||||
LabelBaseColor.DragEnter += LabelBaseColor_DragEnter;
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
pictureBoxObject.Location = new System.Drawing.Point(14, 69);
|
||||
pictureBoxObject.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
pictureBoxObject.Name = "pictureBoxObject";
|
||||
pictureBoxObject.Size = new System.Drawing.Size(242, 258);
|
||||
pictureBoxObject.TabIndex = 1;
|
||||
pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new System.Drawing.Point(504, 381);
|
||||
buttonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new System.Drawing.Size(86, 31);
|
||||
buttonCancel.TabIndex = 14;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonOk
|
||||
//
|
||||
buttonOk.Location = new System.Drawing.Point(348, 381);
|
||||
buttonOk.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
buttonOk.Name = "buttonOk";
|
||||
buttonOk.Size = new System.Drawing.Size(86, 31);
|
||||
buttonOk.TabIndex = 13;
|
||||
buttonOk.Text = "Добавить";
|
||||
buttonOk.UseVisualStyleBackColor = true;
|
||||
buttonOk.Click += buttonOk_Click;
|
||||
//
|
||||
// FormBoatConfig
|
||||
//
|
||||
AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
ClientSize = new System.Drawing.Size(634, 450);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonOk);
|
||||
Controls.Add(panelobject);
|
||||
Controls.Add(groupBox1);
|
||||
Name = "FormBoatConfig";
|
||||
Text = "Создание объекта";
|
||||
groupBox1.ResumeLayout(false);
|
||||
groupBox1.PerformLayout();
|
||||
groupBox2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||
panelobject.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.NumericUpDown numericUpDownWeight;
|
||||
private System.Windows.Forms.NumericUpDown numericUpDownSpeed;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label labelModifyedObject;
|
||||
private System.Windows.Forms.Label labelSimpleObject;
|
||||
private System.Windows.Forms.CheckBox checkBoxIsProtectedGlass;
|
||||
private System.Windows.Forms.CheckBox checkBoxIsMotor;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.Panel panelWhite;
|
||||
private System.Windows.Forms.Panel panelYellow;
|
||||
private System.Windows.Forms.Panel panelGray;
|
||||
private System.Windows.Forms.Panel panelBlue;
|
||||
private System.Windows.Forms.Panel panelGreen;
|
||||
private System.Windows.Forms.Panel panelPurple;
|
||||
private System.Windows.Forms.Panel panelRed;
|
||||
private System.Windows.Forms.Panel panelBlack;
|
||||
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;
|
||||
}
|
||||
}
|
146
speed_Boat/speed_Boat/FormBoatConfig.cs
Normal file
146
speed_Boat/speed_Boat/FormBoatConfig.cs
Normal file
@ -0,0 +1,146 @@
|
||||
using SpeedBoatLab.Drawings;
|
||||
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 speed_Boat
|
||||
{
|
||||
public partial class FormBoatConfig : Form
|
||||
{
|
||||
private event Action<DrawingBoat> EventAddBoat;
|
||||
DrawingBoat _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;
|
||||
buttonCancel.Click += (s, a) => Close();
|
||||
}
|
||||
|
||||
public void AddEvent(Action<DrawingBoat> ev)
|
||||
{
|
||||
if (EventAddBoat == null)
|
||||
{
|
||||
EventAddBoat = new Action<DrawingBoat>(ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddBoat += ev;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawBoat()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_boat?.SetPosition(5, 5);
|
||||
_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 DrawingBoat((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
||||
pictureBoxObject.Height);
|
||||
break;
|
||||
case "labelModifyedObject":
|
||||
_boat = new DrawingSpeedBoat((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxIsMotor.Checked,
|
||||
checkBoxIsProtectedGlass.Checked, pictureBoxObject.Width,
|
||||
pictureBoxObject.Height);
|
||||
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)
|
||||
{
|
||||
if (_boat != null)
|
||||
{
|
||||
_boat.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||
DrawBoat();
|
||||
}
|
||||
else return;
|
||||
}
|
||||
|
||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_boat is not DrawingSpeedBoat MotorBoat || _boat == null)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
speed_Boat/speed_Boat/FormBoatConfig.resx
Normal file
120
speed_Boat/speed_Boat/FormBoatConfig.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -21,11 +21,11 @@ namespace SpeedBoatLab.Drawings
|
||||
/// <summary>
|
||||
/// Ширина окна
|
||||
/// </summary>
|
||||
private int screenWidth;
|
||||
public int screenWidth;
|
||||
/// <summary>
|
||||
/// Высота окна
|
||||
/// </summary>
|
||||
private int screenHeight;
|
||||
public int screenHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Х-координата обьекта
|
||||
@ -238,5 +238,9 @@ namespace SpeedBoatLab.Drawings
|
||||
g.FillEllipse(mainBrush, startXCoord + 25, startYCoord + 25, widthBoat - 50, heightBoat - 50);
|
||||
g.FillPolygon(mainBrush, pointsBoat);
|
||||
}
|
||||
public void SetBodyColor(Color color)
|
||||
{
|
||||
(_entityBoat as EntityBoat).setColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user