lab1 is done
BIN
ProjectTank/.DS_Store
vendored
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 int _endPosX;
|
||||
/// <summary>
|
||||
/// Верхняя кооридната прорисовки танка
|
||||
/// </summary>
|
||||
// private int _endPosY;
|
||||
/// <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;
|
||||
_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)
|
||||
{
|
||||
// TODO: Изменение x, y
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
|
||||
_pictureWidth= x + _tankWidth;
|
||||
_pictureHeight= y + _tankHeight;
|
||||
}
|
||||
/// <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 + _pictureWidth + _EntityTank.Step < TankForm.ActiveForm.ClientSize.Width)
|
||||
{
|
||||
_startPosX += (int)_EntityTank.Step;
|
||||
}
|
||||
break;
|
||||
//вниз
|
||||
case DirectionType.Down:
|
||||
if (_startPosY + _pictureHeight + _EntityTank.Step < TankForm.ActiveForm.ClientSize.Height)
|
||||
{
|
||||
_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 point1 = new Point(_startPosX + 18, _startPosY + 35);
|
||||
Point point2 = new Point(_startPosX + 18, _startPosY + 55);
|
||||
Point point3 = new Point(_startPosX+0, _startPosY+55);
|
||||
Point point4 = new Point(_startPosX + 162, _startPosY + 35);
|
||||
Point point5 = new Point(_startPosX + 185, _startPosY + 55);
|
||||
Point point6 = new Point(_startPosX + 162, _startPosY + 55);
|
||||
|
||||
// Задняя часть
|
||||
Point[] curvePoints = { point1, point2, point3 };
|
||||
g.DrawPolygon(pen, curvePoints);
|
||||
g.FillPolygon(bodyBrush, curvePoints);
|
||||
// Передняя часть
|
||||
Point[] curvePoints2 ={point4,point5,point6};
|
||||
g.DrawPolygon(pen, curvePoints2);
|
||||
g.FillPolygon(bodyBrush, curvePoints2);
|
||||
|
||||
// пушка
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectTank
|
||||
{
|
||||
internal class EnityTank
|
||||
public class EntityTank
|
||||
{
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
@ -18,11 +18,6 @@ namespace ProjectTank
|
||||
/// </summary>
|
||||
public double Weight { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Башня
|
||||
/// </summary>
|
||||
public bool Tower { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Пушка
|
||||
/// </summary>
|
||||
@ -55,18 +50,15 @@ namespace ProjectTank
|
||||
/// <param name="weight">Вес автомобиля</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="tower">Признак наличия башни</param>
|
||||
/// <param name="gun">Признак наличия пушки</param>
|
||||
/// <param name="machineGun">Признак наличия пулемета</param>
|
||||
///
|
||||
public void Init(int speed, double weight, bool tower, bool gun, bool machineGun, Color bodyColor, Color
|
||||
additionalColor)
|
||||
public void Init(int speed, double weight, bool gun, bool machineGun, Color bodyColor, Color additionalColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
AdditionalColor = additionalColor;
|
||||
Tower = tower;
|
||||
Gun = gun;
|
||||
MachineGun = machineGun;
|
||||
}
|
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,18 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace ProjectTank
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// 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 TankForm());
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
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">
|
||||
<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="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>
|
BIN
ProjectTank/ProjectTank/Resources/btnDown.png
Normal file
After Width: | Height: | Size: 333 B |
BIN
ProjectTank/ProjectTank/Resources/btnLeft.png
Normal file
After Width: | Height: | Size: 328 B |
BIN
ProjectTank/ProjectTank/Resources/btnRight.png
Normal file
After Width: | Height: | Size: 335 B |
BIN
ProjectTank/ProjectTank/Resources/btnUp.png
Normal file
After Width: | Height: | Size: 333 B |
148
ProjectTank/ProjectTank/TankForm.Designer.cs
generated
Normal file
@ -0,0 +1,148 @@
|
||||
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.Name = "pictureBoxTanks";
|
||||
this.pictureBoxTanks.Size = new System.Drawing.Size(778, 413);
|
||||
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(12, 378);
|
||||
this.ButtonCreateTank.Name = "ButtonCreateTank";
|
||||
this.ButtonCreateTank.Size = new System.Drawing.Size(75, 23);
|
||||
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(700, 342);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
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(736, 378);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
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(664, 378);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
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(700, 378);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
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(631, 0);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(0, 15);
|
||||
this.label1.TabIndex = 6;
|
||||
//
|
||||
// TankForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(778, 413);
|
||||
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.Name = "TankForm";
|
||||
this.Text = "Tank";
|
||||
this.Load += new System.EventHandler(this.TankForm_Load);
|
||||
((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;
|
||||
}
|
||||
}
|
84
ProjectTank/ProjectTank/TankForm.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using System.Reflection.Emit;
|
||||
|
||||
namespace ProjectTank
|
||||
{
|
||||
/// <summary>
|
||||
/// Ôîðìà ðàáîòû ñ îáúåêòîì "Òàíê"
|
||||
/// </summary>
|
||||
public partial class TankForm : Form
|
||||
{
|
||||
private void TankForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <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(0,0);
|
||||
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
@ -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>
|
BIN
images/btnDown.png
Normal file
After Width: | Height: | Size: 333 B |
BIN
images/btnLeft.png
Normal file
After Width: | Height: | Size: 328 B |
BIN
images/btnRight.png
Normal file
After Width: | Height: | Size: 335 B |
BIN
images/btnUp.png
Normal file
After Width: | Height: | Size: 333 B |