From 335fb2199ad25bb83563c75c83ca05d45b1af35a Mon Sep 17 00:00:00 2001 From: spacyboy Date: Tue, 21 Nov 2023 23:13:14 +0400 Subject: [PATCH 1/2] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F?= =?UTF-8?q?=20=D0=9B=D0=B0=D0=B1=D0=B0=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RoadTrain/RoadTrain/DirectionType.cs | 16 +++ RoadTrain/RoadTrain/DrawingRoadTrain.cs | 113 +++++++++++++++ RoadTrain/RoadTrain/EntityRoadTrain.cs | 25 ++++ RoadTrain/RoadTrain/Form1.Designer.cs | 39 ----- RoadTrain/RoadTrain/Form1.cs | 10 -- RoadTrain/RoadTrain/Program.cs | 9 +- .../Properties/Resources.Designer.cs | 103 +++++++++++++ RoadTrain/RoadTrain/Properties/Resources.resx | 133 +++++++++++++++++ RoadTrain/RoadTrain/Resources/down.png | Bin 0 -> 3385 bytes RoadTrain/RoadTrain/Resources/left.png | Bin 0 -> 3176 bytes RoadTrain/RoadTrain/Resources/right.png | Bin 0 -> 2601 bytes RoadTrain/RoadTrain/Resources/up.png | Bin 0 -> 3331 bytes RoadTrain/RoadTrain/RoadTrain.Designer.cs | 135 ++++++++++++++++++ RoadTrain/RoadTrain/RoadTrain.cs | 62 ++++++++ RoadTrain/RoadTrain/RoadTrain.csproj | 15 ++ .../RoadTrain/{Form1.resx => RoadTrain.resx} | 50 +++---- 16 files changed, 629 insertions(+), 81 deletions(-) create mode 100644 RoadTrain/RoadTrain/DirectionType.cs create mode 100644 RoadTrain/RoadTrain/DrawingRoadTrain.cs create mode 100644 RoadTrain/RoadTrain/EntityRoadTrain.cs delete mode 100644 RoadTrain/RoadTrain/Form1.Designer.cs delete mode 100644 RoadTrain/RoadTrain/Form1.cs create mode 100644 RoadTrain/RoadTrain/Properties/Resources.Designer.cs create mode 100644 RoadTrain/RoadTrain/Properties/Resources.resx create mode 100644 RoadTrain/RoadTrain/Resources/down.png create mode 100644 RoadTrain/RoadTrain/Resources/left.png create mode 100644 RoadTrain/RoadTrain/Resources/right.png create mode 100644 RoadTrain/RoadTrain/Resources/up.png create mode 100644 RoadTrain/RoadTrain/RoadTrain.Designer.cs create mode 100644 RoadTrain/RoadTrain/RoadTrain.cs rename RoadTrain/RoadTrain/{Form1.resx => RoadTrain.resx} (93%) diff --git a/RoadTrain/RoadTrain/DirectionType.cs b/RoadTrain/RoadTrain/DirectionType.cs new file mode 100644 index 0000000..4051946 --- /dev/null +++ b/RoadTrain/RoadTrain/DirectionType.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RoadTrain +{ + public enum DirectionType + { + Up = 1, + Down = 2, + Left = 3, + Right = 4 + } +} \ No newline at end of file diff --git a/RoadTrain/RoadTrain/DrawingRoadTrain.cs b/RoadTrain/RoadTrain/DrawingRoadTrain.cs new file mode 100644 index 0000000..b0007bc --- /dev/null +++ b/RoadTrain/RoadTrain/DrawingRoadTrain.cs @@ -0,0 +1,113 @@ +using System.Net.NetworkInformation; +using System.Net.Sockets; + +namespace RoadTrain +{ + internal class DrawingRoadTrain + { + public EntityRoadTrain? EntityRoadTrain { get; private set; } + private int _pictureWidth; + private int _pictureHeight; + private int _startPosX; + private int _startPosY; + private readonly int _roadTrainWidth = 200; + private readonly int _roadTrainHeight = 100; + public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool wheel, bool door, bool light, int width, int height) + { + if (_roadTrainWidth < width || _roadTrainHeight < height) + { + EntityRoadTrain = new EntityRoadTrain(); + EntityRoadTrain.Init(speed, weight, bodyColor, additionalColor, wheel, door, light); + _pictureWidth = width; + _pictureHeight = height; + return true; + } + return false; + } + public void SetPosition(int x, int y) + { + _startPosX = x; + _startPosY = y; + + if (_startPosX < 0 || _startPosY < 0 || _startPosX > (_pictureWidth - _roadTrainWidth) || _startPosY > (_pictureHeight - _roadTrainHeight)) + { + _startPosX = 50; + _startPosY = 50; + } + } + public void MoveTransport(DirectionType direction) + { + if (EntityRoadTrain == null) + { + return; + } + switch (direction) + { + //влево + case DirectionType.Left: + if (_startPosX - EntityRoadTrain.Step > 0) + { + _startPosX -= (int)EntityRoadTrain.Step; + } + break; + //вверх + case DirectionType.Up: + if (_startPosY - EntityRoadTrain.Step > 0) + { + _startPosY -= (int)EntityRoadTrain.Step; + } + break; + // вправо + case DirectionType.Right: + if (_startPosX + EntityRoadTrain.Step < _pictureWidth - _roadTrainWidth) + { + _startPosX += (int)EntityRoadTrain.Step; + } + break; + //вниз + case DirectionType.Down: + if (_startPosY + EntityRoadTrain.Step < _pictureHeight - _roadTrainHeight) + { + _startPosY += (int)EntityRoadTrain.Step; + } + break; + } + } + public void DrawTransport(Graphics g) + { + if (EntityRoadTrain == null) + { + return; + } + Pen pen = new(Color.Black); + Brush additionalBrush = new + SolidBrush(EntityRoadTrain.AdditionalColor); + g.DrawLine(pen, _startPosX, _startPosY , _startPosX + 180, _startPosY ); //держатель для щетки + g.DrawLine(pen, _startPosX, _startPosY+100 , _startPosX + 180, _startPosY + 100); //держатель для щетки + + //машина + g.DrawRectangle(pen, _startPosX, _startPosY + 50, 160, 20); //кузов + g.DrawEllipse(pen, _startPosX + 5, _startPosY + 70, 30, 30); //колесо + g.DrawEllipse(pen, _startPosX + 40, _startPosY + 70, 30, 30); //колесо + g.DrawEllipse(pen, _startPosX + 120, _startPosY + 70, 30, 30); //колесо + g.DrawRectangle(pen, _startPosX + 120, _startPosY + 10, 40, 40); //кабина + g.DrawRectangle(pen, _startPosX + 10, _startPosY, 90, 50); //бак с водой + g.DrawRectangle(pen, _startPosX + 130, _startPosY + 20, 30, 20); //окно + g.DrawLine(pen, _startPosX + 160, _startPosY + 70, _startPosX + 180, _startPosY + 80); //держатель для щетки + g.DrawRectangle(pen, _startPosX + 170, _startPosY + 80, 40, 10); //щетка + //обвесы + if (EntityRoadTrain.Wheel) + { + g.FillEllipse(additionalBrush, _startPosX + 75, _startPosY + 70, 30, 30); //колесо + } + if (EntityRoadTrain.Door) + { + g.FillRectangle(additionalBrush, _startPosX + 40, _startPosY + 20, 20, 30); //дверь + } + if (EntityRoadTrain.Light) + { + g.FillRectangle(additionalBrush, _startPosX + 135, _startPosY, 10, 10); //мигалка + } + } + } +} \ No newline at end of file diff --git a/RoadTrain/RoadTrain/EntityRoadTrain.cs b/RoadTrain/RoadTrain/EntityRoadTrain.cs new file mode 100644 index 0000000..196715a --- /dev/null +++ b/RoadTrain/RoadTrain/EntityRoadTrain.cs @@ -0,0 +1,25 @@ +namespace RoadTrain +{ + public class EntityRoadTrain + { + public int Speed { get; private set; } + public double Weight { get; private set; } + public Color BodyColor { get; private set; } + public Color AdditionalColor { get; private set; } + public bool Wheel { get; private set; } + public bool Door { get; private set; } + public bool Light { get; private set; } + public double Step => (double)Speed * 100 / Weight; + public void Init(int speed, double weight, Color bodyColor, Color + additionalColor, bool wheel, bool door, bool light) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + AdditionalColor = additionalColor; + Wheel = wheel; + Door = door; + Light = light; + } + } +} \ No newline at end of file diff --git a/RoadTrain/RoadTrain/Form1.Designer.cs b/RoadTrain/RoadTrain/Form1.Designer.cs deleted file mode 100644 index 909c04d..0000000 --- a/RoadTrain/RoadTrain/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace RoadTrain -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} \ No newline at end of file diff --git a/RoadTrain/RoadTrain/Form1.cs b/RoadTrain/RoadTrain/Form1.cs deleted file mode 100644 index 8f6f5e9..0000000 --- a/RoadTrain/RoadTrain/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace RoadTrain -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/RoadTrain/RoadTrain/Program.cs b/RoadTrain/RoadTrain/Program.cs index 45a6222..b765653 100644 --- a/RoadTrain/RoadTrain/Program.cs +++ b/RoadTrain/RoadTrain/Program.cs @@ -1,17 +1,12 @@ -namespace RoadTrain +namespace RoadTrain.A_RoadTrain_Basic { internal static class Program { - /// - /// The main entry point for the application. - /// [STAThread] static void Main() { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(new RoadTrain()); } } } \ No newline at end of file diff --git a/RoadTrain/RoadTrain/Properties/Resources.Designer.cs b/RoadTrain/RoadTrain/Properties/Resources.Designer.cs new file mode 100644 index 0000000..9ca041a --- /dev/null +++ b/RoadTrain/RoadTrain/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace RoadTrain.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("RoadTrain.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/RoadTrain/RoadTrain/Properties/Resources.resx b/RoadTrain/RoadTrain/Properties/Resources.resx new file mode 100644 index 0000000..53ec0b4 --- /dev/null +++ b/RoadTrain/RoadTrain/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + ..\Resources\down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\left.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\right.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/RoadTrain/RoadTrain/Resources/down.png b/RoadTrain/RoadTrain/Resources/down.png new file mode 100644 index 0000000000000000000000000000000000000000..0f9a8dd7cc7e02f150fbdb1604f07d099f338b60 GIT binary patch literal 3385 zcmeH}`#V&77rraE>}9Y*AliaIndosxQULgh$GE>lRkq^PKwhSMPI>E@E&bW%w- zghVdoHW-ZDDxFF$k=vM2Zei3r8E3}c`(6DB=jZpG=h@Gmz1C+w&suBNcbAu+~G>0An+EU%vXV1{Ud{ya8n7{=D?gke}0d6?*KefLtO2*Q3~Gbj>5y7 zK-)dG6w0$ibk>gsxf$o(OgoY!A@%>)|Jnr3R;4>b&)K1_PHq$`qB3Xhy!k(=q6^g2 z7cE|*p-I=$)>)>vTz`du;hJBJjMp+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p(orz+Gt>k!%U41zXd?KA=Tyh-pgV8MqjM;AWh-`1pENvup|0sZ^ zMOtZCgdrGpo52`<1B@X?U>tUnAhLHkRRFpl2asO`#%Mz@8r>+S;Mp$Ch%9xNHWc+Q zL+IXUj}U?u-yzst0>KD3Xne_TJ}*ILR>wqJgc@x?adtnW;EvZZsv_A?i4cp`IPWpE zLhD)z;dLT{swhko!!)l4K$DkspqjNo9GFqd0L&<>0%qjq4Y^T2rxr z*5(BrrYaI!YGGJe3K*8_XDFd07h0R639bE-3$j0%&{{?g810#27*=j249oK=T+44w*HunP$#Skj@N-F*v6H^Q;Jldj9AS(D4VD90s7-C?YGg zsRQuR5dfFO188v_z{>^z?u!R-?ayFzUo!@va|3``#{hKw6Ts4kKR~-5;Ie7}EulMi zRy!hN)yBa$aPc{Si&dcJ^>blfF$)0PGYa6cHrN@<>`nlk;Yf%wZvvB1fSGD|PttL( zKN{WAzb=`#Rr}NcS?Jk|D zR*&sp6DCo()tQu>RCe$Sm4(j(r4^I1sdek0;`e>RMy%7L_@ugz@LS0gbv>u4z_Fi9 qcQlI}En}Xy&| literal 0 HcmV?d00001 diff --git a/RoadTrain/RoadTrain/Resources/left.png b/RoadTrain/RoadTrain/Resources/left.png new file mode 100644 index 0000000000000000000000000000000000000000..8b6ae1e00e4c11f06d6cd53d17952d1d6cc098ac GIT binary patch literal 3176 zcmeH}ZB$a}7RLdHJC0m!YAky9He)ZQK~_?hK{c70qA9+n;!BARS}2HQnup1|D$9mD zdPRj&8%xW~Of3SAW}5Y9dN>8@Gpt~Je<`{B-6>skM^|Icrq zXYYN!JXy!Q-7GCuTfks2OAq(MelQpUdPTs@%^-PNX8RlxGsYnge{*y5-a(%MD1aSKyzFfM@die_Us?}@O+x%^V?Z(Yp?6%rFY{PEfu?x3*&psDC;lM%H zBW~^>oI}dE5dX|9WxBt=koM zEAQQ}t`XEdtZxuDK5A-i5j}qTtX1-|t-a$_XV>d)MNhA4@Xgzy;gQj?@pluGQ)6uxrZtlZ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#VMud-|eklls-*w(F)Bi>TkD3L;+G(B9TFaMvIQ9(AihGkl3ABJ?(6y_6g*Lr%j8 zi>yA$7Pnf%(yQ8yEw)IX!V74f^W+>X)b{}nwbLvm%y52}Q!~Q0_W2@04b8t`J)jEv zGTO)4Vk=z^dky98_{S~26Eq4k+}UCk|7b*5kv|Gx-a!cVWPtFmI`ud-CLjb6t_+Rf z1xsbcgc+KVDRF>x-511+5><_`)(lYGty76ZEs8H7!X(G9cmcI+mM}v#?jR1(t_D)B zH(}m3%N0?G(8A#zUXWDO2AfWiuzA0SoWqK60-qa|Pq4+7j@39+w%7*|DmirE1$ITT zgqdu|j{sJ+QF2&e=8*apNigfO{Sgk;-XDPo{T!z8g8rfw0G&bstZpM;=U`{2`l_9V z@Pce3WAG}|0XE~e-^Za!4v!&dj}Y~FulP>tLaLewUry36Ji}a7q@YQu=Mm>P$~RQ0 zy71>%^g{}Ne!TtK@JYcEPbfz>HkB~rM;a=sP`O?&c)jm;lt@%r1lR0SUD zOZesQetYLKWl9#(f1JZhHJ@8Z%$B5v4Y0ypD2$h5#3iX=xf#yY+r;|Xxd-1%4D)!L zj0ECpmsNvG`|00=70Pe%>I=;~%9CHPBEOOurYj4K)C}=?AJ-O}iOeZwEmZWRmc0~7 z`lGZ)u%z+=zc{y(nOQy17S}CE zQhJGBJV`^>_HZ`NP#y9JZlB)p^x~4VcvRk1pSUYN0k>(N3zu{^aeXyR|x13p#*32l(6g^WZ oZ=Ua~Fx-D`)4%vWx_PZ!M2)@gYdwi5EUcfmG`BS?H}Q=9FXkI%B>(^b literal 0 HcmV?d00001 diff --git a/RoadTrain/RoadTrain/RoadTrain.Designer.cs b/RoadTrain/RoadTrain/RoadTrain.Designer.cs new file mode 100644 index 0000000..96faace --- /dev/null +++ b/RoadTrain/RoadTrain/RoadTrain.Designer.cs @@ -0,0 +1,135 @@ +namespace RoadTrain.A_RoadTrain_Basic +{ + partial class RoadTrain + { + private System.ComponentModel.IContainer components = null; + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + private void InitializeComponent() + { + pictureBoxRoadTrain = new PictureBox(); + buttonCreate = new Button(); + buttonRight = new Button(); + buttonUp = new Button(); + buttonLeft = new Button(); + buttonDown = new Button(); + ((System.ComponentModel.ISupportInitialize)pictureBoxRoadTrain).BeginInit(); + SuspendLayout(); + // + // pictureBoxRoadTrain + // + pictureBoxRoadTrain.Dock = DockStyle.Fill; + pictureBoxRoadTrain.Location = new Point(0, 0); + pictureBoxRoadTrain.Margin = new Padding(3, 2, 3, 2); + pictureBoxRoadTrain.Name = "pictureBoxRoadTrain"; + pictureBoxRoadTrain.Size = new Size(700, 338); + pictureBoxRoadTrain.SizeMode = PictureBoxSizeMode.AutoSize; + pictureBoxRoadTrain.TabIndex = 0; + pictureBoxRoadTrain.TabStop = false; + // + // buttonCreate + // + buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreate.Location = new Point(10, 307); + buttonCreate.Margin = new Padding(3, 2, 3, 2); + buttonCreate.Name = "buttonCreate"; + buttonCreate.Size = new Size(82, 22); + buttonCreate.TabIndex = 1; + buttonCreate.Text = "Создать"; + buttonCreate.UseVisualStyleBackColor = true; + buttonCreate.Click += buttonCreate_Click; + // + // buttonRight + // + buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonRight.BackgroundImage = Properties.Resources.right; + buttonRight.BackgroundImageLayout = ImageLayout.Zoom; + buttonRight.ForeColor = SystemColors.ControlText; + buttonRight.Location = new Point(663, 306); + buttonRight.Margin = new Padding(3, 2, 3, 2); + buttonRight.Name = "buttonRight"; + buttonRight.Size = new Size(26, 22); + buttonRight.TabIndex = 2; + buttonRight.UseVisualStyleBackColor = true; + buttonRight.Click += ButtonMove_Click; + // + // buttonUp + // + buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonUp.BackgroundImage = Properties.Resources.up; + buttonUp.BackgroundImageLayout = ImageLayout.Zoom; + buttonUp.ForeColor = SystemColors.ControlText; + buttonUp.Location = new Point(632, 280); + buttonUp.Margin = new Padding(3, 2, 3, 2); + buttonUp.Name = "buttonUp"; + buttonUp.Size = new Size(26, 22); + buttonUp.TabIndex = 4; + buttonUp.UseVisualStyleBackColor = true; + buttonUp.Click += ButtonMove_Click; + // + // buttonLeft + // + buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonLeft.BackgroundImage = Properties.Resources.left; + buttonLeft.BackgroundImageLayout = ImageLayout.Zoom; + buttonLeft.ForeColor = SystemColors.ControlText; + buttonLeft.Location = new Point(600, 307); + buttonLeft.Margin = new Padding(3, 2, 3, 2); + buttonLeft.Name = "buttonLeft"; + buttonLeft.Size = new Size(26, 22); + buttonLeft.TabIndex = 5; + buttonLeft.UseVisualStyleBackColor = true; + buttonLeft.Click += ButtonMove_Click; + // + // buttonDown + // + buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonDown.BackgroundImage = Properties.Resources.down; + buttonDown.BackgroundImageLayout = ImageLayout.Zoom; + buttonDown.ForeColor = SystemColors.ControlText; + buttonDown.Location = new Point(632, 307); + buttonDown.Margin = new Padding(3, 2, 3, 2); + buttonDown.Name = "buttonDown"; + buttonDown.Size = new Size(26, 22); + buttonDown.TabIndex = 6; + buttonDown.UseVisualStyleBackColor = true; + buttonDown.Click += ButtonMove_Click; + // + // RoadTrain + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(700, 338); + Controls.Add(buttonDown); + Controls.Add(buttonLeft); + Controls.Add(buttonUp); + Controls.Add(buttonRight); + Controls.Add(buttonCreate); + Controls.Add(pictureBoxRoadTrain); + Margin = new Padding(3, 2, 3, 2); + Name = "RoadTrain"; + Text = "RoadTrainForm"; + ((System.ComponentModel.ISupportInitialize)pictureBoxRoadTrain).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + public PictureBox pictureBoxRoadTrain; + private Button buttonCreate; + private Button buttonRight; + private Button buttonUp; + private Button buttonLeft; + private Button buttonDown; + } +} \ No newline at end of file diff --git a/RoadTrain/RoadTrain/RoadTrain.cs b/RoadTrain/RoadTrain/RoadTrain.cs new file mode 100644 index 0000000..616da9a --- /dev/null +++ b/RoadTrain/RoadTrain/RoadTrain.cs @@ -0,0 +1,62 @@ +namespace RoadTrain.A_RoadTrain_Basic +{ + public partial class RoadTrain : Form + { + private DrawingRoadTrain? _drawingRoadTrain; + public RoadTrain() + { + InitializeComponent(); + } + private void Draw() + { + if (_drawingRoadTrain == null) + { + return; + } + Bitmap bmp = new(pictureBoxRoadTrain.Width, + pictureBoxRoadTrain.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawingRoadTrain.DrawTransport(gr); + pictureBoxRoadTrain.Image = bmp; + } + private void buttonCreate_Click(object sender, EventArgs e) + { + Random random = new(); + _drawingRoadTrain = new DrawingRoadTrain(); + _drawingRoadTrain.Init(random.Next(100, 300), + random.Next(1000, 3000), + Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), + Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), + Convert.ToBoolean(random.Next(0, 2)), + Convert.ToBoolean(random.Next(0, 2)), + Convert.ToBoolean(random.Next(0, 2)), + pictureBoxRoadTrain.Width, pictureBoxRoadTrain.Height); + _drawingRoadTrain.SetPosition(random.Next(10, 100), random.Next(10, 100)); + Draw(); + } + private void ButtonMove_Click(object sender, EventArgs e) + { + if (_drawingRoadTrain == null) + { + return; + } + string name = ((Button)sender)?.Name ?? string.Empty; + switch (name) + { + case "buttonUp": + _drawingRoadTrain.MoveTransport(DirectionType.Up); + break; + case "buttonDown": + _drawingRoadTrain.MoveTransport(DirectionType.Down); + break; + case "buttonLeft": + _drawingRoadTrain.MoveTransport(DirectionType.Left); + break; + case "buttonRight": + _drawingRoadTrain.MoveTransport(DirectionType.Right); + break; + } + Draw(); + } + } +} diff --git a/RoadTrain/RoadTrain/RoadTrain.csproj b/RoadTrain/RoadTrain/RoadTrain.csproj index b57c89e..13ee123 100644 --- a/RoadTrain/RoadTrain/RoadTrain.csproj +++ b/RoadTrain/RoadTrain/RoadTrain.csproj @@ -8,4 +8,19 @@ enable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/RoadTrain/RoadTrain/Form1.resx b/RoadTrain/RoadTrain/RoadTrain.resx similarity index 93% rename from RoadTrain/RoadTrain/Form1.resx rename to RoadTrain/RoadTrain/RoadTrain.resx index 1af7de1..af32865 100644 --- a/RoadTrain/RoadTrain/Form1.resx +++ b/RoadTrain/RoadTrain/RoadTrain.resx @@ -1,17 +1,17 @@  - -- 2.25.1 From e66fcaaf6af1331de7813454fa97e69202ec7712 Mon Sep 17 00:00:00 2001 From: spacyboy Date: Tue, 21 Nov 2023 23:31:46 +0400 Subject: [PATCH 2/2] =?UTF-8?q?=D1=83=D0=B1=D1=80=D0=B0=D0=BB=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BE=D1=87=D0=BD=D1=8B=D0=B5=20?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RoadTrain/RoadTrain/DrawingRoadTrain.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/RoadTrain/RoadTrain/DrawingRoadTrain.cs b/RoadTrain/RoadTrain/DrawingRoadTrain.cs index b0007bc..5c03287 100644 --- a/RoadTrain/RoadTrain/DrawingRoadTrain.cs +++ b/RoadTrain/RoadTrain/DrawingRoadTrain.cs @@ -82,9 +82,6 @@ namespace RoadTrain Pen pen = new(Color.Black); Brush additionalBrush = new SolidBrush(EntityRoadTrain.AdditionalColor); - g.DrawLine(pen, _startPosX, _startPosY , _startPosX + 180, _startPosY ); //держатель для щетки - g.DrawLine(pen, _startPosX, _startPosY+100 , _startPosX + 180, _startPosY + 100); //держатель для щетки - //машина g.DrawRectangle(pen, _startPosX, _startPosY + 50, 160, 20); //кузов g.DrawEllipse(pen, _startPosX + 5, _startPosY + 70, 30, 30); //колесо -- 2.25.1