Event work
This commit is contained in:
parent
02ebc568ac
commit
8bd90876de
11
Bus/Bus/BusDelegate.cs
Normal file
11
Bus/Bus/BusDelegate.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bus
|
||||
{
|
||||
public delegate void BusDelegate(DrawingBus bus);
|
||||
|
||||
}
|
45
Bus/Bus/FormBusConfig.Designer.cs
generated
45
Bus/Bus/FormBusConfig.Designer.cs
generated
@ -29,7 +29,7 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.groupBoxConfig = new System.Windows.Forms.GroupBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.labelModifiedObject = new System.Windows.Forms.Label();
|
||||
this.labelSimpleObject = new System.Windows.Forms.Label();
|
||||
this.groupBoxColors = new System.Windows.Forms.GroupBox();
|
||||
this.panelPurple = new System.Windows.Forms.Panel();
|
||||
@ -51,7 +51,7 @@
|
||||
this.panelObject = new System.Windows.Forms.Panel();
|
||||
this.labelDopColor = new System.Windows.Forms.Label();
|
||||
this.labelColor = new System.Windows.Forms.Label();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.buttonOk = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.groupBoxConfig.SuspendLayout();
|
||||
this.groupBoxColors.SuspendLayout();
|
||||
@ -63,7 +63,7 @@
|
||||
//
|
||||
// groupBoxConfig
|
||||
//
|
||||
this.groupBoxConfig.Controls.Add(this.label2);
|
||||
this.groupBoxConfig.Controls.Add(this.labelModifiedObject);
|
||||
this.groupBoxConfig.Controls.Add(this.labelSimpleObject);
|
||||
this.groupBoxConfig.Controls.Add(this.groupBoxColors);
|
||||
this.groupBoxConfig.Controls.Add(this.checkBoxBodyKit);
|
||||
@ -80,16 +80,16 @@
|
||||
this.groupBoxConfig.TabStop = false;
|
||||
this.groupBoxConfig.Text = "Параметры";
|
||||
//
|
||||
// label2
|
||||
// labelModifiedObject
|
||||
//
|
||||
this.label2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.label2.Location = new System.Drawing.Point(221, 182);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(188, 25);
|
||||
this.label2.TabIndex = 9;
|
||||
this.label2.Text = "Продвинутый";
|
||||
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.label2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
|
||||
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelModifiedObject.Location = new System.Drawing.Point(221, 182);
|
||||
this.labelModifiedObject.Name = "labelModifiedObject";
|
||||
this.labelModifiedObject.Size = new System.Drawing.Size(188, 25);
|
||||
this.labelModifiedObject.TabIndex = 9;
|
||||
this.labelModifiedObject.Text = "Продвинутый";
|
||||
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
@ -300,14 +300,15 @@
|
||||
this.labelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
|
||||
this.labelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
|
||||
//
|
||||
// button1
|
||||
// buttonOk
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(460, 200);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(118, 37);
|
||||
this.button1.TabIndex = 3;
|
||||
this.button1.Text = "Добавить";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.buttonOk.Location = new System.Drawing.Point(460, 200);
|
||||
this.buttonOk.Name = "buttonOk";
|
||||
this.buttonOk.Size = new System.Drawing.Size(118, 37);
|
||||
this.buttonOk.TabIndex = 3;
|
||||
this.buttonOk.Text = "Добавить";
|
||||
this.buttonOk.UseVisualStyleBackColor = true;
|
||||
this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
@ -324,7 +325,7 @@
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(722, 249);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.buttonOk);
|
||||
this.Controls.Add(this.panelObject);
|
||||
this.Controls.Add(this.groupBoxConfig);
|
||||
this.Name = "FormBusConfig";
|
||||
@ -360,12 +361,12 @@
|
||||
private Panel panelWhite;
|
||||
private Panel panelGreen;
|
||||
private Panel panelRed;
|
||||
private Label label2;
|
||||
private Label labelModifiedObject;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Panel panelObject;
|
||||
private Label labelDopColor;
|
||||
private Label labelColor;
|
||||
private Button button1;
|
||||
private Button buttonOk;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ namespace Bus
|
||||
{
|
||||
|
||||
DrawingBus _bus = null;
|
||||
//private event BusDelegate EventAddBus;
|
||||
private event BusDelegate EventAddBus;
|
||||
|
||||
public FormBusConfig()
|
||||
{
|
||||
@ -44,6 +44,19 @@ namespace Bus
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
|
||||
public void AddEvent(BusDelegate ev)
|
||||
{
|
||||
if (EventAddBus == null)
|
||||
{
|
||||
EventAddBus = new BusDelegate(ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddBus += ev;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.Text))
|
||||
@ -131,5 +144,11 @@ namespace Bus
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddBus?.Invoke(_bus);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,34 +80,32 @@ namespace Bus
|
||||
|
||||
private void ButtonAddBus_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapBusCollectionGeneric == null)
|
||||
var formBusConfig = new FormBusConfig();
|
||||
// TODO Call method AddEvent from fromBusConfig
|
||||
formBusConfig.AddEvent(AddBus);
|
||||
formBusConfig.Show();
|
||||
}
|
||||
|
||||
private void AddBus(DrawingBus bus)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormBus form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
DrawingObjectBus boat = new(bus);
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + boat >= 0)
|
||||
{
|
||||
if (form.SelectedBus == null)
|
||||
{
|
||||
MessageBox.Show("Сначала создайте объект");
|
||||
return;
|
||||
}
|
||||
|
||||
DrawingObjectBus bus = new(form.SelectedBus);
|
||||
|
||||
if (_mapBusCollectionGeneric + bus != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapBusCollectionGeneric.ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRemoveBus_Click(object sender, EventArgs e)
|
||||
|
||||
private void ButtonRemoveBus_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user