Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 54c2da98b6 | |||
| e396498be1 | |||
| 3ac1a746a0 | |||
| eb8186c60a | |||
| 915ad90162 | |||
| 5b82c75d8d | |||
| cb9551d76e |
@@ -41,7 +41,7 @@ namespace AirBomber.Generics
|
|||||||
public static bool operator -(BomberGenericCollection<T, U> collect, int
|
public static bool operator -(BomberGenericCollection<T, U> collect, int
|
||||||
pos)
|
pos)
|
||||||
{
|
{
|
||||||
T obj = collect._collection.Get(pos);
|
T? obj = collect._collection[pos];
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -51,7 +51,7 @@ namespace AirBomber.Generics
|
|||||||
|
|
||||||
public U? GetU(int pos)
|
public U? GetU(int pos)
|
||||||
{
|
{
|
||||||
return (U?)_collection.Get(pos)?.GetMoveableObject;
|
return (U?)_collection[pos]?.GetMoveableObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap ShowBomber()
|
public Bitmap ShowBomber()
|
||||||
@@ -84,16 +84,13 @@ namespace AirBomber.Generics
|
|||||||
|
|
||||||
private void DrawObjects(Graphics g)
|
private void DrawObjects(Graphics g)
|
||||||
{
|
{
|
||||||
int numColumns = _pictureWidth / _placeSizeWidth;
|
foreach (var air in _collection.GetPlane())
|
||||||
int numRows = _pictureHeight / _placeSizeHeight;
|
|
||||||
|
|
||||||
for (int i = 0; i < _collection.Count; i++)
|
|
||||||
{
|
{
|
||||||
DrawningBomber air = _collection.Get(i);
|
|
||||||
if (air != null)
|
if (air != null)
|
||||||
{
|
{
|
||||||
int row = i / numColumns;
|
// Вычисляем позицию объекта
|
||||||
int column = numColumns - 1 - (i % numColumns);
|
int row = _collection.GetPlane().ToList().IndexOf(air) / (_pictureWidth / _placeSizeWidth);
|
||||||
|
int column = (_pictureWidth / _placeSizeWidth) - 1 - (_collection.GetPlane().ToList().IndexOf(air) % (_pictureWidth / _placeSizeWidth));
|
||||||
int x = column * _placeSizeWidth;
|
int x = column * _placeSizeWidth;
|
||||||
int y = row * _placeSizeHeight;
|
int y = row * _placeSizeHeight;
|
||||||
|
|
||||||
|
|||||||
69
AirBomber/BomberGenericStorage.cs
Normal file
69
AirBomber/BomberGenericStorage.cs
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using AirBomber.DrawningObjects;
|
||||||
|
using AirBomber.MovementStrategy;
|
||||||
|
|
||||||
|
namespace AirBomber.Generics
|
||||||
|
{
|
||||||
|
internal class BomberGenericStorage
|
||||||
|
{
|
||||||
|
readonly Dictionary<string, BomberGenericCollection<DrawningBomber, DrawningObjectBomber>> _bomberStorage;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Возвращение списка названий наборов
|
||||||
|
/// </summary>
|
||||||
|
public List<string> Keys => _bomberStorage.Keys.ToList();
|
||||||
|
/// <summary>
|
||||||
|
/// Ширина окна отрисовки
|
||||||
|
/// </summary>
|
||||||
|
private readonly int _pictureWidth;
|
||||||
|
/// <summary>
|
||||||
|
/// Высота окна отрисовки
|
||||||
|
/// </summary>
|
||||||
|
private readonly int _pictureHeight;
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pictureWidth"></param>
|
||||||
|
/// <param name="pictureHeight"></param>
|
||||||
|
public BomberGenericStorage(int pictureWidth, int pictureHeight)
|
||||||
|
{
|
||||||
|
_bomberStorage = new Dictionary<string, BomberGenericCollection<DrawningBomber, DrawningObjectBomber>>();
|
||||||
|
_pictureWidth = pictureWidth;
|
||||||
|
_pictureHeight = pictureHeight;
|
||||||
|
}
|
||||||
|
public void AddSet(string name)
|
||||||
|
{
|
||||||
|
// TODO Прописать логику для добавления
|
||||||
|
if (!_bomberStorage.ContainsKey(name))
|
||||||
|
{
|
||||||
|
var bomberCollection = new BomberGenericCollection<DrawningBomber, DrawningObjectBomber>(_pictureWidth, _pictureHeight);
|
||||||
|
_bomberStorage.Add(name, bomberCollection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DelSet(string name)
|
||||||
|
{
|
||||||
|
// TODO Прописать логику для удаления
|
||||||
|
if (_bomberStorage.ContainsKey(name))
|
||||||
|
{
|
||||||
|
_bomberStorage.Remove(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public BomberGenericCollection<DrawningBomber, DrawningObjectBomber>? this[string ind]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
// TODO Продумать логику получения набора
|
||||||
|
if (_bomberStorage.ContainsKey(ind))
|
||||||
|
{
|
||||||
|
return _bomberStorage[ind];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -65,5 +65,12 @@ namespace AirBomber.DrawningObjects
|
|||||||
}
|
}
|
||||||
base.DrawBomber(g);
|
base.DrawBomber(g);
|
||||||
}
|
}
|
||||||
|
public void setAddColor(Color color)
|
||||||
|
{
|
||||||
|
if (EntityBomber is EntityAirBomber airbomber)
|
||||||
|
{
|
||||||
|
airbomber.setAddColor(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ namespace AirBomber.DrawningObjects
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
|
Brush bodycolor = new SolidBrush(EntityBomber.BodyColor);
|
||||||
//отрисовка крыла 1
|
//отрисовка крыла 1
|
||||||
GraphicsPath fly_1 = new GraphicsPath();
|
GraphicsPath fly_1 = new GraphicsPath();
|
||||||
fly_1.AddLine(_startPosX + 80, _startPosY + 2, _startPosX + 80, _startPosY + 80);
|
fly_1.AddLine(_startPosX + 80, _startPosY + 2, _startPosX + 80, _startPosY + 80);
|
||||||
@@ -139,7 +140,7 @@ namespace AirBomber.DrawningObjects
|
|||||||
g.FillPath(Brushes.Black, treygol);
|
g.FillPath(Brushes.Black, treygol);
|
||||||
g.DrawPath(Pens.Black, treygol);
|
g.DrawPath(Pens.Black, treygol);
|
||||||
//отрисовка корпуса
|
//отрисовка корпуса
|
||||||
g.DrawRectangle(pen, _startPosX + 30, _startPosY + 80, 120, 25);
|
g.FillRectangle(bodycolor, _startPosX + 30, _startPosY + 80, 120, 25);
|
||||||
//отрисовка крыла 2
|
//отрисовка крыла 2
|
||||||
GraphicsPath fly_2 = new GraphicsPath();
|
GraphicsPath fly_2 = new GraphicsPath();
|
||||||
fly_2.AddLine(_startPosX + 80, _startPosY + 105, _startPosX + 80, _startPosY + 185);
|
fly_2.AddLine(_startPosX + 80, _startPosY + 105, _startPosX + 80, _startPosY + 185);
|
||||||
@@ -161,5 +162,9 @@ namespace AirBomber.DrawningObjects
|
|||||||
wing_2.CloseFigure();
|
wing_2.CloseFigure();
|
||||||
g.DrawPath(Pens.Black, wing_2);
|
g.DrawPath(Pens.Black, wing_2);
|
||||||
}
|
}
|
||||||
|
public void setColor(Color color)
|
||||||
|
{
|
||||||
|
EntityBomber.setColor(color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,9 @@
|
|||||||
Toplivo = toplivo;
|
Toplivo = toplivo;
|
||||||
Rocket = ropcket;
|
Rocket = ropcket;
|
||||||
}
|
}
|
||||||
|
public void setAddColor(Color color)
|
||||||
|
{
|
||||||
|
DopColor = color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace AirBomber.Entities
|
|||||||
{
|
{
|
||||||
public int Speed { get; private set; }
|
public int Speed { get; private set; }
|
||||||
public double Weight { get; private set; }
|
public double Weight { get; private set; }
|
||||||
public Color BodyColor { get; private set; }
|
public Color BodyColor { get; set; }
|
||||||
public double Step => (double)Speed * 100 / Weight;
|
public double Step => (double)Speed * 100 / Weight;
|
||||||
|
|
||||||
public EntityBomber(int speed, double weight, Color bodycolor)
|
public EntityBomber(int speed, double weight, Color bodycolor)
|
||||||
@@ -19,5 +19,9 @@ namespace AirBomber.Entities
|
|||||||
Weight = weight;
|
Weight = weight;
|
||||||
BodyColor = bodycolor;
|
BodyColor = bodycolor;
|
||||||
}
|
}
|
||||||
|
public void setColor(Color color)
|
||||||
|
{
|
||||||
|
BodyColor = color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
74
AirBomber/FormBomberCollection.Designer.cs
generated
74
AirBomber/FormBomberCollection.Designer.cs
generated
@@ -29,31 +29,88 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
Tools = new GroupBox();
|
Tools = new GroupBox();
|
||||||
|
Kit = new GroupBox();
|
||||||
|
RemoveKit = new Button();
|
||||||
|
AddKit = new Button();
|
||||||
|
KitTextbox = new TextBox();
|
||||||
|
listBoxStorages = new ListBox();
|
||||||
ButtonRefreshCollection = new Button();
|
ButtonRefreshCollection = new Button();
|
||||||
ButtonRemoveBomber = new Button();
|
ButtonRemoveBomber = new Button();
|
||||||
ButtonAddBomber = new Button();
|
ButtonAddBomber = new Button();
|
||||||
MessageBoxBomber = new TextBox();
|
MessageBoxBomber = new TextBox();
|
||||||
PicBoxBomberCollection = new PictureBox();
|
PicBoxBomberCollection = new PictureBox();
|
||||||
Tools.SuspendLayout();
|
Tools.SuspendLayout();
|
||||||
|
Kit.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)PicBoxBomberCollection).BeginInit();
|
((System.ComponentModel.ISupportInitialize)PicBoxBomberCollection).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// Tools
|
// Tools
|
||||||
//
|
//
|
||||||
|
Tools.Controls.Add(Kit);
|
||||||
Tools.Controls.Add(ButtonRefreshCollection);
|
Tools.Controls.Add(ButtonRefreshCollection);
|
||||||
Tools.Controls.Add(ButtonRemoveBomber);
|
Tools.Controls.Add(ButtonRemoveBomber);
|
||||||
Tools.Controls.Add(ButtonAddBomber);
|
Tools.Controls.Add(ButtonAddBomber);
|
||||||
Tools.Controls.Add(MessageBoxBomber);
|
Tools.Controls.Add(MessageBoxBomber);
|
||||||
Tools.Location = new Point(538, 5);
|
Tools.Location = new Point(538, 5);
|
||||||
Tools.Name = "Tools";
|
Tools.Name = "Tools";
|
||||||
Tools.Size = new Size(250, 443);
|
Tools.Size = new Size(250, 556);
|
||||||
Tools.TabIndex = 0;
|
Tools.TabIndex = 0;
|
||||||
Tools.TabStop = false;
|
Tools.TabStop = false;
|
||||||
Tools.Text = "Инструменты";
|
Tools.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
|
// Kit
|
||||||
|
//
|
||||||
|
Kit.Controls.Add(RemoveKit);
|
||||||
|
Kit.Controls.Add(AddKit);
|
||||||
|
Kit.Controls.Add(KitTextbox);
|
||||||
|
Kit.Controls.Add(listBoxStorages);
|
||||||
|
Kit.Location = new Point(17, 33);
|
||||||
|
Kit.Name = "Kit";
|
||||||
|
Kit.Size = new Size(227, 282);
|
||||||
|
Kit.TabIndex = 4;
|
||||||
|
Kit.TabStop = false;
|
||||||
|
Kit.Text = "Наборы";
|
||||||
|
//
|
||||||
|
// RemoveKit
|
||||||
|
//
|
||||||
|
RemoveKit.Location = new Point(11, 231);
|
||||||
|
RemoveKit.Name = "RemoveKit";
|
||||||
|
RemoveKit.Size = new Size(193, 36);
|
||||||
|
RemoveKit.TabIndex = 3;
|
||||||
|
RemoveKit.Text = "Удалить набор";
|
||||||
|
RemoveKit.UseVisualStyleBackColor = true;
|
||||||
|
RemoveKit.Click += RemoveKit_Click;
|
||||||
|
//
|
||||||
|
// AddKit
|
||||||
|
//
|
||||||
|
AddKit.Location = new Point(11, 63);
|
||||||
|
AddKit.Name = "AddKit";
|
||||||
|
AddKit.Size = new Size(193, 36);
|
||||||
|
AddKit.TabIndex = 2;
|
||||||
|
AddKit.Text = "Добавить набор";
|
||||||
|
AddKit.UseVisualStyleBackColor = true;
|
||||||
|
AddKit.Click += AddKit_Click;
|
||||||
|
//
|
||||||
|
// KitTextbox
|
||||||
|
//
|
||||||
|
KitTextbox.Location = new Point(15, 30);
|
||||||
|
KitTextbox.Name = "KitTextbox";
|
||||||
|
KitTextbox.Size = new Size(189, 27);
|
||||||
|
KitTextbox.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// listBoxStorages
|
||||||
|
//
|
||||||
|
listBoxStorages.FormattingEnabled = true;
|
||||||
|
listBoxStorages.ItemHeight = 20;
|
||||||
|
listBoxStorages.Location = new Point(11, 109);
|
||||||
|
listBoxStorages.Name = "listBoxStorages";
|
||||||
|
listBoxStorages.Size = new Size(193, 104);
|
||||||
|
listBoxStorages.TabIndex = 0;
|
||||||
|
listBoxStorages.SelectedIndexChanged += ListBoxObjects_SelectedIndexChanged;
|
||||||
|
//
|
||||||
// ButtonRefreshCollection
|
// ButtonRefreshCollection
|
||||||
//
|
//
|
||||||
ButtonRefreshCollection.Location = new Point(25, 243);
|
ButtonRefreshCollection.Location = new Point(28, 481);
|
||||||
ButtonRefreshCollection.Name = "ButtonRefreshCollection";
|
ButtonRefreshCollection.Name = "ButtonRefreshCollection";
|
||||||
ButtonRefreshCollection.Size = new Size(193, 37);
|
ButtonRefreshCollection.Size = new Size(193, 37);
|
||||||
ButtonRefreshCollection.TabIndex = 3;
|
ButtonRefreshCollection.TabIndex = 3;
|
||||||
@@ -63,7 +120,7 @@
|
|||||||
//
|
//
|
||||||
// ButtonRemoveBomber
|
// ButtonRemoveBomber
|
||||||
//
|
//
|
||||||
ButtonRemoveBomber.Location = new Point(25, 178);
|
ButtonRemoveBomber.Location = new Point(28, 416);
|
||||||
ButtonRemoveBomber.Name = "ButtonRemoveBomber";
|
ButtonRemoveBomber.Name = "ButtonRemoveBomber";
|
||||||
ButtonRemoveBomber.Size = new Size(193, 41);
|
ButtonRemoveBomber.Size = new Size(193, 41);
|
||||||
ButtonRemoveBomber.TabIndex = 2;
|
ButtonRemoveBomber.TabIndex = 2;
|
||||||
@@ -73,7 +130,7 @@
|
|||||||
//
|
//
|
||||||
// ButtonAddBomber
|
// ButtonAddBomber
|
||||||
//
|
//
|
||||||
ButtonAddBomber.Location = new Point(25, 42);
|
ButtonAddBomber.Location = new Point(28, 321);
|
||||||
ButtonAddBomber.Name = "ButtonAddBomber";
|
ButtonAddBomber.Name = "ButtonAddBomber";
|
||||||
ButtonAddBomber.Size = new Size(193, 41);
|
ButtonAddBomber.Size = new Size(193, 41);
|
||||||
ButtonAddBomber.TabIndex = 1;
|
ButtonAddBomber.TabIndex = 1;
|
||||||
@@ -83,7 +140,7 @@
|
|||||||
//
|
//
|
||||||
// MessageBoxBomber
|
// MessageBoxBomber
|
||||||
//
|
//
|
||||||
MessageBoxBomber.Location = new Point(25, 109);
|
MessageBoxBomber.Location = new Point(28, 368);
|
||||||
MessageBoxBomber.Name = "MessageBoxBomber";
|
MessageBoxBomber.Name = "MessageBoxBomber";
|
||||||
MessageBoxBomber.Size = new Size(193, 27);
|
MessageBoxBomber.Size = new Size(193, 27);
|
||||||
MessageBoxBomber.TabIndex = 0;
|
MessageBoxBomber.TabIndex = 0;
|
||||||
@@ -107,6 +164,8 @@
|
|||||||
Text = "FormBomberCollection";
|
Text = "FormBomberCollection";
|
||||||
Tools.ResumeLayout(false);
|
Tools.ResumeLayout(false);
|
||||||
Tools.PerformLayout();
|
Tools.PerformLayout();
|
||||||
|
Kit.ResumeLayout(false);
|
||||||
|
Kit.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)PicBoxBomberCollection).EndInit();
|
((System.ComponentModel.ISupportInitialize)PicBoxBomberCollection).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
@@ -119,5 +178,10 @@
|
|||||||
private Button ButtonRefreshCollection;
|
private Button ButtonRefreshCollection;
|
||||||
private Button ButtonRemoveBomber;
|
private Button ButtonRemoveBomber;
|
||||||
private Button ButtonAddBomber;
|
private Button ButtonAddBomber;
|
||||||
|
private GroupBox Kit;
|
||||||
|
private ListBox listBoxStorages;
|
||||||
|
private Button RemoveKit;
|
||||||
|
private Button AddKit;
|
||||||
|
private TextBox KitTextbox;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,28 +15,68 @@ namespace AirBomber
|
|||||||
{
|
{
|
||||||
public partial class FormBomberCollection : Form
|
public partial class FormBomberCollection : Form
|
||||||
{
|
{
|
||||||
private readonly BomberGenericCollection<DrawningBomber, DrawningObjectBomber> _bomber;
|
private readonly BomberGenericStorage _bomber;
|
||||||
|
|
||||||
public FormBomberCollection()
|
public FormBomberCollection()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_bomber = new BomberGenericCollection<DrawningBomber, DrawningObjectBomber>(PicBoxBomberCollection.Width, PicBoxBomberCollection.Height);
|
_bomber = new BomberGenericStorage(PicBoxBomberCollection.Width, PicBoxBomberCollection.Height);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReloadObjects()
|
||||||
|
{
|
||||||
|
int index = listBoxStorages.SelectedIndex;
|
||||||
|
listBoxStorages.Items.Clear();
|
||||||
|
for (int i = 0; i < _bomber.Keys.Count; i++)
|
||||||
|
{
|
||||||
|
listBoxStorages.Items.Add(_bomber.Keys[i]);
|
||||||
|
}
|
||||||
|
if (listBoxStorages.Items.Count > 0 && (index == -1 || index
|
||||||
|
>= listBoxStorages.Items.Count))
|
||||||
|
{
|
||||||
|
listBoxStorages.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
else if (listBoxStorages.Items.Count > 0 && index > -1 &&
|
||||||
|
index < listBoxStorages.Items.Count)
|
||||||
|
{
|
||||||
|
listBoxStorages.SelectedIndex = index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
PicBoxBomberCollection.Image = _bomber.ShowBomber();
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _bomber[listBoxStorages.SelectedItem.ToString() ??
|
||||||
|
string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PicBoxBomberCollection.Image = obj.ShowBomber();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonAddBomber_Click(object sender, EventArgs e)
|
private void ButtonAddBomber_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
FormAirBomber form = new FormAirBomber();
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
{
|
||||||
if (_bomber + form.SelectedBomber != 1)
|
return;
|
||||||
|
}
|
||||||
|
var formBomberConfig = new FormBomberConfig();
|
||||||
|
|
||||||
|
formBomberConfig.AddEvent(bomber =>
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex != -1)
|
||||||
|
{
|
||||||
|
var obj = _bomber[listBoxStorages.SelectedItem?.ToString() ?? string.Empty];
|
||||||
|
if (obj != null)
|
||||||
|
{
|
||||||
|
if (obj + bomber != 1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
PicBoxBomberCollection.Image = _bomber.ShowBomber();
|
PicBoxBomberCollection.Image = obj.ShowBomber();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -44,23 +84,68 @@ namespace AirBomber
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
formBomberConfig.Show();
|
||||||
|
}
|
||||||
|
|
||||||
private void ButtonRemoveBomber_Click(object sender, EventArgs e)
|
private void ButtonRemoveBomber_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _bomber[listBoxStorages.SelectedItem.ToString() ??
|
||||||
|
string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||||
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pos = Convert.ToInt32(MessageBoxBomber.Text);
|
int pos = Convert.ToInt32(MessageBoxBomber.Text);
|
||||||
if (_bomber - pos != null)
|
if (obj - pos != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
PicBoxBomberCollection.Image = _bomber.ShowBomber();
|
PicBoxBomberCollection.Image = obj.ShowBomber();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
MessageBox.Show("Не удалось удалить объект");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddKit_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(KitTextbox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не все данные заполнены", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_bomber.AddSet(KitTextbox.Text);
|
||||||
|
ReloadObjects();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveKit_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
_bomber.DelSet(listBoxStorages.SelectedItem.ToString()
|
||||||
|
?? string.Empty);
|
||||||
|
ReloadObjects();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ListBoxObjects_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
PicBoxBomberCollection.Image =
|
||||||
|
_bomber[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowBomber();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
363
AirBomber/FormBomberConfig.Designer.cs
generated
Normal file
363
AirBomber/FormBomberConfig.Designer.cs
generated
Normal file
@@ -0,0 +1,363 @@
|
|||||||
|
namespace AirBomber
|
||||||
|
{
|
||||||
|
partial class FormBomberConfig
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
hardLabel = new Label();
|
||||||
|
easyLabel = new Label();
|
||||||
|
colorGroupBox = new GroupBox();
|
||||||
|
purplePanel = new Panel();
|
||||||
|
blackPanel = new Panel();
|
||||||
|
greyPanel = new Panel();
|
||||||
|
whitePanel = new Panel();
|
||||||
|
yellowPanel = new Panel();
|
||||||
|
bluePanel = new Panel();
|
||||||
|
greenPanel = new Panel();
|
||||||
|
redPanel = new Panel();
|
||||||
|
rocketCheckBox = new CheckBox();
|
||||||
|
bakCheckBox = new CheckBox();
|
||||||
|
WeightNumericUpDown = new NumericUpDown();
|
||||||
|
SpeedNumericUpDown = new NumericUpDown();
|
||||||
|
weight = new Label();
|
||||||
|
speed = new Label();
|
||||||
|
PanelColor = new Panel();
|
||||||
|
labelDopColor = new Label();
|
||||||
|
labelColor = new Label();
|
||||||
|
pictureBoxConfig = new PictureBox();
|
||||||
|
AddButton = new Button();
|
||||||
|
buttonStop = new Button();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
colorGroupBox.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)WeightNumericUpDown).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)SpeedNumericUpDown).BeginInit();
|
||||||
|
PanelColor.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxConfig).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Controls.Add(hardLabel);
|
||||||
|
groupBox1.Controls.Add(easyLabel);
|
||||||
|
groupBox1.Controls.Add(colorGroupBox);
|
||||||
|
groupBox1.Controls.Add(rocketCheckBox);
|
||||||
|
groupBox1.Controls.Add(bakCheckBox);
|
||||||
|
groupBox1.Controls.Add(WeightNumericUpDown);
|
||||||
|
groupBox1.Controls.Add(SpeedNumericUpDown);
|
||||||
|
groupBox1.Controls.Add(weight);
|
||||||
|
groupBox1.Controls.Add(speed);
|
||||||
|
groupBox1.Location = new Point(12, 12);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Size = new Size(636, 296);
|
||||||
|
groupBox1.TabIndex = 0;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "Параметры";
|
||||||
|
//
|
||||||
|
// hardLabel
|
||||||
|
//
|
||||||
|
hardLabel.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
hardLabel.Location = new Point(421, 228);
|
||||||
|
hardLabel.Name = "hardLabel";
|
||||||
|
hardLabel.Size = new Size(127, 47);
|
||||||
|
hardLabel.TabIndex = 8;
|
||||||
|
hardLabel.Text = "Продвинутый";
|
||||||
|
hardLabel.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
hardLabel.MouseDown += LableObject_MouseDown;
|
||||||
|
//
|
||||||
|
// easyLabel
|
||||||
|
//
|
||||||
|
easyLabel.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
easyLabel.Location = new Point(266, 228);
|
||||||
|
easyLabel.Name = "easyLabel";
|
||||||
|
easyLabel.Size = new Size(116, 47);
|
||||||
|
easyLabel.TabIndex = 7;
|
||||||
|
easyLabel.Text = "Простой";
|
||||||
|
easyLabel.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
easyLabel.MouseDown += LableObject_MouseDown;
|
||||||
|
//
|
||||||
|
// colorGroupBox
|
||||||
|
//
|
||||||
|
colorGroupBox.Controls.Add(purplePanel);
|
||||||
|
colorGroupBox.Controls.Add(blackPanel);
|
||||||
|
colorGroupBox.Controls.Add(greyPanel);
|
||||||
|
colorGroupBox.Controls.Add(whitePanel);
|
||||||
|
colorGroupBox.Controls.Add(yellowPanel);
|
||||||
|
colorGroupBox.Controls.Add(bluePanel);
|
||||||
|
colorGroupBox.Controls.Add(greenPanel);
|
||||||
|
colorGroupBox.Controls.Add(redPanel);
|
||||||
|
colorGroupBox.Location = new Point(248, 34);
|
||||||
|
colorGroupBox.Name = "colorGroupBox";
|
||||||
|
colorGroupBox.Size = new Size(315, 176);
|
||||||
|
colorGroupBox.TabIndex = 6;
|
||||||
|
colorGroupBox.TabStop = false;
|
||||||
|
colorGroupBox.Text = "Цвета";
|
||||||
|
//
|
||||||
|
// purplePanel
|
||||||
|
//
|
||||||
|
purplePanel.BackColor = Color.Purple;
|
||||||
|
purplePanel.Location = new Point(250, 103);
|
||||||
|
purplePanel.Name = "purplePanel";
|
||||||
|
purplePanel.Size = new Size(50, 50);
|
||||||
|
purplePanel.TabIndex = 3;
|
||||||
|
purplePanel.MouseClick += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// blackPanel
|
||||||
|
//
|
||||||
|
blackPanel.BackColor = Color.Black;
|
||||||
|
blackPanel.Location = new Point(174, 103);
|
||||||
|
blackPanel.Name = "blackPanel";
|
||||||
|
blackPanel.Size = new Size(50, 50);
|
||||||
|
blackPanel.TabIndex = 4;
|
||||||
|
blackPanel.MouseClick += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// greyPanel
|
||||||
|
//
|
||||||
|
greyPanel.BackColor = Color.Silver;
|
||||||
|
greyPanel.Location = new Point(97, 103);
|
||||||
|
greyPanel.Name = "greyPanel";
|
||||||
|
greyPanel.Size = new Size(50, 50);
|
||||||
|
greyPanel.TabIndex = 5;
|
||||||
|
greyPanel.MouseClick += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// whitePanel
|
||||||
|
//
|
||||||
|
whitePanel.BackColor = Color.White;
|
||||||
|
whitePanel.Location = new Point(18, 103);
|
||||||
|
whitePanel.Name = "whitePanel";
|
||||||
|
whitePanel.Size = new Size(50, 50);
|
||||||
|
whitePanel.TabIndex = 2;
|
||||||
|
whitePanel.MouseClick += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// yellowPanel
|
||||||
|
//
|
||||||
|
yellowPanel.BackColor = Color.Yellow;
|
||||||
|
yellowPanel.Location = new Point(250, 37);
|
||||||
|
yellowPanel.Name = "yellowPanel";
|
||||||
|
yellowPanel.Size = new Size(50, 50);
|
||||||
|
yellowPanel.TabIndex = 1;
|
||||||
|
yellowPanel.MouseClick += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// bluePanel
|
||||||
|
//
|
||||||
|
bluePanel.BackColor = Color.Blue;
|
||||||
|
bluePanel.Location = new Point(174, 37);
|
||||||
|
bluePanel.Name = "bluePanel";
|
||||||
|
bluePanel.Size = new Size(50, 50);
|
||||||
|
bluePanel.TabIndex = 1;
|
||||||
|
bluePanel.MouseClick += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// greenPanel
|
||||||
|
//
|
||||||
|
greenPanel.BackColor = Color.FromArgb(0, 192, 0);
|
||||||
|
greenPanel.Location = new Point(97, 37);
|
||||||
|
greenPanel.Name = "greenPanel";
|
||||||
|
greenPanel.Size = new Size(50, 50);
|
||||||
|
greenPanel.TabIndex = 1;
|
||||||
|
greenPanel.MouseClick += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// redPanel
|
||||||
|
//
|
||||||
|
redPanel.BackColor = Color.Red;
|
||||||
|
redPanel.Location = new Point(18, 37);
|
||||||
|
redPanel.Name = "redPanel";
|
||||||
|
redPanel.Size = new Size(50, 50);
|
||||||
|
redPanel.TabIndex = 0;
|
||||||
|
redPanel.MouseClick += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// rocketCheckBox
|
||||||
|
//
|
||||||
|
rocketCheckBox.AutoSize = true;
|
||||||
|
rocketCheckBox.Location = new Point(15, 200);
|
||||||
|
rocketCheckBox.Name = "rocketCheckBox";
|
||||||
|
rocketCheckBox.Size = new Size(196, 24);
|
||||||
|
rocketCheckBox.TabIndex = 5;
|
||||||
|
rocketCheckBox.Text = "Признак наличия ракет";
|
||||||
|
rocketCheckBox.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// bakCheckBox
|
||||||
|
//
|
||||||
|
bakCheckBox.AutoSize = true;
|
||||||
|
bakCheckBox.Location = new Point(15, 152);
|
||||||
|
bakCheckBox.Name = "bakCheckBox";
|
||||||
|
bakCheckBox.Size = new Size(199, 24);
|
||||||
|
bakCheckBox.TabIndex = 4;
|
||||||
|
bakCheckBox.Text = "Признак наличия баков";
|
||||||
|
bakCheckBox.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// WeightNumericUpDown
|
||||||
|
//
|
||||||
|
WeightNumericUpDown.Location = new Point(113, 82);
|
||||||
|
WeightNumericUpDown.Name = "WeightNumericUpDown";
|
||||||
|
WeightNumericUpDown.Size = new Size(83, 27);
|
||||||
|
WeightNumericUpDown.TabIndex = 3;
|
||||||
|
WeightNumericUpDown.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// SpeedNumericUpDown
|
||||||
|
//
|
||||||
|
SpeedNumericUpDown.Location = new Point(113, 34);
|
||||||
|
SpeedNumericUpDown.Name = "SpeedNumericUpDown";
|
||||||
|
SpeedNumericUpDown.Size = new Size(83, 27);
|
||||||
|
SpeedNumericUpDown.TabIndex = 2;
|
||||||
|
SpeedNumericUpDown.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// weight
|
||||||
|
//
|
||||||
|
weight.AutoSize = true;
|
||||||
|
weight.Location = new Point(15, 84);
|
||||||
|
weight.Name = "weight";
|
||||||
|
weight.Size = new Size(40, 20);
|
||||||
|
weight.TabIndex = 1;
|
||||||
|
weight.Text = "Вес: ";
|
||||||
|
//
|
||||||
|
// speed
|
||||||
|
//
|
||||||
|
speed.AutoSize = true;
|
||||||
|
speed.Location = new Point(15, 41);
|
||||||
|
speed.Name = "speed";
|
||||||
|
speed.Size = new Size(80, 20);
|
||||||
|
speed.TabIndex = 0;
|
||||||
|
speed.Text = "Скорость: ";
|
||||||
|
//
|
||||||
|
// PanelColor
|
||||||
|
//
|
||||||
|
PanelColor.AllowDrop = true;
|
||||||
|
PanelColor.Controls.Add(labelDopColor);
|
||||||
|
PanelColor.Controls.Add(labelColor);
|
||||||
|
PanelColor.Controls.Add(pictureBoxConfig);
|
||||||
|
PanelColor.Location = new Point(654, 12);
|
||||||
|
PanelColor.Name = "PanelColor";
|
||||||
|
PanelColor.Size = new Size(304, 275);
|
||||||
|
PanelColor.TabIndex = 2;
|
||||||
|
PanelColor.DragDrop += PanelObject_DragDrop;
|
||||||
|
PanelColor.DragEnter += PanelObject_DragEnter;
|
||||||
|
PanelColor.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// labelDopColor
|
||||||
|
//
|
||||||
|
labelDopColor.AllowDrop = true;
|
||||||
|
labelDopColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelDopColor.Location = new Point(152, 12);
|
||||||
|
labelDopColor.Name = "labelDopColor";
|
||||||
|
labelDopColor.Size = new Size(144, 34);
|
||||||
|
labelDopColor.TabIndex = 2;
|
||||||
|
labelDopColor.Text = "Доп. цвет";
|
||||||
|
labelDopColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelDopColor.DragDrop += labelAddBoxColor_DragDrop;
|
||||||
|
labelDopColor.DragEnter += LabelColor_DragEnter;
|
||||||
|
labelDopColor.MouseDown += LableObject_MouseDown;
|
||||||
|
//
|
||||||
|
// labelColor
|
||||||
|
//
|
||||||
|
labelColor.AllowDrop = true;
|
||||||
|
labelColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelColor.Location = new Point(12, 12);
|
||||||
|
labelColor.Name = "labelColor";
|
||||||
|
labelColor.Size = new Size(134, 34);
|
||||||
|
labelColor.TabIndex = 1;
|
||||||
|
labelColor.Text = "Цвет";
|
||||||
|
labelColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelColor.DragDrop += LabelBaseColor_DragDrop;
|
||||||
|
labelColor.DragEnter += LabelColor_DragEnter;
|
||||||
|
labelColor.MouseDown += LableObject_MouseDown;
|
||||||
|
//
|
||||||
|
// pictureBoxConfig
|
||||||
|
//
|
||||||
|
pictureBoxConfig.Location = new Point(12, 54);
|
||||||
|
pictureBoxConfig.Name = "pictureBoxConfig";
|
||||||
|
pictureBoxConfig.Size = new Size(284, 209);
|
||||||
|
pictureBoxConfig.TabIndex = 0;
|
||||||
|
pictureBoxConfig.TabStop = false;
|
||||||
|
//
|
||||||
|
// AddButton
|
||||||
|
//
|
||||||
|
AddButton.Location = new Point(661, 293);
|
||||||
|
AddButton.Name = "AddButton";
|
||||||
|
AddButton.Size = new Size(139, 36);
|
||||||
|
AddButton.TabIndex = 3;
|
||||||
|
AddButton.Text = "Добавить";
|
||||||
|
AddButton.UseVisualStyleBackColor = true;
|
||||||
|
AddButton.Click += AddButton_Click;
|
||||||
|
//
|
||||||
|
// buttonStop
|
||||||
|
//
|
||||||
|
buttonStop.Location = new Point(806, 293);
|
||||||
|
buttonStop.Name = "buttonStop";
|
||||||
|
buttonStop.Size = new Size(131, 36);
|
||||||
|
buttonStop.TabIndex = 4;
|
||||||
|
buttonStop.Text = "Отмена";
|
||||||
|
buttonStop.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// FormBomberConfig
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(962, 337);
|
||||||
|
Controls.Add(buttonStop);
|
||||||
|
Controls.Add(AddButton);
|
||||||
|
Controls.Add(PanelColor);
|
||||||
|
Controls.Add(groupBox1);
|
||||||
|
Name = "FormBomberConfig";
|
||||||
|
Text = "FormBomberConfig";
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
groupBox1.PerformLayout();
|
||||||
|
colorGroupBox.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)WeightNumericUpDown).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)SpeedNumericUpDown).EndInit();
|
||||||
|
PanelColor.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxConfig).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private Label weight;
|
||||||
|
private Label speed;
|
||||||
|
private GroupBox colorGroupBox;
|
||||||
|
private Panel purplePanel;
|
||||||
|
private Panel blackPanel;
|
||||||
|
private Panel greyPanel;
|
||||||
|
private Panel whitePanel;
|
||||||
|
private Panel yellowPanel;
|
||||||
|
private Panel bluePanel;
|
||||||
|
private Panel greenPanel;
|
||||||
|
private Panel redPanel;
|
||||||
|
private CheckBox rocketCheckBox;
|
||||||
|
private CheckBox bakCheckBox;
|
||||||
|
private NumericUpDown WeightNumericUpDown;
|
||||||
|
private NumericUpDown SpeedNumericUpDown;
|
||||||
|
private Label hardLabel;
|
||||||
|
private Label easyLabel;
|
||||||
|
private Panel PanelColor;
|
||||||
|
private Label labelDopColor;
|
||||||
|
private Label labelColor;
|
||||||
|
private PictureBox pictureBoxConfig;
|
||||||
|
private Button AddButton;
|
||||||
|
private Button buttonStop;
|
||||||
|
}
|
||||||
|
}
|
||||||
141
AirBomber/FormBomberConfig.cs
Normal file
141
AirBomber/FormBomberConfig.cs
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
using AirBomber.DrawningObjects;
|
||||||
|
using AirBomber.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace AirBomber
|
||||||
|
{
|
||||||
|
public partial class FormBomberConfig : Form
|
||||||
|
{
|
||||||
|
private event Action<DrawningBomber>? EventAddBomber;
|
||||||
|
DrawningBomber? _bomber = null;
|
||||||
|
|
||||||
|
public FormBomberConfig()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
redPanel.MouseDown += PanelColor_MouseDown;
|
||||||
|
greenPanel.MouseDown += PanelColor_MouseDown;
|
||||||
|
bluePanel.MouseDown += PanelColor_MouseDown;
|
||||||
|
yellowPanel.MouseDown += PanelColor_MouseDown;
|
||||||
|
whitePanel.MouseDown += PanelColor_MouseDown;
|
||||||
|
greyPanel.MouseDown += PanelColor_MouseDown;
|
||||||
|
blackPanel.MouseDown += PanelColor_MouseDown;
|
||||||
|
purplePanel.MouseDown += PanelColor_MouseDown;
|
||||||
|
buttonStop.Click += (sender, e) => Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawBomber()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(pictureBoxConfig.Width, pictureBoxConfig.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_bomber?.SetPosition(5, 5);
|
||||||
|
_bomber?.DrawBomber(gr);
|
||||||
|
pictureBoxConfig.Image = bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddEvent(Action<DrawningBomber> ev)
|
||||||
|
{
|
||||||
|
if (EventAddBomber == null)
|
||||||
|
{
|
||||||
|
EventAddBomber = new Action<DrawningBomber>(ev);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EventAddBomber += ev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LableObject_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||||
|
{
|
||||||
|
case "easyLabel":
|
||||||
|
_bomber = new DrawningBomber((int)SpeedNumericUpDown.Value,
|
||||||
|
(int)WeightNumericUpDown.Value, Color.White, pictureBoxConfig.Width,
|
||||||
|
pictureBoxConfig.Height);
|
||||||
|
break;
|
||||||
|
case "hardLabel":
|
||||||
|
_bomber = new DrawningAirBomber((int)SpeedNumericUpDown.Value,
|
||||||
|
(int)WeightNumericUpDown.Value, Color.Red, Color.Black,
|
||||||
|
bakCheckBox.Checked, rocketCheckBox.Checked, pictureBoxConfig.Width,
|
||||||
|
pictureBoxConfig.Height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawBomber();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
EventAddBomber?.Invoke(_bomber);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_bomber is DrawningBomber entityAirBomber)
|
||||||
|
{
|
||||||
|
labelColor.BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||||
|
_bomber.setColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
}
|
||||||
|
DrawBomber();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LabelColor_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_bomber != null && _bomber.EntityBomber is EntityAirBomber entityAirBomber)
|
||||||
|
{
|
||||||
|
labelDopColor.AllowDrop = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
labelDopColor.AllowDrop = false;
|
||||||
|
|
||||||
|
if (e.Data.GetDataPresent(typeof(Color)))
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void labelAddBoxColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_bomber is DrawningAirBomber entityAirBomber)
|
||||||
|
{
|
||||||
|
labelDopColor.BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||||
|
entityAirBomber.setAddColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
}
|
||||||
|
DrawBomber();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
AirBomber/FormBomberConfig.resx
Normal file
120
AirBomber/FormBomberConfig.resx
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
@@ -17,18 +17,23 @@ namespace ProjectBomber.Generics
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Массив объектов, которые храним
|
/// Массив объектов, которые храним
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly T[] _places;
|
private readonly List<T?> _places;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Количество объектов в массиве
|
/// Количество объектов в массиве
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Count => _places.Length;
|
public int Count => _places.Count;
|
||||||
|
/// <summary>
|
||||||
|
/// Максимальное количество объектов в списке
|
||||||
|
/// </summary>
|
||||||
|
private readonly int _maxCount;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="count"></param>
|
/// <param name="count"></param>
|
||||||
public SetGeneric(int count)
|
public SetGeneric(int count)
|
||||||
{
|
{
|
||||||
_places = new T[count];
|
_maxCount = count;
|
||||||
|
_places = new List<T?>(count);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в набор
|
/// Добавление объекта в набор
|
||||||
@@ -47,32 +52,13 @@ namespace ProjectBomber.Generics
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int Insert(T plane, int position)
|
public int Insert(T plane, int position)
|
||||||
{
|
{
|
||||||
// TODO проверка позиции
|
if (position < 0 || position >= _maxCount)
|
||||||
if (position < 0 && position > Count)
|
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
if (_places[position] != null)
|
if (Count >= _maxCount)
|
||||||
{
|
|
||||||
int d = 0;
|
|
||||||
for (int j = 1; j < Count - position; j++)
|
|
||||||
{
|
|
||||||
if (_places[position + j] == null)
|
|
||||||
{
|
|
||||||
d = position + j;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (d == 0)
|
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
for (int j = d; j > position; j--)
|
_places.Insert(position, plane);
|
||||||
{
|
|
||||||
_places[j] = _places[j - 1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_places[position] = plane;
|
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -83,10 +69,8 @@ namespace ProjectBomber.Generics
|
|||||||
public bool Remove(int position)
|
public bool Remove(int position)
|
||||||
{
|
{
|
||||||
/// Проверка позиции
|
/// Проверка позиции
|
||||||
if (position < 0 || position >= _places.Length)
|
if ((position < 0) || (position > _maxCount)) return false;
|
||||||
return false;
|
_places.RemoveAt(position);
|
||||||
/// Удаление объекта из массива, присвоив элементу массива значение null
|
|
||||||
_places[position] = null;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -94,12 +78,31 @@ namespace ProjectBomber.Generics
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="position"></param>
|
/// <param name="position"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public T Get(int position)
|
public T? this[int position]
|
||||||
{
|
{
|
||||||
// Проверка позиции
|
get
|
||||||
if (position < 0 || position >= _places.Length)
|
{
|
||||||
|
if (position < 0 || position > _maxCount)
|
||||||
return null;
|
return null;
|
||||||
return _places[position];
|
return _places[position];
|
||||||
}
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (position < 0 || position > _maxCount)
|
||||||
|
return;
|
||||||
|
_places[position] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public IEnumerable<T?> GetPlane(int? maxPlane = null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _places.Count; ++i)
|
||||||
|
{
|
||||||
|
yield return _places[i];
|
||||||
|
if (maxPlane.HasValue && i == maxPlane.Value)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user