Event work
This commit is contained in:
parent
d3e7dd9657
commit
1cf95f8b59
10
AirBomber/AirBomber/AirBomberDelegate.cs
Normal file
10
AirBomber/AirBomber/AirBomberDelegate.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirBomber
|
||||||
|
{
|
||||||
|
public delegate void AirBomberDelegate(DrawningBomber airBomber);
|
||||||
|
}
|
21
AirBomber/AirBomber/FormAirBomberConfig.Designer.cs
generated
21
AirBomber/AirBomber/FormAirBomberConfig.Designer.cs
generated
@ -50,7 +50,7 @@
|
|||||||
this.panelObject = new System.Windows.Forms.Panel();
|
this.panelObject = new System.Windows.Forms.Panel();
|
||||||
this.labelDopColor = new System.Windows.Forms.Label();
|
this.labelDopColor = new System.Windows.Forms.Label();
|
||||||
this.labelBaseColor = new System.Windows.Forms.Label();
|
this.labelBaseColor = new System.Windows.Forms.Label();
|
||||||
this.button1 = new System.Windows.Forms.Button();
|
this.buttonOk = new System.Windows.Forms.Button();
|
||||||
this.button2 = new System.Windows.Forms.Button();
|
this.button2 = new System.Windows.Forms.Button();
|
||||||
this.groupBoxConfig.SuspendLayout();
|
this.groupBoxConfig.SuspendLayout();
|
||||||
this.groupBoxColors.SuspendLayout();
|
this.groupBoxColors.SuspendLayout();
|
||||||
@ -286,14 +286,15 @@
|
|||||||
this.labelBaseColor.Text = "Цвет";
|
this.labelBaseColor.Text = "Цвет";
|
||||||
this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
//
|
//
|
||||||
// button1
|
// buttonOk
|
||||||
//
|
//
|
||||||
this.button1.Location = new System.Drawing.Point(777, 226);
|
this.buttonOk.Location = new System.Drawing.Point(777, 226);
|
||||||
this.button1.Name = "button1";
|
this.buttonOk.Name = "buttonOk";
|
||||||
this.button1.Size = new System.Drawing.Size(105, 38);
|
this.buttonOk.Size = new System.Drawing.Size(105, 38);
|
||||||
this.button1.TabIndex = 3;
|
this.buttonOk.TabIndex = 3;
|
||||||
this.button1.Text = "Добавить";
|
this.buttonOk.Text = "Добавить";
|
||||||
this.button1.UseVisualStyleBackColor = true;
|
this.buttonOk.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonOk.Click += new System.EventHandler(this.ButtonOk_Click);
|
||||||
//
|
//
|
||||||
// button2
|
// button2
|
||||||
//
|
//
|
||||||
@ -310,7 +311,7 @@
|
|||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(1055, 279);
|
this.ClientSize = new System.Drawing.Size(1055, 279);
|
||||||
this.Controls.Add(this.button2);
|
this.Controls.Add(this.button2);
|
||||||
this.Controls.Add(this.button1);
|
this.Controls.Add(this.buttonOk);
|
||||||
this.Controls.Add(this.panelObject);
|
this.Controls.Add(this.panelObject);
|
||||||
this.Controls.Add(this.groupBoxConfig);
|
this.Controls.Add(this.groupBoxConfig);
|
||||||
this.Name = "FormAirBomberConfig";
|
this.Name = "FormAirBomberConfig";
|
||||||
@ -350,7 +351,7 @@
|
|||||||
private Panel panelObject;
|
private Panel panelObject;
|
||||||
private Label labelDopColor;
|
private Label labelDopColor;
|
||||||
private Label labelBaseColor;
|
private Label labelBaseColor;
|
||||||
private Button button1;
|
private Button buttonOk;
|
||||||
private Button button2;
|
private Button button2;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,6 +13,8 @@ namespace AirBomber
|
|||||||
public partial class FormAirBomberConfig : Form
|
public partial class FormAirBomberConfig : Form
|
||||||
{
|
{
|
||||||
DrawningBomber _airBomber = null;
|
DrawningBomber _airBomber = null;
|
||||||
|
|
||||||
|
private event AirBomberDelegate EventAddAirBomber;
|
||||||
public FormAirBomberConfig()
|
public FormAirBomberConfig()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -24,6 +26,8 @@ namespace AirBomber
|
|||||||
panelRed.MouseDown += PanelColor_MouseDown;
|
panelRed.MouseDown += PanelColor_MouseDown;
|
||||||
panelPurple.MouseDown += PanelColor_MouseDown;
|
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||||
|
|
||||||
|
// TODO buttonCancel.Click with lambda
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawAirBomber()
|
private void DrawAirBomber()
|
||||||
@ -35,6 +39,18 @@ namespace AirBomber
|
|||||||
pictureBoxObject.Image = bmp;
|
pictureBoxObject.Image = bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddEvent(AirBomberDelegate ev)
|
||||||
|
{
|
||||||
|
if (EventAddAirBomber == null)
|
||||||
|
{
|
||||||
|
EventAddAirBomber = new AirBomberDelegate(ev);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EventAddAirBomber += ev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
(sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
|
(sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
@ -76,7 +92,7 @@ namespace AirBomber
|
|||||||
|
|
||||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
(sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move |)
|
(sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||||
@ -93,5 +109,11 @@ namespace AirBomber
|
|||||||
}
|
}
|
||||||
DrawAirBomber();
|
DrawAirBomber();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ButtonOk_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
EventAddAirBomber?.Invoke(_airBomber);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,24 +56,9 @@ namespace AirBomber
|
|||||||
|
|
||||||
private void ButtonAddAirBomber_Click(object sender, EventArgs e)
|
private void ButtonAddAirBomber_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
var formAirBomberConfig = new FormAirBomberConfig();
|
||||||
{
|
// TODO Call method AddEvent form formCarConfig
|
||||||
return;
|
formAirBomberConfig.Show();
|
||||||
}
|
|
||||||
FormAirBomber form = new();
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
DrawningObjectBomber airBomber = new(form.SelectedAirBomber);
|
|
||||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + airBomber > -1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект добавлен");
|
|
||||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonRemoveAirBomber_Click(object sender, EventArgs e)
|
private void ButtonRemoveAirBomber_Click(object sender, EventArgs e)
|
||||||
|
Loading…
Reference in New Issue
Block a user