From 63a9eb093e6dc56eb41396d40c19dd383d772383 Mon Sep 17 00:00:00 2001 From: vladimir_zinovev Date: Thu, 21 Sep 2023 22:32:58 +0400 Subject: [PATCH] lab1 is done --- .DS_Store | Bin 0 -> 6148 bytes ProjectTank/.DS_Store | Bin 0 -> 6148 bytes ProjectTank/ProjectTank/DrawningTank.cs | 200 ++++++++++++++++++ .../{EnityTank.cs => EntityTank.cs} | 12 +- ProjectTank/ProjectTank/Form1.Designer.cs | 39 ---- ProjectTank/ProjectTank/Form1.cs | 10 - ProjectTank/ProjectTank/Program.cs | 9 +- ProjectTank/ProjectTank/ProjectTank.csproj | 15 ++ .../Properties/Resources.Designer.cs | 103 +++++++++ .../{Form1.resx => Properties/Resources.resx} | 13 ++ ProjectTank/ProjectTank/Resources/btnDown.png | Bin 0 -> 333 bytes ProjectTank/ProjectTank/Resources/btnLeft.png | Bin 0 -> 328 bytes .../ProjectTank/Resources/btnRight.png | Bin 0 -> 335 bytes ProjectTank/ProjectTank/Resources/btnUp.png | Bin 0 -> 333 bytes ProjectTank/ProjectTank/TankForm.Designer.cs | 148 +++++++++++++ ProjectTank/ProjectTank/TankForm.cs | 84 ++++++++ ProjectTank/ProjectTank/TankForm.resx | 60 ++++++ images/btnDown.png | Bin 0 -> 333 bytes images/btnLeft.png | Bin 0 -> 328 bytes images/btnRight.png | Bin 0 -> 335 bytes images/btnUp.png | Bin 0 -> 333 bytes 21 files changed, 630 insertions(+), 63 deletions(-) create mode 100644 .DS_Store create mode 100644 ProjectTank/.DS_Store create mode 100644 ProjectTank/ProjectTank/DrawningTank.cs rename ProjectTank/ProjectTank/{EnityTank.cs => EntityTank.cs} (83%) delete mode 100644 ProjectTank/ProjectTank/Form1.Designer.cs delete mode 100644 ProjectTank/ProjectTank/Form1.cs create mode 100644 ProjectTank/ProjectTank/Properties/Resources.Designer.cs rename ProjectTank/ProjectTank/{Form1.resx => Properties/Resources.resx} (83%) create mode 100644 ProjectTank/ProjectTank/Resources/btnDown.png create mode 100644 ProjectTank/ProjectTank/Resources/btnLeft.png create mode 100644 ProjectTank/ProjectTank/Resources/btnRight.png create mode 100644 ProjectTank/ProjectTank/Resources/btnUp.png create mode 100644 ProjectTank/ProjectTank/TankForm.Designer.cs create mode 100644 ProjectTank/ProjectTank/TankForm.cs create mode 100644 ProjectTank/ProjectTank/TankForm.resx create mode 100644 images/btnDown.png create mode 100644 images/btnLeft.png create mode 100644 images/btnRight.png create mode 100644 images/btnUp.png diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..65b000cd43cfc78c06da3fba22e05f3e40646349 GIT binary patch literal 6148 zcmeHKOHRWu5Pj1|(9%tpY>;w-NZcT;(gh17L^%NTqX-CzR7%&`a~RIY3f|bJQeBW( zAwV*FmQ8dR{)y!vAGvinjn*4qS z^xY-MP~sNr=>3g2m%TZ08#(&$qi=~C4OUo2F)vX}moXbW?s~~{! zW55{ra}4N-N9hebT5Aj#1IECX0X-j5s$w3n_2`ZcHm(F9CNw)?-~IX%Q#BCtfUQSb zDB?qjK2$=9A)#^*AI|wa__rQ?IK-{YJYi)C6^ewyLsI7s$vs+Y3>X8u40Qc)sQ3Tm z>-v8;$VSG1G4QV#kffLvV{R$jt$Ul(yEdg>Q&rTj^|%dT$6dwr)vNfJ>V)=GJH$L- S>yZ|U{RlW3tT6_Dl!15i;$Xx8 literal 0 HcmV?d00001 diff --git a/ProjectTank/.DS_Store b/ProjectTank/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..4daa337b619a76d0b2fb526e100d33398ff65203 GIT binary patch literal 6148 zcmeHK%}N6?5dOyYQ0T!Py$E@Nf^QH@J$Mu918A!Vy6i%$J?D*lMEzza3S0Nklc3B% z@+Fy{WIxzU27oNy9xi|xfC-zT=wLu}c~EsyjmJdM7~N*wbZgEu+}{vA`v`OFvAb@1 z=f9+8{$XODGQ|zH=>jg z4^BgZfnXpQ2nK?IqZ!c5Lzzq+qYnmxfnea90lgm*n_{k59PR30XC(kppV1~9+vA^@ zbb**F7Duj7#9fK*Dz(IrT04llQ=hASaddZx?aVlJ=da>LYUv@#%put^`d}a!=rb_# z=}hzg6@R6{BERnvvtS??_-72rc)40G_)#^t{`fr2wTbPHO-1dB4k#R3DkfSg=0xw2 eGgG=g>6rRlu{dfJT{m}PJOqr8=z@V?VBiz=yFEkz literal 0 HcmV?d00001 diff --git a/ProjectTank/ProjectTank/DrawningTank.cs b/ProjectTank/ProjectTank/DrawningTank.cs new file mode 100644 index 0000000..eba26d2 --- /dev/null +++ b/ProjectTank/ProjectTank/DrawningTank.cs @@ -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 + { + /// + /// Класс-сущность + /// + public EntityTank? _EntityTank { get; private set; } + /// + /// Ширина окна + /// + private int _pictureWidth; + /// + /// Высота окна + /// + private int _pictureHeight; + + /// + /// Левая координата прорисовки танка + /// + private int _startPosX; + /// + /// Верхняя кооридната прорисовки танка + /// + private int _startPosY; + /// + /// Левая координата прорисовки танка + /// + // private int _endPosX; + /// + /// Верхняя кооридната прорисовки танка + /// + // private int _endPosY; + /// + /// Ширина прорисовки танка + /// + private readonly int _tankWidth = 200; + /// + /// Высота прорисовки танка + /// + private readonly int _tankHeight = 80; + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес + /// Цвет кузова + /// Дополнительный цвет + /// Ширина картинки + /// Высота картинки + /// true - объект создан, false - проверка не пройдена,нельзя создать объект в этих размерах + + 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; + } + /// + /// Установка позиции + /// + /// Координата X + /// Координата Y + public void SetPosition(int x, int y) + { + // TODO: Изменение x, y + _startPosX = x; + _startPosY = y; + + _pictureWidth= x + _tankWidth; + _pictureHeight= y + _tankHeight; + } + /// + /// Изменение направления перемещения + /// + /// Направление + 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; + } + } + /// + /// Прорисовка объекта + /// + /// + 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); + + } + } + } +} diff --git a/ProjectTank/ProjectTank/EnityTank.cs b/ProjectTank/ProjectTank/EntityTank.cs similarity index 83% rename from ProjectTank/ProjectTank/EnityTank.cs rename to ProjectTank/ProjectTank/EntityTank.cs index b34bebd..d9103aa 100644 --- a/ProjectTank/ProjectTank/EnityTank.cs +++ b/ProjectTank/ProjectTank/EntityTank.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace ProjectTank { - internal class EnityTank + public class EntityTank { /// /// Скорость @@ -18,11 +18,6 @@ namespace ProjectTank /// public double Weight { get; private set; } - /// - /// Башня - /// - public bool Tower { get; private set; } - /// /// Пушка /// @@ -55,18 +50,15 @@ namespace ProjectTank /// Вес автомобиля /// Основной цвет /// Дополнительный цвет - /// Признак наличия башни /// Признак наличия пушки /// Признак наличия пулемета /// - 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; } diff --git a/ProjectTank/ProjectTank/Form1.Designer.cs b/ProjectTank/ProjectTank/Form1.Designer.cs deleted file mode 100644 index 6b0ceb0..0000000 --- a/ProjectTank/ProjectTank/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace ProjectTank -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - 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 - } -} \ No newline at end of file diff --git a/ProjectTank/ProjectTank/Form1.cs b/ProjectTank/ProjectTank/Form1.cs deleted file mode 100644 index 5ad885c..0000000 --- a/ProjectTank/ProjectTank/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ProjectTank -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/ProjectTank/ProjectTank/Program.cs b/ProjectTank/ProjectTank/Program.cs index e967a59..149fdd8 100644 --- a/ProjectTank/ProjectTank/Program.cs +++ b/ProjectTank/ProjectTank/Program.cs @@ -1,17 +1,18 @@ +using System.Drawing; + namespace ProjectTank { internal static class Program { /// - /// The main entry point for the application. + /// The main entry point for the application. /// [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()); } } } \ No newline at end of file diff --git a/ProjectTank/ProjectTank/ProjectTank.csproj b/ProjectTank/ProjectTank/ProjectTank.csproj index b57c89e..13ee123 100644 --- a/ProjectTank/ProjectTank/ProjectTank.csproj +++ b/ProjectTank/ProjectTank/ProjectTank.csproj @@ -8,4 +8,19 @@ enable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/ProjectTank/ProjectTank/Properties/Resources.Designer.cs b/ProjectTank/ProjectTank/Properties/Resources.Designer.cs new file mode 100644 index 0000000..c600bc6 --- /dev/null +++ b/ProjectTank/ProjectTank/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectTank.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом 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() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [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; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap btnDown { + get { + object obj = ResourceManager.GetObject("btnDown", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap btnLeft { + get { + object obj = ResourceManager.GetObject("btnLeft", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap btnRight { + get { + object obj = ResourceManager.GetObject("btnRight", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap btnUp { + get { + object obj = ResourceManager.GetObject("btnUp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ProjectTank/ProjectTank/Form1.resx b/ProjectTank/ProjectTank/Properties/Resources.resx similarity index 83% rename from ProjectTank/ProjectTank/Form1.resx rename to ProjectTank/ProjectTank/Properties/Resources.resx index 1af7de1..4be9f4a 100644 --- a/ProjectTank/ProjectTank/Form1.resx +++ b/ProjectTank/ProjectTank/Properties/Resources.resx @@ -117,4 +117,17 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\btnDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\btnLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\btnRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\btnUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/ProjectTank/ProjectTank/Resources/btnDown.png b/ProjectTank/ProjectTank/Resources/btnDown.png new file mode 100644 index 0000000000000000000000000000000000000000..51559f1b8b8eb6510faeb32648652cba810d57e9 GIT binary patch literal 333 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3oCO|{#S9GG!XV7ZFl&wkP>``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&eB{v%Hp$B+ufw^I-DHXHD`&RxZ9z?5@HBZonn zVX^^}vH{mk1?43_EkpLIY@EAl?-Nf!g#-H2{)j$i{=zP|B;kI!(Xk_~zvp-EcN8`+ z1fkC#Ir|KwIK?MiyH=e5-~ zk^9qjrFI_NmYef&*Sa~AY&I6_@p->>=sfzs=KQK3D~>9N>+hMYAoTpvQAv%h5;~_B zb@^|VX#OUt&ogC9w1S;V(-f!c@1IxB(>&qX)tRd;(WV&ZynV?-PcNsE6H(q#S7fh$ aV%l`X{$klhp;JKLGI+ZBxvX``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&eB{#{QO$B+ufx6>{PHY@NrB(G<-Xj*L1rM#nY zSEJtoX&~nW+XhFjEnhBFZ3*bK-?O{sS)88YMIO}xM)MsVDt<}omrWcEBo1uSiI}F! zwk&&((e=`!t5$8f;1Xi^T;}$+qc-QwFRge~Id7vz7k{G3MqBsrIcj0KYhV9b{UQG2 z-MWXd*B$SFS7>R7547B8;`>=Aa_d#o4Rv$hmJV VTlHn7s4LK;44$rjF6*2UngIKKf|LLN literal 0 HcmV?d00001 diff --git a/ProjectTank/ProjectTank/Resources/btnRight.png b/ProjectTank/ProjectTank/Resources/btnRight.png new file mode 100644 index 0000000000000000000000000000000000000000..5d43457866fe03ad7f97835e026d24b8f9852704 GIT binary patch literal 335 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3oCO|{#S9GG!XV7ZFl&wkP>``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&eB{u56Z$B+ufx6|J8x*CYI_0P6$;FUP4VV1z` z)5O_xK+VnIQ1xxKqWuB3p?@!{TYhxDXLB~wzf(bh-{yp{qs)=rUuyls8ajKHWp-80 zJ9yA*PuRTY$GCU6=xFyPUn#A%<5%1NXlu&v-RmwtKbYdbCu~}3``dE0Yj6Jt&wH~h z^MvT4wM#_;DE6wUt548Ag3+LFV zbGly6r^Lz9@3Fv3(5q?Db360@d%XB|v2#am^bG;c-Ry_X d#|c``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&eB{v%Hp$B+ufx6=>uwkQa=7HV%`d3z*C=b(_z zLB1u-UJZU4jY4UX!aX;242)AYi^qL>?D*8v$o>eU(kuQwQv}v-Ejp*E*<5n`vrT;X z`@KSpOnr|J^zYsD-r6If`!QeQtYy(QeabBY4cyUt*1gvCy}6Bd$A%+2Zu@6;ZJoAR z#D9;DcUaH&IwiaF#@fDy#{#A=?w-#)mD|o))?|`|cJSn)*P)`19THPlB-M!B&lIa) z?XUa8Z}N_i`B7P4wYoH!Ro8}x`K{Y- literal 0 HcmV?d00001 diff --git a/ProjectTank/ProjectTank/TankForm.Designer.cs b/ProjectTank/ProjectTank/TankForm.Designer.cs new file mode 100644 index 0000000..c8abd55 --- /dev/null +++ b/ProjectTank/ProjectTank/TankForm.Designer.cs @@ -0,0 +1,148 @@ +namespace ProjectTank +{ + partial class TankForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} \ No newline at end of file diff --git a/ProjectTank/ProjectTank/TankForm.cs b/ProjectTank/ProjectTank/TankForm.cs new file mode 100644 index 0000000..c05b907 --- /dev/null +++ b/ProjectTank/ProjectTank/TankForm.cs @@ -0,0 +1,84 @@ +using System.Reflection.Emit; + +namespace ProjectTank +{ + /// + /// "" + /// + public partial class TankForm : Form + { + private void TankForm_Load(object sender, EventArgs e) + { + + } + + + /// + /// - + /// + private DrawningTank? _drawningTank; + /// + /// + /// + public TankForm() + { + InitializeComponent(); + } + /// + /// + /// + 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; + } + /// + /// "" + /// + /// + /// + 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(); + } + /// + /// + /// + /// + /// + 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(); + } + } +} \ No newline at end of file diff --git a/ProjectTank/ProjectTank/TankForm.resx b/ProjectTank/ProjectTank/TankForm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/ProjectTank/ProjectTank/TankForm.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/images/btnDown.png b/images/btnDown.png new file mode 100644 index 0000000000000000000000000000000000000000..51559f1b8b8eb6510faeb32648652cba810d57e9 GIT binary patch literal 333 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3oCO|{#S9GG!XV7ZFl&wkP>``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&eB{v%Hp$B+ufw^I-DHXHD`&RxZ9z?5@HBZonn zVX^^}vH{mk1?43_EkpLIY@EAl?-Nf!g#-H2{)j$i{=zP|B;kI!(Xk_~zvp-EcN8`+ z1fkC#Ir|KwIK?MiyH=e5-~ zk^9qjrFI_NmYef&*Sa~AY&I6_@p->>=sfzs=KQK3D~>9N>+hMYAoTpvQAv%h5;~_B zb@^|VX#OUt&ogC9w1S;V(-f!c@1IxB(>&qX)tRd;(WV&ZynV?-PcNsE6H(q#S7fh$ aV%l`X{$klhp;JKLGI+ZBxvX``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&eB{#{QO$B+ufx6>{PHY@NrB(G<-Xj*L1rM#nY zSEJtoX&~nW+XhFjEnhBFZ3*bK-?O{sS)88YMIO}xM)MsVDt<}omrWcEBo1uSiI}F! zwk&&((e=`!t5$8f;1Xi^T;}$+qc-QwFRge~Id7vz7k{G3MqBsrIcj0KYhV9b{UQG2 z-MWXd*B$SFS7>R7547B8;`>=Aa_d#o4Rv$hmJV VTlHn7s4LK;44$rjF6*2UngIKKf|LLN literal 0 HcmV?d00001 diff --git a/images/btnRight.png b/images/btnRight.png new file mode 100644 index 0000000000000000000000000000000000000000..5d43457866fe03ad7f97835e026d24b8f9852704 GIT binary patch literal 335 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3oCO|{#S9GG!XV7ZFl&wkP>``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&eB{u56Z$B+ufx6|J8x*CYI_0P6$;FUP4VV1z` z)5O_xK+VnIQ1xxKqWuB3p?@!{TYhxDXLB~wzf(bh-{yp{qs)=rUuyls8ajKHWp-80 zJ9yA*PuRTY$GCU6=xFyPUn#A%<5%1NXlu&v-RmwtKbYdbCu~}3``dE0Yj6Jt&wH~h z^MvT4wM#_;DE6wUt548Ag3+LFV zbGly6r^Lz9@3Fv3(5q?Db360@d%XB|v2#am^bG;c-Ry_X d#|c``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&eB{v%Hp$B+ufx6=>uwkQa=7HV%`d3z*C=b(_z zLB1u-UJZU4jY4UX!aX;242)AYi^qL>?D*8v$o>eU(kuQwQv}v-Ejp*E*<5n`vrT;X z`@KSpOnr|J^zYsD-r6If`!QeQtYy(QeabBY4cyUt*1gvCy}6Bd$A%+2Zu@6;ZJoAR z#D9;DcUaH&IwiaF#@fDy#{#A=?w-#)mD|o))?|`|cJSn)*P)`19THPlB-M!B&lIa) z?XUa8Z}N_i`B7P4wYoH!Ro8}x`K{Y- literal 0 HcmV?d00001