зафиксировать всёё

This commit is contained in:
Учебный 2023-11-13 11:36:41 +04:00
parent 568f6fe9ed
commit f0bfd7e353
3 changed files with 133 additions and 102 deletions

View File

@ -0,0 +1,15 @@
using ProjectBoat_bae.DrawningObjects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectBoat_bae
{
internal class BoatDelegate
{
// Делегат для передачи объекта-автомобиля
public delegate void boatDelegate(Drawningboat boat);
}
}

View File

@ -30,8 +30,9 @@
{ {
pictureBoxObject = new PictureBox(); pictureBoxObject = new PictureBox();
groupBoxBoat = new GroupBox(); groupBoxBoat = new GroupBox();
checkBox1 = new CheckBox();
labelModifiedObject = new Label(); labelModifiedObject = new Label();
LabelEasy = new Label(); labelSimpleObject = new Label();
groupBoxColors = new GroupBox(); groupBoxColors = new GroupBox();
panelPurple = new Panel(); panelPurple = new Panel();
panelGray = new Panel(); panelGray = new Panel();
@ -41,26 +42,24 @@
panelBlue = new Panel(); panelBlue = new Panel();
panelGreen = new Panel(); panelGreen = new Panel();
panelRed = new Panel(); panelRed = new Panel();
checkBox3 = new CheckBox();
numericUpDownSpeed = new NumericUpDown(); numericUpDownSpeed = new NumericUpDown();
numericUpDownWeight = new NumericUpDown(); numericUpDownWeight = new NumericUpDown();
Speed = new Label(); Speed = new Label();
checkBoxBoat = new CheckBox(); checkBoxBoat = new CheckBox();
checkBoxRainforce = new CheckBox();
Weight = new Label(); Weight = new Label();
Panelcolor = new Panel(); pictureBox1 = new PictureBox();
AddColorbutton = new Label(); PanelObject = new Panel();
Colorlabel = new Label(); LabelAdditionalColor = new Label();
LabelColor = new Label();
buttonOk = new Button(); buttonOk = new Button();
buttonCancel = new Button(); buttonCancel = new Button();
pictureBox1 = new PictureBox();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
groupBoxBoat.SuspendLayout(); groupBoxBoat.SuspendLayout();
groupBoxColors.SuspendLayout(); groupBoxColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
Panelcolor.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
PanelObject.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
// pictureBoxObject // pictureBoxObject
@ -73,15 +72,14 @@
// //
// groupBoxBoat // groupBoxBoat
// //
groupBoxBoat.Controls.Add(checkBox1);
groupBoxBoat.Controls.Add(labelModifiedObject); groupBoxBoat.Controls.Add(labelModifiedObject);
groupBoxBoat.Controls.Add(LabelEasy); groupBoxBoat.Controls.Add(labelSimpleObject);
groupBoxBoat.Controls.Add(groupBoxColors); groupBoxBoat.Controls.Add(groupBoxColors);
groupBoxBoat.Controls.Add(checkBox3);
groupBoxBoat.Controls.Add(numericUpDownSpeed); groupBoxBoat.Controls.Add(numericUpDownSpeed);
groupBoxBoat.Controls.Add(numericUpDownWeight); groupBoxBoat.Controls.Add(numericUpDownWeight);
groupBoxBoat.Controls.Add(Speed); groupBoxBoat.Controls.Add(Speed);
groupBoxBoat.Controls.Add(checkBoxBoat); groupBoxBoat.Controls.Add(checkBoxBoat);
groupBoxBoat.Controls.Add(checkBoxRainforce);
groupBoxBoat.Controls.Add(Weight); groupBoxBoat.Controls.Add(Weight);
groupBoxBoat.Controls.Add(pictureBox1); groupBoxBoat.Controls.Add(pictureBox1);
groupBoxBoat.Location = new Point(12, 12); groupBoxBoat.Location = new Point(12, 12);
@ -91,6 +89,16 @@
groupBoxBoat.TabStop = false; groupBoxBoat.TabStop = false;
groupBoxBoat.Text = "Параметры"; groupBoxBoat.Text = "Параметры";
// //
// checkBox1
//
checkBox1.AutoSize = true;
checkBox1.Location = new Point(21, 236);
checkBox1.Name = "checkBox1";
checkBox1.Size = new Size(230, 29);
checkBox1.TabIndex = 12;
checkBox1.Text = "Признак наличия весел";
checkBox1.UseVisualStyleBackColor = true;
//
// labelModifiedObject // labelModifiedObject
// //
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle; labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
@ -101,17 +109,17 @@
labelModifiedObject.Text = "Продвинутый"; labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter; labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
// //
// LabelEasy // labelSimpleObject
// //
LabelEasy.BorderStyle = BorderStyle.FixedSingle; labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
LabelEasy.Location = new Point(334, 227); labelSimpleObject.Location = new Point(334, 227);
LabelEasy.Name = "LabelEasy"; labelSimpleObject.Name = "labelSimpleObject";
LabelEasy.Size = new Size(124, 38); labelSimpleObject.Size = new Size(124, 38);
LabelEasy.TabIndex = 10; labelSimpleObject.TabIndex = 10;
LabelEasy.Text = "Простой"; labelSimpleObject.Text = "Простой";
LabelEasy.TextAlign = ContentAlignment.MiddleCenter; labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
LabelEasy.Click += LabelEasy_Click; labelSimpleObject.Click += labelSimpleObject_Click;
LabelEasy.MouseDown += LabelObject_MouseDown; labelSimpleObject.MouseDown += LabelObject_MouseDown;
// //
// groupBoxColors // groupBoxColors
// //
@ -194,16 +202,6 @@
panelRed.Size = new Size(45, 45); panelRed.Size = new Size(45, 45);
panelRed.TabIndex = 10; panelRed.TabIndex = 10;
// //
// checkBox3
//
checkBox3.AutoSize = true;
checkBox3.Location = new Point(21, 299);
checkBox3.Name = "checkBox3";
checkBox3.Size = new Size(108, 29);
checkBox3.TabIndex = 8;
checkBox3.Text = "Признак";
checkBox3.UseVisualStyleBackColor = true;
//
// numericUpDownSpeed // numericUpDownSpeed
// //
numericUpDownSpeed.Location = new Point(148, 61); numericUpDownSpeed.Location = new Point(148, 61);
@ -238,20 +236,11 @@
checkBoxBoat.AutoSize = true; checkBoxBoat.AutoSize = true;
checkBoxBoat.Location = new Point(21, 176); checkBoxBoat.Location = new Point(21, 176);
checkBoxBoat.Name = "checkBoxBoat"; checkBoxBoat.Name = "checkBoxBoat";
checkBoxBoat.Size = new Size(180, 29); checkBoxBoat.Size = new Size(230, 29);
checkBoxBoat.TabIndex = 6; checkBoxBoat.TabIndex = 6;
checkBoxBoat.Text = "Признак наличия"; checkBoxBoat.Text = "Признак наличия весел";
checkBoxBoat.UseVisualStyleBackColor = true; checkBoxBoat.UseVisualStyleBackColor = true;
// checkBoxBoat.CheckedChanged += checkBoxBoat_CheckedChanged;
// checkBoxRainforce
//
checkBoxRainforce.AutoSize = true;
checkBoxRainforce.Location = new Point(21, 236);
checkBoxRainforce.Name = "checkBoxRainforce";
checkBoxRainforce.Size = new Size(108, 29);
checkBoxRainforce.TabIndex = 7;
checkBoxRainforce.Text = "Признак";
checkBoxRainforce.UseVisualStyleBackColor = true;
// //
// Weight // Weight
// //
@ -262,38 +251,48 @@
Weight.TabIndex = 3; Weight.TabIndex = 3;
Weight.Text = "Вес"; Weight.Text = "Вес";
// //
// Panelcolor // pictureBox1
// //
Panelcolor.AllowDrop = true; pictureBox1.Location = new Point(0, 0);
Panelcolor.BorderStyle = BorderStyle.FixedSingle; pictureBox1.Name = "pictureBox1";
Panelcolor.Controls.Add(AddColorbutton); pictureBox1.Size = new Size(668, 449);
Panelcolor.Controls.Add(Colorlabel); pictureBox1.TabIndex = 2;
Panelcolor.Controls.Add(pictureBoxObject); pictureBox1.TabStop = false;
Panelcolor.Location = new Point(696, 23);
Panelcolor.Name = "Panelcolor";
Panelcolor.Size = new Size(460, 378);
Panelcolor.TabIndex = 2;
Panelcolor.MouseDown += PanelColor_MouseDown;
// //
// AddColorbutton // PanelObject
// //
AddColorbutton.AutoSize = true; PanelObject.AllowDrop = true;
AddColorbutton.BorderStyle = BorderStyle.FixedSingle; PanelObject.BorderStyle = BorderStyle.FixedSingle;
AddColorbutton.Location = new Point(333, 38); PanelObject.Controls.Add(LabelAdditionalColor);
AddColorbutton.Name = "AddColorbutton"; PanelObject.Controls.Add(LabelColor);
AddColorbutton.Size = new Size(93, 27); PanelObject.Controls.Add(pictureBoxObject);
AddColorbutton.TabIndex = 1; PanelObject.Location = new Point(696, 23);
AddColorbutton.Text = "Доп. цвет"; PanelObject.Name = "PanelObject";
PanelObject.Size = new Size(460, 378);
PanelObject.TabIndex = 2;
PanelObject.MouseDown += PanelColor_MouseDown;
// //
// Colorlabel // LabelAdditionalColor
// //
Colorlabel.AutoSize = true; LabelAdditionalColor.AllowDrop = true;
Colorlabel.BorderStyle = BorderStyle.FixedSingle; LabelAdditionalColor.AutoSize = true;
Colorlabel.Location = new Point(38, 38); LabelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
Colorlabel.Name = "Colorlabel"; LabelAdditionalColor.Location = new Point(333, 38);
Colorlabel.Size = new Size(53, 27); LabelAdditionalColor.Name = "LabelAdditionalColor";
Colorlabel.TabIndex = 0; LabelAdditionalColor.Size = new Size(93, 27);
Colorlabel.Text = "Цвет"; LabelAdditionalColor.TabIndex = 1;
LabelAdditionalColor.Text = "Доп. цвет";
//
// LabelColor
//
LabelColor.AllowDrop = true;
LabelColor.AutoSize = true;
LabelColor.BorderStyle = BorderStyle.FixedSingle;
LabelColor.Location = new Point(38, 38);
LabelColor.Name = "LabelColor";
LabelColor.Size = new Size(53, 27);
LabelColor.TabIndex = 0;
LabelColor.Text = "Цвет";
// //
// buttonOk // buttonOk
// //
@ -313,14 +312,6 @@
buttonCancel.Text = "Отмена"; buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true; buttonCancel.UseVisualStyleBackColor = true;
// //
// pictureBox1
//
pictureBox1.Location = new Point(0, 0);
pictureBox1.Name = "pictureBox1";
pictureBox1.Size = new Size(668, 449);
pictureBox1.TabIndex = 2;
pictureBox1.TabStop = false;
//
// FormBoatConfig // FormBoatConfig
// //
AutoScaleDimensions = new SizeF(10F, 25F); AutoScaleDimensions = new SizeF(10F, 25F);
@ -328,7 +319,7 @@
ClientSize = new Size(1178, 498); ClientSize = new Size(1178, 498);
Controls.Add(buttonCancel); Controls.Add(buttonCancel);
Controls.Add(buttonOk); Controls.Add(buttonOk);
Controls.Add(Panelcolor); Controls.Add(PanelObject);
Controls.Add(groupBoxBoat); Controls.Add(groupBoxBoat);
Name = "FormBoatConfig"; Name = "FormBoatConfig";
Text = "FormBoatConfig"; Text = "FormBoatConfig";
@ -338,9 +329,9 @@
groupBoxColors.ResumeLayout(false); groupBoxColors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit(); ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit(); ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
Panelcolor.ResumeLayout(false);
Panelcolor.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
PanelObject.ResumeLayout(false);
PanelObject.PerformLayout();
ResumeLayout(false); ResumeLayout(false);
} }
@ -353,10 +344,8 @@
private NumericUpDown numericUpDownSpeed; private NumericUpDown numericUpDownSpeed;
private NumericUpDown numericUpDownWeight; private NumericUpDown numericUpDownWeight;
private GroupBox groupBoxColors; private GroupBox groupBoxColors;
private CheckBox checkBox3;
private CheckBox checkBoxBoat; private CheckBox checkBoxBoat;
private CheckBox checkBoxRainforce; private Label labelSimpleObject;
private Label LabelEasy;
private Panel panelPurple; private Panel panelPurple;
private Panel panelGray; private Panel panelGray;
private Panel panelWhite; private Panel panelWhite;
@ -366,11 +355,12 @@
private Panel panelGreen; private Panel panelGreen;
private Panel panelRed; private Panel panelRed;
private Label labelModifiedObject; private Label labelModifiedObject;
private Panel Panelcolor; private Panel PanelObject;
private Button buttonOk; private Button buttonOk;
private Button buttonCancel; private Button buttonCancel;
private Label AddColorbutton; private Label LabelAdditionalColor;
private Label Colorlabel; private Label LabelColor;
private PictureBox pictureBox1; private PictureBox pictureBox1;
private CheckBox checkBox1;
} }
} }

View File

@ -46,11 +46,13 @@ namespace ProjectBoat_bae
panelWhite.MouseDown += PanelColor_MouseDown; panelWhite.MouseDown += PanelColor_MouseDown;
panelYellow.MouseDown += PanelColor_MouseDown; panelYellow.MouseDown += PanelColor_MouseDown;
panelBlue.MouseDown += PanelColor_MouseDown; panelBlue.MouseDown += PanelColor_MouseDown;
buttonCancel.Click += (sender, e) => Close(); labelSimpleObject.MouseDown += LabelObject_MouseDown;
labelModifiedObject.MouseDown += LabelObject_MouseDown;
buttonCancel.Click += (s, e) => Close();
} }
// Метод прорисовки // Метод прорисовки
private void Draw() private void DrawBoat()
{ {
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp); Graphics gr = Graphics.FromImage(bmp);
@ -81,17 +83,33 @@ namespace ProjectBoat_bae
// Действия при приеме перетаскиваемой информации // Действия при приеме перетаскиваемой информации
private void PanelObject_DragDrop(object sender, DragEventArgs e) 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, pictureBoxObject.Width, pictureBoxObject.Height);
// break;
// case "labelModifiedObject":
// _boat = new DrawningMotorBoat((int)numericUpDownSpeed.Value,
// (int)numericUpDownWeight.Value, Color.White, Color.Black,
// checkBoxBoat.Checked, checkBoxBoat.Checked, pictureBoxObject.Width, pictureBoxObject.Height);
// break;
//}
//LabelColor.BackColor = Color.Empty;
//LabelAdditionalColor.BackColor = Color.Empty;
//DrawBoat();
switch (e.Data?.GetData(DataFormats.Text).ToString()) switch (e.Data?.GetData(DataFormats.Text).ToString())
{ {
case "labelEasy": case "labelSimpleObject":
_boat = new Drawningboat((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width, pictureBoxObject.Height); _boat = new Drawningboat((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width, pictureBoxObject.Height);
break; break;
case "labelModifiedObject": case "labelModifiedObject":
_boat = new DrawningMotorBoat((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, _boat = new DrawningMotorBoat((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxBoat.Checked, checkBox1.Checked, pictureBoxObject.Width, pictureBoxObject.Height);
checkBoxBoat.Checked, checkBoxRainforce.Checked, pictureBoxObject.Width, pictureBoxObject.Height);
break; break;
} }
Draw(); LabelColor.BackColor = Color.Empty;
LabelAdditionalColor.BackColor = Color.Empty;
DrawBoat();
} }
// Добавление установки // Добавление установки
@ -110,18 +128,21 @@ namespace ProjectBoat_bae
private void LabelColor_DragDrop(object sender, DragEventArgs e) private void LabelColor_DragDrop(object sender, DragEventArgs e)
{ {
if (_boat == null) return; if (_boat == null)
return;
switch (((Label)sender).Name) switch (((Label)sender).Name)
{ {
case "labelColor": case "LabelColor":
_boat.EntityBoat.SetBodyColor((Color)e.Data.GetData(typeof(Color))); _boat?.EntityBoat?.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
break; break;
case "labelAdditionalColor": case "LabelAdditionalColor":
if (_boat == null) return; if (!(_boat is ProjectBoat_bae))
(_boat.EntityBoat as EntityMotorBoat).setAdditionalColor((Color)e.Data.GetData(typeof(Color))); return;
(_boat.EntityBoat as EntityMotorBoat)?.setAdditionalColor(color:
(Color)e.Data.GetData(typeof(Color)));
break; break;
} }
Draw(); DrawBoat();
} }
private void LabelColor_DragEnter(object sender, DragEventArgs e) private void LabelColor_DragEnter(object sender, DragEventArgs e)
@ -153,10 +174,15 @@ namespace ProjectBoat_bae
//Приведение к EntityTrolleybus для замены доп. цвета //Приведение к EntityTrolleybus для замены доп. цвета
EntityMotorBoat? _motorboat = _boat.EntityBoat as EntityMotorBoat; EntityMotorBoat? _motorboat = _boat.EntityBoat as EntityMotorBoat;
_motorboat.setAdditionalColor(color); _motorboat.setAdditionalColor(color);
Draw(); DrawBoat();
} }
private void LabelEasy_Click(object sender, EventArgs e) private void checkBoxBoat_CheckedChanged(object sender, EventArgs e)
{
}
private void labelSimpleObject_Click(object sender, EventArgs e)
{ {
} }