diff --git a/Excavator/Drawing/DrawingExcavator.cs b/Excavator/Drawing/DrawingExcavator.cs
index 433e91e..9c7b390 100644
--- a/Excavator/Drawing/DrawingExcavator.cs
+++ b/Excavator/Drawing/DrawingExcavator.cs
@@ -16,6 +16,7 @@ namespace Excavator.Drawing
{
EntityMash = new EntityExcavator(speed, weight, bodyColor, additionalColor, bucket, supports);
}
+
}
public override void DrawTransport(Graphics g)
{
@@ -25,10 +26,10 @@ namespace Excavator.Drawing
}
Pen pen = new(Color.Black);
Pen additionalPen = new(Excavator.Body);
- Brush additionalBrush = new SolidBrush(Excavator.Body);
+ Brush additionalBrush = new SolidBrush(Excavator.AddColor);
base.DrawTransport(g);
- if (Excavator.Bucket)
+ if (Excavator.IsBucket)
{
Brush additionalBrush2 = new
SolidBrush(EntityMash.BodyColor);
@@ -37,7 +38,7 @@ namespace Excavator.Drawing
g.FillRectangle(additionalBrush, _startPosX + 5, _startPosY + 37, 10, 50);
}
- if (Excavator.Supports)
+ if (Excavator.IsSupports)
{
g.FillRectangle(additionalBrush, _startPosX + 170, _startPosY + 47, 25, 5);
g.FillRectangle(additionalBrush, _startPosX + 180, _startPosY + 27, 15, 45);
diff --git a/Excavator/Drawing/DrawingMash.cs b/Excavator/Drawing/DrawingMash.cs
index 459d44b..9b45e84 100644
--- a/Excavator/Drawing/DrawingMash.cs
+++ b/Excavator/Drawing/DrawingMash.cs
@@ -11,7 +11,7 @@ namespace Excavator.Drawing
{
public class DrawingMash
{
- public IMoveableObject GetMoveableObject => new DrawingObjectmash(this);
+ public IMoveableObject GetMoveableObject => new DrawingObjectMash(this);
public EntityMash? EntityMash { get; protected set; }
public int _pictureWidth;
public int _pictureHeight;
@@ -33,7 +33,7 @@ namespace Excavator.Drawing
_pictureHeight = height;
EntityMash = new EntityMash(speed, weight, bodyColor);
}
- protected DrawingMash(int speed, double weight, Color bodyColor, int width, int height, int mashWidth, int mashHeight)
+ protected DrawingMash(int speed, double weight, Color bodyColor, int width, int height, int busWidth, int busHeight)
{
if (width < _mashWidth || height < _mashHeight)
{
@@ -41,8 +41,8 @@ namespace Excavator.Drawing
}
_pictureWidth = width;
_pictureHeight = height;
- _mashWidth = mashWidth;
- _mashHeight = mashHeight;
+ _mashWidth = busWidth;
+ _mashHeight = busHeight;
EntityMash = new EntityMash(speed, weight, bodyColor);
}
public void SetPosition(int x, int y)
@@ -136,6 +136,7 @@ namespace Excavator.Drawing
_ => false,
};
}
+
public void ChangeBordersPicture(int width, int height)
{
_pictureWidth = width;
diff --git a/Excavator/Drawing/ExtentionDrawingMash.cs b/Excavator/Drawing/ExtentionDrawingMash.cs
new file mode 100644
index 0000000..1e33ae3
--- /dev/null
+++ b/Excavator/Drawing/ExtentionDrawingMash.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Excavator.Entities;
+
+namespace Excavator.Drawing
+{
+ public static class ExtentionDrawingMash
+ {
+ public static DrawingMash? CreateDrawingMash(this string info, char separatorForObject, int width, int height)
+ {
+ string[] strs = info.Split(separatorForObject);
+ if (strs.Length == 3)
+ {
+ return new DrawingMash(
+ Convert.ToInt32(strs[0]),
+ Convert.ToInt32(strs[1]),
+ Color.FromName(strs[2]), width, height);
+ }
+ if (strs.Length == 6)
+ {
+ return new DrawingExcavator(
+ Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]),
+ Color.FromName(strs[2]), Color.FromName(strs[3]),
+ Convert.ToBoolean(strs[4]), Convert.ToBoolean(strs[5]),
+ width, height);
+ }
+ return null;
+ }
+
+ public static string GetDataForSave(this DrawingMash DrawingMash, char separatorForObject)
+ {
+ var truck = DrawingMash.EntityMash;
+ if (truck == null)
+ {
+ return string.Empty;
+ }
+ var str = $"{truck.Speed}{separatorForObject}{truck.Weight}{separatorForObject}{truck.BodyColor.Name}";
+ if (truck is not EntityExcavator Excavator)
+ {
+ return str;
+ }
+ return $"{str}{separatorForObject}{Excavator.AddColor.Name}{separatorForObject}{Excavator.IsBucket}{separatorForObject}{Excavator.IsSupports}";
+ }
+ }
+}
+
diff --git a/Excavator/Entities/DirectionType.cs b/Excavator/Entities/DirectionType.cs
index d392619..436b36b 100644
--- a/Excavator/Entities/DirectionType.cs
+++ b/Excavator/Entities/DirectionType.cs
@@ -12,5 +12,6 @@ namespace Excavator.Entities
Down = 2,
Left = 3,
Right = 4
+
}
}
\ No newline at end of file
diff --git a/Excavator/Entities/EntityExcavator.cs b/Excavator/Entities/EntityExcavator.cs
index 955ff61..7a3f177 100644
--- a/Excavator/Entities/EntityExcavator.cs
+++ b/Excavator/Entities/EntityExcavator.cs
@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
@@ -11,17 +12,18 @@ namespace Excavator.Entities
{
public Color Body { get; private set; }
public Color AddColor { get; private set; }
- public bool Bucket { get; private set; }
- public bool Supports { get; private set; }
+ public bool IsBucket { get; private set; }
+ public bool IsSupports { get; private set; }
+
public EntityExcavator(int speed, double weight, Color bodyColor, Color additionalColor, bool bucket, bool supports) : base(speed, weight, bodyColor)
{
AddColor = additionalColor;
- Bucket = bucket;
- Supports = supports;
+ IsBucket = bucket;
+ IsSupports = supports;
}
public void ChangeAdditionalColor(Color additionalColor)
{
- Body = additionalColor;
+ AddColor = additionalColor;
}
}
}
\ No newline at end of file
diff --git a/Excavator/Entities/EntityMash.cs b/Excavator/Entities/EntityMash.cs
index c3b0de6..652bfb0 100644
--- a/Excavator/Entities/EntityMash.cs
+++ b/Excavator/Entities/EntityMash.cs
@@ -18,6 +18,7 @@ namespace Excavator.Entities
Weight = weight;
BodyColor = bodyColor;
}
+
public void ChangeBodyColor(Color color)
{
BodyColor = color;
diff --git a/Excavator/FormExcavatorCollection.Designer.cs b/Excavator/FormExcavatorCollection.Designer.cs
index d018c15..e60d297 100644
--- a/Excavator/FormExcavatorCollection.Designer.cs
+++ b/Excavator/FormExcavatorCollection.Designer.cs
@@ -40,7 +40,14 @@
this.buttonAddStorage = new System.Windows.Forms.Button();
this.buttonDeleteStorage = new System.Windows.Forms.Button();
this.textBoxStorageName = new System.Windows.Forms.TextBox();
+ 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();
+ this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
+ this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
+ this.menuStrip.SuspendLayout();
this.SuspendLayout();
//
// buttonAddMash
@@ -57,12 +64,13 @@
//
// pictureBoxCollection
//
- this.pictureBoxCollection.Location = new System.Drawing.Point(3, 0);
+ this.pictureBoxCollection.Location = new System.Drawing.Point(0, 27);
this.pictureBoxCollection.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.pictureBoxCollection.Name = "pictureBoxCollection";
this.pictureBoxCollection.Size = new System.Drawing.Size(949, 633);
this.pictureBoxCollection.TabIndex = 1;
- this.pictureBoxCollection.TabStop = false; //
+ this.pictureBoxCollection.TabStop = false;
+ //
// labelInstruments
//
this.labelInstruments.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@@ -84,6 +92,7 @@
this.buttonUpdate.TabIndex = 3;
this.buttonUpdate.Text = "Обновить набор";
this.buttonUpdate.UseVisualStyleBackColor = true;
+ this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
//
// buttonDeleteMash
//
@@ -93,8 +102,9 @@
this.buttonDeleteMash.Name = "buttonDeleteMash";
this.buttonDeleteMash.Size = new System.Drawing.Size(135, 37);
this.buttonDeleteMash.TabIndex = 4;
- this.buttonDeleteMash.Text = "Удалить ";
+ this.buttonDeleteMash.Text = "Удалить";
this.buttonDeleteMash.UseVisualStyleBackColor = true;
+ this.buttonDeleteMash.Click += new System.EventHandler(this.buttonDeleteMash_Click);
//
// maskedTextBoxNumber
//
@@ -125,6 +135,7 @@
this.listBoxStorages.Name = "listBoxStorages";
this.listBoxStorages.Size = new System.Drawing.Size(150, 144);
this.listBoxStorages.TabIndex = 8;
+ this.listBoxStorages.SelectedIndexChanged += new System.EventHandler(this.listBoxObjects_SelectedIndexChanged);
//
// buttonAddStorage
//
@@ -144,6 +155,7 @@
this.buttonDeleteStorage.TabIndex = 10;
this.buttonDeleteStorage.Text = "Удалить набор";
this.buttonDeleteStorage.UseVisualStyleBackColor = true;
+ this.buttonDeleteStorage.Click += new System.EventHandler(this.buttonDeleteStorage_Click);
//
// textBoxStorageName
//
@@ -152,11 +164,55 @@
this.textBoxStorageName.Size = new System.Drawing.Size(150, 27);
this.textBoxStorageName.TabIndex = 11;
//
+ // 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.Padding = new System.Windows.Forms.Padding(6, 3, 0, 3);
+ this.menuStrip.Size = new System.Drawing.Size(1146, 30);
+ this.menuStrip.TabIndex = 12;
+ this.menuStrip.Text = "menuStrip1";
+ //
+ // 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(166, 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(166, 26);
+ this.loadToolStripMenuItem.Text = "Загрузить";
+ this.loadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click);
+ //
+ // saveFileDialog
+ //
+ this.saveFileDialog.Filter = "txt file | *.txt";
+ //
+ // openFileDialog
+ //
+ this.openFileDialog.FileName = "openFileDialog1";
+ this.openFileDialog.Filter = "txt file | *.txt";
+ //
// FormExcavatorCollection
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1146, 640);
+ this.ClientSize = new System.Drawing.Size(1146, 672);
this.Controls.Add(this.textBoxStorageName);
this.Controls.Add(this.buttonDeleteStorage);
this.Controls.Add(this.buttonAddStorage);
@@ -168,10 +224,14 @@
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.labelInstruments);
this.Controls.Add(this.pictureBoxCollection);
+ this.Controls.Add(this.menuStrip);
+ this.MainMenuStrip = this.menuStrip;
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "FormExcavatorCollection";
this.Text = "Набор объектов";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
+ this.menuStrip.ResumeLayout(false);
+ this.menuStrip.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@@ -191,5 +251,11 @@
private Button buttonAddStorage;
private Button buttonDeleteStorage;
private TextBox textBoxStorageName;
+ private MenuStrip menuStrip;
+ private ToolStripMenuItem toolStripMenuItem;
+ private ToolStripMenuItem saveToolStripMenuItem;
+ private ToolStripMenuItem loadToolStripMenuItem;
+ private SaveFileDialog saveFileDialog;
+ private OpenFileDialog openFileDialog;
}
}
\ No newline at end of file
diff --git a/Excavator/FormExcavatorCollection.cs b/Excavator/FormExcavatorCollection.cs
index 63769c4..94380b1 100644
--- a/Excavator/FormExcavatorCollection.cs
+++ b/Excavator/FormExcavatorCollection.cs
@@ -11,15 +11,17 @@ using Excavator.Generic;
using Excavator.Drawing;
using Excavator.Move_Strategy;
+
namespace Excavator
{
public partial class FormExcavatorCollection : Form
{
- private readonly mashesGenericStorage _storage;
+ private readonly MashGenericStorage _storage;
+
public FormExcavatorCollection()
{
InitializeComponent();
- _storage = new mashesGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
+ _storage = new MashGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
}
private void ReloadObjects()
{
@@ -37,6 +39,7 @@ namespace Excavator
{
listBoxStorages.SelectedIndex = index;
}
+
}
private void buttonAddStorage_Click(object sender, EventArgs e)
{
@@ -64,12 +67,15 @@ namespace Excavator
ReloadObjects();
}
}
+
private void buttonAddMash_Click(object sender, EventArgs e)
{
- var formmashConfig = new FormmashConfig();
- formmashConfig.AddEvent(AddMash);
- formmashConfig.Show();
+
+ var FormMashConfig = new FormMashConfig();
+ FormMashConfig.AddEvent(AddMash);
+ FormMashConfig.Show();
}
+
private void AddMash(DrawingMash SelectedMash)
{
if (listBoxStorages.SelectedIndex == -1)
@@ -84,15 +90,16 @@ namespace Excavator
}
SelectedMash.ChangeBordersPicture(pictureBoxCollection.Width, pictureBoxCollection.Height);
if (obj + SelectedMash != -1)
- {
- MessageBox.Show("Объект добавлен");
- pictureBoxCollection.Image = obj.ShowMash();
- }
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBoxCollection.Image = obj.ShowMash();
+ }
else
- {
- MessageBox.Show("Не удалось добавить объект");
- }
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
}
+
private void buttonDeleteMash_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
@@ -118,7 +125,7 @@ namespace Excavator
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
- if (obj - pos)
+ if (obj - pos)
{
MessageBox.Show("Объект удален");
pictureBoxCollection.Image = obj.ShowMash();
@@ -142,5 +149,36 @@ namespace Excavator
}
pictureBoxCollection.Image = obj.ShowMash();
}
+ 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);
+ }
+ }
+ }
+ private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ if (openFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ if (_storage.LoadData(openFileDialog.FileName))
+ {
+ ReloadObjects();
+ var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
+ pictureBoxCollection.Image = obj.ShowMash();
+ MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ MessageBox.Show("Не загрузилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
}
}
diff --git a/Excavator/FormExcavatorCollection.resx b/Excavator/FormExcavatorCollection.resx
index f1dbd20..40da1d6 100644
--- a/Excavator/FormExcavatorCollection.resx
+++ b/Excavator/FormExcavatorCollection.resx
@@ -60,6 +60,15 @@
17, 17
+
+ 152, 17
+
+
+ 428, 16
+
+
+ 590, 16
+
36
diff --git a/Excavator/FormMashConfig.Designer.cs b/Excavator/FormMashConfig.Designer.cs
index cfb98da..6e39766 100644
--- a/Excavator/FormMashConfig.Designer.cs
+++ b/Excavator/FormMashConfig.Designer.cs
@@ -1,8 +1,16 @@
namespace Excavator
{
- partial class FormmashConfig
+ partial class FormMashConfig
{
+ ///
+ /// Required designer variable.
+ ///
private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@@ -33,7 +41,7 @@
this.panelRoyalBlue = new System.Windows.Forms.Panel();
this.panelFirebrick = new System.Windows.Forms.Panel();
this.checkBoxLadder = new System.Windows.Forms.CheckBox();
- this.checkBoxbucket = new System.Windows.Forms.CheckBox();
+ this.checkBoxBucket = new System.Windows.Forms.CheckBox();
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
this.labelWeight = new System.Windows.Forms.Label();
@@ -58,7 +66,7 @@
this.groupBoxConfig.Controls.Add(this.labelSimpleObject);
this.groupBoxConfig.Controls.Add(this.groupBoxColor);
this.groupBoxConfig.Controls.Add(this.checkBoxLadder);
- this.groupBoxConfig.Controls.Add(this.checkBoxbucket);
+ this.groupBoxConfig.Controls.Add(this.checkBoxBucket);
this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed);
this.groupBoxConfig.Controls.Add(this.numericUpDownWeight);
this.groupBoxConfig.Controls.Add(this.labelWeight);
@@ -143,7 +151,7 @@
//
// 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(215, 25);
this.panelGreen.Name = "panelGreen";
this.panelGreen.Size = new System.Drawing.Size(50, 40);
@@ -182,17 +190,16 @@
this.checkBoxLadder.TabIndex = 5;
this.checkBoxLadder.Text = "Наличие опор";
this.checkBoxLadder.UseVisualStyleBackColor = true;
-
//
- // checkBoxbucket
+ // checkBoxBucket
//
- this.checkBoxbucket.AutoSize = true;
- this.checkBoxbucket.Location = new System.Drawing.Point(13, 119);
- this.checkBoxbucket.Name = "checkBoxbucket";
- this.checkBoxbucket.Size = new System.Drawing.Size(149, 24);
- this.checkBoxbucket.TabIndex = 4;
- this.checkBoxbucket.Text = "Наличие Отвала ";
- this.checkBoxbucket.UseVisualStyleBackColor = true;
+ this.checkBoxBucket.AutoSize = true;
+ this.checkBoxBucket.Location = new System.Drawing.Point(13, 119);
+ this.checkBoxBucket.Name = "checkBoxBucket";
+ this.checkBoxBucket.Size = new System.Drawing.Size(143, 24);
+ this.checkBoxBucket.TabIndex = 4;
+ this.checkBoxBucket.Text = "Наличие отвала";
+ this.checkBoxBucket.UseVisualStyleBackColor = true;
//
// numericUpDownSpeed
//
@@ -323,7 +330,7 @@
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
//
- // FormmashConfig
+ // FormMashConfig
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
@@ -332,8 +339,8 @@
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.panelObject);
this.Controls.Add(this.groupBoxConfig);
- this.Name = "FormmashConfig";
- this.Text = "FormmashConfig";
+ this.Name = "FormMashConfig";
+ this.Text = "FormMashConfig";
this.groupBoxConfig.ResumeLayout(false);
this.groupBoxConfig.PerformLayout();
this.groupBoxColor.ResumeLayout(false);
@@ -353,7 +360,7 @@
private Label labelWeight;
private Label labelSpeed;
private CheckBox checkBoxLadder;
- private CheckBox checkBoxbucket;
+ private CheckBox checkBoxBucket;
private GroupBox groupBoxColor;
private Panel panelBlue;
private Panel panelBlack;
diff --git a/Excavator/FormMashConfig.cs b/Excavator/FormMashConfig.cs
index 7312a56..ea4987f 100644
--- a/Excavator/FormMashConfig.cs
+++ b/Excavator/FormMashConfig.cs
@@ -12,11 +12,12 @@ using Excavator.Entities;
namespace Excavator
{
- public partial class FormmashConfig : Form
+ public partial class FormMashConfig : Form
{
+
DrawingMash? _mash = null;
private event Action? EventAddMash;
- public FormmashConfig()
+ public FormMashConfig()
{
InitializeComponent();
panelFirebrick.MouseDown += PanelColor_MouseDown;
@@ -48,11 +49,13 @@ namespace Excavator
EventAddMash += ev;
}
}
+
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name,
DragDropEffects.Move | DragDropEffects.Copy);
}
+
private void PanelObject_DragEnter(object sender, DragEventArgs e)
{
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
@@ -81,17 +84,19 @@ namespace Excavator
(int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value,
Color.White, Color.Black,
- checkBoxbucket.Checked, checkBoxLadder.Checked,
+ checkBoxBucket.Checked, checkBoxLadder.Checked,
pictureBoxObject.Width, pictureBoxObject.Height);
break;
}
DrawMash();
}
+
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
DragDropEffects.Move | DragDropEffects.Copy);
}
+
private void LabelMainColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)) && _mash != null)
@@ -103,12 +108,14 @@ namespace Excavator
e.Effect = DragDropEffects.None;
}
}
+
private void LabelMainColor_DragDrop(object sender, DragEventArgs e)
{
var color = (Color)e.Data.GetData(typeof(Color));
_mash.EntityMash.ChangeBodyColor(color);
DrawMash();
}
+
private void LabelAdditionalColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)) && _mash != null && _mash is DrawingExcavator)
@@ -128,6 +135,7 @@ namespace Excavator
_Excavator.ChangeAdditionalColor(color);
DrawMash();
}
+
private void ButtonAdd_Click(object sender, EventArgs e)
{
EventAddMash?.Invoke(_mash);
diff --git a/Excavator/Generic/MashGenericCollection.cs b/Excavator/Generic/MashGenericCollection.cs
index 4e8a377..78226a3 100644
--- a/Excavator/Generic/MashGenericCollection.cs
+++ b/Excavator/Generic/MashGenericCollection.cs
@@ -43,10 +43,13 @@ namespace Excavator.Generic
}
return collect?._collection.Remove(pos) ?? false;
}
+
+ public IEnumerable GetMash => _collection.GetMash();
public U? GetU(int pos)
{
return (U?)_collection[pos]?.GetMoveableObject;
}
+
public Bitmap ShowMash()
{
Bitmap bmp = new(_pictureWidth, _pictureHeight);
@@ -55,6 +58,7 @@ namespace Excavator.Generic
DrawObjects(gr);
return bmp;
}
+
private void DrawBackground(Graphics gr)
{
Pen pen = new(Color.Black, 3);
@@ -67,9 +71,9 @@ namespace Excavator.Generic
}
}
}
+
private void DrawObjects(Graphics g)
{
-
int x = _pictureWidth / _placeSizeWidth - 1;
int y = 0;
diff --git a/Excavator/Generic/MashsGenericStorage.cs b/Excavator/Generic/MashsGenericStorage.cs
index 0201584..c0469bd 100644
--- a/Excavator/Generic/MashsGenericStorage.cs
+++ b/Excavator/Generic/MashsGenericStorage.cs
@@ -8,18 +8,23 @@ using Excavator.Move_Strategy;
namespace Excavator.Generic
{
- internal class mashesGenericStorage
+ internal class MashGenericStorage
{
- readonly Dictionary> _mashStorages;
+ readonly Dictionary> _mashStorages;
public List Keys => _mashStorages.Keys.ToList();
private readonly int _pictureWidth;
private readonly int _pictureHeight;
- public mashesGenericStorage(int pictureWidth, int pictureHeight)
+ private static readonly char _separatorForKeyValue = '|';
+ private readonly char _separatorRecords = ';';
+ private static readonly char _separatorForObject = ':';
+
+ public MashGenericStorage(int pictureWidth, int pictureHeight)
{
- _mashStorages = new Dictionary>();
+ _mashStorages = new Dictionary>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
+
public void AddSet(string name)
{
foreach (string nameStorage in Keys)
@@ -30,16 +35,18 @@ namespace Excavator.Generic
return;
}
}
- _mashStorages.Add(name, new MashGenericCollection(_pictureWidth, _pictureHeight));
+ _mashStorages.Add(name, new MashGenericCollection(_pictureWidth, _pictureHeight));
}
+
public void DelSet(string name)
{
if (_mashStorages.ContainsKey(name))
{
_mashStorages.Remove(name);
}
+
}
- public MashGenericCollection? this[string ind]
+ public MashGenericCollection? this[string ind]
{
get
{
@@ -50,5 +57,69 @@ namespace Excavator.Generic
return null;
}
}
+
+ public bool SaveData(string filename)
+ {
+ if (File.Exists(filename))
+ {
+ File.Delete(filename);
+ }
+
+ using (StreamWriter sw = File.CreateText(filename))
+ {
+ sw.WriteLine($"ExcavatorStorage");
+ foreach (var record in _mashStorages)
+ {
+ StringBuilder records = new();
+ foreach (DrawingMash? elem in record.Value.GetMash)
+ {
+ records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
+ }
+ sw.WriteLine($"{record.Key}{_separatorForKeyValue}{records}");
+ }
+ }
+
+ return true;
+ }
+
+ public bool LoadData(string filename)
+ {
+ if (!File.Exists(filename))
+ {
+ return false;
+ }
+
+ using (StreamReader sr = File.OpenText(filename))
+ {
+ string? curLine = sr.ReadLine();
+ if (curLine == null || !curLine.Contains("ExcavatorStorage"))
+ {
+ return false;
+ }
+ _mashStorages.Clear();
+ curLine = sr.ReadLine();
+ while (curLine != null)
+ {
+ string[] record = curLine.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
+ MashGenericCollection collection = new(_pictureWidth, _pictureHeight);
+ string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries);
+
+ foreach (string elem in set)
+ {
+ DrawingMash? Mash = elem?.CreateDrawingMash(_separatorForObject, _pictureWidth, _pictureHeight);
+ if (Mash != null)
+ {
+ if (collection + Mash == -1)
+ {
+ return false;
+ }
+ }
+ }
+ _mashStorages.Add(record[0], collection);
+ curLine = sr.ReadLine();
+ }
+ }
+ return true;
+ }
}
}
diff --git a/Excavator/Generic/SetGeneric.cs b/Excavator/Generic/SetGeneric.cs
index 2cf6d43..155a866 100644
--- a/Excavator/Generic/SetGeneric.cs
+++ b/Excavator/Generic/SetGeneric.cs
@@ -17,11 +17,13 @@ namespace Excavator.Generic
_maxCount = count;
_places = new List(count);
}
- public int Insert(T mash)
+
+ public int Insert(T bus)
{
- _places.Insert(0, mash);
+ _places.Insert(0, bus);
return 0;
}
+
public bool Insert(T mash, int position)
{
if (position < 0 || position >= Count || Count >= _maxCount)
@@ -60,16 +62,16 @@ namespace Excavator.Generic
_places.Insert(position, value);
}
}
- public IEnumerable GetMash(int? maxmash = null)
+ public IEnumerable GetMash(int? maxMash = null)
{
for (int i = 0; i < _places.Count; ++i)
{
yield return _places[i];
- if (maxmash.HasValue && i == maxmash.Value)
+ if (maxMash.HasValue && i == maxMash.Value)
{
yield break;
}
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Excavator/Move_Strategy/AbstractStrategy.cs b/Excavator/Move_Strategy/AbstractStrategy.cs
index a307eee..29aca81 100644
--- a/Excavator/Move_Strategy/AbstractStrategy.cs
+++ b/Excavator/Move_Strategy/AbstractStrategy.cs
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Excavator.Entities;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
+
namespace Excavator.Move_Strategy
{
public abstract class AbstractStrategy
@@ -69,4 +70,5 @@ namespace Excavator.Move_Strategy
return false;
}
}
-}
\ No newline at end of file
+}
+
diff --git a/Excavator/Move_Strategy/DrawingObjectMash.cs b/Excavator/Move_Strategy/DrawingObjectMash.cs
index 06feec6..377f42b 100644
--- a/Excavator/Move_Strategy/DrawingObjectMash.cs
+++ b/Excavator/Move_Strategy/DrawingObjectMash.cs
@@ -8,12 +8,13 @@ using System.Threading.Tasks;
using Excavator.Entities;
using Excavator.Drawing;
+
namespace Excavator.Move_Strategy
{
- public class DrawingObjectmash : IMoveableObject
+ public class DrawingObjectMash : IMoveableObject
{
private readonly DrawingMash? _DrawingMash = null;
- public DrawingObjectmash(DrawingMash DrawingMash)
+ public DrawingObjectMash(DrawingMash DrawingMash)
{
_DrawingMash = DrawingMash;
}
diff --git a/Excavator/Properties/Resources.Designer.cs b/Excavator/Properties/Resources.Designer.cs
index a121a44..231975d 100644
--- a/Excavator/Properties/Resources.Designer.cs
+++ b/Excavator/Properties/Resources.Designer.cs
@@ -63,9 +63,9 @@ namespace Excavator.Properties {
///
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
///
- internal static System.Drawing.Bitmap ArrowDown {
+ internal static System.Drawing.Bitmap стрелка_вверх {
get {
- object obj = ResourceManager.GetObject("ArrowDown", resourceCulture);
+ object obj = ResourceManager.GetObject("стрелка вверх", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
@@ -73,9 +73,9 @@ namespace Excavator.Properties {
///
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
///
- internal static System.Drawing.Bitmap ArrowLeft {
+ internal static System.Drawing.Bitmap стрелка_влево {
get {
- object obj = ResourceManager.GetObject("ArrowLeft", resourceCulture);
+ object obj = ResourceManager.GetObject("стрелка влево", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
@@ -83,9 +83,9 @@ namespace Excavator.Properties {
///
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
///
- internal static System.Drawing.Bitmap ArrowRight {
+ internal static System.Drawing.Bitmap стрелка_вниз {
get {
- object obj = ResourceManager.GetObject("ArrowRight", resourceCulture);
+ object obj = ResourceManager.GetObject("стрелка вниз", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
@@ -93,9 +93,9 @@ namespace Excavator.Properties {
///
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
///
- internal static System.Drawing.Bitmap ArrowUp {
+ internal static System.Drawing.Bitmap стрелка_вправо {
get {
- object obj = ResourceManager.GetObject("ArrowUp", resourceCulture);
+ object obj = ResourceManager.GetObject("стрелка вправо", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
diff --git a/Excavator/Properties/Resources.resx b/Excavator/Properties/Resources.resx
index aebcb60..39ee3cd 100644
--- a/Excavator/Properties/Resources.resx
+++ b/Excavator/Properties/Resources.resx
@@ -118,16 +118,16 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- ..\Resources\ArrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Resources\стрелка вверх.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- ..\Resources\ArrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Resources\стрелка влево.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- ..\Resources\ArrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Resources\стрелка вниз.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- ..\Resources\ArrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Resources\стрелка вправо.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
\ No newline at end of file