Этап 3. Форма

This commit is contained in:
Артем Харламов 2022-11-28 21:18:10 +04:00
parent 2ea383775d
commit 8b72e04647
3 changed files with 204 additions and 158 deletions

View File

@ -29,46 +29,119 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.groupBoxTools = new System.Windows.Forms.GroupBox(); this.groupBoxTools = new System.Windows.Forms.GroupBox();
this.groupBoxMaps = new System.Windows.Forms.GroupBox();
this.listBoxMaps = new System.Windows.Forms.ListBox();
this.buttonDeleteMap = new System.Windows.Forms.Button();
this.buttonAddMap = new System.Windows.Forms.Button();
this.textBoxNewMapName = new System.Windows.Forms.TextBox();
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox(); this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
this.buttonRemoveStorm = new System.Windows.Forms.Button(); this.buttonRemoveCar = new System.Windows.Forms.Button();
this.buttonShowStorage = new System.Windows.Forms.Button(); this.buttonShowStorage = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button(); this.buttonDown = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button(); this.buttonRight = new System.Windows.Forms.Button();
this.buttonLeft = new System.Windows.Forms.Button(); this.buttonLeft = new System.Windows.Forms.Button();
this.buttonUp = new System.Windows.Forms.Button(); this.buttonUp = new System.Windows.Forms.Button();
this.buttonShowOnMap = new System.Windows.Forms.Button(); this.buttonShowOnMap = new System.Windows.Forms.Button();
this.buttonAddStorm = new System.Windows.Forms.Button(); this.buttonAddCar = new System.Windows.Forms.Button();
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
this.pictureBox = new System.Windows.Forms.PictureBox(); this.pictureBox = new System.Windows.Forms.PictureBox();
this.groupBoxTools.SuspendLayout(); this.groupBoxTools.SuspendLayout();
this.groupBoxMaps.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// groupBoxTools // groupBoxTools
// //
this.groupBoxTools.Controls.Add(this.groupBoxMaps);
this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition); this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
this.groupBoxTools.Controls.Add(this.buttonRemoveStorm); this.groupBoxTools.Controls.Add(this.buttonRemoveCar);
this.groupBoxTools.Controls.Add(this.buttonShowStorage); this.groupBoxTools.Controls.Add(this.buttonShowStorage);
this.groupBoxTools.Controls.Add(this.buttonDown); this.groupBoxTools.Controls.Add(this.buttonDown);
this.groupBoxTools.Controls.Add(this.buttonRight); this.groupBoxTools.Controls.Add(this.buttonRight);
this.groupBoxTools.Controls.Add(this.buttonLeft); this.groupBoxTools.Controls.Add(this.buttonLeft);
this.groupBoxTools.Controls.Add(this.buttonUp); this.groupBoxTools.Controls.Add(this.buttonUp);
this.groupBoxTools.Controls.Add(this.buttonShowOnMap); this.groupBoxTools.Controls.Add(this.buttonShowOnMap);
this.groupBoxTools.Controls.Add(this.buttonAddStorm); this.groupBoxTools.Controls.Add(this.buttonAddCar);
this.groupBoxTools.Controls.Add(this.comboBoxSelectorMap);
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right; this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
this.groupBoxTools.Location = new System.Drawing.Point(927, 0); this.groupBoxTools.Location = new System.Drawing.Point(927, 0);
this.groupBoxTools.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.groupBoxTools.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.groupBoxTools.Name = "groupBoxTools"; this.groupBoxTools.Name = "groupBoxTools";
this.groupBoxTools.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); this.groupBoxTools.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.groupBoxTools.Size = new System.Drawing.Size(233, 739); this.groupBoxTools.Size = new System.Drawing.Size(233, 884);
this.groupBoxTools.TabIndex = 0; this.groupBoxTools.TabIndex = 0;
this.groupBoxTools.TabStop = false; this.groupBoxTools.TabStop = false;
this.groupBoxTools.Text = "Инструменты"; this.groupBoxTools.Text = "Инструменты";
// //
// groupBoxMaps
//
this.groupBoxMaps.Controls.Add(this.listBoxMaps);
this.groupBoxMaps.Controls.Add(this.buttonDeleteMap);
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(14, 28);
this.groupBoxMaps.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.groupBoxMaps.Name = "groupBoxMaps";
this.groupBoxMaps.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.groupBoxMaps.Size = new System.Drawing.Size(213, 360);
this.groupBoxMaps.TabIndex = 11;
this.groupBoxMaps.TabStop = false;
this.groupBoxMaps.Text = "Карты";
//
// listBoxMaps
//
this.listBoxMaps.FormattingEnabled = true;
this.listBoxMaps.ItemHeight = 20;
this.listBoxMaps.Location = new System.Drawing.Point(7, 160);
this.listBoxMaps.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.listBoxMaps.Name = "listBoxMaps";
this.listBoxMaps.Size = new System.Drawing.Size(198, 144);
this.listBoxMaps.TabIndex = 4;
this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.listBoxMaps_SelectedIndexChanged);
//
// buttonDeleteMap
//
this.buttonDeleteMap.Location = new System.Drawing.Point(7, 313);
this.buttonDeleteMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonDeleteMap.Name = "buttonDeleteMap";
this.buttonDeleteMap.Size = new System.Drawing.Size(199, 39);
this.buttonDeleteMap.TabIndex = 3;
this.buttonDeleteMap.Text = "Удалить карту";
this.buttonDeleteMap.UseVisualStyleBackColor = true;
this.buttonDeleteMap.Click += new System.EventHandler(this.ButtonDeleteMap_Click);
//
// buttonAddMap
//
this.buttonAddMap.Location = new System.Drawing.Point(6, 115);
this.buttonAddMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonAddMap.Name = "buttonAddMap";
this.buttonAddMap.Size = new System.Drawing.Size(200, 37);
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(7, 37);
this.textBoxNewMapName.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.textBoxNewMapName.Name = "textBoxNewMapName";
this.textBoxNewMapName.Size = new System.Drawing.Size(198, 27);
this.textBoxNewMapName.TabIndex = 1;
//
// comboBoxSelectorMap
//
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSelectorMap.FormattingEnabled = true;
this.comboBoxSelectorMap.Location = new System.Drawing.Point(7, 76);
this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
this.comboBoxSelectorMap.Size = new System.Drawing.Size(198, 28);
this.comboBoxSelectorMap.TabIndex = 0;
//
// maskedTextBoxPosition // maskedTextBoxPosition
// //
this.maskedTextBoxPosition.Location = new System.Drawing.Point(19, 221); this.maskedTextBoxPosition.Location = new System.Drawing.Point(21, 511);
this.maskedTextBoxPosition.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.maskedTextBoxPosition.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.maskedTextBoxPosition.Mask = "00"; this.maskedTextBoxPosition.Mask = "00";
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
@ -76,20 +149,20 @@
this.maskedTextBoxPosition.TabIndex = 2; this.maskedTextBoxPosition.TabIndex = 2;
this.maskedTextBoxPosition.ValidatingType = typeof(int); this.maskedTextBoxPosition.ValidatingType = typeof(int);
// //
// buttonRemoveStorm // buttonRemoveCar
// //
this.buttonRemoveStorm.Location = new System.Drawing.Point(19, 260); this.buttonRemoveCar.Location = new System.Drawing.Point(21, 565);
this.buttonRemoveStorm.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonRemoveCar.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonRemoveStorm.Name = "buttonRemoveStorm"; this.buttonRemoveCar.Name = "buttonRemoveCar";
this.buttonRemoveStorm.Size = new System.Drawing.Size(200, 47); this.buttonRemoveCar.Size = new System.Drawing.Size(200, 47);
this.buttonRemoveStorm.TabIndex = 3; this.buttonRemoveCar.TabIndex = 3;
this.buttonRemoveStorm.Text = "Удалить самолёт"; this.buttonRemoveCar.Text = "Удалить самолёт";
this.buttonRemoveStorm.UseVisualStyleBackColor = true; this.buttonRemoveCar.UseVisualStyleBackColor = true;
this.buttonRemoveStorm.Click += new System.EventHandler(this.ButtonRemoveStorm_Click); this.buttonRemoveCar.Click += new System.EventHandler(this.ButtonRemoveStorm_Click);
// //
// buttonShowStorage // buttonShowStorage
// //
this.buttonShowStorage.Location = new System.Drawing.Point(19, 383); this.buttonShowStorage.Location = new System.Drawing.Point(21, 633);
this.buttonShowStorage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonShowStorage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonShowStorage.Name = "buttonShowStorage"; this.buttonShowStorage.Name = "buttonShowStorage";
this.buttonShowStorage.Size = new System.Drawing.Size(200, 47); this.buttonShowStorage.Size = new System.Drawing.Size(200, 47);
@ -103,7 +176,7 @@
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDown.BackgroundImage = global::Stormtrooper.Properties.Resources.arrowDown; this.buttonDown.BackgroundImage = global::Stormtrooper.Properties.Resources.arrowDown;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonDown.Location = new System.Drawing.Point(104, 672); this.buttonDown.Location = new System.Drawing.Point(104, 817);
this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonDown.Name = "buttonDown"; this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(34, 40); this.buttonDown.Size = new System.Drawing.Size(34, 40);
@ -116,7 +189,7 @@
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRight.BackgroundImage = global::Stormtrooper.Properties.Resources.arrowRight; this.buttonRight.BackgroundImage = global::Stormtrooper.Properties.Resources.arrowRight;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonRight.Location = new System.Drawing.Point(145, 672); this.buttonRight.Location = new System.Drawing.Point(145, 817);
this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonRight.Name = "buttonRight"; this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(34, 40); this.buttonRight.Size = new System.Drawing.Size(34, 40);
@ -129,7 +202,7 @@
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonLeft.BackgroundImage = global::Stormtrooper.Properties.Resources.arrowLeft; this.buttonLeft.BackgroundImage = global::Stormtrooper.Properties.Resources.arrowLeft;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonLeft.Location = new System.Drawing.Point(63, 672); this.buttonLeft.Location = new System.Drawing.Point(63, 817);
this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonLeft.Name = "buttonLeft"; this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(34, 40); this.buttonLeft.Size = new System.Drawing.Size(34, 40);
@ -142,7 +215,7 @@
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUp.BackgroundImage = global::Stormtrooper.Properties.Resources.arrowUp; this.buttonUp.BackgroundImage = global::Stormtrooper.Properties.Resources.arrowUp;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonUp.Location = new System.Drawing.Point(104, 624); this.buttonUp.Location = new System.Drawing.Point(104, 769);
this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonUp.Name = "buttonUp"; this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(34, 40); this.buttonUp.Size = new System.Drawing.Size(34, 40);
@ -152,7 +225,7 @@
// //
// buttonShowOnMap // buttonShowOnMap
// //
this.buttonShowOnMap.Location = new System.Drawing.Point(19, 521); this.buttonShowOnMap.Location = new System.Drawing.Point(21, 700);
this.buttonShowOnMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonShowOnMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonShowOnMap.Name = "buttonShowOnMap"; this.buttonShowOnMap.Name = "buttonShowOnMap";
this.buttonShowOnMap.Size = new System.Drawing.Size(200, 47); this.buttonShowOnMap.Size = new System.Drawing.Size(200, 47);
@ -161,31 +234,16 @@
this.buttonShowOnMap.UseVisualStyleBackColor = true; this.buttonShowOnMap.UseVisualStyleBackColor = true;
this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click); this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
// //
// buttonAddStorm // buttonAddCar
// //
this.buttonAddStorm.Location = new System.Drawing.Point(19, 141); this.buttonAddCar.Location = new System.Drawing.Point(21, 443);
this.buttonAddStorm.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonAddCar.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonAddStorm.Name = "buttonAddStorm"; this.buttonAddCar.Name = "buttonAddCar";
this.buttonAddStorm.Size = new System.Drawing.Size(200, 47); this.buttonAddCar.Size = new System.Drawing.Size(200, 47);
this.buttonAddStorm.TabIndex = 1; this.buttonAddCar.TabIndex = 1;
this.buttonAddStorm.Text = "Добавить самолёт"; this.buttonAddCar.Text = "Добавить самолёт";
this.buttonAddStorm.UseVisualStyleBackColor = true; this.buttonAddCar.UseVisualStyleBackColor = true;
this.buttonAddStorm.Click += new System.EventHandler(this.ButtonAddStorm_Click); this.buttonAddCar.Click += new System.EventHandler(this.ButtonAddStorm_Click);
//
// comboBoxSelectorMap
//
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSelectorMap.FormattingEnabled = true;
this.comboBoxSelectorMap.Items.AddRange(new object[] {
"Простая карта",
"Ясное небо",
"Пасмурное небо"});
this.comboBoxSelectorMap.Location = new System.Drawing.Point(19, 43);
this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
this.comboBoxSelectorMap.Size = new System.Drawing.Size(199, 28);
this.comboBoxSelectorMap.TabIndex = 0;
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
// //
// pictureBox // pictureBox
// //
@ -193,7 +251,7 @@
this.pictureBox.Location = new System.Drawing.Point(0, 0); this.pictureBox.Location = new System.Drawing.Point(0, 0);
this.pictureBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.pictureBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.pictureBox.Name = "pictureBox"; this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(927, 739); this.pictureBox.Size = new System.Drawing.Size(927, 884);
this.pictureBox.TabIndex = 1; this.pictureBox.TabIndex = 1;
this.pictureBox.TabStop = false; this.pictureBox.TabStop = false;
// //
@ -201,7 +259,7 @@
// //
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(1160, 739); this.ClientSize = new System.Drawing.Size(1160, 884);
this.Controls.Add(this.pictureBox); this.Controls.Add(this.pictureBox);
this.Controls.Add(this.groupBoxTools); this.Controls.Add(this.groupBoxTools);
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
@ -209,8 +267,11 @@
this.Text = "Карта с набором объектов"; this.Text = "Карта с набором объектов";
this.groupBoxTools.ResumeLayout(false); this.groupBoxTools.ResumeLayout(false);
this.groupBoxTools.PerformLayout(); this.groupBoxTools.PerformLayout();
this.groupBoxMaps.ResumeLayout(false);
this.groupBoxMaps.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
#endregion #endregion
@ -218,13 +279,18 @@
private PictureBox pictureBox; private PictureBox pictureBox;
private ComboBox comboBoxSelectorMap; private ComboBox comboBoxSelectorMap;
private Button buttonShowOnMap; private Button buttonShowOnMap;
private Button buttonAddStorm; private Button buttonAddCar;
private Button buttonDown; private Button buttonDown;
private Button buttonRight; private Button buttonRight;
private Button buttonLeft; private Button buttonLeft;
private Button buttonUp; private Button buttonUp;
private Button buttonShowStorage; private Button buttonShowStorage;
private Button buttonRemoveStorm; private Button buttonRemoveCar;
private MaskedTextBox maskedTextBoxPosition; private MaskedTextBox maskedTextBoxPosition;
private GroupBox groupBoxMaps;
private ListBox listBoxMaps;
private Button buttonDeleteMap;
private Button buttonAddMap;
private TextBox textBoxNewMapName;
} }
} }

View File

@ -13,44 +13,30 @@ namespace Stormtrooper
public partial class FormMapWithSetStormtroopers : Form public partial class FormMapWithSetStormtroopers : Form
{ {
/// <summary> /// <summary>
/// Объект от класса карты с набором объектов /// Словарь для выпадающего списка
/// </summary> /// </summary>
private MapWithSetStormtroopersGeneric<DrawningObjectStorm, AbstractMap> _mapStormtroopersCollectionGeneric; private readonly Dictionary<string, AbstractMap> _mapsDict = new()
{
{ "Простая карта", new SimpleMap() },
{"Ясное небо", new SecondMap() },
{"Пасмурное небо", new ThirdMap() }
};
/// <summary>
/// Объект от коллекции карт
/// </summary>
private readonly MapsCollection _mapsCollection;
/// <summary> /// <summary>
/// Конструктор /// Конструктор
/// </summary> /// </summary>
public FormMapWithSetStormtroopers() public FormMapWithSetStormtroopers()
{ {
InitializeComponent(); ; InitializeComponent();
} _mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
/// <summary> comboBoxSelectorMap.Items.Clear();
/// Выбор карты foreach (var elem in _mapsDict)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
{ {
AbstractMap map = null; comboBoxSelectorMap.Items.Add(elem.Key);
switch (comboBoxSelectorMap.Text)
{
case "Простая карта":
map = new SimpleMap();
break;
case "Ясное небо":
map = new SecondMap();
break;
case "Пасмурное небо":
map = new ThirdMap();
break;
}
if (map != null)
{
_mapStormtroopersCollectionGeneric = new MapWithSetStormtroopersGeneric<DrawningObjectStorm, AbstractMap>(
pictureBox.Width, pictureBox.Height, map);
}
else
{
_mapStormtroopersCollectionGeneric = null;
} }
} }
/// <summary> /// <summary>
@ -60,18 +46,18 @@ namespace Stormtrooper
/// <param name="e"></param> /// <param name="e"></param>
private void ButtonAddStorm_Click(object sender, EventArgs e) private void ButtonAddStorm_Click(object sender, EventArgs e)
{ {
if (_mapStormtroopersCollectionGeneric == null) if (listBoxMaps.SelectedIndex == -1)
{ {
return; return;
} }
FormStormtrooper form = new(); FormStormtrooper form = new();
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
DrawningObjectStorm car = new(form.SelectedStormtrooper); DrawningObjectStorm airBomber = new(form.SelectedStormtrooper);
if ((_mapStormtroopersCollectionGeneric + car) != -1) if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + airBomber != -1)
{ {
MessageBox.Show("Объект добавлен"); MessageBox.Show("Объект добавлен");
pictureBox.Image = _mapStormtroopersCollectionGeneric.ShowSet(); pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
} }
else else
{ {
@ -86,6 +72,10 @@ namespace Stormtrooper
/// <param name="e"></param> /// <param name="e"></param>
private void ButtonRemoveStorm_Click(object sender, EventArgs e) private void ButtonRemoveStorm_Click(object sender, EventArgs e)
{ {
if (listBoxMaps.SelectedIndex == -1)
{
return;
}
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text)) if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
{ {
return; return;
@ -95,10 +85,10 @@ namespace Stormtrooper
return; return;
} }
int pos = Convert.ToInt32(maskedTextBoxPosition.Text); int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
if ((_mapStormtroopersCollectionGeneric - pos) != null) if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
{ {
MessageBox.Show("Объект удален"); MessageBox.Show("Объект удален");
pictureBox.Image = _mapStormtroopersCollectionGeneric.ShowSet(); pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
} }
else else
{ {
@ -112,11 +102,11 @@ namespace Stormtrooper
/// <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 (_mapStormtroopersCollectionGeneric == null) if (listBoxMaps.SelectedIndex == -1)
{ {
return; return;
} }
pictureBox.Image = _mapStormtroopersCollectionGeneric.ShowSet(); pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
} }
/// <summary> /// <summary>
/// Вывод карты /// Вывод карты
@ -125,11 +115,11 @@ namespace Stormtrooper
/// <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 (_mapStormtroopersCollectionGeneric == null) if (listBoxMaps.SelectedIndex == -1)
{ {
return; return;
} }
pictureBox.Image = _mapStormtroopersCollectionGeneric.ShowOnMap(); pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
} }
/// <summary> /// <summary>
/// Перемещение /// Перемещение
@ -138,10 +128,6 @@ namespace Stormtrooper
/// <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 (_mapStormtroopersCollectionGeneric == null)
{
return;
}
//получаем имя кнопки //получаем имя кнопки
string name = ((Button)sender)?.Name ?? string.Empty; string name = ((Button)sender)?.Name ?? string.Empty;
Direction dir = Direction.None; Direction dir = Direction.None;
@ -160,7 +146,61 @@ namespace Stormtrooper
dir = Direction.Right; dir = Direction.Right;
break; break;
} }
pictureBox.Image = _mapStormtroopersCollectionGeneric.MoveObject(dir); pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
}
private void ReloadMaps()
{
int index = listBoxMaps.SelectedIndex;
listBoxMaps.Items.Clear();
for (int i = 0; i < _mapsCollection.Keys.Count; i++)
{
listBoxMaps.Items.Add(_mapsCollection.Keys[i]);
}
if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count))
{
listBoxMaps.SelectedIndex = 0;
}
else if (listBoxMaps.Items.Count > 0 && index > -1 && index < listBoxMaps.Items.Count)
{
listBoxMaps.SelectedIndex = index;
}
}
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();
}
private void listBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
{
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
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();
}
} }
} }
} }

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <root>
<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: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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">