починила создание простого и продвинутого объектов
This commit is contained in:
parent
3677d2733d
commit
9e26269aa5
@ -1,11 +0,0 @@
|
||||
using Sailboat.DrawingObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sailboat
|
||||
{
|
||||
internal delegate void BoatDelegate(DrawingBoat boat);
|
||||
}
|
@ -49,6 +49,16 @@ namespace Sailboat
|
||||
|
||||
private void buttonAddBoat_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var formBoatConfig = new FormBoatConfig();
|
||||
formBoatConfig.AddEvent(AddBoat);
|
||||
formBoatConfig.Show();
|
||||
@ -66,18 +76,15 @@ namespace Sailboat
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormSailboat form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
|
||||
if (obj + drawingBoat)
|
||||
{
|
||||
if (obj + form.SelectedBoat)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowBoats();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowBoats();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
|
||||
|
33
Sailboat/Sailboat/FormBoatConfig.Designer.cs
generated
33
Sailboat/Sailboat/FormBoatConfig.Designer.cs
generated
@ -46,7 +46,7 @@
|
||||
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelWeight = new System.Windows.Forms.Label();
|
||||
this.labelSpeed = new System.Windows.Forms.Label();
|
||||
this.panelObject = new System.Windows.Forms.Panel();
|
||||
this.PanelObject = new System.Windows.Forms.Panel();
|
||||
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
|
||||
this.labelAddColor = new System.Windows.Forms.Label();
|
||||
this.labelColor = new System.Windows.Forms.Label();
|
||||
@ -56,7 +56,7 @@
|
||||
this.groupBoxParameters.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
|
||||
this.panelObject.SuspendLayout();
|
||||
this.PanelObject.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@ -271,17 +271,18 @@
|
||||
this.labelSpeed.TabIndex = 1;
|
||||
this.labelSpeed.Text = "Скорость:";
|
||||
//
|
||||
// panelObject
|
||||
// PanelObject
|
||||
//
|
||||
this.panelObject.Controls.Add(this.pictureBoxObject);
|
||||
this.panelObject.Controls.Add(this.labelAddColor);
|
||||
this.panelObject.Controls.Add(this.labelColor);
|
||||
this.panelObject.Location = new System.Drawing.Point(658, 12);
|
||||
this.panelObject.Name = "panelObject";
|
||||
this.panelObject.Size = new System.Drawing.Size(362, 330);
|
||||
this.panelObject.TabIndex = 2;
|
||||
this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
|
||||
this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
|
||||
this.PanelObject.AllowDrop = true;
|
||||
this.PanelObject.Controls.Add(this.pictureBoxObject);
|
||||
this.PanelObject.Controls.Add(this.labelAddColor);
|
||||
this.PanelObject.Controls.Add(this.labelColor);
|
||||
this.PanelObject.Location = new System.Drawing.Point(658, 12);
|
||||
this.PanelObject.Name = "PanelObject";
|
||||
this.PanelObject.Size = new System.Drawing.Size(362, 330);
|
||||
this.PanelObject.TabIndex = 2;
|
||||
this.PanelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
|
||||
this.PanelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
@ -293,6 +294,7 @@
|
||||
//
|
||||
// labelAddColor
|
||||
//
|
||||
this.labelAddColor.AllowDrop = true;
|
||||
this.labelAddColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelAddColor.Location = new System.Drawing.Point(182, 16);
|
||||
this.labelAddColor.Name = "labelAddColor";
|
||||
@ -303,6 +305,7 @@
|
||||
//
|
||||
// labelColor
|
||||
//
|
||||
this.labelColor.AllowDrop = true;
|
||||
this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelColor.Location = new System.Drawing.Point(38, 16);
|
||||
this.labelColor.Name = "labelColor";
|
||||
@ -337,7 +340,7 @@
|
||||
this.ClientSize = new System.Drawing.Size(1032, 394);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonOk);
|
||||
this.Controls.Add(this.panelObject);
|
||||
this.Controls.Add(this.PanelObject);
|
||||
this.Controls.Add(this.groupBoxParameters);
|
||||
this.Name = "FormBoatConfig";
|
||||
this.Text = "Создание объекта";
|
||||
@ -346,7 +349,7 @@
|
||||
this.groupBoxParameters.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
|
||||
this.panelObject.ResumeLayout(false);
|
||||
this.PanelObject.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
@ -372,7 +375,7 @@
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private Label labelWeight;
|
||||
private Label labelSpeed;
|
||||
private Panel panelObject;
|
||||
private Panel PanelObject;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Label labelAddColor;
|
||||
private Label labelColor;
|
||||
|
@ -17,7 +17,7 @@ namespace Sailboat
|
||||
public partial class FormBoatConfig : Form
|
||||
{
|
||||
DrawingBoat? _boat = null;
|
||||
private event BoatDelegate? EventAddBoat;
|
||||
private event Action <DrawingBoat>? EventAddBoat;
|
||||
public FormBoatConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -30,7 +30,7 @@ namespace Sailboat
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
|
||||
//button_close.Click += (s, e) => Close();
|
||||
buttonCancel.Click += (s, e) => Close();
|
||||
}
|
||||
|
||||
private void DrawBoat()
|
||||
@ -41,7 +41,7 @@ namespace Sailboat
|
||||
_boat?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
internal void AddEvent(BoatDelegate ev)
|
||||
internal void AddEvent(Action<DrawingBoat> ev)
|
||||
{
|
||||
if (EventAddBoat == null)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user