Compare commits
2 Commits
de23a30c02
...
9874caf690
Author | SHA1 | Date | |
---|---|---|---|
9874caf690 | |||
3a02eacd59 |
@ -0,0 +1,48 @@
|
|||||||
|
using Bulldozer.Entities;
|
||||||
|
|
||||||
|
namespace Bulldozer.DrawingObjects
|
||||||
|
{
|
||||||
|
public static class ExtentionDrawingBulldozer
|
||||||
|
{
|
||||||
|
public static DrawingBulldozer? CreateDrawingBulldozer(this string info, char separatorForObject, int width, int height)
|
||||||
|
{
|
||||||
|
string[] strs = info.Split(separatorForObject);
|
||||||
|
if (strs.Length == 4)
|
||||||
|
{
|
||||||
|
return new DrawingBulldozer(Convert.ToInt32(strs[0]),
|
||||||
|
Convert.ToInt32(strs[1]), Color.FromName(strs[2]), Color.FromName(strs[3]), width, height);
|
||||||
|
}
|
||||||
|
if (strs.Length == 7)
|
||||||
|
{
|
||||||
|
return new DrawingBulldozerUpgraded(Convert.ToInt32(strs[0]),
|
||||||
|
Convert.ToInt32(strs[1]),
|
||||||
|
Color.FromName(strs[2]),
|
||||||
|
Color.FromName(strs[3]),
|
||||||
|
Color.FromName(strs[4]),
|
||||||
|
Convert.ToBoolean(strs[5]),
|
||||||
|
Convert.ToBoolean(strs[6]), width, height);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Получение данных для сохранения в файл
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="drawingBulldozer">Сохраняемый объект</param>
|
||||||
|
/// <param name="separatorForObject">Разделитель даннных</param>
|
||||||
|
/// <returns>Строка с данными по объекту</returns>
|
||||||
|
public static string GetDataForSave(this DrawingBulldozer drawingBulldozer, char separatorForObject)
|
||||||
|
{
|
||||||
|
var bulldozer = drawingBulldozer.EntityBulldozer;
|
||||||
|
if (bulldozer == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
var str = $"{bulldozer.Speed}{separatorForObject}{bulldozer.Weight}{separatorForObject}{bulldozer.BodyColor.Name}{separatorForObject}{bulldozer.AdditionalColor.Name}";
|
||||||
|
if (bulldozer is not EntityBulldozerUpgraded bulldozerUpgraded)
|
||||||
|
{
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
return $"{str}{separatorForObject}{bulldozerUpgraded.DopColor.Name}{separatorForObject}{bulldozerUpgraded.Ripper}{separatorForObject}{bulldozerUpgraded.Blade}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -39,9 +39,16 @@
|
|||||||
this.buttonUpdateColletion = new System.Windows.Forms.Button();
|
this.buttonUpdateColletion = new System.Windows.Forms.Button();
|
||||||
this.buttonDeleteBulldozer = new System.Windows.Forms.Button();
|
this.buttonDeleteBulldozer = new System.Windows.Forms.Button();
|
||||||
this.buttonAddBulldozer = new System.Windows.Forms.Button();
|
this.buttonAddBulldozer = new System.Windows.Forms.Button();
|
||||||
|
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||||
|
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||||
|
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||||
|
this.toolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.SaveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
|
||||||
this.panelTools.SuspendLayout();
|
this.panelTools.SuspendLayout();
|
||||||
this.groupListBulldozersBox.SuspendLayout();
|
this.groupListBulldozersBox.SuspendLayout();
|
||||||
|
this.menuStrip.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// pictureBoxCollection
|
// pictureBoxCollection
|
||||||
@ -163,12 +170,56 @@
|
|||||||
this.buttonAddBulldozer.UseVisualStyleBackColor = true;
|
this.buttonAddBulldozer.UseVisualStyleBackColor = true;
|
||||||
this.buttonAddBulldozer.Click += new System.EventHandler(this.buttonAddBulldozer_Click);
|
this.buttonAddBulldozer.Click += new System.EventHandler(this.buttonAddBulldozer_Click);
|
||||||
//
|
//
|
||||||
|
// openFileDialog
|
||||||
|
//
|
||||||
|
this.openFileDialog.FileName = "openFileDialog";
|
||||||
|
this.openFileDialog.Filter = "txt file | *.txt";
|
||||||
|
//
|
||||||
|
// saveFileDialog
|
||||||
|
//
|
||||||
|
this.saveFileDialog.Filter = "txt file | *.txt";
|
||||||
|
//
|
||||||
|
// menuStrip
|
||||||
|
//
|
||||||
|
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||||
|
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.toolStripMenuItem});
|
||||||
|
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.menuStrip.Name = "menuStrip";
|
||||||
|
this.menuStrip.Size = new System.Drawing.Size(1110, 28);
|
||||||
|
this.menuStrip.TabIndex = 2;
|
||||||
|
this.menuStrip.Text = "menuStrip";
|
||||||
|
//
|
||||||
|
// toolStripMenuItem
|
||||||
|
//
|
||||||
|
this.toolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.SaveToolStripMenuItem,
|
||||||
|
this.LoadToolStripMenuItem});
|
||||||
|
this.toolStripMenuItem.Name = "toolStripMenuItem";
|
||||||
|
this.toolStripMenuItem.Size = new System.Drawing.Size(59, 24);
|
||||||
|
this.toolStripMenuItem.Text = "Файл";
|
||||||
|
//
|
||||||
|
// SaveToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||||
|
this.SaveToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||||
|
this.SaveToolStripMenuItem.Text = "Сохранить";
|
||||||
|
this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// LoadToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||||
|
this.LoadToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||||
|
this.LoadToolStripMenuItem.Text = "Загрузить";
|
||||||
|
this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// FormBulldozerCollection
|
// FormBulldozerCollection
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(1110, 793);
|
this.ClientSize = new System.Drawing.Size(1110, 793);
|
||||||
this.Controls.Add(this.panelTools);
|
this.Controls.Add(this.panelTools);
|
||||||
|
this.Controls.Add(this.menuStrip);
|
||||||
this.Controls.Add(this.pictureBoxCollection);
|
this.Controls.Add(this.pictureBoxCollection);
|
||||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
this.Name = "FormBulldozerCollection";
|
this.Name = "FormBulldozerCollection";
|
||||||
@ -178,7 +229,10 @@
|
|||||||
this.panelTools.PerformLayout();
|
this.panelTools.PerformLayout();
|
||||||
this.groupListBulldozersBox.ResumeLayout(false);
|
this.groupListBulldozersBox.ResumeLayout(false);
|
||||||
this.groupListBulldozersBox.PerformLayout();
|
this.groupListBulldozersBox.PerformLayout();
|
||||||
|
this.menuStrip.ResumeLayout(false);
|
||||||
|
this.menuStrip.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,5 +249,11 @@
|
|||||||
private GroupBox groupListBulldozersBox;
|
private GroupBox groupListBulldozersBox;
|
||||||
private Button buttonDeleteBulldozersList;
|
private Button buttonDeleteBulldozersList;
|
||||||
private Button buttonAddBulldozersList;
|
private Button buttonAddBulldozersList;
|
||||||
|
private OpenFileDialog openFileDialog;
|
||||||
|
private SaveFileDialog saveFileDialog;
|
||||||
|
private MenuStrip menuStrip;
|
||||||
|
private ToolStripMenuItem toolStripMenuItem;
|
||||||
|
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using Bulldozer.DrawingObjects;
|
using Bulldozer.DrawingObjects;
|
||||||
using Bulldozer.Generics;
|
using Bulldozer.Generics;
|
||||||
using Bulldozer.MovementStrategy;
|
using Bulldozer.MovementStrategy;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
|
||||||
namespace Bulldozer
|
namespace Bulldozer
|
||||||
@ -91,6 +92,7 @@ namespace Bulldozer
|
|||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
|
|
||||||
|
|
||||||
private void buttonAddBulldozer_Click(object sender, EventArgs e)
|
private void buttonAddBulldozer_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (listBoxBulldozerStorages.SelectedIndex == -1)
|
if (listBoxBulldozerStorages.SelectedIndex == -1)
|
||||||
@ -176,5 +178,46 @@ namespace Bulldozer
|
|||||||
}
|
}
|
||||||
pictureBoxCollection.Image = obj.ShowBulldozers();
|
pictureBoxCollection.Image = obj.ShowBulldozers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Обработка нажатия "Сохранение"
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void SaveToolStripMenuItem_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 LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (_storage.LoadData(openFileDialog.FileName))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Загрузка прошла успешно!", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
ReloadObjects();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не загрузилось!", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,4 +57,13 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>184, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>338, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
21
Bulldozer/Bulldozer/FormBulldozerConfig.Designer.cs
generated
21
Bulldozer/Bulldozer/FormBulldozerConfig.Designer.cs
generated
@ -125,7 +125,6 @@
|
|||||||
this.labelModifiedObject.TabIndex = 8;
|
this.labelModifiedObject.TabIndex = 8;
|
||||||
this.labelModifiedObject.Text = "Продвинутый";
|
this.labelModifiedObject.Text = "Продвинутый";
|
||||||
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
this.labelModifiedObject.MouseDown += labelObject_MouseDown;
|
|
||||||
//
|
//
|
||||||
// labelSimpleObject
|
// labelSimpleObject
|
||||||
//
|
//
|
||||||
@ -138,7 +137,6 @@
|
|||||||
this.labelSimpleObject.TabIndex = 7;
|
this.labelSimpleObject.TabIndex = 7;
|
||||||
this.labelSimpleObject.Text = "Простой";
|
this.labelSimpleObject.Text = "Простой";
|
||||||
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
this.labelSimpleObject.MouseDown += labelObject_MouseDown;
|
|
||||||
//
|
//
|
||||||
// groupBoxColors
|
// groupBoxColors
|
||||||
//
|
//
|
||||||
@ -158,8 +156,6 @@
|
|||||||
this.groupBoxColors.TabIndex = 6;
|
this.groupBoxColors.TabIndex = 6;
|
||||||
this.groupBoxColors.TabStop = false;
|
this.groupBoxColors.TabStop = false;
|
||||||
this.groupBoxColors.Text = "Цвета";
|
this.groupBoxColors.Text = "Цвета";
|
||||||
this.groupBoxColors.DragDrop += PanelObject_DragDrop;
|
|
||||||
this.groupBoxColors.DragEnter += PanelObject_DragEnter;
|
|
||||||
//
|
//
|
||||||
// panelPurple
|
// panelPurple
|
||||||
//
|
//
|
||||||
@ -169,7 +165,6 @@
|
|||||||
this.panelPurple.Name = "panelPurple";
|
this.panelPurple.Name = "panelPurple";
|
||||||
this.panelPurple.Size = new System.Drawing.Size(43, 43);
|
this.panelPurple.Size = new System.Drawing.Size(43, 43);
|
||||||
this.panelPurple.TabIndex = 1;
|
this.panelPurple.TabIndex = 1;
|
||||||
this.panelPurple.MouseDown += panelColor_MouseDown;
|
|
||||||
//
|
//
|
||||||
// panelBlack
|
// panelBlack
|
||||||
//
|
//
|
||||||
@ -179,7 +174,6 @@
|
|||||||
this.panelBlack.Name = "panelBlack";
|
this.panelBlack.Name = "panelBlack";
|
||||||
this.panelBlack.Size = new System.Drawing.Size(43, 43);
|
this.panelBlack.Size = new System.Drawing.Size(43, 43);
|
||||||
this.panelBlack.TabIndex = 1;
|
this.panelBlack.TabIndex = 1;
|
||||||
this.panelBlack.MouseDown += panelColor_MouseDown;
|
|
||||||
//
|
//
|
||||||
// panelGray
|
// panelGray
|
||||||
//
|
//
|
||||||
@ -189,7 +183,6 @@
|
|||||||
this.panelGray.Name = "panelGray";
|
this.panelGray.Name = "panelGray";
|
||||||
this.panelGray.Size = new System.Drawing.Size(43, 43);
|
this.panelGray.Size = new System.Drawing.Size(43, 43);
|
||||||
this.panelGray.TabIndex = 1;
|
this.panelGray.TabIndex = 1;
|
||||||
this.panelGray.MouseDown += panelColor_MouseDown;
|
|
||||||
//
|
//
|
||||||
// panelWhite
|
// panelWhite
|
||||||
//
|
//
|
||||||
@ -199,7 +192,6 @@
|
|||||||
this.panelWhite.Name = "panelWhite";
|
this.panelWhite.Name = "panelWhite";
|
||||||
this.panelWhite.Size = new System.Drawing.Size(43, 43);
|
this.panelWhite.Size = new System.Drawing.Size(43, 43);
|
||||||
this.panelWhite.TabIndex = 1;
|
this.panelWhite.TabIndex = 1;
|
||||||
this.panelWhite.MouseDown += panelColor_MouseDown;
|
|
||||||
//
|
//
|
||||||
// panelYellow
|
// panelYellow
|
||||||
//
|
//
|
||||||
@ -209,7 +201,6 @@
|
|||||||
this.panelYellow.Name = "panelYellow";
|
this.panelYellow.Name = "panelYellow";
|
||||||
this.panelYellow.Size = new System.Drawing.Size(43, 43);
|
this.panelYellow.Size = new System.Drawing.Size(43, 43);
|
||||||
this.panelYellow.TabIndex = 1;
|
this.panelYellow.TabIndex = 1;
|
||||||
this.panelYellow.MouseDown += panelColor_MouseDown;
|
|
||||||
//
|
//
|
||||||
// panelBlue
|
// panelBlue
|
||||||
//
|
//
|
||||||
@ -219,17 +210,15 @@
|
|||||||
this.panelBlue.Name = "panelBlue";
|
this.panelBlue.Name = "panelBlue";
|
||||||
this.panelBlue.Size = new System.Drawing.Size(43, 43);
|
this.panelBlue.Size = new System.Drawing.Size(43, 43);
|
||||||
this.panelBlue.TabIndex = 1;
|
this.panelBlue.TabIndex = 1;
|
||||||
this.panelBlue.MouseDown += panelColor_MouseDown;
|
|
||||||
//
|
//
|
||||||
// panelGreen
|
// panelGreen
|
||||||
//
|
//
|
||||||
this.panelGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
|
this.panelGreen.BackColor = System.Drawing.Color.Green;
|
||||||
this.panelGreen.Location = new System.Drawing.Point(77, 34);
|
this.panelGreen.Location = new System.Drawing.Point(77, 34);
|
||||||
this.panelGreen.Margin = new System.Windows.Forms.Padding(2);
|
this.panelGreen.Margin = new System.Windows.Forms.Padding(2);
|
||||||
this.panelGreen.Name = "panelGreen";
|
this.panelGreen.Name = "panelGreen";
|
||||||
this.panelGreen.Size = new System.Drawing.Size(43, 43);
|
this.panelGreen.Size = new System.Drawing.Size(43, 43);
|
||||||
this.panelGreen.TabIndex = 1;
|
this.panelGreen.TabIndex = 1;
|
||||||
this.panelGreen.MouseDown += panelColor_MouseDown;
|
|
||||||
//
|
//
|
||||||
// panelRed
|
// panelRed
|
||||||
//
|
//
|
||||||
@ -239,7 +228,6 @@
|
|||||||
this.panelRed.Name = "panelRed";
|
this.panelRed.Name = "panelRed";
|
||||||
this.panelRed.Size = new System.Drawing.Size(43, 43);
|
this.panelRed.Size = new System.Drawing.Size(43, 43);
|
||||||
this.panelRed.TabIndex = 0;
|
this.panelRed.TabIndex = 0;
|
||||||
this.panelRed.MouseDown += panelColor_MouseDown;
|
|
||||||
//
|
//
|
||||||
// numericUpDownWeight
|
// numericUpDownWeight
|
||||||
//
|
//
|
||||||
@ -327,8 +315,6 @@
|
|||||||
this.panelObject.Name = "panelObject";
|
this.panelObject.Name = "panelObject";
|
||||||
this.panelObject.Size = new System.Drawing.Size(334, 202);
|
this.panelObject.Size = new System.Drawing.Size(334, 202);
|
||||||
this.panelObject.TabIndex = 2;
|
this.panelObject.TabIndex = 2;
|
||||||
this. panelObject.DragDrop += PanelObject_DragDrop;
|
|
||||||
panelObject.DragEnter += PanelObject_DragEnter;
|
|
||||||
//
|
//
|
||||||
// labelAddColor
|
// labelAddColor
|
||||||
//
|
//
|
||||||
@ -341,8 +327,6 @@
|
|||||||
this.labelAddColor.TabIndex = 3;
|
this.labelAddColor.TabIndex = 3;
|
||||||
this.labelAddColor.Text = "Дополн. цвет";
|
this.labelAddColor.Text = "Дополн. цвет";
|
||||||
this.labelAddColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
this.labelAddColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
this.labelAddColor.DragDrop += labelColor_dragDrop;
|
|
||||||
this.labelAddColor.DragEnter += labelColor_dragEnter;
|
|
||||||
//
|
//
|
||||||
// labelColor
|
// labelColor
|
||||||
//
|
//
|
||||||
@ -355,8 +339,6 @@
|
|||||||
this.labelColor.TabIndex = 2;
|
this.labelColor.TabIndex = 2;
|
||||||
this.labelColor.Text = "Основной цвет";
|
this.labelColor.Text = "Основной цвет";
|
||||||
this.labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
this.labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
this.labelColor.DragDrop += labelColor_dragDrop;
|
|
||||||
this.labelColor.DragEnter += labelColor_dragEnter;
|
|
||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
@ -367,7 +349,6 @@
|
|||||||
this.buttonAdd.TabIndex = 3;
|
this.buttonAdd.TabIndex = 3;
|
||||||
this.buttonAdd.Text = "Добавить";
|
this.buttonAdd.Text = "Добавить";
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
this.buttonAdd.Click += buttonAdd_Click;
|
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
|
@ -7,6 +7,10 @@ namespace Bulldozer.Generics
|
|||||||
where T : DrawingBulldozer
|
where T : DrawingBulldozer
|
||||||
where U : IMoveableObject
|
where U : IMoveableObject
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Получение объектов коллекции
|
||||||
|
/// </summary>
|
||||||
|
public IEnumerable<T?> GetBulldozers => _collection.GetBulldozers();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина окна прорисовки
|
/// Ширина окна прорисовки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -141,7 +145,7 @@ namespace Bulldozer.Generics
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using Bulldozer.DrawingObjects;
|
using Bulldozer.DrawingObjects;
|
||||||
using Bulldozer.MovementStrategy;
|
using Bulldozer.MovementStrategy;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace Bulldozer.Generics
|
namespace Bulldozer.Generics
|
||||||
{
|
{
|
||||||
@ -66,12 +67,10 @@ namespace Bulldozer.Generics
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ind"></param>
|
/// <param name="ind"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public BulldozersGenericCollection<DrawingBulldozer, DrawingObjectBulldozer>?
|
public BulldozersGenericCollection<DrawingBulldozer, DrawingObjectBulldozer>? this[string ind]
|
||||||
this[string ind]
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
// TODO: Продумать логику получения набора
|
|
||||||
if (_bulldozerStorages.ContainsKey(ind))
|
if (_bulldozerStorages.ContainsKey(ind))
|
||||||
{
|
{
|
||||||
return _bulldozerStorages[ind];
|
return _bulldozerStorages[ind];
|
||||||
@ -82,6 +81,108 @@ namespace Bulldozer.Generics
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// Разделитель для записи ключа и значения элемента словаря
|
||||||
|
/// </summary>
|
||||||
|
private static readonly char _separatorForKeyValue = '|';
|
||||||
|
/// <summary>
|
||||||
|
/// Разделитель для записей коллекции данных в файл
|
||||||
|
/// </summary>
|
||||||
|
private readonly char _separatorRecords = ';';
|
||||||
|
/// <summary>
|
||||||
|
/// Разделитель для записи информации по объекту в файл
|
||||||
|
/// </summary>
|
||||||
|
private static readonly char _separatorForObject = ':';
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Сохранение информации по автомобилям в хранилище в файл
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename">Путь и имя файла</param>
|
||||||
|
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
|
||||||
|
public bool SaveData(string filename)
|
||||||
|
{
|
||||||
|
if (File.Exists(filename))
|
||||||
|
{
|
||||||
|
File.Delete(filename);
|
||||||
|
}
|
||||||
|
StringBuilder data = new();
|
||||||
|
foreach (KeyValuePair<string, BulldozersGenericCollection<DrawingBulldozer, DrawingObjectBulldozer>> record in _bulldozerStorages)
|
||||||
|
{
|
||||||
|
StringBuilder records = new();
|
||||||
|
foreach (DrawingBulldozer? elem in record.Value.GetBulldozers)
|
||||||
|
{
|
||||||
|
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
||||||
|
}
|
||||||
|
data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}");
|
||||||
|
}
|
||||||
|
if (data.Length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
string toWrite = $"BulldozerStorage{Environment.NewLine}{data}";
|
||||||
|
var strs = toWrite.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
using (StreamWriter sw = new(filename))
|
||||||
|
{
|
||||||
|
foreach (var str in strs)
|
||||||
|
{
|
||||||
|
sw.WriteLine(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Загрузка информации по автомобилям в хранилище из файла
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename">Путь и имя файла</param>
|
||||||
|
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
||||||
|
public bool LoadData(string filename)
|
||||||
|
{
|
||||||
|
if (!File.Exists(filename))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
using (StreamReader sr = new(filename))
|
||||||
|
{
|
||||||
|
string str = sr.ReadLine();
|
||||||
|
var strs = str.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (strs == null || strs.Length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!strs[0].StartsWith("BulldozerStorage"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_bulldozerStorages.Clear();
|
||||||
|
do
|
||||||
|
{
|
||||||
|
string[] record = str.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (record.Length != 2)
|
||||||
|
{
|
||||||
|
str = sr.ReadLine();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
BulldozersGenericCollection<DrawingBulldozer, DrawingObjectBulldozer> collection = new(_pictureWidth, _pictureHeight);
|
||||||
|
string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
foreach (string elem in set)
|
||||||
|
{
|
||||||
|
DrawingBulldozer? bulldozer =
|
||||||
|
elem?.CreateDrawingBulldozer(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||||
|
if (bulldozer != null)
|
||||||
|
{
|
||||||
|
if ((collection + bulldozer) == -1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_bulldozerStorages.Add(record[0], collection);
|
||||||
|
|
||||||
|
str = sr.ReadLine();
|
||||||
|
} while (str != null);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user