некоторые изменения
This commit is contained in:
parent
468f859fe0
commit
e992d502d6
@ -29,6 +29,12 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.groupBoxTools = new System.Windows.Forms.GroupBox();
|
this.groupBoxTools = new System.Windows.Forms.GroupBox();
|
||||||
|
this.groupBoxMap = new System.Windows.Forms.GroupBox();
|
||||||
|
this.buttonRemoveMap = new System.Windows.Forms.Button();
|
||||||
|
this.listBoxMap = new System.Windows.Forms.ListBox();
|
||||||
|
this.textBoxMapName = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonAddMap = new System.Windows.Forms.Button();
|
||||||
|
this.comboBoxMapSelector = new System.Windows.Forms.ComboBox();
|
||||||
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.buttonDown = new System.Windows.Forms.Button();
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
@ -38,14 +44,15 @@
|
|||||||
this.buttonRemove = new System.Windows.Forms.Button();
|
this.buttonRemove = new System.Windows.Forms.Button();
|
||||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||||
this.buttonCreate = new System.Windows.Forms.Button();
|
this.buttonCreate = new System.Windows.Forms.Button();
|
||||||
this.comboBoxMapSelector = 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.groupBoxMap.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
//
|
//
|
||||||
|
this.groupBoxTools.Controls.Add(this.groupBoxMap);
|
||||||
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.buttonDown);
|
this.groupBoxTools.Controls.Add(this.buttonDown);
|
||||||
@ -55,19 +62,82 @@
|
|||||||
this.groupBoxTools.Controls.Add(this.buttonRemove);
|
this.groupBoxTools.Controls.Add(this.buttonRemove);
|
||||||
this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
|
this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonCreate);
|
this.groupBoxTools.Controls.Add(this.buttonCreate);
|
||||||
this.groupBoxTools.Controls.Add(this.comboBoxMapSelector);
|
|
||||||
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
|
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
|
||||||
this.groupBoxTools.Location = new System.Drawing.Point(600, 0);
|
this.groupBoxTools.Location = new System.Drawing.Point(600, 0);
|
||||||
this.groupBoxTools.Name = "groupBoxTools";
|
this.groupBoxTools.Name = "groupBoxTools";
|
||||||
this.groupBoxTools.Size = new System.Drawing.Size(200, 450);
|
this.groupBoxTools.Size = new System.Drawing.Size(200, 588);
|
||||||
this.groupBoxTools.TabIndex = 0;
|
this.groupBoxTools.TabIndex = 0;
|
||||||
this.groupBoxTools.TabStop = false;
|
this.groupBoxTools.TabStop = false;
|
||||||
this.groupBoxTools.Text = "Инструменты";
|
this.groupBoxTools.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
|
// groupBoxMap
|
||||||
|
//
|
||||||
|
this.groupBoxMap.Controls.Add(this.buttonRemoveMap);
|
||||||
|
this.groupBoxMap.Controls.Add(this.listBoxMap);
|
||||||
|
this.groupBoxMap.Controls.Add(this.textBoxMapName);
|
||||||
|
this.groupBoxMap.Controls.Add(this.buttonAddMap);
|
||||||
|
this.groupBoxMap.Controls.Add(this.comboBoxMapSelector);
|
||||||
|
this.groupBoxMap.Location = new System.Drawing.Point(6, 22);
|
||||||
|
this.groupBoxMap.Name = "groupBoxMap";
|
||||||
|
this.groupBoxMap.Size = new System.Drawing.Size(182, 259);
|
||||||
|
this.groupBoxMap.TabIndex = 19;
|
||||||
|
this.groupBoxMap.TabStop = false;
|
||||||
|
this.groupBoxMap.Text = "Карты";
|
||||||
|
//
|
||||||
|
// buttonRemoveMap
|
||||||
|
//
|
||||||
|
this.buttonRemoveMap.Location = new System.Drawing.Point(20, 207);
|
||||||
|
this.buttonRemoveMap.Name = "buttonRemoveMap";
|
||||||
|
this.buttonRemoveMap.Size = new System.Drawing.Size(144, 23);
|
||||||
|
this.buttonRemoveMap.TabIndex = 13;
|
||||||
|
this.buttonRemoveMap.Text = "Удалить карту";
|
||||||
|
this.buttonRemoveMap.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRemoveMap.Click += new System.EventHandler(this.ButtonRemoveMap_Click);
|
||||||
|
//
|
||||||
|
// listBoxMap
|
||||||
|
//
|
||||||
|
this.listBoxMap.FormattingEnabled = true;
|
||||||
|
this.listBoxMap.ItemHeight = 15;
|
||||||
|
this.listBoxMap.Location = new System.Drawing.Point(18, 104);
|
||||||
|
this.listBoxMap.Name = "listBoxMap";
|
||||||
|
this.listBoxMap.Size = new System.Drawing.Size(146, 94);
|
||||||
|
this.listBoxMap.TabIndex = 12;
|
||||||
|
this.listBoxMap.SelectedIndexChanged += new System.EventHandler(this.listBoxMap_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// textBoxMapName
|
||||||
|
//
|
||||||
|
this.textBoxMapName.Location = new System.Drawing.Point(18, 17);
|
||||||
|
this.textBoxMapName.Name = "textBoxMapName";
|
||||||
|
this.textBoxMapName.Size = new System.Drawing.Size(146, 23);
|
||||||
|
this.textBoxMapName.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// buttonAddMap
|
||||||
|
//
|
||||||
|
this.buttonAddMap.Location = new System.Drawing.Point(18, 75);
|
||||||
|
this.buttonAddMap.Name = "buttonAddMap";
|
||||||
|
this.buttonAddMap.Size = new System.Drawing.Size(146, 23);
|
||||||
|
this.buttonAddMap.TabIndex = 10;
|
||||||
|
this.buttonAddMap.Text = "Добавить карту";
|
||||||
|
this.buttonAddMap.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAddMap.Click += new System.EventHandler(this.ButtonAddMap_Click);
|
||||||
|
//
|
||||||
|
// comboBoxMapSelector
|
||||||
|
//
|
||||||
|
this.comboBoxMapSelector.BackColor = System.Drawing.SystemColors.Window;
|
||||||
|
this.comboBoxMapSelector.FormattingEnabled = true;
|
||||||
|
this.comboBoxMapSelector.Items.AddRange(new object[] {
|
||||||
|
"Простая карта",
|
||||||
|
"Опасная карта",
|
||||||
|
"Облачная карта"});
|
||||||
|
this.comboBoxMapSelector.Location = new System.Drawing.Point(18, 46);
|
||||||
|
this.comboBoxMapSelector.Name = "comboBoxMapSelector";
|
||||||
|
this.comboBoxMapSelector.Size = new System.Drawing.Size(146, 23);
|
||||||
|
this.comboBoxMapSelector.TabIndex = 9;
|
||||||
|
//
|
||||||
// buttonRight
|
// buttonRight
|
||||||
//
|
//
|
||||||
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.Location = new System.Drawing.Point(119, 402);
|
this.buttonRight.Location = new System.Drawing.Point(119, 540);
|
||||||
this.buttonRight.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
this.buttonRight.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
this.buttonRight.Name = "buttonRight";
|
this.buttonRight.Name = "buttonRight";
|
||||||
this.buttonRight.Size = new System.Drawing.Size(35, 35);
|
this.buttonRight.Size = new System.Drawing.Size(35, 35);
|
||||||
@ -78,7 +148,7 @@
|
|||||||
// buttonLeft
|
// buttonLeft
|
||||||
//
|
//
|
||||||
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.Location = new System.Drawing.Point(35, 402);
|
this.buttonLeft.Location = new System.Drawing.Point(35, 540);
|
||||||
this.buttonLeft.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
this.buttonLeft.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
this.buttonLeft.Name = "buttonLeft";
|
this.buttonLeft.Name = "buttonLeft";
|
||||||
this.buttonLeft.Size = new System.Drawing.Size(35, 35);
|
this.buttonLeft.Size = new System.Drawing.Size(35, 35);
|
||||||
@ -89,7 +159,7 @@
|
|||||||
// buttonDown
|
// buttonDown
|
||||||
//
|
//
|
||||||
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.Location = new System.Drawing.Point(77, 403);
|
this.buttonDown.Location = new System.Drawing.Point(77, 541);
|
||||||
this.buttonDown.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
this.buttonDown.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
this.buttonDown.Name = "buttonDown";
|
this.buttonDown.Name = "buttonDown";
|
||||||
this.buttonDown.Size = new System.Drawing.Size(35, 35);
|
this.buttonDown.Size = new System.Drawing.Size(35, 35);
|
||||||
@ -100,7 +170,7 @@
|
|||||||
// buttonUp
|
// buttonUp
|
||||||
//
|
//
|
||||||
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.Location = new System.Drawing.Point(77, 361);
|
this.buttonUp.Location = new System.Drawing.Point(77, 499);
|
||||||
this.buttonUp.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
this.buttonUp.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
this.buttonUp.Name = "buttonUp";
|
this.buttonUp.Name = "buttonUp";
|
||||||
this.buttonUp.Size = new System.Drawing.Size(35, 35);
|
this.buttonUp.Size = new System.Drawing.Size(35, 35);
|
||||||
@ -110,7 +180,7 @@
|
|||||||
//
|
//
|
||||||
// buttonShowOnMap
|
// buttonShowOnMap
|
||||||
//
|
//
|
||||||
this.buttonShowOnMap.Location = new System.Drawing.Point(8, 323);
|
this.buttonShowOnMap.Location = new System.Drawing.Point(8, 453);
|
||||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||||
this.buttonShowOnMap.Size = new System.Drawing.Size(174, 23);
|
this.buttonShowOnMap.Size = new System.Drawing.Size(174, 23);
|
||||||
this.buttonShowOnMap.TabIndex = 14;
|
this.buttonShowOnMap.TabIndex = 14;
|
||||||
@ -120,7 +190,7 @@
|
|||||||
//
|
//
|
||||||
// buttonShowStorage
|
// buttonShowStorage
|
||||||
//
|
//
|
||||||
this.buttonShowStorage.Location = new System.Drawing.Point(8, 275);
|
this.buttonShowStorage.Location = new System.Drawing.Point(8, 424);
|
||||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||||
this.buttonShowStorage.Size = new System.Drawing.Size(174, 23);
|
this.buttonShowStorage.Size = new System.Drawing.Size(174, 23);
|
||||||
this.buttonShowStorage.TabIndex = 13;
|
this.buttonShowStorage.TabIndex = 13;
|
||||||
@ -130,17 +200,17 @@
|
|||||||
//
|
//
|
||||||
// buttonRemove
|
// buttonRemove
|
||||||
//
|
//
|
||||||
this.buttonRemove.Location = new System.Drawing.Point(7, 172);
|
this.buttonRemove.Location = new System.Drawing.Point(7, 378);
|
||||||
this.buttonRemove.Name = "buttonRemove";
|
this.buttonRemove.Name = "buttonRemove";
|
||||||
this.buttonRemove.Size = new System.Drawing.Size(174, 23);
|
this.buttonRemove.Size = new System.Drawing.Size(174, 23);
|
||||||
this.buttonRemove.TabIndex = 12;
|
this.buttonRemove.TabIndex = 12;
|
||||||
this.buttonRemove.Text = "Удалить";
|
this.buttonRemove.Text = "Удалить самолёт";
|
||||||
this.buttonRemove.UseVisualStyleBackColor = true;
|
this.buttonRemove.UseVisualStyleBackColor = true;
|
||||||
this.buttonRemove.Click += new System.EventHandler(this.ButtonRemove_Click);
|
this.buttonRemove.Click += new System.EventHandler(this.ButtonRemove_Click);
|
||||||
//
|
//
|
||||||
// maskedTextBoxPosition
|
// maskedTextBoxPosition
|
||||||
//
|
//
|
||||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(7, 122);
|
this.maskedTextBoxPosition.Location = new System.Drawing.Point(8, 347);
|
||||||
this.maskedTextBoxPosition.Mask = "00";
|
this.maskedTextBoxPosition.Mask = "00";
|
||||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(175, 23);
|
this.maskedTextBoxPosition.Size = new System.Drawing.Size(175, 23);
|
||||||
@ -149,34 +219,20 @@
|
|||||||
//
|
//
|
||||||
// buttonCreate
|
// buttonCreate
|
||||||
//
|
//
|
||||||
this.buttonCreate.Location = new System.Drawing.Point(6, 74);
|
this.buttonCreate.Location = new System.Drawing.Point(8, 318);
|
||||||
this.buttonCreate.Name = "buttonCreate";
|
this.buttonCreate.Name = "buttonCreate";
|
||||||
this.buttonCreate.Size = new System.Drawing.Size(175, 23);
|
this.buttonCreate.Size = new System.Drawing.Size(175, 23);
|
||||||
this.buttonCreate.TabIndex = 10;
|
this.buttonCreate.TabIndex = 10;
|
||||||
this.buttonCreate.Text = "Добавить";
|
this.buttonCreate.Text = "Добавить самолёт";
|
||||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||||
this.buttonCreate.Click += new System.EventHandler(this.ButtonAdd_Click);
|
this.buttonCreate.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||||
//
|
//
|
||||||
// comboBoxMapSelector
|
|
||||||
//
|
|
||||||
this.comboBoxMapSelector.BackColor = System.Drawing.SystemColors.Window;
|
|
||||||
this.comboBoxMapSelector.FormattingEnabled = true;
|
|
||||||
this.comboBoxMapSelector.Items.AddRange(new object[] {
|
|
||||||
"Простая карта",
|
|
||||||
"Опасная карта",
|
|
||||||
"Облачная карта"});
|
|
||||||
this.comboBoxMapSelector.Location = new System.Drawing.Point(6, 22);
|
|
||||||
this.comboBoxMapSelector.Name = "comboBoxMapSelector";
|
|
||||||
this.comboBoxMapSelector.Size = new System.Drawing.Size(175, 23);
|
|
||||||
this.comboBoxMapSelector.TabIndex = 9;
|
|
||||||
this.comboBoxMapSelector.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(600, 450);
|
this.pictureBox.Size = new System.Drawing.Size(600, 588);
|
||||||
this.pictureBox.TabIndex = 1;
|
this.pictureBox.TabIndex = 1;
|
||||||
this.pictureBox.TabStop = false;
|
this.pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
@ -184,13 +240,15 @@
|
|||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
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(800, 588);
|
||||||
this.Controls.Add(this.pictureBox);
|
this.Controls.Add(this.pictureBox);
|
||||||
this.Controls.Add(this.groupBoxTools);
|
this.Controls.Add(this.groupBoxTools);
|
||||||
this.Name = "FormMapWithSetAirplane";
|
this.Name = "FormMapWithSetAirplane";
|
||||||
this.Text = "FormMapWithSetAirplane";
|
this.Text = "FormMapWithSetAirplane";
|
||||||
this.groupBoxTools.ResumeLayout(false);
|
this.groupBoxTools.ResumeLayout(false);
|
||||||
this.groupBoxTools.PerformLayout();
|
this.groupBoxTools.PerformLayout();
|
||||||
|
this.groupBoxMap.ResumeLayout(false);
|
||||||
|
this.groupBoxMap.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
@ -210,5 +268,10 @@
|
|||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
private Button buttonDown;
|
private Button buttonDown;
|
||||||
private Button buttonUp;
|
private Button buttonUp;
|
||||||
|
private GroupBox groupBoxMap;
|
||||||
|
private TextBox textBoxMapName;
|
||||||
|
private Button buttonAddMap;
|
||||||
|
private Button buttonRemoveMap;
|
||||||
|
private ListBox listBoxMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,4 @@
|
|||||||
using Cars;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@ -14,41 +13,64 @@ namespace Stormtrooper
|
|||||||
{
|
{
|
||||||
public partial class FormMapWithSetAirplane : Form
|
public partial class FormMapWithSetAirplane : Form
|
||||||
{
|
{
|
||||||
|
private readonly Dictionary<string, AbstractMap> _mapsDict = new()
|
||||||
|
{
|
||||||
|
{"Простая карта", new SimpleMap()},
|
||||||
|
{"Опасная карта", new DangerMap()},
|
||||||
|
{"Облачная карта", new CloudMap()}
|
||||||
|
};
|
||||||
|
/// <summary>
|
||||||
|
/// Объект от коллекции карт
|
||||||
|
/// </summary>
|
||||||
|
private readonly MapCollection _mapCollection;
|
||||||
private MapWithSetAirplaneGeneric<DrawningObject, AbstractMap> _mapAirsCollectionGeneric;
|
private MapWithSetAirplaneGeneric<DrawningObject, AbstractMap> _mapAirsCollectionGeneric;
|
||||||
public FormMapWithSetAirplane()
|
public FormMapWithSetAirplane()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_mapCollection = new MapCollection(pictureBox.Width, pictureBox.Height);
|
||||||
|
comboBoxMapSelector.Items.Clear();
|
||||||
|
foreach(var map in _mapsDict)
|
||||||
|
{
|
||||||
|
comboBoxMapSelector.Items.Add(map.Key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Выбор карты
|
/// Выбор карты
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
private void ReloadMaps()
|
||||||
{
|
{
|
||||||
AbstractMap map = null;
|
int index = listBoxMap.SelectedIndex;
|
||||||
switch (comboBoxMapSelector.Text)
|
listBoxMap.Items.Clear();
|
||||||
|
for (int i = 0; i < _mapCollection.Keys.Count; i++)
|
||||||
{
|
{
|
||||||
case "Простая карта":
|
listBoxMap.Items.Add(_mapCollection.Keys[i]);
|
||||||
map = new SimpleMap();
|
|
||||||
break;
|
|
||||||
case "Опасная карта":
|
|
||||||
map = new DangerMap();
|
|
||||||
break;
|
|
||||||
case "Облачная карта":
|
|
||||||
map = new CloudMap();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (map != null)
|
if (listBoxMap.Items.Count > 0 && (index == -1 || index >= listBoxMap.Items.Count))
|
||||||
{
|
{
|
||||||
_mapAirsCollectionGeneric = new MapWithSetAirplaneGeneric<DrawningObject, AbstractMap>(
|
listBoxMap.SelectedIndex = 0;
|
||||||
pictureBox.Width, pictureBox.Height, map);
|
|
||||||
}
|
}
|
||||||
else
|
else if (listBoxMap.Items.Count > 0 && index > -1 && index < listBoxMap.Items.Count)
|
||||||
{
|
{
|
||||||
_mapAirsCollectionGeneric = null;
|
listBoxMap.SelectedIndex = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void ButtonAddMap_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (comboBoxMapSelector.SelectedIndex == -1 || string.IsNullOrEmpty(textBoxMapName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!_mapsDict.ContainsKey(comboBoxMapSelector.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Нет такой карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_mapCollection.AddMap(textBoxMapName.Text, _mapsDict[comboBoxMapSelector.Text]);
|
||||||
|
ReloadMaps();
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта
|
/// Добавление объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -56,7 +78,7 @@ namespace Stormtrooper
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mapAirsCollectionGeneric == null)
|
if (listBoxMap.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -66,10 +88,10 @@ namespace Stormtrooper
|
|||||||
if(form.SelectedAirplane != null)
|
if(form.SelectedAirplane != null)
|
||||||
{
|
{
|
||||||
DrawningObject airplane = new (form.SelectedAirplane);
|
DrawningObject airplane = new (form.SelectedAirplane);
|
||||||
if (_mapAirsCollectionGeneric + airplane != -1)
|
if (_mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty] + airplane != -1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBox.Image = _mapAirsCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -90,6 +112,10 @@ namespace Stormtrooper
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonRemove_Click(object sender, EventArgs e)
|
private void ButtonRemove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (listBoxMap.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -99,10 +125,10 @@ namespace Stormtrooper
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||||
if (_mapAirsCollectionGeneric - pos != null)
|
if (_mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
pictureBox.Image = _mapAirsCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -116,11 +142,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 (_mapAirsCollectionGeneric == null)
|
if (listBoxMap.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapAirsCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вывод карты
|
/// Вывод карты
|
||||||
@ -129,11 +155,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 (_mapAirsCollectionGeneric == null)
|
if (listBoxMap.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapAirsCollectionGeneric.ShowOnMap();
|
pictureBox.Image = _mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перемещение
|
/// Перемещение
|
||||||
@ -142,7 +168,7 @@ 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 (_mapAirsCollectionGeneric == null)
|
if (listBoxMap.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -164,7 +190,25 @@ namespace Stormtrooper
|
|||||||
dir = Direction.Right;
|
dir = Direction.Right;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapAirsCollectionGeneric.MoveObject(dir);
|
pictureBox.Image = _mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void listBoxMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
pictureBox.Image = _mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
|
}
|
||||||
|
private void ButtonRemoveMap_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxMap.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MessageBox.Show($"Удалить карту {listBoxMap.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
_mapCollection.DelMap(listBoxMap.SelectedItem?.ToString() ?? string.Empty);
|
||||||
|
ReloadMaps();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
81
Stormtrooper/Stormtrooper/MapCollection.cs
Normal file
81
Stormtrooper/Stormtrooper/MapCollection.cs
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Stormtrooper
|
||||||
|
{
|
||||||
|
internal class MapCollection
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Словарь (хранилище) с картами
|
||||||
|
/// </summary>
|
||||||
|
readonly Dictionary<string, MapWithSetAirplaneGeneric<DrawningObject, AbstractMap>> _mapStorages;
|
||||||
|
/// <summary>
|
||||||
|
/// Возвращение списка названий карт
|
||||||
|
/// </summary>
|
||||||
|
public List<string> Keys => _mapStorages.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 MapCollection(int pictureWidth, int pictureHeight)
|
||||||
|
{
|
||||||
|
_mapStorages = new Dictionary<string, MapWithSetAirplaneGeneric<DrawningObject, AbstractMap>>();
|
||||||
|
_pictureWidth = pictureWidth;
|
||||||
|
_pictureHeight = pictureHeight;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название карты</param>
|
||||||
|
/// <param name="map">Карта</param>
|
||||||
|
public void AddMap(string name, AbstractMap map)
|
||||||
|
{
|
||||||
|
// Добавление карты
|
||||||
|
MapWithSetAirplaneGeneric<DrawningObject, AbstractMap> newMap = new(_pictureWidth, _pictureHeight, map);
|
||||||
|
if (!_mapStorages.ContainsKey(name))
|
||||||
|
_mapStorages.Add(name, newMap);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название карты</param>
|
||||||
|
public void DelMap(string name)
|
||||||
|
{
|
||||||
|
// Удаление карты
|
||||||
|
if (!_mapStorages.ContainsKey(name))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_mapStorages.Remove(name);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Доступ к гавани
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ind"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public MapWithSetAirplaneGeneric<DrawningObject, AbstractMap> this[string index]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
// Получение объекта
|
||||||
|
if (_mapStorages.ContainsKey(index))
|
||||||
|
{
|
||||||
|
return _mapStorages[index];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -87,15 +87,10 @@ namespace Stormtrooper
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Bitmap ShowOnMap()
|
public Bitmap ShowOnMap()
|
||||||
{
|
{
|
||||||
Shaking();
|
foreach (var air in _setAirs.GetBoats())
|
||||||
for (int i = 0; i < _setAirs.Count; i++)
|
|
||||||
{
|
|
||||||
var air = _setAirs.Get(i);
|
|
||||||
if (air != null)
|
|
||||||
{
|
{
|
||||||
return _map.CreateMap(_pictureWidth, _pictureHeight, air);
|
return _map.CreateMap(_pictureWidth, _pictureHeight, air);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return new(_pictureWidth, _pictureHeight);
|
return new(_pictureWidth, _pictureHeight);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -120,11 +115,11 @@ namespace Stormtrooper
|
|||||||
int j = _setAirs.Count - 1;
|
int j = _setAirs.Count - 1;
|
||||||
for (int i = 0; i < _setAirs.Count; i++)
|
for (int i = 0; i < _setAirs.Count; i++)
|
||||||
{
|
{
|
||||||
if (_setAirs.Get(i) == null)
|
if (_setAirs[i] == null)
|
||||||
{
|
{
|
||||||
for (; j > i; j--)
|
for (; j > i; j--)
|
||||||
{
|
{
|
||||||
var air = _setAirs.Get(j);
|
var air = _setAirs[j];
|
||||||
if (air != null)
|
if (air != null)
|
||||||
{
|
{
|
||||||
_setAirs.Insert(air, i);
|
_setAirs.Insert(air, i);
|
||||||
@ -171,22 +166,16 @@ namespace Stormtrooper
|
|||||||
int currentWidth = width - 1;
|
int currentWidth = width - 1;
|
||||||
int currentHeight = 0;
|
int currentHeight = 0;
|
||||||
|
|
||||||
for (int i = 0; i < _setAirs.Count; i++)
|
int i = 0;
|
||||||
|
foreach (var air in _setAirs.GetBoats())
|
||||||
{
|
{
|
||||||
|
|
||||||
_setAirs.Get(i)?.SetObject(currentWidth * _placeSizeWidth,
|
air.SetObject(currentWidth * _placeSizeWidth,
|
||||||
currentHeight * _placeSizeHeight,
|
currentHeight * _placeSizeHeight,
|
||||||
_pictureWidth, _pictureHeight);
|
_pictureWidth, _pictureHeight);
|
||||||
_setAirs.Get(i)?.DrawningObject(g);
|
air.DrawningObject(g);
|
||||||
|
|
||||||
if (currentWidth > 0)
|
i++;
|
||||||
currentWidth--;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
currentWidth = width - 1;
|
|
||||||
currentHeight++;
|
|
||||||
}
|
|
||||||
if (currentHeight > height) return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,20 +10,22 @@ namespace Stormtrooper
|
|||||||
where T : class
|
where T : class
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Массив объектов, которые храним
|
/// List объектов, которые храним
|
||||||
/// </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;
|
||||||
|
private readonly int _maxCount;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="count"></param>
|
/// <param name="count"></param>
|
||||||
public SetAirplaneGeneric(int count)
|
public SetAirplaneGeneric(int count)
|
||||||
{
|
{
|
||||||
_places = new T[count];
|
_places = new List<T>();
|
||||||
|
_maxCount = count;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в набор
|
/// Добавление объекта в набор
|
||||||
@ -32,6 +34,8 @@ namespace Stormtrooper
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int Insert(T airplane)
|
public int Insert(T airplane)
|
||||||
{
|
{
|
||||||
|
if (Count == _maxCount)
|
||||||
|
return -1;
|
||||||
Insert(airplane, 0);
|
Insert(airplane, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -43,42 +47,10 @@ namespace Stormtrooper
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int Insert(T airplane, int position)
|
public int Insert(T airplane, int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count)
|
if (position < 0 || position >= _maxCount - 1)
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
_places.Insert(position, airplane);
|
||||||
if (_places[position] == null || _places[position] == default(T))
|
|
||||||
{
|
|
||||||
_places[position] = airplane;
|
|
||||||
return position;
|
return position;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bool hasEmptySpace = false;
|
|
||||||
int indexOfEmptyPlace = 0;
|
|
||||||
for (int i = position + 1; i < Count; ++i)
|
|
||||||
{
|
|
||||||
if (_places[i] == null || _places[i] == default(T))
|
|
||||||
{
|
|
||||||
hasEmptySpace = true;
|
|
||||||
indexOfEmptyPlace = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hasEmptySpace)
|
|
||||||
{
|
|
||||||
for (int i = indexOfEmptyPlace; i > position; --i)
|
|
||||||
{
|
|
||||||
_places[i] = _places[i - 1];
|
|
||||||
}
|
|
||||||
_places[position] = airplane;
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -88,26 +60,49 @@ namespace Stormtrooper
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public T Remove(int position)
|
public T Remove(int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count)
|
if (Count == 0 || position < 0 || position >= _maxCount)
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
T air = _places[position];
|
||||||
T memoryObj = _places[position];
|
|
||||||
_places[position] = null;
|
_places[position] = null;
|
||||||
return memoryObj;
|
return air;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение объекта из набора по позиции
|
/// Получение объекта из набора по позиции
|
||||||
/// </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 >= Count)
|
if (position < 0 || position >= Count)
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
return _places[position];
|
return _places[position];
|
||||||
}
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
// Проверка позиции
|
||||||
|
if (position < 0 || position >= Count)
|
||||||
|
return;
|
||||||
|
// Вставка по позиции
|
||||||
|
_places[position] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<T> GetBoats()
|
||||||
|
{
|
||||||
|
foreach (var boat in _places)
|
||||||
|
{
|
||||||
|
if (boat != null)
|
||||||
|
{
|
||||||
|
yield return boat;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user