Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ec986c5a2c | |||
| 825ad3cdf5 | |||
| fce83f96d5 | |||
| 5630e074f1 | |||
| 0027078048 | |||
| 9123f0442e | |||
| 4e82bda63b | |||
| ef93a0293c | |||
| 16b6400b36 | |||
| c53647752a |
@@ -4,45 +4,51 @@ namespace ProjectBulldozer.Drawning
|
|||||||
public class DrawingBulldozer : DrawingTractor
|
public class DrawingBulldozer : DrawingTractor
|
||||||
{
|
{
|
||||||
public DrawingBulldozer(int speed, double weight, Color bodyColor, Color additionalColor,
|
public DrawingBulldozer(int speed, double weight, Color bodyColor, Color additionalColor,
|
||||||
bool horns, bool seifBatteries, int width, int height) : base(speed, weight, bodyColor, width, height, 120, 110)
|
bool otval, bool thirdWheel, int width, int height) : base(speed, weight, bodyColor, width, height, 120, 110)
|
||||||
{
|
{
|
||||||
if (EntityTractor != null)
|
if (EntityTractor != null)
|
||||||
{
|
{
|
||||||
EntityTractor = new EntityBulldozer(speed, width, bodyColor, additionalColor, horns, seifBatteries);
|
EntityTractor = new EntityBulldozer(speed, width, bodyColor, additionalColor, otval, thirdWheel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public object Otval { get; private set; }
|
|
||||||
public override void DrawTransport(Graphics g)
|
public override void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
if (EntityTractor is not EntityBulldozer Bulldozer)
|
if (EntityTractor is not EntityBulldozer Bulldozer)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
Brush blackBrush = new SolidBrush(Color.Black);
|
Brush blackBrush = new SolidBrush(Color.Black);
|
||||||
Brush windows = new SolidBrush(Color.LightBlue);
|
|
||||||
Brush bodyColor = new SolidBrush(Bulldozer.BodyColor);
|
|
||||||
Brush additionalColor = new SolidBrush(Bulldozer.AdditionalColor);
|
Brush additionalColor = new SolidBrush(Bulldozer.AdditionalColor);
|
||||||
Brush grayBrush = new SolidBrush(Color.Gray);
|
Brush grayBrush = new SolidBrush(Color.Gray);
|
||||||
|
|
||||||
|
if (Bulldozer.Otval)
|
||||||
|
{
|
||||||
//otval
|
//otval
|
||||||
Point[] Otval =
|
Point[] Otval =
|
||||||
{
|
{
|
||||||
new Point(_startPosX + 118, _startPosY + 50),
|
new Point(_startPosX + 118, _startPosY + 50),
|
||||||
new Point(_startPosX + 148, _startPosY + 111),
|
new Point(_startPosX + 148, _startPosY + 111),
|
||||||
new Point(_startPosX+ 118, _startPosY + 111),
|
new Point(_startPosX+ 118, _startPosY + 111),
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
g.FillPolygon(additionalColor, Otval);
|
g.FillPolygon(additionalColor, Otval);
|
||||||
g.DrawPolygon(pen, Otval);
|
g.DrawPolygon(pen, Otval);
|
||||||
|
}
|
||||||
//гусеницы
|
//гусеницы
|
||||||
Brush gg = new SolidBrush(Color.LightGray);
|
Brush gg = new SolidBrush(Color.LightGray);
|
||||||
g.FillEllipse(gg, _startPosX + 16, _startPosY + 65, 101, 63);
|
g.FillEllipse(gg, _startPosX + 16, _startPosY + 65, 101, 63);
|
||||||
g.DrawEllipse(pen, _startPosX + 16, _startPosY + 65, 101, 63);
|
g.DrawEllipse(pen, _startPosX + 16, _startPosY + 65, 101, 63);
|
||||||
|
|
||||||
|
if (Bulldozer.ThirdWheel)
|
||||||
|
{
|
||||||
|
|
||||||
g.FillEllipse(grayBrush, _startPosX + 65, _startPosY + 100, 13, 13);
|
g.FillEllipse(grayBrush, _startPosX + 65, _startPosY + 100, 13, 13);
|
||||||
g.DrawEllipse(pen, _startPosX + 65, _startPosY + 100, 13, 13);
|
g.DrawEllipse(pen, _startPosX + 65, _startPosY + 100, 13, 13);
|
||||||
|
}
|
||||||
Point[] Ttt =
|
Point[] Ttt =
|
||||||
{
|
{
|
||||||
|
|
||||||
new Point(_startPosX + 16, _startPosY + 79),
|
new Point(_startPosX + 16, _startPosY + 79),
|
||||||
new Point(_startPosX + 16, _startPosY + 120),
|
new Point(_startPosX + 16, _startPosY + 120),
|
||||||
new Point(_startPosX, _startPosY + 48),
|
new Point(_startPosX, _startPosY + 48),
|
||||||
@@ -50,10 +56,8 @@ namespace ProjectBulldozer.Drawning
|
|||||||
};
|
};
|
||||||
g.FillPolygon(blackBrush, Ttt);
|
g.FillPolygon(blackBrush, Ttt);
|
||||||
g.DrawPolygon(pen, Ttt);
|
g.DrawPolygon(pen, Ttt);
|
||||||
if (Bulldozer.SeifBatteries)
|
|
||||||
{
|
|
||||||
g.FillRectangle(blackBrush, _startPosX + 110, _startPosY + 60, 5, 10);
|
g.FillRectangle(blackBrush, _startPosX + 110, _startPosY + 60, 5, 10);
|
||||||
}
|
|
||||||
base.DrawTransport(g);
|
base.DrawTransport(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
using ProjectBulldozer.Entities;
|
using ProjectBulldozer.Entities;
|
||||||
using ProjectBulldozer.MovementStrategy;
|
using ProjectBulldozer.MovementStrategy;
|
||||||
|
|
||||||
namespace ProjectBulldozer.Drawning
|
namespace ProjectBulldozer.Drawning
|
||||||
{
|
{
|
||||||
public class DrawingTractor
|
public class DrawingTractor
|
||||||
{
|
{
|
||||||
public EntityTractor? EntityTractor { get; protected set; }
|
public EntityTractor? EntityTractor { get; protected set; }
|
||||||
protected int _pictureWidth;
|
public int _pictureWidth;
|
||||||
protected int _pictureHeight;
|
public int _pictureHeight;
|
||||||
protected int _startPosX;
|
protected int _startPosX;
|
||||||
protected int _startPosY;
|
protected int _startPosY;
|
||||||
protected readonly int _tractWidth = 120;
|
protected readonly int _tractWidth = 120;
|
||||||
@@ -40,7 +39,6 @@ namespace ProjectBulldozer.Drawning
|
|||||||
_tractHeight = tractHeight;
|
_tractHeight = tractHeight;
|
||||||
EntityTractor = new EntityTractor(speed, weight, bodyColor);
|
EntityTractor = new EntityTractor(speed, weight, bodyColor);
|
||||||
}
|
}
|
||||||
//Установка позиции
|
|
||||||
public void SetPosition(int x, int y)
|
public void SetPosition(int x, int y)
|
||||||
{
|
{
|
||||||
if (x < 0 || x + _tractWidth > _pictureWidth)
|
if (x < 0 || x + _tractWidth > _pictureWidth)
|
||||||
@@ -54,7 +52,6 @@ namespace ProjectBulldozer.Drawning
|
|||||||
_startPosX = x;
|
_startPosX = x;
|
||||||
_startPosY = y;
|
_startPosY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveTransport(DirectionType direction)
|
public void MoveTransport(DirectionType direction)
|
||||||
{
|
{
|
||||||
if (EntityTractor == null)
|
if (EntityTractor == null)
|
||||||
@@ -89,7 +86,6 @@ namespace ProjectBulldozer.Drawning
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void DrawTransport(Graphics g)
|
public virtual void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@@ -123,13 +119,9 @@ namespace ProjectBulldozer.Drawning
|
|||||||
}
|
}
|
||||||
return direction switch
|
return direction switch
|
||||||
{
|
{
|
||||||
//влево
|
|
||||||
DirectionType.Left => _startPosX - EntityTractor.Step > 0,
|
DirectionType.Left => _startPosX - EntityTractor.Step > 0,
|
||||||
//вверх
|
|
||||||
DirectionType.Up => _startPosY - EntityTractor.Step > 0,
|
DirectionType.Up => _startPosY - EntityTractor.Step > 0,
|
||||||
// вправо
|
|
||||||
DirectionType.Right => _startPosX + EntityTractor.Step < _pictureWidth,
|
DirectionType.Right => _startPosX + EntityTractor.Step < _pictureWidth,
|
||||||
//вниз
|
|
||||||
DirectionType.Down => _startPosY + EntityTractor.Step < _pictureHeight,
|
DirectionType.Down => _startPosY + EntityTractor.Step < _pictureHeight,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
48
ProjectBulldozer/Drawning/ExtentionDrawingTractor.cs
Normal file
48
ProjectBulldozer/Drawning/ExtentionDrawingTractor.cs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
using ProjectBulldozer.Drawning;
|
||||||
|
using ProjectBulldozer.Entities;
|
||||||
|
namespace ProjectBulldozer.Drawing
|
||||||
|
{
|
||||||
|
public static class ExtentionDrawingTractor
|
||||||
|
{
|
||||||
|
public static DrawingTractor? CreateDrawingTractor(this string info,
|
||||||
|
char separatorForObject, int width, int height)
|
||||||
|
{
|
||||||
|
string[] strs = info.Split(separatorForObject);
|
||||||
|
if (strs.Length == 3)
|
||||||
|
{
|
||||||
|
return new DrawingTractor(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]),
|
||||||
|
Color.FromName(strs[2]), width, height);
|
||||||
|
}
|
||||||
|
if (strs.Length == 7)
|
||||||
|
{
|
||||||
|
return new DrawingBulldozer(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 DrawingTractor drawingTractor,
|
||||||
|
char separatorForObject)
|
||||||
|
{
|
||||||
|
var tractor = drawingTractor.EntityTractor;
|
||||||
|
if (tractor == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
var str =
|
||||||
|
$"{tractor.Speed}{separatorForObject}{tractor.Weight}{separatorForObject}{tractor.BodyColor.Name}";
|
||||||
|
if (tractor is not EntityBulldozer bulldozer)
|
||||||
|
{
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
return
|
||||||
|
$"{str}{separatorForObject}{bulldozer.AdditionalColor.Name}{separatorForObject}" +
|
||||||
|
$"{bulldozer.ThirdWheel}{separatorForObject}{bulldozer.Otval}{separatorForObject}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -3,14 +3,19 @@
|
|||||||
public class EntityBulldozer : EntityTractor
|
public class EntityBulldozer : EntityTractor
|
||||||
{
|
{
|
||||||
public Color AdditionalColor { get; private set; }
|
public Color AdditionalColor { get; private set; }
|
||||||
public bool Horns { get; private set; }
|
public bool Otval { get; private set; }
|
||||||
public bool SeifBatteries { get; private set; }
|
public bool ThirdWheel { get; private set; }
|
||||||
public EntityBulldozer(int speed, double weight, Color bodyColor, Color additionalColor, bool horns,
|
public EntityBulldozer(int speed, double weight, Color bodyColor, Color additionalColor,
|
||||||
bool seifBatteries) : base(speed, weight, bodyColor)
|
bool otval, bool thirdWheel) : base(speed, weight, bodyColor)
|
||||||
{
|
{
|
||||||
AdditionalColor = additionalColor;
|
AdditionalColor = additionalColor;
|
||||||
Horns = horns;
|
Otval = otval;
|
||||||
SeifBatteries = seifBatteries;
|
ThirdWheel = thirdWheel;
|
||||||
|
|
||||||
|
}
|
||||||
|
public void setAdditionalColor(Color color)
|
||||||
|
{
|
||||||
|
AdditionalColor = color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,9 @@
|
|||||||
Weight = weight;
|
Weight = weight;
|
||||||
BodyColor = bodyColor;
|
BodyColor = bodyColor;
|
||||||
}
|
}
|
||||||
|
public void setBodyColor(Color color)
|
||||||
|
{
|
||||||
|
BodyColor = color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
ProjectBulldozer/Exceptions/BulldozerNotFoundException.cs
Normal file
17
ProjectBulldozer/Exceptions/BulldozerNotFoundException.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System.Runtime.Serialization;
|
||||||
|
namespace ProjectBulldozer.Exceptions
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
internal class BulldozerNotFoundException : ApplicationException
|
||||||
|
{
|
||||||
|
public BulldozerNotFoundException(int i) : base($"Не найден объект по позиции {i}") { }
|
||||||
|
|
||||||
|
public BulldozerNotFoundException() : base() { }
|
||||||
|
|
||||||
|
public BulldozerNotFoundException(string message) : base(message) { }
|
||||||
|
|
||||||
|
public BulldozerNotFoundException(string message, Exception exception) : base(message, exception) { }
|
||||||
|
|
||||||
|
protected BulldozerNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
17
ProjectBulldozer/Exceptions/StorageOverflowException.cs
Normal file
17
ProjectBulldozer/Exceptions/StorageOverflowException.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System.Runtime.Serialization;
|
||||||
|
namespace ProjectBulldozer.Exceptions
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
internal class StorageOverflowException : ApplicationException
|
||||||
|
{
|
||||||
|
public StorageOverflowException(int count) : base($"В наборе превышено допустимое количество: {count}") { }
|
||||||
|
|
||||||
|
public StorageOverflowException() : base() { }
|
||||||
|
|
||||||
|
public StorageOverflowException(string message) : base(message) { }
|
||||||
|
|
||||||
|
public StorageOverflowException(string message, Exception Exception) : base(message, Exception) { }
|
||||||
|
|
||||||
|
protected StorageOverflowException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
22
ProjectBulldozer/FormBulldozer.Designer.cs
generated
22
ProjectBulldozer/FormBulldozer.Designer.cs
generated
@@ -1,27 +1,8 @@
|
|||||||
|
namespace Bulldozer
|
||||||
namespace Bulldozer
|
|
||||||
{
|
{
|
||||||
partial class FormBulldozer
|
partial class FormBulldozer
|
||||||
{
|
{
|
||||||
private System.ComponentModel.IContainer components = null;
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormBulldozer));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormBulldozer));
|
||||||
@@ -185,7 +166,6 @@ namespace Bulldozer
|
|||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
private PictureBox pictureBoxBulldozer;
|
private PictureBox pictureBoxBulldozer;
|
||||||
private Button buttonCreateBulldozer;
|
private Button buttonCreateBulldozer;
|
||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
using ProjectBulldozer;
|
using ProjectBulldozer;
|
||||||
using ProjectBulldozer.Drawning;
|
using ProjectBulldozer.Drawning;
|
||||||
using ProjectBulldozer.MovementStrategy;
|
using ProjectBulldozer.MovementStrategy;
|
||||||
using System;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace Bulldozer
|
namespace Bulldozer
|
||||||
{
|
{
|
||||||
public partial class FormBulldozer : Form
|
public partial class FormBulldozer : Form
|
||||||
|
|||||||
149
ProjectBulldozer/FormBulldozerCollections.Designer.cs
generated
149
ProjectBulldozer/FormBulldozerCollections.Designer.cs
generated
@@ -1,58 +1,42 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ProjectBulldozer
|
namespace ProjectBulldozer
|
||||||
{
|
{
|
||||||
partial class FormTractorCollections
|
partial class FormTractorCollections
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
private System.ComponentModel.IContainer components = null;
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
components = new System.ComponentModel.Container();
|
|
||||||
maskedTextBoxNumber = new MaskedTextBox();
|
maskedTextBoxNumber = new MaskedTextBox();
|
||||||
ButtonRefreshCollection = new Button();
|
ButtonRefreshCollection = new Button();
|
||||||
ButtonRemoveTractor = new Button();
|
ButtonRemoveTractor = new Button();
|
||||||
ButtonAddTractor = new Button();
|
ButtonAddTractor = new Button();
|
||||||
pictureBoxCollections = new PictureBox();
|
pictureBoxCollections = new PictureBox();
|
||||||
textBoxStorageName = new TextBox();
|
textBoxStorageName = new TextBox();
|
||||||
bindingSource1 = new BindingSource(components);
|
|
||||||
bindingSource2 = new BindingSource(components);
|
|
||||||
groupBox1 = new GroupBox();
|
groupBox1 = new GroupBox();
|
||||||
listBoxStorage = new ListBox();
|
listBoxStorage = new ListBox();
|
||||||
ButtonAddObject = new Button();
|
ButtonAddObject = new Button();
|
||||||
ButtonRemoveObject = new Button();
|
ButtonRemoveObject = new Button();
|
||||||
Instruments = new GroupBox();
|
Instruments = new GroupBox();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollections).BeginInit();
|
openFileDialog = new OpenFileDialog();
|
||||||
((System.ComponentModel.ISupportInitialize)bindingSource1).BeginInit();
|
saveFileDialog = new SaveFileDialog();
|
||||||
((System.ComponentModel.ISupportInitialize)bindingSource2).BeginInit();
|
menuStrip1 = new MenuStrip();
|
||||||
|
файлToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
сохранитьToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
загрузитьToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
toolStripMenuItem1 = new ToolStripMenuItem();
|
||||||
|
((ISupportInitialize)pictureBoxCollections).BeginInit();
|
||||||
groupBox1.SuspendLayout();
|
groupBox1.SuspendLayout();
|
||||||
Instruments.SuspendLayout();
|
Instruments.SuspendLayout();
|
||||||
|
menuStrip1.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// maskedTextBoxNumber
|
// maskedTextBoxNumber
|
||||||
//
|
//
|
||||||
maskedTextBoxNumber.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
maskedTextBoxNumber.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
maskedTextBoxNumber.Location = new Point(33, 399);
|
maskedTextBoxNumber.Location = new Point(33, 356);
|
||||||
maskedTextBoxNumber.Margin = new Padding(3, 2, 3, 2);
|
maskedTextBoxNumber.Margin = new Padding(3, 2, 3, 2);
|
||||||
maskedTextBoxNumber.Mask = "0";
|
maskedTextBoxNumber.Mask = "00";
|
||||||
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||||
maskedTextBoxNumber.Size = new Size(131, 23);
|
maskedTextBoxNumber.Size = new Size(131, 23);
|
||||||
maskedTextBoxNumber.TabIndex = 4;
|
maskedTextBoxNumber.TabIndex = 4;
|
||||||
@@ -67,14 +51,15 @@ namespace ProjectBulldozer
|
|||||||
ButtonRefreshCollection.TabIndex = 2;
|
ButtonRefreshCollection.TabIndex = 2;
|
||||||
ButtonRefreshCollection.Text = "Обновить все";
|
ButtonRefreshCollection.Text = "Обновить все";
|
||||||
ButtonRefreshCollection.UseVisualStyleBackColor = true;
|
ButtonRefreshCollection.UseVisualStyleBackColor = true;
|
||||||
|
ButtonRefreshCollection.Click += ButtonRefreshCollection_Click;
|
||||||
//
|
//
|
||||||
// ButtonRemoveTractor
|
// ButtonRemoveTractor
|
||||||
//
|
//
|
||||||
ButtonRemoveTractor.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
ButtonRemoveTractor.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
ButtonRemoveTractor.Location = new Point(33, 444);
|
ButtonRemoveTractor.Location = new Point(33, 393);
|
||||||
ButtonRemoveTractor.Margin = new Padding(3, 2, 3, 2);
|
ButtonRemoveTractor.Margin = new Padding(3, 2, 3, 2);
|
||||||
ButtonRemoveTractor.Name = "ButtonRemoveTractor";
|
ButtonRemoveTractor.Name = "ButtonRemoveTractor";
|
||||||
ButtonRemoveTractor.Size = new Size(131, 33);
|
ButtonRemoveTractor.Size = new Size(131, 31);
|
||||||
ButtonRemoveTractor.TabIndex = 1;
|
ButtonRemoveTractor.TabIndex = 1;
|
||||||
ButtonRemoveTractor.Text = "Удалить объект";
|
ButtonRemoveTractor.Text = "Удалить объект";
|
||||||
ButtonRemoveTractor.UseVisualStyleBackColor = true;
|
ButtonRemoveTractor.UseVisualStyleBackColor = true;
|
||||||
@@ -83,7 +68,7 @@ namespace ProjectBulldozer
|
|||||||
// ButtonAddTractor
|
// ButtonAddTractor
|
||||||
//
|
//
|
||||||
ButtonAddTractor.Anchor = AnchorStyles.Top;
|
ButtonAddTractor.Anchor = AnchorStyles.Top;
|
||||||
ButtonAddTractor.Location = new Point(33, 346);
|
ButtonAddTractor.Location = new Point(33, 323);
|
||||||
ButtonAddTractor.Margin = new Padding(3, 2, 3, 2);
|
ButtonAddTractor.Margin = new Padding(3, 2, 3, 2);
|
||||||
ButtonAddTractor.Name = "ButtonAddTractor";
|
ButtonAddTractor.Name = "ButtonAddTractor";
|
||||||
ButtonAddTractor.Size = new Size(131, 29);
|
ButtonAddTractor.Size = new Size(131, 29);
|
||||||
@@ -95,12 +80,13 @@ namespace ProjectBulldozer
|
|||||||
// pictureBoxCollections
|
// pictureBoxCollections
|
||||||
//
|
//
|
||||||
pictureBoxCollections.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
pictureBoxCollections.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
pictureBoxCollections.Location = new Point(4, 4);
|
pictureBoxCollections.Location = new Point(0, 26);
|
||||||
pictureBoxCollections.Margin = new Padding(3, 2, 3, 2);
|
pictureBoxCollections.Margin = new Padding(3, 2, 3, 2);
|
||||||
pictureBoxCollections.Name = "pictureBoxCollections";
|
pictureBoxCollections.Name = "pictureBoxCollections";
|
||||||
pictureBoxCollections.Size = new Size(693, 541);
|
pictureBoxCollections.Size = new Size(697, 404);
|
||||||
pictureBoxCollections.TabIndex = 1;
|
pictureBoxCollections.TabIndex = 1;
|
||||||
pictureBoxCollections.TabStop = false;
|
pictureBoxCollections.TabStop = false;
|
||||||
|
pictureBoxCollections.Click += pictureBoxCollections_Click;
|
||||||
//
|
//
|
||||||
// textBoxStorageName
|
// textBoxStorageName
|
||||||
//
|
//
|
||||||
@@ -108,7 +94,6 @@ namespace ProjectBulldozer
|
|||||||
textBoxStorageName.Name = "textBoxStorageName";
|
textBoxStorageName.Name = "textBoxStorageName";
|
||||||
textBoxStorageName.Size = new Size(131, 23);
|
textBoxStorageName.Size = new Size(131, 23);
|
||||||
textBoxStorageName.TabIndex = 5;
|
textBoxStorageName.TabIndex = 5;
|
||||||
textBoxStorageName.TextChanged += textBoxStorageName_TextChanged;
|
|
||||||
//
|
//
|
||||||
// groupBox1
|
// groupBox1
|
||||||
//
|
//
|
||||||
@@ -171,27 +156,99 @@ namespace ProjectBulldozer
|
|||||||
Instruments.TabStop = false;
|
Instruments.TabStop = false;
|
||||||
Instruments.Text = "Инструменты";
|
Instruments.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
|
// openFileDialog
|
||||||
|
//
|
||||||
|
openFileDialog.FileName = "openFileDialog";
|
||||||
|
openFileDialog.Filter = "txt file | *.txt";
|
||||||
|
openFileDialog.FileOk += openFileDialog_FileOk;
|
||||||
|
//
|
||||||
|
// saveFileDialog
|
||||||
|
//
|
||||||
|
saveFileDialog.FileName = "saveFileDialog";
|
||||||
|
saveFileDialog.Filter = "txt file | *.txt";
|
||||||
|
saveFileDialog.FileOk += saveFileDialog_FileOk;
|
||||||
|
//
|
||||||
|
// menuStrip1
|
||||||
|
//
|
||||||
|
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||||
|
menuStrip1.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
|
||||||
|
menuStrip1.Location = new Point(0, 0);
|
||||||
|
menuStrip1.Name = "menuStrip1";
|
||||||
|
menuStrip1.Padding = new Padding(5, 2, 0, 2);
|
||||||
|
menuStrip1.RenderMode = ToolStripRenderMode.System;
|
||||||
|
menuStrip1.Size = new Size(904, 24);
|
||||||
|
menuStrip1.TabIndex = 6;
|
||||||
|
menuStrip1.Text = "menuStrip1";
|
||||||
|
//
|
||||||
|
// файлToolStripMenuItem
|
||||||
|
//
|
||||||
|
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { сохранитьToolStripMenuItem, загрузитьToolStripMenuItem });
|
||||||
|
файлToolStripMenuItem.Name = "файлToolStripMenuItem";
|
||||||
|
файлToolStripMenuItem.Size = new Size(50, 20);
|
||||||
|
файлToolStripMenuItem.Text = "Файл";
|
||||||
|
файлToolStripMenuItem.Click += файлToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// сохранитьToolStripMenuItem
|
||||||
|
//
|
||||||
|
сохранитьToolStripMenuItem.Name = "сохранитьToolStripMenuItem";
|
||||||
|
сохранитьToolStripMenuItem.Size = new Size(135, 22);
|
||||||
|
сохранитьToolStripMenuItem.Text = "Сохранить";
|
||||||
|
сохранитьToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// загрузитьToolStripMenuItem
|
||||||
|
//
|
||||||
|
загрузитьToolStripMenuItem.Name = "загрузитьToolStripMenuItem";
|
||||||
|
загрузитьToolStripMenuItem.Size = new Size(135, 22);
|
||||||
|
загрузитьToolStripMenuItem.Text = "Загрузить";
|
||||||
|
загрузитьToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// toolStripMenuItem1
|
||||||
|
//
|
||||||
|
toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||||
|
toolStripMenuItem1.Size = new Size(32, 19);
|
||||||
|
//
|
||||||
// FormTractorCollections
|
// FormTractorCollections
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(904, 543);
|
ClientSize = new Size(904, 439);
|
||||||
Controls.Add(Instruments);
|
Controls.Add(Instruments);
|
||||||
Controls.Add(pictureBoxCollections);
|
Controls.Add(pictureBoxCollections);
|
||||||
|
Controls.Add(menuStrip1);
|
||||||
|
MainMenuStrip = menuStrip1;
|
||||||
Margin = new Padding(3, 2, 3, 2);
|
Margin = new Padding(3, 2, 3, 2);
|
||||||
Name = "FormTractorCollections";
|
Name = "FormTractorCollections";
|
||||||
Text = "Набор локомотивов";
|
Text = "Набор объектов";
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollections).EndInit();
|
((ISupportInitialize)pictureBoxCollections).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)bindingSource1).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)bindingSource2).EndInit();
|
|
||||||
groupBox1.ResumeLayout(false);
|
groupBox1.ResumeLayout(false);
|
||||||
groupBox1.PerformLayout();
|
groupBox1.PerformLayout();
|
||||||
Instruments.ResumeLayout(false);
|
Instruments.ResumeLayout(false);
|
||||||
Instruments.PerformLayout();
|
Instruments.PerformLayout();
|
||||||
|
menuStrip1.ResumeLayout(false);
|
||||||
|
menuStrip1.PerformLayout();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
private void файлToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveFileDialog_FileOk(object sender, CancelEventArgs e)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openFileDialog_FileOk(object sender, CancelEventArgs e)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pictureBoxCollections_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
private Button ButtonRefreshCollection;
|
private Button ButtonRefreshCollection;
|
||||||
private Button ButtonRemoveTractor;
|
private Button ButtonRemoveTractor;
|
||||||
private Button ButtonAddTractor;
|
private Button ButtonAddTractor;
|
||||||
@@ -199,12 +256,16 @@ namespace ProjectBulldozer
|
|||||||
private MaskedTextBox maskedTextBoxNumber;
|
private MaskedTextBox maskedTextBoxNumber;
|
||||||
private GroupBox groupBox1;
|
private GroupBox groupBox1;
|
||||||
private TextBox textBoxStorageName;
|
private TextBox textBoxStorageName;
|
||||||
private BindingSource bindingSource1;
|
|
||||||
private BindingSource bindingSource2;
|
|
||||||
private ListBox listBoxStorage;
|
private ListBox listBoxStorage;
|
||||||
|
private OpenFileDialog openFileDialog;
|
||||||
|
private SaveFileDialog saveFileDialog;
|
||||||
private Button ButtonAddObject;
|
private Button ButtonAddObject;
|
||||||
private Button ButtonRemoveObject;
|
private Button ButtonRemoveObject;
|
||||||
private GroupBox Instruments;
|
private GroupBox Instruments;
|
||||||
private EventHandler textBoxStorageName_TextChanged;
|
private MenuStrip menuStrip1;
|
||||||
|
private ToolStripMenuItem файлToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem сохранитьToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem загрузитьToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem toolStripMenuItem1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,31 @@
|
|||||||
using Bulldozer;
|
using Bulldozer;
|
||||||
using ProjectBulldozer.Generics;
|
using ProjectBulldozer.Generics;
|
||||||
|
using ProjectBulldozer.Drawning;
|
||||||
|
using ProjectBulldozer.Exceptions;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Xml.Linq;
|
||||||
namespace ProjectBulldozer
|
namespace ProjectBulldozer
|
||||||
{
|
{
|
||||||
public partial class FormTractorCollections : Form
|
public partial class FormTractorCollections : Form
|
||||||
{
|
{
|
||||||
private readonly TractorGenericStorage _storage;
|
private readonly TractorGenericStorage _storage;
|
||||||
//private readonly TractorGenericCollection<DrawingTractor, DrawingObjectTractor> _Tractors;
|
private readonly TractorGenericCollection<DrawingTractor, DrawingObjectTractor> _tractors;
|
||||||
|
readonly int countPlace = 10;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
public FormTractorCollections()
|
public FormTractorCollections()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_storage = new TractorGenericStorage(pictureBoxCollections.Width, pictureBoxCollections.Height);
|
_storage = new TractorGenericStorage(pictureBoxCollections.Width, pictureBoxCollections.Height);
|
||||||
}
|
}
|
||||||
|
public FormTractorCollections(ILogger<FormTractorCollections> logger)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_storage = new TractorGenericStorage(pictureBoxCollections.Width, pictureBoxCollections.Height);
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
private void ReloadObjects()
|
private void ReloadObjects()
|
||||||
{
|
{
|
||||||
int index = listBoxStorage.SelectedIndex;
|
int index = listBoxStorage.SelectedIndex;
|
||||||
@@ -34,10 +49,12 @@ namespace ProjectBulldozer
|
|||||||
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не всё заполнено", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Не всё заполнено", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
_logger.LogWarning($"!!Ошибка!! Не все данные заполнены");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_storage.AddSet(textBoxStorageName.Text);
|
_storage.AddSet(textBoxStorageName.Text);
|
||||||
ReloadObjects();
|
ReloadObjects();
|
||||||
|
_logger.LogInformation($"Добавлен набор: {textBoxStorageName.Text}");
|
||||||
}
|
}
|
||||||
private void listBoxStorage_SelectedIndexChanged(object sender, EventArgs e)
|
private void listBoxStorage_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@@ -47,39 +64,66 @@ namespace ProjectBulldozer
|
|||||||
{
|
{
|
||||||
if (listBoxStorage.SelectedIndex == -1)
|
if (listBoxStorage.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
|
_logger.LogWarning($"Удаление не выбранного набора");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
string name = listBoxStorage.SelectedItem.ToString() ?? string.Empty;
|
||||||
if (MessageBox.Show($"Удалить объект {listBoxStorage.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo,
|
if (MessageBox.Show($"Удалить объект {listBoxStorage.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo,
|
||||||
MessageBoxIcon.Question) == DialogResult.Yes)
|
MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
_storage.DelSet(listBoxStorage.SelectedItem.ToString() ?? string.Empty);
|
_storage.DelSet(listBoxStorage.SelectedItem.ToString() ?? string.Empty);
|
||||||
ReloadObjects();
|
ReloadObjects();
|
||||||
|
_logger.LogInformation($"Удален набор: {name}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonAddTractor_Click(object sender, EventArgs e)
|
private void ButtonAddTractor_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (listBoxStorage.SelectedIndex == -1)
|
||||||
if (listBoxStorage.SelectedIndex == -1) return;
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
|
var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FormBulldozer form = new();
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
var formBulldozerConfig = new FormBulldozerConfig();
|
||||||
|
formBulldozerConfig.AddEvent(AddTractor);
|
||||||
|
formBulldozerConfig.Show();
|
||||||
|
}
|
||||||
|
private void AddTractor(DrawingTractor tractor)
|
||||||
{
|
{
|
||||||
//проверяем, удалось ли нам загрузить объект
|
tractor._pictureWidth = pictureBoxCollections.Width;
|
||||||
if (obj + form.SelectedTractor > -1)
|
tractor._pictureHeight = pictureBoxCollections.Height;
|
||||||
|
|
||||||
|
if (listBoxStorage.SelectedIndex == -1) return;
|
||||||
|
var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
string name = listBoxStorage.SelectedItem.ToString() ?? string.Empty;
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (obj + tractor)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBoxCollections.Image = obj.ShowTractors();
|
pictureBoxCollections.Image = obj.ShowTractors();
|
||||||
|
_logger.LogInformation($"В набор {name} добавлен объект");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
_logger.LogWarning("Не удалось добавить объект");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (StorageOverflowException ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
_logger.LogWarning($"{ex.Message}. Не удалось добавить объект");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void ButtonRemoveTractor_Click(object sender, EventArgs e)
|
private void ButtonRemoveTractor_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@@ -89,22 +133,34 @@ namespace ProjectBulldozer
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (maskedTextBoxNumber.Text == "") { return; }
|
||||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string name = listBoxStorage.SelectedItem.ToString() ?? string.Empty;
|
||||||
if (obj - pos != null)
|
if (obj - pos != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
pictureBoxCollections.Image = obj.ShowTractors();
|
pictureBoxCollections.Image = obj.ShowTractors();
|
||||||
|
_logger.LogInformation($"Из набора {name} удален объект");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
MessageBox.Show("Не удалось удалить объект");
|
||||||
|
_logger.LogWarning("Не удалось удалить объект");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (BulldozerNotFoundException ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
_logger.LogWarning($"{ex.Message}. Не удалось удалить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (listBoxStorage.SelectedIndex == -1) return;
|
if (listBoxStorage.SelectedIndex == -1) return;
|
||||||
@@ -115,5 +171,42 @@ namespace ProjectBulldozer
|
|||||||
}
|
}
|
||||||
pictureBoxCollections.Image = obj.ShowTractors();
|
pictureBoxCollections.Image = obj.ShowTractors();
|
||||||
}
|
}
|
||||||
|
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_storage.SaveData(saveFileDialog.FileName);
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
_logger.LogInformation("Сохранение");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
_logger.LogWarning("Ошибка сохранения");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_storage.LoadData(openFileDialog.FileName);
|
||||||
|
ReloadObjects();
|
||||||
|
MessageBox.Show("Загрузка произошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
_logger.LogInformation("Загрузка");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
_logger.LogWarning("Ошибка загрузки");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,7 @@
|
|||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
<data name="
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
|
||||||
1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -119,4 +117,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>153, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>286, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
||||||
412
ProjectBulldozer/FormBulldozerConfig.Designer.cs
generated
Normal file
412
ProjectBulldozer/FormBulldozerConfig.Designer.cs
generated
Normal file
@@ -0,0 +1,412 @@
|
|||||||
|
namespace Bulldozer
|
||||||
|
{
|
||||||
|
partial class FormBulldozerConfig
|
||||||
|
{
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
labelModifiedObject = new Label();
|
||||||
|
labelSimpleObject = new Label();
|
||||||
|
GroupColor = new GroupBox();
|
||||||
|
panelPurple = new Panel();
|
||||||
|
panelYellow = new Panel();
|
||||||
|
panelBlack = new Panel();
|
||||||
|
panelBlue = new Panel();
|
||||||
|
panelGray = new Panel();
|
||||||
|
panelGreen = new Panel();
|
||||||
|
panelWhite = new Panel();
|
||||||
|
panelRed = new Panel();
|
||||||
|
checkBoxKovsh = new CheckBox();
|
||||||
|
checkBoxThirdWheel = new CheckBox();
|
||||||
|
label2 = new Label();
|
||||||
|
label1 = new Label();
|
||||||
|
numericUpDownWeight = new NumericUpDown();
|
||||||
|
numericUpDownSpeed = new NumericUpDown();
|
||||||
|
ButtonOk = new Button();
|
||||||
|
ButtonCancel = new Button();
|
||||||
|
label_body_color = new Label();
|
||||||
|
label_additional_color = new Label();
|
||||||
|
pictureBoxObject = new PictureBox();
|
||||||
|
label4 = new Label();
|
||||||
|
PanelObject = new Panel();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
GroupColor.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||||
|
PanelObject.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Controls.Add(labelModifiedObject);
|
||||||
|
groupBox1.Controls.Add(labelSimpleObject);
|
||||||
|
groupBox1.Controls.Add(GroupColor);
|
||||||
|
groupBox1.Controls.Add(checkBoxKovsh);
|
||||||
|
groupBox1.Controls.Add(checkBoxThirdWheel);
|
||||||
|
groupBox1.Controls.Add(label2);
|
||||||
|
groupBox1.Controls.Add(label1);
|
||||||
|
groupBox1.Controls.Add(numericUpDownWeight);
|
||||||
|
groupBox1.Controls.Add(numericUpDownSpeed);
|
||||||
|
groupBox1.ForeColor = SystemColors.ControlLightLight;
|
||||||
|
groupBox1.Location = new Point(10, 9);
|
||||||
|
groupBox1.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Padding = new Padding(3, 2, 3, 2);
|
||||||
|
groupBox1.Size = new Size(542, 405);
|
||||||
|
groupBox1.TabIndex = 0;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "Параметры";
|
||||||
|
groupBox1.Enter += groupBox1_Enter;
|
||||||
|
//
|
||||||
|
// labelModifiedObject
|
||||||
|
//
|
||||||
|
labelModifiedObject.AllowDrop = true;
|
||||||
|
labelModifiedObject.BackColor = SystemColors.Info;
|
||||||
|
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelModifiedObject.ForeColor = SystemColors.ControlText;
|
||||||
|
labelModifiedObject.Location = new Point(377, 170);
|
||||||
|
labelModifiedObject.Name = "labelModifiedObject";
|
||||||
|
labelModifiedObject.Size = new Size(132, 53);
|
||||||
|
labelModifiedObject.TabIndex = 9;
|
||||||
|
labelModifiedObject.Text = "Продвинутый";
|
||||||
|
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||||
|
//
|
||||||
|
// labelSimpleObject
|
||||||
|
//
|
||||||
|
labelSimpleObject.AllowDrop = true;
|
||||||
|
labelSimpleObject.BackColor = SystemColors.Info;
|
||||||
|
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelSimpleObject.ForeColor = SystemColors.ControlText;
|
||||||
|
labelSimpleObject.Location = new Point(225, 170);
|
||||||
|
labelSimpleObject.Name = "labelSimpleObject";
|
||||||
|
labelSimpleObject.Size = new Size(132, 53);
|
||||||
|
labelSimpleObject.TabIndex = 7;
|
||||||
|
labelSimpleObject.Text = "Простой";
|
||||||
|
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||||
|
//
|
||||||
|
// GroupColor
|
||||||
|
//
|
||||||
|
GroupColor.Controls.Add(panelPurple);
|
||||||
|
GroupColor.Controls.Add(panelYellow);
|
||||||
|
GroupColor.Controls.Add(panelBlack);
|
||||||
|
GroupColor.Controls.Add(panelBlue);
|
||||||
|
GroupColor.Controls.Add(panelGray);
|
||||||
|
GroupColor.Controls.Add(panelGreen);
|
||||||
|
GroupColor.Controls.Add(panelWhite);
|
||||||
|
GroupColor.Controls.Add(panelRed);
|
||||||
|
GroupColor.ForeColor = SystemColors.ControlLightLight;
|
||||||
|
GroupColor.Location = new Point(225, 20);
|
||||||
|
GroupColor.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
GroupColor.Name = "GroupColor";
|
||||||
|
GroupColor.Padding = new Padding(3, 2, 3, 2);
|
||||||
|
GroupColor.Size = new Size(302, 131);
|
||||||
|
GroupColor.TabIndex = 6;
|
||||||
|
GroupColor.TabStop = false;
|
||||||
|
GroupColor.Text = "Цвета";
|
||||||
|
GroupColor.Enter += GroupColor_Enter;
|
||||||
|
//
|
||||||
|
// panelPurple
|
||||||
|
//
|
||||||
|
panelPurple.BackColor = Color.Purple;
|
||||||
|
panelPurple.Location = new Point(226, 76);
|
||||||
|
panelPurple.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
panelPurple.Name = "panelPurple";
|
||||||
|
panelPurple.Size = new Size(68, 41);
|
||||||
|
panelPurple.TabIndex = 3;
|
||||||
|
panelPurple.Paint += panelPurple_Paint;
|
||||||
|
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelYellow
|
||||||
|
//
|
||||||
|
panelYellow.BackColor = Color.Yellow;
|
||||||
|
panelYellow.Location = new Point(226, 24);
|
||||||
|
panelYellow.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
panelYellow.Name = "panelYellow";
|
||||||
|
panelYellow.Size = new Size(68, 41);
|
||||||
|
panelYellow.TabIndex = 1;
|
||||||
|
panelYellow.Paint += panelYellow_Paint;
|
||||||
|
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelBlack
|
||||||
|
//
|
||||||
|
panelBlack.BackColor = Color.Black;
|
||||||
|
panelBlack.Location = new Point(152, 76);
|
||||||
|
panelBlack.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
panelBlack.Name = "panelBlack";
|
||||||
|
panelBlack.Size = new Size(68, 41);
|
||||||
|
panelBlack.TabIndex = 4;
|
||||||
|
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelBlue
|
||||||
|
//
|
||||||
|
panelBlue.BackColor = Color.Blue;
|
||||||
|
panelBlue.Location = new Point(152, 24);
|
||||||
|
panelBlue.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
panelBlue.Name = "panelBlue";
|
||||||
|
panelBlue.Size = new Size(68, 41);
|
||||||
|
panelBlue.TabIndex = 1;
|
||||||
|
panelBlue.Paint += panelBlue_Paint;
|
||||||
|
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelGray
|
||||||
|
//
|
||||||
|
panelGray.BackColor = Color.Gray;
|
||||||
|
panelGray.Location = new Point(79, 76);
|
||||||
|
panelGray.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
panelGray.Name = "panelGray";
|
||||||
|
panelGray.Size = new Size(68, 41);
|
||||||
|
panelGray.TabIndex = 5;
|
||||||
|
panelGray.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelGreen
|
||||||
|
//
|
||||||
|
panelGreen.BackColor = Color.Lime;
|
||||||
|
panelGreen.Location = new Point(79, 24);
|
||||||
|
panelGreen.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
panelGreen.Name = "panelGreen";
|
||||||
|
panelGreen.Size = new Size(68, 41);
|
||||||
|
panelGreen.TabIndex = 1;
|
||||||
|
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelWhite
|
||||||
|
//
|
||||||
|
panelWhite.BackColor = Color.White;
|
||||||
|
panelWhite.Location = new Point(5, 76);
|
||||||
|
panelWhite.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
panelWhite.Name = "panelWhite";
|
||||||
|
panelWhite.Size = new Size(68, 41);
|
||||||
|
panelWhite.TabIndex = 2;
|
||||||
|
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelRed
|
||||||
|
//
|
||||||
|
panelRed.BackColor = Color.Red;
|
||||||
|
panelRed.Location = new Point(5, 24);
|
||||||
|
panelRed.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
panelRed.Name = "panelRed";
|
||||||
|
panelRed.Size = new Size(68, 41);
|
||||||
|
panelRed.TabIndex = 0;
|
||||||
|
panelRed.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// checkBoxKovsh
|
||||||
|
//
|
||||||
|
checkBoxKovsh.AutoSize = true;
|
||||||
|
checkBoxKovsh.ForeColor = SystemColors.ControlLightLight;
|
||||||
|
checkBoxKovsh.Location = new Point(18, 132);
|
||||||
|
checkBoxKovsh.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
checkBoxKovsh.Name = "checkBoxKovsh";
|
||||||
|
checkBoxKovsh.Size = new Size(182, 19);
|
||||||
|
checkBoxKovsh.TabIndex = 5;
|
||||||
|
checkBoxKovsh.Text = "Третье колесо в гусеницах";
|
||||||
|
checkBoxKovsh.UseVisualStyleBackColor = true;
|
||||||
|
checkBoxKovsh.CheckedChanged += GroupColor_Enter;
|
||||||
|
//
|
||||||
|
// checkBoxThirdWheel
|
||||||
|
//
|
||||||
|
checkBoxThirdWheel.AutoSize = true;
|
||||||
|
checkBoxThirdWheel.ForeColor = SystemColors.ControlLightLight;
|
||||||
|
checkBoxThirdWheel.Location = new Point(18, 106);
|
||||||
|
checkBoxThirdWheel.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
checkBoxThirdWheel.Name = "checkBoxThirdWheel";
|
||||||
|
checkBoxThirdWheel.Size = new Size(60, 19);
|
||||||
|
checkBoxThirdWheel.TabIndex = 4;
|
||||||
|
checkBoxThirdWheel.Text = "Отвал";
|
||||||
|
checkBoxThirdWheel.UseVisualStyleBackColor = true;
|
||||||
|
checkBoxThirdWheel.CheckedChanged += checkBoxOtval_CheckedChanged;
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.ForeColor = SystemColors.ControlLightLight;
|
||||||
|
label2.Location = new Point(5, 70);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(31, 15);
|
||||||
|
label2.TabIndex = 3;
|
||||||
|
label2.Text = "Вес:";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.ForeColor = SystemColors.ControlLightLight;
|
||||||
|
label1.Location = new Point(5, 38);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(63, 15);
|
||||||
|
label1.TabIndex = 2;
|
||||||
|
label1.Text = "Скорость:";
|
||||||
|
//
|
||||||
|
// numericUpDownWeight
|
||||||
|
//
|
||||||
|
numericUpDownWeight.BackColor = SystemColors.Info;
|
||||||
|
numericUpDownWeight.Location = new Point(88, 68);
|
||||||
|
numericUpDownWeight.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||||
|
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
numericUpDownWeight.Name = "numericUpDownWeight";
|
||||||
|
numericUpDownWeight.Size = new Size(131, 23);
|
||||||
|
numericUpDownWeight.TabIndex = 1;
|
||||||
|
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// numericUpDownSpeed
|
||||||
|
//
|
||||||
|
numericUpDownSpeed.BackColor = SystemColors.Info;
|
||||||
|
numericUpDownSpeed.Location = new Point(88, 36);
|
||||||
|
numericUpDownSpeed.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||||
|
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||||
|
numericUpDownSpeed.Size = new Size(131, 23);
|
||||||
|
numericUpDownSpeed.TabIndex = 0;
|
||||||
|
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// ButtonOk
|
||||||
|
//
|
||||||
|
ButtonOk.BackColor = SystemColors.Info;
|
||||||
|
ButtonOk.ForeColor = SystemColors.ControlText;
|
||||||
|
ButtonOk.Location = new Point(27, 345);
|
||||||
|
ButtonOk.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
ButtonOk.Name = "ButtonOk";
|
||||||
|
ButtonOk.Size = new Size(93, 44);
|
||||||
|
ButtonOk.TabIndex = 12;
|
||||||
|
ButtonOk.Text = "Добавить";
|
||||||
|
ButtonOk.UseVisualStyleBackColor = false;
|
||||||
|
ButtonOk.Click += ButtonOk_Click;
|
||||||
|
//
|
||||||
|
// ButtonCancel
|
||||||
|
//
|
||||||
|
ButtonCancel.BackColor = SystemColors.Info;
|
||||||
|
ButtonCancel.ForeColor = SystemColors.ControlText;
|
||||||
|
ButtonCancel.Location = new Point(203, 345);
|
||||||
|
ButtonCancel.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
ButtonCancel.Name = "ButtonCancel";
|
||||||
|
ButtonCancel.Size = new Size(93, 44);
|
||||||
|
ButtonCancel.TabIndex = 13;
|
||||||
|
ButtonCancel.Text = "Отмена";
|
||||||
|
ButtonCancel.UseVisualStyleBackColor = false;
|
||||||
|
ButtonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// label_body_color
|
||||||
|
//
|
||||||
|
label_body_color.AllowDrop = true;
|
||||||
|
label_body_color.BackColor = SystemColors.Info;
|
||||||
|
label_body_color.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
label_body_color.ForeColor = SystemColors.ControlText;
|
||||||
|
label_body_color.Location = new Point(27, 7);
|
||||||
|
label_body_color.Name = "label_body_color";
|
||||||
|
label_body_color.Size = new Size(93, 42);
|
||||||
|
label_body_color.TabIndex = 10;
|
||||||
|
label_body_color.Text = "Осн. цвет";
|
||||||
|
label_body_color.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
label_body_color.DragDrop += PanelColor_DragDrop;
|
||||||
|
label_body_color.DragEnter += PanelColor_DragEnter;
|
||||||
|
//
|
||||||
|
// label_additional_color
|
||||||
|
//
|
||||||
|
label_additional_color.AllowDrop = true;
|
||||||
|
label_additional_color.BackColor = SystemColors.Info;
|
||||||
|
label_additional_color.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
label_additional_color.ForeColor = SystemColors.ControlText;
|
||||||
|
label_additional_color.Location = new Point(207, 7);
|
||||||
|
label_additional_color.Name = "label_additional_color";
|
||||||
|
label_additional_color.Size = new Size(89, 42);
|
||||||
|
label_additional_color.TabIndex = 10;
|
||||||
|
label_additional_color.Text = "Доп. цвет";
|
||||||
|
label_additional_color.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
label_additional_color.DragDrop += PanelColor_DragDrop;
|
||||||
|
label_additional_color.DragEnter += PanelColor_DragEnter;
|
||||||
|
//
|
||||||
|
// pictureBoxObject
|
||||||
|
//
|
||||||
|
pictureBoxObject.Location = new Point(27, 53);
|
||||||
|
pictureBoxObject.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
pictureBoxObject.Name = "pictureBoxObject";
|
||||||
|
pictureBoxObject.Size = new Size(306, 288);
|
||||||
|
pictureBoxObject.TabIndex = 1;
|
||||||
|
pictureBoxObject.TabStop = false;
|
||||||
|
pictureBoxObject.Click += pictureBoxObject_Click;
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(449, 278);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(0, 15);
|
||||||
|
label4.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// PanelObject
|
||||||
|
//
|
||||||
|
PanelObject.AllowDrop = true;
|
||||||
|
PanelObject.Controls.Add(ButtonCancel);
|
||||||
|
PanelObject.Controls.Add(ButtonOk);
|
||||||
|
PanelObject.Controls.Add(pictureBoxObject);
|
||||||
|
PanelObject.Controls.Add(label_body_color);
|
||||||
|
PanelObject.Controls.Add(label_additional_color);
|
||||||
|
PanelObject.Location = new Point(558, 19);
|
||||||
|
PanelObject.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
PanelObject.Name = "PanelObject";
|
||||||
|
PanelObject.Size = new Size(347, 395);
|
||||||
|
PanelObject.TabIndex = 15;
|
||||||
|
PanelObject.DragDrop += PanelObject_DragDrop;
|
||||||
|
PanelObject.DragEnter += PanelObject_DragEnter;
|
||||||
|
//
|
||||||
|
// FormBulldozerConfig
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
BackColor = SystemColors.WindowFrame;
|
||||||
|
ClientSize = new Size(917, 419);
|
||||||
|
Controls.Add(PanelObject);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Controls.Add(groupBox1);
|
||||||
|
Margin = new Padding(3, 2, 3, 2);
|
||||||
|
Name = "FormBulldozerConfig";
|
||||||
|
Text = "FormBulldozerlConfig";
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
groupBox1.PerformLayout();
|
||||||
|
GroupColor.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||||
|
PanelObject.ResumeLayout(false);
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private Label label2;
|
||||||
|
private Label label1;
|
||||||
|
private NumericUpDown numericUpDownWeight;
|
||||||
|
private NumericUpDown numericUpDownSpeed;
|
||||||
|
private GroupBox GroupColor;
|
||||||
|
private Panel panelYellow;
|
||||||
|
private Panel panelBlue;
|
||||||
|
private Panel panelGreen;
|
||||||
|
private Panel panelRed;
|
||||||
|
private CheckBox checkBoxKovsh;
|
||||||
|
private CheckBox checkBoxThirdWheel;
|
||||||
|
private Label labelModifiedObject;
|
||||||
|
private Label labelSimpleObject;
|
||||||
|
private Panel panelPurple;
|
||||||
|
private Panel panelBlack;
|
||||||
|
private Panel panelGray;
|
||||||
|
private Panel panelWhite;
|
||||||
|
private PictureBox pictureBoxObject;
|
||||||
|
private Label label4;
|
||||||
|
private Button ButtonOk;
|
||||||
|
private Button ButtonCancel;
|
||||||
|
private Panel PanelObject;
|
||||||
|
private Label label_body_color;
|
||||||
|
private Label label_additional_color;
|
||||||
|
private EventHandler groupBox1_Enter;
|
||||||
|
private PaintEventHandler panelPurple_Paint;
|
||||||
|
private PaintEventHandler panelYellow_Paint;
|
||||||
|
private PaintEventHandler panelBlue_Paint;
|
||||||
|
private EventHandler checkBoxOtval_CheckedChanged;
|
||||||
|
private EventHandler pictureBoxObject_Click;
|
||||||
|
|
||||||
|
public EventHandler GroupColor_Enter { get; private set; }
|
||||||
|
public EventHandler ButtonCancel_Click { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
119
ProjectBulldozer/FormBulldozerConfig.cs
Normal file
119
ProjectBulldozer/FormBulldozerConfig.cs
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
using ProjectBulldozer.Drawning;
|
||||||
|
using ProjectBulldozer.Entities;
|
||||||
|
namespace Bulldozer
|
||||||
|
{
|
||||||
|
public partial class FormBulldozerConfig : Form
|
||||||
|
{
|
||||||
|
DrawingTractor? _tractor = null;
|
||||||
|
public event Action<DrawingTractor>? EventAddTractor;
|
||||||
|
public FormBulldozerConfig()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelGray.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelRed.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||||
|
ButtonCancel.Click += (s, e) => Close();
|
||||||
|
}
|
||||||
|
private void DrawTractor()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_tractor?.SetPosition(pictureBoxObject.Width / 10, pictureBoxObject.Height / 10);
|
||||||
|
_tractor?.DrawTransport(gr);
|
||||||
|
pictureBoxObject.Image = bmp;
|
||||||
|
}
|
||||||
|
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
|
||||||
|
DragDropEffects.Copy | DragDropEffects.Move);
|
||||||
|
}
|
||||||
|
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||||
|
{
|
||||||
|
case "labelSimpleObject":
|
||||||
|
_tractor = new DrawingTractor((int)numericUpDownSpeed.Value,
|
||||||
|
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
||||||
|
pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
case "labelModifiedObject":
|
||||||
|
_tractor = new DrawingBulldozer((int)numericUpDownSpeed.Value,
|
||||||
|
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxThirdWheel.Checked,
|
||||||
|
checkBoxKovsh.Checked, pictureBoxObject.Width,
|
||||||
|
pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawTractor();
|
||||||
|
}
|
||||||
|
private void PanelColor_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void PanelColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_tractor == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (((Label)sender).Name)
|
||||||
|
{
|
||||||
|
case "label_body_color":
|
||||||
|
_tractor?.EntityTractor?.setBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
break;
|
||||||
|
case "label_additional_color":
|
||||||
|
if (!(_tractor is DrawingBulldozer))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
(_tractor.EntityTractor as EntityBulldozer)?
|
||||||
|
.setAdditionalColor(color: (Color)e.Data.GetData(typeof(Color)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawTractor();
|
||||||
|
}
|
||||||
|
public void AddEvent(Action<DrawingTractor> ev)
|
||||||
|
{
|
||||||
|
if (EventAddTractor == null)
|
||||||
|
{
|
||||||
|
EventAddTractor = ev;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EventAddTractor += ev;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private void ButtonOk_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
EventAddTractor?.Invoke(obj: _tractor);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
ProjectBulldozer/FormBulldozerConfig.resx
Normal file
120
ProjectBulldozer/FormBulldozerConfig.resx
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
@@ -5,34 +5,25 @@ namespace ProjectBulldozer.Generics
|
|||||||
{
|
{
|
||||||
internal class TractorGenericCollection<T, U> where T : DrawingTractor where U : IMoveableObject
|
internal class TractorGenericCollection<T, U> where T : DrawingTractor where U : IMoveableObject
|
||||||
{
|
{
|
||||||
//ширина/высота окна
|
|
||||||
private readonly int _pictureWidth;
|
private readonly int _pictureWidth;
|
||||||
private readonly int _pictureHeight;
|
private readonly int _pictureHeight;
|
||||||
//ширина/высота занимаемого места
|
|
||||||
private readonly int _placeSizeWidth = 150;
|
private readonly int _placeSizeWidth = 150;
|
||||||
private readonly int _placeSizeHeight = 130;
|
private readonly int _placeSizeHeight = 130;
|
||||||
/// Набор объектов
|
|
||||||
private readonly SetGeneric<T> _collection;
|
private readonly SetGeneric<T> _collection;
|
||||||
|
public IEnumerable<T?> GetTractors => _collection.GetTractors();
|
||||||
public TractorGenericCollection(int picWidth, int picHeight)
|
public TractorGenericCollection(int picWidth, int picHeight)
|
||||||
{
|
{
|
||||||
|
|
||||||
// высчитываем размер массива для setgeneric
|
|
||||||
int width = picWidth / _placeSizeWidth;
|
int width = picWidth / _placeSizeWidth;
|
||||||
int height = picHeight / _placeSizeHeight;
|
int height = picHeight / _placeSizeHeight;
|
||||||
_pictureWidth = picWidth;
|
_pictureWidth = picWidth;
|
||||||
_pictureHeight = picHeight;
|
_pictureHeight = picHeight;
|
||||||
_collection = new SetGeneric<T>(width * height);
|
_collection = new SetGeneric<T>(width * height);
|
||||||
}
|
}
|
||||||
/// Перегрузка оператора сложения
|
public static bool operator +(TractorGenericCollection<T, U> collect, T? tract)
|
||||||
public static int operator +(TractorGenericCollection<T, U> collect, T? tract)
|
|
||||||
{
|
{
|
||||||
if (tract == null)
|
if (tract == null) return false;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return collect._collection.Insert(tract);
|
return collect._collection.Insert(tract);
|
||||||
}
|
}
|
||||||
/// Перегрузка оператора вычитания
|
|
||||||
public static T? operator -(TractorGenericCollection<T, U> collect, int pos)
|
public static T? operator -(TractorGenericCollection<T, U> collect, int pos)
|
||||||
{
|
{
|
||||||
T? obj = collect._collection[pos];
|
T? obj = collect._collection[pos];
|
||||||
@@ -42,12 +33,6 @@ namespace ProjectBulldozer.Generics
|
|||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
// получение объекта imoveableObj
|
|
||||||
public U? GetU(int pos)
|
|
||||||
{
|
|
||||||
return (U?)_collection[pos]?.GetMoveableObject;
|
|
||||||
}
|
|
||||||
/// Вывод всего набора объектов
|
|
||||||
public Bitmap ShowTractors()
|
public Bitmap ShowTractors()
|
||||||
{
|
{
|
||||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||||
@@ -69,21 +54,17 @@ namespace ProjectBulldozer.Generics
|
|||||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawObjects(Graphics g)
|
private void DrawObjects(Graphics g)
|
||||||
{
|
{
|
||||||
int width = _pictureWidth / _placeSizeWidth;
|
int width = _pictureWidth / _placeSizeWidth;
|
||||||
int height = _pictureHeight / _placeSizeHeight;
|
int height = _pictureHeight / _placeSizeHeight;
|
||||||
for (int i = 0; i < _collection.Count; i++)
|
for (int i = 0; i < _collection.Count; i++)
|
||||||
{
|
{
|
||||||
// Получение объекта
|
|
||||||
var obj = _collection[i];
|
var obj = _collection[i];
|
||||||
// Установка позиции
|
|
||||||
obj?.SetPosition(
|
obj?.SetPosition(
|
||||||
(int)((width - 1) * _placeSizeWidth - (i % width * _placeSizeWidth)),
|
(int)((width - 1) * _placeSizeWidth - (i % width * _placeSizeWidth)),
|
||||||
(int)((height - 1) * _placeSizeHeight - (i / width * _placeSizeHeight))
|
(int)((height - 1) * _placeSizeHeight - (i / width * _placeSizeHeight))
|
||||||
);
|
);
|
||||||
// Прорисовка объекта
|
|
||||||
obj?.DrawTransport(g);
|
obj?.DrawTransport(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
namespace ProjectBulldozer.Generics
|
using ProjectBulldozer.Exceptions;
|
||||||
|
namespace ProjectBulldozer.Generics
|
||||||
{
|
{
|
||||||
internal class SetGeneric<T> where T : class
|
internal class SetGeneric<T> where T : class
|
||||||
{
|
{
|
||||||
@@ -12,24 +13,35 @@
|
|||||||
_places = new List<T?>(count);
|
_places = new List<T?>(count);
|
||||||
}
|
}
|
||||||
/// Добавление объекта в набор
|
/// Добавление объекта в набор
|
||||||
public int Insert(T tract)
|
public bool Insert(T tract)
|
||||||
{
|
{
|
||||||
return Insert(tract, 0);
|
return Insert(tract, 0);
|
||||||
}
|
}
|
||||||
public int Insert(T tract, int position)
|
public bool Insert(T tract, int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= _maxCount) return -1;
|
if (position < 0 || position >= _maxCount)
|
||||||
_places.Insert(position, tract);
|
{
|
||||||
return position;
|
throw new BulldozerNotFoundException(position);
|
||||||
}
|
}
|
||||||
public T? Remove(int position)
|
if (Count >= _maxCount)
|
||||||
{
|
{
|
||||||
if (position >= Count || position < 0)
|
throw new StorageOverflowException(_maxCount);
|
||||||
return null;
|
}
|
||||||
|
_places.Insert(position, tract);
|
||||||
T? tmp = _places[position];
|
return true;
|
||||||
|
}
|
||||||
|
public bool Remove(int position)
|
||||||
|
{
|
||||||
|
if (position < 0 || position >= _maxCount)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (_places[position] == null)
|
||||||
|
{
|
||||||
|
throw new BulldozerNotFoundException(position);
|
||||||
|
}
|
||||||
_places[position] = null;
|
_places[position] = null;
|
||||||
return tmp;
|
return true;
|
||||||
}
|
}
|
||||||
public T? this[int position]
|
public T? this[int position]
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
using ProjectBulldozer.Drawning;
|
using ProjectBulldozer.Drawing;
|
||||||
using ProjectBulldozer.MovementStrategy;
|
using ProjectBulldozer.Drawning;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace ProjectBulldozer.Generics
|
namespace ProjectBulldozer.Generics
|
||||||
{
|
{
|
||||||
internal class TractorGenericStorage
|
internal class TractorGenericStorage
|
||||||
{
|
{
|
||||||
|
private static readonly char _separatorForKeyValue = '|';
|
||||||
|
private readonly char _separatorRecords = ';';
|
||||||
|
private static readonly char _separatorForObject = ':';
|
||||||
readonly Dictionary<string, TractorGenericCollection<DrawingTractor, DrawingObjectTractor>> _TractorsStorage;
|
readonly Dictionary<string, TractorGenericCollection<DrawingTractor, DrawingObjectTractor>> _TractorsStorage;
|
||||||
public List<string> Keys => _TractorsStorage.Keys.ToList();
|
public List<string> Keys => _TractorsStorage.Keys.ToList();
|
||||||
private readonly int _pictureWidth;
|
private readonly int _pictureWidth;
|
||||||
@@ -28,8 +33,7 @@ namespace ProjectBulldozer.Generics
|
|||||||
_TractorsStorage.Remove(name);
|
_TractorsStorage.Remove(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public TractorGenericCollection<DrawingTractor, DrawingObjectTractor>?
|
public TractorGenericCollection<DrawingTractor, DrawingObjectTractor>? this[string ind]
|
||||||
this[string ind]
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -40,5 +44,84 @@ namespace ProjectBulldozer.Generics
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public bool SaveData(string filename)
|
||||||
|
{
|
||||||
|
if (File.Exists(filename))
|
||||||
|
{
|
||||||
|
File.Delete(filename);
|
||||||
|
}
|
||||||
|
StringBuilder data = new();
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, TractorGenericCollection<DrawingTractor, DrawingObjectTractor>>
|
||||||
|
record in _TractorsStorage)
|
||||||
|
{
|
||||||
|
StringBuilder records = new();
|
||||||
|
foreach (DrawingTractor? elem in record.Value.GetTractors)
|
||||||
|
{
|
||||||
|
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
||||||
|
}
|
||||||
|
data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}");
|
||||||
|
}
|
||||||
|
if (data.Length == 0)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Невалиданя операция, нет данных для сохранения");
|
||||||
|
}
|
||||||
|
using StreamWriter sw = new(filename);
|
||||||
|
sw.Write($"TractorsStorage{Environment.NewLine}{data}");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool LoadData(string filename)
|
||||||
|
{
|
||||||
|
if (!File.Exists(filename))
|
||||||
|
{
|
||||||
|
throw new FileNotFoundException("Файл не найден");
|
||||||
|
}
|
||||||
|
using (StreamReader sr = File.OpenText(filename))
|
||||||
|
{
|
||||||
|
string str = sr.ReadLine();
|
||||||
|
if (str == null || str.Length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!str.StartsWith("TractorsStorage"))
|
||||||
|
{
|
||||||
|
throw new FormatException("Неверный формат данных");
|
||||||
|
}
|
||||||
|
|
||||||
|
_TractorsStorage.Clear();
|
||||||
|
string strs = "";
|
||||||
|
|
||||||
|
while ((strs = sr.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
if (strs == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (record.Length != 2)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
TractorGenericCollection<DrawingTractor, DrawingObjectTractor> collection =
|
||||||
|
new(_pictureWidth, _pictureHeight);
|
||||||
|
string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
foreach (string elem in set)
|
||||||
|
{
|
||||||
|
DrawingTractor? tractor = elem?.CreateDrawingTractor(_separatorForObject,
|
||||||
|
_pictureWidth, _pictureHeight);
|
||||||
|
if (tractor != null)
|
||||||
|
{
|
||||||
|
if ((collection + tractor))
|
||||||
|
{
|
||||||
|
throw new ApplicationException("Ошибка добавления в коллекцию");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_TractorsStorage.Add(record[0], collection);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
using Bulldozer;
|
using ProjectBulldozer.MovementStrategy;
|
||||||
using ProjectBulldozer.MovementStrategy;
|
|
||||||
namespace ProjectBulldozer.Drawning
|
namespace ProjectBulldozer.Drawning
|
||||||
{
|
{
|
||||||
public class DrawingObjectTractor : IMoveableObject
|
public class DrawingObjectTractor : IMoveableObject
|
||||||
{
|
{
|
||||||
private readonly DrawingTractor? _drawningTractor = null;
|
private readonly DrawingTractor? _drawningTractor = null;
|
||||||
|
|
||||||
public DrawingObjectTractor(DrawingTractor drawningTractor)
|
public DrawingObjectTractor(DrawingTractor drawningTractor)
|
||||||
{
|
{
|
||||||
_drawningTractor = drawningTractor;
|
_drawningTractor = drawningTractor;
|
||||||
|
|||||||
@@ -6,17 +6,9 @@
|
|||||||
private readonly int _y;
|
private readonly int _y;
|
||||||
private readonly int _width;
|
private readonly int _width;
|
||||||
private readonly int _height;
|
private readonly int _height;
|
||||||
/// Левая граница
|
|
||||||
public int LeftBorder => _x;
|
|
||||||
/// Верхняя граница
|
|
||||||
public int TopBorder => _y;
|
|
||||||
/// Правая граница
|
|
||||||
public int RightBorder => _x + _width;
|
public int RightBorder => _x + _width;
|
||||||
/// Нижняя граница
|
|
||||||
public int DownBorder => _y + _height;
|
public int DownBorder => _y + _height;
|
||||||
/// Середина объекта по горизонтали
|
|
||||||
public int ObjectMiddleHorizontal => _x + _width / 2;
|
public int ObjectMiddleHorizontal => _x + _width / 2;
|
||||||
/// Середина объекта по вертикали
|
|
||||||
public int ObjectMiddleVertical => _y + _height / 2;
|
public int ObjectMiddleVertical => _y + _height / 2;
|
||||||
public ObjectParameters(int x, int y, int width, int height)
|
public ObjectParameters(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,14 +1,40 @@
|
|||||||
using ProjectBulldozer;
|
using ProjectBulldozer;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Serilog;
|
||||||
namespace Bulldozer
|
namespace Bulldozer
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
|
private static Serilog.ILogger? logger;
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormTractorCollections());
|
var services = new ServiceCollection();
|
||||||
|
ConfigureServices(services);
|
||||||
|
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
|
||||||
|
{
|
||||||
|
Application.Run(serviceProvider.GetRequiredService<FormTractorCollections>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static void ConfigureServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddSingleton<FormTractorCollections>().AddLogging(option =>
|
||||||
|
{
|
||||||
|
string[] path = Directory.GetCurrentDirectory().Split('\\');
|
||||||
|
string appPath = "";
|
||||||
|
for (int i = 0; i < path.Length - 3; i++)
|
||||||
|
{
|
||||||
|
appPath += path[i] + "\\";
|
||||||
|
}
|
||||||
|
var configuration = new ConfigurationBuilder().AddJsonFile($"{appPath}appsettings.json").Build();
|
||||||
|
var logger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();
|
||||||
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
|
option.AddSerilog(logger);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,20 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
||||||
|
<PackageReference Include="NLog" Version="5.2.7" />
|
||||||
|
<PackageReference Include="NLog.Config" Version="4.7.15" />
|
||||||
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.7" />
|
||||||
|
<PackageReference Include="NLog.Schema" Version="5.2.7" />
|
||||||
|
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.7" />
|
||||||
|
<PackageReference Include="Serilog.Extensions.Logging.File" Version="3.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Update="Properties\Resources.Designer.cs">
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
|
|||||||
20
ProjectBulldozer/appsettings.json
Normal file
20
ProjectBulldozer/appsettings.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"Serilog": {
|
||||||
|
"Using": [ "Serilog.Sinks.File" ],
|
||||||
|
"MinimumLevel": "Information",
|
||||||
|
"WriteTo": [
|
||||||
|
{
|
||||||
|
"Name": "File",
|
||||||
|
"Args": {
|
||||||
|
"path": "logs/bulldozerlog-.log",
|
||||||
|
"rollingInterval": "Day",
|
||||||
|
"outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
|
||||||
|
"Properties": {
|
||||||
|
"Application": "Bulldozer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user