Second Stage of lab work
This commit is contained in:
parent
878637552a
commit
e2129a1e01
125
ArmoredVehicle/FormMapWithSetMachine.Designer.cs
generated
125
ArmoredVehicle/FormMapWithSetMachine.Designer.cs
generated
@ -30,6 +30,12 @@
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMapWithSetMachine));
|
||||
this.groupBoxInstruments = new System.Windows.Forms.GroupBox();
|
||||
this.groupBoxMap = 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.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
this.textBoxNewMapName = new System.Windows.Forms.TextBox();
|
||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||
this.ButtonDown = new System.Windows.Forms.Button();
|
||||
this.ButtonRight = new System.Windows.Forms.Button();
|
||||
@ -39,14 +45,15 @@
|
||||
this.buttonStore = new System.Windows.Forms.Button();
|
||||
this.buttonDelete = new System.Windows.Forms.Button();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.comboBoxMap = new System.Windows.Forms.ComboBox();
|
||||
this.pictureBoxImage = new System.Windows.Forms.PictureBox();
|
||||
this.groupBoxInstruments.SuspendLayout();
|
||||
this.groupBoxMap.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxImage)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBoxInstruments
|
||||
//
|
||||
this.groupBoxInstruments.Controls.Add(this.groupBoxMap);
|
||||
this.groupBoxInstruments.Controls.Add(this.maskedTextBoxPosition);
|
||||
this.groupBoxInstruments.Controls.Add(this.ButtonDown);
|
||||
this.groupBoxInstruments.Controls.Add(this.ButtonRight);
|
||||
@ -56,18 +63,84 @@
|
||||
this.groupBoxInstruments.Controls.Add(this.buttonStore);
|
||||
this.groupBoxInstruments.Controls.Add(this.buttonDelete);
|
||||
this.groupBoxInstruments.Controls.Add(this.buttonAdd);
|
||||
this.groupBoxInstruments.Controls.Add(this.comboBoxMap);
|
||||
this.groupBoxInstruments.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.groupBoxInstruments.Location = new System.Drawing.Point(728, 0);
|
||||
this.groupBoxInstruments.Location = new System.Drawing.Point(964, 0);
|
||||
this.groupBoxInstruments.Name = "groupBoxInstruments";
|
||||
this.groupBoxInstruments.Size = new System.Drawing.Size(300, 644);
|
||||
this.groupBoxInstruments.Size = new System.Drawing.Size(300, 910);
|
||||
this.groupBoxInstruments.TabIndex = 0;
|
||||
this.groupBoxInstruments.TabStop = false;
|
||||
this.groupBoxInstruments.Text = "Инструменты";
|
||||
//
|
||||
// groupBoxMap
|
||||
//
|
||||
this.groupBoxMap.Controls.Add(this.buttonDeleteMap);
|
||||
this.groupBoxMap.Controls.Add(this.listBoxMaps);
|
||||
this.groupBoxMap.Controls.Add(this.buttonAddMap);
|
||||
this.groupBoxMap.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.groupBoxMap.Controls.Add(this.textBoxNewMapName);
|
||||
this.groupBoxMap.Location = new System.Drawing.Point(13, 30);
|
||||
this.groupBoxMap.Name = "groupBoxMap";
|
||||
this.groupBoxMap.Size = new System.Drawing.Size(267, 408);
|
||||
this.groupBoxMap.TabIndex = 19;
|
||||
this.groupBoxMap.TabStop = false;
|
||||
this.groupBoxMap.Text = "Карты";
|
||||
//
|
||||
// buttonDeleteMap
|
||||
//
|
||||
this.buttonDeleteMap.Location = new System.Drawing.Point(5, 330);
|
||||
this.buttonDeleteMap.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.buttonDeleteMap.Name = "buttonDeleteMap";
|
||||
this.buttonDeleteMap.Size = new System.Drawing.Size(250, 58);
|
||||
this.buttonDeleteMap.TabIndex = 6;
|
||||
this.buttonDeleteMap.Text = "Удалить карту";
|
||||
this.buttonDeleteMap.UseVisualStyleBackColor = true;
|
||||
this.buttonDeleteMap.Click += new System.EventHandler(this.ButtonDeleteMap_Click);
|
||||
//
|
||||
// listBoxMaps
|
||||
//
|
||||
this.listBoxMaps.FormattingEnabled = true;
|
||||
this.listBoxMaps.ItemHeight = 25;
|
||||
this.listBoxMaps.Location = new System.Drawing.Point(5, 189);
|
||||
this.listBoxMaps.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.listBoxMaps.Name = "listBoxMaps";
|
||||
this.listBoxMaps.Size = new System.Drawing.Size(248, 129);
|
||||
this.listBoxMaps.TabIndex = 5;
|
||||
this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.ListBoxMaps_SelectedIndexChanged);
|
||||
//
|
||||
// buttonAddMap
|
||||
//
|
||||
this.buttonAddMap.Location = new System.Drawing.Point(5, 121);
|
||||
this.buttonAddMap.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.buttonAddMap.Name = "buttonAddMap";
|
||||
this.buttonAddMap.Size = new System.Drawing.Size(250, 58);
|
||||
this.buttonAddMap.TabIndex = 4;
|
||||
this.buttonAddMap.Text = "Добавить карту";
|
||||
this.buttonAddMap.UseVisualStyleBackColor = true;
|
||||
this.buttonAddMap.Click += new System.EventHandler(this.ButtonAddMap_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(5, 73);
|
||||
this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(248, 33);
|
||||
this.comboBoxSelectorMap.TabIndex = 3;
|
||||
//
|
||||
// textBoxNewMapName
|
||||
//
|
||||
this.textBoxNewMapName.Location = new System.Drawing.Point(5, 32);
|
||||
this.textBoxNewMapName.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.textBoxNewMapName.Name = "textBoxNewMapName";
|
||||
this.textBoxNewMapName.Size = new System.Drawing.Size(248, 31);
|
||||
this.textBoxNewMapName.TabIndex = 1;
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(18, 179);
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(10, 506);
|
||||
this.maskedTextBoxPosition.Mask = "00";
|
||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(270, 31);
|
||||
@ -78,7 +151,7 @@
|
||||
this.ButtonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonDown.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("ButtonDown.BackgroundImage")));
|
||||
this.ButtonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonDown.Location = new System.Drawing.Point(139, 555);
|
||||
this.ButtonDown.Location = new System.Drawing.Point(129, 823);
|
||||
this.ButtonDown.Name = "ButtonDown";
|
||||
this.ButtonDown.Size = new System.Drawing.Size(40, 36);
|
||||
this.ButtonDown.TabIndex = 17;
|
||||
@ -90,7 +163,7 @@
|
||||
this.ButtonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonRight.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("ButtonRight.BackgroundImage")));
|
||||
this.ButtonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonRight.Location = new System.Drawing.Point(182, 508);
|
||||
this.ButtonRight.Location = new System.Drawing.Point(172, 776);
|
||||
this.ButtonRight.Name = "ButtonRight";
|
||||
this.ButtonRight.Size = new System.Drawing.Size(40, 36);
|
||||
this.ButtonRight.TabIndex = 16;
|
||||
@ -102,7 +175,7 @@
|
||||
this.ButtonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonLeft.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("ButtonLeft.BackgroundImage")));
|
||||
this.ButtonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonLeft.Location = new System.Drawing.Point(99, 510);
|
||||
this.ButtonLeft.Location = new System.Drawing.Point(89, 778);
|
||||
this.ButtonLeft.Name = "ButtonLeft";
|
||||
this.ButtonLeft.Size = new System.Drawing.Size(40, 36);
|
||||
this.ButtonLeft.TabIndex = 15;
|
||||
@ -114,7 +187,7 @@
|
||||
this.ButtonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonUp.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("ButtonUp.BackgroundImage")));
|
||||
this.ButtonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonUp.Location = new System.Drawing.Point(139, 460);
|
||||
this.ButtonUp.Location = new System.Drawing.Point(129, 728);
|
||||
this.ButtonUp.Name = "ButtonUp";
|
||||
this.ButtonUp.Size = new System.Drawing.Size(40, 36);
|
||||
this.ButtonUp.TabIndex = 14;
|
||||
@ -123,7 +196,7 @@
|
||||
//
|
||||
// buttonMap
|
||||
//
|
||||
this.buttonMap.Location = new System.Drawing.Point(26, 373);
|
||||
this.buttonMap.Location = new System.Drawing.Point(18, 680);
|
||||
this.buttonMap.Name = "buttonMap";
|
||||
this.buttonMap.Size = new System.Drawing.Size(262, 34);
|
||||
this.buttonMap.TabIndex = 5;
|
||||
@ -133,7 +206,7 @@
|
||||
//
|
||||
// buttonStore
|
||||
//
|
||||
this.buttonStore.Location = new System.Drawing.Point(24, 307);
|
||||
this.buttonStore.Location = new System.Drawing.Point(16, 614);
|
||||
this.buttonStore.Name = "buttonStore";
|
||||
this.buttonStore.Size = new System.Drawing.Size(264, 34);
|
||||
this.buttonStore.TabIndex = 4;
|
||||
@ -143,7 +216,7 @@
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
this.buttonDelete.Location = new System.Drawing.Point(20, 234);
|
||||
this.buttonDelete.Location = new System.Drawing.Point(12, 561);
|
||||
this.buttonDelete.Name = "buttonDelete";
|
||||
this.buttonDelete.Size = new System.Drawing.Size(268, 34);
|
||||
this.buttonDelete.TabIndex = 3;
|
||||
@ -153,7 +226,7 @@
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(13, 117);
|
||||
this.buttonAdd.Location = new System.Drawing.Point(5, 444);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(275, 34);
|
||||
this.buttonAdd.TabIndex = 1;
|
||||
@ -161,25 +234,12 @@
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||
//
|
||||
// comboBoxMap
|
||||
//
|
||||
this.comboBoxMap.FormattingEnabled = true;
|
||||
this.comboBoxMap.Items.AddRange(new object[] {
|
||||
"Простая карта",
|
||||
"Горизонтальная карта",
|
||||
"Вертикальная карта"});
|
||||
this.comboBoxMap.Location = new System.Drawing.Point(9, 41);
|
||||
this.comboBoxMap.Name = "comboBoxMap";
|
||||
this.comboBoxMap.Size = new System.Drawing.Size(279, 33);
|
||||
this.comboBoxMap.TabIndex = 0;
|
||||
this.comboBoxMap.SelectedIndexChanged += new System.EventHandler(this.comboBoxMap_SelectedIndexChanged);
|
||||
//
|
||||
// pictureBoxImage
|
||||
//
|
||||
this.pictureBoxImage.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxImage.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxImage.Name = "pictureBoxImage";
|
||||
this.pictureBoxImage.Size = new System.Drawing.Size(728, 644);
|
||||
this.pictureBoxImage.Size = new System.Drawing.Size(964, 910);
|
||||
this.pictureBoxImage.TabIndex = 1;
|
||||
this.pictureBoxImage.TabStop = false;
|
||||
//
|
||||
@ -187,13 +247,15 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1028, 644);
|
||||
this.ClientSize = new System.Drawing.Size(1264, 910);
|
||||
this.Controls.Add(this.pictureBoxImage);
|
||||
this.Controls.Add(this.groupBoxInstruments);
|
||||
this.Name = "FormMapWithSetMachine";
|
||||
this.Text = "Карта с набором объектов";
|
||||
this.groupBoxInstruments.ResumeLayout(false);
|
||||
this.groupBoxInstruments.PerformLayout();
|
||||
this.groupBoxMap.ResumeLayout(false);
|
||||
this.groupBoxMap.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxImage)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
@ -206,12 +268,17 @@
|
||||
private Button buttonStore;
|
||||
private Button buttonDelete;
|
||||
private Button buttonAdd;
|
||||
private ComboBox comboBoxMap;
|
||||
private PictureBox pictureBoxImage;
|
||||
private MaskedTextBox maskedTextBoxPosition;
|
||||
private Button ButtonDown;
|
||||
private Button ButtonRight;
|
||||
private Button ButtonLeft;
|
||||
private Button ButtonUp;
|
||||
private GroupBox groupBoxMap;
|
||||
private Button buttonDeleteMap;
|
||||
private ListBox listBoxMaps;
|
||||
private Button buttonAddMap;
|
||||
private ComboBox comboBoxSelectorMap;
|
||||
private TextBox textBoxNewMapName;
|
||||
}
|
||||
}
|
@ -11,17 +11,76 @@ using System.Windows.Forms;
|
||||
namespace ArmoredVehicle
|
||||
{
|
||||
public partial class FormMapWithSetMachine : Form
|
||||
{
|
||||
{
|
||||
/// <summary>
|
||||
/// Объект от класса карты с набором объектов
|
||||
/// </summary>
|
||||
private MapWithSetMachineGeneric<DrawningObject, AbstractMap> _mapCarsCollectionGeneric;
|
||||
/// Словарь для выпадающего списка
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, AbstractMap> _mapsDict = new()
|
||||
{
|
||||
{ "Простая карта", new SimpleMap() },
|
||||
{ "Вертикальная карта", new VerticalMap() },
|
||||
{ "Горизонтальная карта", new HorizontalMap() }
|
||||
};
|
||||
/// <summary>
|
||||
/// Объект от коллекции карт
|
||||
/// </summary>
|
||||
private readonly MapsCollection _mapsCollection;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormMapWithSetMachine()
|
||||
{
|
||||
InitializeComponent();
|
||||
_mapsCollection = new MapsCollection(pictureBoxImage.Width, pictureBoxImage.Height);
|
||||
comboBoxSelectorMap.Items.Clear();
|
||||
foreach (var elem in _mapsDict)
|
||||
{
|
||||
comboBoxSelectorMap.Items.Add(elem.Key);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Заполнение listBoxMaps
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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>
|
||||
@ -29,31 +88,30 @@ namespace ArmoredVehicle
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void comboBoxMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||
private void ListBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
AbstractMap map = null;
|
||||
switch (comboBoxMap.Text)
|
||||
pictureBoxImage.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)
|
||||
{
|
||||
case "Простая карта":
|
||||
map = new SimpleMap();
|
||||
break;
|
||||
case "Горизонтальная карта":
|
||||
map = new HorizontalMap();
|
||||
break;
|
||||
case "Вертикальная карта":
|
||||
map = new VerticalMap();
|
||||
break;
|
||||
return;
|
||||
}
|
||||
if (map != null)
|
||||
|
||||
if (MessageBox.Show($"Удалить карту {listBoxMaps.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_mapCarsCollectionGeneric = new MapWithSetMachineGeneric<DrawningObject, AbstractMap>(
|
||||
pictureBoxImage.Width, pictureBoxImage.Height, map);
|
||||
}
|
||||
else
|
||||
{
|
||||
_mapCarsCollectionGeneric = null;
|
||||
_mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty);
|
||||
ReloadMaps();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление объекта
|
||||
/// </summary>
|
||||
@ -61,23 +119,42 @@ namespace ArmoredVehicle
|
||||
/// <param name="e"></param>
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapCarsCollectionGeneric == null)
|
||||
//if (_mapCarsCollectionGeneric == null)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
//MainForm form = new();
|
||||
//if (form.ShowDialog() == DialogResult.OK)
|
||||
//{
|
||||
// if (form.SelectedMachine == null)
|
||||
// {
|
||||
// MessageBox.Show("Вы не создали объект");
|
||||
// return;
|
||||
// }
|
||||
// DrawningObject machine = new(form.SelectedMachine);
|
||||
// if (_mapCarsCollectionGeneric + machine != -1)
|
||||
// {
|
||||
// MessageBox.Show("Объект добавлен");
|
||||
// pictureBoxImage.Image = _mapCarsCollectionGeneric.ShowSet();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// MessageBox.Show("Не удалось добавить объект");
|
||||
// }
|
||||
//}
|
||||
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MainForm form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.SelectedMachine == null)
|
||||
{
|
||||
MessageBox.Show("Вы не создали объект");
|
||||
return;
|
||||
}
|
||||
DrawningObject machine = new(form.SelectedMachine);
|
||||
if (_mapCarsCollectionGeneric + machine != -1)
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + machine != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxImage.Image = _mapCarsCollectionGeneric.ShowSet();
|
||||
pictureBoxImage.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -86,9 +163,6 @@ namespace ArmoredVehicle
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///<summary>
|
||||
/// Удаление объекта
|
||||
/// </summary>
|
||||
@ -105,10 +179,10 @@ namespace ArmoredVehicle
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if (_mapCarsCollectionGeneric - pos != null)
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxImage.Image = _mapCarsCollectionGeneric.ShowSet();
|
||||
pictureBoxImage.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -123,11 +197,11 @@ namespace ArmoredVehicle
|
||||
/// <param name="e"></param>
|
||||
private void buttonStore_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapCarsCollectionGeneric == null)
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxImage.Image = _mapCarsCollectionGeneric.ShowSet();
|
||||
pictureBoxImage.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -137,11 +211,11 @@ namespace ArmoredVehicle
|
||||
/// <param name="e"></param>
|
||||
private void buttonMap_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapCarsCollectionGeneric == null)
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxImage.Image = _mapCarsCollectionGeneric.ShowOnMap();
|
||||
pictureBoxImage.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -151,7 +225,7 @@ namespace ArmoredVehicle
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapCarsCollectionGeneric == null)
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -173,7 +247,7 @@ namespace ArmoredVehicle
|
||||
dir = Direction.Right;
|
||||
break;
|
||||
}
|
||||
pictureBoxImage.Image = _mapCarsCollectionGeneric.MoveObject(dir);
|
||||
pictureBoxImage.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user