Polevoy S.V Lab_work4 #4
@ -29,29 +29,35 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.toolsGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.mapsGroupBox = 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.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
||||
this.buttonShowStorage = new System.Windows.Forms.Button();
|
||||
this.buttonRemoveArtillery = new System.Windows.Forms.Button();
|
||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||
this.buttonAddArtillery = new System.Windows.Forms.Button();
|
||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.pictureBoxArtilleries = new System.Windows.Forms.PictureBox();
|
||||
this.toolsGroupBox.SuspendLayout();
|
||||
this.mapsGroupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxArtilleries)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// toolsGroupBox
|
||||
//
|
||||
this.toolsGroupBox.Controls.Add(this.mapsGroupBox);
|
||||
this.toolsGroupBox.Controls.Add(this.buttonShowOnMap);
|
||||
this.toolsGroupBox.Controls.Add(this.buttonShowStorage);
|
||||
this.toolsGroupBox.Controls.Add(this.buttonRemoveArtillery);
|
||||
this.toolsGroupBox.Controls.Add(this.maskedTextBoxPosition);
|
||||
this.toolsGroupBox.Controls.Add(this.buttonAddArtillery);
|
||||
this.toolsGroupBox.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.toolsGroupBox.Controls.Add(this.buttonRight);
|
||||
this.toolsGroupBox.Controls.Add(this.buttonDown);
|
||||
this.toolsGroupBox.Controls.Add(this.buttonUp);
|
||||
@ -59,14 +65,77 @@
|
||||
this.toolsGroupBox.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.toolsGroupBox.Location = new System.Drawing.Point(600, 0);
|
||||
this.toolsGroupBox.Name = "toolsGroupBox";
|
||||
this.toolsGroupBox.Size = new System.Drawing.Size(200, 450);
|
||||
this.toolsGroupBox.Size = new System.Drawing.Size(200, 596);
|
||||
this.toolsGroupBox.TabIndex = 0;
|
||||
this.toolsGroupBox.TabStop = false;
|
||||
this.toolsGroupBox.Text = "Инструменты";
|
||||
//
|
||||
// mapsGroupBox
|
||||
//
|
||||
this.mapsGroupBox.Controls.Add(this.buttonDeleteMap);
|
||||
this.mapsGroupBox.Controls.Add(this.listBoxMaps);
|
||||
this.mapsGroupBox.Controls.Add(this.buttonAddMap);
|
||||
this.mapsGroupBox.Controls.Add(this.textBoxNewMapName);
|
||||
this.mapsGroupBox.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.mapsGroupBox.Location = new System.Drawing.Point(6, 22);
|
||||
this.mapsGroupBox.Name = "mapsGroupBox";
|
||||
this.mapsGroupBox.Size = new System.Drawing.Size(188, 258);
|
||||
this.mapsGroupBox.TabIndex = 25;
|
||||
this.mapsGroupBox.TabStop = false;
|
||||
this.mapsGroupBox.Text = "Карты";
|
||||
//
|
||||
// buttonDeleteMap
|
||||
//
|
||||
this.buttonDeleteMap.Location = new System.Drawing.Point(12, 218);
|
||||
this.buttonDeleteMap.Name = "buttonDeleteMap";
|
||||
this.buttonDeleteMap.Size = new System.Drawing.Size(170, 32);
|
||||
this.buttonDeleteMap.TabIndex = 26;
|
||||
this.buttonDeleteMap.Text = "Удалить карту";
|
||||
this.buttonDeleteMap.UseVisualStyleBackColor = true;
|
||||
this.buttonDeleteMap.Click += new System.EventHandler(this.buttonDeleteMap_Click);
|
||||
//
|
||||
// listBoxMaps
|
||||
//
|
||||
this.listBoxMaps.FormattingEnabled = true;
|
||||
this.listBoxMaps.ItemHeight = 15;
|
||||
this.listBoxMaps.Location = new System.Drawing.Point(12, 118);
|
||||
this.listBoxMaps.Name = "listBoxMaps";
|
||||
this.listBoxMaps.Size = new System.Drawing.Size(170, 94);
|
||||
this.listBoxMaps.TabIndex = 27;
|
||||
this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.listBoxMaps_SelectedIndexChanged);
|
||||
//
|
||||
// buttonAddMap
|
||||
//
|
||||
this.buttonAddMap.Location = new System.Drawing.Point(12, 80);
|
||||
this.buttonAddMap.Name = "buttonAddMap";
|
||||
this.buttonAddMap.Size = new System.Drawing.Size(170, 32);
|
||||
this.buttonAddMap.TabIndex = 26;
|
||||
this.buttonAddMap.Text = "Добавить карту";
|
||||
this.buttonAddMap.UseVisualStyleBackColor = true;
|
||||
this.buttonAddMap.Click += new System.EventHandler(this.buttonAddMap_Click);
|
||||
//
|
||||
// textBoxNewMapName
|
||||
//
|
||||
this.textBoxNewMapName.Location = new System.Drawing.Point(12, 22);
|
||||
this.textBoxNewMapName.Name = "textBoxNewMapName";
|
||||
this.textBoxNewMapName.Size = new System.Drawing.Size(170, 23);
|
||||
this.textBoxNewMapName.TabIndex = 0;
|
||||
//
|
||||
// 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(12, 51);
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(170, 23);
|
||||
this.comboBoxSelectorMap.TabIndex = 19;
|
||||
//
|
||||
// buttonShowOnMap
|
||||
//
|
||||
this.buttonShowOnMap.Location = new System.Drawing.Point(13, 315);
|
||||
this.buttonShowOnMap.Location = new System.Drawing.Point(13, 470);
|
||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||
this.buttonShowOnMap.Size = new System.Drawing.Size(175, 32);
|
||||
this.buttonShowOnMap.TabIndex = 24;
|
||||
@ -76,7 +145,7 @@
|
||||
//
|
||||
// buttonShowStorage
|
||||
//
|
||||
this.buttonShowStorage.Location = new System.Drawing.Point(13, 249);
|
||||
this.buttonShowStorage.Location = new System.Drawing.Point(13, 423);
|
||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||
this.buttonShowStorage.Size = new System.Drawing.Size(175, 32);
|
||||
this.buttonShowStorage.TabIndex = 23;
|
||||
@ -86,7 +155,7 @@
|
||||
//
|
||||
// buttonRemoveArtillery
|
||||
//
|
||||
this.buttonRemoveArtillery.Location = new System.Drawing.Point(13, 177);
|
||||
this.buttonRemoveArtillery.Location = new System.Drawing.Point(13, 376);
|
||||
this.buttonRemoveArtillery.Name = "buttonRemoveArtillery";
|
||||
this.buttonRemoveArtillery.Size = new System.Drawing.Size(175, 32);
|
||||
this.buttonRemoveArtillery.TabIndex = 22;
|
||||
@ -96,7 +165,7 @@
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(13, 148);
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(13, 347);
|
||||
this.maskedTextBoxPosition.Mask = "00";
|
||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(175, 23);
|
||||
@ -104,7 +173,7 @@
|
||||
//
|
||||
// buttonAddArtillery
|
||||
//
|
||||
this.buttonAddArtillery.Location = new System.Drawing.Point(13, 83);
|
||||
this.buttonAddArtillery.Location = new System.Drawing.Point(13, 309);
|
||||
this.buttonAddArtillery.Name = "buttonAddArtillery";
|
||||
this.buttonAddArtillery.Size = new System.Drawing.Size(175, 32);
|
||||
this.buttonAddArtillery.TabIndex = 20;
|
||||
@ -112,25 +181,12 @@
|
||||
this.buttonAddArtillery.UseVisualStyleBackColor = true;
|
||||
this.buttonAddArtillery.Click += new System.EventHandler(this.buttonAddArtillery_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(13, 22);
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(175, 23);
|
||||
this.comboBoxSelectorMap.TabIndex = 19;
|
||||
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.comboBoxSelectorMap_SelectedIndexChanged);
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::SelfPropelledArtilleryUnit.Properties.Resources.ArrowRight;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonRight.Location = new System.Drawing.Point(124, 399);
|
||||
this.buttonRight.Location = new System.Drawing.Point(124, 545);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonRight.TabIndex = 18;
|
||||
@ -142,7 +198,7 @@
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::SelfPropelledArtilleryUnit.Properties.Resources.ArrowDown;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonDown.Location = new System.Drawing.Point(88, 399);
|
||||
this.buttonDown.Location = new System.Drawing.Point(88, 545);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonDown.TabIndex = 17;
|
||||
@ -154,7 +210,7 @@
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::SelfPropelledArtilleryUnit.Properties.Resources.ArrowUp;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonUp.Location = new System.Drawing.Point(88, 366);
|
||||
this.buttonUp.Location = new System.Drawing.Point(88, 512);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonUp.TabIndex = 16;
|
||||
@ -166,7 +222,7 @@
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::SelfPropelledArtilleryUnit.Properties.Resources.ArrowLeft;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(54, 399);
|
||||
this.buttonLeft.Location = new System.Drawing.Point(54, 545);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonLeft.TabIndex = 15;
|
||||
@ -178,7 +234,7 @@
|
||||
this.pictureBoxArtilleries.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxArtilleries.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxArtilleries.Name = "pictureBoxArtilleries";
|
||||
this.pictureBoxArtilleries.Size = new System.Drawing.Size(600, 450);
|
||||
this.pictureBoxArtilleries.Size = new System.Drawing.Size(600, 596);
|
||||
this.pictureBoxArtilleries.TabIndex = 1;
|
||||
this.pictureBoxArtilleries.TabStop = false;
|
||||
//
|
||||
@ -186,13 +242,15 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.ClientSize = new System.Drawing.Size(800, 596);
|
||||
this.Controls.Add(this.pictureBoxArtilleries);
|
||||
this.Controls.Add(this.toolsGroupBox);
|
||||
this.Name = "FormMapWithSetArtilleries";
|
||||
this.Text = "Artillery";
|
||||
this.toolsGroupBox.ResumeLayout(false);
|
||||
this.toolsGroupBox.PerformLayout();
|
||||
this.mapsGroupBox.ResumeLayout(false);
|
||||
this.mapsGroupBox.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxArtilleries)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
@ -212,5 +270,10 @@
|
||||
private Button buttonRemoveArtillery;
|
||||
private MaskedTextBox maskedTextBoxPosition;
|
||||
private Button buttonAddArtillery;
|
||||
private GroupBox mapsGroupBox;
|
||||
private Button buttonDeleteMap;
|
||||
private ListBox listBoxMaps;
|
||||
private Button buttonAddMap;
|
||||
private TextBox textBoxNewMapName;
|
||||
}
|
||||
}
|
@ -13,49 +13,93 @@ namespace Artilleries
|
||||
{
|
||||
public partial class FormMapWithSetArtilleries : Form
|
||||
{
|
||||
private MapWithSetArtilleriesGeneric<DrawingObjectArtillery, AbstractMap> _mapArtilleriesCollectionGeneric;
|
||||
private readonly Dictionary<string, AbstractMap> _mapsDict = new()
|
||||
{
|
||||
{ "Простая карта", new SimpleMap() },
|
||||
{ "Лесная карта", new ForestMap() }
|
||||
};
|
||||
|
||||
private readonly MapsCollection _mapsCollection;
|
||||
|
||||
public FormMapWithSetArtilleries()
|
||||
{
|
||||
InitializeComponent();
|
||||
_mapsCollection = new MapsCollection(pictureBoxArtilleries.Width, pictureBoxArtilleries.Height);
|
||||
comboBoxSelectorMap.Items.Clear();
|
||||
foreach(var element in _mapsDict)
|
||||
{
|
||||
comboBoxSelectorMap.Items.Add(element.Key);
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||
private void ReloadMaps()
|
||||
{
|
||||
AbstractMap map = null;
|
||||
switch (comboBoxSelectorMap.Text)
|
||||
int index = listBoxMaps.SelectedIndex;
|
||||
|
||||
listBoxMaps.Items.Clear();
|
||||
for (int i = 0; i < _mapsCollection.Keys.Count; i++)
|
||||
{
|
||||
case "Простая карта":
|
||||
map = new SimpleMap();
|
||||
break;
|
||||
case "Лесная карта":
|
||||
map = new ForestMap();
|
||||
break;
|
||||
listBoxMaps.Items.Add(_mapsCollection.Keys[i]);
|
||||
}
|
||||
if (map != null)
|
||||
if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count))
|
||||
{
|
||||
_mapArtilleriesCollectionGeneric = new MapWithSetArtilleriesGeneric<DrawingObjectArtillery, AbstractMap>(pictureBoxArtilleries.Width, pictureBoxArtilleries.Height, map);
|
||||
listBoxMaps.SelectedIndex = 0;
|
||||
}
|
||||
else
|
||||
else if (listBoxMaps.Items.Count > 0 && index > -1 && index < listBoxMaps.Items.Count)
|
||||
{
|
||||
_mapArtilleriesCollectionGeneric = null;
|
||||
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)
|
||||
{
|
||||
pictureBoxArtilleries.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();
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAddArtillery_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapArtilleriesCollectionGeneric == null)
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormArtillery form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
DrawingObjectArtillery car = new(form.SelectedArtillery);
|
||||
if (_mapArtilleriesCollectionGeneric + car != -1)
|
||||
DrawingObjectArtillery artillery = new(form.SelectedArtillery);
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + artillery != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxArtilleries.Image = _mapArtilleriesCollectionGeneric.ShowSet();
|
||||
pictureBoxArtilleries.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -66,6 +110,10 @@ namespace Artilleries
|
||||
|
||||
private void buttonRemoveArtillery_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
||||
{
|
||||
return;
|
||||
@ -75,10 +123,10 @@ namespace Artilleries
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if (_mapArtilleriesCollectionGeneric - pos != null)
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxArtilleries.Image = _mapArtilleriesCollectionGeneric.ShowSet();
|
||||
pictureBoxArtilleries.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -88,25 +136,25 @@ namespace Artilleries
|
||||
|
||||
private void buttonShowStorage_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapArtilleriesCollectionGeneric == null)
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxArtilleries.Image = _mapArtilleriesCollectionGeneric.ShowSet();
|
||||
pictureBoxArtilleries.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
|
||||
private void buttonShowOnMap_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapArtilleriesCollectionGeneric == null)
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxArtilleries.Image = _mapArtilleriesCollectionGeneric.ShowOnMap();
|
||||
pictureBoxArtilleries.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
||||
}
|
||||
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapArtilleriesCollectionGeneric == null)
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -128,7 +176,8 @@ namespace Artilleries
|
||||
dir = Direction.Right;
|
||||
break;
|
||||
}
|
||||
pictureBoxArtilleries.Image = _mapArtilleriesCollectionGeneric.MoveObject(dir);
|
||||
pictureBoxArtilleries.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace Artilleries
|
||||
|
||||
public int Insert(T artillery, int position)
|
||||
{
|
||||
if (position < 0 || position >= Count || Count == _maxCount)
|
||||
if (position < 0 || position > Count || Count == _maxCount)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user