Доработана форма
This commit is contained in:
parent
bdc1823059
commit
51a27f8e12
@ -29,17 +29,24 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
groupBoxTools = new GroupBox();
|
||||
groupBoxStorages = new GroupBox();
|
||||
buttonRemoveStorage = new Button();
|
||||
listBoxStorages = new ListBox();
|
||||
buttonAddStorage = new Button();
|
||||
textBoxStorageName = new TextBox();
|
||||
maskedTextBoxNumber = new MaskedTextBox();
|
||||
buttonRefreshCollection = new Button();
|
||||
buttonRemovePlane = new Button();
|
||||
buttonAddPlane = new Button();
|
||||
pictureBoxCollection = new PictureBox();
|
||||
groupBoxTools.SuspendLayout();
|
||||
groupBoxStorages.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxTools
|
||||
//
|
||||
groupBoxTools.Controls.Add(groupBoxStorages);
|
||||
groupBoxTools.Controls.Add(maskedTextBoxNumber);
|
||||
groupBoxTools.Controls.Add(buttonRefreshCollection);
|
||||
groupBoxTools.Controls.Add(buttonRemovePlane);
|
||||
@ -52,9 +59,59 @@
|
||||
groupBoxTools.TabStop = false;
|
||||
groupBoxTools.Text = "Инструменты";
|
||||
//
|
||||
// groupBoxStorages
|
||||
//
|
||||
groupBoxStorages.Controls.Add(buttonRemoveStorage);
|
||||
groupBoxStorages.Controls.Add(listBoxStorages);
|
||||
groupBoxStorages.Controls.Add(buttonAddStorage);
|
||||
groupBoxStorages.Controls.Add(textBoxStorageName);
|
||||
groupBoxStorages.Location = new Point(6, 26);
|
||||
groupBoxStorages.Name = "groupBoxStorages";
|
||||
groupBoxStorages.Size = new Size(218, 241);
|
||||
groupBoxStorages.TabIndex = 5;
|
||||
groupBoxStorages.TabStop = false;
|
||||
groupBoxStorages.Text = "Наборы";
|
||||
//
|
||||
// buttonRemoveStorage
|
||||
//
|
||||
buttonRemoveStorage.Location = new Point(6, 204);
|
||||
buttonRemoveStorage.Name = "buttonRemoveStorage";
|
||||
buttonRemoveStorage.Size = new Size(206, 29);
|
||||
buttonRemoveStorage.TabIndex = 3;
|
||||
buttonRemoveStorage.Text = "Удалить набор";
|
||||
buttonRemoveStorage.UseVisualStyleBackColor = true;
|
||||
buttonRemoveStorage.Click += buttonDelStorage_Click;
|
||||
//
|
||||
// listBoxStorages
|
||||
//
|
||||
listBoxStorages.FormattingEnabled = true;
|
||||
listBoxStorages.ItemHeight = 20;
|
||||
listBoxStorages.Location = new Point(6, 94);
|
||||
listBoxStorages.Name = "listBoxStorages";
|
||||
listBoxStorages.Size = new Size(206, 104);
|
||||
listBoxStorages.TabIndex = 2;
|
||||
listBoxStorages.SelectedIndexChanged += listBoxStorages_SelectedIndexChanged;
|
||||
//
|
||||
// buttonAddStorage
|
||||
//
|
||||
buttonAddStorage.Location = new Point(6, 59);
|
||||
buttonAddStorage.Name = "buttonAddStorage";
|
||||
buttonAddStorage.Size = new Size(206, 29);
|
||||
buttonAddStorage.TabIndex = 1;
|
||||
buttonAddStorage.Text = "Добавить набор";
|
||||
buttonAddStorage.UseVisualStyleBackColor = true;
|
||||
buttonAddStorage.Click += buttonAddStorage_Click;
|
||||
//
|
||||
// textBoxStorageName
|
||||
//
|
||||
textBoxStorageName.Location = new Point(6, 26);
|
||||
textBoxStorageName.Name = "textBoxStorageName";
|
||||
textBoxStorageName.Size = new Size(206, 27);
|
||||
textBoxStorageName.TabIndex = 0;
|
||||
//
|
||||
// maskedTextBoxNumber
|
||||
//
|
||||
maskedTextBoxNumber.Location = new Point(6, 87);
|
||||
maskedTextBoxNumber.Location = new Point(6, 404);
|
||||
maskedTextBoxNumber.Mask = "00";
|
||||
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||
maskedTextBoxNumber.Size = new Size(218, 27);
|
||||
@ -64,7 +121,7 @@
|
||||
//
|
||||
// buttonRefreshCollection
|
||||
//
|
||||
buttonRefreshCollection.Location = new Point(6, 180);
|
||||
buttonRefreshCollection.Location = new Point(6, 497);
|
||||
buttonRefreshCollection.Name = "buttonRefreshCollection";
|
||||
buttonRefreshCollection.Size = new Size(218, 29);
|
||||
buttonRefreshCollection.TabIndex = 3;
|
||||
@ -74,7 +131,7 @@
|
||||
//
|
||||
// buttonRemovePlane
|
||||
//
|
||||
buttonRemovePlane.Location = new Point(6, 120);
|
||||
buttonRemovePlane.Location = new Point(6, 437);
|
||||
buttonRemovePlane.Name = "buttonRemovePlane";
|
||||
buttonRemovePlane.Size = new Size(218, 29);
|
||||
buttonRemovePlane.TabIndex = 2;
|
||||
@ -84,7 +141,7 @@
|
||||
//
|
||||
// buttonAddPlane
|
||||
//
|
||||
buttonAddPlane.Location = new Point(6, 26);
|
||||
buttonAddPlane.Location = new Point(6, 349);
|
||||
buttonAddPlane.Name = "buttonAddPlane";
|
||||
buttonAddPlane.Size = new Size(218, 29);
|
||||
buttonAddPlane.TabIndex = 0;
|
||||
@ -112,6 +169,8 @@
|
||||
Text = "Набор самолетов";
|
||||
groupBoxTools.ResumeLayout(false);
|
||||
groupBoxTools.PerformLayout();
|
||||
groupBoxStorages.ResumeLayout(false);
|
||||
groupBoxStorages.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
@ -124,5 +183,10 @@
|
||||
private Button buttonAddPlane;
|
||||
private MaskedTextBox maskedTextBoxNumber;
|
||||
private PictureBox pictureBoxCollection;
|
||||
private GroupBox groupBoxStorages;
|
||||
private Button buttonRemoveStorage;
|
||||
private ListBox listBoxStorages;
|
||||
private Button buttonAddStorage;
|
||||
private TextBox textBoxStorageName;
|
||||
}
|
||||
}
|
@ -18,14 +18,75 @@ namespace ProjectStormtrooper
|
||||
/// <summary>
|
||||
/// Набор объектов
|
||||
/// </summary>
|
||||
private readonly PlanesGenericCollection<DrawingPlane, DrawingObjectPlane> _planes;
|
||||
private readonly PlanesGenericStorage _storage;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormPlaneCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_planes = new PlanesGenericCollection<DrawingPlane, DrawingObjectPlane>(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
_storage = new PlanesGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
}
|
||||
/// <summary>
|
||||
/// Заполнение listBoxObjects
|
||||
/// </summary>
|
||||
private void ReloadObjects()
|
||||
{
|
||||
int index = listBoxStorages.SelectedIndex;
|
||||
listBoxStorages.Items.Clear();
|
||||
for (int i = 0; i < _storage.Keys.Count; i++)
|
||||
{
|
||||
listBoxStorages.Items.Add(_storage.Keys[i]);
|
||||
}
|
||||
if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count))
|
||||
{
|
||||
listBoxStorages.SelectedIndex = 0;
|
||||
}
|
||||
else if (listBoxStorages.Items.Count > 0 && index > -1 && index < listBoxStorages.Items.Count)
|
||||
{
|
||||
listBoxStorages.SelectedIndex = index;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление набора в коллекцию
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonAddStorage_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
||||
{
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_storage.AddSet(textBoxStorageName.Text);
|
||||
ReloadObjects();
|
||||
}
|
||||
/// <summary>
|
||||
/// Выбор набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void listBoxStorages_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowPlanes();
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonDelStorage_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_storage.DelSet(listBoxStorages.SelectedItem.ToString() ?? string.Empty);
|
||||
ReloadObjects();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
@ -34,13 +95,22 @@ namespace ProjectStormtrooper
|
||||
/// <param name="e"></param>
|
||||
private void buttonAddPlane_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormStormtrooper form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_planes + form.SelectedPlane > -1)
|
||||
if (obj + form.SelectedPlane > -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = _planes.ShowPlanes();
|
||||
pictureBoxCollection.Image = obj.ShowPlanes();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -55,15 +125,24 @@ namespace ProjectStormtrooper
|
||||
/// <param name="e"></param>
|
||||
private void buttonRemovePlane_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||
if (_planes - pos != null)
|
||||
if (obj - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxCollection.Image = _planes.ShowPlanes();
|
||||
pictureBoxCollection.Image = obj.ShowPlanes();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -77,7 +156,16 @@ namespace ProjectStormtrooper
|
||||
/// <param name="e"></param>
|
||||
private void buttonRefreshCollection_Click(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxCollection.Image = _planes.ShowPlanes();
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxCollection.Image = obj.ShowPlanes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user