Bondarenko M.S. Lab Work 5 #11

Closed
maxnes3 wants to merge 6 commits from LabWork_05 into LabWork_04
4 changed files with 177 additions and 154 deletions
Showing only changes of commit 6b3edfe5e6 - Show all commits

View File

@ -119,5 +119,10 @@ namespace WarmlyShip
{
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);
}
}
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()
{
this.groupBoxConfig = new System.Windows.Forms.GroupBox();
this.labelSpeed = new System.Windows.Forms.Label();
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
this.labelModifiedObject = new System.Windows.Forms.Label();
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.labelWeight = new System.Windows.Forms.Label();
this.checkBoxTubes = new System.Windows.Forms.CheckBox();
this.checkBoxCistern = new System.Windows.Forms.CheckBox();
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.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
this.labelSpeed = new System.Windows.Forms.Label();
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
this.panelObject = new System.Windows.Forms.Panel();
this.labelBaseColor = 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.buttonCancel = new System.Windows.Forms.Button();
this.groupBoxConfig.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
this.groupBoxColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
this.panelObject.SuspendLayout();
this.SuspendLayout();
@ -78,57 +78,27 @@
this.groupBoxConfig.TabStop = false;
this.groupBoxConfig.Text = "Параметры";
//
// labelSpeed
// labelModifiedObject
//
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 = "Скорость:";
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelModifiedObject.Location = new System.Drawing.Point(339, 149);
this.labelModifiedObject.Name = "labelModifiedObject";
this.labelModifiedObject.Size = new System.Drawing.Size(100, 23);
this.labelModifiedObject.TabIndex = 8;
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.numericUpDownSpeed.Name = "numericUpDownSpeed";
this.numericUpDownSpeed.Size = new System.Drawing.Size(120, 23);
this.numericUpDownSpeed.TabIndex = 1;
//
// 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 = "Вес:";
//
// 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;
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelSimpleObject.Location = new System.Drawing.Point(233, 149);
this.labelSimpleObject.Name = "labelSimpleObject";
this.labelSimpleObject.Size = new System.Drawing.Size(100, 23);
this.labelSimpleObject.TabIndex = 7;
this.labelSimpleObject.Text = "Простой";
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
//
// groupBoxColors
//
@ -148,53 +118,13 @@
this.groupBoxColors.TabStop = false;
this.groupBoxColors.Text = "Цвета";
//
// panelPink
// panelBlack
//
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;
//
// 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;
this.panelBlack.BackColor = System.Drawing.Color.Black;
this.panelBlack.Location = new System.Drawing.Point(147, 67);
this.panelBlack.Name = "panelBlack";
this.panelBlack.Size = new System.Drawing.Size(41, 39);
this.panelBlack.TabIndex = 1;
//
// panelWhite
//
@ -204,35 +134,105 @@
this.panelWhite.Size = new System.Drawing.Size(41, 39);
this.panelWhite.TabIndex = 1;
//
// panelBlack
// panelBlue
//
this.panelBlack.BackColor = System.Drawing.Color.Black;
this.panelBlack.Location = new System.Drawing.Point(147, 67);
this.panelBlack.Name = "panelBlack";
this.panelBlack.Size = new System.Drawing.Size(41, 39);
this.panelBlack.TabIndex = 1;
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;
//
// labelSimpleObject
// panelYellow
//
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelSimpleObject.Location = new System.Drawing.Point(233, 149);
this.labelSimpleObject.Name = "labelSimpleObject";
this.labelSimpleObject.Size = new System.Drawing.Size(100, 23);
this.labelSimpleObject.TabIndex = 7;
this.labelSimpleObject.Text = "Простой";
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
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;
//
// labelModifiedObject
// panelCyan
//
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelModifiedObject.Location = new System.Drawing.Point(339, 149);
this.labelModifiedObject.Name = "labelModifiedObject";
this.labelModifiedObject.Size = new System.Drawing.Size(100, 23);
this.labelModifiedObject.TabIndex = 8;
this.labelModifiedObject.Text = "Продвинутый";
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
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;
//
// 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;
//
// 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
//
@ -255,19 +255,6 @@
this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
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
//
this.labelDopColor.AllowDrop = true;
@ -281,6 +268,19 @@
this.labelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
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
//
this.buttonAddShip.Location = new System.Drawing.Point(616, 248);
@ -289,6 +289,7 @@
this.buttonAddShip.TabIndex = 3;
this.buttonAddShip.Text = "Добавить";
this.buttonAddShip.UseVisualStyleBackColor = true;
this.buttonAddShip.Click += new System.EventHandler(this.ButtonOk_Click);
//
// buttonCancel
//
@ -312,9 +313,9 @@
this.Text = "Создание объекта";
this.groupBoxConfig.ResumeLayout(false);
this.groupBoxConfig.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
this.groupBoxColors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
this.panelObject.ResumeLayout(false);
this.ResumeLayout(false);

View File

@ -105,15 +105,26 @@ namespace WarmlyShip
{
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();
}
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)
{