diff --git a/MotorBoat/MotorBoat/EntityBoat.cs b/MotorBoat/MotorBoat/EntityBoat.cs index 6706ebb..2b6c8f3 100644 --- a/MotorBoat/MotorBoat/EntityBoat.cs +++ b/MotorBoat/MotorBoat/EntityBoat.cs @@ -11,7 +11,7 @@ namespace MotorBoat { public int Speed { get; private set; } public float Weight { get; private set; } - public Color BodyColor { get; private set; } + public Color BodyColor { get; set; } public float Step => Speed * 100 / Weight; public EntityBoat(int speed, float weight, Color bodyColor) { diff --git a/MotorBoat/MotorBoat/FormBoatConfig.Designer.cs b/MotorBoat/MotorBoat/FormBoatConfig.Designer.cs index ea21ed9..27a66f7 100644 --- a/MotorBoat/MotorBoat/FormBoatConfig.Designer.cs +++ b/MotorBoat/MotorBoat/FormBoatConfig.Designer.cs @@ -52,7 +52,7 @@ this.LabelDopColor = new System.Windows.Forms.Label(); this.LabelBaseColor = new System.Windows.Forms.Label(); this.buttonOk = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); @@ -349,21 +349,21 @@ this.buttonOk.UseVisualStyleBackColor = true; this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click); // - // button2 + // buttonCancel // - this.button2.Location = new System.Drawing.Point(674, 190); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(75, 23); - this.button2.TabIndex = 12; - this.button2.Text = "Отмена"; - this.button2.UseVisualStyleBackColor = true; + this.buttonCancel.Location = new System.Drawing.Point(674, 190); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 12; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; // // FormBoatConfig // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(783, 221); - this.Controls.Add(this.button2); + this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonOk); this.Controls.Add(this.panelobject); this.Controls.Add(this.groupBox1); @@ -405,7 +405,7 @@ private Label LabelDopColor; private Label LabelBaseColor; private Button buttonOk; - private Button button2; + private Button buttonCancel; private CheckBox checkBoxBackside; } } \ No newline at end of file diff --git a/MotorBoat/MotorBoat/FormBoatConfig.cs b/MotorBoat/MotorBoat/FormBoatConfig.cs index 88844a5..8c2cc68 100644 --- a/MotorBoat/MotorBoat/FormBoatConfig.cs +++ b/MotorBoat/MotorBoat/FormBoatConfig.cs @@ -25,6 +25,7 @@ namespace MotorBoat panelWhite.MouseDown += PanelColor_MouseDown; panelYellow.MouseDown += PanelColor_MouseDown; panelBlue.MouseDown += PanelColor_MouseDown; + buttonCancel.Click += (s, a) => Close(); } public void AddEvent(BoatDelegate ev) @@ -98,13 +99,17 @@ namespace MotorBoat private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) { - _boat.SetBodyColor((Color)e.Data.GetData(typeof(Color))); - DrawBoat(); + 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 DrawningMotorBoat MotorBoat) + if(_boat is not DrawningMotorBoat MotorBoat || _boat==null) { return; } diff --git a/MotorBoat/MotorBoat/FormMapWithSetBoats.cs b/MotorBoat/MotorBoat/FormMapWithSetBoats.cs index 757820c..cbc794e 100644 --- a/MotorBoat/MotorBoat/FormMapWithSetBoats.cs +++ b/MotorBoat/MotorBoat/FormMapWithSetBoats.cs @@ -111,12 +111,12 @@ namespace MotorBoat if (_mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawningObjectBoat(boat) != -1) { - MessageBox.Show("Object is added"); + MessageBox.Show("Объект добавлен"); pictureBox.Image = _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } else { - MessageBox.Show("Unable to add object"); + MessageBox.Show("Не удалось добавить"); } }