PIbd-13 NefedovA.V. LabWork01 Simple #1
23
SPAI/SPAI/DirectionType.cs
Normal file
23
SPAI/SPAI/DirectionType.cs
Normal file
@ -0,0 +1,23 @@
|
||||
namespace SPAI;
|
||||
/// <summary>
|
||||
/// Направление перемещения
|
||||
/// </summary>
|
||||
public enum DirectionType
|
||||
{
|
||||
/// <summary>
|
||||
/// Вверх
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
/// <summary>
|
||||
/// Вниз
|
||||
/// </summary>
|
||||
Down = 2,
|
||||
/// <summary>
|
||||
/// Влево
|
||||
/// </summary>
|
||||
Left = 3,
|
||||
/// <summary>
|
||||
/// Вправо
|
||||
/// </summary>
|
||||
Right = 4
|
||||
}
|
211
SPAI/SPAI/DrawningSPAI.cs
Normal file
211
SPAI/SPAI/DrawningSPAI.cs
Normal file
@ -0,0 +1,211 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SPAI;
|
||||
|
||||
|
||||
public class DrawningSPAI
|
||||
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public EntitySPAI? EntitySPAI { get; private set; }
|
||||
/// <summary>
|
||||
/// Ширина окна
|
||||
/// </summary>
|
||||
private int? _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна
|
||||
/// </summary>
|
||||
private int? _pictureHeight;
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки
|
||||
/// </summary>
|
||||
private int? _startPosX;
|
||||
/// <summary>
|
||||
/// Верхняя кооридната прорисовки
|
||||
/// </summary>
|
||||
private int? _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина прорисовки
|
||||
/// </summary>
|
||||
private readonly int _drawningSPAIWidth = 103;
|
||||
/// <summary>
|
||||
/// Высота прорисовки
|
||||
/// </summary>
|
||||
private readonly int _drawningSPAIHeight = 135;
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес САУ</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="tracks">Признак наличия гусениц</param>
|
||||
/// <param name="multipleLaunchBattery">Признак наличия залповой батареи</param>
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool multipleLaunchBattery, bool tracks)
|
||||
{
|
||||
EntitySPAI = new EntitySPAI();
|
||||
EntitySPAI.Init(speed, weight, bodyColor, additionalColor, tracks, multipleLaunchBattery);
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
_startPosX = null;
|
||||
_startPosY = null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка границ поля
|
||||
/// </summary>
|
||||
/// <param name="width">Ширина поля</param>
|
||||
/// <param name="height">Высота поля</param>
|
||||
/// <returns>true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах</returns>
|
||||
public void SetPictureSize(int width, int height)
|
||||
{
|
||||
if (_drawningSPAIHeight > height || _drawningSPAIWidth > width) return;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка позиции
|
||||
/// </summary>
|
||||
/// <param name="x">Координата X</param>
|
||||
/// <param name="y">Координата Y</param>
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (x < 0 || y < 0 || x + _drawningSPAIWidth > _pictureWidth || y + _drawningSPAIHeight > _pictureHeight) return;
|
||||
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Изменение направления перемещения
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
/// <returns>true - перемещене выполнено, false - перемещение
|
||||
public bool MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (EntitySPAI == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
//влево
|
||||
case DirectionType.Left:
|
||||
if (_startPosX.Value - EntitySPAI.Step >= 0)
|
||||
{
|
||||
_startPosX -= (int)EntitySPAI.Step;
|
||||
}
|
||||
return true;
|
||||
//вверх
|
||||
case DirectionType.Up:
|
||||
if (_startPosY.Value - EntitySPAI.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntitySPAI.Step;
|
||||
}
|
||||
return true;
|
||||
// вправо
|
||||
// вправо
|
||||
case DirectionType.Right:
|
||||
if (_startPosX.Value - EntitySPAI.Step < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntitySPAI.Step;
|
||||
}
|
||||
return true;
|
||||
//вниз
|
||||
case DirectionType.Down:
|
||||
if (_startPosY.Value - EntitySPAI.Step < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntitySPAI.Step;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Прорисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
|
||||
/// <summary>
|
||||
/// Прорисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntitySPAI == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new
|
||||
SolidBrush(EntitySPAI.AdditionalColor);
|
||||
//корпус
|
||||
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 20, 100, 15);
|
||||
//башня
|
||||
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 5, 30, 5);
|
||||
Brush brGreen = new SolidBrush(Color.Green);
|
||||
g.FillRectangle(brGreen, _startPosX.Value + 30, _startPosY.Value + 1, 46, 21);
|
||||
|
||||
//орудие
|
||||
g.DrawRectangle(pen, _startPosX.Value + 29, _startPosY.Value, 45, 20);
|
||||
g.FillRectangle(brGreen, _startPosX.Value, _startPosY.Value + 5, 30, 5);
|
||||
|
||||
//гусеничная часть
|
||||
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 20, 100, 30);
|
||||
//цвет гусеничной части
|
||||
Brush brBlue = new SolidBrush(Color.Blue);
|
||||
g.FillEllipse(brBlue, _startPosX.Value + 1, _startPosY.Value + 21, 101, 31);
|
||||
|
||||
if (EntitySPAI.Tracks)
|
||||
{
|
||||
//катки
|
||||
g.DrawEllipse(pen, _startPosX.Value + 18, _startPosY.Value + 35, 16, 16);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 19, _startPosY.Value + 35, 16, 16);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 34, _startPosY.Value + 35, 16, 16);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 49, _startPosY.Value + 35, 16, 16);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 65, _startPosY.Value + 35, 16, 16);
|
||||
|
||||
//цвет катков
|
||||
Brush brGray = new SolidBrush(Color.Gray);
|
||||
g.FillEllipse(brGray, _startPosX.Value + 20, _startPosY.Value + 35, 16, 16);
|
||||
g.FillEllipse(brGray, _startPosX.Value + 35, _startPosY.Value + 35, 16, 16);
|
||||
g.FillEllipse(brGray, _startPosX.Value + 50, _startPosY.Value + 35, 16, 16);
|
||||
g.FillEllipse(brGray, _startPosX.Value + 65, _startPosY.Value + 35, 16, 16);
|
||||
}
|
||||
//колеса
|
||||
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 35, 20, 20); //левое колесo
|
||||
g.DrawEllipse(pen, _startPosX.Value + 79, _startPosY.Value + 35, 20, 20); //правое колесо
|
||||
if (EntitySPAI.MultipleLaunchBattery)
|
||||
{
|
||||
//залповая батарея
|
||||
g.DrawRectangle(pen, _startPosX.Value + 74, _startPosY.Value + 5, 5, 10);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 81, _startPosY.Value + 5, 5, 10);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 88, _startPosY.Value + 5, 5, 10);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 95, _startPosY.Value + 5, 5, 10);
|
||||
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 74, _startPosY.Value + 5, 5, 10);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 81, _startPosY.Value + 5, 5, 10);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 88, _startPosY.Value + 5, 5, 10);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 95, _startPosY.Value + 5, 5, 10);
|
||||
}
|
||||
//цвет колес
|
||||
Brush brBlack = new SolidBrush(Color.Black);
|
||||
g.FillEllipse(brBlack, _startPosX.Value, _startPosY.Value + 35, 20, 20); //левое колесо
|
||||
g.FillEllipse(brBlack, _startPosX.Value + 79, _startPosY.Value + 35, 20, 20); //правое колесо
|
||||
//цвет корпуса
|
||||
Brush br = new SolidBrush(EntitySPAI.BodyColor);
|
||||
g.FillRectangle(br, _startPosX.Value + 1, _startPosY.Value + 21, 101, 16);
|
||||
|
||||
|
||||
}
|
||||
}
|
44
SPAI/SPAI/EntitySPAI.cs
Normal file
44
SPAI/SPAI/EntitySPAI.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SPAI;
|
||||
|
||||
public class EntitySPAI
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
|
||||
public double Weight { get; private set; }
|
||||
|
||||
public Color BodyColor { get; private set; }
|
||||
|
||||
public Color AdditionalColor { get; private set; }
|
||||
|
||||
public bool Tracks { get; private set; }
|
||||
|
||||
public bool MultipleLaunchBattery { get; private set; }
|
||||
|
||||
public double Step => Speed * 100 / Weight;
|
||||
/// <summary>
|
||||
/// Инициализация полей объекта-класса спортивного автомобиля
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес автомобиля</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="tracks">Признак наличия орудия</param>
|
||||
/// <param name="multipleLaunchBattery">Признак наличия залповой батареи</param>
|
||||
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool tracks, bool multipleLaunchBattery)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
AdditionalColor = additionalColor;
|
||||
Tracks = tracks;
|
||||
MultipleLaunchBattery = multipleLaunchBattery;
|
||||
}
|
||||
}
|
39
SPAI/SPAI/Form1.Designer.cs
generated
39
SPAI/SPAI/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
||||
namespace SPAI
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
namespace SPAI
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
139
SPAI/SPAI/FormSPAI.Designer.cs
generated
Normal file
139
SPAI/SPAI/FormSPAI.Designer.cs
generated
Normal file
@ -0,0 +1,139 @@
|
||||
namespace SPAI
|
||||
{
|
||||
partial class FormSPAI
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormSPAI));
|
||||
pictureBoxSPAI = new PictureBox();
|
||||
bottonCreateSPAI = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonDown = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonUp = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxSPAI).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxSPAI
|
||||
//
|
||||
pictureBoxSPAI.Dock = DockStyle.Fill;
|
||||
pictureBoxSPAI.Location = new Point(0, 0);
|
||||
pictureBoxSPAI.Name = "pictureBoxSPAI";
|
||||
pictureBoxSPAI.Size = new Size(858, 498);
|
||||
pictureBoxSPAI.TabIndex = 0;
|
||||
pictureBoxSPAI.TabStop = false;
|
||||
//
|
||||
// bottonCreateSPAI
|
||||
//
|
||||
bottonCreateSPAI.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
bottonCreateSPAI.Location = new Point(0, 469);
|
||||
bottonCreateSPAI.Name = "bottonCreateSPAI";
|
||||
bottonCreateSPAI.Size = new Size(94, 29);
|
||||
bottonCreateSPAI.TabIndex = 1;
|
||||
bottonCreateSPAI.Text = "Создать";
|
||||
bottonCreateSPAI.UseVisualStyleBackColor = true;
|
||||
bottonCreateSPAI.Click += BottonCreateSPAI_Click;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
|
||||
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonLeft.Location = new Point(745, 463);
|
||||
buttonLeft.Name = "buttonLeft";
|
||||
buttonLeft.RightToLeft = RightToLeft.Yes;
|
||||
buttonLeft.Size = new Size(35, 35);
|
||||
buttonLeft.TabIndex = 2;
|
||||
buttonLeft.UseVisualStyleBackColor = true;
|
||||
buttonLeft.Click += BottonMove_Click;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonDown.BackgroundImage = (Image)resources.GetObject("buttonDown.BackgroundImage");
|
||||
buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDown.Location = new Point(786, 463);
|
||||
buttonDown.Name = "buttonDown";
|
||||
buttonDown.RightToLeft = RightToLeft.Yes;
|
||||
buttonDown.Size = new Size(35, 35);
|
||||
buttonDown.TabIndex = 3;
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += BottonMove_Click;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonRight.BackgroundImage = (Image)resources.GetObject("buttonRight.BackgroundImage");
|
||||
buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonRight.Location = new Point(823, 463);
|
||||
buttonRight.Name = "buttonRight";
|
||||
buttonRight.RightToLeft = RightToLeft.Yes;
|
||||
buttonRight.Size = new Size(35, 35);
|
||||
buttonRight.TabIndex = 4;
|
||||
buttonRight.UseVisualStyleBackColor = true;
|
||||
buttonRight.Click += BottonMove_Click;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonUp.BackgroundImage = (Image)resources.GetObject("buttonUp.BackgroundImage");
|
||||
buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonUp.Location = new Point(786, 422);
|
||||
buttonUp.Name = "buttonUp";
|
||||
buttonUp.RightToLeft = RightToLeft.Yes;
|
||||
buttonUp.Size = new Size(35, 35);
|
||||
buttonUp.TabIndex = 5;
|
||||
buttonUp.UseVisualStyleBackColor = true;
|
||||
buttonUp.Click += BottonMove_Click;
|
||||
//
|
||||
// FormSPAI
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(858, 498);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(bottonCreateSPAI);
|
||||
Controls.Add(pictureBoxSPAI);
|
||||
Name = "FormSPAI";
|
||||
Text = "Самоходная установка";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxSPAI).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxSPAI;
|
||||
private Button bottonCreateSPAI;
|
||||
private Button buttonLeft;
|
||||
private Button buttonDown;
|
||||
private Button buttonRight;
|
||||
private Button buttonUp;
|
||||
}
|
||||
}
|
91
SPAI/SPAI/FormSPAI.cs
Normal file
91
SPAI/SPAI/FormSPAI.cs
Normal file
@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SPAI;
|
||||
|
||||
public partial class FormSPAI : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Поле-объект для прорисовки объекта
|
||||
/// </summary>
|
||||
private DrawningSPAI? _drawningSPAI;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор формы
|
||||
/// </summary>
|
||||
public FormSPAI()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Метод прорисовки машины
|
||||
/// </summary>
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningSPAI == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBoxSPAI.Width, pictureBoxSPAI.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningSPAI.DrawTransport(gr);
|
||||
pictureBoxSPAI.Image = bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Создать"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void BottonCreateSPAI_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
_drawningSPAI = new DrawningSPAI();
|
||||
_drawningSPAI.Init(random.Next(100, 300), random.Next(1000, 3000),
|
||||
Color.FromArgb(random.Next(256), random.Next(0, 256), random.Next(0, 256)),
|
||||
Color.FromArgb(random.Next(256), random.Next(0, 256), random.Next(0, 256)),
|
||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||
_drawningSPAI.SetPictureSize(pictureBoxSPAI.Width - 125, pictureBoxSPAI.Height - 80);
|
||||
_drawningSPAI.SetPosition(random.Next(1, 50), random.Next(1, 50));
|
||||
Draw();
|
||||
}
|
||||
|
||||
|
||||
private void BottonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningSPAI == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
bool result = false;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
result = _drawningSPAI.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
result = _drawningSPAI.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
result = _drawningSPAI.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
result = _drawningSPAI.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
3232
SPAI/SPAI/FormSPAI.resx
Normal file
3232
SPAI/SPAI/FormSPAI.resx
Normal file
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,7 @@ namespace SPAI
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
Application.Run(new FormSPAI());
|
||||
}
|
||||
}
|
||||
}
|
103
SPAI/SPAI/Properties/Resources.Designer.cs
generated
Normal file
103
SPAI/SPAI/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace SPAI.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("SPAI.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 arrowLeft {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowLeft", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowRight {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowRight", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowUp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowUp", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -117,4 +117,17 @@
|
||||
<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="arrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowLeft.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowDown.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowRight.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowUp.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
SPAI/SPAI/Resources/arrowDown.jpg
Normal file
BIN
SPAI/SPAI/Resources/arrowDown.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
BIN
SPAI/SPAI/Resources/arrowLeft.jpg
Normal file
BIN
SPAI/SPAI/Resources/arrowLeft.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
BIN
SPAI/SPAI/Resources/arrowRight.jpg
Normal file
BIN
SPAI/SPAI/Resources/arrowRight.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
BIN
SPAI/SPAI/Resources/arrowUp.jpg
Normal file
BIN
SPAI/SPAI/Resources/arrowUp.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
@ -8,4 +8,19 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</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>
|
Loading…
x
Reference in New Issue
Block a user