исправления
This commit is contained in:
parent
ed52510daf
commit
ef272fb946
@ -47,6 +47,76 @@
|
|||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
|
// groupBoxMaps
|
||||||
|
//
|
||||||
|
this.groupBoxMaps.Controls.Add(this.buttonDeleteMap);
|
||||||
|
this.groupBoxMaps.Controls.Add(this.listBoxMaps);
|
||||||
|
this.groupBoxMaps.Controls.Add(this.buttonAddMap);
|
||||||
|
this.groupBoxMaps.Controls.Add(this.comboBoxSelectorMap);
|
||||||
|
this.groupBoxMaps.Controls.Add(this.textBoxNewMapName);
|
||||||
|
this.groupBoxMaps.Location = new System.Drawing.Point(13, 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(229, 326);
|
||||||
|
this.groupBoxMaps.TabIndex = 11;
|
||||||
|
this.groupBoxMaps.TabStop = false;
|
||||||
|
this.groupBoxMaps.Text = "Карты";
|
||||||
|
//
|
||||||
|
// buttonDeleteMap
|
||||||
|
//
|
||||||
|
this.buttonDeleteMap.Location = new System.Drawing.Point(7, 271);
|
||||||
|
this.buttonDeleteMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonDeleteMap.Name = "buttonDeleteMap";
|
||||||
|
this.buttonDeleteMap.Size = new System.Drawing.Size(200, 47);
|
||||||
|
this.buttonDeleteMap.TabIndex = 5;
|
||||||
|
this.buttonDeleteMap.Text = "Удалить карту";
|
||||||
|
this.buttonDeleteMap.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDeleteMap.Click += new System.EventHandler(this.buttonDeleteMap_Click);
|
||||||
|
//
|
||||||
|
// listBoxMaps
|
||||||
|
//
|
||||||
|
this.listBoxMaps.FormattingEnabled = true;
|
||||||
|
this.listBoxMaps.ItemHeight = 20;
|
||||||
|
this.listBoxMaps.Location = new System.Drawing.Point(7, 157);
|
||||||
|
this.listBoxMaps.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.listBoxMaps.Name = "listBoxMaps";
|
||||||
|
this.listBoxMaps.Size = new System.Drawing.Size(199, 104);
|
||||||
|
this.listBoxMaps.TabIndex = 4;
|
||||||
|
this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.ListBoxMaps_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// buttonAddMap
|
||||||
|
//
|
||||||
|
this.buttonAddMap.Location = new System.Drawing.Point(7, 107);
|
||||||
|
this.buttonAddMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonAddMap.Name = "buttonAddMap";
|
||||||
|
this.buttonAddMap.Size = new System.Drawing.Size(200, 43);
|
||||||
|
this.buttonAddMap.TabIndex = 3;
|
||||||
|
this.buttonAddMap.Text = "Добавить карту";
|
||||||
|
this.buttonAddMap.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAddMap.Click += new System.EventHandler(this.buttonAddMap_Click_1);
|
||||||
|
//
|
||||||
|
// 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(7, 68);
|
||||||
|
this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||||
|
this.comboBoxSelectorMap.Size = new System.Drawing.Size(200, 28);
|
||||||
|
this.comboBoxSelectorMap.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// textBoxNewMapName
|
||||||
|
//
|
||||||
|
this.textBoxNewMapName.Location = new System.Drawing.Point(7, 29);
|
||||||
|
this.textBoxNewMapName.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.textBoxNewMapName.Name = "textBoxNewMapName";
|
||||||
|
this.textBoxNewMapName.Size = new System.Drawing.Size(200, 27);
|
||||||
|
this.textBoxNewMapName.TabIndex = 0;
|
||||||
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
//
|
//
|
||||||
this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
|
this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
|
||||||
|
@ -12,25 +12,54 @@ namespace HoistingCrane
|
|||||||
{
|
{
|
||||||
public partial class FormMapWithSetHoistingCrane : Form
|
public partial class FormMapWithSetHoistingCrane : Form
|
||||||
{
|
{
|
||||||
|
/// Словарь для выпадающего списка
|
||||||
private MapWithSetHoistingCraneGeneric<DrawingObjectHoistingCrane, AbstractMap> _mapHoistingCraneCollectionGeneric;
|
/// </summary>
|
||||||
|
private readonly Dictionary<string, AbstractMap> _mapsDict = new()
|
||||||
public FormMapWithSetHoistingCrane()
|
{
|
||||||
|
{ "Простая карта", new SimpleMap() },
|
||||||
|
{ "Вторая карта", new SecondMap() },
|
||||||
|
};
|
||||||
|
/// <summary>
|
||||||
|
/// Объект от коллекции карт
|
||||||
|
/// </summary>
|
||||||
|
/// Логер
|
||||||
|
/// </summary>
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
/// <summary>
|
||||||
|
private readonly MapsCollection _mapsCollection;
|
||||||
|
/// <summary>
|
||||||
|
public FormMapWithSetHoistingCrane(ILogger<FormMapWithSetHoistingCrane> logger)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
AbstractMap map = null;
|
AbstractMap map = null;
|
||||||
switch (comboBoxSelectorMap.Text)
|
switch (comboBoxSelectorMap.Text)
|
||||||
{
|
{
|
||||||
case "Первая карта":
|
case "Простая карта":
|
||||||
map = new SimpleMap();
|
map = new SimpleMap();
|
||||||
break;
|
break;
|
||||||
case "Вторая карта":
|
case "Вторая карта":
|
||||||
map = new SecondMap();
|
map = new SecondMap();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (map != null)
|
if (map != null)
|
||||||
{
|
{
|
||||||
@ -42,7 +71,50 @@ namespace HoistingCrane
|
|||||||
_mapHoistingCraneCollectionGeneric = null;
|
_mapHoistingCraneCollectionGeneric = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void buttonAddMap_Click_1(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();
|
||||||
|
_logger.LogInformation($"Добавлена карта {textBoxNewMapName.Text}");
|
||||||
|
}
|
||||||
|
private void ListBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
|
_logger.LogInformation($"Переход на карту {listBoxMaps.SelectedItem?.ToString()}");
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void buttonDeleteMap_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show($"Удалить карту {listBoxMaps.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
_mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty);
|
||||||
|
ReloadMaps();
|
||||||
|
_logger.LogInformation($"Удалена карта {listBoxMaps.SelectedItem?.ToString()}");
|
||||||
|
}
|
||||||
|
}
|
||||||
private void ButtonAddHoistingCrane_Click(object sender, EventArgs e)
|
private void ButtonAddHoistingCrane_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mapHoistingCraneCollectionGeneric == null)
|
if (_mapHoistingCraneCollectionGeneric == null)
|
||||||
@ -130,7 +202,7 @@ namespace HoistingCrane
|
|||||||
enums = Direction.Right;
|
enums = Direction.Right;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapHoistingCraneCollectionGeneric.MoveObject(enums);
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(enums);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pictureBox_Click(object sender, EventArgs e)
|
private void pictureBox_Click(object sender, EventArgs e)
|
||||||
|
Loading…
Reference in New Issue
Block a user