Обработка исключений
This commit is contained in:
parent
cdaae7bc7d
commit
923aafca36
@ -1,4 +1,6 @@
|
|||||||
|
|
||||||
|
using ProjectAirplaneWithRadar.Exceptions;
|
||||||
|
|
||||||
namespace ProjectAirplaneWithRadar.CollectionGenericObjects
|
namespace ProjectAirplaneWithRadar.CollectionGenericObjects
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -48,7 +50,7 @@ namespace ProjectAirplaneWithRadar.CollectionGenericObjects
|
|||||||
public T? Get(int position)
|
public T? Get(int position)
|
||||||
{
|
{
|
||||||
if (position >= Count || position < 0)
|
if (position >= Count || position < 0)
|
||||||
return null;
|
throw new PositionOutOfCollectionException(position);
|
||||||
|
|
||||||
return _collection[position];
|
return _collection[position];
|
||||||
}
|
}
|
||||||
@ -56,7 +58,8 @@ namespace ProjectAirplaneWithRadar.CollectionGenericObjects
|
|||||||
public int Insert(T obj)
|
public int Insert(T obj)
|
||||||
{
|
{
|
||||||
if (Count + 1 > _maxCount)
|
if (Count + 1 > _maxCount)
|
||||||
return -1;
|
throw new CollectionOverflowException(Count);
|
||||||
|
|
||||||
_collection.Add(obj);
|
_collection.Add(obj);
|
||||||
return Count;
|
return Count;
|
||||||
}
|
}
|
||||||
@ -64,9 +67,11 @@ namespace ProjectAirplaneWithRadar.CollectionGenericObjects
|
|||||||
public int Insert(T obj, int position)
|
public int Insert(T obj, int position)
|
||||||
{
|
{
|
||||||
if (Count + 1 > _maxCount)
|
if (Count + 1 > _maxCount)
|
||||||
return -1;
|
throw new CollectionOverflowException(Count);
|
||||||
|
|
||||||
if (position < 0 || position > Count)
|
if (position < 0 || position > Count)
|
||||||
return -1;
|
throw new PositionOutOfCollectionException(position);
|
||||||
|
|
||||||
_collection.Insert(position, obj);
|
_collection.Insert(position, obj);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -74,7 +79,7 @@ namespace ProjectAirplaneWithRadar.CollectionGenericObjects
|
|||||||
public T? Remove(int position)
|
public T? Remove(int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position > Count)
|
if (position < 0 || position > Count)
|
||||||
return null;
|
throw new PositionOutOfCollectionException(position);
|
||||||
|
|
||||||
T? temp = _collection[position];
|
T? temp = _collection[position];
|
||||||
_collection.RemoveAt(position);
|
_collection.RemoveAt(position);
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
|
|
||||||
|
using ProjectAirplaneWithRadar.Exceptions;
|
||||||
|
|
||||||
namespace ProjectAirplaneWithRadar.CollectionGenericObjects
|
namespace ProjectAirplaneWithRadar.CollectionGenericObjects
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -51,7 +53,11 @@ namespace ProjectAirplaneWithRadar.CollectionGenericObjects
|
|||||||
public T? Get(int position)
|
public T? Get(int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count)
|
if (position < 0 || position >= Count)
|
||||||
return null;
|
throw new PositionOutOfCollectionException(position);
|
||||||
|
|
||||||
|
if (position >= _collection.Length && _collection[position] == null)
|
||||||
|
throw new ObjectNotFoundException(position);
|
||||||
|
|
||||||
return _collection[position];
|
return _collection[position];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,13 +71,13 @@ namespace ProjectAirplaneWithRadar.CollectionGenericObjects
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
throw new CollectionOverflowException(Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Insert(T obj, int position)
|
public int Insert(T obj, int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count)
|
if (position < 0 || position >= Count)
|
||||||
return -1;
|
throw new PositionOutOfCollectionException(position);
|
||||||
|
|
||||||
if (_collection[position] == null)
|
if (_collection[position] == null)
|
||||||
{
|
{
|
||||||
@ -100,19 +106,16 @@ namespace ProjectAirplaneWithRadar.CollectionGenericObjects
|
|||||||
}
|
}
|
||||||
temp--;
|
temp--;
|
||||||
}
|
}
|
||||||
|
throw new CollectionOverflowException(Count);
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public T? Remove(int position)
|
public T? Remove(int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count)
|
if (position < 0 || position >= Count)
|
||||||
return null;
|
throw new PositionOutOfCollectionException(position);
|
||||||
|
|
||||||
if (_collection[position] == null)
|
if (_collection[position] == null)
|
||||||
{
|
throw new ObjectNotFoundException(position);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
T? temp = _collection[position];
|
T? temp = _collection[position];
|
||||||
_collection[position] = null;
|
_collection[position] = null;
|
||||||
|
@ -66,9 +66,11 @@
|
|||||||
groupBoxTools.Controls.Add(panelStorage);
|
groupBoxTools.Controls.Add(panelStorage);
|
||||||
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
||||||
groupBoxTools.Dock = DockStyle.Right;
|
groupBoxTools.Dock = DockStyle.Right;
|
||||||
groupBoxTools.Location = new Point(883, 24);
|
groupBoxTools.Location = new Point(855, 30);
|
||||||
|
groupBoxTools.Margin = new Padding(3, 4, 3, 4);
|
||||||
groupBoxTools.Name = "groupBoxTools";
|
groupBoxTools.Name = "groupBoxTools";
|
||||||
groupBoxTools.Size = new Size(206, 583);
|
groupBoxTools.Padding = new Padding(3, 4, 3, 4);
|
||||||
|
groupBoxTools.Size = new Size(235, 779);
|
||||||
groupBoxTools.TabIndex = 0;
|
groupBoxTools.TabIndex = 0;
|
||||||
groupBoxTools.TabStop = false;
|
groupBoxTools.TabStop = false;
|
||||||
groupBoxTools.Text = "Инструменты";
|
groupBoxTools.Text = "Инструменты";
|
||||||
@ -82,17 +84,19 @@
|
|||||||
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
||||||
panelCompanyTools.Dock = DockStyle.Bottom;
|
panelCompanyTools.Dock = DockStyle.Bottom;
|
||||||
panelCompanyTools.Enabled = false;
|
panelCompanyTools.Enabled = false;
|
||||||
panelCompanyTools.Location = new Point(3, 393);
|
panelCompanyTools.Location = new Point(3, 526);
|
||||||
|
panelCompanyTools.Margin = new Padding(3, 4, 3, 4);
|
||||||
panelCompanyTools.Name = "panelCompanyTools";
|
panelCompanyTools.Name = "panelCompanyTools";
|
||||||
panelCompanyTools.Size = new Size(200, 187);
|
panelCompanyTools.Size = new Size(229, 249);
|
||||||
panelCompanyTools.TabIndex = 8;
|
panelCompanyTools.TabIndex = 8;
|
||||||
//
|
//
|
||||||
// buttonAddAirplane
|
// buttonAddAirplane
|
||||||
//
|
//
|
||||||
buttonAddAirplane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonAddAirplane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonAddAirplane.Location = new Point(0, 3);
|
buttonAddAirplane.Location = new Point(0, 4);
|
||||||
|
buttonAddAirplane.Margin = new Padding(3, 4, 3, 4);
|
||||||
buttonAddAirplane.Name = "buttonAddAirplane";
|
buttonAddAirplane.Name = "buttonAddAirplane";
|
||||||
buttonAddAirplane.Size = new Size(97, 56);
|
buttonAddAirplane.Size = new Size(111, 75);
|
||||||
buttonAddAirplane.TabIndex = 1;
|
buttonAddAirplane.TabIndex = 1;
|
||||||
buttonAddAirplane.Text = "Добавить самолет";
|
buttonAddAirplane.Text = "Добавить самолет";
|
||||||
buttonAddAirplane.UseVisualStyleBackColor = true;
|
buttonAddAirplane.UseVisualStyleBackColor = true;
|
||||||
@ -100,19 +104,21 @@
|
|||||||
//
|
//
|
||||||
// maskedTextBoxPosition
|
// maskedTextBoxPosition
|
||||||
//
|
//
|
||||||
maskedTextBoxPosition.Location = new Point(0, 81);
|
maskedTextBoxPosition.Location = new Point(0, 108);
|
||||||
|
maskedTextBoxPosition.Margin = new Padding(3, 4, 3, 4);
|
||||||
maskedTextBoxPosition.Mask = "00";
|
maskedTextBoxPosition.Mask = "00";
|
||||||
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
maskedTextBoxPosition.Size = new Size(78, 23);
|
maskedTextBoxPosition.Size = new Size(89, 27);
|
||||||
maskedTextBoxPosition.TabIndex = 3;
|
maskedTextBoxPosition.TabIndex = 3;
|
||||||
maskedTextBoxPosition.ValidatingType = typeof(int);
|
maskedTextBoxPosition.ValidatingType = typeof(int);
|
||||||
//
|
//
|
||||||
// buttonRefresh
|
// buttonRefresh
|
||||||
//
|
//
|
||||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonRefresh.Location = new Point(103, 123);
|
buttonRefresh.Location = new Point(118, 164);
|
||||||
|
buttonRefresh.Margin = new Padding(3, 4, 3, 4);
|
||||||
buttonRefresh.Name = "buttonRefresh";
|
buttonRefresh.Name = "buttonRefresh";
|
||||||
buttonRefresh.Size = new Size(97, 56);
|
buttonRefresh.Size = new Size(111, 75);
|
||||||
buttonRefresh.TabIndex = 6;
|
buttonRefresh.TabIndex = 6;
|
||||||
buttonRefresh.Text = "Обновить";
|
buttonRefresh.Text = "Обновить";
|
||||||
buttonRefresh.UseVisualStyleBackColor = true;
|
buttonRefresh.UseVisualStyleBackColor = true;
|
||||||
@ -121,9 +127,10 @@
|
|||||||
// buttonRemoveAirplane
|
// buttonRemoveAirplane
|
||||||
//
|
//
|
||||||
buttonRemoveAirplane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonRemoveAirplane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonRemoveAirplane.Location = new Point(103, 70);
|
buttonRemoveAirplane.Location = new Point(118, 93);
|
||||||
|
buttonRemoveAirplane.Margin = new Padding(3, 4, 3, 4);
|
||||||
buttonRemoveAirplane.Name = "buttonRemoveAirplane";
|
buttonRemoveAirplane.Name = "buttonRemoveAirplane";
|
||||||
buttonRemoveAirplane.Size = new Size(97, 43);
|
buttonRemoveAirplane.Size = new Size(111, 57);
|
||||||
buttonRemoveAirplane.TabIndex = 4;
|
buttonRemoveAirplane.TabIndex = 4;
|
||||||
buttonRemoveAirplane.Text = "Удалить самолет";
|
buttonRemoveAirplane.Text = "Удалить самолет";
|
||||||
buttonRemoveAirplane.UseVisualStyleBackColor = true;
|
buttonRemoveAirplane.UseVisualStyleBackColor = true;
|
||||||
@ -132,9 +139,10 @@
|
|||||||
// buttonGoToCheck
|
// buttonGoToCheck
|
||||||
//
|
//
|
||||||
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonGoToCheck.Location = new Point(0, 123);
|
buttonGoToCheck.Location = new Point(0, 164);
|
||||||
|
buttonGoToCheck.Margin = new Padding(3, 4, 3, 4);
|
||||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||||
buttonGoToCheck.Size = new Size(97, 56);
|
buttonGoToCheck.Size = new Size(111, 75);
|
||||||
buttonGoToCheck.TabIndex = 5;
|
buttonGoToCheck.TabIndex = 5;
|
||||||
buttonGoToCheck.Text = "Передать на тесты";
|
buttonGoToCheck.Text = "Передать на тесты";
|
||||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||||
@ -142,9 +150,10 @@
|
|||||||
//
|
//
|
||||||
// buttonCreateCompany
|
// buttonCreateCompany
|
||||||
//
|
//
|
||||||
buttonCreateCompany.Location = new Point(6, 305);
|
buttonCreateCompany.Location = new Point(7, 407);
|
||||||
|
buttonCreateCompany.Margin = new Padding(3, 4, 3, 4);
|
||||||
buttonCreateCompany.Name = "buttonCreateCompany";
|
buttonCreateCompany.Name = "buttonCreateCompany";
|
||||||
buttonCreateCompany.Size = new Size(194, 23);
|
buttonCreateCompany.Size = new Size(222, 31);
|
||||||
buttonCreateCompany.TabIndex = 7;
|
buttonCreateCompany.TabIndex = 7;
|
||||||
buttonCreateCompany.Text = "Создать компанию";
|
buttonCreateCompany.Text = "Создать компанию";
|
||||||
buttonCreateCompany.UseVisualStyleBackColor = true;
|
buttonCreateCompany.UseVisualStyleBackColor = true;
|
||||||
@ -160,16 +169,18 @@
|
|||||||
panelStorage.Controls.Add(textBoxCollectionName);
|
panelStorage.Controls.Add(textBoxCollectionName);
|
||||||
panelStorage.Controls.Add(labelCollectionName);
|
panelStorage.Controls.Add(labelCollectionName);
|
||||||
panelStorage.Dock = DockStyle.Top;
|
panelStorage.Dock = DockStyle.Top;
|
||||||
panelStorage.Location = new Point(3, 19);
|
panelStorage.Location = new Point(3, 24);
|
||||||
|
panelStorage.Margin = new Padding(3, 4, 3, 4);
|
||||||
panelStorage.Name = "panelStorage";
|
panelStorage.Name = "panelStorage";
|
||||||
panelStorage.Size = new Size(200, 251);
|
panelStorage.Size = new Size(229, 335);
|
||||||
panelStorage.TabIndex = 7;
|
panelStorage.TabIndex = 7;
|
||||||
//
|
//
|
||||||
// buttonCollectionDel
|
// buttonCollectionDel
|
||||||
//
|
//
|
||||||
buttonCollectionDel.Location = new Point(3, 221);
|
buttonCollectionDel.Location = new Point(3, 295);
|
||||||
|
buttonCollectionDel.Margin = new Padding(3, 4, 3, 4);
|
||||||
buttonCollectionDel.Name = "buttonCollectionDel";
|
buttonCollectionDel.Name = "buttonCollectionDel";
|
||||||
buttonCollectionDel.Size = new Size(194, 23);
|
buttonCollectionDel.Size = new Size(222, 31);
|
||||||
buttonCollectionDel.TabIndex = 6;
|
buttonCollectionDel.TabIndex = 6;
|
||||||
buttonCollectionDel.Text = "Удалить коллекцию";
|
buttonCollectionDel.Text = "Удалить коллекцию";
|
||||||
buttonCollectionDel.UseVisualStyleBackColor = true;
|
buttonCollectionDel.UseVisualStyleBackColor = true;
|
||||||
@ -178,17 +189,18 @@
|
|||||||
// listBoxCollection
|
// listBoxCollection
|
||||||
//
|
//
|
||||||
listBoxCollection.FormattingEnabled = true;
|
listBoxCollection.FormattingEnabled = true;
|
||||||
listBoxCollection.ItemHeight = 15;
|
listBoxCollection.Location = new Point(3, 161);
|
||||||
listBoxCollection.Location = new Point(3, 121);
|
listBoxCollection.Margin = new Padding(3, 4, 3, 4);
|
||||||
listBoxCollection.Name = "listBoxCollection";
|
listBoxCollection.Name = "listBoxCollection";
|
||||||
listBoxCollection.Size = new Size(194, 94);
|
listBoxCollection.Size = new Size(221, 124);
|
||||||
listBoxCollection.TabIndex = 5;
|
listBoxCollection.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// buttonCollectionAdd
|
// buttonCollectionAdd
|
||||||
//
|
//
|
||||||
buttonCollectionAdd.Location = new Point(3, 82);
|
buttonCollectionAdd.Location = new Point(3, 109);
|
||||||
|
buttonCollectionAdd.Margin = new Padding(3, 4, 3, 4);
|
||||||
buttonCollectionAdd.Name = "buttonCollectionAdd";
|
buttonCollectionAdd.Name = "buttonCollectionAdd";
|
||||||
buttonCollectionAdd.Size = new Size(194, 23);
|
buttonCollectionAdd.Size = new Size(222, 31);
|
||||||
buttonCollectionAdd.TabIndex = 4;
|
buttonCollectionAdd.TabIndex = 4;
|
||||||
buttonCollectionAdd.Text = "Добавить коллекцию";
|
buttonCollectionAdd.Text = "Добавить коллекцию";
|
||||||
buttonCollectionAdd.UseVisualStyleBackColor = true;
|
buttonCollectionAdd.UseVisualStyleBackColor = true;
|
||||||
@ -197,9 +209,10 @@
|
|||||||
// radioButtonList
|
// radioButtonList
|
||||||
//
|
//
|
||||||
radioButtonList.AutoSize = true;
|
radioButtonList.AutoSize = true;
|
||||||
radioButtonList.Location = new Point(106, 57);
|
radioButtonList.Location = new Point(121, 76);
|
||||||
|
radioButtonList.Margin = new Padding(3, 4, 3, 4);
|
||||||
radioButtonList.Name = "radioButtonList";
|
radioButtonList.Name = "radioButtonList";
|
||||||
radioButtonList.Size = new Size(66, 19);
|
radioButtonList.Size = new Size(80, 24);
|
||||||
radioButtonList.TabIndex = 3;
|
radioButtonList.TabIndex = 3;
|
||||||
radioButtonList.TabStop = true;
|
radioButtonList.TabStop = true;
|
||||||
radioButtonList.Text = "Список";
|
radioButtonList.Text = "Список";
|
||||||
@ -208,9 +221,10 @@
|
|||||||
// radioButtonMassive
|
// radioButtonMassive
|
||||||
//
|
//
|
||||||
radioButtonMassive.AutoSize = true;
|
radioButtonMassive.AutoSize = true;
|
||||||
radioButtonMassive.Location = new Point(27, 57);
|
radioButtonMassive.Location = new Point(31, 76);
|
||||||
|
radioButtonMassive.Margin = new Padding(3, 4, 3, 4);
|
||||||
radioButtonMassive.Name = "radioButtonMassive";
|
radioButtonMassive.Name = "radioButtonMassive";
|
||||||
radioButtonMassive.Size = new Size(67, 19);
|
radioButtonMassive.Size = new Size(82, 24);
|
||||||
radioButtonMassive.TabIndex = 2;
|
radioButtonMassive.TabIndex = 2;
|
||||||
radioButtonMassive.TabStop = true;
|
radioButtonMassive.TabStop = true;
|
||||||
radioButtonMassive.Text = "Массив";
|
radioButtonMassive.Text = "Массив";
|
||||||
@ -218,17 +232,18 @@
|
|||||||
//
|
//
|
||||||
// textBoxCollectionName
|
// textBoxCollectionName
|
||||||
//
|
//
|
||||||
textBoxCollectionName.Location = new Point(3, 28);
|
textBoxCollectionName.Location = new Point(3, 37);
|
||||||
|
textBoxCollectionName.Margin = new Padding(3, 4, 3, 4);
|
||||||
textBoxCollectionName.Name = "textBoxCollectionName";
|
textBoxCollectionName.Name = "textBoxCollectionName";
|
||||||
textBoxCollectionName.Size = new Size(194, 23);
|
textBoxCollectionName.Size = new Size(221, 27);
|
||||||
textBoxCollectionName.TabIndex = 1;
|
textBoxCollectionName.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// labelCollectionName
|
// labelCollectionName
|
||||||
//
|
//
|
||||||
labelCollectionName.AutoSize = true;
|
labelCollectionName.AutoSize = true;
|
||||||
labelCollectionName.Location = new Point(38, 10);
|
labelCollectionName.Location = new Point(43, 13);
|
||||||
labelCollectionName.Name = "labelCollectionName";
|
labelCollectionName.Name = "labelCollectionName";
|
||||||
labelCollectionName.Size = new Size(125, 15);
|
labelCollectionName.Size = new Size(158, 20);
|
||||||
labelCollectionName.TabIndex = 0;
|
labelCollectionName.TabIndex = 0;
|
||||||
labelCollectionName.Text = "Название коллекции:";
|
labelCollectionName.Text = "Название коллекции:";
|
||||||
//
|
//
|
||||||
@ -238,27 +253,31 @@
|
|||||||
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboBoxSelectorCompany.FormattingEnabled = true;
|
comboBoxSelectorCompany.FormattingEnabled = true;
|
||||||
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
|
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
|
||||||
comboBoxSelectorCompany.Location = new Point(6, 276);
|
comboBoxSelectorCompany.Location = new Point(7, 368);
|
||||||
|
comboBoxSelectorCompany.Margin = new Padding(3, 4, 3, 4);
|
||||||
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
||||||
comboBoxSelectorCompany.Size = new Size(194, 23);
|
comboBoxSelectorCompany.Size = new Size(221, 28);
|
||||||
comboBoxSelectorCompany.TabIndex = 0;
|
comboBoxSelectorCompany.TabIndex = 0;
|
||||||
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
|
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
|
||||||
//
|
//
|
||||||
// pictureBox
|
// pictureBox
|
||||||
//
|
//
|
||||||
pictureBox.Dock = DockStyle.Fill;
|
pictureBox.Dock = DockStyle.Fill;
|
||||||
pictureBox.Location = new Point(0, 24);
|
pictureBox.Location = new Point(0, 30);
|
||||||
|
pictureBox.Margin = new Padding(3, 4, 3, 4);
|
||||||
pictureBox.Name = "pictureBox";
|
pictureBox.Name = "pictureBox";
|
||||||
pictureBox.Size = new Size(883, 583);
|
pictureBox.Size = new Size(855, 779);
|
||||||
pictureBox.TabIndex = 1;
|
pictureBox.TabIndex = 1;
|
||||||
pictureBox.TabStop = false;
|
pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
// menuStrip
|
// menuStrip
|
||||||
//
|
//
|
||||||
|
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||||
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
|
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
|
||||||
menuStrip.Location = new Point(0, 0);
|
menuStrip.Location = new Point(0, 0);
|
||||||
menuStrip.Name = "menuStrip";
|
menuStrip.Name = "menuStrip";
|
||||||
menuStrip.Size = new Size(1089, 24);
|
menuStrip.Padding = new Padding(7, 3, 0, 3);
|
||||||
|
menuStrip.Size = new Size(1090, 30);
|
||||||
menuStrip.TabIndex = 2;
|
menuStrip.TabIndex = 2;
|
||||||
menuStrip.Text = "menuStrip";
|
menuStrip.Text = "menuStrip";
|
||||||
//
|
//
|
||||||
@ -266,14 +285,14 @@
|
|||||||
//
|
//
|
||||||
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
|
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
|
||||||
файлToolStripMenuItem.Name = "файлToolStripMenuItem";
|
файлToolStripMenuItem.Name = "файлToolStripMenuItem";
|
||||||
файлToolStripMenuItem.Size = new Size(48, 20);
|
файлToolStripMenuItem.Size = new Size(59, 24);
|
||||||
файлToolStripMenuItem.Text = "Файл";
|
файлToolStripMenuItem.Text = "Файл";
|
||||||
//
|
//
|
||||||
// saveToolStripMenuItem
|
// saveToolStripMenuItem
|
||||||
//
|
//
|
||||||
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||||
saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||||
saveToolStripMenuItem.Size = new Size(181, 22);
|
saveToolStripMenuItem.Size = new Size(227, 26);
|
||||||
saveToolStripMenuItem.Text = "Сохранение";
|
saveToolStripMenuItem.Text = "Сохранение";
|
||||||
saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
@ -281,7 +300,7 @@
|
|||||||
//
|
//
|
||||||
loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
||||||
loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
|
loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
|
||||||
loadToolStripMenuItem.Size = new Size(181, 22);
|
loadToolStripMenuItem.Size = new Size(227, 26);
|
||||||
loadToolStripMenuItem.Text = "Загрузка";
|
loadToolStripMenuItem.Text = "Загрузка";
|
||||||
loadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
loadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
@ -295,13 +314,14 @@
|
|||||||
//
|
//
|
||||||
// FormAirplaneCollection
|
// FormAirplaneCollection
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(1089, 607);
|
ClientSize = new Size(1090, 809);
|
||||||
Controls.Add(pictureBox);
|
Controls.Add(pictureBox);
|
||||||
Controls.Add(groupBoxTools);
|
Controls.Add(groupBoxTools);
|
||||||
Controls.Add(menuStrip);
|
Controls.Add(menuStrip);
|
||||||
MainMenuStrip = menuStrip;
|
MainMenuStrip = menuStrip;
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
Name = "FormAirplaneCollection";
|
Name = "FormAirplaneCollection";
|
||||||
Text = "Коллекция самолетов";
|
Text = "Коллекция самолетов";
|
||||||
groupBoxTools.ResumeLayout(false);
|
groupBoxTools.ResumeLayout(false);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using ProjectAirplaneWithRadar.CollectionGenericObjects;
|
using ProjectAirplaneWithRadar.CollectionGenericObjects;
|
||||||
using ProjectAirplaneWithRadar.Drawnings;
|
using ProjectAirplaneWithRadar.Drawnings;
|
||||||
|
using ProjectAirplaneWithRadar.Exceptions;
|
||||||
|
|
||||||
namespace ProjectAirplaneWithRadar
|
namespace ProjectAirplaneWithRadar
|
||||||
{
|
{
|
||||||
@ -56,19 +57,24 @@ namespace ProjectAirplaneWithRadar
|
|||||||
private void SetAirplane(DrawningAirplane airplane)
|
private void SetAirplane(DrawningAirplane airplane)
|
||||||
{
|
{
|
||||||
if (_company == null || airplane == null)
|
if (_company == null || airplane == null)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (_company + airplane != -1)
|
try
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
if (_company + airplane != -1)
|
||||||
pictureBox.Image = _company.Show();
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBox.Image = _company.Show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (CollectionOverflowException ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
MessageBox.Show(ex.Message);
|
||||||
}
|
}
|
||||||
|
catch (ObjectNotFoundException ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -89,14 +95,20 @@ namespace ProjectAirplaneWithRadar
|
|||||||
}
|
}
|
||||||
|
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||||
if (_company - pos != null)
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
if (_company - pos != null)
|
||||||
pictureBox.Image = _company.Show();
|
{
|
||||||
}
|
MessageBox.Show("Объект удален");
|
||||||
else
|
pictureBox.Image = _company.Show();
|
||||||
|
}
|
||||||
|
} catch (PositionOutOfCollectionException ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
MessageBox.Show(ex.Message);
|
||||||
|
} catch (ObjectNotFoundException ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,11 +128,22 @@ namespace ProjectAirplaneWithRadar
|
|||||||
int counter = 100;
|
int counter = 100;
|
||||||
while (plane == null)
|
while (plane == null)
|
||||||
{
|
{
|
||||||
plane = _company.GetRandomObject();
|
try
|
||||||
counter--;
|
|
||||||
if (counter <= 0)
|
|
||||||
{
|
{
|
||||||
break;
|
plane = _company.GetRandomObject();
|
||||||
|
counter--;
|
||||||
|
if (counter <= 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (PositionOutOfCollectionException ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
}
|
||||||
|
catch (ObjectNotFoundException ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user