Turner I.A. LabWork05 #5
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AntiAircraftGun
|
||||
{
|
||||
/// <summary>
|
||||
/// Делегат для передачи объекта-орудия
|
||||
/// </summary>
|
||||
/// <param name="antiAircraftGun"></param>
|
||||
public delegate void AntiAircraftGunDelegate(DrawingAntiAircraftGun antiAircraftGun);
|
||||
}
|
@ -19,7 +19,7 @@ namespace AntiAircraftGun
|
||||
/// <summary>
|
||||
/// Цвет зенитнго орудия
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
public Color BodyColor { get; set; }
|
||||
/// <summary>
|
||||
/// Шаг перемещения зенитного орудия
|
||||
/// </summary>
|
||||
|
@ -11,7 +11,7 @@ namespace AntiAircraftGun
|
||||
/// <summary>
|
||||
/// Дополнительный цвет
|
||||
/// </summary>
|
||||
public Color DopColor { get; private set; }
|
||||
public Color DopColor { get; set; }
|
||||
/// <summary>
|
||||
/// Признак наличия башни с орудием
|
||||
/// </summary>
|
||||
|
@ -7,6 +7,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip;
|
||||
|
||||
namespace AntiAircraftGun
|
||||
{
|
||||
@ -19,7 +20,7 @@ namespace AntiAircraftGun
|
||||
/// <summary>
|
||||
/// Событие
|
||||
/// </summary>
|
||||
private event AntiAircraftGunDelegate EventAddAntiAircraftGun;
|
||||
private event Action<DrawingAntiAircraftGun> EventAddAntiAircraftGun;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
@ -34,12 +35,12 @@ namespace AntiAircraftGun
|
||||
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
// TODO buttonCancel.Click with lambda
|
||||
buttonCancel.Click += (sender, e) => { Close(); };
|
||||
}
|
||||
/// <summary>
|
||||
/// Отрисовать орудие
|
||||
/// </summary>
|
||||
private void DrawCar()
|
||||
private void DrawAntiAircraftGun()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
@ -51,11 +52,11 @@ namespace AntiAircraftGun
|
||||
/// Добавление события
|
||||
/// </summary>
|
||||
/// <param name="ev"></param>
|
||||
public void AddEvent(AntiAircraftGunDelegate ev)
|
||||
public void AddEvent(Action<DrawingAntiAircraftGun> ev)
|
||||
{
|
||||
if (EventAddAntiAircraftGun == null)
|
||||
{
|
||||
EventAddAntiAircraftGun = new AntiAircraftGunDelegate(ev);
|
||||
EventAddAntiAircraftGun = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -105,7 +106,7 @@ namespace AntiAircraftGun
|
||||
checkBoxGun.Checked, checkBoxRadar.Checked);
|
||||
break;
|
||||
}
|
||||
DrawCar();
|
||||
DrawAntiAircraftGun();
|
||||
}
|
||||
/// <summary>
|
||||
/// Отправляем цвет с панели
|
||||
@ -132,14 +133,19 @@ namespace AntiAircraftGun
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <summary>labelModifiedObject
|
||||
/// Принимаем основной цвет
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LableBaseColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
// TODO Call method from object _antiAircraftGun and set color
|
||||
if (_antiAircraftGun == null || !e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
_antiAircraftGun.AntiAircraftGun.BodyColor = (Color)e.Data.GetData(typeof(Color));
|
||||
DrawAntiAircraftGun();
|
||||
}
|
||||
/// <summary>
|
||||
/// Принимаем дополнительный цвет
|
||||
@ -148,7 +154,15 @@ namespace AntiAircraftGun
|
||||
/// <param name="e"></param>
|
||||
private void LableDopColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
// TODO Call method from object _car if _antiAircraftGun is DrawningSportCar and set dop color
|
||||
if (_antiAircraftGun == null || _antiAircraftGun.GetType() != typeof(DrawingUpdateAntiAircraftGun) || !e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_antiAircraftGun.AntiAircraftGun is EntityUpdateAntiAircraftGun upGun)
|
||||
{
|
||||
upGun.DopColor = (Color)e.Data.GetData(typeof(Color));
|
||||
}
|
||||
DrawAntiAircraftGun();
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление орудия
|
||||
|
@ -188,6 +188,7 @@
|
||||
//
|
||||
// groupBoxMaps
|
||||
//
|
||||
this.groupBoxMaps.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupBoxMaps.Controls.Add(this.listBoxMaps);
|
||||
this.groupBoxMaps.Controls.Add(this.buttonDeleteMap);
|
||||
this.groupBoxMaps.Controls.Add(this.buttonAddMap);
|
||||
@ -195,7 +196,7 @@
|
||||
this.groupBoxMaps.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.groupBoxMaps.Location = new System.Drawing.Point(580, 26);
|
||||
this.groupBoxMaps.Name = "groupBoxMaps";
|
||||
this.groupBoxMaps.Size = new System.Drawing.Size(226, 277);
|
||||
this.groupBoxMaps.Size = new System.Drawing.Size(220, 277);
|
||||
this.groupBoxMaps.TabIndex = 17;
|
||||
this.groupBoxMaps.TabStop = false;
|
||||
this.groupBoxMaps.Text = "Карты";
|
||||
|
@ -110,9 +110,26 @@ namespace AntiAircraftGun
|
||||
private void ButtonAddAntiAircraftGun_Click(object sender, EventArgs e)
|
||||
{
|
||||
var formAntiAircraftGunConfig = new FormAntiAircraftGunConfig();
|
||||
// TODO Call method AddEvent from formAntiAircraftGunConfig
|
||||
formAntiAircraftGunConfig.AddEvent(AddAntiAircraftGun);
|
||||
formAntiAircraftGunConfig.Show();
|
||||
}
|
||||
private void AddAntiAircraftGun(DrawingAntiAircraftGun drawingAntiAircraftGuns)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DrawingObjectAntiAircraftGun antiAircraftGun = new DrawingObjectAntiAircraftGun(drawingAntiAircraftGuns);
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + antiAircraftGun != -1)
|
||||
{
|
||||
MessageBox.Show("Object added");
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Cant add object");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user