борьба с конфликтами

This commit is contained in:
sqdselo 2024-06-06 10:00:41 +04:00
commit 92a8dc27f7
3 changed files with 55 additions and 49 deletions

View File

@ -27,7 +27,7 @@ namespace HoistingCrane.CollectionGenericObjects
int currentPosWidth = countWidth - 1; int currentPosWidth = countWidth - 1;
int currentPosHeight = countHeight - 1; int currentPosHeight = countHeight - 1;
for (int i = 0; i < (_collection?.Count ?? 0); i++) for (int i = 0; i < (_collection?.Count ?? 0); i++)
{ {
if (_collection?.Get(i) != null) if (_collection?.Get(i) != null)

View File

@ -52,6 +52,8 @@
loadToolStripMenuItem = new ToolStripMenuItem(); loadToolStripMenuItem = new ToolStripMenuItem();
saveFileDialog = new SaveFileDialog(); saveFileDialog = new SaveFileDialog();
openFileDialog = new OpenFileDialog(); openFileDialog = new OpenFileDialog();
buttonSortByType = new Button();
buttonSortByColor = new Button();
groupBoxTools.SuspendLayout(); groupBoxTools.SuspendLayout();
panelCompanyTool.SuspendLayout(); panelCompanyTool.SuspendLayout();
panelStorage.SuspendLayout(); panelStorage.SuspendLayout();
@ -68,7 +70,7 @@
groupBoxTools.Dock = DockStyle.Right; groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(763, 24); groupBoxTools.Location = new Point(763, 24);
groupBoxTools.Name = "groupBoxTools"; groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(210, 499); groupBoxTools.Size = new Size(210, 524);
groupBoxTools.TabIndex = 0; groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false; groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты"; groupBoxTools.Text = "Инструменты";
@ -76,20 +78,22 @@
// panelCompanyTool // panelCompanyTool
// //
panelCompanyTool.Anchor = AnchorStyles.None; panelCompanyTool.Anchor = AnchorStyles.None;
panelCompanyTool.Controls.Add(buttonSortByColor);
panelCompanyTool.Controls.Add(buttonSortByType);
panelCompanyTool.Controls.Add(buttonCreateHoistingCrane); panelCompanyTool.Controls.Add(buttonCreateHoistingCrane);
panelCompanyTool.Controls.Add(maskedTextBox); panelCompanyTool.Controls.Add(maskedTextBox);
panelCompanyTool.Controls.Add(buttonRefresh); panelCompanyTool.Controls.Add(buttonRefresh);
panelCompanyTool.Controls.Add(buttonGoToChek); panelCompanyTool.Controls.Add(buttonGoToChek);
panelCompanyTool.Controls.Add(buttonDeleteCar); panelCompanyTool.Controls.Add(buttonDeleteCar);
panelCompanyTool.Location = new Point(6, 319); panelCompanyTool.Location = new Point(6, 296);
panelCompanyTool.Name = "panelCompanyTool"; panelCompanyTool.Name = "panelCompanyTool";
panelCompanyTool.Size = new Size(204, 185); panelCompanyTool.Size = new Size(204, 221);
panelCompanyTool.TabIndex = 8; panelCompanyTool.TabIndex = 8;
// //
// buttonCreateHoistingCrane // buttonCreateHoistingCrane
// //
buttonCreateHoistingCrane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; buttonCreateHoistingCrane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonCreateHoistingCrane.Location = new Point(9, 13); buttonCreateHoistingCrane.Location = new Point(6, 3);
buttonCreateHoistingCrane.Name = "buttonCreateHoistingCrane"; buttonCreateHoistingCrane.Name = "buttonCreateHoistingCrane";
buttonCreateHoistingCrane.Size = new Size(192, 22); buttonCreateHoistingCrane.Size = new Size(192, 22);
buttonCreateHoistingCrane.TabIndex = 0; buttonCreateHoistingCrane.TabIndex = 0;
@ -100,7 +104,7 @@
// maskedTextBox // maskedTextBox
// //
maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
maskedTextBox.Location = new Point(9, 41); maskedTextBox.Location = new Point(6, 31);
maskedTextBox.Mask = "00"; maskedTextBox.Mask = "00";
maskedTextBox.Name = "maskedTextBox"; maskedTextBox.Name = "maskedTextBox";
maskedTextBox.Size = new Size(192, 23); maskedTextBox.Size = new Size(192, 23);
@ -109,7 +113,7 @@
// buttonRefresh // buttonRefresh
// //
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(9, 129); buttonRefresh.Location = new Point(6, 119);
buttonRefresh.Name = "buttonRefresh"; buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(192, 27); buttonRefresh.Size = new Size(192, 27);
buttonRefresh.TabIndex = 5; buttonRefresh.TabIndex = 5;
@ -120,7 +124,7 @@
// buttonGoToChek // buttonGoToChek
// //
buttonGoToChek.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; buttonGoToChek.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonGoToChek.Location = new Point(9, 99); buttonGoToChek.Location = new Point(6, 89);
buttonGoToChek.Name = "buttonGoToChek"; buttonGoToChek.Name = "buttonGoToChek";
buttonGoToChek.Size = new Size(192, 24); buttonGoToChek.Size = new Size(192, 24);
buttonGoToChek.TabIndex = 6; buttonGoToChek.TabIndex = 6;
@ -131,7 +135,7 @@
// buttonDeleteCar // buttonDeleteCar
// //
buttonDeleteCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; buttonDeleteCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonDeleteCar.Location = new Point(9, 70); buttonDeleteCar.Location = new Point(6, 60);
buttonDeleteCar.Name = "buttonDeleteCar"; buttonDeleteCar.Name = "buttonDeleteCar";
buttonDeleteCar.Size = new Size(192, 23); buttonDeleteCar.Size = new Size(192, 23);
buttonDeleteCar.TabIndex = 4; buttonDeleteCar.TabIndex = 4;
@ -141,7 +145,7 @@
// //
// buttonCreateCompany // buttonCreateCompany
// //
buttonCreateCompany.Location = new Point(12, 295); buttonCreateCompany.Location = new Point(12, 267);
buttonCreateCompany.Name = "buttonCreateCompany"; buttonCreateCompany.Name = "buttonCreateCompany";
buttonCreateCompany.Size = new Size(192, 23); buttonCreateCompany.Size = new Size(192, 23);
buttonCreateCompany.TabIndex = 7; buttonCreateCompany.TabIndex = 7;
@ -161,12 +165,12 @@
panelStorage.Dock = DockStyle.Top; panelStorage.Dock = DockStyle.Top;
panelStorage.Location = new Point(3, 19); panelStorage.Location = new Point(3, 19);
panelStorage.Name = "panelStorage"; panelStorage.Name = "panelStorage";
panelStorage.Size = new Size(204, 229); panelStorage.Size = new Size(204, 216);
panelStorage.TabIndex = 7; panelStorage.TabIndex = 7;
// //
// buttonDeleteCollection // buttonDeleteCollection
// //
buttonDeleteCollection.Location = new Point(9, 199); buttonDeleteCollection.Location = new Point(9, 186);
buttonDeleteCollection.Name = "buttonDeleteCollection"; buttonDeleteCollection.Name = "buttonDeleteCollection";
buttonDeleteCollection.Size = new Size(192, 27); buttonDeleteCollection.Size = new Size(192, 27);
buttonDeleteCollection.TabIndex = 6; buttonDeleteCollection.TabIndex = 6;
@ -178,14 +182,14 @@
// //
listBoxCollection.FormattingEnabled = true; listBoxCollection.FormattingEnabled = true;
listBoxCollection.ItemHeight = 15; listBoxCollection.ItemHeight = 15;
listBoxCollection.Location = new Point(9, 118); listBoxCollection.Location = new Point(9, 101);
listBoxCollection.Name = "listBoxCollection"; listBoxCollection.Name = "listBoxCollection";
listBoxCollection.Size = new Size(192, 79); listBoxCollection.Size = new Size(192, 79);
listBoxCollection.TabIndex = 5; listBoxCollection.TabIndex = 5;
// //
// buttonCollectionAdd // buttonCollectionAdd
// //
buttonCollectionAdd.Location = new Point(9, 81); buttonCollectionAdd.Location = new Point(9, 72);
buttonCollectionAdd.Name = "buttonCollectionAdd"; buttonCollectionAdd.Name = "buttonCollectionAdd";
buttonCollectionAdd.Size = new Size(192, 23); buttonCollectionAdd.Size = new Size(192, 23);
buttonCollectionAdd.TabIndex = 4; buttonCollectionAdd.TabIndex = 4;
@ -196,7 +200,7 @@
// radioButtonList // radioButtonList
// //
radioButtonList.AutoSize = true; radioButtonList.AutoSize = true;
radioButtonList.Location = new Point(128, 56); radioButtonList.Location = new Point(128, 47);
radioButtonList.Name = "radioButtonList"; radioButtonList.Name = "radioButtonList";
radioButtonList.Size = new Size(66, 19); radioButtonList.Size = new Size(66, 19);
radioButtonList.TabIndex = 3; radioButtonList.TabIndex = 3;
@ -207,7 +211,7 @@
// radioButtonMassive // radioButtonMassive
// //
radioButtonMassive.AutoSize = true; radioButtonMassive.AutoSize = true;
radioButtonMassive.Location = new Point(18, 56); radioButtonMassive.Location = new Point(12, 47);
radioButtonMassive.Name = "radioButtonMassive"; radioButtonMassive.Name = "radioButtonMassive";
radioButtonMassive.Size = new Size(67, 19); radioButtonMassive.Size = new Size(67, 19);
radioButtonMassive.TabIndex = 2; radioButtonMassive.TabIndex = 2;
@ -237,7 +241,7 @@
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(12, 266); comboBoxSelectorCompany.Location = new Point(12, 238);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(192, 23); comboBoxSelectorCompany.Size = new Size(192, 23);
comboBoxSelectorCompany.TabIndex = 2; comboBoxSelectorCompany.TabIndex = 2;
@ -248,7 +252,7 @@
pictureBox.Dock = DockStyle.Fill; pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 24); pictureBox.Location = new Point(0, 24);
pictureBox.Name = "pictureBox"; pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(763, 499); pictureBox.Size = new Size(763, 524);
pictureBox.TabIndex = 1; pictureBox.TabIndex = 1;
pictureBox.TabStop = false; pictureBox.TabStop = false;
// //
@ -296,7 +300,7 @@
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(973, 523); ClientSize = new Size(973, 548);
Controls.Add(pictureBox); Controls.Add(pictureBox);
Controls.Add(groupBoxTools); Controls.Add(groupBoxTools);
Controls.Add(menuStrip); Controls.Add(menuStrip);
@ -341,5 +345,7 @@
private ToolStripMenuItem loadToolStripMenuItem; private ToolStripMenuItem loadToolStripMenuItem;
private SaveFileDialog saveFileDialog; private SaveFileDialog saveFileDialog;
private OpenFileDialog openFileDialog; private OpenFileDialog openFileDialog;
private Button buttonSortByColor;
private Button buttonSortByType;
} }
} }

View File

@ -31,16 +31,16 @@ namespace HoistingCrane
private void SetCrane(DrawningTrackedVehicle drawningTrackedVehicle) private void SetCrane(DrawningTrackedVehicle drawningTrackedVehicle)
{ {
if (_company == null || drawningTrackedVehicle == null) return; if (_company == null || drawningTrackedVehicle == null) return;
if (_company + drawningTrackedVehicle != -1) if (_company + drawningTrackedVehicle != -1)
{ {
MessageBox.Show("Объект добавлен"); MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show(); pictureBox.Image = _company.Show();
} }
else else
{ {
MessageBox.Show("Не удалось добавить объект"); MessageBox.Show("Не удалось добавить объект");
} }
} }
private void buttonDeleteCar_Click(object sender, EventArgs e) private void buttonDeleteCar_Click(object sender, EventArgs e)
@ -53,17 +53,17 @@ namespace HoistingCrane
{ {
return; return;
} }
int pos = Convert.ToInt32(maskedTextBox.Text); int pos = Convert.ToInt32(maskedTextBox.Text);
if ((_company - pos) != null) if ((_company - pos) != null)
{ {
MessageBox.Show("Объект удален!"); MessageBox.Show("Объект удален!");
pictureBox.Image = _company.Show(); pictureBox.Image = _company.Show();
} }
else else
{ {
MessageBox.Show("Не удалось удалить объект"); MessageBox.Show("Не удалось удалить объект");
} }
} }
private void buttonRefresh_Click(object sender, EventArgs e) private void buttonRefresh_Click(object sender, EventArgs e)
{ {
@ -120,7 +120,7 @@ namespace HoistingCrane
{ {
collectionType = CollectionType.List; collectionType = CollectionType.List;
} }
_storageCollection.AddCollection(textBoxCollectionName.Text,collectionType);RerfreshListBoxItems(); _storageCollection.AddCollection(textBoxCollectionName.Text, collectionType); RerfreshListBoxItems();
} }
private void buttonDeleteCollection_Click(object sender, EventArgs e) private void buttonDeleteCollection_Click(object sender, EventArgs e)
{ {
@ -133,18 +133,18 @@ namespace HoistingCrane
return; return;
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString()); _storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
RerfreshListBoxItems(); RerfreshListBoxItems();
} }
private void buttonCreateCompany_Click(object sender, EventArgs e) private void buttonCreateCompany_Click(object sender, EventArgs e)
{ {
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null) if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
{ {
MessageBox.Show("Коллекция не выбрана"); MessageBox.Show("Коллекция не выбрана");
return; return;
} }
ICollectionGenericObjects<DrawningTrackedVehicle>? collection = _storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty]; ICollectionGenericObjects<DrawningTrackedVehicle>? collection = _storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
if (collection == null) if (collection == null)
{ {
MessageBox.Show("Коллекция не проинициализирована"); MessageBox.Show("Коллекция не проинициализирована");
return; return;
@ -172,7 +172,7 @@ namespace HoistingCrane
{ {
_storageCollection.SaveData(saveFileDialog.FileName); _storageCollection.SaveData(saveFileDialog.FileName);
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -188,16 +188,16 @@ namespace HoistingCrane
/// <param name="e"></param> /// <param name="e"></param>
private void loadToolStripMenuItem_Click(object sender, EventArgs e) private void loadToolStripMenuItem_Click(object sender, EventArgs e)
{ {
if(openFileDialog.ShowDialog() == DialogResult.OK) if (openFileDialog.ShowDialog() == DialogResult.OK)
{ {
try try
{ {
_storageCollection.LoadData(openFileDialog.FileName); _storageCollection.LoadData(openFileDialog.FileName);
RerfreshListBoxItems(); RerfreshListBoxItems();
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
catch(Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }