Почти сделано

This commit is contained in:
Макс Бондаренко 2022-11-11 01:12:45 +04:00
parent f092f6cd87
commit 6b3edfe5e6
4 changed files with 177 additions and 154 deletions

View File

@ -119,5 +119,10 @@ namespace WarmlyShip
{ {
return (_startPosX, _startPosX + _warmlyShipWidth, _startPosY, _startPosY + _warmlyShipHeight); return (_startPosX, _startPosX + _warmlyShipWidth, _startPosY, _startPosY + _warmlyShipHeight);
} }
public DrawingWarmlyShip ModifShip(int? speed = null, float? weight = null, Color? bodyColor = null)
{
return new DrawingWarmlyShip(speed ?? warmlyShip.Speed, weight ?? warmlyShip.Weight, bodyColor ?? warmlyShip.BodyColor);
}
} }
} }

View File

@ -40,5 +40,11 @@ namespace WarmlyShip
g.DrawEllipse(pen, _startPosX, _startPosY + 25, 25, 20); g.DrawEllipse(pen, _startPosX, _startPosY + 25, 25, 20);
} }
} }
public DrawningMotorShip ModifShip(int? speed = null, float? weight = null, Color? bodyColor = null, Color? dopColor = null, bool? tubes = null, bool? cistern = null)
{
EntityMotorShip motorShip = (EntityMotorShip)warmlyShip;
return new DrawningMotorShip(speed ?? warmlyShip.Speed, weight ?? warmlyShip.Weight, bodyColor ?? warmlyShip.BodyColor, dopColor ?? motorShip.DopColor, tubes ?? motorShip.Tubes, cistern ?? motorShip.Cistern);
}
} }
} }

View File

@ -29,33 +29,33 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.groupBoxConfig = new System.Windows.Forms.GroupBox(); this.groupBoxConfig = new System.Windows.Forms.GroupBox();
this.labelSpeed = new System.Windows.Forms.Label(); this.labelModifiedObject = new System.Windows.Forms.Label();
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown(); this.labelSimpleObject = new System.Windows.Forms.Label();
this.groupBoxColors = new System.Windows.Forms.GroupBox();
this.panelBlack = new System.Windows.Forms.Panel();
this.panelWhite = new System.Windows.Forms.Panel();
this.panelBlue = new System.Windows.Forms.Panel();
this.panelYellow = new System.Windows.Forms.Panel();
this.panelCyan = new System.Windows.Forms.Panel();
this.panelGreen = new System.Windows.Forms.Panel();
this.panelRed = new System.Windows.Forms.Panel();
this.panelPink = new System.Windows.Forms.Panel();
this.checkBoxCistern = new System.Windows.Forms.CheckBox();
this.checkBoxTubes = new System.Windows.Forms.CheckBox();
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown(); this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
this.labelWeight = new System.Windows.Forms.Label(); this.labelWeight = new System.Windows.Forms.Label();
this.checkBoxTubes = new System.Windows.Forms.CheckBox(); this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
this.checkBoxCistern = new System.Windows.Forms.CheckBox(); this.labelSpeed = new System.Windows.Forms.Label();
this.groupBoxColors = new System.Windows.Forms.GroupBox();
this.panelPink = new System.Windows.Forms.Panel();
this.panelRed = new System.Windows.Forms.Panel();
this.panelGreen = new System.Windows.Forms.Panel();
this.panelCyan = new System.Windows.Forms.Panel();
this.panelYellow = new System.Windows.Forms.Panel();
this.panelBlue = new System.Windows.Forms.Panel();
this.panelWhite = new System.Windows.Forms.Panel();
this.panelBlack = new System.Windows.Forms.Panel();
this.labelSimpleObject = new System.Windows.Forms.Label();
this.labelModifiedObject = new System.Windows.Forms.Label();
this.pictureBoxObject = new System.Windows.Forms.PictureBox(); this.pictureBoxObject = new System.Windows.Forms.PictureBox();
this.panelObject = new System.Windows.Forms.Panel(); this.panelObject = new System.Windows.Forms.Panel();
this.labelBaseColor = new System.Windows.Forms.Label();
this.labelDopColor = new System.Windows.Forms.Label(); this.labelDopColor = new System.Windows.Forms.Label();
this.labelBaseColor = new System.Windows.Forms.Label();
this.buttonAddShip = new System.Windows.Forms.Button(); this.buttonAddShip = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button();
this.groupBoxConfig.SuspendLayout(); this.groupBoxConfig.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
this.groupBoxColors.SuspendLayout(); this.groupBoxColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
this.panelObject.SuspendLayout(); this.panelObject.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
@ -78,57 +78,27 @@
this.groupBoxConfig.TabStop = false; this.groupBoxConfig.TabStop = false;
this.groupBoxConfig.Text = "Параметры"; this.groupBoxConfig.Text = "Параметры";
// //
// labelSpeed // labelModifiedObject
// //
this.labelSpeed.AutoSize = true; this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelSpeed.Location = new System.Drawing.Point(32, 24); this.labelModifiedObject.Location = new System.Drawing.Point(339, 149);
this.labelSpeed.Name = "labelSpeed"; this.labelModifiedObject.Name = "labelModifiedObject";
this.labelSpeed.Size = new System.Drawing.Size(62, 15); this.labelModifiedObject.Size = new System.Drawing.Size(100, 23);
this.labelSpeed.TabIndex = 0; this.labelModifiedObject.TabIndex = 8;
this.labelSpeed.Text = "Скорость:"; this.labelModifiedObject.Text = "Продвинутый";
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
// //
// numericUpDownSpeed // labelSimpleObject
// //
this.numericUpDownSpeed.Location = new System.Drawing.Point(100, 22); this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.numericUpDownSpeed.Name = "numericUpDownSpeed"; this.labelSimpleObject.Location = new System.Drawing.Point(233, 149);
this.numericUpDownSpeed.Size = new System.Drawing.Size(120, 23); this.labelSimpleObject.Name = "labelSimpleObject";
this.numericUpDownSpeed.TabIndex = 1; this.labelSimpleObject.Size = new System.Drawing.Size(100, 23);
// this.labelSimpleObject.TabIndex = 7;
// numericUpDownWeight this.labelSimpleObject.Text = "Простой";
// this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.numericUpDownWeight.Location = new System.Drawing.Point(100, 51); this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
this.numericUpDownWeight.Name = "numericUpDownWeight";
this.numericUpDownWeight.Size = new System.Drawing.Size(120, 23);
this.numericUpDownWeight.TabIndex = 3;
//
// labelWeight
//
this.labelWeight.AutoSize = true;
this.labelWeight.Location = new System.Drawing.Point(32, 53);
this.labelWeight.Name = "labelWeight";
this.labelWeight.Size = new System.Drawing.Size(29, 15);
this.labelWeight.TabIndex = 2;
this.labelWeight.Text = "Вес:";
//
// checkBoxTubes
//
this.checkBoxTubes.AutoSize = true;
this.checkBoxTubes.Location = new System.Drawing.Point(32, 91);
this.checkBoxTubes.Name = "checkBoxTubes";
this.checkBoxTubes.Size = new System.Drawing.Size(151, 19);
this.checkBoxTubes.TabIndex = 4;
this.checkBoxTubes.Text = "Признак наличия труб";
this.checkBoxTubes.UseVisualStyleBackColor = true;
//
// checkBoxCistern
//
this.checkBoxCistern.AutoSize = true;
this.checkBoxCistern.Location = new System.Drawing.Point(32, 116);
this.checkBoxCistern.Name = "checkBoxCistern";
this.checkBoxCistern.Size = new System.Drawing.Size(180, 19);
this.checkBoxCistern.TabIndex = 5;
this.checkBoxCistern.Text = "Признак наличия цистерны";
this.checkBoxCistern.UseVisualStyleBackColor = true;
// //
// groupBoxColors // groupBoxColors
// //
@ -148,53 +118,13 @@
this.groupBoxColors.TabStop = false; this.groupBoxColors.TabStop = false;
this.groupBoxColors.Text = "Цвета"; this.groupBoxColors.Text = "Цвета";
// //
// panelPink // panelBlack
// //
this.panelPink.BackColor = System.Drawing.Color.Fuchsia; this.panelBlack.BackColor = System.Drawing.Color.Black;
this.panelPink.Location = new System.Drawing.Point(6, 22); this.panelBlack.Location = new System.Drawing.Point(147, 67);
this.panelPink.Name = "panelPink"; this.panelBlack.Name = "panelBlack";
this.panelPink.Size = new System.Drawing.Size(41, 39); this.panelBlack.Size = new System.Drawing.Size(41, 39);
this.panelPink.TabIndex = 0; this.panelBlack.TabIndex = 1;
//
// panelRed
//
this.panelRed.BackColor = System.Drawing.Color.Red;
this.panelRed.Location = new System.Drawing.Point(53, 22);
this.panelRed.Name = "panelRed";
this.panelRed.Size = new System.Drawing.Size(41, 39);
this.panelRed.TabIndex = 1;
//
// panelGreen
//
this.panelGreen.BackColor = System.Drawing.Color.Lime;
this.panelGreen.Location = new System.Drawing.Point(100, 22);
this.panelGreen.Name = "panelGreen";
this.panelGreen.Size = new System.Drawing.Size(41, 39);
this.panelGreen.TabIndex = 2;
//
// panelCyan
//
this.panelCyan.BackColor = System.Drawing.Color.Cyan;
this.panelCyan.Location = new System.Drawing.Point(147, 22);
this.panelCyan.Name = "panelCyan";
this.panelCyan.Size = new System.Drawing.Size(41, 39);
this.panelCyan.TabIndex = 3;
//
// panelYellow
//
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
this.panelYellow.Location = new System.Drawing.Point(6, 69);
this.panelYellow.Name = "panelYellow";
this.panelYellow.Size = new System.Drawing.Size(41, 39);
this.panelYellow.TabIndex = 4;
//
// panelBlue
//
this.panelBlue.BackColor = System.Drawing.Color.Blue;
this.panelBlue.Location = new System.Drawing.Point(53, 67);
this.panelBlue.Name = "panelBlue";
this.panelBlue.Size = new System.Drawing.Size(41, 39);
this.panelBlue.TabIndex = 1;
// //
// panelWhite // panelWhite
// //
@ -204,35 +134,105 @@
this.panelWhite.Size = new System.Drawing.Size(41, 39); this.panelWhite.Size = new System.Drawing.Size(41, 39);
this.panelWhite.TabIndex = 1; this.panelWhite.TabIndex = 1;
// //
// panelBlack // panelBlue
// //
this.panelBlack.BackColor = System.Drawing.Color.Black; this.panelBlue.BackColor = System.Drawing.Color.Blue;
this.panelBlack.Location = new System.Drawing.Point(147, 67); this.panelBlue.Location = new System.Drawing.Point(53, 67);
this.panelBlack.Name = "panelBlack"; this.panelBlue.Name = "panelBlue";
this.panelBlack.Size = new System.Drawing.Size(41, 39); this.panelBlue.Size = new System.Drawing.Size(41, 39);
this.panelBlack.TabIndex = 1; this.panelBlue.TabIndex = 1;
// //
// labelSimpleObject // panelYellow
// //
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panelYellow.BackColor = System.Drawing.Color.Yellow;
this.labelSimpleObject.Location = new System.Drawing.Point(233, 149); this.panelYellow.Location = new System.Drawing.Point(6, 69);
this.labelSimpleObject.Name = "labelSimpleObject"; this.panelYellow.Name = "panelYellow";
this.labelSimpleObject.Size = new System.Drawing.Size(100, 23); this.panelYellow.Size = new System.Drawing.Size(41, 39);
this.labelSimpleObject.TabIndex = 7; this.panelYellow.TabIndex = 4;
this.labelSimpleObject.Text = "Простой";
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
// //
// labelModifiedObject // panelCyan
// //
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panelCyan.BackColor = System.Drawing.Color.Cyan;
this.labelModifiedObject.Location = new System.Drawing.Point(339, 149); this.panelCyan.Location = new System.Drawing.Point(147, 22);
this.labelModifiedObject.Name = "labelModifiedObject"; this.panelCyan.Name = "panelCyan";
this.labelModifiedObject.Size = new System.Drawing.Size(100, 23); this.panelCyan.Size = new System.Drawing.Size(41, 39);
this.labelModifiedObject.TabIndex = 8; this.panelCyan.TabIndex = 3;
this.labelModifiedObject.Text = "Продвинутый"; //
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // panelGreen
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown); //
this.panelGreen.BackColor = System.Drawing.Color.Lime;
this.panelGreen.Location = new System.Drawing.Point(100, 22);
this.panelGreen.Name = "panelGreen";
this.panelGreen.Size = new System.Drawing.Size(41, 39);
this.panelGreen.TabIndex = 2;
//
// panelRed
//
this.panelRed.BackColor = System.Drawing.Color.Red;
this.panelRed.Location = new System.Drawing.Point(53, 22);
this.panelRed.Name = "panelRed";
this.panelRed.Size = new System.Drawing.Size(41, 39);
this.panelRed.TabIndex = 1;
//
// panelPink
//
this.panelPink.BackColor = System.Drawing.Color.Fuchsia;
this.panelPink.Location = new System.Drawing.Point(6, 22);
this.panelPink.Name = "panelPink";
this.panelPink.Size = new System.Drawing.Size(41, 39);
this.panelPink.TabIndex = 0;
//
// checkBoxCistern
//
this.checkBoxCistern.AutoSize = true;
this.checkBoxCistern.Location = new System.Drawing.Point(32, 116);
this.checkBoxCistern.Name = "checkBoxCistern";
this.checkBoxCistern.Size = new System.Drawing.Size(180, 19);
this.checkBoxCistern.TabIndex = 5;
this.checkBoxCistern.Text = "Признак наличия цистерны";
this.checkBoxCistern.UseVisualStyleBackColor = true;
//
// checkBoxTubes
//
this.checkBoxTubes.AutoSize = true;
this.checkBoxTubes.Location = new System.Drawing.Point(32, 91);
this.checkBoxTubes.Name = "checkBoxTubes";
this.checkBoxTubes.Size = new System.Drawing.Size(151, 19);
this.checkBoxTubes.TabIndex = 4;
this.checkBoxTubes.Text = "Признак наличия труб";
this.checkBoxTubes.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
this.numericUpDownWeight.Location = new System.Drawing.Point(100, 51);
this.numericUpDownWeight.Name = "numericUpDownWeight";
this.numericUpDownWeight.Size = new System.Drawing.Size(120, 23);
this.numericUpDownWeight.TabIndex = 3;
//
// labelWeight
//
this.labelWeight.AutoSize = true;
this.labelWeight.Location = new System.Drawing.Point(32, 53);
this.labelWeight.Name = "labelWeight";
this.labelWeight.Size = new System.Drawing.Size(29, 15);
this.labelWeight.TabIndex = 2;
this.labelWeight.Text = "Вес:";
//
// numericUpDownSpeed
//
this.numericUpDownSpeed.Location = new System.Drawing.Point(100, 22);
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
this.numericUpDownSpeed.Size = new System.Drawing.Size(120, 23);
this.numericUpDownSpeed.TabIndex = 1;
//
// labelSpeed
//
this.labelSpeed.AutoSize = true;
this.labelSpeed.Location = new System.Drawing.Point(32, 24);
this.labelSpeed.Name = "labelSpeed";
this.labelSpeed.Size = new System.Drawing.Size(62, 15);
this.labelSpeed.TabIndex = 0;
this.labelSpeed.Text = "Скорость:";
// //
// pictureBoxObject // pictureBoxObject
// //
@ -255,19 +255,6 @@
this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop); this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter); this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
// //
// labelBaseColor
//
this.labelBaseColor.AllowDrop = true;
this.labelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelBaseColor.Location = new System.Drawing.Point(119, 6);
this.labelBaseColor.Name = "labelBaseColor";
this.labelBaseColor.Size = new System.Drawing.Size(100, 23);
this.labelBaseColor.TabIndex = 8;
this.labelBaseColor.Text = "Цвет";
this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelBaseColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
//
// labelDopColor // labelDopColor
// //
this.labelDopColor.AllowDrop = true; this.labelDopColor.AllowDrop = true;
@ -281,6 +268,19 @@
this.labelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop); this.labelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
this.labelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter); this.labelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
// //
// labelBaseColor
//
this.labelBaseColor.AllowDrop = true;
this.labelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelBaseColor.Location = new System.Drawing.Point(119, 6);
this.labelBaseColor.Name = "labelBaseColor";
this.labelBaseColor.Size = new System.Drawing.Size(100, 23);
this.labelBaseColor.TabIndex = 8;
this.labelBaseColor.Text = "Цвет";
this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelBaseColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
//
// buttonAddShip // buttonAddShip
// //
this.buttonAddShip.Location = new System.Drawing.Point(616, 248); this.buttonAddShip.Location = new System.Drawing.Point(616, 248);
@ -289,6 +289,7 @@
this.buttonAddShip.TabIndex = 3; this.buttonAddShip.TabIndex = 3;
this.buttonAddShip.Text = "Добавить"; this.buttonAddShip.Text = "Добавить";
this.buttonAddShip.UseVisualStyleBackColor = true; this.buttonAddShip.UseVisualStyleBackColor = true;
this.buttonAddShip.Click += new System.EventHandler(this.ButtonOk_Click);
// //
// buttonCancel // buttonCancel
// //
@ -312,9 +313,9 @@
this.Text = "Создание объекта"; this.Text = "Создание объекта";
this.groupBoxConfig.ResumeLayout(false); this.groupBoxConfig.ResumeLayout(false);
this.groupBoxConfig.PerformLayout(); this.groupBoxConfig.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
this.groupBoxColors.ResumeLayout(false); this.groupBoxColors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
this.panelObject.ResumeLayout(false); this.panelObject.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);

View File

@ -105,14 +105,25 @@ namespace WarmlyShip
{ {
if (_warmlyShip == null) return; if (_warmlyShip == null) return;
if (_warmlyShip is DrawningMotorShip)
{
_warmlyShip = ((DrawningMotorShip)_warmlyShip).ModifShip(bodyColor: (Color)e.Data.GetData(typeof(Color)));
}
else
{
_warmlyShip = _warmlyShip.ModifShip(bodyColor: (Color)e.Data.GetData(typeof(Color)));
}
DrawShip(); DrawShip();
} }
private void LabelDopColor_DragDrop(object sender, DragEventArgs e) private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
{ {
// TODO Call method from object _car if _car is DrawningSportCar and set dop color if (_warmlyShip == null || !(_warmlyShip is DrawningMotorShip)) return;
_warmlyShip = ((DrawningMotorShip)_warmlyShip).ModifShip(dopColor: (Color)e.Data.GetData(typeof(Color)));
DrawShip();
} }
private void ButtonOk_Click(object sender, EventArgs e) private void ButtonOk_Click(object sender, EventArgs e)