commit
This commit is contained in:
parent
0ed1f29f97
commit
3a7a9170a6
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Tank;
|
namespace Tank;
|
||||||
|
|
||||||
public class DrawningtTank
|
public class DrawningTank
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Класс-сущность
|
/// Класс-сущность
|
||||||
@ -31,11 +31,11 @@ public class DrawningtTank
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина прорисовки автомобиля
|
/// Ширина прорисовки автомобиля
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _drawningCarWidth = 110;
|
private readonly int _drawningTankWidth = 145;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота прорисовки автомобиля
|
/// Высота прорисовки автомобиля
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _drawningCarHeight = 60;
|
private readonly int _drawningTankHeight = 105;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Инициализация свойств
|
/// Инициализация свойств
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -43,15 +43,13 @@ public class DrawningtTank
|
|||||||
/// <param name="weight">Вес</param>
|
/// <param name="weight">Вес</param>
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
/// <param name="bodyColor">Основной цвет</param>
|
||||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||||
/// <param name="bodyKit">Признак наличия обвеса</param>
|
/// <param name="pushka">Признак наличия обвеса</param>
|
||||||
/// <param name="wing">Признак наличия антикрыла</param>
|
/// <param name="pulemet">Признак наличия антикрыла</param>
|
||||||
/// <param name="sportLine">Признак наличия гоночной полосы</param>
|
|
||||||
public void Init(int speed, double weight, Color bodyColor, Color
|
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool pushka, bool pulemet)
|
||||||
additionalColor, bool bodyKit, bool wing, bool sportLine)
|
|
||||||
{
|
{
|
||||||
EntityTank = new EntityTank();
|
EntityTank = new EntityTank();
|
||||||
EntityTank.Init(speed, weight, bodyColor, additionalColor,
|
EntityTank.Init(speed, weight, bodyColor, additionalColor,pushka, pulemet);
|
||||||
bodyKit, wing, sportLine);
|
|
||||||
_pictureWidth = null;
|
_pictureWidth = null;
|
||||||
_pictureHeight = null;
|
_pictureHeight = null;
|
||||||
_startPosX = null;
|
_startPosX = null;
|
||||||
@ -63,13 +61,33 @@ public class DrawningtTank
|
|||||||
/// <param name="width">Ширина поля</param>
|
/// <param name="width">Ширина поля</param>
|
||||||
/// <param name="height">Высота поля</param>
|
/// <param name="height">Высота поля</param>
|
||||||
/// <returns>true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах</returns>
|
/// <returns>true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах</returns>
|
||||||
public bool SetPictureSize(int width, int height)
|
/// <summary>
|
||||||
|
/// Установка границ поля
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="width">Ширина поля</param>
|
||||||
|
/// <param name="height">Высота поля</param>
|
||||||
|
/// <returns>true - границы заданы, false - проверка не пройдена, нельзя
|
||||||
|
public bool SetPictureSize(int width, int height)
|
||||||
{
|
{
|
||||||
// TODO проверка, что объект "влезает" в размеры поля
|
if (_drawningTankWidth <= width && _drawningTankHeight <= height)
|
||||||
// если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена
|
{
|
||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
return true;
|
if (_startPosX.HasValue && _startPosY.HasValue)
|
||||||
|
{
|
||||||
|
if (_startPosX + _drawningTankWidth > _pictureWidth)
|
||||||
|
{
|
||||||
|
_startPosX = _pictureWidth - _drawningTankWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_startPosY + _drawningTankHeight > _pictureHeight)
|
||||||
|
{
|
||||||
|
_startPosY = _pictureHeight - _drawningTankHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка позиции
|
/// Установка позиции
|
||||||
@ -82,8 +100,11 @@ public bool SetPictureSize(int width, int height)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы
|
if (x < 0) x = 0;
|
||||||
// то надо изменить координаты, чтобы он оставался в этих границах
|
else if (x + _drawningTankWidth > _pictureWidth) x = _pictureWidth.Value - _drawningTankWidth;
|
||||||
|
|
||||||
|
if (y < 0) y = 0;
|
||||||
|
else if (y + _drawningTankHeight > _pictureHeight) y = _pictureHeight.Value - _drawningTankHeight;
|
||||||
_startPosX = x;
|
_startPosX = x;
|
||||||
_startPosY = y;
|
_startPosY = y;
|
||||||
}
|
}
|
||||||
@ -92,7 +113,7 @@ public bool SetPictureSize(int width, int height)
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="direction">Направление</param>
|
/// <param name="direction">Направление</param>
|
||||||
/// <returns>true - перемещене выполнено, false - перемещение невозможно</returns>
|
/// <returns>true - перемещене выполнено, false - перемещение невозможно</returns>
|
||||||
public bool MoveTransport(DirectionType direction)
|
public bool MoveTransport(DirectionType direction)
|
||||||
{
|
{
|
||||||
if (EntityTank == null || !_startPosX.HasValue ||
|
if (EntityTank == null || !_startPosX.HasValue ||
|
||||||
!_startPosY.HasValue)
|
!_startPosY.HasValue)
|
||||||
@ -104,24 +125,22 @@ public bool MoveTransport(DirectionType direction)
|
|||||||
//влево
|
//влево
|
||||||
case DirectionType.Left:
|
case DirectionType.Left:
|
||||||
if (_startPosX.Value - EntityTank.Step > 0)
|
if (_startPosX.Value - EntityTank.Step > 0)
|
||||||
{
|
|
||||||
_startPosX -= (int)EntityTank.Step;
|
_startPosX -= (int)EntityTank.Step;
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
//вверх
|
//вверх
|
||||||
case DirectionType.Up:
|
case DirectionType.Up:
|
||||||
if (_startPosY.Value - EntityTank.Step > 0)
|
if (_startPosY.Value - EntityTank.Step > 0)
|
||||||
{
|
|
||||||
_startPosY -= (int)EntityTank.Step;
|
_startPosY -= (int)EntityTank.Step;
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
// вправо
|
// вправо
|
||||||
case DirectionType.Right:
|
case DirectionType.Right:
|
||||||
//TODO прописать логику сдвига в право
|
if (_startPosX.Value + _drawningTankWidth + EntityTank.Step < _pictureWidth)
|
||||||
|
_startPosX += (int)EntityTank.Step;
|
||||||
return true;
|
return true;
|
||||||
//вниз
|
//вниз
|
||||||
case DirectionType.Down:
|
case DirectionType.Down:
|
||||||
//TODO прописать логику сдвига в вниз
|
if (_startPosY.Value + _drawningTankHeight + EntityTank.Step < _pictureHeight)
|
||||||
|
_startPosY += (int)EntityTank.Step;
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@ -139,12 +158,35 @@ public bool MoveTransport(DirectionType direction)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
Brush additionalBrush = new
|
Brush additionalBrush = new SolidBrush(EntityTank.AdditionalColor);
|
||||||
SolidBrush(EntityTank.AdditionalColor);
|
Brush bodyBrush = new SolidBrush(EntityTank.BodyColor);
|
||||||
// обвесы
|
|
||||||
if (EntityTank.BodyKit)
|
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 45, 150, 60);
|
||||||
|
g.DrawEllipse(pen, _startPosX.Value + 5, _startPosY.Value + 60, 33, 33);
|
||||||
|
g.DrawEllipse(pen, _startPosX.Value + 110, _startPosY.Value + 60, 33, 33);
|
||||||
|
g.DrawEllipse(pen, _startPosX.Value + 35, _startPosY.Value + 80, 16, 16);
|
||||||
|
g.DrawEllipse(pen, _startPosX.Value + 55, _startPosY.Value + 83, 16, 16);
|
||||||
|
g.DrawEllipse(pen, _startPosX.Value + 75, _startPosY.Value + 83, 16, 16);
|
||||||
|
g.DrawEllipse(pen, _startPosX.Value + 95, _startPosY.Value + 80, 16, 16);
|
||||||
|
|
||||||
|
g.FillEllipse(bodyBrush, _startPosX.Value + 45, _startPosY.Value + 55, 15, 15);
|
||||||
|
g.FillEllipse(bodyBrush, _startPosX.Value + 65, _startPosY.Value + 55, 15, 15);
|
||||||
|
g.FillEllipse(bodyBrush, _startPosX.Value + 85, _startPosY.Value + 55, 15, 15);
|
||||||
|
|
||||||
|
g.FillRectangle(bodyBrush, _startPosX.Value + 30, _startPosY.Value + 10, 100, 30);
|
||||||
|
g.FillRectangle(bodyBrush, _startPosX.Value + 5, _startPosY.Value + 40, 140, 25);
|
||||||
|
|
||||||
|
if(EntityTank.Pushka)
|
||||||
|
g.FillRectangle(additionalBrush, _startPosX.Value + 120, _startPosY.Value + 20, 100, 15);
|
||||||
|
|
||||||
|
if (EntityTank.Pulemet)
|
||||||
{
|
{
|
||||||
return;
|
Point p = new Point(_startPosX.Value + 75, _startPosY.Value + 10);
|
||||||
|
Point p1 = new Point(_startPosX.Value + 80, _startPosY.Value + 1);
|
||||||
|
Point p2 = new Point(_startPosX.Value + 87, _startPosY.Value + 2);
|
||||||
|
Point p3 = new Point(_startPosX.Value + 80, _startPosY.Value + 10);
|
||||||
|
Point[] p_pulemet = { p, p1, p2, p3 };
|
||||||
|
g.FillPolygon(additionalBrush, p_pulemet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,15 +21,11 @@ public class EntityTank
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Признак (опция) наличия обвеса
|
/// Признак (опция) наличия обвеса
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool BodyKit { get; private set; }
|
public bool Pushka { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Признак (опция) наличия антикрыла
|
/// Признак (опция) наличия антикрыла
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Wing { get; private set; }
|
public bool Pulemet { get; private set; }
|
||||||
/// <summary>
|
|
||||||
/// Признак (опция) наличия гоночной полосы
|
|
||||||
/// </summary>
|
|
||||||
public bool SportLine { get; private set; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Шаг перемещения автомобиля
|
/// Шаг перемещения автомобиля
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -41,17 +37,17 @@ public class EntityTank
|
|||||||
/// <param name="weight">Вес автомобиля</param>
|
/// <param name="weight">Вес автомобиля</param>
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
/// <param name="bodyColor">Основной цвет</param>
|
||||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||||
/// <param name="bodyKit">Признак наличия обвеса</param>
|
/// <param name="pushka">Признак наличия обвеса</param>
|
||||||
/// <param name="wing">Признак наличия антикрыла</param>
|
/// <param name="pulemet">Признак наличия антикрыла</param>
|
||||||
/// <param name="sportLine">Признак наличия гоночной полосы</param>
|
/// <param name="sportLine">Признак наличия гоночной полосы</param>
|
||||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine)
|
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool pushka, bool pulemet)
|
||||||
{
|
{
|
||||||
Speed = speed;
|
Speed = speed;
|
||||||
Weight = weight;
|
Weight = weight;
|
||||||
BodyColor = bodyColor;
|
BodyColor = bodyColor;
|
||||||
AdditionalColor = additionalColor;
|
AdditionalColor = additionalColor;
|
||||||
BodyKit = bodyKit;
|
Pushka = pushka;
|
||||||
Wing = wing;
|
Pulemet = pulemet;
|
||||||
SportLine = sportLine;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
103
Tank/Tank/FormTank.Designer.cs
generated
103
Tank/Tank/FormTank.Designer.cs
generated
@ -28,31 +28,110 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
button1 = new Button();
|
pictureBoxTank = new PictureBox();
|
||||||
|
buttonCreate = new Button();
|
||||||
|
buttonLeft = new Button();
|
||||||
|
buttonUp = new Button();
|
||||||
|
buttonRight = new Button();
|
||||||
|
buttonDown = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxTank).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// button1
|
// pictureBoxTank
|
||||||
//
|
//
|
||||||
button1.Location = new Point(51, 65);
|
pictureBoxTank.AccessibleRole = AccessibleRole.None;
|
||||||
button1.Name = "button1";
|
pictureBoxTank.Dock = DockStyle.Fill;
|
||||||
button1.Size = new Size(150, 46);
|
pictureBoxTank.Location = new Point(0, 0);
|
||||||
button1.TabIndex = 0;
|
pictureBoxTank.Name = "pictureBoxTank";
|
||||||
button1.Text = "button1";
|
pictureBoxTank.Size = new Size(1235, 854);
|
||||||
button1.UseVisualStyleBackColor = true;
|
pictureBoxTank.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||||
|
pictureBoxTank.TabIndex = 1;
|
||||||
|
pictureBoxTank.TabStop = false;
|
||||||
|
pictureBoxTank.Click += ButtonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
|
buttonCreate.Location = new Point(12, 796);
|
||||||
|
buttonCreate.Name = "buttonCreate";
|
||||||
|
buttonCreate.Size = new Size(150, 46);
|
||||||
|
buttonCreate.TabIndex = 2;
|
||||||
|
buttonCreate.Text = "Создать";
|
||||||
|
buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreate.Click += ButtonCreateTank_Click;
|
||||||
|
//
|
||||||
|
// buttonLeft
|
||||||
|
//
|
||||||
|
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonLeft.BackgroundImage = Properties.Resources.left;
|
||||||
|
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonLeft.Location = new Point(1021, 786);
|
||||||
|
buttonLeft.Name = "buttonLeft";
|
||||||
|
buttonLeft.Size = new Size(45, 45);
|
||||||
|
buttonLeft.TabIndex = 3;
|
||||||
|
buttonLeft.UseVisualStyleBackColor = true;
|
||||||
|
buttonLeft.Click += ButtonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonUp
|
||||||
|
//
|
||||||
|
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonUp.BackgroundImage = Properties.Resources.up;
|
||||||
|
buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonUp.Location = new Point(1072, 735);
|
||||||
|
buttonUp.Name = "buttonUp";
|
||||||
|
buttonUp.Size = new Size(45, 45);
|
||||||
|
buttonUp.TabIndex = 4;
|
||||||
|
buttonUp.UseVisualStyleBackColor = true;
|
||||||
|
buttonUp.Click += ButtonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonRight
|
||||||
|
//
|
||||||
|
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonRight.BackgroundImage = Properties.Resources.right;
|
||||||
|
buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonRight.Location = new Point(1123, 786);
|
||||||
|
buttonRight.Name = "buttonRight";
|
||||||
|
buttonRight.Size = new Size(45, 45);
|
||||||
|
buttonRight.TabIndex = 5;
|
||||||
|
buttonRight.UseVisualStyleBackColor = true;
|
||||||
|
buttonRight.Click += ButtonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonDown
|
||||||
|
//
|
||||||
|
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonDown.BackgroundImage = Properties.Resources.down;
|
||||||
|
buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonDown.Location = new Point(1072, 786);
|
||||||
|
buttonDown.Name = "buttonDown";
|
||||||
|
buttonDown.Size = new Size(45, 45);
|
||||||
|
buttonDown.TabIndex = 6;
|
||||||
|
buttonDown.UseVisualStyleBackColor = true;
|
||||||
|
buttonDown.Click += ButtonMove_Click;
|
||||||
//
|
//
|
||||||
// FormTank
|
// FormTank
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(1235, 854);
|
||||||
Controls.Add(button1);
|
Controls.Add(buttonDown);
|
||||||
|
Controls.Add(buttonRight);
|
||||||
|
Controls.Add(buttonUp);
|
||||||
|
Controls.Add(buttonLeft);
|
||||||
|
Controls.Add(buttonCreate);
|
||||||
|
Controls.Add(pictureBoxTank);
|
||||||
Name = "FormTank";
|
Name = "FormTank";
|
||||||
Text = "Танк";
|
Text = "Танк";
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxTank).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
private PictureBox pictureBoxTank;
|
||||||
private Button button1;
|
private Button buttonCreate;
|
||||||
|
private Button buttonLeft;
|
||||||
|
private Button buttonUp;
|
||||||
|
private Button buttonRight;
|
||||||
|
private Button buttonDown;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,9 +12,92 @@ namespace Tank
|
|||||||
{
|
{
|
||||||
public partial class FormTank : Form
|
public partial class FormTank : Form
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Поле-объект для прорисовки объекта
|
||||||
|
/// </summary>
|
||||||
|
private DrawningTank? _drawningTank;
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор формы
|
||||||
|
/// </summary>
|
||||||
public FormTank()
|
public FormTank()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Метод прорисовки машины
|
||||||
|
/// </summary>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Обработка нажатия кнопки "Создать"
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonCreateTank_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Random random = new();
|
||||||
|
_drawningTank = new DrawningTank();
|
||||||
|
|
||||||
|
_drawningTank.Init(random.Next(100, 300), random.Next(1000,
|
||||||
|
3000),
|
||||||
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256),
|
||||||
|
random.Next(0, 256)),
|
||||||
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256),
|
||||||
|
random.Next(0, 256)),
|
||||||
|
Convert.ToBoolean(random.Next(0, 2)),
|
||||||
|
Convert.ToBoolean(random.Next(0, 2)));
|
||||||
|
_drawningTank.SetPictureSize(pictureBoxTank.Width,
|
||||||
|
pictureBoxTank.Height);
|
||||||
|
_drawningTank.SetPosition(random.Next(10, 100), random.Next(10,
|
||||||
|
100));
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Перемещение объекта по форме (нажатие кнопок навигации)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_drawningTank == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||||
|
bool result = false;
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case "buttonUp":
|
||||||
|
result =
|
||||||
|
_drawningTank.MoveTransport(DirectionType.Up);
|
||||||
|
break;
|
||||||
|
case "buttonDown":
|
||||||
|
result =
|
||||||
|
_drawningTank.MoveTransport(DirectionType.Down);
|
||||||
|
break;
|
||||||
|
case "buttonLeft":
|
||||||
|
result =
|
||||||
|
_drawningTank.MoveTransport(DirectionType.Left);
|
||||||
|
break;
|
||||||
|
case "buttonRight":
|
||||||
|
result =
|
||||||
|
_drawningTank.MoveTransport(DirectionType.Right);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
103
Tank/Tank/Properties/Resources.Designer.cs
generated
Normal file
103
Tank/Tank/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Этот код создан программой.
|
||||||
|
// Исполняемая версия:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||||
|
// повторной генерации кода.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace Tank.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("Tank.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 down {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("down", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap left {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("left", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap right {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("right", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap up {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("up", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
133
Tank/Tank/Properties/Resources.resx
Normal file
133
Tank/Tank/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="left" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\left.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="down" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="right" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\right.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="up" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
BIN
Tank/Tank/Resources/down.png
Normal file
BIN
Tank/Tank/Resources/down.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
Tank/Tank/Resources/left.png
Normal file
BIN
Tank/Tank/Resources/left.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
Tank/Tank/Resources/right.png
Normal file
BIN
Tank/Tank/Resources/right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
Tank/Tank/Resources/up.png
Normal file
BIN
Tank/Tank/Resources/up.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
@ -8,4 +8,19 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Update="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
Loading…
x
Reference in New Issue
Block a user