This commit is contained in:
Robert 2023-12-29 06:27:01 +04:00
parent 2fd36d4785
commit b66ac1589e
5 changed files with 132 additions and 20 deletions

View File

@ -29,7 +29,7 @@ namespace DumpTruck.DrawningObjects
return new DrawningTruck(Convert.ToInt32(strs[0]),
Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
}
if (strs.Length == 6)
if (strs.Length == 5)
{
return new DrawningDumpTruck(Convert.ToInt32(strs[0]),
Convert.ToInt32(strs[1]),

View File

@ -38,9 +38,16 @@
buttonRefreshCollection = new Button();
buttonRemoveTruck = new Button();
buttonAddTruck = new Button();
menuStrip = new MenuStrip();
toolStripMenuItem1 = new ToolStripMenuItem();
toolStripMenuItemLoad = new ToolStripMenuItem();
toolStripMenuItemSave = new ToolStripMenuItem();
pictureBoxCollection = new PictureBox();
openFileDialog = new OpenFileDialog();
saveFileDialog = new SaveFileDialog();
groupBox1.SuspendLayout();
groupBox2.SuspendLayout();
menuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
SuspendLayout();
//
@ -51,6 +58,7 @@
groupBox1.Controls.Add(buttonRefreshCollection);
groupBox1.Controls.Add(buttonRemoveTruck);
groupBox1.Controls.Add(buttonAddTruck);
groupBox1.Controls.Add(menuStrip);
groupBox1.Location = new Point(689, 16);
groupBox1.Margin = new Padding(3, 4, 3, 4);
groupBox1.Name = "groupBox1";
@ -68,14 +76,14 @@
groupBox2.Controls.Add(buttonAddObject);
groupBox2.Location = new Point(3, 24);
groupBox2.Name = "groupBox2";
groupBox2.Size = new Size(220, 302);
groupBox2.Size = new Size(220, 267);
groupBox2.TabIndex = 5;
groupBox2.TabStop = false;
groupBox2.Text = "Наборы";
//
// textBoxStorageName
//
textBoxStorageName.Location = new Point(30, 50);
textBoxStorageName.Location = new Point(30, 26);
textBoxStorageName.Name = "textBoxStorageName";
textBoxStorageName.Size = new Size(171, 27);
textBoxStorageName.TabIndex = 3;
@ -83,8 +91,7 @@
// listBoxStorages
//
listBoxStorages.FormattingEnabled = true;
listBoxStorages.ItemHeight = 20;
listBoxStorages.Location = new Point(30, 135);
listBoxStorages.Location = new Point(30, 107);
listBoxStorages.Name = "listBoxStorages";
listBoxStorages.Size = new Size(171, 104);
listBoxStorages.TabIndex = 2;
@ -92,7 +99,7 @@
//
// buttonRemoveObject
//
buttonRemoveObject.Location = new Point(30, 258);
buttonRemoveObject.Location = new Point(30, 217);
buttonRemoveObject.Name = "buttonRemoveObject";
buttonRemoveObject.Size = new Size(171, 39);
buttonRemoveObject.TabIndex = 1;
@ -102,7 +109,7 @@
//
// buttonAddObject
//
buttonAddObject.Location = new Point(30, 86);
buttonAddObject.Location = new Point(30, 59);
buttonAddObject.Name = "buttonAddObject";
buttonAddObject.Size = new Size(171, 33);
buttonAddObject.TabIndex = 0;
@ -151,22 +158,67 @@
buttonAddTruck.UseVisualStyleBackColor = true;
buttonAddTruck.Click += buttonAddTruck_Click;
//
// menuStrip
//
menuStrip.AutoSize = false;
menuStrip.Dock = DockStyle.None;
menuStrip.ImageScalingSize = new Size(20, 20);
menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem1 });
menuStrip.Location = new Point(7, 314);
menuStrip.Name = "menuStrip";
menuStrip.RenderMode = ToolStripRenderMode.Professional;
menuStrip.Size = new Size(223, 47);
menuStrip.TabIndex = 6;
menuStrip.Tag = "";
menuStrip.Text = "menuStrip";
//
// toolStripMenuItem1
//
toolStripMenuItem1.DropDownItems.AddRange(new ToolStripItem[] { toolStripMenuItemLoad, toolStripMenuItemSave });
toolStripMenuItem1.Name = "toolStripMenuItem1";
toolStripMenuItem1.Size = new Size(44, 43);
toolStripMenuItem1.Text = "file";
//
// toolStripMenuItemLoad
//
toolStripMenuItemLoad.Name = "toolStripMenuItemLoad";
toolStripMenuItemLoad.Size = new Size(224, 26);
toolStripMenuItemLoad.Text = "Load";
toolStripMenuItemLoad.Click += LoadStripMenuItem_Click;
//
// toolStripMenuItemSave
//
toolStripMenuItemSave.Name = "toolStripMenuItemSave";
toolStripMenuItemSave.Size = new Size(224, 26);
toolStripMenuItemSave.Text = "Save";
toolStripMenuItemSave.Click += SaveStripMenuItem_Click;
//
// pictureBoxCollection
//
pictureBoxCollection.Location = new Point(12, 16);
pictureBoxCollection.Location = new Point(11, 16);
pictureBoxCollection.Margin = new Padding(3, 4, 3, 4);
pictureBoxCollection.Name = "pictureBoxCollection";
pictureBoxCollection.Size = new Size(651, 568);
pictureBoxCollection.Size = new Size(672, 568);
pictureBoxCollection.TabIndex = 1;
pictureBoxCollection.TabStop = false;
//
// openFileDialog
//
openFileDialog.FileName = "openFileDialog";
openFileDialog.Filter = "txt file | *.txt";
//
// saveFileDialog
//
saveFileDialog.Filter = "txt file | *.txt";
//
// FormTruckCollection
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(935, 593);
ClientSize = new Size(935, 611);
Controls.Add(pictureBoxCollection);
Controls.Add(groupBox1);
MainMenuStrip = menuStrip;
Margin = new Padding(3, 4, 3, 4);
Name = "FormTruckCollection";
Text = "Набор грузовиков";
@ -174,6 +226,8 @@
groupBox1.PerformLayout();
groupBox2.ResumeLayout(false);
groupBox2.PerformLayout();
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
ResumeLayout(false);
}
@ -191,5 +245,11 @@
private Button buttonAddObject;
private ListBox listBoxStorages;
private TextBox textBoxStorageName;
private MenuStrip menuStrip;
private ToolStripMenuItem toolStripMenuItem1;
private OpenFileDialog openFileDialog;
private SaveFileDialog saveFileDialog;
private ToolStripMenuItem toolStripMenuItemLoad;
private ToolStripMenuItem toolStripMenuItemSave;
}
}

View File

@ -11,6 +11,7 @@ using System.Xml;
using DumpTruck.DrawningObjects;
using DumpTruck.Generics;
using DumpTruck.MovementStrategy;
using Microsoft.Win32;
namespace DumpTruck
@ -47,7 +48,7 @@ namespace DumpTruck
listBoxStorages.SelectedIndex = index;
}
}
private void buttonRemoveTruck_Click(object sender, EventArgs e)
{
@ -131,7 +132,7 @@ namespace DumpTruck
MessageBox.Show("Не удалось добавить объект");
}
}
private void buttonAddTruck_Click(object sender, EventArgs e)
private void buttonAddTruck_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{
@ -161,6 +162,48 @@ namespace DumpTruck
ReloadObjects();
}
}
/// <summary>
/// Обработка нажатия "Сохранение"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SaveStripMenuItem_Click(object sender, EventArgs e)
{
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
if (_storage.SaveData(saveFileDialog.FileName))
{
MessageBox.Show("Сохранение прошло успешно",
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Не сохранилось", "Результат",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
/// <summary>
/// Обработка нажатия "Загрузка"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LoadStripMenuItem_Click(object sender, EventArgs e)
{
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
if (_storage.LoadData(openFileDialog.FileName))
{
MessageBox.Show("Загрузка прошла успешно",
"Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
ReloadObjects();
}
else
{
MessageBox.Show("Не загрузилось", "Результат",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

View File

@ -117,4 +117,13 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>145, 17</value>
</metadata>
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>315, 17</value>
</metadata>
</root>

View File

@ -237,9 +237,9 @@
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(12, 38);
pictureBoxObject.Location = new Point(3, 67);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(333, 253);
pictureBoxObject.Size = new Size(357, 278);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
//
@ -251,7 +251,7 @@
panelObject.Controls.Add(pictureBoxObject);
panelObject.Location = new Point(742, 37);
panelObject.Name = "panelObject";
panelObject.Size = new Size(363, 326);
panelObject.Size = new Size(363, 345);
panelObject.TabIndex = 3;
panelObject.DragDrop += PanelObject_DragDrop;
panelObject.DragEnter += PanelObject_DragEnter;
@ -262,7 +262,7 @@
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionalColor.Location = new Point(211, 8);
labelAdditionalColor.Name = "labelAdditionalColor";
labelAdditionalColor.Size = new Size(111, 25);
labelAdditionalColor.Size = new Size(111, 56);
labelAdditionalColor.TabIndex = 3;
labelAdditionalColor.Text = "Доп Цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
@ -276,7 +276,7 @@
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
labelBodyColor.Location = new Point(42, 8);
labelBodyColor.Name = "labelBodyColor";
labelBodyColor.Size = new Size(100, 25);
labelBodyColor.Size = new Size(100, 56);
labelBodyColor.TabIndex = 2;
labelBodyColor.Text = "Цвет";
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
@ -285,7 +285,7 @@
//
// buttonOk
//
buttonOk.Location = new Point(764, 379);
buttonOk.Location = new Point(764, 388);
buttonOk.Name = "buttonOk";
buttonOk.Size = new Size(94, 29);
buttonOk.TabIndex = 4;
@ -295,7 +295,7 @@
//
// buttonCancel
//
buttonCancel.Location = new Point(993, 379);
buttonCancel.Location = new Point(993, 388);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 5;