basic lab
This commit is contained in:
parent
80af4c8885
commit
df69837593
3
.gitignore
vendored
3
.gitignore
vendored
@ -4,6 +4,9 @@
|
|||||||
##
|
##
|
||||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||||
|
|
||||||
|
#mac file
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
# User-specific files
|
# User-specific files
|
||||||
*.rsuser
|
*.rsuser
|
||||||
*.suo
|
*.suo
|
||||||
|
28
ProjectTank/ProjectTank/Direction.cs
Normal file
28
ProjectTank/ProjectTank/Direction.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectTank
|
||||||
|
{
|
||||||
|
public enum DirectionType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Вверх
|
||||||
|
/// </summary>
|
||||||
|
Up = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// Вниз
|
||||||
|
/// </summary>
|
||||||
|
Down = 2,
|
||||||
|
/// <summary>
|
||||||
|
/// Влево
|
||||||
|
/// </summary>
|
||||||
|
Left = 3,
|
||||||
|
/// <summary>
|
||||||
|
/// Вправо
|
||||||
|
/// </summary>
|
||||||
|
Right = 4
|
||||||
|
}
|
||||||
|
}
|
200
ProjectTank/ProjectTank/DrawningTank.cs
Normal file
200
ProjectTank/ProjectTank/DrawningTank.cs
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ProjectTank
|
||||||
|
{
|
||||||
|
public class DrawningTank
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Класс-сущность
|
||||||
|
/// </summary>
|
||||||
|
public EntityTank? _EntityTank { 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 _tankWidth = 200;
|
||||||
|
/// <summary>
|
||||||
|
/// Высота прорисовки танка
|
||||||
|
/// </summary>
|
||||||
|
private readonly int _tankHeight = 80;
|
||||||
|
/// <summary>
|
||||||
|
/// Инициализация свойств
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="speed">Скорость</param>
|
||||||
|
/// <param name="weight">Вес</param>
|
||||||
|
/// <param name="bodyColor">Цвет кузова</param>
|
||||||
|
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||||
|
/// <param name="width">Ширина картинки</param>
|
||||||
|
/// <param name="height">Высота картинки</param>
|
||||||
|
/// <returns>true - объект создан, false - проверка не пройдена,нельзя создать объект в этих размерах</returns>
|
||||||
|
public bool Init(int speed, double weight, Color bodyColor, Color additionalColor,
|
||||||
|
bool gun, bool machineGun, int width, int height)
|
||||||
|
{
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
|
|
||||||
|
if ((_pictureHeight < _tankHeight) || (_pictureWidth < _tankWidth))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_EntityTank = new EntityTank();
|
||||||
|
_EntityTank.Init(speed, weight, gun, machineGun, bodyColor, additionalColor);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Установка позиции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x">Координата X</param>
|
||||||
|
/// <param name="y">Координата Y</param>
|
||||||
|
public void SetPosition(int x, int y)
|
||||||
|
{
|
||||||
|
if ((x < 0 || y < 0) || (x + _tankWidth > _pictureWidth || y + _tankHeight > _pictureHeight))
|
||||||
|
{
|
||||||
|
_startPosX = 0;
|
||||||
|
_startPosY = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_startPosX = x;
|
||||||
|
_startPosY = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Изменение направления перемещения
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="direction">Направление</param>
|
||||||
|
public void MoveTransport(DirectionType direction)
|
||||||
|
{
|
||||||
|
if (_EntityTank == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
//влево
|
||||||
|
case DirectionType.Left:
|
||||||
|
if (_startPosX - _EntityTank.Step > 0)
|
||||||
|
{
|
||||||
|
_startPosX -= (int)_EntityTank.Step;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//вверх
|
||||||
|
case DirectionType.Up:
|
||||||
|
if (_startPosY - _EntityTank.Step > 0)
|
||||||
|
{
|
||||||
|
_startPosY -= (int)_EntityTank.Step;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//вправо
|
||||||
|
case DirectionType.Right:
|
||||||
|
if (_startPosX + _tankWidth + _EntityTank.Step < _pictureWidth)
|
||||||
|
{
|
||||||
|
_startPosX += (int)_EntityTank.Step;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//вниз
|
||||||
|
case DirectionType.Down:
|
||||||
|
if (_startPosY + _tankHeight + _EntityTank.Step < _pictureHeight)
|
||||||
|
{
|
||||||
|
_startPosY += (int)_EntityTank.Step;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Прорисовка объекта
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g"></param>
|
||||||
|
public void DrawTransport(Graphics g)
|
||||||
|
{
|
||||||
|
if (_EntityTank == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Pen pen = new(Color.Black, 3);
|
||||||
|
Pen penGray = new(Color.Gray, 4);
|
||||||
|
Brush grayColorBrush = new SolidBrush(Color.Gray);
|
||||||
|
Brush blackColorBrush = new SolidBrush(Color.Black);
|
||||||
|
Brush additionalBrush = new SolidBrush(_EntityTank.AdditionalColor);
|
||||||
|
Brush bodyBrush = new SolidBrush(_EntityTank.BodyColor);
|
||||||
|
|
||||||
|
// Границы автомобиля
|
||||||
|
// гусеницы
|
||||||
|
g.DrawEllipse(pen, _startPosX+14, _startPosY+44, 151, 31);
|
||||||
|
g.FillEllipse(blackColorBrush, _startPosX + 15, _startPosY + 45, 150, 30);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 24, _startPosY + 54, 10, 10);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 144, _startPosY + 54, 10, 10);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 44, _startPosY + 59, 10, 10);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 124, _startPosY + 59, 10, 10);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 64, _startPosY + 61, 10, 10);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 104, _startPosY + 61, 10, 10);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 84, _startPosY + 62, 10, 10);
|
||||||
|
// Кузов
|
||||||
|
g.DrawRectangle(pen, _startPosX + 19, _startPosY + 34, 141, 21);
|
||||||
|
g.FillRectangle(bodyBrush, _startPosX+20, _startPosY+35, 140, 20);
|
||||||
|
|
||||||
|
// Башня
|
||||||
|
g.FillRectangle(blackColorBrush, _startPosX + 75, _startPosY + 10, 25, 5);
|
||||||
|
g.DrawRectangle(pen, _startPosX + 64, _startPosY + 14, 66, 21);
|
||||||
|
g.FillRectangle(additionalBrush, _startPosX + 65, _startPosY + 15, 65, 20);
|
||||||
|
|
||||||
|
//Точки для отрисовки передней и задней части
|
||||||
|
Point pointFirstBackSide = new Point(_startPosX + 18, _startPosY + 35);
|
||||||
|
Point pointSecondBackSide = new Point(_startPosX + 18, _startPosY + 55);
|
||||||
|
Point pointThirdBackSide = new Point(_startPosX+0, _startPosY+55);
|
||||||
|
Point pointFirstFrontSide = new Point(_startPosX + 162, _startPosY + 35);
|
||||||
|
Point pointSecondFrontSide = new Point(_startPosX + 185, _startPosY + 55);
|
||||||
|
Point pointThirdFrontSide = new Point(_startPosX + 162, _startPosY + 55);
|
||||||
|
|
||||||
|
// Задняя часть
|
||||||
|
Point[] backSide = { pointFirstBackSide, pointSecondBackSide, pointThirdBackSide };
|
||||||
|
g.DrawPolygon(pen, backSide);
|
||||||
|
g.FillPolygon(bodyBrush, backSide);
|
||||||
|
// Передняя часть
|
||||||
|
Point[] frontSide ={ pointFirstFrontSide, pointSecondFrontSide, pointThirdFrontSide };
|
||||||
|
g.DrawPolygon(pen, frontSide);
|
||||||
|
g.FillPolygon(bodyBrush, frontSide);
|
||||||
|
|
||||||
|
// пушка
|
||||||
|
if (_EntityTank.Gun)
|
||||||
|
{
|
||||||
|
g.DrawRectangle(pen, _startPosX + 129, _startPosY + 19, 56, 6);
|
||||||
|
g.FillRectangle(additionalBrush, _startPosX + 130, _startPosY + 20, 55, 5);
|
||||||
|
g.DrawRectangle(pen, _startPosX + 184, _startPosY + 17, 16, 11);
|
||||||
|
g.FillRectangle(blackColorBrush, _startPosX + 185, _startPosY + 18, 15, 10);
|
||||||
|
}
|
||||||
|
// пулемет
|
||||||
|
if (_EntityTank.MachineGun)
|
||||||
|
{
|
||||||
|
g.DrawRectangle(pen, _startPosX + 104, _startPosY + 9, 16, 6);
|
||||||
|
g.FillRectangle(additionalBrush, _startPosX + 105, _startPosY + 10, 15, 5);
|
||||||
|
g.DrawRectangle(pen, _startPosX + 111, _startPosY, 4, 6);
|
||||||
|
g.FillRectangle(additionalBrush, _startPosX + 112, _startPosY + 1, 4, 7);
|
||||||
|
g.FillRectangle(blackColorBrush, _startPosX + 98, _startPosY, 7, 7);
|
||||||
|
g.DrawRectangle(pen, _startPosX + 104, _startPosY + 2, 30, 3);
|
||||||
|
g.FillRectangle(additionalBrush, _startPosX + 105, _startPosY + 3, 29, 3);
|
||||||
|
g.FillRectangle(blackColorBrush, _startPosX + 135, _startPosY, 15, 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
67
ProjectTank/ProjectTank/EntityTank.cs
Normal file
67
ProjectTank/ProjectTank/EntityTank.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectTank
|
||||||
|
{
|
||||||
|
public class EntityTank
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Скорость
|
||||||
|
/// </summary>
|
||||||
|
public int Speed { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Вес
|
||||||
|
/// </summary>
|
||||||
|
public double Weight { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Пушка
|
||||||
|
/// </summary>
|
||||||
|
public bool Gun { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Пулемет
|
||||||
|
/// </summary>
|
||||||
|
public bool MachineGun { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Основной цвет
|
||||||
|
/// </summary>
|
||||||
|
public Color BodyColor { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Дополнительный цвет (для опциональных элементов)
|
||||||
|
/// </summary>
|
||||||
|
public Color AdditionalColor { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Расчет шага по карте
|
||||||
|
/// </summary>
|
||||||
|
public double Step => (double)Speed * 100 / Weight;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Инициализация полей объекта-класса спортивного автомобиля
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="speed">Скорость</param>
|
||||||
|
/// <param name="weight">Вес автомобиля</param>
|
||||||
|
/// <param name="bodyColor">Основной цвет</param>
|
||||||
|
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||||
|
/// <param name="gun">Признак наличия пушки</param>
|
||||||
|
/// <param name="machineGun">Признак наличия пулемета</param>
|
||||||
|
///
|
||||||
|
public void Init(int speed, double weight, bool gun,
|
||||||
|
bool machineGun, Color bodyColor, Color additionalColor)
|
||||||
|
{
|
||||||
|
Speed = speed;
|
||||||
|
Weight = weight;
|
||||||
|
BodyColor = bodyColor;
|
||||||
|
AdditionalColor = additionalColor;
|
||||||
|
Gun = gun;
|
||||||
|
MachineGun = machineGun;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
39
ProjectTank/ProjectTank/Form1.Designer.cs
generated
39
ProjectTank/ProjectTank/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
|||||||
namespace ProjectTank
|
|
||||||
{
|
|
||||||
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 ProjectTank
|
|
||||||
{
|
|
||||||
public partial class Form1 : Form
|
|
||||||
{
|
|
||||||
public Form1()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +1,17 @@
|
|||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace ProjectTank
|
namespace ProjectTank
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
// To customize application configuration such as set high DPI settings or default font,
|
|
||||||
// see https://aka.ms/applicationconfiguration.
|
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new Form1());
|
Application.Run(new TankForm());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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>
|
103
ProjectTank/ProjectTank/Properties/Resources.Designer.cs
generated
Normal file
103
ProjectTank/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 btnDown {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("btnDown", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap btnLeft {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("btnLeft", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap btnRight {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("btnRight", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap btnUp {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("btnUp", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -117,4 +117,17 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
|
<data name="btnDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\btnDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="btnLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\btnLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="btnRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\btnRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="btnUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\btnUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
BIN
ProjectTank/ProjectTank/Resources/btnDown.png
Normal file
BIN
ProjectTank/ProjectTank/Resources/btnDown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 333 B |
BIN
ProjectTank/ProjectTank/Resources/btnLeft.png
Normal file
BIN
ProjectTank/ProjectTank/Resources/btnLeft.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 328 B |
BIN
ProjectTank/ProjectTank/Resources/btnRight.png
Normal file
BIN
ProjectTank/ProjectTank/Resources/btnRight.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 335 B |
BIN
ProjectTank/ProjectTank/Resources/btnUp.png
Normal file
BIN
ProjectTank/ProjectTank/Resources/btnUp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 333 B |
155
ProjectTank/ProjectTank/TankForm.Designer.cs
generated
Normal file
155
ProjectTank/ProjectTank/TankForm.Designer.cs
generated
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
namespace ProjectTank
|
||||||
|
{
|
||||||
|
partial class TankForm
|
||||||
|
{
|
||||||
|
/// <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.pictureBoxTanks = new System.Windows.Forms.PictureBox();
|
||||||
|
this.ButtonCreateTank = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUp = new System.Windows.Forms.Button();
|
||||||
|
this.buttonRight = new System.Windows.Forms.Button();
|
||||||
|
this.buttonLeft = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTanks)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// pictureBoxTanks
|
||||||
|
//
|
||||||
|
this.pictureBoxTanks.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.pictureBoxTanks.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.pictureBoxTanks.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
||||||
|
this.pictureBoxTanks.Name = "pictureBoxTanks";
|
||||||
|
this.pictureBoxTanks.Size = new System.Drawing.Size(1445, 881);
|
||||||
|
this.pictureBoxTanks.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||||
|
this.pictureBoxTanks.TabIndex = 0;
|
||||||
|
this.pictureBoxTanks.TabStop = false;
|
||||||
|
//
|
||||||
|
// ButtonCreateTank
|
||||||
|
//
|
||||||
|
this.ButtonCreateTank.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.ButtonCreateTank.Location = new System.Drawing.Point(22, 806);
|
||||||
|
this.ButtonCreateTank.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
||||||
|
this.ButtonCreateTank.Name = "ButtonCreateTank";
|
||||||
|
this.ButtonCreateTank.Size = new System.Drawing.Size(139, 49);
|
||||||
|
this.ButtonCreateTank.TabIndex = 1;
|
||||||
|
this.ButtonCreateTank.Text = "Создать";
|
||||||
|
this.ButtonCreateTank.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonCreateTank.Click += new System.EventHandler(this.ButtonCreateTank_Click);
|
||||||
|
//
|
||||||
|
// buttonUp
|
||||||
|
//
|
||||||
|
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonUp.BackgroundImage = global::ProjectTank.Properties.Resources.btnUp;
|
||||||
|
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||||
|
this.buttonUp.Location = new System.Drawing.Point(1300, 730);
|
||||||
|
this.buttonUp.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
||||||
|
this.buttonUp.Name = "buttonUp";
|
||||||
|
this.buttonUp.Size = new System.Drawing.Size(56, 64);
|
||||||
|
this.buttonUp.TabIndex = 2;
|
||||||
|
this.buttonUp.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonRight
|
||||||
|
//
|
||||||
|
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonRight.BackgroundImage = global::ProjectTank.Properties.Resources.btnRight;
|
||||||
|
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||||
|
this.buttonRight.Location = new System.Drawing.Point(1367, 806);
|
||||||
|
this.buttonRight.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
||||||
|
this.buttonRight.Name = "buttonRight";
|
||||||
|
this.buttonRight.Size = new System.Drawing.Size(56, 64);
|
||||||
|
this.buttonRight.TabIndex = 3;
|
||||||
|
this.buttonRight.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonLeft
|
||||||
|
//
|
||||||
|
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonLeft.BackgroundImage = global::ProjectTank.Properties.Resources.btnLeft;
|
||||||
|
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||||
|
this.buttonLeft.Location = new System.Drawing.Point(1233, 806);
|
||||||
|
this.buttonLeft.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
||||||
|
this.buttonLeft.Name = "buttonLeft";
|
||||||
|
this.buttonLeft.Size = new System.Drawing.Size(56, 64);
|
||||||
|
this.buttonLeft.TabIndex = 4;
|
||||||
|
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonDown
|
||||||
|
//
|
||||||
|
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonDown.BackgroundImage = global::ProjectTank.Properties.Resources.btnDown;
|
||||||
|
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||||
|
this.buttonDown.Location = new System.Drawing.Point(1300, 806);
|
||||||
|
this.buttonDown.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
||||||
|
this.buttonDown.Name = "buttonDown";
|
||||||
|
this.buttonDown.Size = new System.Drawing.Size(56, 64);
|
||||||
|
this.buttonDown.TabIndex = 5;
|
||||||
|
this.buttonDown.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(1172, 0);
|
||||||
|
this.label1.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(0, 32);
|
||||||
|
this.label1.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// TankForm
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(1445, 881);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.buttonDown);
|
||||||
|
this.Controls.Add(this.buttonLeft);
|
||||||
|
this.Controls.Add(this.buttonRight);
|
||||||
|
this.Controls.Add(this.buttonUp);
|
||||||
|
this.Controls.Add(this.ButtonCreateTank);
|
||||||
|
this.Controls.Add(this.pictureBoxTanks);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
||||||
|
this.Name = "TankForm";
|
||||||
|
this.Text = "Tank";
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTanks)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private Button ButtonCreateTank;
|
||||||
|
private Button buttonUp;
|
||||||
|
private Button buttonRight;
|
||||||
|
private Button buttonLeft;
|
||||||
|
private Button buttonDown;
|
||||||
|
public PictureBox pictureBoxTanks;
|
||||||
|
private Label label1;
|
||||||
|
}
|
||||||
|
}
|
81
ProjectTank/ProjectTank/TankForm.cs
Normal file
81
ProjectTank/ProjectTank/TankForm.cs
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
using System.Reflection.Emit;
|
||||||
|
|
||||||
|
namespace ProjectTank
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Ôîðìà ðàáîòû ñ îáúåêòîì "Òàíê"
|
||||||
|
/// </summary>
|
||||||
|
public partial class TankForm : Form
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Ïîëå-îáúåêò äëÿ ïðîðèñîâêè îáúåêòà
|
||||||
|
/// </summary>
|
||||||
|
private DrawningTank? _drawningTank;
|
||||||
|
/// <summary>
|
||||||
|
/// Èíèöèàëèçàöèÿ ôîðìû
|
||||||
|
/// </summary>
|
||||||
|
public TankForm()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Ìåòîä ïðîðèñîâêè ìàøèíû
|
||||||
|
/// </summary>
|
||||||
|
private void Draw()
|
||||||
|
{
|
||||||
|
if (_drawningTank == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Bitmap bmp = new(pictureBoxTanks.Width, pictureBoxTanks.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_drawningTank.DrawTransport(gr);
|
||||||
|
pictureBoxTanks.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)),
|
||||||
|
pictureBoxTanks.Width, pictureBoxTanks.Height);
|
||||||
|
_drawningTank.SetPosition(random.Next(0, 100), random.Next(0, 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;
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
ProjectTank/ProjectTank/TankForm.resx
Normal file
60
ProjectTank/ProjectTank/TankForm.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<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>
|
Loading…
Reference in New Issue
Block a user