Этап 3. Форма
This commit is contained in:
parent
66cf50c25a
commit
50baf3b05b
@ -40,12 +40,19 @@
|
|||||||
this.buttonAddAirFighter = new System.Windows.Forms.Button();
|
this.buttonAddAirFighter = new System.Windows.Forms.Button();
|
||||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||||
|
this.groupBoxMaps = new System.Windows.Forms.GroupBox();
|
||||||
|
this.buttonDeleteMap = new System.Windows.Forms.Button();
|
||||||
|
this.listBoxMaps = new System.Windows.Forms.ListBox();
|
||||||
|
this.buttonAddMap = new System.Windows.Forms.Button();
|
||||||
|
this.textBoxNewMapName = new System.Windows.Forms.TextBox();
|
||||||
this.groupBox.SuspendLayout();
|
this.groupBox.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||||
|
this.groupBoxMaps.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBox
|
// groupBox
|
||||||
//
|
//
|
||||||
|
this.groupBox.Controls.Add(this.groupBoxMaps);
|
||||||
this.groupBox.Controls.Add(this.buttonUp);
|
this.groupBox.Controls.Add(this.buttonUp);
|
||||||
this.groupBox.Controls.Add(this.buttonDown);
|
this.groupBox.Controls.Add(this.buttonDown);
|
||||||
this.groupBox.Controls.Add(this.buttonLeft);
|
this.groupBox.Controls.Add(this.buttonLeft);
|
||||||
@ -55,20 +62,20 @@
|
|||||||
this.groupBox.Controls.Add(this.buttonRemoveAirFighter);
|
this.groupBox.Controls.Add(this.buttonRemoveAirFighter);
|
||||||
this.groupBox.Controls.Add(this.maskedTextBoxPosition);
|
this.groupBox.Controls.Add(this.maskedTextBoxPosition);
|
||||||
this.groupBox.Controls.Add(this.buttonAddAirFighter);
|
this.groupBox.Controls.Add(this.buttonAddAirFighter);
|
||||||
this.groupBox.Controls.Add(this.comboBoxSelectorMap);
|
|
||||||
this.groupBox.Dock = System.Windows.Forms.DockStyle.Right;
|
this.groupBox.Dock = System.Windows.Forms.DockStyle.Right;
|
||||||
this.groupBox.Location = new System.Drawing.Point(550, 0);
|
this.groupBox.Location = new System.Drawing.Point(732, 0);
|
||||||
this.groupBox.Name = "groupBox";
|
this.groupBox.Name = "groupBox";
|
||||||
this.groupBox.Size = new System.Drawing.Size(250, 450);
|
this.groupBox.Size = new System.Drawing.Size(250, 555);
|
||||||
this.groupBox.TabIndex = 0;
|
this.groupBox.TabIndex = 0;
|
||||||
this.groupBox.TabStop = false;
|
this.groupBox.TabStop = false;
|
||||||
this.groupBox.Text = "Инструменты";
|
this.groupBox.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
// buttonUp
|
// buttonUp
|
||||||
//
|
//
|
||||||
|
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonUp.BackgroundImage = global::AirFighter.Properties.Resources.Up;
|
this.buttonUp.BackgroundImage = global::AirFighter.Properties.Resources.Up;
|
||||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonUp.Location = new System.Drawing.Point(135, 370);
|
this.buttonUp.Location = new System.Drawing.Point(135, 475);
|
||||||
this.buttonUp.Name = "buttonUp";
|
this.buttonUp.Name = "buttonUp";
|
||||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||||
this.buttonUp.TabIndex = 2;
|
this.buttonUp.TabIndex = 2;
|
||||||
@ -77,9 +84,10 @@
|
|||||||
//
|
//
|
||||||
// buttonDown
|
// buttonDown
|
||||||
//
|
//
|
||||||
|
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonDown.BackgroundImage = global::AirFighter.Properties.Resources.Down;
|
this.buttonDown.BackgroundImage = global::AirFighter.Properties.Resources.Down;
|
||||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonDown.Location = new System.Drawing.Point(135, 408);
|
this.buttonDown.Location = new System.Drawing.Point(135, 513);
|
||||||
this.buttonDown.Name = "buttonDown";
|
this.buttonDown.Name = "buttonDown";
|
||||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||||
this.buttonDown.TabIndex = 3;
|
this.buttonDown.TabIndex = 3;
|
||||||
@ -88,9 +96,10 @@
|
|||||||
//
|
//
|
||||||
// buttonLeft
|
// buttonLeft
|
||||||
//
|
//
|
||||||
|
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonLeft.BackgroundImage = global::AirFighter.Properties.Resources.Left;
|
this.buttonLeft.BackgroundImage = global::AirFighter.Properties.Resources.Left;
|
||||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonLeft.Location = new System.Drawing.Point(99, 408);
|
this.buttonLeft.Location = new System.Drawing.Point(99, 513);
|
||||||
this.buttonLeft.Name = "buttonLeft";
|
this.buttonLeft.Name = "buttonLeft";
|
||||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||||
this.buttonLeft.TabIndex = 4;
|
this.buttonLeft.TabIndex = 4;
|
||||||
@ -99,9 +108,10 @@
|
|||||||
//
|
//
|
||||||
// buttonRight
|
// buttonRight
|
||||||
//
|
//
|
||||||
|
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonRight.BackgroundImage = global::AirFighter.Properties.Resources.Right;
|
this.buttonRight.BackgroundImage = global::AirFighter.Properties.Resources.Right;
|
||||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonRight.Location = new System.Drawing.Point(171, 408);
|
this.buttonRight.Location = new System.Drawing.Point(171, 513);
|
||||||
this.buttonRight.Name = "buttonRight";
|
this.buttonRight.Name = "buttonRight";
|
||||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||||
this.buttonRight.TabIndex = 5;
|
this.buttonRight.TabIndex = 5;
|
||||||
@ -110,7 +120,7 @@
|
|||||||
//
|
//
|
||||||
// buttonShowOnMap
|
// buttonShowOnMap
|
||||||
//
|
//
|
||||||
this.buttonShowOnMap.Location = new System.Drawing.Point(28, 296);
|
this.buttonShowOnMap.Location = new System.Drawing.Point(28, 443);
|
||||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||||
this.buttonShowOnMap.Size = new System.Drawing.Size(210, 29);
|
this.buttonShowOnMap.Size = new System.Drawing.Size(210, 29);
|
||||||
this.buttonShowOnMap.TabIndex = 5;
|
this.buttonShowOnMap.TabIndex = 5;
|
||||||
@ -120,7 +130,7 @@
|
|||||||
//
|
//
|
||||||
// buttonShowStorage
|
// buttonShowStorage
|
||||||
//
|
//
|
||||||
this.buttonShowStorage.Location = new System.Drawing.Point(28, 252);
|
this.buttonShowStorage.Location = new System.Drawing.Point(28, 408);
|
||||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||||
this.buttonShowStorage.Size = new System.Drawing.Size(210, 29);
|
this.buttonShowStorage.Size = new System.Drawing.Size(210, 29);
|
||||||
this.buttonShowStorage.TabIndex = 4;
|
this.buttonShowStorage.TabIndex = 4;
|
||||||
@ -130,7 +140,7 @@
|
|||||||
//
|
//
|
||||||
// buttonRemoveAirFighter
|
// buttonRemoveAirFighter
|
||||||
//
|
//
|
||||||
this.buttonRemoveAirFighter.Location = new System.Drawing.Point(28, 194);
|
this.buttonRemoveAirFighter.Location = new System.Drawing.Point(28, 373);
|
||||||
this.buttonRemoveAirFighter.Name = "buttonRemoveAirFighter";
|
this.buttonRemoveAirFighter.Name = "buttonRemoveAirFighter";
|
||||||
this.buttonRemoveAirFighter.Size = new System.Drawing.Size(210, 29);
|
this.buttonRemoveAirFighter.Size = new System.Drawing.Size(210, 29);
|
||||||
this.buttonRemoveAirFighter.TabIndex = 3;
|
this.buttonRemoveAirFighter.TabIndex = 3;
|
||||||
@ -140,7 +150,7 @@
|
|||||||
//
|
//
|
||||||
// maskedTextBoxPosition
|
// maskedTextBoxPosition
|
||||||
//
|
//
|
||||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(28, 145);
|
this.maskedTextBoxPosition.Location = new System.Drawing.Point(28, 340);
|
||||||
this.maskedTextBoxPosition.Mask = "00";
|
this.maskedTextBoxPosition.Mask = "00";
|
||||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(210, 27);
|
this.maskedTextBoxPosition.Size = new System.Drawing.Size(210, 27);
|
||||||
@ -148,7 +158,7 @@
|
|||||||
//
|
//
|
||||||
// buttonAddAirFighter
|
// buttonAddAirFighter
|
||||||
//
|
//
|
||||||
this.buttonAddAirFighter.Location = new System.Drawing.Point(28, 96);
|
this.buttonAddAirFighter.Location = new System.Drawing.Point(28, 296);
|
||||||
this.buttonAddAirFighter.Name = "buttonAddAirFighter";
|
this.buttonAddAirFighter.Name = "buttonAddAirFighter";
|
||||||
this.buttonAddAirFighter.Size = new System.Drawing.Size(210, 29);
|
this.buttonAddAirFighter.Size = new System.Drawing.Size(210, 29);
|
||||||
this.buttonAddAirFighter.TabIndex = 1;
|
this.buttonAddAirFighter.TabIndex = 1;
|
||||||
@ -163,26 +173,76 @@
|
|||||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||||
"Простая карта",
|
"Простая карта",
|
||||||
"Карта шторма"});
|
"Карта шторма"});
|
||||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(28, 45);
|
this.comboBoxSelectorMap.Location = new System.Drawing.Point(17, 75);
|
||||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(210, 28);
|
this.comboBoxSelectorMap.Size = new System.Drawing.Size(210, 28);
|
||||||
this.comboBoxSelectorMap.TabIndex = 0;
|
this.comboBoxSelectorMap.TabIndex = 0;
|
||||||
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
|
||||||
//
|
//
|
||||||
// pictureBox
|
// pictureBox
|
||||||
//
|
//
|
||||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
||||||
this.pictureBox.Name = "pictureBox";
|
this.pictureBox.Name = "pictureBox";
|
||||||
this.pictureBox.Size = new System.Drawing.Size(550, 450);
|
this.pictureBox.Size = new System.Drawing.Size(732, 555);
|
||||||
this.pictureBox.TabIndex = 1;
|
this.pictureBox.TabIndex = 1;
|
||||||
this.pictureBox.TabStop = false;
|
this.pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
|
// groupBoxMaps
|
||||||
|
//
|
||||||
|
this.groupBoxMaps.Controls.Add(this.buttonDeleteMap);
|
||||||
|
this.groupBoxMaps.Controls.Add(this.listBoxMaps);
|
||||||
|
this.groupBoxMaps.Controls.Add(this.buttonAddMap);
|
||||||
|
this.groupBoxMaps.Controls.Add(this.textBoxNewMapName);
|
||||||
|
this.groupBoxMaps.Controls.Add(this.comboBoxSelectorMap);
|
||||||
|
this.groupBoxMaps.Location = new System.Drawing.Point(0, 12);
|
||||||
|
this.groupBoxMaps.Name = "groupBoxMaps";
|
||||||
|
this.groupBoxMaps.Size = new System.Drawing.Size(250, 278);
|
||||||
|
this.groupBoxMaps.TabIndex = 6;
|
||||||
|
this.groupBoxMaps.TabStop = false;
|
||||||
|
this.groupBoxMaps.Text = "Карты";
|
||||||
|
//
|
||||||
|
// buttonDeleteMap
|
||||||
|
//
|
||||||
|
this.buttonDeleteMap.Location = new System.Drawing.Point(17, 244);
|
||||||
|
this.buttonDeleteMap.Name = "buttonDeleteMap";
|
||||||
|
this.buttonDeleteMap.Size = new System.Drawing.Size(210, 29);
|
||||||
|
this.buttonDeleteMap.TabIndex = 4;
|
||||||
|
this.buttonDeleteMap.Text = "Удалить карту";
|
||||||
|
this.buttonDeleteMap.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDeleteMap.Click += new System.EventHandler(this.ButtonDeleteMap_Click);
|
||||||
|
//
|
||||||
|
// listBoxMaps
|
||||||
|
//
|
||||||
|
this.listBoxMaps.FormattingEnabled = true;
|
||||||
|
this.listBoxMaps.ItemHeight = 20;
|
||||||
|
this.listBoxMaps.Location = new System.Drawing.Point(17, 154);
|
||||||
|
this.listBoxMaps.Name = "listBoxMaps";
|
||||||
|
this.listBoxMaps.Size = new System.Drawing.Size(210, 84);
|
||||||
|
this.listBoxMaps.TabIndex = 3;
|
||||||
|
this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.ListBoxMaps_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// buttonAddMap
|
||||||
|
//
|
||||||
|
this.buttonAddMap.Location = new System.Drawing.Point(17, 119);
|
||||||
|
this.buttonAddMap.Name = "buttonAddMap";
|
||||||
|
this.buttonAddMap.Size = new System.Drawing.Size(210, 29);
|
||||||
|
this.buttonAddMap.TabIndex = 2;
|
||||||
|
this.buttonAddMap.Text = "Добавить карту";
|
||||||
|
this.buttonAddMap.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAddMap.Click += new System.EventHandler(this.ButtonAddMap_Click);
|
||||||
|
//
|
||||||
|
// textBoxNewMapName
|
||||||
|
//
|
||||||
|
this.textBoxNewMapName.Location = new System.Drawing.Point(17, 36);
|
||||||
|
this.textBoxNewMapName.Name = "textBoxNewMapName";
|
||||||
|
this.textBoxNewMapName.Size = new System.Drawing.Size(210, 27);
|
||||||
|
this.textBoxNewMapName.TabIndex = 1;
|
||||||
|
//
|
||||||
// FormMapWithSetAirFighters
|
// FormMapWithSetAirFighters
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
this.ClientSize = new System.Drawing.Size(982, 555);
|
||||||
this.Controls.Add(this.pictureBox);
|
this.Controls.Add(this.pictureBox);
|
||||||
this.Controls.Add(this.groupBox);
|
this.Controls.Add(this.groupBox);
|
||||||
this.Name = "FormMapWithSetAirFighters";
|
this.Name = "FormMapWithSetAirFighters";
|
||||||
@ -190,6 +250,8 @@
|
|||||||
this.groupBox.ResumeLayout(false);
|
this.groupBox.ResumeLayout(false);
|
||||||
this.groupBox.PerformLayout();
|
this.groupBox.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||||
|
this.groupBoxMaps.ResumeLayout(false);
|
||||||
|
this.groupBoxMaps.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -208,5 +270,10 @@
|
|||||||
private Button buttonDown;
|
private Button buttonDown;
|
||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
|
private GroupBox groupBoxMaps;
|
||||||
|
private Button buttonDeleteMap;
|
||||||
|
private ListBox listBoxMaps;
|
||||||
|
private Button buttonAddMap;
|
||||||
|
private TextBox textBoxNewMapName;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,42 +14,49 @@ namespace AirFighter
|
|||||||
public partial class FormMapWithSetAirFighters : Form
|
public partial class FormMapWithSetAirFighters : Form
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Объект от класса карты с набором объектов
|
/// Словарь для выпадающего списка
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private MapWithSetAirFightersGeneric<DrawningObjectAirFighter, AbstractMap> _mapAirFightersCollectionGeneric;
|
private readonly Dictionary<string, AbstractMap> _mapsDict = new()
|
||||||
|
{
|
||||||
|
{ "Простая карта", new SimpleMap() },
|
||||||
|
{ "Карта шторма", new StormMap() }
|
||||||
|
};
|
||||||
|
/// <summary>
|
||||||
|
/// Объект от коллекции карт
|
||||||
|
/// </summary>
|
||||||
|
private readonly MapsCollection _mapsCollection;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
public FormMapWithSetAirFighters()
|
public FormMapWithSetAirFighters()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
|
||||||
|
comboBoxSelectorMap.Items.Clear();
|
||||||
|
foreach (var elem in _mapsDict)
|
||||||
|
{
|
||||||
|
comboBoxSelectorMap.Items.Add(elem.Key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Выбор карты
|
/// Заполнение listBoxMaps
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
private void ReloadMaps()
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender,
|
|
||||||
EventArgs e)
|
|
||||||
{
|
{
|
||||||
AbstractMap map = null;
|
int index = listBoxMaps.SelectedIndex;
|
||||||
switch (comboBoxSelectorMap.Text)
|
listBoxMaps.Items.Clear();
|
||||||
|
for (int i = 0; i < _mapsCollection.Keys.Count; i++)
|
||||||
{
|
{
|
||||||
case "Простая карта":
|
listBoxMaps.Items.Add(_mapsCollection.Keys[i]);
|
||||||
map = new SimpleMap();
|
|
||||||
break;
|
|
||||||
case "Карта шторма":
|
|
||||||
map = new StormMap();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (map != null)
|
if (listBoxMaps.Items.Count > 0 && (index == -1 || index >=
|
||||||
|
listBoxMaps.Items.Count))
|
||||||
{
|
{
|
||||||
_mapAirFightersCollectionGeneric = new
|
listBoxMaps.SelectedIndex = 0;
|
||||||
MapWithSetAirFightersGeneric<DrawningObjectAirFighter, AbstractMap>(
|
|
||||||
pictureBox.Width, pictureBox.Height, map);
|
|
||||||
}
|
}
|
||||||
else
|
else if (listBoxMaps.Items.Count > 0 && index > -1 && index <
|
||||||
|
listBoxMaps.Items.Count)
|
||||||
{
|
{
|
||||||
_mapAirFightersCollectionGeneric = null;
|
listBoxMaps.SelectedIndex = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -59,7 +66,7 @@ namespace AirFighter
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonAddAirFighter_Click(object sender, EventArgs e)
|
private void ButtonAddAirFighter_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mapAirFightersCollectionGeneric == null)
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -67,10 +74,10 @@ namespace AirFighter
|
|||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
DrawningObjectAirFighter airFighter = new(form.SelectedAirFighter);
|
DrawningObjectAirFighter airFighter = new(form.SelectedAirFighter);
|
||||||
if ((_mapAirFightersCollectionGeneric + airFighter) == 0)
|
if ((_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + airFighter) == 0)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBox.Image = _mapAirFightersCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -85,6 +92,10 @@ namespace AirFighter
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonRemoveAirFighter_Click(object sender, EventArgs e)
|
private void ButtonRemoveAirFighter_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -95,10 +106,10 @@ namespace AirFighter
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||||
if ((_mapAirFightersCollectionGeneric - pos) != null)
|
if ((_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos) != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
pictureBox.Image = _mapAirFightersCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -112,11 +123,11 @@ namespace AirFighter
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mapAirFightersCollectionGeneric == null)
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapAirFightersCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вывод карты
|
/// Вывод карты
|
||||||
@ -125,11 +136,11 @@ namespace AirFighter
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mapAirFightersCollectionGeneric == null)
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapAirFightersCollectionGeneric.ShowOnMap();
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перемещение
|
/// Перемещение
|
||||||
@ -138,7 +149,7 @@ namespace AirFighter
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mapAirFightersCollectionGeneric == null)
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -160,7 +171,56 @@ namespace AirFighter
|
|||||||
dir = Direction.Right;
|
dir = Direction.Right;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapAirFightersCollectionGeneric.MoveObject(dir);
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonAddMap_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (comboBoxSelectorMap.SelectedIndex == -1 || string.IsNullOrEmpty(textBoxNewMapName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не все данные заполнены", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!_mapsDict.ContainsKey(comboBoxSelectorMap.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Нет такой карты", "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_mapsCollection.AddMap(textBoxNewMapName.Text,
|
||||||
|
_mapsDict[comboBoxSelectorMap.Text]);
|
||||||
|
ReloadMaps();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Выбор карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ListBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonDeleteMap_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show($"Удалить карту {listBoxMaps.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
_mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty);
|
||||||
|
ReloadMaps();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user