изменения
This commit is contained in:
parent
1284f2afaa
commit
b4d3dfbd11
@ -43,15 +43,14 @@ namespace AirBomber.Generics
|
||||
return collect._collection.Insert(obj);
|
||||
}
|
||||
|
||||
public static bool operator -(BomberGenericCollection<T, U> collect, int
|
||||
pos)
|
||||
public static T? operator -(BomberGenericCollection<T, U> collect, int pos)
|
||||
{
|
||||
T? obj = collect._collection[pos];
|
||||
if (obj == null)
|
||||
if (obj != null)
|
||||
{
|
||||
return false;
|
||||
collect._collection.Remove(pos);
|
||||
}
|
||||
return collect._collection.Remove(pos);
|
||||
return obj;
|
||||
}
|
||||
|
||||
public U? GetU(int pos)
|
||||
|
@ -52,7 +52,7 @@ namespace AirBomber.DrawningObjects
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (_startPosX + _PlaneWidth > _pictureWidth + 180)
|
||||
if (_startPosX + _PlaneWidth > _pictureWidth)
|
||||
{
|
||||
_startPosX = _pictureWidth - _PlaneWidth;
|
||||
}
|
||||
|
73
AirBomber/FormBomberCollection.Designer.cs
generated
73
AirBomber/FormBomberCollection.Designer.cs
generated
@ -58,9 +58,11 @@
|
||||
Tools.Controls.Add(ButtonRemoveBomber);
|
||||
Tools.Controls.Add(ButtonAddBomber);
|
||||
Tools.Controls.Add(MessageBoxBomber);
|
||||
Tools.Location = new Point(538, 5);
|
||||
Tools.Location = new Point(471, 4);
|
||||
Tools.Margin = new Padding(3, 2, 3, 2);
|
||||
Tools.Name = "Tools";
|
||||
Tools.Size = new Size(250, 556);
|
||||
Tools.Padding = new Padding(3, 2, 3, 2);
|
||||
Tools.Size = new Size(219, 417);
|
||||
Tools.TabIndex = 0;
|
||||
Tools.TabStop = false;
|
||||
Tools.Text = "Инструменты";
|
||||
@ -71,18 +73,21 @@
|
||||
Kit.Controls.Add(AddKit);
|
||||
Kit.Controls.Add(KitTextbox);
|
||||
Kit.Controls.Add(listBoxStorages);
|
||||
Kit.Location = new Point(17, 33);
|
||||
Kit.Location = new Point(15, 25);
|
||||
Kit.Margin = new Padding(3, 2, 3, 2);
|
||||
Kit.Name = "Kit";
|
||||
Kit.Size = new Size(227, 282);
|
||||
Kit.Padding = new Padding(3, 2, 3, 2);
|
||||
Kit.Size = new Size(199, 212);
|
||||
Kit.TabIndex = 4;
|
||||
Kit.TabStop = false;
|
||||
Kit.Text = "Наборы";
|
||||
//
|
||||
// RemoveKit
|
||||
//
|
||||
RemoveKit.Location = new Point(11, 231);
|
||||
RemoveKit.Location = new Point(10, 173);
|
||||
RemoveKit.Margin = new Padding(3, 2, 3, 2);
|
||||
RemoveKit.Name = "RemoveKit";
|
||||
RemoveKit.Size = new Size(193, 36);
|
||||
RemoveKit.Size = new Size(169, 27);
|
||||
RemoveKit.TabIndex = 3;
|
||||
RemoveKit.Text = "Удалить набор";
|
||||
RemoveKit.UseVisualStyleBackColor = true;
|
||||
@ -90,9 +95,10 @@
|
||||
//
|
||||
// AddKit
|
||||
//
|
||||
AddKit.Location = new Point(11, 63);
|
||||
AddKit.Location = new Point(10, 47);
|
||||
AddKit.Margin = new Padding(3, 2, 3, 2);
|
||||
AddKit.Name = "AddKit";
|
||||
AddKit.Size = new Size(193, 36);
|
||||
AddKit.Size = new Size(169, 27);
|
||||
AddKit.TabIndex = 2;
|
||||
AddKit.Text = "Добавить набор";
|
||||
AddKit.UseVisualStyleBackColor = true;
|
||||
@ -100,26 +106,29 @@
|
||||
//
|
||||
// KitTextbox
|
||||
//
|
||||
KitTextbox.Location = new Point(15, 30);
|
||||
KitTextbox.Location = new Point(13, 22);
|
||||
KitTextbox.Margin = new Padding(3, 2, 3, 2);
|
||||
KitTextbox.Name = "KitTextbox";
|
||||
KitTextbox.Size = new Size(189, 27);
|
||||
KitTextbox.Size = new Size(166, 23);
|
||||
KitTextbox.TabIndex = 1;
|
||||
//
|
||||
// listBoxStorages
|
||||
//
|
||||
listBoxStorages.FormattingEnabled = true;
|
||||
listBoxStorages.ItemHeight = 20;
|
||||
listBoxStorages.Location = new Point(11, 109);
|
||||
listBoxStorages.ItemHeight = 15;
|
||||
listBoxStorages.Location = new Point(10, 82);
|
||||
listBoxStorages.Margin = new Padding(3, 2, 3, 2);
|
||||
listBoxStorages.Name = "listBoxStorages";
|
||||
listBoxStorages.Size = new Size(193, 104);
|
||||
listBoxStorages.Size = new Size(169, 79);
|
||||
listBoxStorages.TabIndex = 0;
|
||||
listBoxStorages.SelectedIndexChanged += ListBoxObjects_SelectedIndexChanged;
|
||||
//
|
||||
// ButtonRefreshCollection
|
||||
//
|
||||
ButtonRefreshCollection.Location = new Point(28, 448);
|
||||
ButtonRefreshCollection.Location = new Point(24, 336);
|
||||
ButtonRefreshCollection.Margin = new Padding(3, 2, 3, 2);
|
||||
ButtonRefreshCollection.Name = "ButtonRefreshCollection";
|
||||
ButtonRefreshCollection.Size = new Size(193, 37);
|
||||
ButtonRefreshCollection.Size = new Size(169, 28);
|
||||
ButtonRefreshCollection.TabIndex = 3;
|
||||
ButtonRefreshCollection.Text = "Обновить коллекцию";
|
||||
ButtonRefreshCollection.UseVisualStyleBackColor = true;
|
||||
@ -127,9 +136,10 @@
|
||||
//
|
||||
// ButtonRemoveBomber
|
||||
//
|
||||
ButtonRemoveBomber.Location = new Point(28, 401);
|
||||
ButtonRemoveBomber.Location = new Point(24, 301);
|
||||
ButtonRemoveBomber.Margin = new Padding(3, 2, 3, 2);
|
||||
ButtonRemoveBomber.Name = "ButtonRemoveBomber";
|
||||
ButtonRemoveBomber.Size = new Size(193, 41);
|
||||
ButtonRemoveBomber.Size = new Size(169, 31);
|
||||
ButtonRemoveBomber.TabIndex = 2;
|
||||
ButtonRemoveBomber.Text = "Удалить самолёт";
|
||||
ButtonRemoveBomber.UseVisualStyleBackColor = true;
|
||||
@ -137,9 +147,10 @@
|
||||
//
|
||||
// ButtonAddBomber
|
||||
//
|
||||
ButtonAddBomber.Location = new Point(28, 321);
|
||||
ButtonAddBomber.Location = new Point(24, 241);
|
||||
ButtonAddBomber.Margin = new Padding(3, 2, 3, 2);
|
||||
ButtonAddBomber.Name = "ButtonAddBomber";
|
||||
ButtonAddBomber.Size = new Size(193, 41);
|
||||
ButtonAddBomber.Size = new Size(169, 31);
|
||||
ButtonAddBomber.TabIndex = 1;
|
||||
ButtonAddBomber.Text = "Добавить самолёт";
|
||||
ButtonAddBomber.UseVisualStyleBackColor = true;
|
||||
@ -147,16 +158,18 @@
|
||||
//
|
||||
// MessageBoxBomber
|
||||
//
|
||||
MessageBoxBomber.Location = new Point(28, 368);
|
||||
MessageBoxBomber.Location = new Point(24, 276);
|
||||
MessageBoxBomber.Margin = new Padding(3, 2, 3, 2);
|
||||
MessageBoxBomber.Name = "MessageBoxBomber";
|
||||
MessageBoxBomber.Size = new Size(193, 27);
|
||||
MessageBoxBomber.Size = new Size(169, 23);
|
||||
MessageBoxBomber.TabIndex = 0;
|
||||
//
|
||||
// PicBoxBomberCollection
|
||||
//
|
||||
PicBoxBomberCollection.Location = new Point(0, 38);
|
||||
PicBoxBomberCollection.Location = new Point(7, 28);
|
||||
PicBoxBomberCollection.Margin = new Padding(3, 2, 3, 2);
|
||||
PicBoxBomberCollection.Name = "PicBoxBomberCollection";
|
||||
PicBoxBomberCollection.Size = new Size(473, 563);
|
||||
PicBoxBomberCollection.Size = new Size(473, 422);
|
||||
PicBoxBomberCollection.TabIndex = 1;
|
||||
PicBoxBomberCollection.TabStop = false;
|
||||
//
|
||||
@ -166,7 +179,8 @@
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(800, 28);
|
||||
menuStrip.Padding = new Padding(5, 2, 0, 2);
|
||||
menuStrip.Size = new Size(700, 24);
|
||||
menuStrip.TabIndex = 2;
|
||||
menuStrip.Text = "Файл";
|
||||
//
|
||||
@ -174,20 +188,20 @@
|
||||
//
|
||||
fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SaveToolStripMenuItem, LoadToolStripMenuItem });
|
||||
fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
fileToolStripMenuItem.Size = new Size(59, 24);
|
||||
fileToolStripMenuItem.Size = new Size(48, 20);
|
||||
fileToolStripMenuItem.Text = "Файл";
|
||||
//
|
||||
// SaveToolStripMenuItem
|
||||
//
|
||||
SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||
SaveToolStripMenuItem.Size = new Size(224, 26);
|
||||
SaveToolStripMenuItem.Size = new Size(141, 22);
|
||||
SaveToolStripMenuItem.Text = "Сохранение";
|
||||
SaveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
||||
//
|
||||
// LoadToolStripMenuItem
|
||||
//
|
||||
LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||
LoadToolStripMenuItem.Size = new Size(224, 26);
|
||||
LoadToolStripMenuItem.Size = new Size(141, 22);
|
||||
LoadToolStripMenuItem.Text = "Загрузка";
|
||||
LoadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
||||
//
|
||||
@ -203,13 +217,14 @@
|
||||
//
|
||||
// FormBomberCollection
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 619);
|
||||
ClientSize = new Size(700, 467);
|
||||
Controls.Add(PicBoxBomberCollection);
|
||||
Controls.Add(Tools);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormBomberCollection";
|
||||
Text = "FormBomberCollection";
|
||||
Tools.ResumeLayout(false);
|
||||
|
@ -63,35 +63,38 @@ namespace AirBomber
|
||||
}
|
||||
PicBoxBomberCollection.Image = obj.ShowBomber();
|
||||
}
|
||||
private void AddBomber(DrawningBomber bomber)
|
||||
{
|
||||
|
||||
var obj = _bomber[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
_logger.LogWarning("Добавление пустого объекта");
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
_ = obj + bomber;
|
||||
|
||||
MessageBox.Show("Объект добавлен");
|
||||
PicBoxBomberCollection.Image = obj.ShowBomber();
|
||||
_logger.LogInformation($"Добавлен объект в набор {listBoxStorages.SelectedItem.ToString()}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
_logger.LogWarning($"{ex.Message} в наборе {listBoxStorages.SelectedItem.ToString()}");
|
||||
}
|
||||
}
|
||||
private void ButtonAddBomber_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -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("Объект добавлен");
|
||||
PicBoxBomberCollection.Image = obj.ShowBomber();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
formBomberConfig.Show();
|
||||
FormBomberConfig form = new FormBomberConfig();
|
||||
form.Show();
|
||||
form.AddEvent(AddBomber);
|
||||
}
|
||||
|
||||
private void ButtonRemoveBomber_Click(object sender, EventArgs e)
|
||||
|
@ -127,6 +127,6 @@
|
||||
<value>315, 1</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>25</value>
|
||||
<value>62</value>
|
||||
</metadata>
|
||||
</root>
|
@ -69,7 +69,7 @@ namespace ProjectBomber.Generics
|
||||
public bool Remove(int position)
|
||||
{
|
||||
/// Проверка позиции
|
||||
if (position < 0 || position >= _places.Count)
|
||||
if (position < 0 || position > _maxCount || position >= Count)
|
||||
throw new BomberNotFoundException(position);
|
||||
/// Удаление объекта из массива, присвоив элементу массива значение null
|
||||
_places.RemoveAt(position);
|
||||
|
@ -8,7 +8,7 @@
|
||||
"Args": {
|
||||
"path": "Logs/log_.log",
|
||||
"rollingInterval": "Day",
|
||||
"outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}"
|
||||
"outputTemplate": "{Level:u4}[{Timestamp:HH:mm:ss.fff}]: {Message:lj}{NewLine}{Exception}"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user