чет не робит
This commit is contained in:
parent
86aee47092
commit
8e29980e9f
@ -30,6 +30,8 @@
|
||||
{
|
||||
pictureBoxAirplanesCollection = new PictureBox();
|
||||
groupBoxAirplaneWithRadar = new GroupBox();
|
||||
buttonSortByColor = new Button();
|
||||
buttonSortByType = new Button();
|
||||
groupBoxCollection = new GroupBox();
|
||||
buttonRemoveObject = new Button();
|
||||
listBoxStorages = new ListBox();
|
||||
@ -59,10 +61,11 @@
|
||||
pictureBoxAirplanesCollection.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||
pictureBoxAirplanesCollection.TabIndex = 0;
|
||||
pictureBoxAirplanesCollection.TabStop = false;
|
||||
pictureBoxAirplanesCollection.Click += pictureBoxAirplanesCollection_Click;
|
||||
//
|
||||
// groupBoxAirplaneWithRadar
|
||||
//
|
||||
groupBoxAirplaneWithRadar.Controls.Add(buttonSortByColor);
|
||||
groupBoxAirplaneWithRadar.Controls.Add(buttonSortByType);
|
||||
groupBoxAirplaneWithRadar.Controls.Add(groupBoxCollection);
|
||||
groupBoxAirplaneWithRadar.Controls.Add(buttonUpdateCollection);
|
||||
groupBoxAirplaneWithRadar.Controls.Add(buttonDeleteAirplane);
|
||||
@ -76,6 +79,26 @@
|
||||
groupBoxAirplaneWithRadar.TabStop = false;
|
||||
groupBoxAirplaneWithRadar.Text = "Инструменты";
|
||||
//
|
||||
// buttonSortByColor
|
||||
//
|
||||
buttonSortByColor.Location = new Point(7, 487);
|
||||
buttonSortByColor.Name = "buttonSortByColor";
|
||||
buttonSortByColor.Size = new Size(238, 29);
|
||||
buttonSortByColor.TabIndex = 6;
|
||||
buttonSortByColor.Text = "Сортировка по цвету";
|
||||
buttonSortByColor.UseVisualStyleBackColor = true;
|
||||
buttonSortByColor.Click += buttonSortByColor_Click;
|
||||
//
|
||||
// buttonSortByType
|
||||
//
|
||||
buttonSortByType.Location = new Point(6, 453);
|
||||
buttonSortByType.Name = "buttonSortByType";
|
||||
buttonSortByType.Size = new Size(238, 29);
|
||||
buttonSortByType.TabIndex = 5;
|
||||
buttonSortByType.Text = "Сортировка по типу";
|
||||
buttonSortByType.UseVisualStyleBackColor = true;
|
||||
buttonSortByType.Click += buttonSortByType_Click;
|
||||
//
|
||||
// groupBoxCollection
|
||||
//
|
||||
groupBoxCollection.Controls.Add(buttonRemoveObject);
|
||||
@ -238,5 +261,7 @@
|
||||
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private Button buttonSortByColor;
|
||||
private Button buttonSortByType;
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ namespace ProjectAirplaneWithRadar
|
||||
listBoxStorages.Items.Clear();
|
||||
for (int i = 0; i < _storage.Keys.Count; i++)
|
||||
{
|
||||
listBoxStorages.Items.Add(_storage.Keys[i]);
|
||||
listBoxStorages.Items.Add(_storage.Keys[i].Name);
|
||||
}
|
||||
if (listBoxStorages.Items.Count > 0 && (index == -1 || index
|
||||
>= listBoxStorages.Items.Count))
|
||||
@ -69,6 +69,11 @@ namespace ProjectAirplaneWithRadar
|
||||
Log.Warning($"Êîëëåêöèÿ {listBoxStorages.SelectedItem.ToString() ?? string.Empty} ïåðåïîëíåíà");
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
Log.Warning($"Äîáàâëÿåìûé îáúåêò óæå ñóùåñòâóåò â êîëëåêöèè {listBoxStorages.SelectedItem.ToString() ?? string.Empty}");
|
||||
MessageBox.Show("Äîáàâëÿåìûé îáúåêò óæå ñóùåñâóåò â êîëëåêöèè");
|
||||
}
|
||||
});
|
||||
form.AddEvent(airplaneDelegate);
|
||||
}
|
||||
@ -89,8 +94,6 @@ namespace ProjectAirplaneWithRadar
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||
@ -125,7 +128,6 @@ namespace ProjectAirplaneWithRadar
|
||||
}
|
||||
pictureBoxAirplanesCollection.Image = obj.ShowAirplanes();
|
||||
}
|
||||
|
||||
private void buttonAddObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
||||
@ -150,17 +152,11 @@ namespace ProjectAirplaneWithRadar
|
||||
ReloadObjects();
|
||||
Log.Information($"Óäàëåí íàáîð: {name}");
|
||||
}
|
||||
|
||||
}
|
||||
private void listBoxStorages_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxAirplanesCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowAirplanes();
|
||||
}
|
||||
|
||||
private void pictureBoxAirplanesCollection_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
private void SaveToolStripMenuItem_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
@ -202,5 +198,26 @@ namespace ProjectAirplaneWithRadar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSortByType_Click(object sender, EventArgs e) => CompareAirplanes(new AirplaneCompareByType());
|
||||
|
||||
|
||||
private void CompareAirplanes(IComparer<DrawningAirplane?> comparer)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
obj.Sort(comparer);
|
||||
pictureBoxAirplanesCollection.Image = obj.ShowAirplanes();
|
||||
}
|
||||
|
||||
private void buttonSortByColor_Click(object sender, EventArgs e) => CompareAirplanes(new AirplaneCompareByColor());
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user