Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
2b49c57bd9 | ||
|
2468f39500 | ||
|
e6406130fd | ||
|
b2e5c3e9b5 | ||
|
8893e998d1 | ||
|
76dbe4761b | ||
|
feac50420c | ||
|
6a949caa88 | ||
|
710ecb435c |
2
.gitignore
vendored
@ -2,6 +2,8 @@
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
.idea
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
|
25
ProjectTank.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.6.33801.468
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectTank", "ProjectTank\ProjectTank.csproj", "{3813FF33-65D9-4474-8AC9-594C12C365A8}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3813FF33-65D9-4474-8AC9-594C12C365A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3813FF33-65D9-4474-8AC9-594C12C365A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3813FF33-65D9-4474-8AC9-594C12C365A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3813FF33-65D9-4474-8AC9-594C12C365A8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {B481448C-8B20-483C-BA2D-C90D5AACDB69}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
16
ProjectTank/DirectionType.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectTank
|
||||
{
|
||||
public enum DirectionType
|
||||
{
|
||||
Up = 0,
|
||||
Down = 1,
|
||||
Left = 2,
|
||||
Right = 3,
|
||||
}
|
||||
}
|
67
ProjectTank/DrawningObjects/DrawningTank.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using ProjectTank.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectTank.DrawningObjects
|
||||
{
|
||||
public class DrawningTank : DrawningTankBase
|
||||
{
|
||||
public DrawningTank(int speed, int weight, Color bodyColor, Color additionalColor, bool isTankTower, bool isAntiAirforceGun, int width, int height) : base(speed, weight, bodyColor, width, height)
|
||||
{
|
||||
if (EntityTankBase == null) return;
|
||||
|
||||
EntityTankBase = new EntityTank(speed, weight, bodyColor, additionalColor, isTankTower, isAntiAirforceGun);
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityTankBase is not EntityTank tank) return;
|
||||
|
||||
Pen pen = new(tank.AdditionalColor);
|
||||
|
||||
if (tank.TankTower)
|
||||
{
|
||||
// дуло
|
||||
g.DrawRectangle(pen, startPosX + 15, startPosY + 37, 30, 7);
|
||||
}
|
||||
|
||||
base.DrawTransport(g);
|
||||
|
||||
if (tank.AntiAirforceGun)
|
||||
{
|
||||
// зенитное орудие
|
||||
g.DrawRectangle(pen, startPosX + 65, startPosY + 18, 8, 12);
|
||||
g.DrawRectangle(pen, startPosX + 65 + 8, startPosY + 16, 8, 14);
|
||||
|
||||
Point[] leftRectanglePoints =
|
||||
{
|
||||
new Point(startPosX + 52, startPosY + 5),
|
||||
new Point(startPosX + 67, startPosY + 18),
|
||||
new Point(startPosX + 67 + 5, startPosY + 18),
|
||||
new Point(startPosX + 57, startPosY + 5),
|
||||
};
|
||||
|
||||
g.DrawPolygon(pen, leftRectanglePoints);
|
||||
|
||||
Point[] rightRectanglePoints =
|
||||
{
|
||||
new Point(startPosX + 59, startPosY),
|
||||
new Point(startPosX + 74, startPosY + 16),
|
||||
new Point(startPosX + 74 + 5, startPosY + 16),
|
||||
new Point(startPosX + 66, startPosY),
|
||||
};
|
||||
|
||||
g.DrawPolygon(pen, rightRectanglePoints);
|
||||
}
|
||||
}
|
||||
public void ChangeAdditionalColor(Color color)
|
||||
{
|
||||
((EntityTank)EntityTankBase).AdditionalColor = color;
|
||||
}
|
||||
}
|
||||
}
|
130
ProjectTank/DrawningObjects/DrawningTankBase.cs
Normal file
@ -0,0 +1,130 @@
|
||||
using ProjectTank.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectTank.MovementStrategy;
|
||||
|
||||
namespace ProjectTank.DrawningObjects
|
||||
{
|
||||
public class DrawningTankBase
|
||||
{
|
||||
public EntityTankBase? EntityTankBase { get; protected set; }
|
||||
private int pictureWidth;
|
||||
private int pictureHeight;
|
||||
protected int startPosX;
|
||||
protected int startPosY;
|
||||
protected readonly int tankWidth = 145;
|
||||
protected readonly int tankHeight = 95;
|
||||
|
||||
public int GetPosX => startPosX;
|
||||
public int GetPosY => startPosY;
|
||||
public int GetWidth => tankWidth;
|
||||
public int GetHeight => tankHeight;
|
||||
public IMoveableObject GetMoveableObject => new DrawningObjectTank(this);
|
||||
public DrawningTankBase(int speed, int weight, Color bodyColor, int width, int height)
|
||||
{
|
||||
if (width <= tankWidth || height <= tankHeight) return;
|
||||
|
||||
pictureWidth = width;
|
||||
pictureHeight = height;
|
||||
EntityTankBase = new EntityTankBase(speed, weight, bodyColor);
|
||||
}
|
||||
public bool CanMove(DirectionType direction)
|
||||
{
|
||||
if (EntityTankBase == null) return false;
|
||||
|
||||
return direction switch
|
||||
{
|
||||
DirectionType.Left => startPosX - EntityTankBase.Step > 0,
|
||||
DirectionType.Up => startPosY - EntityTankBase.Step > 0,
|
||||
DirectionType.Right => startPosX + tankWidth + EntityTankBase.Step < pictureWidth,
|
||||
DirectionType.Down => startPosY + tankHeight + EntityTankBase.Step < pictureHeight,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (EntityTankBase == null) return;
|
||||
startPosX = x;
|
||||
startPosY = y;
|
||||
|
||||
if (x + tankWidth > pictureWidth || y + tankHeight > pictureHeight)
|
||||
{
|
||||
startPosX = 1;
|
||||
startPosY = 1;
|
||||
}
|
||||
}
|
||||
public void ChangePictureBoxSize(int pictureBoxWidth, int pictureBoxHeight)
|
||||
{
|
||||
pictureHeight = pictureBoxHeight;
|
||||
pictureWidth = pictureBoxWidth;
|
||||
}
|
||||
public void MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (!CanMove(direction) || EntityTankBase == null) return;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
//влево
|
||||
case DirectionType.Left:
|
||||
startPosX -= (int)EntityTankBase.Step;
|
||||
break;
|
||||
//вверх
|
||||
case DirectionType.Up:
|
||||
startPosY -= (int)EntityTankBase.Step;
|
||||
break;
|
||||
// вправо
|
||||
case DirectionType.Right:
|
||||
startPosX += (int)EntityTankBase.Step;
|
||||
break;
|
||||
//вниз
|
||||
case DirectionType.Down:
|
||||
startPosY += (int)EntityTankBase.Step;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityTankBase == null) return;
|
||||
|
||||
Pen pen = new(EntityTankBase.BodyColor);
|
||||
|
||||
// гусеница
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
int cornerRadius = 20;
|
||||
|
||||
path.AddArc(startPosX + 1, startPosY + 65, cornerRadius, cornerRadius, 180, 90);
|
||||
path.AddArc(startPosX + tankWidth - cornerRadius, startPosY + 65, cornerRadius, cornerRadius, 270, 90);
|
||||
path.AddArc(startPosX + tankWidth - cornerRadius, startPosY + tankHeight - cornerRadius, cornerRadius, cornerRadius, 0, 90);
|
||||
path.AddArc(startPosX + 1, startPosY + tankHeight - cornerRadius, cornerRadius, cornerRadius, 90, 90);
|
||||
|
||||
path.CloseFigure();
|
||||
g.DrawPath(pen, path);
|
||||
|
||||
// колеса
|
||||
g.DrawEllipse(pen, startPosX + 1, startPosY + tankHeight - 3 - 25, 25, 25);
|
||||
for (int i = 1; i < 5; i++)
|
||||
{
|
||||
g.DrawEllipse(pen, startPosX + 30 + 5 * i + 15 * (i - 1), startPosY + tankHeight - 5 - 15, 15, 15);
|
||||
}
|
||||
g.DrawEllipse(pen, startPosX + tankWidth - 25 - 1, startPosY + tankHeight - 3 - 25, 25, 25);
|
||||
|
||||
// башня
|
||||
SolidBrush brush = new SolidBrush(EntityTankBase.BodyColor);
|
||||
g.FillRectangle(brush, startPosX + 45, startPosY + 30, 60, 26);
|
||||
|
||||
g.FillRectangle(brush, startPosX + 5, startPosY + 55 + 1, tankWidth - 10, 9);
|
||||
}
|
||||
|
||||
public void ChangeColor(Color col)
|
||||
{
|
||||
if (EntityTankBase == null) return;
|
||||
EntityTankBase.BodyColor = col;
|
||||
}
|
||||
}
|
||||
}
|
58
ProjectTank/DrawningObjects/ExtensionDrawningTankBase.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using ProjectTank.DrawningObjects;
|
||||
using ProjectTank.Entities;
|
||||
|
||||
namespace ProjectTank.Drawnings
|
||||
{
|
||||
public static class ExtentionDrawningTankBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Создание объекта из строки
|
||||
/// </summary>
|
||||
/// <param name="info">Строка с данными для создания объекта</param>
|
||||
/// <param name="separatorForObject">Разделитель даннных</param>
|
||||
/// <param name="width">Ширина</param>
|
||||
/// <param name="height">Высота</param>
|
||||
/// <returns>Объект</returns>
|
||||
public static DrawningTankBase? CreateDrawningTankBase(this string info, char
|
||||
separatorForObject, int width, int height)
|
||||
{
|
||||
string[] strs = info.Split(separatorForObject);
|
||||
if (strs.Length == 3)
|
||||
{
|
||||
return new DrawningTankBase(Convert.ToInt32(strs[0]),
|
||||
Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
|
||||
}
|
||||
if (strs.Length == 6)
|
||||
{
|
||||
return new DrawningTank(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;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение данных для сохранения в файл
|
||||
/// </summary>
|
||||
/// <param name="drawningCar">Сохраняемый объект</param>
|
||||
/// <param name="separatorForObject">Разделитель даннных</param>
|
||||
/// <returns>Строка с данными по объекту</returns>
|
||||
public static string GetDataForSave(this DrawningTankBase drawningTankBase, char separatorForObject)
|
||||
{
|
||||
var tankBase = drawningTankBase.EntityTankBase;
|
||||
if (tankBase == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
var str = $"{tankBase.Speed}{separatorForObject}{tankBase.Weight}{separatorForObject}{tankBase.BodyColor.Name}";
|
||||
if (tankBase is not EntityTank tank)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
return $"{str}{separatorForObject}{tank.AdditionalColor.Name}{separatorForObject}{tank.AntiAirforceGun}{separatorForObject}{tank.TankTower}";
|
||||
}
|
||||
}
|
||||
}
|
23
ProjectTank/Entities/EntityTank.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectTank.Entities
|
||||
{
|
||||
public class EntityTank : EntityTankBase
|
||||
{
|
||||
public Color AdditionalColor { get; set; }
|
||||
public bool TankTower { get; private set; }
|
||||
public bool AntiAirforceGun { get; private set; }
|
||||
public EntityTank(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool tankTower, bool antiAirforceGun) : base(speed, weight, bodyColor)
|
||||
{
|
||||
AdditionalColor = additionalColor;
|
||||
TankTower = tankTower;
|
||||
AntiAirforceGun = antiAirforceGun;
|
||||
}
|
||||
}
|
||||
}
|
22
ProjectTank/Entities/EntityTankBase.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectTank.Entities
|
||||
{
|
||||
public class EntityTankBase
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
public double Weight { get; private set; }
|
||||
public Color BodyColor { get; set; }
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
public EntityTankBase(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
}
|
||||
}
|
15
ProjectTank/Exceptions/StorageOverlowException.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System.Runtime.Serialization;
|
||||
namespace ProjectTank.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 contex) : base(info, contex) { }
|
||||
}
|
||||
}
|
16
ProjectTank/Exceptions/TankNotFoundException.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ProjectTank.Exceptions
|
||||
{
|
||||
[Serializable]
|
||||
internal class TankNotFoundException : ApplicationException
|
||||
{
|
||||
public TankNotFoundException(int i) : base($"Не найден объект по позиции {i}") { }
|
||||
public TankNotFoundException() : base() { }
|
||||
public TankNotFoundException(string message) : base(message) { }
|
||||
public TankNotFoundException(string message, Exception exception) :
|
||||
base(message, exception) { }
|
||||
protected TankNotFoundException(SerializationInfo info,
|
||||
StreamingContext contex) : base(info, contex) { }
|
||||
}
|
||||
}
|
188
ProjectTank/FormTank.Designer.cs
generated
Normal file
@ -0,0 +1,188 @@
|
||||
namespace ProjectTank
|
||||
{
|
||||
partial class FormTank
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
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()
|
||||
{
|
||||
pictureBoxTank = new PictureBox();
|
||||
createButton = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonDown = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonUp = new Button();
|
||||
comboBoxStrategy = new ComboBox();
|
||||
button1 = new Button();
|
||||
button2 = new Button();
|
||||
button3 = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxTank).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxTank
|
||||
//
|
||||
pictureBoxTank.Dock = DockStyle.Fill;
|
||||
pictureBoxTank.Location = new Point(0, 0);
|
||||
pictureBoxTank.Name = "pictureBoxTank";
|
||||
pictureBoxTank.Size = new Size(760, 458);
|
||||
pictureBoxTank.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||
pictureBoxTank.TabIndex = 7;
|
||||
pictureBoxTank.TabStop = false;
|
||||
//
|
||||
// createButton
|
||||
//
|
||||
createButton.Location = new Point(403, 406);
|
||||
createButton.Name = "createButton";
|
||||
createButton.Size = new Size(167, 41);
|
||||
createButton.TabIndex = 8;
|
||||
createButton.Text = "Создать основу танка";
|
||||
createButton.UseVisualStyleBackColor = true;
|
||||
createButton.Click += ButtonCreateTankBase_Click;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.BackgroundImage = Properties.Resources.icons8_left_arrow_40;
|
||||
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonLeft.Font = new Font("Segoe UI", 15F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
buttonLeft.Location = new Point(12, 396);
|
||||
buttonLeft.Name = "buttonLeft";
|
||||
buttonLeft.Size = new Size(50, 50);
|
||||
buttonLeft.TabIndex = 9;
|
||||
buttonLeft.UseVisualStyleBackColor = true;
|
||||
buttonLeft.Click += moveButton_Click;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
buttonDown.BackgroundImage = Properties.Resources.arrowDown;
|
||||
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonDown.Font = new Font("Segoe UI", 10F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
buttonDown.Location = new Point(68, 396);
|
||||
buttonDown.Name = "buttonDown";
|
||||
buttonDown.Size = new Size(50, 50);
|
||||
buttonDown.TabIndex = 10;
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += moveButton_Click;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
buttonRight.BackgroundImage = Properties.Resources.icons8_right_arrow_40;
|
||||
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonRight.Font = new Font("Segoe UI", 15F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
buttonRight.Location = new Point(124, 396);
|
||||
buttonRight.Name = "buttonRight";
|
||||
buttonRight.Size = new Size(50, 50);
|
||||
buttonRight.TabIndex = 11;
|
||||
buttonRight.UseVisualStyleBackColor = true;
|
||||
buttonRight.Click += moveButton_Click;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
buttonUp.BackgroundImage = Properties.Resources.icons8_up_arrow_40;
|
||||
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonUp.Font = new Font("Segoe UI", 15F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
buttonUp.Location = new Point(68, 340);
|
||||
buttonUp.Name = "buttonUp";
|
||||
buttonUp.Size = new Size(50, 50);
|
||||
buttonUp.TabIndex = 12;
|
||||
buttonUp.UseVisualStyleBackColor = true;
|
||||
buttonUp.Click += moveButton_Click;
|
||||
//
|
||||
// comboBoxStrategy
|
||||
//
|
||||
comboBoxStrategy.AutoCompleteCustomSource.AddRange(new string[] { "Move to center", "Move to border" });
|
||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxStrategy.FormattingEnabled = true;
|
||||
comboBoxStrategy.Items.AddRange(new object[] { "Двигаться в центр", "Двигаться в правый нижний угол" });
|
||||
comboBoxStrategy.Location = new Point(514, 0);
|
||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
||||
comboBoxStrategy.Size = new Size(234, 28);
|
||||
comboBoxStrategy.TabIndex = 13;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(576, 405);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(172, 41);
|
||||
button1.TabIndex = 14;
|
||||
button1.Text = "Создать полный танк";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += ButtonCreateTank_Click;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(654, 49);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(94, 29);
|
||||
button2.TabIndex = 15;
|
||||
button2.Text = "Шаг";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += ButtonStep_Click;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.Location = new Point(277, 406);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(120, 41);
|
||||
button3.TabIndex = 16;
|
||||
button3.Text = "Выбрать танк";
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += ButtonSelectTank_Click;
|
||||
//
|
||||
// FormTank
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(760, 458);
|
||||
Controls.Add(button3);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(comboBoxStrategy);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(createButton);
|
||||
Controls.Add(pictureBoxTank);
|
||||
Name = "FormTank";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Рисунок танка";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxTank).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
private PictureBox pictureBoxTank;
|
||||
private Button createButton;
|
||||
private Button buttonLeft;
|
||||
private Button buttonDown;
|
||||
private Button buttonRight;
|
||||
private Button buttonUp;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button button1;
|
||||
private Button button2;
|
||||
private Button button3;
|
||||
}
|
||||
}
|
124
ProjectTank/FormTank.cs
Normal file
@ -0,0 +1,124 @@
|
||||
using ProjectTank;
|
||||
using ProjectTank.DrawningObjects;
|
||||
using ProjectTank.MovementStrategy;
|
||||
|
||||
namespace ProjectTank
|
||||
{
|
||||
public partial class FormTank : Form
|
||||
{
|
||||
private DrawningTankBase? _drawningTank;
|
||||
private AbstractStrategy? _strategy;
|
||||
public DrawningTankBase? SelectedTank { get; private set; }
|
||||
|
||||
public FormTank()
|
||||
{
|
||||
InitializeComponent();
|
||||
_strategy = null;
|
||||
SelectedTank = null;
|
||||
}
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningTank == null) return;
|
||||
Bitmap bmp = new(pictureBoxTank.Width, pictureBoxTank.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningTank.DrawTransport(gr);
|
||||
pictureBoxTank.Image = bmp;
|
||||
}
|
||||
private void ButtonCreateTank_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
Color bodyColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
Color additionalColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
bodyColor = dialog.Color;
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
additionalColor = dialog.Color;
|
||||
}
|
||||
|
||||
|
||||
_drawningTank = new DrawningTank(random.Next(100, 300), random.Next(1000, 3000), bodyColor,
|
||||
additionalColor, Convert.ToBoolean(random.Next(0, 2)),
|
||||
Convert.ToBoolean(random.Next(0, 2)), pictureBoxTank.Width, pictureBoxTank.Height);
|
||||
_drawningTank.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
private void ButtonCreateTankBase_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
|
||||
_drawningTank = new DrawningTankBase(random.Next(100, 300), random.Next(1000, 3000), color,
|
||||
pictureBoxTank.Width, pictureBoxTank.Height);
|
||||
_drawningTank.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
|
||||
}
|
||||
private void moveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningTank == null) return;
|
||||
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawningTank.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_drawningTank.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_drawningTank.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_drawningTank.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
private void ButtonStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningTank == null) return;
|
||||
|
||||
if (comboBoxStrategy.Enabled)
|
||||
{
|
||||
_strategy = comboBoxStrategy.SelectedIndex
|
||||
switch
|
||||
{
|
||||
0 => new MoveToCenter(),
|
||||
1 => new MoveToRightBottomCorner(),
|
||||
_ => null,
|
||||
};
|
||||
if (_strategy == null) return;
|
||||
_strategy.SetData(new DrawningObjectTank(_drawningTank), pictureBoxTank.Width, pictureBoxTank.Height);
|
||||
comboBoxStrategy.Enabled = false;
|
||||
}
|
||||
if (_strategy == null) return;
|
||||
|
||||
_strategy.MakeStep();
|
||||
Draw();
|
||||
if (_strategy.GetStatus() == MovementStrategy.Status.Finish)
|
||||
{
|
||||
comboBoxStrategy.Enabled = true;
|
||||
_strategy = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSelectTank_Click(object sender, EventArgs e)
|
||||
{
|
||||
SelectedTank = _drawningTank;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
120
ProjectTank/FormTank.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>
|
268
ProjectTank/FormTankCollection.Designer.cs
generated
Normal file
@ -0,0 +1,268 @@
|
||||
namespace ProjectTank
|
||||
{
|
||||
partial class FormTankCollection
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
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()
|
||||
{
|
||||
pictureBoxCollection = new PictureBox();
|
||||
refreshObjectsButton = new Button();
|
||||
deleteTankButton = new Button();
|
||||
addTankButton = new Button();
|
||||
maskedTextBoxNumber = new TextBox();
|
||||
label2 = new Label();
|
||||
textBoxStorageName = new TextBox();
|
||||
addObjectButton = new Button();
|
||||
listBoxStorages = new ListBox();
|
||||
deleteObjectButton = new Button();
|
||||
groupBox1 = new GroupBox();
|
||||
sortByColorButton = new Button();
|
||||
sortByTypeButton = new Button();
|
||||
menuStrip = new MenuStrip();
|
||||
fileToolStripMenuItem = new ToolStripMenuItem();
|
||||
loadToolStripMenuItem = new ToolStripMenuItem();
|
||||
saveToolStripMenuItem = new ToolStripMenuItem();
|
||||
openFileDialog = new OpenFileDialog();
|
||||
saveFileDialog = new SaveFileDialog();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
||||
groupBox1.SuspendLayout();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxCollection
|
||||
//
|
||||
pictureBoxCollection.Location = new Point(6, 32);
|
||||
pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
pictureBoxCollection.Size = new Size(760, 475);
|
||||
pictureBoxCollection.TabIndex = 0;
|
||||
pictureBoxCollection.TabStop = false;
|
||||
//
|
||||
// refreshObjectsButton
|
||||
//
|
||||
refreshObjectsButton.Location = new Point(6, 440);
|
||||
refreshObjectsButton.Name = "refreshObjectsButton";
|
||||
refreshObjectsButton.Size = new Size(139, 29);
|
||||
refreshObjectsButton.TabIndex = 4;
|
||||
refreshObjectsButton.Text = "Обн. коллекцию";
|
||||
refreshObjectsButton.UseVisualStyleBackColor = true;
|
||||
refreshObjectsButton.Click += ButtonRefreshCollection_Click;
|
||||
//
|
||||
// deleteTankButton
|
||||
//
|
||||
deleteTankButton.Location = new Point(6, 404);
|
||||
deleteTankButton.Name = "deleteTankButton";
|
||||
deleteTankButton.Size = new Size(139, 29);
|
||||
deleteTankButton.TabIndex = 5;
|
||||
deleteTankButton.Text = "Удалить танк";
|
||||
deleteTankButton.UseVisualStyleBackColor = true;
|
||||
deleteTankButton.Click += ButtonRemoveTank_Click;
|
||||
//
|
||||
// addTankButton
|
||||
//
|
||||
addTankButton.Location = new Point(6, 338);
|
||||
addTankButton.Name = "addTankButton";
|
||||
addTankButton.Size = new Size(139, 29);
|
||||
addTankButton.TabIndex = 6;
|
||||
addTankButton.Text = "Добавить танк";
|
||||
addTankButton.UseVisualStyleBackColor = true;
|
||||
addTankButton.Click += ButtonAddTank_Click;
|
||||
//
|
||||
// maskedTextBoxNumber
|
||||
//
|
||||
maskedTextBoxNumber.Location = new Point(6, 373);
|
||||
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||
maskedTextBoxNumber.Size = new Size(139, 27);
|
||||
maskedTextBoxNumber.TabIndex = 7;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(6, 30);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(66, 20);
|
||||
label2.TabIndex = 8;
|
||||
label2.Text = "Наборы";
|
||||
//
|
||||
// textBoxStorageName
|
||||
//
|
||||
textBoxStorageName.Location = new Point(6, 59);
|
||||
textBoxStorageName.Name = "textBoxStorageName";
|
||||
textBoxStorageName.Size = new Size(139, 27);
|
||||
textBoxStorageName.TabIndex = 9;
|
||||
//
|
||||
// addObjectButton
|
||||
//
|
||||
addObjectButton.Location = new Point(6, 92);
|
||||
addObjectButton.Name = "addObjectButton";
|
||||
addObjectButton.Size = new Size(139, 29);
|
||||
addObjectButton.TabIndex = 10;
|
||||
addObjectButton.Text = "Добавить набор";
|
||||
addObjectButton.UseVisualStyleBackColor = true;
|
||||
addObjectButton.Click += ButtonAddObject_Click;
|
||||
//
|
||||
// listBoxStorages
|
||||
//
|
||||
listBoxStorages.FormattingEnabled = true;
|
||||
listBoxStorages.ItemHeight = 20;
|
||||
listBoxStorages.Location = new Point(6, 131);
|
||||
listBoxStorages.Name = "listBoxStorages";
|
||||
listBoxStorages.Size = new Size(139, 84);
|
||||
listBoxStorages.TabIndex = 11;
|
||||
listBoxStorages.SelectedIndexChanged += ListBoxObjects_SelectedIndexChanged;
|
||||
//
|
||||
// deleteObjectButton
|
||||
//
|
||||
deleteObjectButton.Location = new Point(6, 222);
|
||||
deleteObjectButton.Name = "deleteObjectButton";
|
||||
deleteObjectButton.Size = new Size(139, 29);
|
||||
deleteObjectButton.TabIndex = 12;
|
||||
deleteObjectButton.Text = "Удалить набор";
|
||||
deleteObjectButton.UseVisualStyleBackColor = true;
|
||||
deleteObjectButton.Click += ButtonDelObject_Click;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Controls.Add(sortByColorButton);
|
||||
groupBox1.Controls.Add(sortByTypeButton);
|
||||
groupBox1.Controls.Add(label2);
|
||||
groupBox1.Controls.Add(refreshObjectsButton);
|
||||
groupBox1.Controls.Add(deleteTankButton);
|
||||
groupBox1.Controls.Add(maskedTextBoxNumber);
|
||||
groupBox1.Controls.Add(deleteObjectButton);
|
||||
groupBox1.Controls.Add(addTankButton);
|
||||
groupBox1.Controls.Add(textBoxStorageName);
|
||||
groupBox1.Controls.Add(listBoxStorages);
|
||||
groupBox1.Controls.Add(addObjectButton);
|
||||
groupBox1.Location = new Point(775, 32);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(154, 472);
|
||||
groupBox1.TabIndex = 13;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Инструменты";
|
||||
//
|
||||
// sortByColorButton
|
||||
//
|
||||
sortByColorButton.Location = new Point(6, 297);
|
||||
sortByColorButton.Name = "sortByColorButton";
|
||||
sortByColorButton.Size = new Size(139, 29);
|
||||
sortByColorButton.TabIndex = 14;
|
||||
sortByColorButton.Text = "Сорт. по цвету";
|
||||
sortByColorButton.UseVisualStyleBackColor = true;
|
||||
sortByColorButton.Click += ButtonSortByColor_Click;
|
||||
//
|
||||
// sortByTypeButton
|
||||
//
|
||||
sortByTypeButton.Location = new Point(6, 262);
|
||||
sortByTypeButton.Name = "sortByTypeButton";
|
||||
sortByTypeButton.Size = new Size(139, 29);
|
||||
sortByTypeButton.TabIndex = 13;
|
||||
sortByTypeButton.Text = "Сорт. по типу";
|
||||
sortByTypeButton.UseVisualStyleBackColor = true;
|
||||
sortByTypeButton.Click += ButtonSortByType_Click;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(935, 28);
|
||||
menuStrip.TabIndex = 14;
|
||||
menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { loadToolStripMenuItem, saveToolStripMenuItem });
|
||||
fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
fileToolStripMenuItem.Size = new Size(59, 24);
|
||||
fileToolStripMenuItem.Text = "Файл";
|
||||
//
|
||||
// loadToolStripMenuItem
|
||||
//
|
||||
loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
||||
loadToolStripMenuItem.Size = new Size(166, 26);
|
||||
loadToolStripMenuItem.Text = "Загрузить";
|
||||
loadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
||||
//
|
||||
// saveToolStripMenuItem
|
||||
//
|
||||
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||
saveToolStripMenuItem.Size = new Size(166, 26);
|
||||
saveToolStripMenuItem.Text = "Сохранить";
|
||||
saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
openFileDialog.FileName = "openFileDialog";
|
||||
openFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
saveFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// FormTankCollection
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(935, 516);
|
||||
Controls.Add(groupBox1);
|
||||
Controls.Add(pictureBoxCollection);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Name = "FormTankCollection";
|
||||
Text = "Набор танков";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
||||
groupBox1.ResumeLayout(false);
|
||||
groupBox1.PerformLayout();
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxCollection;
|
||||
private Button refreshObjectsButton;
|
||||
private Button deleteTankButton;
|
||||
private Button addTankButton;
|
||||
private TextBox maskedTextBoxNumber;
|
||||
private Label label2;
|
||||
private TextBox textBoxStorageName;
|
||||
private Button addObjectButton;
|
||||
private ListBox listBoxStorages;
|
||||
private Button deleteObjectButton;
|
||||
private GroupBox groupBox1;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem fileToolStripMenuItem;
|
||||
private ToolStripMenuItem loadToolStripMenuItem;
|
||||
private ToolStripMenuItem saveToolStripMenuItem;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private Button sortByColorButton;
|
||||
private Button sortByTypeButton;
|
||||
}
|
||||
}
|
251
ProjectTank/FormTankCollection.cs
Normal file
@ -0,0 +1,251 @@
|
||||
using ProjectTank.DrawningObjects;
|
||||
using ProjectTank.Generics;
|
||||
using ProjectTank.MovementStrategy;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.VisualBasic.Logging;
|
||||
using ProjectTank.Exceptions;
|
||||
using Serilog;
|
||||
using Log = Serilog.Log;
|
||||
|
||||
namespace ProjectTank
|
||||
{
|
||||
public partial class FormTankCollection : Form
|
||||
{
|
||||
private readonly TanksGenericStorage _storage;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormTankCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_storage = new TanksGenericStorage(pictureBoxCollection.Width,
|
||||
pictureBoxCollection.Height);
|
||||
}
|
||||
|
||||
private void ReloadObjects()
|
||||
{
|
||||
int index = listBoxStorages.SelectedIndex;
|
||||
listBoxStorages.Items.Clear();
|
||||
|
||||
for (int i = 0; i < _storage.Keys.Count; i++)
|
||||
{
|
||||
listBoxStorages.Items.Add(_storage.Keys[i].Name);
|
||||
}
|
||||
|
||||
if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count))
|
||||
{
|
||||
listBoxStorages.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
else if (listBoxStorages.Items.Count > 0 && index > -1 && index < listBoxStorages.Items.Count)
|
||||
{
|
||||
listBoxStorages.SelectedIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAddObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
||||
{
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_storage.AddSet(textBoxStorageName.Text);
|
||||
ReloadObjects();
|
||||
Log.Information($"Добавлен набор: {textBoxStorageName.Text}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Сортировка по типу
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonSortByType_Click(object sender, EventArgs e) => CompareTanks(new TankCompareByType());
|
||||
/// <summary>
|
||||
/// Сортировка по цвету
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonSortByColor_Click(object sender, EventArgs e) => CompareTanks(new TankCompareByColor());
|
||||
/// <summary>
|
||||
/// Сортировка по сравнителю
|
||||
/// </summary>
|
||||
/// <param name="comparer"></param>
|
||||
private void CompareTanks(IComparer<DrawningTankBase?> comparer)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1) return;
|
||||
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
|
||||
if (obj == null) return;
|
||||
|
||||
obj.Sort(comparer);
|
||||
pictureBoxCollection.Image = obj.ShowTanks();
|
||||
}
|
||||
|
||||
|
||||
private void ListBoxObjects_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowTanks();
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonDelObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1) return;
|
||||
|
||||
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
string name = listBoxStorages.SelectedItem.ToString() ?? string.Empty;
|
||||
_storage.DelSet(name);
|
||||
ReloadObjects();
|
||||
Log.Information($"Удален набор: {name}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddTank_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1) return;
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null) return;
|
||||
|
||||
FormTankConfig form = new();
|
||||
form.Show();
|
||||
Action<DrawningTankBase>? tankDelegate = new((t) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
bool q = (obj + t);
|
||||
MessageBox.Show("Объект добавлен");
|
||||
Log.Information($"Добавлен объект в коллекцию {listBoxStorages.SelectedItem.ToString() ?? string.Empty}");
|
||||
pictureBoxCollection.Image = obj.ShowTanks();
|
||||
t.ChangePictureBoxSize(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
}
|
||||
catch (StorageOverflowException ex)
|
||||
{
|
||||
Log.Warning($"Коллекция {listBoxStorages.SelectedItem.ToString() ?? string.Empty} переполнена");
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
Log.Warning($"Добавляемый объект уже существует в коллекции {listBoxStorages.SelectedItem.ToString() ?? string.Empty}");
|
||||
MessageBox.Show("Добавляемый объект уже существует в коллекции");
|
||||
}
|
||||
});
|
||||
|
||||
form.AddEvent(tankDelegate);
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRemoveTank_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null) return;
|
||||
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||
var q = obj - pos;
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxCollection.Image = obj.ShowTanks();
|
||||
Log.Information($"Удален объект из коллекции {listBoxStorages.SelectedItem.ToString() ?? string.Empty} по номеру {pos}");
|
||||
}
|
||||
catch (TankNotFoundException exception)
|
||||
{
|
||||
Log.Warning($"Не получилось удалить объект из коллекции {listBoxStorages.SelectedItem.ToString() ?? string.Empty}");
|
||||
MessageBox.Show(exception.Message);
|
||||
}
|
||||
catch (FormatException ex)
|
||||
{
|
||||
Log.Warning("Было введено не-число при удалении объекта из набора");
|
||||
MessageBox.Show("Введите число");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обновление рисунка по набору
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
|
||||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1) return;
|
||||
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null) return;
|
||||
|
||||
pictureBoxCollection.Image = obj.ShowTanks();
|
||||
}
|
||||
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_storage.SaveData(saveFileDialog.FileName);
|
||||
MessageBox.Show("Сохранение прошло успешно",
|
||||
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
Log.Information($"Файл {saveFileDialog.FileName} успешно сохранен");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Warning("Не удалось сохранить файл");
|
||||
MessageBox.Show($"Не сохранилось: {exception.Message}", "Результат",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Обработка нажатия "Загрузка"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_storage.LoadData(openFileDialog.FileName);
|
||||
MessageBox.Show("Загрузка прошла успешно",
|
||||
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
Log.Information($"Файл {openFileDialog.FileName} успешно загружен");
|
||||
foreach (var collection in _storage.Keys)
|
||||
{
|
||||
listBoxStorages.Items.Add(collection);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Warning("Не удалось загрузить");
|
||||
MessageBox.Show($"Не загрузилось: {exception.Message}", "Результат",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
129
ProjectTank/FormTankCollection.resx
Normal file
@ -0,0 +1,129 @@
|
||||
<?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>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>144, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>303, 17</value>
|
||||
</metadata>
|
||||
</root>
|
365
ProjectTank/FormTankConfig.Designer.cs
generated
Normal file
@ -0,0 +1,365 @@
|
||||
namespace ProjectTank
|
||||
{
|
||||
partial class FormTankConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
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()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
contextMenuStrip1 = new ContextMenuStrip(components);
|
||||
mainGroupBox = new GroupBox();
|
||||
labelModifiedObject = new Label();
|
||||
labelSimpleObject = new Label();
|
||||
colorsGroupBox = new GroupBox();
|
||||
bluePanel = new Panel();
|
||||
blackPanel = new Panel();
|
||||
orangePanel = new Panel();
|
||||
greenPanel = new Panel();
|
||||
redPanel = new Panel();
|
||||
purplePanel = new Panel();
|
||||
cyanPanel = new Panel();
|
||||
yellowPanel = new Panel();
|
||||
checkBoxAntiAirforceGun = new CheckBox();
|
||||
checkBoxTankTower = new CheckBox();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
weightLabel = new Label();
|
||||
speedLabel = new Label();
|
||||
mainColorLabel = new Label();
|
||||
additionalColorLabel = new Label();
|
||||
addButton = new Button();
|
||||
cancelButton = new Button();
|
||||
pictureBoxPanel = new Panel();
|
||||
pictureBoxObject = new PictureBox();
|
||||
mainGroupBox.SuspendLayout();
|
||||
colorsGroupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
pictureBoxPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// contextMenuStrip1
|
||||
//
|
||||
contextMenuStrip1.ImageScalingSize = new Size(20, 20);
|
||||
contextMenuStrip1.Name = "contextMenuStrip1";
|
||||
contextMenuStrip1.Size = new Size(61, 4);
|
||||
//
|
||||
// mainGroupBox
|
||||
//
|
||||
mainGroupBox.Controls.Add(labelModifiedObject);
|
||||
mainGroupBox.Controls.Add(labelSimpleObject);
|
||||
mainGroupBox.Controls.Add(colorsGroupBox);
|
||||
mainGroupBox.Controls.Add(checkBoxAntiAirforceGun);
|
||||
mainGroupBox.Controls.Add(checkBoxTankTower);
|
||||
mainGroupBox.Controls.Add(numericUpDownWeight);
|
||||
mainGroupBox.Controls.Add(numericUpDownSpeed);
|
||||
mainGroupBox.Controls.Add(weightLabel);
|
||||
mainGroupBox.Controls.Add(speedLabel);
|
||||
mainGroupBox.Location = new Point(12, 12);
|
||||
mainGroupBox.Name = "mainGroupBox";
|
||||
mainGroupBox.Size = new Size(610, 239);
|
||||
mainGroupBox.TabIndex = 1;
|
||||
mainGroupBox.TabStop = false;
|
||||
mainGroupBox.Text = "Параметры";
|
||||
//
|
||||
// labelModifiedObject
|
||||
//
|
||||
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelModifiedObject.Location = new Point(465, 179);
|
||||
labelModifiedObject.Name = "labelModifiedObject";
|
||||
labelModifiedObject.Size = new Size(127, 47);
|
||||
labelModifiedObject.TabIndex = 8;
|
||||
labelModifiedObject.Text = "Продвинутый";
|
||||
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelSimpleObject.Location = new Point(322, 179);
|
||||
labelSimpleObject.Name = "labelSimpleObject";
|
||||
labelSimpleObject.Size = new Size(127, 47);
|
||||
labelSimpleObject.TabIndex = 5;
|
||||
labelSimpleObject.Text = "Простой";
|
||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// colorsGroupBox
|
||||
//
|
||||
colorsGroupBox.Controls.Add(bluePanel);
|
||||
colorsGroupBox.Controls.Add(blackPanel);
|
||||
colorsGroupBox.Controls.Add(orangePanel);
|
||||
colorsGroupBox.Controls.Add(greenPanel);
|
||||
colorsGroupBox.Controls.Add(redPanel);
|
||||
colorsGroupBox.Controls.Add(purplePanel);
|
||||
colorsGroupBox.Controls.Add(cyanPanel);
|
||||
colorsGroupBox.Controls.Add(yellowPanel);
|
||||
colorsGroupBox.Location = new Point(322, 26);
|
||||
colorsGroupBox.Name = "colorsGroupBox";
|
||||
colorsGroupBox.Size = new Size(270, 145);
|
||||
colorsGroupBox.TabIndex = 2;
|
||||
colorsGroupBox.TabStop = false;
|
||||
colorsGroupBox.Text = "Цвета";
|
||||
//
|
||||
// bluePanel
|
||||
//
|
||||
bluePanel.BackColor = Color.Blue;
|
||||
bluePanel.Location = new Point(211, 84);
|
||||
bluePanel.Name = "bluePanel";
|
||||
bluePanel.Size = new Size(49, 48);
|
||||
bluePanel.TabIndex = 4;
|
||||
//
|
||||
// blackPanel
|
||||
//
|
||||
blackPanel.BackColor = Color.Black;
|
||||
blackPanel.Location = new Point(143, 84);
|
||||
blackPanel.Name = "blackPanel";
|
||||
blackPanel.Size = new Size(49, 48);
|
||||
blackPanel.TabIndex = 3;
|
||||
//
|
||||
// orangePanel
|
||||
//
|
||||
orangePanel.BackColor = Color.DarkOrange;
|
||||
orangePanel.Location = new Point(78, 84);
|
||||
orangePanel.Name = "orangePanel";
|
||||
orangePanel.Size = new Size(49, 48);
|
||||
orangePanel.TabIndex = 2;
|
||||
//
|
||||
// greenPanel
|
||||
//
|
||||
greenPanel.BackColor = Color.Lime;
|
||||
greenPanel.Location = new Point(12, 84);
|
||||
greenPanel.Name = "greenPanel";
|
||||
greenPanel.Size = new Size(49, 48);
|
||||
greenPanel.TabIndex = 1;
|
||||
//
|
||||
// redPanel
|
||||
//
|
||||
redPanel.BackColor = Color.Red;
|
||||
redPanel.Location = new Point(211, 26);
|
||||
redPanel.Name = "redPanel";
|
||||
redPanel.Size = new Size(49, 48);
|
||||
redPanel.TabIndex = 3;
|
||||
//
|
||||
// purplePanel
|
||||
//
|
||||
purplePanel.BackColor = Color.Fuchsia;
|
||||
purplePanel.Location = new Point(143, 26);
|
||||
purplePanel.Name = "purplePanel";
|
||||
purplePanel.Size = new Size(49, 48);
|
||||
purplePanel.TabIndex = 2;
|
||||
//
|
||||
// cyanPanel
|
||||
//
|
||||
cyanPanel.BackColor = Color.Cyan;
|
||||
cyanPanel.Location = new Point(78, 26);
|
||||
cyanPanel.Name = "cyanPanel";
|
||||
cyanPanel.Size = new Size(49, 48);
|
||||
cyanPanel.TabIndex = 1;
|
||||
//
|
||||
// yellowPanel
|
||||
//
|
||||
yellowPanel.BackColor = Color.Gold;
|
||||
yellowPanel.Location = new Point(12, 26);
|
||||
yellowPanel.Name = "yellowPanel";
|
||||
yellowPanel.Size = new Size(49, 48);
|
||||
yellowPanel.TabIndex = 0;
|
||||
//
|
||||
// checkBoxAntiAirforceGun
|
||||
//
|
||||
checkBoxAntiAirforceGun.AutoSize = true;
|
||||
checkBoxAntiAirforceGun.Location = new Point(17, 175);
|
||||
checkBoxAntiAirforceGun.Name = "checkBoxAntiAirforceGun";
|
||||
checkBoxAntiAirforceGun.Size = new Size(287, 24);
|
||||
checkBoxAntiAirforceGun.TabIndex = 7;
|
||||
checkBoxAntiAirforceGun.Text = "Признак наличия зенитного оружия";
|
||||
checkBoxAntiAirforceGun.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxTankTower
|
||||
//
|
||||
checkBoxTankTower.AutoSize = true;
|
||||
checkBoxTankTower.Location = new Point(17, 134);
|
||||
checkBoxTankTower.Name = "checkBoxTankTower";
|
||||
checkBoxTankTower.Size = new Size(253, 24);
|
||||
checkBoxTankTower.TabIndex = 6;
|
||||
checkBoxTankTower.Text = "Признак наличия дула и башни";
|
||||
checkBoxTankTower.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(99, 80);
|
||||
numericUpDownWeight.Maximum = new decimal(new int[] { 3000, 0, 0, 0 });
|
||||
numericUpDownWeight.Minimum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
numericUpDownWeight.Name = "numericUpDownWeight";
|
||||
numericUpDownWeight.Size = new Size(150, 27);
|
||||
numericUpDownWeight.TabIndex = 5;
|
||||
numericUpDownWeight.Value = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
numericUpDownSpeed.Location = new Point(99, 40);
|
||||
numericUpDownSpeed.Maximum = new decimal(new int[] { 300, 0, 0, 0 });
|
||||
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||
numericUpDownSpeed.Size = new Size(150, 27);
|
||||
numericUpDownSpeed.TabIndex = 4;
|
||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// weightLabel
|
||||
//
|
||||
weightLabel.AutoSize = true;
|
||||
weightLabel.Location = new Point(17, 82);
|
||||
weightLabel.Name = "weightLabel";
|
||||
weightLabel.Size = new Size(36, 20);
|
||||
weightLabel.TabIndex = 3;
|
||||
weightLabel.Text = "Вес:";
|
||||
//
|
||||
// speedLabel
|
||||
//
|
||||
speedLabel.AutoSize = true;
|
||||
speedLabel.Location = new Point(17, 42);
|
||||
speedLabel.Name = "speedLabel";
|
||||
speedLabel.Size = new Size(76, 20);
|
||||
speedLabel.TabIndex = 2;
|
||||
speedLabel.Text = "Скорость:";
|
||||
//
|
||||
// mainColorLabel
|
||||
//
|
||||
mainColorLabel.AllowDrop = true;
|
||||
mainColorLabel.BorderStyle = BorderStyle.FixedSingle;
|
||||
mainColorLabel.Location = new Point(13, 9);
|
||||
mainColorLabel.Name = "mainColorLabel";
|
||||
mainColorLabel.Size = new Size(92, 38);
|
||||
mainColorLabel.TabIndex = 9;
|
||||
mainColorLabel.Text = "Цвет";
|
||||
mainColorLabel.TextAlign = ContentAlignment.MiddleCenter;
|
||||
mainColorLabel.DragDrop += ColorLabel_DragDrop;
|
||||
mainColorLabel.DragEnter += ColorLabel_DragEnter;
|
||||
//
|
||||
// additionalColorLabel
|
||||
//
|
||||
additionalColorLabel.AllowDrop = true;
|
||||
additionalColorLabel.BorderStyle = BorderStyle.FixedSingle;
|
||||
additionalColorLabel.Location = new Point(126, 9);
|
||||
additionalColorLabel.Name = "additionalColorLabel";
|
||||
additionalColorLabel.Size = new Size(92, 38);
|
||||
additionalColorLabel.TabIndex = 10;
|
||||
additionalColorLabel.Text = "Доп. Цвет";
|
||||
additionalColorLabel.TextAlign = ContentAlignment.MiddleCenter;
|
||||
additionalColorLabel.DragDrop += ColorLabel_DragDrop;
|
||||
additionalColorLabel.DragEnter += ColorLabel_DragEnter;
|
||||
//
|
||||
// addButton
|
||||
//
|
||||
addButton.Location = new Point(632, 222);
|
||||
addButton.Name = "addButton";
|
||||
addButton.Size = new Size(94, 29);
|
||||
addButton.TabIndex = 11;
|
||||
addButton.Text = "Добавить";
|
||||
addButton.UseVisualStyleBackColor = true;
|
||||
addButton.Click += ButtonOk_Click;
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
cancelButton.Location = new Point(769, 222);
|
||||
cancelButton.Name = "cancelButton";
|
||||
cancelButton.Size = new Size(94, 29);
|
||||
cancelButton.TabIndex = 12;
|
||||
cancelButton.Text = "Отмена";
|
||||
cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// pictureBoxPanel
|
||||
//
|
||||
pictureBoxPanel.AllowDrop = true;
|
||||
pictureBoxPanel.Controls.Add(pictureBoxObject);
|
||||
pictureBoxPanel.Controls.Add(mainColorLabel);
|
||||
pictureBoxPanel.Controls.Add(additionalColorLabel);
|
||||
pictureBoxPanel.Location = new Point(628, 22);
|
||||
pictureBoxPanel.Name = "pictureBoxPanel";
|
||||
pictureBoxPanel.Size = new Size(235, 189);
|
||||
pictureBoxPanel.TabIndex = 9;
|
||||
pictureBoxPanel.DragDrop += PanelObject_DragDrop;
|
||||
pictureBoxPanel.DragEnter += PanelObject_DragEnter;
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
pictureBoxObject.Location = new Point(13, 60);
|
||||
pictureBoxObject.Name = "pictureBoxObject";
|
||||
pictureBoxObject.Size = new Size(205, 117);
|
||||
pictureBoxObject.TabIndex = 13;
|
||||
pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// FormTankConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(875, 267);
|
||||
Controls.Add(pictureBoxPanel);
|
||||
Controls.Add(cancelButton);
|
||||
Controls.Add(addButton);
|
||||
Controls.Add(mainGroupBox);
|
||||
Name = "FormTankConfig";
|
||||
Text = "Настройка конфигурации танка";
|
||||
mainGroupBox.ResumeLayout(false);
|
||||
mainGroupBox.PerformLayout();
|
||||
colorsGroupBox.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||
pictureBoxPanel.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ContextMenuStrip contextMenuStrip1;
|
||||
private GroupBox mainGroupBox;
|
||||
private CheckBox checkBoxAntiAirforceGun;
|
||||
private CheckBox checkBoxTankTower;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private Label weightLabel;
|
||||
private Label speedLabel;
|
||||
private GroupBox colorsGroupBox;
|
||||
private Panel redPanel;
|
||||
private Panel purplePanel;
|
||||
private Panel cyanPanel;
|
||||
private Panel yellowPanel;
|
||||
private Panel greenPanel;
|
||||
private Panel bluePanel;
|
||||
private Panel blackPanel;
|
||||
private Panel orangePanel;
|
||||
private Label labelSimpleObject;
|
||||
private Label labelModifiedObject;
|
||||
private Label mainColorLabel;
|
||||
private Label additionalColorLabel;
|
||||
private Button addButton;
|
||||
private Button cancelButton;
|
||||
private Panel pictureBoxPanel;
|
||||
private PictureBox pictureBoxObject;
|
||||
}
|
||||
}
|
156
ProjectTank/FormTankConfig.cs
Normal file
@ -0,0 +1,156 @@
|
||||
using ProjectTank.DrawningObjects;
|
||||
|
||||
namespace ProjectTank
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма создания объекта
|
||||
/// </summary>
|
||||
public partial class FormTankConfig : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Переменная-выбранный танк
|
||||
/// </summary>
|
||||
DrawningTankBase? _tank = null;
|
||||
/// <summary>
|
||||
/// Событие
|
||||
/// </summary>
|
||||
private event Action<DrawningTankBase>? EventAddTank;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormTankConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
yellowPanel.MouseDown += PanelColor_MouseDown;
|
||||
cyanPanel.MouseDown += PanelColor_MouseDown;
|
||||
purplePanel.MouseDown += PanelColor_MouseDown;
|
||||
redPanel.MouseDown += PanelColor_MouseDown;
|
||||
greenPanel.MouseDown += PanelColor_MouseDown;
|
||||
orangePanel.MouseDown += PanelColor_MouseDown;
|
||||
blackPanel.MouseDown += PanelColor_MouseDown;
|
||||
bluePanel.MouseDown += PanelColor_MouseDown;
|
||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||
cancelButton.Click += (s, e) => Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// Отрисовать танк
|
||||
/// </summary>
|
||||
private void DrawTank()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_tank?.SetPosition(5, 5);
|
||||
_tank?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление события
|
||||
/// </summary>
|
||||
/// <param name="ev">Привязанный метод</param>
|
||||
public void AddEvent(Action<DrawningTankBase> ev)
|
||||
{
|
||||
if (EventAddTank == null) EventAddTank = ev;
|
||||
else EventAddTank += ev;
|
||||
}
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Передаем информацию при нажатии на Label
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name,
|
||||
DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
/// <summary>
|
||||
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Действия при приеме перетаскиваемой информации
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "labelSimpleObject":
|
||||
_tank = new DrawningTankBase((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
||||
pictureBoxObject.Height);
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
_tank = new DrawningTank((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxTankTower.Checked,
|
||||
checkBoxAntiAirforceGun.Checked, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
break;
|
||||
}
|
||||
|
||||
mainColorLabel.BackColor = Color.Empty;
|
||||
additionalColorLabel.BackColor = Color.Empty;
|
||||
DrawTank();
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление танка
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddTank?.Invoke(_tank);
|
||||
Close();
|
||||
}
|
||||
private void ColorLabel_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
string senderName = ((Label)sender).Name;
|
||||
if (_tank == null || e.Data.GetDataPresent(typeof(Color)) == false)
|
||||
return;
|
||||
|
||||
Color droppedColor = (Color)e.Data.GetData(typeof(Color));
|
||||
|
||||
if (senderName == "mainColorLabel")
|
||||
{
|
||||
mainColorLabel.BackColor = droppedColor;
|
||||
((DrawningTankBase)_tank).ChangeColor(mainColorLabel.BackColor);
|
||||
}
|
||||
else if (senderName == "additionalColorLabel" && _tank is DrawningTank)
|
||||
{
|
||||
additionalColorLabel.BackColor = droppedColor;
|
||||
((DrawningTank)_tank).ChangeAdditionalColor(additionalColorLabel.BackColor);
|
||||
}
|
||||
|
||||
DrawTank();
|
||||
}
|
||||
private void ColorLabel_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
123
ProjectTank/FormTankConfig.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?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>
|
||||
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
53
ProjectTank/Generics/DrawningTankBaseEqutables.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using ProjectTank.DrawningObjects;
|
||||
using ProjectTank.Entities;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace ProjectTank.Generics
|
||||
{
|
||||
internal class DrawningTankBaseEqutables : IEqualityComparer<DrawningTankBase?>
|
||||
{
|
||||
public bool Equals(DrawningTankBase? x, DrawningTankBase? y)
|
||||
{
|
||||
if (x == null || x.EntityTankBase == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
}
|
||||
if (y == null || y.EntityTankBase == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
}
|
||||
if (x.GetType().Name != y.GetType().Name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (x.EntityTankBase.Speed != y.EntityTankBase.Speed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (x.EntityTankBase.Weight != y.EntityTankBase.Weight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (x.EntityTankBase.BodyColor != y.EntityTankBase.BodyColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (x is DrawningTank && y is DrawningTank)
|
||||
{
|
||||
EntityTank EntityX = (EntityTank)x.EntityTankBase;
|
||||
EntityTank EntityY = (EntityTank)y.EntityTankBase;
|
||||
if (EntityX.AntiAirforceGun != EntityY.AntiAirforceGun)
|
||||
return false;
|
||||
if (EntityX.TankTower != EntityY.TankTower)
|
||||
return false;
|
||||
if (EntityX.AdditionalColor != EntityY.AdditionalColor)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public int GetHashCode([DisallowNull] DrawningTankBase obj)
|
||||
{
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
107
ProjectTank/Generics/SetGeneric.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using ProjectTank.Exceptions;
|
||||
|
||||
namespace ProjectTank.Generics
|
||||
{
|
||||
/// <summary>
|
||||
/// Параметризованный набор объектов
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
internal class SetGeneric<T> where T : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Массив объектов, которые храним
|
||||
/// </summary>
|
||||
private readonly List<T?> _places;
|
||||
/// <summary>
|
||||
/// Количество объектов в массиве
|
||||
/// </summary>
|
||||
public int Count => _places.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
private readonly int _maxCount;
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_maxCount = count;
|
||||
_places = new List<T?>(count);
|
||||
}
|
||||
public void SortSet(IComparer<T?> comparer) => _places.Sort(comparer);
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
/// </summary>
|
||||
/// <param name="tank">Добавляемый танк</param>
|
||||
/// <returns></returns>
|
||||
public bool Insert(T tank, IEqualityComparer<T>? equal = null)
|
||||
{
|
||||
if (_places.Count == _maxCount)
|
||||
throw new StorageOverflowException(_maxCount);
|
||||
|
||||
Insert(tank, 0, equal);
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор на конкретную позицию
|
||||
/// </summary>
|
||||
/// <param name="tank">Добавляемый танк</param>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns></returns>
|
||||
public bool Insert(T tank, int position, IEqualityComparer<T>? equal = null)
|
||||
{
|
||||
if (_places.Count == _maxCount)
|
||||
throw new StorageOverflowException(_maxCount);
|
||||
if (!(position >= 0 && position <= Count))
|
||||
return false;
|
||||
if (equal != null)
|
||||
{
|
||||
if (_places.Contains(tank, equal))
|
||||
throw new ArgumentException(nameof(tank));
|
||||
}
|
||||
_places.Insert(position, tank);
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора с конкретной позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public bool Remove(int position)
|
||||
{
|
||||
if (!(position >= 0 && position < Count))
|
||||
throw new TankNotFoundException(position);
|
||||
_places.RemoveAt(position);
|
||||
return true;
|
||||
}
|
||||
|
||||
public T? this[int position]
|
||||
{
|
||||
get {
|
||||
if (!(position >= 0 && position < Count))
|
||||
return null;
|
||||
return _places[position];
|
||||
}
|
||||
set {
|
||||
if (!(position >= 0 && position < Count && _places.Count < _maxCount))
|
||||
return;
|
||||
_places.Insert(position, value);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение объекта из набора по позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<T?> GetTanks(int? maxTanks = null)
|
||||
{
|
||||
for (int i = 0; i < _places.Count; ++i)
|
||||
{
|
||||
yield return _places[i];
|
||||
if (maxTanks.HasValue && i == maxTanks.Value)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
42
ProjectTank/Generics/TankCompareByColor.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using ProjectTank.DrawningObjects;
|
||||
using ProjectTank.Entities;
|
||||
|
||||
namespace ProjectTank.Generics
|
||||
{
|
||||
internal class TankCompareByColor : IComparer<DrawningTankBase?>
|
||||
{
|
||||
public int Compare(DrawningTankBase? x, DrawningTankBase? y)
|
||||
{
|
||||
if (x == null || x.EntityTankBase == null)
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
|
||||
if (y == null || y.EntityTankBase == null)
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
|
||||
if (x.EntityTankBase.BodyColor.Name != y.EntityTankBase.BodyColor.Name)
|
||||
{
|
||||
return x.EntityTankBase.BodyColor.Name.CompareTo(y.EntityTankBase.BodyColor.Name);
|
||||
}
|
||||
if (x.GetType().Name != y.GetType().Name)
|
||||
{
|
||||
if (x is DrawningTankBase) return -1;
|
||||
else return 1;
|
||||
}
|
||||
if (x.GetType().Name == y.GetType().Name && x is DrawningTank)
|
||||
{
|
||||
EntityTank EntityX = (EntityTank)x.EntityTankBase;
|
||||
EntityTank EntityY = (EntityTank)y.EntityTankBase;
|
||||
if (EntityX.AdditionalColor.Name != EntityY.AdditionalColor.Name)
|
||||
{
|
||||
return EntityX.AdditionalColor.Name.CompareTo(EntityY.AdditionalColor.Name);
|
||||
}
|
||||
}
|
||||
var speedCompare = x.EntityTankBase.Speed.CompareTo(y.EntityTankBase.Speed);
|
||||
|
||||
if (speedCompare != 0)
|
||||
return speedCompare;
|
||||
|
||||
return x.EntityTankBase.Weight.CompareTo(y.EntityTankBase.Weight);
|
||||
}
|
||||
}
|
||||
}
|
29
ProjectTank/Generics/TankCompareByType.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using ProjectTank.DrawningObjects;
|
||||
|
||||
namespace ProjectTank.Generics
|
||||
{
|
||||
internal class TankCompareByType : IComparer<DrawningTankBase?>
|
||||
{
|
||||
public int Compare(DrawningTankBase? x, DrawningTankBase? y)
|
||||
{
|
||||
if (x == null || x.EntityTankBase == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
}
|
||||
if (y == null || y.EntityTankBase == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
}
|
||||
if (x.GetType().Name != y.GetType().Name)
|
||||
{
|
||||
return x.GetType().Name.CompareTo(y.GetType().Name);
|
||||
}
|
||||
var speedCompare = x.EntityTankBase.Speed.CompareTo(y.EntityTankBase.Speed);
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
return speedCompare;
|
||||
}
|
||||
return x.EntityTankBase.Weight.CompareTo(y.EntityTankBase.Weight);
|
||||
}
|
||||
}
|
||||
}
|
22
ProjectTank/Generics/TanksCollectionInfo.cs
Normal file
@ -0,0 +1,22 @@
|
||||
namespace ProjectTank.Generics
|
||||
{
|
||||
internal class TanksCollectionInfo : IEquatable<TanksCollectionInfo>
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public string Description { get; private set; }
|
||||
public TanksCollectionInfo(string name, string description)
|
||||
{
|
||||
Name = name;
|
||||
Description = description;
|
||||
}
|
||||
public bool Equals(TanksCollectionInfo? other)
|
||||
{
|
||||
if (other == null) return false;
|
||||
return Name == other.Name;
|
||||
}
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return this.Name.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
144
ProjectTank/Generics/TanksGenericCollection.cs
Normal file
@ -0,0 +1,144 @@
|
||||
using ProjectTank.DrawningObjects;
|
||||
using ProjectTank.MovementStrategy;
|
||||
|
||||
namespace ProjectTank.Generics
|
||||
{
|
||||
/// <summary>
|
||||
/// Параметризованный класс для набора объектов DrawningTankBase
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="U"></typeparam>
|
||||
internal class TanksGenericCollection<T, U> where T : DrawningTankBase where U : IMoveableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Ширина окна прорисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна прорисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureHeight;
|
||||
/// <summary>
|
||||
/// Размер занимаемого объектом места (ширина)
|
||||
/// </summary>
|
||||
private readonly int _placeSizeWidth = 150;
|
||||
/// <summary>
|
||||
/// Размер занимаемого объектом места (высота)
|
||||
/// </summary>
|
||||
private readonly int _placeSizeHeight = 100;
|
||||
/// <summary>
|
||||
/// Набор объектов
|
||||
/// </summary>
|
||||
private readonly SetGeneric<T> _collection;
|
||||
/// <summary>
|
||||
/// Получение объектов коллекции
|
||||
/// </summary>
|
||||
public IEnumerable<T?> GetTanks => _collection.GetTanks();
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="picWidth"></param>
|
||||
/// <param name="picHeight"></param>
|
||||
public TanksGenericCollection(int picWidth, int picHeight)
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_collection = new SetGeneric<T>(width * height);
|
||||
}
|
||||
/// <summary>
|
||||
/// Сортировка
|
||||
/// </summary>
|
||||
/// <param name="comparer"></param>
|
||||
public void Sort(IComparer<T?> comparer) => _collection.SortSet(comparer);
|
||||
/// <summary>
|
||||
/// Перегрузка оператора сложения
|
||||
/// </summary>
|
||||
/// <param name="collect"></param>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static bool operator +(TanksGenericCollection<T,U> collect, T? obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
||||
return collect?._collection.Insert(obj, new DrawningTankBaseEqutables()) ?? false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора вычитания
|
||||
/// </summary>
|
||||
/// <param name="collect"></param>
|
||||
/// <param name="pos"></param>
|
||||
/// <returns></returns>
|
||||
public static T? operator -(TanksGenericCollection<T, U> collect, int
|
||||
pos)
|
||||
{
|
||||
T? obj = collect._collection[pos];
|
||||
collect._collection.Remove(pos);
|
||||
return obj;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение объекта IMoveableObject
|
||||
/// </summary>
|
||||
/// <param name="pos"></param>
|
||||
/// <returns></returns>
|
||||
public U? GetU(int pos)
|
||||
{
|
||||
return (U?)_collection[pos]?.GetMoveableObject;
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод всего набора объектов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Bitmap ShowTanks()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
DrawBackground(gr);
|
||||
DrawObjects(gr);
|
||||
return bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод отрисовки фона
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
private void DrawBackground(Graphics g)
|
||||
{
|
||||
Pen pen = new(Color.Black, 3);
|
||||
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
||||
{
|
||||
//линия рамзетки места
|
||||
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
|
||||
}
|
||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод прорисовки объектов
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
private void DrawObjects(Graphics g)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var tank in _collection.GetTanks())
|
||||
{
|
||||
if (tank != null)
|
||||
{
|
||||
int columnsCount = _pictureHeight / _placeSizeHeight + 1;
|
||||
|
||||
int colIndex = i % columnsCount;
|
||||
int rowIndex = i / columnsCount;
|
||||
|
||||
tank.SetPosition(colIndex * _placeSizeWidth + 2, rowIndex * _placeSizeHeight + 2);
|
||||
tank.DrawTransport(g);
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
189
ProjectTank/Generics/TanksGenericStorage.cs
Normal file
@ -0,0 +1,189 @@
|
||||
using ProjectTank.DrawningObjects;
|
||||
using ProjectTank.Drawnings;
|
||||
using ProjectTank.MovementStrategy;
|
||||
using System.Text;
|
||||
|
||||
namespace ProjectTank.Generics
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс для хранения коллекции
|
||||
/// </summary>
|
||||
internal class TanksGenericStorage
|
||||
{
|
||||
/// <summary>
|
||||
/// Словарь (хранилище)
|
||||
/// </summary>
|
||||
readonly Dictionary<TanksCollectionInfo,
|
||||
TanksGenericCollection<DrawningTankBase, DrawningObjectTank>> _tankStorages;
|
||||
/// <summary>
|
||||
/// Возвращение списка названий наборов
|
||||
/// </summary>
|
||||
public List<TanksCollectionInfo> Keys => _tankStorages.Keys.ToList();
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureHeight;
|
||||
/// <summary>
|
||||
/// Разделитель для записи ключа и значения элемента словаря
|
||||
/// </summary>
|
||||
private static readonly char _separatorForKeyValue = '|';
|
||||
/// <summary>
|
||||
/// Разделитель для записей коллекции данных в файл
|
||||
/// </summary>
|
||||
private readonly char _separatorRecords = ';';
|
||||
/// <summary>
|
||||
/// Разделитель для записи информации по объекту в файл
|
||||
/// </summary>
|
||||
private static readonly char _separatorForObject = ':';
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="pictureWidth"></param>
|
||||
/// <param name="pictureHeight"></param>
|
||||
public TanksGenericStorage(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_tankStorages = new Dictionary<TanksCollectionInfo,
|
||||
TanksGenericCollection<DrawningTankBase, DrawningObjectTank>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление набора
|
||||
/// </summary>
|
||||
/// <param name="name">Название набора</param>
|
||||
public void AddSet(string name)
|
||||
{
|
||||
_tankStorages.Add(new TanksCollectionInfo(name, string.Empty),
|
||||
new TanksGenericCollection<DrawningTankBase, DrawningObjectTank>(_pictureWidth, _pictureHeight));
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление набора
|
||||
/// </summary>
|
||||
/// <param name="name">Название набора</param>
|
||||
public void DelSet(string name)
|
||||
{
|
||||
if (!_tankStorages.ContainsKey(new TanksCollectionInfo(name, string.Empty)))
|
||||
return;
|
||||
_tankStorages.Remove(new TanksCollectionInfo(name, string.Empty));
|
||||
}
|
||||
/// <summary>
|
||||
/// Доступ к набору
|
||||
/// </summary>
|
||||
/// <param name="ind"></param>
|
||||
/// <returns></returns>
|
||||
public TanksGenericCollection<DrawningTankBase, DrawningObjectTank>? this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
TanksCollectionInfo indObj = new TanksCollectionInfo(ind, string.Empty);
|
||||
if (_tankStorages.ContainsKey(indObj))
|
||||
return _tankStorages[indObj];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Сохранение информации по автомобилям в хранилище в файл
|
||||
/// </summary>
|
||||
/// <param name="filename">Путь и имя файла</param>
|
||||
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
|
||||
public bool SaveData(string filename)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
File.Delete(filename);
|
||||
}
|
||||
StringBuilder data = new();
|
||||
foreach (KeyValuePair<TanksCollectionInfo, TanksGenericCollection<DrawningTankBase, DrawningObjectTank>> record in _tankStorages)
|
||||
{
|
||||
StringBuilder records = new();
|
||||
foreach (DrawningTankBase? elem in record.Value.GetTanks)
|
||||
{
|
||||
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
||||
}
|
||||
data.AppendLine($"{record.Key.Name}{_separatorForKeyValue}{records}");
|
||||
}
|
||||
|
||||
if (data.Length == 0)
|
||||
{
|
||||
throw new Exception("Невалидная операция, нет данных для сохранения");
|
||||
}
|
||||
|
||||
string toWrite = $"TanksStorage{Environment.NewLine}{data}";
|
||||
var strs = toWrite.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
using (StreamWriter sw = new(filename))
|
||||
{
|
||||
foreach (var str in strs)
|
||||
{
|
||||
sw.WriteLine(str);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Загрузка информации по танкам в хранилище из файла
|
||||
/// </summary>
|
||||
/// <param name="filename">Путь и имя файла</param>
|
||||
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
||||
public bool LoadData(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
throw new IOException("Файл не найден");
|
||||
}
|
||||
|
||||
using (StreamReader sr = new(filename))
|
||||
{
|
||||
string str = sr.ReadLine();
|
||||
var strs = str.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (strs == null || strs.Length == 0)
|
||||
{
|
||||
throw new IOException("Нет данных для загрузки");
|
||||
}
|
||||
|
||||
if (!strs[0].StartsWith("TanksStorage"))
|
||||
{
|
||||
//если нет такой записи, то это не те данные
|
||||
throw new IOException("Неверный формат данных");
|
||||
}
|
||||
|
||||
_tankStorages.Clear();
|
||||
|
||||
do
|
||||
{
|
||||
string[] record = str.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (record.Length != 2)
|
||||
{
|
||||
str = sr.ReadLine();
|
||||
continue;
|
||||
}
|
||||
TanksGenericCollection<DrawningTankBase, DrawningObjectTank> collection = new(_pictureWidth, _pictureHeight);
|
||||
string[] set = record[1].Split(_separatorRecords,
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string elem in set)
|
||||
{
|
||||
DrawningTankBase? tank =
|
||||
elem?.CreateDrawningTankBase(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||
if (tank != null)
|
||||
{
|
||||
if (!(collection + tank))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
_tankStorages.Add(new TanksCollectionInfo(record[0], string.Empty), collection);
|
||||
|
||||
str = sr.ReadLine();
|
||||
} while (str != null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
129
ProjectTank/MovementStrategy/AbstractStrategy.cs
Normal file
@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace ProjectTank.MovementStrategy
|
||||
{
|
||||
public abstract class AbstractStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Перемещаемый объект
|
||||
/// </summary>
|
||||
private IMoveableObject? _moveableObject;
|
||||
/// <summary>
|
||||
/// Статус перемещения
|
||||
/// </summary>
|
||||
private Status _state = Status.NotInit;
|
||||
/// <summary>
|
||||
/// Ширина поля
|
||||
/// </summary>
|
||||
protected int FieldWidth { get; private set; }
|
||||
/// <summary>
|
||||
/// Высота поля
|
||||
/// </summary>
|
||||
protected int FieldHeight { get; private set; }
|
||||
/// <summary>
|
||||
/// Статус перемещения
|
||||
/// </summary>
|
||||
public Status GetStatus() { return _state; }
|
||||
/// <summary>
|
||||
/// Установка данных
|
||||
/// </summary>
|
||||
/// <param name="moveableObject">Перемещаемый объект</param>
|
||||
/// <param name="width">Ширина поля</param>
|
||||
/// <param name="height">Высота поля</param>
|
||||
public void SetData(IMoveableObject moveableObject, int width, int
|
||||
height)
|
||||
{
|
||||
if (moveableObject == null)
|
||||
{
|
||||
_state = Status.NotInit;
|
||||
return;
|
||||
}
|
||||
_state = Status.InProgress;
|
||||
_moveableObject = moveableObject;
|
||||
FieldWidth = width;
|
||||
FieldHeight = height;
|
||||
}
|
||||
/// <summary>
|
||||
/// Шаг перемещения
|
||||
/// </summary>
|
||||
public void MakeStep()
|
||||
{
|
||||
if (_state != Status.InProgress) return;
|
||||
if (IsTargetDestination())
|
||||
{
|
||||
_state = Status.Finish;
|
||||
return;
|
||||
}
|
||||
MoveToTarget();
|
||||
}
|
||||
/// <summary>
|
||||
/// Перемещение влево
|
||||
/// </summary>
|
||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
||||
protected bool MoveLeft() => MoveTo(DirectionType.Left);
|
||||
/// <summary>
|
||||
/// Перемещение вправо
|
||||
/// </summary>
|
||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
||||
protected bool MoveRight() => MoveTo(DirectionType.Right);
|
||||
/// <summary>
|
||||
/// Перемещение вверх
|
||||
/// </summary>
|
||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
||||
protected bool MoveUp() => MoveTo(DirectionType.Up);
|
||||
/// <summary>
|
||||
/// Перемещение вниз
|
||||
/// </summary>
|
||||
/// <returns>Результат перемещения (true - удалось переместиться,false - неудача)</returns>
|
||||
protected bool MoveDown() => MoveTo(DirectionType.Down);
|
||||
/// <summary>
|
||||
/// Параметры объекта
|
||||
/// </summary>
|
||||
protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
|
||||
/// <summary>
|
||||
/// Шаг объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected int? GetStep()
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _moveableObject?.GetStep;
|
||||
}
|
||||
/// <summary>
|
||||
/// Перемещение к цели
|
||||
/// </summary>
|
||||
protected abstract void MoveToTarget();
|
||||
/// <summary>
|
||||
/// Достигнута ли цель
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected abstract bool IsTargetDestination();
|
||||
/// <summary>
|
||||
/// Попытка перемещения в требуемом направлении
|
||||
/// </summary>
|
||||
/// <param name="directionType">Направление</param>
|
||||
/// <returns>Результат попытки (true - удалось переместиться, false - неудача)
|
||||
/// </returns>
|
||||
private bool MoveTo(DirectionType directionType)
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_moveableObject?.CheckCanMove(directionType) ?? false)
|
||||
{
|
||||
_moveableObject.MoveObject(directionType);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
31
ProjectTank/MovementStrategy/DrawningObjectTank.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using ProjectTank.DrawningObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectTank.MovementStrategy
|
||||
{
|
||||
public class DrawningObjectTank : IMoveableObject
|
||||
{
|
||||
private readonly DrawningTankBase? DrawningTankBase = null;
|
||||
public DrawningObjectTank(DrawningTankBase drawningTankBase)
|
||||
{
|
||||
DrawningTankBase = drawningTankBase;
|
||||
}
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (DrawningTankBase == null || DrawningTankBase.EntityTankBase == null) return null;
|
||||
|
||||
return new ObjectParameters(DrawningTankBase.GetPosX,
|
||||
DrawningTankBase.GetPosY, DrawningTankBase.GetWidth, DrawningTankBase.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(DrawningTankBase?.EntityTankBase?.Step ?? 0);
|
||||
public bool CheckCanMove(DirectionType direction) => DrawningTankBase?.CanMove(direction) ?? false;
|
||||
public void MoveObject(DirectionType direction) => DrawningTankBase?.MoveTransport(direction);
|
||||
}
|
||||
}
|
26
ProjectTank/MovementStrategy/IMoveableObject.cs
Normal file
@ -0,0 +1,26 @@
|
||||
namespace ProjectTank.MovementStrategy
|
||||
{
|
||||
public interface IMoveableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Получение координаты X объекта
|
||||
/// </summary>
|
||||
ObjectParameters? GetObjectPosition { get; }
|
||||
/// <summary>
|
||||
/// Шаг объекта
|
||||
/// </summary>
|
||||
int GetStep { get; }
|
||||
/// <summary>
|
||||
/// Проверка, можно ли переместиться по нужному направлению
|
||||
/// </summary>
|
||||
/// <param name="direction"></param>
|
||||
/// <returns></returns>
|
||||
bool CheckCanMove(DirectionType direction);
|
||||
/// <summary>
|
||||
/// Изменение направления пермещения объекта
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
void MoveObject(DirectionType direction);
|
||||
}
|
||||
|
||||
}
|
40
ProjectTank/MovementStrategy/MoveToCenter.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectTank.MovementStrategy
|
||||
{
|
||||
public class MoveToCenter : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDestination()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null) return false;
|
||||
|
||||
return objParams.ObjectMiddleHorizontal <= FieldWidth / 2 &&
|
||||
objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
|
||||
objParams.ObjectMiddleVertical <= FieldHeight / 2 &&
|
||||
objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
|
||||
}
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null) return;
|
||||
|
||||
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
|
||||
if (Math.Abs(diffX) > GetStep())
|
||||
{
|
||||
if (diffX > 0) MoveLeft();
|
||||
else MoveRight();
|
||||
}
|
||||
var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
if (diffY > 0) MoveUp();
|
||||
else MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
40
ProjectTank/MovementStrategy/MoveToRightBottomCorner.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectTank.MovementStrategy
|
||||
{
|
||||
public class MoveToRightBottomCorner : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDestination()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null) return false;
|
||||
|
||||
return objParams.RightBorder <= FieldWidth && objParams.RightBorder + GetStep() > FieldWidth &&
|
||||
objParams.DownBorder <= FieldHeight && objParams.DownBorder + GetStep() > FieldHeight;
|
||||
}
|
||||
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null) return;
|
||||
|
||||
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth;
|
||||
if (Math.Abs(diffX) > GetStep())
|
||||
{
|
||||
if (diffX > 0) MoveLeft();
|
||||
else MoveRight();
|
||||
}
|
||||
|
||||
var diffY = objParams.ObjectMiddleVertical - FieldHeight;
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
if (diffY > 0) MoveUp();
|
||||
else MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
56
ProjectTank/MovementStrategy/ObjectParameters.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectTank.MovementStrategy
|
||||
{
|
||||
/// </summary>
|
||||
public class ObjectParameters
|
||||
{
|
||||
private readonly int _x;
|
||||
private readonly int _y;
|
||||
private readonly int _width;
|
||||
private readonly int _height;
|
||||
/// <summary>
|
||||
/// Левая граница
|
||||
/// </summary>
|
||||
public int LeftBorder => _x;
|
||||
/// <summary>
|
||||
/// Верхняя граница
|
||||
/// </summary>
|
||||
public int TopBorder => _y;
|
||||
/// <summary>
|
||||
/// Правая граница
|
||||
/// </summary>
|
||||
public int RightBorder => _x + _width;
|
||||
/// <summary>
|
||||
/// Нижняя граница
|
||||
/// </summary>
|
||||
public int DownBorder => _y + _height;
|
||||
/// <summary>
|
||||
/// Середина объекта
|
||||
/// </summary>
|
||||
public int ObjectMiddleHorizontal => _x + _width / 2;
|
||||
/// <summary>
|
||||
/// Середина объекта
|
||||
/// </summary>
|
||||
public int ObjectMiddleVertical => _y + _height / 2;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="x">Координата X</param>
|
||||
/// <param name="y">Координата Y</param>
|
||||
/// <param name="width">Ширина</param>
|
||||
/// <param name="height">Высота</param>
|
||||
public ObjectParameters(int x, int y, int width, int height)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
15
ProjectTank/MovementStrategy/Status.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectTank.MovementStrategy
|
||||
{
|
||||
public enum Status
|
||||
{
|
||||
NotInit = 1,
|
||||
InProgress = 2,
|
||||
Finish = 3
|
||||
}
|
||||
}
|
36
ProjectTank/Program.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.VisualBasic.Logging;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
using Serilog.Formatting.Json;
|
||||
using Log = Serilog.Log;
|
||||
|
||||
namespace ProjectTank
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.WriteTo.File("log.txt")
|
||||
.MinimumLevel.Debug()
|
||||
.CreateLogger();
|
||||
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new FormTankCollection());
|
||||
}
|
||||
}
|
||||
}
|
18
ProjectTank/ProjectTank.csproj
Normal file
@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.5" />
|
||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
103
ProjectTank/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ProjectTank.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||
/// </summary>
|
||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||
// с помощью такого средства, как ResGen или Visual Studio.
|
||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||
// с параметром /str или перестройте свой проект VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectTank.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowDown {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowDown", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap icons8_left_arrow_40 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("icons8-left-arrow-40", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap icons8_right_arrow_40 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("icons8-right-arrow-40", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap icons8_up_arrow_40 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("icons8-up-arrow-40", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
ProjectTank/Properties/Resources.resx
Normal file
@ -0,0 +1,133 @@
|
||||
<?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>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="arrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-down-arrow-50.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icons8-left-arrow-40" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-left-arrow-40.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icons8-right-arrow-40" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-right-arrow-40.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icons8-up-arrow-40" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-up-arrow-40.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
ProjectTank/Resources/icons8-down-arrow-30.png
Normal file
After Width: | Height: | Size: 263 B |
BIN
ProjectTank/Resources/icons8-down-arrow-40.png
Normal file
After Width: | Height: | Size: 334 B |
BIN
ProjectTank/Resources/icons8-down-arrow-50.png
Normal file
After Width: | Height: | Size: 392 B |
BIN
ProjectTank/Resources/icons8-left-arrow-40.png
Normal file
After Width: | Height: | Size: 235 B |
BIN
ProjectTank/Resources/icons8-right-arrow-40.png
Normal file
After Width: | Height: | Size: 245 B |
BIN
ProjectTank/Resources/icons8-up-40.png
Normal file
After Width: | Height: | Size: 262 B |
BIN
ProjectTank/Resources/icons8-up-arrow-40.png
Normal file
After Width: | Height: | Size: 363 B |
BIN
ProjectTank/Resources/pngwing.com.png
Normal file
After Width: | Height: | Size: 33 KiB |