From 0e65921327a5fd3756293297e23ec57de156226c Mon Sep 17 00:00:00 2001 From: asoc1al Date: Mon, 18 Sep 2023 12:47:53 +0400 Subject: [PATCH 1/7] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=201(=D0=B5=D1=81=D1=82=D1=8C=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D1=8B,=20=D0=BD=D0=B5=D1=82=20?= =?UTF-8?q?=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=BE=D0=BD=D0=B0=D0=BB?= =?UTF-8?q?=D0=B0=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BE=D0=BA)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DumpTruck/DumpTruck/Direction.cs | 16 +++ DumpTruck/DumpTruck/DrawingTruck.cs | 120 ++++++++++++++++++ DumpTruck/DumpTruck/DumpTruck.csproj | 15 +++ DumpTruck/DumpTruck/EntityTruck.cs | 27 ++++ DumpTruck/DumpTruck/Form1.cs | 10 -- ...orm1.Designer.cs => FormTruck.Designer.cs} | 10 +- DumpTruck/DumpTruck/FormTruck.cs | 28 ++++ DumpTruck/DumpTruck/FormTruck.resx | 60 +++++++++ DumpTruck/DumpTruck/Program.cs | 2 +- .../Properties/Resources.Designer.cs | 103 +++++++++++++++ .../{Form1.resx => Properties/Resources.resx} | 13 ++ DumpTruck/DumpTruck/Resources/down.jpg | Bin 0 -> 3703 bytes DumpTruck/DumpTruck/Resources/left.jpg | Bin 0 -> 3146 bytes DumpTruck/DumpTruck/Resources/right.jpg | Bin 0 -> 3706 bytes DumpTruck/DumpTruck/Resources/up.jpg | Bin 0 -> 3188 bytes 15 files changed, 388 insertions(+), 16 deletions(-) create mode 100644 DumpTruck/DumpTruck/Direction.cs create mode 100644 DumpTruck/DumpTruck/DrawingTruck.cs create mode 100644 DumpTruck/DumpTruck/EntityTruck.cs delete mode 100644 DumpTruck/DumpTruck/Form1.cs rename DumpTruck/DumpTruck/{Form1.Designer.cs => FormTruck.Designer.cs} (77%) create mode 100644 DumpTruck/DumpTruck/FormTruck.cs create mode 100644 DumpTruck/DumpTruck/FormTruck.resx create mode 100644 DumpTruck/DumpTruck/Properties/Resources.Designer.cs rename DumpTruck/DumpTruck/{Form1.resx => Properties/Resources.resx} (84%) create mode 100644 DumpTruck/DumpTruck/Resources/down.jpg create mode 100644 DumpTruck/DumpTruck/Resources/left.jpg create mode 100644 DumpTruck/DumpTruck/Resources/right.jpg create mode 100644 DumpTruck/DumpTruck/Resources/up.jpg diff --git a/DumpTruck/DumpTruck/Direction.cs b/DumpTruck/DumpTruck/Direction.cs new file mode 100644 index 0000000..fbff3f8 --- /dev/null +++ b/DumpTruck/DumpTruck/Direction.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DumpTruck +{ + internal enum Direction + { + Up = 1, + Down = 2, + Left = 3, + Right = 4 + } +} \ No newline at end of file diff --git a/DumpTruck/DumpTruck/DrawingTruck.cs b/DumpTruck/DumpTruck/DrawingTruck.cs new file mode 100644 index 0000000..fb1ab84 --- /dev/null +++ b/DumpTruck/DumpTruck/DrawingTruck.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DumpTruck +{ + internal class drawingTruck + { + public EntityTruck Truck { get; private set; } + private float _startPosX; + private float _startPosY; + private int? _pictureWidth = null; + private int? _pictureHeight = null; + protected readonly int _truckWidth = 100; + protected readonly int _truckHeight = 55; + public void Init(int speed, float weight, Color bodyColor) + { + Truck = new EntityTruck(); + Truck.Init(speed, weight, bodyColor); + } + public void SetPosition(int x, int y, int width, int height) + { + _startPosX = x; + _startPosY = y; + _pictureWidth = width; + _pictureHeight = height; + } + public void MoveTransport(Direction direction) + { + if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) + { + return; + } + switch (direction) + { + case Direction.Left: + if (_startPosX - Truck.Step > 0) + { + _startPosX -= Truck.Step; + } + break; + case Direction.Right: + if (_startPosX + _truckWidth + Truck.Step < _pictureWidth) + { + _startPosX += Truck.Step; + } + + break; + case Direction.Up: + if (_startPosY - Truck.Step > 0) + { + _startPosY -= Truck.Step; + } + break; + case Direction.Down: + if (_startPosY + _truckHeight + Truck.Step < _pictureHeight) + { + _startPosY += Truck.Step; + } + break; + + } + } + public void DrawTransport(Graphics g) + { + if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue) + { + return; + } + + + Brush br = new SolidBrush(Truck?.BodyColor ?? Color.Black); + g.FillRectangle(br, _startPosX + 80, _startPosY, 20, 30); + + Brush brBrown = new SolidBrush(Color.FromArgb(200, 150, 40)); + g.FillRectangle(brBrown, _startPosX, _startPosY + 30, 100, 5); + + Brush brBlack = new SolidBrush(Color.Black); + g.FillEllipse(brBlack, _startPosX, _startPosY + 35, 20, 20); + g.FillEllipse(brBlack, _startPosX + 22, _startPosY + 35, 20, 20); + g.FillEllipse(brBlack, _startPosX + 80, _startPosY + 35, 20, 20); + + Brush brWhite = new SolidBrush(Color.White); + g.FillEllipse(brWhite, _startPosX + 5, _startPosY + 40, 10, 10); + g.FillEllipse(brWhite, _startPosX + 27, _startPosY + 40, 10, 10); + g.FillEllipse(brWhite, _startPosX + 85, _startPosY + 40, 10, 10); + + Pen pen = new Pen(Color.Black); + + g.DrawRectangle(pen, _startPosX + 80, _startPosY, 20, 30); + g.DrawRectangle(pen, _startPosX, _startPosY + 30, 100, 5); + g.DrawEllipse(pen, _startPosX, _startPosY + 35, 20, 20); + g.DrawEllipse(pen, _startPosX + 22, _startPosY + 35, 20, 20); + g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20); + + } + public void ChangeBorders(int width, int height) + { + _pictureWidth = width; + _pictureHeight = height; + if (_pictureWidth <= _truckWidth || _pictureHeight <= _truckHeight) + { + _pictureHeight = null; + _pictureWidth = null; + return; + } + if (_startPosX + _truckWidth >= _pictureWidth) + { + _startPosX = _pictureWidth.Value - _truckWidth; + } + if (_startPosY + _truckHeight >= _pictureHeight) + { + _startPosY = _pictureHeight.Value - _truckHeight; + } + } + } +} \ No newline at end of file diff --git a/DumpTruck/DumpTruck/DumpTruck.csproj b/DumpTruck/DumpTruck/DumpTruck.csproj index b57c89e..13ee123 100644 --- a/DumpTruck/DumpTruck/DumpTruck.csproj +++ b/DumpTruck/DumpTruck/DumpTruck.csproj @@ -8,4 +8,19 @@ enable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/DumpTruck/DumpTruck/EntityTruck.cs b/DumpTruck/DumpTruck/EntityTruck.cs new file mode 100644 index 0000000..f0a7cd2 --- /dev/null +++ b/DumpTruck/DumpTruck/EntityTruck.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DumpTruck +{ + internal class EntityTruck + { + public int Speed { get; private set; } + + public float Weight { get; private set; } + + public Color BodyColor { get; private set; } + + public float Step => Speed * 100 / Weight; + + public void Init(int speed, float weight, Color bodyColor) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + } + } +} \ No newline at end of file diff --git a/DumpTruck/DumpTruck/Form1.cs b/DumpTruck/DumpTruck/Form1.cs deleted file mode 100644 index 2326120..0000000 --- a/DumpTruck/DumpTruck/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace DumpTruck -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/DumpTruck/DumpTruck/Form1.Designer.cs b/DumpTruck/DumpTruck/FormTruck.Designer.cs similarity index 77% rename from DumpTruck/DumpTruck/Form1.Designer.cs rename to DumpTruck/DumpTruck/FormTruck.Designer.cs index 073cfce..e2ceb32 100644 --- a/DumpTruck/DumpTruck/Form1.Designer.cs +++ b/DumpTruck/DumpTruck/FormTruck.Designer.cs @@ -1,6 +1,6 @@ namespace DumpTruck { - partial class Form1 + partial class FormTruck { /// /// Required designer variable. @@ -28,10 +28,10 @@ /// 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"; + components = new System.ComponentModel.Container(); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Text = "Form1"; } #endregion diff --git a/DumpTruck/DumpTruck/FormTruck.cs b/DumpTruck/DumpTruck/FormTruck.cs new file mode 100644 index 0000000..1a2608a --- /dev/null +++ b/DumpTruck/DumpTruck/FormTruck.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace DumpTruck +{ + public partial class FormTruck : Form + { + public FormTruck() + { + InitializeComponent(); + } + private void btnCreate_Click(object sender, EventArgs e) + { + + } + private void btnMove_Click(object sender, EventArgs e) + { + + } + } +} \ No newline at end of file diff --git a/DumpTruck/DumpTruck/FormTruck.resx b/DumpTruck/DumpTruck/FormTruck.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/DumpTruck/DumpTruck/FormTruck.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/DumpTruck/DumpTruck/Program.cs b/DumpTruck/DumpTruck/Program.cs index a716913..b5a689f 100644 --- a/DumpTruck/DumpTruck/Program.cs +++ b/DumpTruck/DumpTruck/Program.cs @@ -11,7 +11,7 @@ namespace DumpTruck // 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 FormTruck()); } } } \ No newline at end of file diff --git a/DumpTruck/DumpTruck/Properties/Resources.Designer.cs b/DumpTruck/DumpTruck/Properties/Resources.Designer.cs new file mode 100644 index 0000000..aac7e60 --- /dev/null +++ b/DumpTruck/DumpTruck/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace DumpTruck.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("DumpTruck.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 down { + get { + object obj = ResourceManager.GetObject("down", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap left { + get { + object obj = ResourceManager.GetObject("left", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap right { + get { + object obj = ResourceManager.GetObject("right", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap up { + get { + object obj = ResourceManager.GetObject("up", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/DumpTruck/DumpTruck/Form1.resx b/DumpTruck/DumpTruck/Properties/Resources.resx similarity index 84% rename from DumpTruck/DumpTruck/Form1.resx rename to DumpTruck/DumpTruck/Properties/Resources.resx index 1af7de1..3d5a144 100644 --- a/DumpTruck/DumpTruck/Form1.resx +++ b/DumpTruck/DumpTruck/Properties/Resources.resx @@ -117,4 +117,17 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\down.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\left.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\right.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\up.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/DumpTruck/DumpTruck/Resources/down.jpg b/DumpTruck/DumpTruck/Resources/down.jpg new file mode 100644 index 0000000000000000000000000000000000000000..aabdc4a1f9659ec8f5c3abc7680984a5b2a03056 GIT binary patch literal 3703 zcmd^BX;>528a^R}C4eE6fZzhMR0JXqTR|@pm0jyYK_NiI2xYermr{Zk4Fy>Y77E3n z*cJf=6(Q`1Qo<5IK-*HJXe>)WT4j+0HH;*gxs$fHz1aS^xA$kiIo~|3m1#a%CB6lsJwRlMtwtLQ*+C$ z*4tg({GQ&vyZr;-4L=z9e)QoZfpBX2$;^*GJ$*JSUV8EJm1G%uy`tcS0oY$?{l@GK zUPP3a5^4iwRRu4MQWC0IqB3rit%}YrKh>~fZ<*MAtfsp=zqGDX-PGP+L<&DXgx523 z5Soh>)P836-w{juOU!;F_B$^D(8OX;<6((_0_3tXwgo^H`#KE)=_98A>&|EYgB*1WS6Jyz#F-Vq*#S>^w2(}aK^$s0=iO7A&M%gvW3{=O+b5p~)^jzM^G zcc01j`ubX&w{faRGy=LG^5PgP+ZcJMU5>tD!QPh%3rlR+7y-h0dXtlUeM=t#WX>mf z2r%684LnUX)ti&V!2` zPRdzaq3>kn!X0tB6Nme{I%NiUFGG&0 znP<7PUuc$WM~0XvI8MZgm_fF~@tQv`Tpk90q4XfOp0j_#}~1T1+Ni6l0H zOK>i28UgV79drZ~SYV|oWxO0pT1oTb!k}~y^TzaUC{dgw;fmpw*qG55&){`pYPKWo zTKve6VH8_E6eak{USev5-{-X`9~Ns;SOPg++Jk_!B4*&?RAtwleH0H!UM9d;dlU#p z`#56b15K?b&g6=TyE~8bm6W<|iP=}1;h?r);SOrYAx8T>`8p|;Z&(v`>(+(Fj||Dh^=BDebNqNf+dqrQY4`5sm$lV6PDX$&+V5D&Gsbq`5rRwP)T0hW>iui;yQ{en~MTVX(>aU#^ z@OoCKIV*Z?8)@PE%rFoBMmU z2kSs;?LGJKE%7{#jULlCK%~!ZB5Q;WJ8J3Eh7x9KA2>**NzJ!wZ=D_3t6AqvSf4#R zFwj9VPQ#Go66#ErY`r}KR9?i=MgEKUG1&o#8e934XVggBX`WqA3xSr#&G4L-tw;06 zO)P@82Bq!{iZZd)ZSF7{I8Q2_`bK@WT}d2xwe-mCsM4~zljI+o4Kqtv36jx3ed0Es zFwSPobpD3m;2@4mQ5xMWcJj!GtOSFfQWhC;UKkBu?F)eKt=-P4Z0i*1; zfW(Bl38+|nAax$YupHmR6j#x>1qslCG!)pxC+?U+Qg|;MRB*2y_ zR*l0i>3IV3WgUJnxjH48p@Z8?D{}T;B@Q$<}YUD+D(*m6eO z5g}KbN#P6VMUwlbwBZUgpk3~MA0)eL9+2fI0oC8xcyzgyuEy#_flp>_)ItyK zs}w_8Rp7A9N?hL6eC|tqv0JbEiHcwZG%zGeOTl*kIup5F^djc!SbHPtkXi3YICwVLkf&@ZUT(KXL!ck|)ss?1$~-<(8+@_Afy(ioX3V|#KLQf`)imIH?Tudb&EC~j8$EWk zD>kdL`}@&o-`yyS$5bzzSEeWspWts zVl#TfXy-nvq!5x$va&*SS58&5pnGWtF&VyJ%E!oIx7u2B$2XtPS2PCxJ$~6h=re`3 W>QdBy{%Xx~z5GVwu4v?uNB;s+v+WB2 literal 0 HcmV?d00001 diff --git a/DumpTruck/DumpTruck/Resources/left.jpg b/DumpTruck/DumpTruck/Resources/left.jpg new file mode 100644 index 0000000000000000000000000000000000000000..36676e19f5d91e6f70d8e6221d7b62840195b22a GIT binary patch literal 3146 zcmc&$X;4$i7Vc~$1R;b~TqX!OAd3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>$GFRwJ(GJA<~sZ6S#M$>(< zCohxP{0z029-j3y+(XyaF+8mK7r&VvJE+?z0fW`{1R4(mDeI7JkH$@_UMDCK3>?1< zcTxtH0aPGAIZz@$d0VPqIa`_RBNH8|VC}YM*L&CRP4AEe?h7JXeBb!PY&*S~Y31j0 z&26%Z{!E_K`>Q&W8M1YVHvSuhSL!X!|20Z&sBG*CFbgw#iB;BGzt9AH zx%Br1q18B4zjWw?6c4V=N>Vj4m>1luC#XU`;{|kI?gv6vOJ)4kX!gT<($T#DA0kPv?f?J) literal 0 HcmV?d00001 -- 2.25.1 From 241a0e3ca4188b3bdd054bb18ee8620750c9ec5c Mon Sep 17 00:00:00 2001 From: Katerina881 Date: Sat, 7 Oct 2023 09:40:07 +0400 Subject: [PATCH 2/7] . --- DumpTruck/DumpTruck/DrawingTruck.cs | 30 +----- DumpTruck/DumpTruck/FormTruck.Designer.cs | 111 +++++++++++++++++++++- DumpTruck/DumpTruck/FormTruck.cs | 26 ++++- 3 files changed, 135 insertions(+), 32 deletions(-) diff --git a/DumpTruck/DumpTruck/DrawingTruck.cs b/DumpTruck/DumpTruck/DrawingTruck.cs index fb1ab84..7dac9ad 100644 --- a/DumpTruck/DumpTruck/DrawingTruck.cs +++ b/DumpTruck/DumpTruck/DrawingTruck.cs @@ -7,26 +7,24 @@ using System.Threading.Tasks; namespace DumpTruck { - internal class drawingTruck + internal class DrawingTruck { public EntityTruck Truck { get; private set; } private float _startPosX; private float _startPosY; private int? _pictureWidth = null; private int? _pictureHeight = null; - protected readonly int _truckWidth = 100; - protected readonly int _truckHeight = 55; + protected readonly int _truckWidth = 110; + protected readonly int _truckHeight = 60; public void Init(int speed, float weight, Color bodyColor) { Truck = new EntityTruck(); Truck.Init(speed, weight, bodyColor); } - public void SetPosition(int x, int y, int width, int height) + public void SetPosition(int x, int y) { _startPosX = x; _startPosY = y; - _pictureWidth = width; - _pictureHeight = height; } public void MoveTransport(Direction direction) { @@ -95,26 +93,6 @@ namespace DumpTruck g.DrawEllipse(pen, _startPosX, _startPosY + 35, 20, 20); g.DrawEllipse(pen, _startPosX + 22, _startPosY + 35, 20, 20); g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20); - - } - public void ChangeBorders(int width, int height) - { - _pictureWidth = width; - _pictureHeight = height; - if (_pictureWidth <= _truckWidth || _pictureHeight <= _truckHeight) - { - _pictureHeight = null; - _pictureWidth = null; - return; - } - if (_startPosX + _truckWidth >= _pictureWidth) - { - _startPosX = _pictureWidth.Value - _truckWidth; - } - if (_startPosY + _truckHeight >= _pictureHeight) - { - _startPosY = _pictureHeight.Value - _truckHeight; - } } } } \ No newline at end of file diff --git a/DumpTruck/DumpTruck/FormTruck.Designer.cs b/DumpTruck/DumpTruck/FormTruck.Designer.cs index e2ceb32..47c7eda 100644 --- a/DumpTruck/DumpTruck/FormTruck.Designer.cs +++ b/DumpTruck/DumpTruck/FormTruck.Designer.cs @@ -28,12 +28,115 @@ /// private void InitializeComponent() { - components = new System.ComponentModel.Container(); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); - Text = "Form1"; + this.btnCreate = new System.Windows.Forms.Button(); + this.btnLeft = new System.Windows.Forms.Button(); + this.btnDown = new System.Windows.Forms.Button(); + this.btnRight = new System.Windows.Forms.Button(); + this.btnUp = new System.Windows.Forms.Button(); + this.pictureBoxTruck = new System.Windows.Forms.PictureBox(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTruck)).BeginInit(); + this.SuspendLayout(); + // + // btnCreate + // + this.btnCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnCreate.Location = new System.Drawing.Point(12, 426); + this.btnCreate.Name = "btnCreate"; + this.btnCreate.Size = new System.Drawing.Size(75, 23); + this.btnCreate.TabIndex = 0; + this.btnCreate.Text = "Создать"; + this.btnCreate.UseVisualStyleBackColor = true; + this.btnCreate.Click += new System.EventHandler(this.btnCreate_Click); + // + // btnLeft + // + this.btnLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnLeft.BackgroundImage = global::DumpTruck.Properties.Resources.left; + this.btnLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.btnLeft.Location = new System.Drawing.Point(766, 419); + this.btnLeft.Name = "btnLeft"; + this.btnLeft.Size = new System.Drawing.Size(30, 30); + this.btnLeft.TabIndex = 1; + this.btnLeft.Text = " "; + this.btnLeft.UseVisualStyleBackColor = true; + this.btnLeft.Click += new System.EventHandler(this.btnMove_Click); + // + // btnDown + // + this.btnDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnDown.BackgroundImage = global::DumpTruck.Properties.Resources.down; + this.btnDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.btnDown.Location = new System.Drawing.Point(802, 419); + this.btnDown.Name = "btnDown"; + this.btnDown.Size = new System.Drawing.Size(30, 30); + this.btnDown.TabIndex = 2; + this.btnDown.Text = " "; + this.btnDown.UseVisualStyleBackColor = true; + this.btnDown.Click += new System.EventHandler(this.btnMove_Click); + // + // btnRight + // + this.btnRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnRight.BackgroundImage = global::DumpTruck.Properties.Resources.right; + this.btnRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.btnRight.Location = new System.Drawing.Point(838, 419); + this.btnRight.Name = "btnRight"; + this.btnRight.Size = new System.Drawing.Size(30, 30); + this.btnRight.TabIndex = 3; + this.btnRight.Text = " "; + this.btnRight.UseVisualStyleBackColor = true; + this.btnRight.Click += new System.EventHandler(this.btnMove_Click); + // + // btnUp + // + this.btnUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnUp.BackgroundImage = global::DumpTruck.Properties.Resources.up; + this.btnUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.btnUp.Location = new System.Drawing.Point(802, 383); + this.btnUp.Name = "btnUp"; + this.btnUp.Size = new System.Drawing.Size(30, 30); + this.btnUp.TabIndex = 4; + this.btnUp.Text = " "; + this.btnUp.UseVisualStyleBackColor = true; + this.btnUp.Click += new System.EventHandler(this.btnMove_Click); + // + // pictureBoxTruck + // + this.pictureBoxTruck.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBoxTruck.Location = new System.Drawing.Point(0, 0); + this.pictureBoxTruck.Name = "pictureBoxTruck"; + this.pictureBoxTruck.Size = new System.Drawing.Size(884, 461); + this.pictureBoxTruck.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.pictureBoxTruck.TabIndex = 5; + this.pictureBoxTruck.TabStop = false; + // + // FormTruck + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(884, 461); + this.Controls.Add(this.btnUp); + this.Controls.Add(this.btnRight); + this.Controls.Add(this.btnDown); + this.Controls.Add(this.btnLeft); + this.Controls.Add(this.btnCreate); + this.Controls.Add(this.pictureBoxTruck); + this.Name = "FormTruck"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "FormTruck"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTruck)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + } #endregion + + private Button btnCreate; + private Button btnLeft; + private Button btnDown; + private Button btnRight; + private Button btnUp; + private PictureBox pictureBoxTruck; } } \ No newline at end of file diff --git a/DumpTruck/DumpTruck/FormTruck.cs b/DumpTruck/DumpTruck/FormTruck.cs index 1a2608a..f8724eb 100644 --- a/DumpTruck/DumpTruck/FormTruck.cs +++ b/DumpTruck/DumpTruck/FormTruck.cs @@ -12,17 +12,39 @@ namespace DumpTruck { public partial class FormTruck : Form { + + private DrawingTruck? _drawningTruck; + + private void Draw() + { + if (_drawningTruck == null) + { + return; + } + Bitmap bmp = new(pictureBoxTruck.Width, + pictureBoxTruck.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawningTruck.DrawTransport(gr); + pictureBoxTruck.Image = bmp; + } + public FormTruck() { InitializeComponent(); } + private void btnCreate_Click(object sender, EventArgs e) { - + Random random = new(); + _drawningTruck = new DrawingTruck(); + _drawningTruck.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256))); + _drawningTruck.SetPosition(random.Next(1, 100), random.Next(1, 100)); + Draw(); } + private void btnMove_Click(object sender, EventArgs e) { - + } } } \ No newline at end of file -- 2.25.1 From 698646124819a6b533d4a0fa323170171ecd355e Mon Sep 17 00:00:00 2001 From: asoc1al Date: Sat, 7 Oct 2023 10:46:14 +0400 Subject: [PATCH 3/7] All done --- DumpTruck/DumpTruck/Direction.cs | 2 +- DumpTruck/DumpTruck/DrawingTruck.cs | 70 +++++++++++++++++------------ DumpTruck/DumpTruck/FormTruck.cs | 28 ++++++++++-- 3 files changed, 68 insertions(+), 32 deletions(-) diff --git a/DumpTruck/DumpTruck/Direction.cs b/DumpTruck/DumpTruck/Direction.cs index fbff3f8..8cd74cb 100644 --- a/DumpTruck/DumpTruck/Direction.cs +++ b/DumpTruck/DumpTruck/Direction.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace DumpTruck { - internal enum Direction + internal enum DirectionType { Up = 1, Down = 2, diff --git a/DumpTruck/DumpTruck/DrawingTruck.cs b/DumpTruck/DumpTruck/DrawingTruck.cs index 7dac9ad..566a34e 100644 --- a/DumpTruck/DumpTruck/DrawingTruck.cs +++ b/DumpTruck/DumpTruck/DrawingTruck.cs @@ -9,58 +9,65 @@ namespace DumpTruck { internal class DrawingTruck { - public EntityTruck Truck { get; private set; } + public EntityTruck? EntityTruck { get; private set; } private float _startPosX; private float _startPosY; - private int? _pictureWidth = null; - private int? _pictureHeight = null; + private int? _pictureWidth; + private int? _pictureHeight; protected readonly int _truckWidth = 110; protected readonly int _truckHeight = 60; - public void Init(int speed, float weight, Color bodyColor) + public bool Init(int speed, float weight, Color bodyColor, int width, int height) { - Truck = new EntityTruck(); - Truck.Init(speed, weight, bodyColor); + _pictureWidth = width; + _pictureHeight = height; + EntityTruck = new EntityTruck(); + EntityTruck.Init(speed, weight, bodyColor); + return true; } public void SetPosition(int x, int y) { _startPosX = x; _startPosY = y; } - public void MoveTransport(Direction direction) + public void MoveTransport(DirectionType direction) { - if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) + if (EntityTruck == null) + { return; } + switch (direction) { - case Direction.Left: - if (_startPosX - Truck.Step > 0) + case DirectionType.Left: + if (_startPosX - EntityTruck.Step > 0) { - _startPosX -= Truck.Step; + _startPosX -= (int)EntityTruck.Step; } break; - case Direction.Right: - if (_startPosX + _truckWidth + Truck.Step < _pictureWidth) + //вверх + case DirectionType.Up: + if (_startPosY - EntityTruck.Step > 0) { - _startPosX += Truck.Step; - } - - break; - case Direction.Up: - if (_startPosY - Truck.Step > 0) - { - _startPosY -= Truck.Step; + _startPosY -= (int)EntityTruck.Step; } break; - case Direction.Down: - if (_startPosY + _truckHeight + Truck.Step < _pictureHeight) + //вправо + case DirectionType.Right: + if (_startPosX + EntityTruck.Step + _truckWidth < _pictureWidth) { - _startPosY += Truck.Step; + _startPosX += (int)EntityTruck.Step; + } + break; + case DirectionType.Down: + if (_startPosY + EntityTruck.Step + _truckHeight < _pictureHeight) + { + _startPosY += (int)EntityTruck.Step; } break; - } + + } public void DrawTransport(Graphics g) { @@ -70,11 +77,11 @@ namespace DumpTruck } - Brush br = new SolidBrush(Truck?.BodyColor ?? Color.Black); + Brush br = new SolidBrush(EntityTruck?.BodyColor ?? Color.Black); g.FillRectangle(br, _startPosX + 80, _startPosY, 20, 30); - Brush brBrown = new SolidBrush(Color.FromArgb(200, 150, 40)); - g.FillRectangle(brBrown, _startPosX, _startPosY + 30, 100, 5); + Brush brBodyRandom = new SolidBrush(Color.FromArgb(0, 255, 128)); + g.FillRectangle(brBodyRandom, _startPosX, _startPosY + 30, 100, 5); Brush brBlack = new SolidBrush(Color.Black); g.FillEllipse(brBlack, _startPosX, _startPosY + 35, 20, 20); @@ -93,6 +100,13 @@ namespace DumpTruck g.DrawEllipse(pen, _startPosX, _startPosY + 35, 20, 20); g.DrawEllipse(pen, _startPosX + 22, _startPosY + 35, 20, 20); g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20); + + Brush brBody = new SolidBrush(Color.FromArgb(255, 0, 0)); + g.FillRectangle(brBody, _startPosX + 0, _startPosY, 70, 30); + Pen pen1 = new Pen(Color.Black); + g.DrawRectangle(pen1, _startPosX + 0, _startPosY, 70, 30); + + } } } \ No newline at end of file diff --git a/DumpTruck/DumpTruck/FormTruck.cs b/DumpTruck/DumpTruck/FormTruck.cs index f8724eb..a522920 100644 --- a/DumpTruck/DumpTruck/FormTruck.cs +++ b/DumpTruck/DumpTruck/FormTruck.cs @@ -15,8 +15,10 @@ namespace DumpTruck private DrawingTruck? _drawningTruck; + private void Draw() { + if (_drawningTruck == null) { return; @@ -37,14 +39,34 @@ namespace DumpTruck { Random random = new(); _drawningTruck = new DrawingTruck(); - _drawningTruck.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256))); - _drawningTruck.SetPosition(random.Next(1, 100), random.Next(1, 100)); + _drawningTruck.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256)), pictureBoxTruck.Width, pictureBoxTruck.Height); + _drawningTruck.SetPosition(random.Next(1, pictureBoxTruck.Width), random.Next(1, pictureBoxTruck.Height)); Draw(); } private void btnMove_Click(object sender, EventArgs e) { - + if (_drawningTruck == null) + { + return; + } + string name = ((Button)sender)?.Name ?? string.Empty; + switch (name) + { + case "btnUp": + _drawningTruck.MoveTransport(DirectionType.Up); + break; + case "btnDown": + _drawningTruck.MoveTransport(DirectionType.Down); + break; + case "btnLeft": + _drawningTruck.MoveTransport(DirectionType.Left); + break; + case "btnRight": + _drawningTruck.MoveTransport(DirectionType.Right); + break; + } + Draw(); } } } \ No newline at end of file -- 2.25.1 From e300a3d194759234b2120e634e2bfcb47011ce3d Mon Sep 17 00:00:00 2001 From: asoc1al Date: Sat, 7 Oct 2023 11:34:38 +0400 Subject: [PATCH 4/7] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D1=82=D0=B8=20=D0=B2?= =?UTF-8?q?=D1=81=D0=B5,=20=D1=84=D0=B8=D0=BA=D1=81=D0=B0=D0=BD=D1=83?= =?UTF-8?q?=D1=82=D1=8C=20=D1=81=D0=B2=D0=BE=D0=B9=D1=81=D1=82=D0=B2=D0=B0?= =?UTF-8?q?-=D0=BF=D1=80=D0=B8=D0=B7=D0=BD=D0=B0=D0=BA=D0=B8=20(bool=20?= =?UTF-8?q?=D0=B2=20=D1=81=D1=83=D1=89=D0=BD=D0=BE=D1=81=D1=82=D0=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DumpTruck/DumpTruck/DrawingTruck.cs | 39 +++++++++++++++++++---------- DumpTruck/DumpTruck/EntityTruck.cs | 4 ++- DumpTruck/DumpTruck/FormTruck.cs | 7 +++--- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/DumpTruck/DumpTruck/DrawingTruck.cs b/DumpTruck/DumpTruck/DrawingTruck.cs index 566a34e..ec65513 100644 --- a/DumpTruck/DumpTruck/DrawingTruck.cs +++ b/DumpTruck/DumpTruck/DrawingTruck.cs @@ -10,22 +10,34 @@ namespace DumpTruck internal class DrawingTruck { public EntityTruck? EntityTruck { get; private set; } - private float _startPosX; - private float _startPosY; - private int? _pictureWidth; - private int? _pictureHeight; - protected readonly int _truckWidth = 110; - protected readonly int _truckHeight = 60; - public bool Init(int speed, float weight, Color bodyColor, int width, int height) + private int _startPosX; + private int _startPosY; + private int _pictureWidth; + private int _pictureHeight; + protected readonly int _truckWidth = 100; + protected readonly int _truckHeight = 50; + public bool Init(int speed, float weight, Color bodyColor, Color additionalColor, int width, int height) { + if (width < _truckWidth || height < _truckHeight) + { + return false; + } _pictureWidth = width; _pictureHeight = height; EntityTruck = new EntityTruck(); - EntityTruck.Init(speed, weight, bodyColor); + EntityTruck.Init(speed, weight, bodyColor, additionalColor); return true; } public void SetPosition(int x, int y) { + if (x < 0 || x + _truckWidth > _pictureWidth) + { + x = _pictureWidth - _truckWidth; + } + if (y < 0 || y + _truckHeight > _pictureHeight) + { + y = _pictureHeight - _truckHeight; + } _startPosX = x; _startPosY = y; } @@ -69,9 +81,9 @@ namespace DumpTruck } - public void DrawTransport(Graphics g) + public void DrawTransport(Graphics g, Color bodyColor, Color additionalColor) { - if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue) + if (EntityTruck == null) { return; } @@ -80,7 +92,7 @@ namespace DumpTruck Brush br = new SolidBrush(EntityTruck?.BodyColor ?? Color.Black); g.FillRectangle(br, _startPosX + 80, _startPosY, 20, 30); - Brush brBodyRandom = new SolidBrush(Color.FromArgb(0, 255, 128)); + Brush brBodyRandom = new SolidBrush(bodyColor); g.FillRectangle(brBodyRandom, _startPosX, _startPosY + 30, 100, 5); Brush brBlack = new SolidBrush(Color.Black); @@ -101,8 +113,9 @@ namespace DumpTruck g.DrawEllipse(pen, _startPosX + 22, _startPosY + 35, 20, 20); g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20); - Brush brBody = new SolidBrush(Color.FromArgb(255, 0, 0)); - g.FillRectangle(brBody, _startPosX + 0, _startPosY, 70, 30); + //Brush brBody = new SolidBrush(EntityTruck?.AdditionalColor ?? Color.Red); + Brush brBodyAdditional = new SolidBrush(additionalColor); + g.FillRectangle(brBodyAdditional, _startPosX + 0, _startPosY, 70, 30); Pen pen1 = new Pen(Color.Black); g.DrawRectangle(pen1, _startPosX + 0, _startPosY, 70, 30); diff --git a/DumpTruck/DumpTruck/EntityTruck.cs b/DumpTruck/DumpTruck/EntityTruck.cs index f0a7cd2..793c885 100644 --- a/DumpTruck/DumpTruck/EntityTruck.cs +++ b/DumpTruck/DumpTruck/EntityTruck.cs @@ -14,14 +14,16 @@ namespace DumpTruck public float Weight { get; private set; } public Color BodyColor { get; private set; } + public Color AdditionalColor { get; private set; } public float Step => Speed * 100 / Weight; - public void Init(int speed, float weight, Color bodyColor) + public void Init(int speed, float weight, Color bodyColor, Color additionalColor) { Speed = speed; Weight = weight; BodyColor = bodyColor; + AdditionalColor = additionalColor; } } } \ No newline at end of file diff --git a/DumpTruck/DumpTruck/FormTruck.cs b/DumpTruck/DumpTruck/FormTruck.cs index a522920..92a926e 100644 --- a/DumpTruck/DumpTruck/FormTruck.cs +++ b/DumpTruck/DumpTruck/FormTruck.cs @@ -23,10 +23,11 @@ namespace DumpTruck { return; } + Random rnd = new Random(); Bitmap bmp = new(pictureBoxTruck.Width, pictureBoxTruck.Height); Graphics gr = Graphics.FromImage(bmp); - _drawningTruck.DrawTransport(gr); + _drawningTruck.DrawTransport(gr, Color.FromArgb(0,255,128),Color.FromArgb(255,0,0)); pictureBoxTruck.Image = bmp; } @@ -39,8 +40,8 @@ namespace DumpTruck { Random random = new(); _drawningTruck = new DrawingTruck(); - _drawningTruck.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256)), pictureBoxTruck.Width, pictureBoxTruck.Height); - _drawningTruck.SetPosition(random.Next(1, pictureBoxTruck.Width), random.Next(1, pictureBoxTruck.Height)); + _drawningTruck.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256)), Color.FromArgb(random.Next(0,256)), pictureBoxTruck.Width, pictureBoxTruck.Height); + _drawningTruck.SetPosition(random.Next(1, 100), random.Next(1, 100)); Draw(); } -- 2.25.1 From 35d382d5867259128b8a1d7f7f30adf3e5f5f1a1 Mon Sep 17 00:00:00 2001 From: asoc1al Date: Sat, 7 Oct 2023 11:40:56 +0400 Subject: [PATCH 5/7] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=D0=B8=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DumpTruck/DumpTruck/DrawingTruck.cs | 5 +++-- DumpTruck/DumpTruck/EntityTruck.cs | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/DumpTruck/DumpTruck/DrawingTruck.cs b/DumpTruck/DumpTruck/DrawingTruck.cs index ec65513..b369c3a 100644 --- a/DumpTruck/DumpTruck/DrawingTruck.cs +++ b/DumpTruck/DumpTruck/DrawingTruck.cs @@ -16,7 +16,7 @@ namespace DumpTruck private int _pictureHeight; protected readonly int _truckWidth = 100; protected readonly int _truckHeight = 50; - public bool Init(int speed, float weight, Color bodyColor, Color additionalColor, int width, int height) + public bool Init(int speed, float weight, Color bodyColor, Color additionalColor, int width, int height, bool threeWheels, bool dump) { if (width < _truckWidth || height < _truckHeight) { @@ -25,7 +25,7 @@ namespace DumpTruck _pictureWidth = width; _pictureHeight = height; EntityTruck = new EntityTruck(); - EntityTruck.Init(speed, weight, bodyColor, additionalColor); + EntityTruck.Init(speed, weight, bodyColor, additionalColor, threeWheels, dump); return true; } public void SetPosition(int x, int y) @@ -113,6 +113,7 @@ namespace DumpTruck g.DrawEllipse(pen, _startPosX + 22, _startPosY + 35, 20, 20); g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20); + //Brush brBody = new SolidBrush(EntityTruck?.AdditionalColor ?? Color.Red); Brush brBodyAdditional = new SolidBrush(additionalColor); g.FillRectangle(brBodyAdditional, _startPosX + 0, _startPosY, 70, 30); diff --git a/DumpTruck/DumpTruck/EntityTruck.cs b/DumpTruck/DumpTruck/EntityTruck.cs index 793c885..8f9e4dc 100644 --- a/DumpTruck/DumpTruck/EntityTruck.cs +++ b/DumpTruck/DumpTruck/EntityTruck.cs @@ -16,14 +16,20 @@ namespace DumpTruck public Color BodyColor { get; private set; } public Color AdditionalColor { get; private set; } + public bool ThreeWheels { get; private set; } + + public bool Dump { get; private set; } + public float Step => Speed * 100 / Weight; - public void Init(int speed, float weight, Color bodyColor, Color additionalColor) + public void Init(int speed, float weight, Color bodyColor, Color additionalColor, bool threeWheels, bool dump) { Speed = speed; Weight = weight; BodyColor = bodyColor; AdditionalColor = additionalColor; + ThreeWheels = threeWheels; + Dump = dump; } } } \ No newline at end of file -- 2.25.1 From 992a9c227116f8d786efd575a9acefd4cf581d58 Mon Sep 17 00:00:00 2001 From: asoc1al Date: Sat, 7 Oct 2023 11:55:42 +0400 Subject: [PATCH 6/7] =?UTF-8?q?=D0=A2=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20?= =?UTF-8?q?=D1=82=D0=BE=D1=87=D0=BD=D0=BE=20All=20Done?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DumpTruck/DumpTruck/DrawingTruck.cs | 26 +++++++++++++++++--------- DumpTruck/DumpTruck/FormTruck.cs | 4 ++-- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/DumpTruck/DumpTruck/DrawingTruck.cs b/DumpTruck/DumpTruck/DrawingTruck.cs index b369c3a..8a05ede 100644 --- a/DumpTruck/DumpTruck/DrawingTruck.cs +++ b/DumpTruck/DumpTruck/DrawingTruck.cs @@ -81,7 +81,7 @@ namespace DumpTruck } - public void DrawTransport(Graphics g, Color bodyColor, Color additionalColor) + public void DrawTransport(Graphics g, Color bodyColor, Color additionalColor, bool threeWheels, bool Dump) { if (EntityTruck == null) { @@ -96,13 +96,16 @@ namespace DumpTruck g.FillRectangle(brBodyRandom, _startPosX, _startPosY + 30, 100, 5); Brush brBlack = new SolidBrush(Color.Black); + g.FillEllipse(brBlack, _startPosX, _startPosY + 35, 20, 20); - g.FillEllipse(brBlack, _startPosX + 22, _startPosY + 35, 20, 20); + if (threeWheels) + g.FillEllipse(brBlack, _startPosX + 22, _startPosY + 35, 20, 20); g.FillEllipse(brBlack, _startPosX + 80, _startPosY + 35, 20, 20); Brush brWhite = new SolidBrush(Color.White); g.FillEllipse(brWhite, _startPosX + 5, _startPosY + 40, 10, 10); - g.FillEllipse(brWhite, _startPosX + 27, _startPosY + 40, 10, 10); + if (threeWheels) + g.FillEllipse(brWhite, _startPosX + 27, _startPosY + 40, 10, 10); g.FillEllipse(brWhite, _startPosX + 85, _startPosY + 40, 10, 10); Pen pen = new Pen(Color.Black); @@ -110,15 +113,20 @@ namespace DumpTruck g.DrawRectangle(pen, _startPosX + 80, _startPosY, 20, 30); g.DrawRectangle(pen, _startPosX, _startPosY + 30, 100, 5); g.DrawEllipse(pen, _startPosX, _startPosY + 35, 20, 20); - g.DrawEllipse(pen, _startPosX + 22, _startPosY + 35, 20, 20); + if (threeWheels) + g.DrawEllipse(pen, _startPosX + 22, _startPosY + 35, 20, 20); g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20); - + //Brush brBody = new SolidBrush(EntityTruck?.AdditionalColor ?? Color.Red); - Brush brBodyAdditional = new SolidBrush(additionalColor); - g.FillRectangle(brBodyAdditional, _startPosX + 0, _startPosY, 70, 30); - Pen pen1 = new Pen(Color.Black); - g.DrawRectangle(pen1, _startPosX + 0, _startPosY, 70, 30); + if (Dump) + { + Brush brBodyAdditional = new SolidBrush(additionalColor); + g.FillRectangle(brBodyAdditional, _startPosX + 0, _startPosY, 70, 30); + Pen pen1 = new Pen(Color.Black); + g.DrawRectangle(pen1, _startPosX + 0, _startPosY, 70, 30); + } + } diff --git a/DumpTruck/DumpTruck/FormTruck.cs b/DumpTruck/DumpTruck/FormTruck.cs index 92a926e..584da64 100644 --- a/DumpTruck/DumpTruck/FormTruck.cs +++ b/DumpTruck/DumpTruck/FormTruck.cs @@ -27,7 +27,7 @@ namespace DumpTruck Bitmap bmp = new(pictureBoxTruck.Width, pictureBoxTruck.Height); Graphics gr = Graphics.FromImage(bmp); - _drawningTruck.DrawTransport(gr, Color.FromArgb(0,255,128),Color.FromArgb(255,0,0)); + _drawningTruck.DrawTransport(gr, Color.FromArgb(0,255,128),Color.FromArgb(255,0,0), false, true); pictureBoxTruck.Image = bmp; } @@ -40,7 +40,7 @@ namespace DumpTruck { Random random = new(); _drawningTruck = new DrawingTruck(); - _drawningTruck.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256)), Color.FromArgb(random.Next(0,256)), pictureBoxTruck.Width, pictureBoxTruck.Height); + _drawningTruck.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256)), Color.FromArgb(random.Next(0,256)), pictureBoxTruck.Width, pictureBoxTruck.Height, Convert.ToBoolean(random.Next(2)), Convert.ToBoolean(random.Next(2))); _drawningTruck.SetPosition(random.Next(1, 100), random.Next(1, 100)); Draw(); } -- 2.25.1 From 85a5630fa71c6ea0f267f53443c72bc87b1f84d5 Mon Sep 17 00:00:00 2001 From: asoc1al Date: Sat, 30 Dec 2023 12:09:54 +0400 Subject: [PATCH 7/7] lab2 --- DumpTruck/DumpTruck/AbstractStrategy.cs | 131 ++++++++++ .../{Direction.cs => DirectionType.cs} | 4 +- DumpTruck/DumpTruck/DrawingTruck.cs | 134 ----------- DumpTruck/DumpTruck/DrawningDumpTruck.cs | 65 +++++ DumpTruck/DumpTruck/DrawningObjectTruck.cs | 33 +++ DumpTruck/DumpTruck/DrawningTruck.cs | 223 ++++++++++++++++++ DumpTruck/DumpTruck/EntityDumpTruck.cs | 43 ++++ DumpTruck/DumpTruck/EntityTruck.cs | 39 +-- DumpTruck/DumpTruck/FormDumpTruck.Designer.cs | 179 ++++++++++++++ DumpTruck/DumpTruck/FormDumpTruck.cs | 131 ++++++++++ DumpTruck/DumpTruck/FormDumpTruck.resx | 120 ++++++++++ DumpTruck/DumpTruck/FormTruck.Designer.cs | 142 ----------- DumpTruck/DumpTruck/FormTruck.cs | 73 ------ DumpTruck/DumpTruck/FormTruck.resx | 60 ----- DumpTruck/DumpTruck/IMoveableObject.cs | 31 +++ DumpTruck/DumpTruck/MoveToBorder.cs | 59 +++++ DumpTruck/DumpTruck/MoveToCenter.cs | 54 +++++ DumpTruck/DumpTruck/ObjectParameters.cs | 55 +++++ DumpTruck/DumpTruck/Program.cs | 2 +- .../Properties/Resources.Designer.cs | 16 +- DumpTruck/DumpTruck/Properties/Resources.resx | 16 +- DumpTruck/DumpTruck/Resources/arrowDown.png | Bin 0 -> 418 bytes DumpTruck/DumpTruck/Resources/arrowLeft.png | Bin 0 -> 362 bytes DumpTruck/DumpTruck/Resources/arrowRight.png | Bin 0 -> 428 bytes DumpTruck/DumpTruck/Resources/arrowUp.png | Bin 0 -> 412 bytes DumpTruck/DumpTruck/Resources/down.jpg | Bin 3703 -> 0 bytes DumpTruck/DumpTruck/Resources/left.jpg | Bin 3146 -> 0 bytes DumpTruck/DumpTruck/Resources/right.jpg | Bin 3706 -> 0 bytes DumpTruck/DumpTruck/Resources/up.jpg | Bin 3188 -> 0 bytes DumpTruck/DumpTruck/Status.cs | 17 ++ 30 files changed, 1184 insertions(+), 443 deletions(-) create mode 100644 DumpTruck/DumpTruck/AbstractStrategy.cs rename DumpTruck/DumpTruck/{Direction.cs => DirectionType.cs} (87%) delete mode 100644 DumpTruck/DumpTruck/DrawingTruck.cs create mode 100644 DumpTruck/DumpTruck/DrawningDumpTruck.cs create mode 100644 DumpTruck/DumpTruck/DrawningObjectTruck.cs create mode 100644 DumpTruck/DumpTruck/DrawningTruck.cs create mode 100644 DumpTruck/DumpTruck/EntityDumpTruck.cs create mode 100644 DumpTruck/DumpTruck/FormDumpTruck.Designer.cs create mode 100644 DumpTruck/DumpTruck/FormDumpTruck.cs create mode 100644 DumpTruck/DumpTruck/FormDumpTruck.resx delete mode 100644 DumpTruck/DumpTruck/FormTruck.Designer.cs delete mode 100644 DumpTruck/DumpTruck/FormTruck.cs delete mode 100644 DumpTruck/DumpTruck/FormTruck.resx create mode 100644 DumpTruck/DumpTruck/IMoveableObject.cs create mode 100644 DumpTruck/DumpTruck/MoveToBorder.cs create mode 100644 DumpTruck/DumpTruck/MoveToCenter.cs create mode 100644 DumpTruck/DumpTruck/ObjectParameters.cs create mode 100644 DumpTruck/DumpTruck/Resources/arrowDown.png create mode 100644 DumpTruck/DumpTruck/Resources/arrowLeft.png create mode 100644 DumpTruck/DumpTruck/Resources/arrowRight.png create mode 100644 DumpTruck/DumpTruck/Resources/arrowUp.png delete mode 100644 DumpTruck/DumpTruck/Resources/down.jpg delete mode 100644 DumpTruck/DumpTruck/Resources/left.jpg delete mode 100644 DumpTruck/DumpTruck/Resources/right.jpg delete mode 100644 DumpTruck/DumpTruck/Resources/up.jpg create mode 100644 DumpTruck/DumpTruck/Status.cs diff --git a/DumpTruck/DumpTruck/AbstractStrategy.cs b/DumpTruck/DumpTruck/AbstractStrategy.cs new file mode 100644 index 0000000..9d92804 --- /dev/null +++ b/DumpTruck/DumpTruck/AbstractStrategy.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DumpTruck.MovementStrategy +{ + public abstract class AbstractStrategy + { + /// + /// Перемещаемый объект + /// + private IMoveableObject? _moveableObject; + /// + /// Статус перемещения + /// + private Status _state = Status.NotInit; + /// + /// Ширина поля + /// + protected int FieldWidth { get; private set; } + /// + /// Высота поля + /// + protected int FieldHeight { get; private set; } + /// + /// Статус перемещения + /// + public Status GetStatus() { return _state; } + /// + /// Установка данных + /// + /// Перемещаемый объект + /// Ширина поля + /// Высота поля + public void SetData(IMoveableObject moveableObject, int width, int height) + { + if (moveableObject == null) + { + _state = Status.NotInit; + return; + } + _state = Status.InProgress; + _moveableObject = moveableObject; + FieldWidth = width; + FieldHeight = height; + } + + /// + /// Шаг перемещения + /// + public void MakeStep() + { + if (_state != Status.InProgress) + { + return; + } + if (IsTargetDestinaion()) + { + _state = Status.Finish; + return; + } + MoveToTarget(); + } + /// + /// Перемещение влево + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveLeft() => MoveTo(DirectionType.Left); + /// + /// Перемещение вправо + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveRight() => MoveTo(DirectionType.Right); + /// + /// Перемещение вверх + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveUp() => MoveTo(DirectionType.Up); + /// + /// Перемещение вниз + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveDown() => MoveTo(DirectionType.Down); + /// + /// Параметры объекта + /// + protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition; + /// + /// Шаг объекта + /// + /// + protected int? GetStep() + { + if (_state != Status.InProgress) + { + return null; + } + return _moveableObject?.GetStep; + } + + /// + /// Перемещение к цели + /// + protected abstract void MoveToTarget(); + /// + /// Достигнута ли цель + /// + /// + protected abstract bool IsTargetDestinaion(); + /// + /// Попытка перемещения в требуемом направлении + /// + /// Направление + /// Результат попытки (true - удалось переместиться, false - неудача) + private bool MoveTo(DirectionType directionType) + { + if (_state != Status.InProgress) + { + return false; + } + if (_moveableObject?.CheckCanMove(directionType) ?? false) + { + _moveableObject.MoveObject(directionType); + return true; + } + return false; + } + } +} diff --git a/DumpTruck/DumpTruck/Direction.cs b/DumpTruck/DumpTruck/DirectionType.cs similarity index 87% rename from DumpTruck/DumpTruck/Direction.cs rename to DumpTruck/DumpTruck/DirectionType.cs index 8cd74cb..2ae426b 100644 --- a/DumpTruck/DumpTruck/Direction.cs +++ b/DumpTruck/DumpTruck/DirectionType.cs @@ -6,11 +6,11 @@ using System.Threading.Tasks; namespace DumpTruck { - internal enum DirectionType + public enum DirectionType { Up = 1, Down = 2, Left = 3, Right = 4 } -} \ No newline at end of file +} diff --git a/DumpTruck/DumpTruck/DrawingTruck.cs b/DumpTruck/DumpTruck/DrawingTruck.cs deleted file mode 100644 index 8a05ede..0000000 --- a/DumpTruck/DumpTruck/DrawingTruck.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DumpTruck -{ - internal class DrawingTruck - { - public EntityTruck? EntityTruck { get; private set; } - private int _startPosX; - private int _startPosY; - private int _pictureWidth; - private int _pictureHeight; - protected readonly int _truckWidth = 100; - protected readonly int _truckHeight = 50; - public bool Init(int speed, float weight, Color bodyColor, Color additionalColor, int width, int height, bool threeWheels, bool dump) - { - if (width < _truckWidth || height < _truckHeight) - { - return false; - } - _pictureWidth = width; - _pictureHeight = height; - EntityTruck = new EntityTruck(); - EntityTruck.Init(speed, weight, bodyColor, additionalColor, threeWheels, dump); - return true; - } - public void SetPosition(int x, int y) - { - if (x < 0 || x + _truckWidth > _pictureWidth) - { - x = _pictureWidth - _truckWidth; - } - if (y < 0 || y + _truckHeight > _pictureHeight) - { - y = _pictureHeight - _truckHeight; - } - _startPosX = x; - _startPosY = y; - } - public void MoveTransport(DirectionType direction) - { - if (EntityTruck == null) - - { - return; - } - - switch (direction) - { - case DirectionType.Left: - if (_startPosX - EntityTruck.Step > 0) - { - _startPosX -= (int)EntityTruck.Step; - } - break; - //вверх - case DirectionType.Up: - if (_startPosY - EntityTruck.Step > 0) - { - _startPosY -= (int)EntityTruck.Step; - } - break; - //вправо - case DirectionType.Right: - if (_startPosX + EntityTruck.Step + _truckWidth < _pictureWidth) - { - _startPosX += (int)EntityTruck.Step; - } - break; - case DirectionType.Down: - if (_startPosY + EntityTruck.Step + _truckHeight < _pictureHeight) - { - _startPosY += (int)EntityTruck.Step; - } - break; - } - - - } - public void DrawTransport(Graphics g, Color bodyColor, Color additionalColor, bool threeWheels, bool Dump) - { - if (EntityTruck == null) - { - return; - } - - - Brush br = new SolidBrush(EntityTruck?.BodyColor ?? Color.Black); - g.FillRectangle(br, _startPosX + 80, _startPosY, 20, 30); - - Brush brBodyRandom = new SolidBrush(bodyColor); - g.FillRectangle(brBodyRandom, _startPosX, _startPosY + 30, 100, 5); - - Brush brBlack = new SolidBrush(Color.Black); - - g.FillEllipse(brBlack, _startPosX, _startPosY + 35, 20, 20); - if (threeWheels) - g.FillEllipse(brBlack, _startPosX + 22, _startPosY + 35, 20, 20); - g.FillEllipse(brBlack, _startPosX + 80, _startPosY + 35, 20, 20); - - Brush brWhite = new SolidBrush(Color.White); - g.FillEllipse(brWhite, _startPosX + 5, _startPosY + 40, 10, 10); - if (threeWheels) - g.FillEllipse(brWhite, _startPosX + 27, _startPosY + 40, 10, 10); - g.FillEllipse(brWhite, _startPosX + 85, _startPosY + 40, 10, 10); - - Pen pen = new Pen(Color.Black); - - g.DrawRectangle(pen, _startPosX + 80, _startPosY, 20, 30); - g.DrawRectangle(pen, _startPosX, _startPosY + 30, 100, 5); - g.DrawEllipse(pen, _startPosX, _startPosY + 35, 20, 20); - if (threeWheels) - g.DrawEllipse(pen, _startPosX + 22, _startPosY + 35, 20, 20); - g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20); - - - //Brush brBody = new SolidBrush(EntityTruck?.AdditionalColor ?? Color.Red); - if (Dump) - { - Brush brBodyAdditional = new SolidBrush(additionalColor); - g.FillRectangle(brBodyAdditional, _startPosX + 0, _startPosY, 70, 30); - Pen pen1 = new Pen(Color.Black); - g.DrawRectangle(pen1, _startPosX + 0, _startPosY, 70, 30); - } - - - - } - } -} \ No newline at end of file diff --git a/DumpTruck/DumpTruck/DrawningDumpTruck.cs b/DumpTruck/DumpTruck/DrawningDumpTruck.cs new file mode 100644 index 0000000..13e6de5 --- /dev/null +++ b/DumpTruck/DumpTruck/DrawningDumpTruck.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DumpTruck.DrawningObjects; +using DumpTruck.Entities; + +namespace DumpTruck.DrawningObjects +{ + public class DrawningDumpTruck : DrawningTruck + { + /// + /// Конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + /// Дополнительный цвет + /// Ширина картинки + /// Высота картинки + /// Признак наличия груза + /// Признак наличия тента + public DrawningDumpTruck(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool tent, int width, int height) : + base(speed, weight, bodyColor, width, height, 110, 60) + { + if (EntityTruck != null) + { + EntityTruck = new EntityDumpTruck(speed, weight, bodyColor, additionalColor, bodyKit, tent); + } + } + + /// + /// Отрисовка автомобиля + /// + /// + public override void DrawTransport(Graphics g) + { + if (EntityTruck is not EntityDumpTruck dumpTruck) + { + return; + } + + Brush brushAdditionalColor = new SolidBrush(dumpTruck.AdditionalColor); + Brush brushWhite = new SolidBrush(Color.White); + Pen penBlack = new Pen(Color.Black); + + base.DrawTransport(g); + + if (dumpTruck.BodyKit) + { + g.FillRectangle(brushAdditionalColor, _startPosX, _startPosY + 30, 100, 5); + g.FillRectangle(brushAdditionalColor, _startPosX, _startPosY + 10, 70, 20); + g.DrawRectangle(penBlack, _startPosX, _startPosY + 30, 100, 5); + g.DrawRectangle(penBlack, _startPosX, _startPosY + 10, 70, 20); + + if (dumpTruck.Tent) + { + g.FillRectangle(brushWhite, _startPosX, _startPosY + 10, 70, 5); + g.DrawRectangle(penBlack, _startPosX, _startPosY + 10, 70, 5); + } + } + } + } +} diff --git a/DumpTruck/DumpTruck/DrawningObjectTruck.cs b/DumpTruck/DumpTruck/DrawningObjectTruck.cs new file mode 100644 index 0000000..70d7303 --- /dev/null +++ b/DumpTruck/DumpTruck/DrawningObjectTruck.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DumpTruck.DrawningObjects; + +namespace DumpTruck.MovementStrategy +{ + public class DrawningObjectTruck : IMoveableObject + { + private readonly DrawningTruck? _drawningTruck = null; + public DrawningObjectTruck(DrawningTruck drawningTruck) + { + _drawningTruck = drawningTruck; + } + public ObjectParameters? GetObjectPosition + { + get + { + if (_drawningTruck == null || _drawningTruck.EntityTruck == null) + { + return null; + } + return new ObjectParameters(_drawningTruck.GetPosX, _drawningTruck.GetPosY, _drawningTruck.GetWidth, _drawningTruck.GetHeight); + } + } + public int GetStep => (int)(_drawningTruck?.EntityTruck?.Step ?? 0); + + public bool CheckCanMove(DirectionType direction) => _drawningTruck?.CanMove(direction) ?? false; + public void MoveObject(DirectionType direction) => _drawningTruck?.MoveTransport(direction); + } +} diff --git a/DumpTruck/DumpTruck/DrawningTruck.cs b/DumpTruck/DumpTruck/DrawningTruck.cs new file mode 100644 index 0000000..46b29e2 --- /dev/null +++ b/DumpTruck/DumpTruck/DrawningTruck.cs @@ -0,0 +1,223 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DumpTruck.Entities; + +namespace DumpTruck.DrawningObjects +{ + public class DrawningTruck + { + /// + /// Класс-сущность + /// + public EntityTruck? EntityTruck { get; protected set; } + /// + /// Ширина окна + /// + private int _pictureWidth; + /// + /// Высота окна + /// + private int _pictureHeight; + /// + /// Левая координата прорисовки автомобиля + /// + protected int _startPosX; + /// + /// Верхняя кооридната прорисовки автомобиля + /// + protected int _startPosY; + /// + /// Ширина прорисовки автомобиля + /// + protected readonly int _truckWidth = 110; + /// + /// Высота прорисовки автомобиля + /// + protected readonly int _truckHeight = 60; + /// + /// + /// Координата X объекта + /// + public int GetPosX => _startPosX; + /// + /// Координата Y объекта + /// + public int GetPosY => _startPosY; + /// + /// Ширина объекта + /// + public int GetWidth => _truckWidth; + /// + /// Высота объекта + /// + public int GetHeight => _truckHeight; + + /// Конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + /// Ширина картинки + /// Высота картинки + public DrawningTruck(int speed, double weight, Color bodyColor, int width, int height) + { + if (width < _truckWidth || height < _truckHeight) + { + return; + } + _pictureWidth = width; + _pictureHeight = height; + EntityTruck = new EntityTruck(speed, weight, bodyColor); + } + + /// + /// Конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + /// Ширина картинки + /// Высота картинки + /// Ширина прорисовки автомобиля + /// Высота прорисовки автомобиля + protected DrawningTruck(int speed, double weight, Color bodyColor, int width, int height, int truckWidth, int truckHeight) + { + if (width <= _truckWidth || height <= _truckHeight) + { + return; + } + _pictureWidth = width; + _pictureHeight = height; + _truckWidth = truckWidth; + _truckHeight = truckHeight; + EntityTruck = new EntityTruck(speed, weight, bodyColor); + } + + /// + /// Проверка, что объект может переместится по указанному направлению + /// + /// Направление + /// true - можно переместится по указанному направлению + public bool CanMove(DirectionType direction) + { + if (EntityTruck == null) + { + return false; + } + return direction switch + { + //влево + DirectionType.Left => _startPosX - EntityTruck.Step > 0, + //вверх + DirectionType.Up => _startPosY - EntityTruck.Step > 0, + // вправо + DirectionType.Right => _startPosX + _truckWidth + EntityTruck.Step < _pictureWidth, + //вниз + DirectionType.Down => _startPosY + _truckHeight + EntityTruck.Step < _pictureHeight, + _ => false, + }; + } + + /// + /// Установка позиции + /// + /// Координата X + /// Координата Y + public void SetPosition(int x, int y) + { + if (x < 0 || x + _truckWidth > _pictureWidth) + { + x = Math.Max(0, _pictureWidth - _truckWidth); + } + if (y < 0 || y + _truckHeight > _pictureHeight) + { + y = Math.Max(0, _pictureHeight - _truckHeight); + } + _startPosX = x; + _startPosY = y; + } + + /// + /// Изменение направления перемещения + /// + /// Направление + public void MoveTransport(DirectionType direction) + { + if (!CanMove(direction) || EntityTruck == null) + { + return; + } + switch (direction) + { + //влево + case DirectionType.Left: + if (_startPosX - EntityTruck.Step > 0) + { + _startPosX -= (int)EntityTruck.Step; + } + break; + //вверх + case DirectionType.Up: + if (_startPosY - EntityTruck.Step > 0) + { + _startPosY -= (int)EntityTruck.Step; + } + break; + // вправо + case DirectionType.Right: + if (_startPosX + _truckWidth + EntityTruck.Step < _pictureWidth) + { + _startPosX += (int)EntityTruck.Step; + } + break; + //вниз + case DirectionType.Down: + if (_startPosY + _truckHeight + EntityTruck.Step < _pictureHeight) + { + _startPosY += (int)EntityTruck.Step; + } + break; + } + } + + /// + /// Прорисовка объекта + /// + /// + public virtual void DrawTransport(Graphics g) + { + if (EntityTruck == null) + { + return; + } + Pen penBlack = new Pen(Color.Black); + Brush brushBodyColor = new SolidBrush(EntityTruck.BodyColor); + Brush brushBlack = new SolidBrush(Color.Black); + Brush brushWhite = new SolidBrush(Color.White); + + //Кабина + g.FillRectangle(brushBodyColor, _startPosX + 80, _startPosY, 20, 30); + g.DrawRectangle(penBlack, _startPosX + 80, _startPosY, 20, 30); + + //Рама + g.FillRectangle(brushBodyColor, _startPosX, _startPosY + 30, 100, 5); + g.DrawRectangle(penBlack, _startPosX, _startPosY + 30, 100, 5); + + //Колёса + g.FillEllipse(brushBlack, _startPosX, _startPosY + 35, 20, 20); + g.FillEllipse(brushBlack, _startPosX + 22, _startPosY + 35, 20, 20); + g.FillEllipse(brushBlack, _startPosX + 80, _startPosY + 35, 20, 20); + + g.FillEllipse(brushWhite, _startPosX + 5, _startPosY + 40, 10, 10); + g.FillEllipse(brushWhite, _startPosX + 27, _startPosY + 40, 10, 10); + g.FillEllipse(brushWhite, _startPosX + 85, _startPosY + 40, 10, 10); + + g.DrawEllipse(penBlack, _startPosX, _startPosY + 35, 20, 20); + g.DrawEllipse(penBlack, _startPosX + 22, _startPosY + 35, 20, 20); + g.DrawEllipse(penBlack, _startPosX + 80, _startPosY + 35, 20, 20); + } + } +} diff --git a/DumpTruck/DumpTruck/EntityDumpTruck.cs b/DumpTruck/DumpTruck/EntityDumpTruck.cs new file mode 100644 index 0000000..b326478 --- /dev/null +++ b/DumpTruck/DumpTruck/EntityDumpTruck.cs @@ -0,0 +1,43 @@ +using DumpTruck.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DumpTruck.Entities +{ + internal class EntityDumpTruck: EntityTruck + { + /// + /// Дополнительный цвет (для опциональных элементов) + /// + public Color AdditionalColor { get; private set; } + + /// + /// Признак (опция) наличия кузова + /// + public bool BodyKit { get; private set; } + + /// + /// Признак (опция) наличия тента + /// + public bool Tent { get; private set; } + + /// + /// Инициализация полей объекта-класса автомобиля + /// + /// + /// + /// + /// + /// + public EntityDumpTruck(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool tent) : + base(speed, weight, bodyColor) + { + AdditionalColor = additionalColor; + BodyKit = bodyKit; + Tent = tent; + } + } +} diff --git a/DumpTruck/DumpTruck/EntityTruck.cs b/DumpTruck/DumpTruck/EntityTruck.cs index 8f9e4dc..c2b757f 100644 --- a/DumpTruck/DumpTruck/EntityTruck.cs +++ b/DumpTruck/DumpTruck/EntityTruck.cs @@ -1,35 +1,44 @@ using System; using System.Collections.Generic; -using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace DumpTruck +namespace DumpTruck.Entities { - internal class EntityTruck + public class EntityTruck { + /// + /// Скорость + /// public int Speed { get; private set; } - public float Weight { get; private set; } + /// + /// Вес + /// + public double Weight { get; private set; } + /// + /// Основной цвет + /// public Color BodyColor { get; private set; } - public Color AdditionalColor { get; private set; } - public bool ThreeWheels { get; private set; } + /// + /// Шаг перемещения автомобиля + /// + public double Step => (double)Speed * 100 / Weight; - public bool Dump { get; private set; } - - public float Step => Speed * 100 / Weight; - - public void Init(int speed, float weight, Color bodyColor, Color additionalColor, bool threeWheels, bool dump) + /// + /// Конструктор с параметрами + /// + /// Скорость + /// Вес автомобиля + /// Основной цвет + public EntityTruck(int speed, double weight, Color bodyColor) { Speed = speed; Weight = weight; BodyColor = bodyColor; - AdditionalColor = additionalColor; - ThreeWheels = threeWheels; - Dump = dump; } } -} \ No newline at end of file +} diff --git a/DumpTruck/DumpTruck/FormDumpTruck.Designer.cs b/DumpTruck/DumpTruck/FormDumpTruck.Designer.cs new file mode 100644 index 0000000..5090c0d --- /dev/null +++ b/DumpTruck/DumpTruck/FormDumpTruck.Designer.cs @@ -0,0 +1,179 @@ +namespace DumpTruck +{ + partial class FormDumpTruck + { + /// + /// 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() + { + pictureBoxDumpTruck = new PictureBox(); + buttonCreateTruck = new Button(); + buttonLeft = new Button(); + buttonUp = new Button(); + buttonDown = new Button(); + buttonRight = new Button(); + buttonCreateDumpTruck = new Button(); + comboBoxStrategy = new ComboBox(); + buttonStep = new Button(); + ((System.ComponentModel.ISupportInitialize)pictureBoxDumpTruck).BeginInit(); + SuspendLayout(); + // + // pictureBoxDumpTruck + // + pictureBoxDumpTruck.Dock = DockStyle.Fill; + pictureBoxDumpTruck.Location = new Point(0, 0); + pictureBoxDumpTruck.Name = "pictureBoxDumpTruck"; + pictureBoxDumpTruck.Size = new Size(884, 461); + pictureBoxDumpTruck.SizeMode = PictureBoxSizeMode.AutoSize; + pictureBoxDumpTruck.TabIndex = 0; + pictureBoxDumpTruck.TabStop = false; + // + // buttonCreateTruck + // + buttonCreateTruck.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreateTruck.Location = new Point(12, 406); + buttonCreateTruck.Name = "buttonCreateTruck"; + buttonCreateTruck.Size = new Size(107, 43); + buttonCreateTruck.TabIndex = 1; + buttonCreateTruck.Text = "Создать грузовик"; + buttonCreateTruck.UseVisualStyleBackColor = true; + buttonCreateTruck.Click += buttonCreateTruck_Click; + // + // buttonLeft + // + buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonLeft.BackgroundImage = Properties.Resources.arrowLeft; + buttonLeft.BackgroundImageLayout = ImageLayout.Zoom; + buttonLeft.Location = new Point(770, 426); + buttonLeft.Name = "buttonLeft"; + buttonLeft.Size = new Size(30, 30); + buttonLeft.TabIndex = 2; + buttonLeft.UseVisualStyleBackColor = true; + buttonLeft.Click += buttonMove_Click; + // + // buttonUp + // + buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonUp.BackgroundImage = Properties.Resources.arrowUp; + buttonUp.BackgroundImageLayout = ImageLayout.Zoom; + buttonUp.Location = new Point(806, 390); + buttonUp.Name = "buttonUp"; + buttonUp.Size = new Size(30, 30); + buttonUp.TabIndex = 3; + buttonUp.UseVisualStyleBackColor = true; + buttonUp.Click += buttonMove_Click; + // + // buttonDown + // + buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonDown.BackgroundImage = Properties.Resources.arrowDown; + buttonDown.BackgroundImageLayout = ImageLayout.Zoom; + buttonDown.Location = new Point(806, 426); + buttonDown.Name = "buttonDown"; + buttonDown.Size = new Size(30, 30); + buttonDown.TabIndex = 4; + buttonDown.UseVisualStyleBackColor = true; + buttonDown.Click += buttonMove_Click; + // + // buttonRight + // + buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonRight.BackgroundImage = Properties.Resources.arrowRight; + buttonRight.BackgroundImageLayout = ImageLayout.Zoom; + buttonRight.Location = new Point(842, 426); + buttonRight.Name = "buttonRight"; + buttonRight.Size = new Size(30, 30); + buttonRight.TabIndex = 5; + buttonRight.UseVisualStyleBackColor = true; + buttonRight.Click += buttonMove_Click; + // + // buttonCreateDumpTruck + // + buttonCreateDumpTruck.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreateDumpTruck.Location = new Point(125, 406); + buttonCreateDumpTruck.Name = "buttonCreateDumpTruck"; + buttonCreateDumpTruck.Size = new Size(118, 43); + buttonCreateDumpTruck.TabIndex = 6; + buttonCreateDumpTruck.Text = "Создать грузовик с кузовом"; + buttonCreateDumpTruck.UseVisualStyleBackColor = true; + buttonCreateDumpTruck.Click += buttonCreateDumpTruck_Click; + // + // comboBoxStrategy + // + comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right; + comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxStrategy.FormattingEnabled = true; + comboBoxStrategy.Items.AddRange(new object[] { "Путь к центру", "Путь к правому нижнему углу" }); + comboBoxStrategy.Location = new Point(751, 12); + comboBoxStrategy.Name = "comboBoxStrategy"; + comboBoxStrategy.Size = new Size(121, 23); + comboBoxStrategy.TabIndex = 7; + // + // buttonStep + // + buttonStep.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonStep.Location = new Point(797, 41); + buttonStep.Name = "buttonStep"; + buttonStep.Size = new Size(75, 23); + buttonStep.TabIndex = 8; + buttonStep.Text = "Шаг"; + buttonStep.UseVisualStyleBackColor = true; + buttonStep.Click += buttonStep_Click; + // + // FormDumpTruck + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(884, 461); + Controls.Add(buttonStep); + Controls.Add(comboBoxStrategy); + Controls.Add(buttonCreateDumpTruck); + Controls.Add(buttonRight); + Controls.Add(buttonDown); + Controls.Add(buttonUp); + Controls.Add(buttonLeft); + Controls.Add(buttonCreateTruck); + Controls.Add(pictureBoxDumpTruck); + Name = "FormDumpTruck"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Проект"; + ((System.ComponentModel.ISupportInitialize)pictureBoxDumpTruck).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private PictureBox pictureBoxDumpTruck; + private Button buttonCreateTruck; + private Button buttonLeft; + private Button buttonUp; + private Button buttonDown; + private Button buttonRight; + private Button buttonCreateDumpTruck; + private ComboBox comboBoxStrategy; + private Button buttonStep; + } +} \ No newline at end of file diff --git a/DumpTruck/DumpTruck/FormDumpTruck.cs b/DumpTruck/DumpTruck/FormDumpTruck.cs new file mode 100644 index 0000000..6daad08 --- /dev/null +++ b/DumpTruck/DumpTruck/FormDumpTruck.cs @@ -0,0 +1,131 @@ +using DumpTruck.DrawningObjects; +using DumpTruck.MovementStrategy; + +namespace DumpTruck +{ + public partial class FormDumpTruck : Form + { + /// + /// Поле-объект для прорисовки объекта + /// + private DrawningTruck? _drawningTruck; + + private AbstractStrategy? _abstractStrategy; + + /// + /// Инициализация формы + /// + public FormDumpTruck() + { + InitializeComponent(); + } + + /// + /// Метод прорисовки машины + /// + private void Draw() + { + if (_drawningTruck == null) + return; + Bitmap bmp = new(pictureBoxDumpTruck.Width, pictureBoxDumpTruck.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawningTruck.DrawTransport(gr); + pictureBoxDumpTruck.Image = bmp; + } + + /// + /// Обработка нажатия кнопки "Создать truck" + /// + /// + /// + private void buttonCreateTruck_Click(object sender, EventArgs e) + { + Random random = new(); + _drawningTruck = new DrawningTruck(random.Next(100, 300), random.Next(1000, 3000), + Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), + pictureBoxDumpTruck.Width, pictureBoxDumpTruck.Height); + _drawningTruck.SetPosition(random.Next(10, 100), random.Next(10, 100)); + + Draw(); + } + + /// + /// Изменение размеров формы + /// + /// + /// + private void buttonMove_Click(object sender, EventArgs e) + { + if (_drawningTruck == null) + { + return; + } + string name = ((Button)sender)?.Name ?? string.Empty; + switch (name) + { + case "buttonUp": + _drawningTruck.MoveTransport(DirectionType.Up); + break; + case "buttonDown": + _drawningTruck.MoveTransport(DirectionType.Down); + break; + case "buttonLeft": + _drawningTruck.MoveTransport(DirectionType.Left); + break; + case "buttonRight": + _drawningTruck.MoveTransport(DirectionType.Right); + break; + } + Draw(); + } + + private void buttonCreateDumpTruck_Click(object sender, EventArgs e) + { + Random random = new(); + _drawningTruck = new DrawningDumpTruck(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)), + pictureBoxDumpTruck.Width, pictureBoxDumpTruck.Height); + _drawningTruck.SetPosition(random.Next(10, 100), random.Next(10, 100)); + Draw(); + } + + private void buttonStep_Click(object sender, EventArgs e) + { + if (_drawningTruck == null) + { + return; + } + if (comboBoxStrategy.Enabled) + { + _abstractStrategy = comboBoxStrategy.SelectedIndex + switch + { + 0 => new MoveToCenter(), + 1 => new MoveToBorder(), + _ => null, + }; + if (_abstractStrategy == null) + { + return; + } + _abstractStrategy.SetData(new + DrawningObjectTruck(_drawningTruck), pictureBoxDumpTruck.Width, + pictureBoxDumpTruck.Height); + comboBoxStrategy.Enabled = false; + } + if (_abstractStrategy == null) + { + return; + } + _abstractStrategy.MakeStep(); + Draw(); + if (_abstractStrategy.GetStatus() == Status.Finish) + { + comboBoxStrategy.Enabled = true; + _abstractStrategy = null; + } + } + } +} \ No newline at end of file diff --git a/DumpTruck/DumpTruck/FormDumpTruck.resx b/DumpTruck/DumpTruck/FormDumpTruck.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/DumpTruck/DumpTruck/FormDumpTruck.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/DumpTruck/DumpTruck/FormTruck.Designer.cs b/DumpTruck/DumpTruck/FormTruck.Designer.cs deleted file mode 100644 index 47c7eda..0000000 --- a/DumpTruck/DumpTruck/FormTruck.Designer.cs +++ /dev/null @@ -1,142 +0,0 @@ -namespace DumpTruck -{ - partial class FormTruck - { - /// - /// 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.btnCreate = new System.Windows.Forms.Button(); - this.btnLeft = new System.Windows.Forms.Button(); - this.btnDown = new System.Windows.Forms.Button(); - this.btnRight = new System.Windows.Forms.Button(); - this.btnUp = new System.Windows.Forms.Button(); - this.pictureBoxTruck = new System.Windows.Forms.PictureBox(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTruck)).BeginInit(); - this.SuspendLayout(); - // - // btnCreate - // - this.btnCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnCreate.Location = new System.Drawing.Point(12, 426); - this.btnCreate.Name = "btnCreate"; - this.btnCreate.Size = new System.Drawing.Size(75, 23); - this.btnCreate.TabIndex = 0; - this.btnCreate.Text = "Создать"; - this.btnCreate.UseVisualStyleBackColor = true; - this.btnCreate.Click += new System.EventHandler(this.btnCreate_Click); - // - // btnLeft - // - this.btnLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnLeft.BackgroundImage = global::DumpTruck.Properties.Resources.left; - this.btnLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.btnLeft.Location = new System.Drawing.Point(766, 419); - this.btnLeft.Name = "btnLeft"; - this.btnLeft.Size = new System.Drawing.Size(30, 30); - this.btnLeft.TabIndex = 1; - this.btnLeft.Text = " "; - this.btnLeft.UseVisualStyleBackColor = true; - this.btnLeft.Click += new System.EventHandler(this.btnMove_Click); - // - // btnDown - // - this.btnDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnDown.BackgroundImage = global::DumpTruck.Properties.Resources.down; - this.btnDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.btnDown.Location = new System.Drawing.Point(802, 419); - this.btnDown.Name = "btnDown"; - this.btnDown.Size = new System.Drawing.Size(30, 30); - this.btnDown.TabIndex = 2; - this.btnDown.Text = " "; - this.btnDown.UseVisualStyleBackColor = true; - this.btnDown.Click += new System.EventHandler(this.btnMove_Click); - // - // btnRight - // - this.btnRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnRight.BackgroundImage = global::DumpTruck.Properties.Resources.right; - this.btnRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.btnRight.Location = new System.Drawing.Point(838, 419); - this.btnRight.Name = "btnRight"; - this.btnRight.Size = new System.Drawing.Size(30, 30); - this.btnRight.TabIndex = 3; - this.btnRight.Text = " "; - this.btnRight.UseVisualStyleBackColor = true; - this.btnRight.Click += new System.EventHandler(this.btnMove_Click); - // - // btnUp - // - this.btnUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnUp.BackgroundImage = global::DumpTruck.Properties.Resources.up; - this.btnUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.btnUp.Location = new System.Drawing.Point(802, 383); - this.btnUp.Name = "btnUp"; - this.btnUp.Size = new System.Drawing.Size(30, 30); - this.btnUp.TabIndex = 4; - this.btnUp.Text = " "; - this.btnUp.UseVisualStyleBackColor = true; - this.btnUp.Click += new System.EventHandler(this.btnMove_Click); - // - // pictureBoxTruck - // - this.pictureBoxTruck.Dock = System.Windows.Forms.DockStyle.Fill; - this.pictureBoxTruck.Location = new System.Drawing.Point(0, 0); - this.pictureBoxTruck.Name = "pictureBoxTruck"; - this.pictureBoxTruck.Size = new System.Drawing.Size(884, 461); - this.pictureBoxTruck.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.pictureBoxTruck.TabIndex = 5; - this.pictureBoxTruck.TabStop = false; - // - // FormTruck - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(884, 461); - this.Controls.Add(this.btnUp); - this.Controls.Add(this.btnRight); - this.Controls.Add(this.btnDown); - this.Controls.Add(this.btnLeft); - this.Controls.Add(this.btnCreate); - this.Controls.Add(this.pictureBoxTruck); - this.Name = "FormTruck"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "FormTruck"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTruck)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private Button btnCreate; - private Button btnLeft; - private Button btnDown; - private Button btnRight; - private Button btnUp; - private PictureBox pictureBoxTruck; - } -} \ No newline at end of file diff --git a/DumpTruck/DumpTruck/FormTruck.cs b/DumpTruck/DumpTruck/FormTruck.cs deleted file mode 100644 index 584da64..0000000 --- a/DumpTruck/DumpTruck/FormTruck.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace DumpTruck -{ - public partial class FormTruck : Form - { - - private DrawingTruck? _drawningTruck; - - - private void Draw() - { - - if (_drawningTruck == null) - { - return; - } - Random rnd = new Random(); - Bitmap bmp = new(pictureBoxTruck.Width, - pictureBoxTruck.Height); - Graphics gr = Graphics.FromImage(bmp); - _drawningTruck.DrawTransport(gr, Color.FromArgb(0,255,128),Color.FromArgb(255,0,0), false, true); - pictureBoxTruck.Image = bmp; - } - - public FormTruck() - { - InitializeComponent(); - } - - private void btnCreate_Click(object sender, EventArgs e) - { - Random random = new(); - _drawningTruck = new DrawingTruck(); - _drawningTruck.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256)), Color.FromArgb(random.Next(0,256)), pictureBoxTruck.Width, pictureBoxTruck.Height, Convert.ToBoolean(random.Next(2)), Convert.ToBoolean(random.Next(2))); - _drawningTruck.SetPosition(random.Next(1, 100), random.Next(1, 100)); - Draw(); - } - - private void btnMove_Click(object sender, EventArgs e) - { - if (_drawningTruck == null) - { - return; - } - string name = ((Button)sender)?.Name ?? string.Empty; - switch (name) - { - case "btnUp": - _drawningTruck.MoveTransport(DirectionType.Up); - break; - case "btnDown": - _drawningTruck.MoveTransport(DirectionType.Down); - break; - case "btnLeft": - _drawningTruck.MoveTransport(DirectionType.Left); - break; - case "btnRight": - _drawningTruck.MoveTransport(DirectionType.Right); - break; - } - Draw(); - } - } -} \ No newline at end of file diff --git a/DumpTruck/DumpTruck/FormTruck.resx b/DumpTruck/DumpTruck/FormTruck.resx deleted file mode 100644 index f298a7b..0000000 --- a/DumpTruck/DumpTruck/FormTruck.resx +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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/DumpTruck/DumpTruck/IMoveableObject.cs b/DumpTruck/DumpTruck/IMoveableObject.cs new file mode 100644 index 0000000..6792e74 --- /dev/null +++ b/DumpTruck/DumpTruck/IMoveableObject.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DumpTruck.MovementStrategy +{ + public interface IMoveableObject + { + /// + /// Получение координаты X объекта + /// + ObjectParameters? GetObjectPosition { get; } + /// + /// Шаг объекта + /// + int GetStep { get; } + /// + /// Проверка, можно ли переместиться по нужному направлению + /// + /// + /// + bool CheckCanMove(DirectionType direction); + /// + /// Изменение направления пермещения объекта + /// + /// Направление + void MoveObject(DirectionType direction); + } +} diff --git a/DumpTruck/DumpTruck/MoveToBorder.cs b/DumpTruck/DumpTruck/MoveToBorder.cs new file mode 100644 index 0000000..2a4a825 --- /dev/null +++ b/DumpTruck/DumpTruck/MoveToBorder.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DumpTruck.MovementStrategy; + +namespace DumpTruck +{ + internal class MoveToBorder : AbstractStrategy + { + protected override bool IsTargetDestinaion() + { + var objParams = GetObjectParameters; + if (objParams == null) + { + return false; + } + + return objParams.RightBorder <= FieldWidth && + objParams.RightBorder + GetStep() >= FieldWidth && + objParams.DownBorder <= FieldHeight && + objParams.DownBorder + GetStep() >= FieldHeight; + } + + protected override void MoveToTarget() + { + var objParams = GetObjectParameters; + if (objParams == null) + { + return; + } + var diffX = objParams.RightBorder - FieldWidth; + if (Math.Abs(diffX) > GetStep()) + { + if (diffX > 0) + { + MoveLeft(); + } + else + { + MoveRight(); + } + } + var diffY = objParams.DownBorder - FieldHeight; + if (Math.Abs(diffY) > GetStep()) + { + if (diffY > 0) + { + MoveUp(); + } + else + { + MoveDown(); + } + } + } + } +} diff --git a/DumpTruck/DumpTruck/MoveToCenter.cs b/DumpTruck/DumpTruck/MoveToCenter.cs new file mode 100644 index 0000000..fe0c9c4 --- /dev/null +++ b/DumpTruck/DumpTruck/MoveToCenter.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DumpTruck.MovementStrategy +{ + public class MoveToCenter : AbstractStrategy + { + protected override bool IsTargetDestinaion() + { + var objParams = GetObjectParameters; + if (objParams == null) + { + return false; + } + return objParams.ObjectMiddleHorizontal <= FieldWidth / 2 && objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 && + objParams.ObjectMiddleVertical <= FieldHeight / 2 && objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2; + } + protected override void MoveToTarget() + { + var objParams = GetObjectParameters; + if (objParams == null) + { + return; + } + var diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2; + if (Math.Abs(diffX) > GetStep()) + { + if (diffX > 0) + { + MoveLeft(); + } + else + { + MoveRight(); + } + } + var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2; + if (Math.Abs(diffY) > GetStep()) + { + if (diffY > 0) + { + MoveUp(); + } + else + { + MoveDown(); + } + } + } + } +} diff --git a/DumpTruck/DumpTruck/ObjectParameters.cs b/DumpTruck/DumpTruck/ObjectParameters.cs new file mode 100644 index 0000000..2af38ef --- /dev/null +++ b/DumpTruck/DumpTruck/ObjectParameters.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DumpTruck.MovementStrategy +{ + public class ObjectParameters + { + private readonly int _x; + private readonly int _y; + private readonly int _width; + private readonly int _height; + /// + /// Левая граница + /// + public int LeftBorder => _x; + /// + /// Верхняя граница + /// + public int TopBorder => _y; + /// + /// Правая граница + /// + public int RightBorder => _x + _width; + /// + /// Нижняя граница + /// + public int DownBorder => _y + _height; + + /// + /// Середина объекта + /// + public int ObjectMiddleHorizontal => _x + _width / 2; + /// + /// Середина объекта + /// + public int ObjectMiddleVertical => _y + _height / 2; + /// + /// Конструктор + /// + /// Координата X + /// Координата Y + /// Ширина + /// Высота + public ObjectParameters(int x, int y, int width, int height) + { + _x = x; + _y = y; + _width = width; + _height = height; + } + } +} diff --git a/DumpTruck/DumpTruck/Program.cs b/DumpTruck/DumpTruck/Program.cs index b5a689f..b619d5a 100644 --- a/DumpTruck/DumpTruck/Program.cs +++ b/DumpTruck/DumpTruck/Program.cs @@ -11,7 +11,7 @@ namespace DumpTruck // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormTruck()); + Application.Run(new FormDumpTruck()); } } } \ No newline at end of file diff --git a/DumpTruck/DumpTruck/Properties/Resources.Designer.cs b/DumpTruck/DumpTruck/Properties/Resources.Designer.cs index aac7e60..eb02a09 100644 --- a/DumpTruck/DumpTruck/Properties/Resources.Designer.cs +++ b/DumpTruck/DumpTruck/Properties/Resources.Designer.cs @@ -63,9 +63,9 @@ namespace DumpTruck.Properties { /// /// Поиск локализованного ресурса типа System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap down { + internal static System.Drawing.Bitmap arrowDown { get { - object obj = ResourceManager.GetObject("down", resourceCulture); + object obj = ResourceManager.GetObject("arrowDown", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -73,9 +73,9 @@ namespace DumpTruck.Properties { /// /// Поиск локализованного ресурса типа System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap left { + internal static System.Drawing.Bitmap arrowLeft { get { - object obj = ResourceManager.GetObject("left", resourceCulture); + object obj = ResourceManager.GetObject("arrowLeft", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -83,9 +83,9 @@ namespace DumpTruck.Properties { /// /// Поиск локализованного ресурса типа System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap right { + internal static System.Drawing.Bitmap arrowRight { get { - object obj = ResourceManager.GetObject("right", resourceCulture); + object obj = ResourceManager.GetObject("arrowRight", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -93,9 +93,9 @@ namespace DumpTruck.Properties { /// /// Поиск локализованного ресурса типа System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap up { + internal static System.Drawing.Bitmap arrowUp { get { - object obj = ResourceManager.GetObject("up", resourceCulture); + object obj = ResourceManager.GetObject("arrowUp", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } diff --git a/DumpTruck/DumpTruck/Properties/Resources.resx b/DumpTruck/DumpTruck/Properties/Resources.resx index 3d5a144..dc6b4c5 100644 --- a/DumpTruck/DumpTruck/Properties/Resources.resx +++ b/DumpTruck/DumpTruck/Properties/Resources.resx @@ -118,16 +118,16 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - ..\Resources\down.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\arrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\left.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\arrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\right.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\arrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\up.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\arrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/DumpTruck/DumpTruck/Resources/arrowDown.png b/DumpTruck/DumpTruck/Resources/arrowDown.png new file mode 100644 index 0000000000000000000000000000000000000000..c8222f89bae0602a328321b3e0e1649adb45dd04 GIT binary patch literal 418 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1quc4d$LMjv*f2$r2g|IF@=c1wFd-f1!^-#kWtI zC!ZNOX6|YZ?0(7Srn^j9V(W~&geytA8X*F1jJvFM@d_=P^!NY&|NcKdJZxqNkx*w? z`SbVp{Dut;9{bmA%VQ3a&{nt+#uQaEue0+c!>PXvN7x%I7|u91@H)IE0%b%j<;KI?w9=#cGuNI+qw?U^GdjN+YqY#2|u zGU~_ejrs8YzkE|)GvlO9!Y3Zs*Z+%YD4KYXHAsh*ank3Hy|=G3H;QPK9zMXHki^t^ zQI6sBR^|=TpXIJhW!$*%&=8|WD1#)#jv{Hf3DS31!c`@xf3A_ zAMNY@>|k^W7B+Cov`9!wnW?X+*7xQx|M@sO(Uwgs*&f)j9b4WsW5bV16K}@{3{#eA zG5nU0Xy>~mWc0exhf!euH3o^M9-rA}xmpXBFEu#uK^lbYbB$V-RI?x*5XEJb!M&gZuyOJ5Pt}dbbogIy^Ys&i}=mc|k?H=*;^6|9Bg? zF0(g0k`3|X;O_Y1-1>sMWb4X!-M*$k1FjV;5)up|7o+FLKl!Qw3Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0YOPbK~zXfV;BXa zfbM`9N>cci2N4uc=0}MK0 zM9_i6r~+V#K~zu-Xer}=c4p39eSLlK#6UG5CoK<7-UfOG|I5nC`hY^zPu{=`suAEH z@Ki=p_T&8d3zC3*c91yLGb}KJ#sYnExvZ?*1}a1wAR;6ZDJm?c0_Bc^Q7|X~0|Nlx WnO}aK49 literal 0 HcmV?d00001 diff --git a/DumpTruck/DumpTruck/Resources/arrowUp.png b/DumpTruck/DumpTruck/Resources/arrowUp.png new file mode 100644 index 0000000000000000000000000000000000000000..0c80a4f97ff38cc21261925a85af0da7210d2efe GIT binary patch literal 412 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1quc4ThdBjv*f2$qM3YA~r5cxV+4lH9)WS!2kdM zWtSXT`k(n@wScsik5EF>C70&%_xChCyicrYFJg7bnIJL6-z1^sk_+2tH8F5=cQc0cWjJg(%FZw6GeJPuzoE#G!QspawYabaKFvqVQ@Bd5bo3r5H8 ztyi`>YD!GYvS;|n#v#nwaKxcVVFAMxXM>UtY+KiD%R9Vz`T3uXn%^EgKR=(JgM*`i zm;Gtt1}2S)Z=W=8%;A@}M literal 0 HcmV?d00001 diff --git a/DumpTruck/DumpTruck/Resources/down.jpg b/DumpTruck/DumpTruck/Resources/down.jpg deleted file mode 100644 index aabdc4a1f9659ec8f5c3abc7680984a5b2a03056..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3703 zcmd^BX;>528a^R}C4eE6fZzhMR0JXqTR|@pm0jyYK_NiI2xYermr{Zk4Fy>Y77E3n z*cJf=6(Q`1Qo<5IK-*HJXe>)WT4j+0HH;*gxs$fHz1aS^xA$kiIo~|3m1#a%CB6lsJwRlMtwtLQ*+C$ z*4tg({GQ&vyZr;-4L=z9e)QoZfpBX2$;^*GJ$*JSUV8EJm1G%uy`tcS0oY$?{l@GK zUPP3a5^4iwRRu4MQWC0IqB3rit%}YrKh>~fZ<*MAtfsp=zqGDX-PGP+L<&DXgx523 z5Soh>)P836-w{juOU!;F_B$^D(8OX;<6((_0_3tXwgo^H`#KE)=_98A>&|EYgB*1WS6Jyz#F-Vq*#S>^w2(}aK^$s0=iO7A&M%gvW3{=O+b5p~)^jzM^G zcc01j`ubX&w{faRGy=LG^5PgP+ZcJMU5>tD!QPh%3rlR+7y-h0dXtlUeM=t#WX>mf z2r%684LnUX)ti&V!2` zPRdzaq3>kn!X0tB6Nme{I%NiUFGG&0 znP<7PUuc$WM~0XvI8MZgm_fF~@tQv`Tpk90q4XfOp0j_#}~1T1+Ni6l0H zOK>i28UgV79drZ~SYV|oWxO0pT1oTb!k}~y^TzaUC{dgw;fmpw*qG55&){`pYPKWo zTKve6VH8_E6eak{USev5-{-X`9~Ns;SOPg++Jk_!B4*&?RAtwleH0H!UM9d;dlU#p z`#56b15K?b&g6=TyE~8bm6W<|iP=}1;h?r);SOrYAx8T>`8p|;Z&(v`>(+(Fj||Dh^=BDebNqNf+dqrQY4`5sm$lV6PDX$&+V5D&Gsbq`5rRwP)T0hW>iui;yQ{en~MTVX(>aU#^ z@OoCKIV*Z?8)@PE%rFoBMmU z2kSs;?LGJKE%7{#jULlCK%~!ZB5Q;WJ8J3Eh7x9KA2>**NzJ!wZ=D_3t6AqvSf4#R zFwj9VPQ#Go66#ErY`r}KR9?i=MgEKUG1&o#8e934XVggBX`WqA3xSr#&G4L-tw;06 zO)P@82Bq!{iZZd)ZSF7{I8Q2_`bK@WT}d2xwe-mCsM4~zljI+o4Kqtv36jx3ed0Es zFwSPobpD3m;2@4mQ5xMWcJj!GtOSFfQWhC;UKkBu?F)eKt=-P4Z0i*1; zfW(Bl38+|nAax$YupHmR6j#x>1qslCG!)pxC+?U+Qg|;MRB*2y_ zR*l0i>3IV3WgUJnxjH48p@Z8?D{}T;B@Q$<}YUD+D(*m6eO z5g}KbN#P6VMUwlbwBZUgpk3~MA0)eL9+2fI0oC8xcyzgyuEy#_flp>_)ItyK zs}w_8Rp7A9N?hL6eC|tqv0JbEiHcwZG%zGeOTl*kIup5F^djc!SbHPtkXi3YICwVLkf&@ZUT(KXL!ck|)ss?1$~-<(8+@_Afy(ioX3V|#KLQf`)imIH?Tudb&EC~j8$EWk zD>kdL`}@&o-`yyS$5bzzSEeWspWts zVl#TfXy-nvq!5x$va&*SS58&5pnGWtF&VyJ%E!oIx7u2B$2XtPS2PCxJ$~6h=re`3 W>QdBy{%Xx~z5GVwu4v?uNB;s+v+WB2 diff --git a/DumpTruck/DumpTruck/Resources/left.jpg b/DumpTruck/DumpTruck/Resources/left.jpg deleted file mode 100644 index 36676e19f5d91e6f70d8e6221d7b62840195b22a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3146 zcmc&$X;4$i7Vc~$1R;b~TqX!OAd3j{y6^X$?*7h& zPhc0&|H|`APk_VWKp55l>;@LB_?WE#tXTtW0RR+i&Hxaw5e{o_4R(N40FT3I`a2_# z2pZEO5(y--7MZMZinfk6g+ir}$y8k`Rc9JzWNkf~?le8kShI;{xn>pCr%}ihO~l6; ztO9fj-~&DZX94hZ9D$C5V!*(#k}yUZQtu3hClE-!6y*#7+4aKh()Jh z^MFVv8O(87p=G#k3)y0qk@Mc8=P8yeuT~rTHAt-%hI7-jsV1h=&1TH~+}dWI?V`p1 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)4kX!gT<($T#DA0kPv?f?J) diff --git a/DumpTruck/DumpTruck/Status.cs b/DumpTruck/DumpTruck/Status.cs new file mode 100644 index 0000000..fafc078 --- /dev/null +++ b/DumpTruck/DumpTruck/Status.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DumpTruck.MovementStrategy +{ + public enum Status + { + NotInit, + + InProgress, + + Finish + } +} -- 2.25.1