From 83514622886c09abbc587dda8073144cf8bbf75b Mon Sep 17 00:00:00 2001 From: 1SooNoo1 Date: Sat, 16 Sep 2023 16:05:15 +0400 Subject: [PATCH] Lab_1_Kryukov_AI_Excavator --- .../ExcavatorForm.Designer.cs | 96 ++++++++++++- .../ProjectExcavator/ExcavatorForm.cs | 72 ++++++++++ .../ProjectExcavator/ProjectExcavator.csproj | 15 ++ .../Properties/Resources.Designer.cs | 103 ++++++++++++++ .../Properties/Resources.resx | 133 ++++++++++++++++++ .../ProjectExcavator/Resources/down.jpg | Bin 0 -> 735 bytes .../ProjectExcavator/Resources/left.jpg | Bin 0 -> 748 bytes .../ProjectExcavator/Resources/right.jpg | Bin 0 -> 741 bytes .../ProjectExcavator/Resources/up.jpg | Bin 0 -> 739 bytes .../lab_1_pojectExcavator.sln | 12 -- 10 files changed, 417 insertions(+), 14 deletions(-) create mode 100644 ProjectExcavator/ProjectExcavator/Properties/Resources.Designer.cs create mode 100644 ProjectExcavator/ProjectExcavator/Properties/Resources.resx create mode 100644 ProjectExcavator/ProjectExcavator/Resources/down.jpg create mode 100644 ProjectExcavator/ProjectExcavator/Resources/left.jpg create mode 100644 ProjectExcavator/ProjectExcavator/Resources/right.jpg create mode 100644 ProjectExcavator/ProjectExcavator/Resources/up.jpg diff --git a/ProjectExcavator/ProjectExcavator/ExcavatorForm.Designer.cs b/ProjectExcavator/ProjectExcavator/ExcavatorForm.Designer.cs index 81929e4..e7b1f13 100644 --- a/ProjectExcavator/ProjectExcavator/ExcavatorForm.Designer.cs +++ b/ProjectExcavator/ProjectExcavator/ExcavatorForm.Designer.cs @@ -28,18 +28,110 @@ /// private void InitializeComponent() { + pictureBoxExcavator = new PictureBox(); + buttonCreate = new Button(); + buttonDown = new Button(); + buttonUp = new Button(); + buttonLeft = new Button(); + buttonRight = new Button(); + ((System.ComponentModel.ISupportInitialize)pictureBoxExcavator).BeginInit(); SuspendLayout(); // - // Form1 + // pictureBoxExcavator + // + pictureBoxExcavator.Dock = DockStyle.Fill; + pictureBoxExcavator.Location = new Point(0, 0); + pictureBoxExcavator.Name = "pictureBoxExcavator"; + pictureBoxExcavator.Size = new Size(800, 450); + pictureBoxExcavator.SizeMode = PictureBoxSizeMode.AutoSize; + pictureBoxExcavator.TabIndex = 0; + pictureBoxExcavator.TabStop = false; + // + // buttonCreate + // + buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreate.Location = new Point(12, 415); + buttonCreate.Name = "buttonCreate"; + buttonCreate.Size = new Size(75, 23); + buttonCreate.TabIndex = 1; + buttonCreate.Text = "Создать"; + buttonCreate.UseVisualStyleBackColor = true; + buttonCreate.Click += buttonCreate_Click; + // + // buttonDown + // + buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonDown.BackgroundImage = Properties.Resources.down; + buttonDown.BackgroundImageLayout = ImageLayout.Zoom; + buttonDown.Location = new Point(722, 415); + buttonDown.Name = "buttonDown"; + buttonDown.Size = new Size(30, 30); + buttonDown.TabIndex = 2; + buttonDown.UseVisualStyleBackColor = true; + buttonDown.Click += buttonMove_Click; + // + // buttonUp + // + buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonUp.BackgroundImage = Properties.Resources.up; + buttonUp.BackgroundImageLayout = ImageLayout.Zoom; + buttonUp.Location = new Point(722, 379); + buttonUp.Name = "buttonUp"; + buttonUp.Size = new Size(30, 30); + buttonUp.TabIndex = 3; + buttonUp.UseVisualStyleBackColor = true; + buttonUp.Click += buttonMove_Click; + // + // buttonLeft + // + buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonLeft.BackgroundImage = Properties.Resources.left; + buttonLeft.BackgroundImageLayout = ImageLayout.Zoom; + buttonLeft.Location = new Point(686, 415); + buttonLeft.Name = "buttonLeft"; + buttonLeft.Size = new Size(30, 30); + buttonLeft.TabIndex = 4; + buttonLeft.UseVisualStyleBackColor = true; + buttonLeft.Click += buttonMove_Click; + // + // buttonRight + // + buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonRight.BackgroundImage = Properties.Resources.right; + buttonRight.BackgroundImageLayout = ImageLayout.Zoom; + buttonRight.Location = new Point(758, 415); + buttonRight.Name = "buttonRight"; + buttonRight.Size = new Size(30, 30); + buttonRight.TabIndex = 5; + buttonRight.UseVisualStyleBackColor = true; + buttonRight.Click += buttonMove_Click; + // + // ExcavatorForm // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(800, 450); - Name = "Form1"; + Controls.Add(buttonRight); + Controls.Add(buttonLeft); + Controls.Add(buttonUp); + Controls.Add(buttonDown); + Controls.Add(buttonCreate); + Controls.Add(pictureBoxExcavator); + Name = "ExcavatorForm"; Text = "Excavator"; + Click += buttonMove_Click; + ((System.ComponentModel.ISupportInitialize)pictureBoxExcavator).EndInit(); ResumeLayout(false); + PerformLayout(); } #endregion + + private PictureBox pictureBoxExcavator; + private Button buttonCreate; + private Button buttonDown; + private Button buttonUp; + private Button buttonLeft; + private Button buttonRight; } } \ No newline at end of file diff --git a/ProjectExcavator/ProjectExcavator/ExcavatorForm.cs b/ProjectExcavator/ProjectExcavator/ExcavatorForm.cs index 84a8ad1..6b7455f 100644 --- a/ProjectExcavator/ProjectExcavator/ExcavatorForm.cs +++ b/ProjectExcavator/ProjectExcavator/ExcavatorForm.cs @@ -2,9 +2,81 @@ namespace ProjectExcavator { public partial class ExcavatorForm : Form { + /// + /// - + /// + private DrawningExcavator? _drawnigExcavator; + /// + /// + /// public ExcavatorForm() { InitializeComponent(); } + /// + /// + /// + private void Draw() + { + if (_drawnigExcavator == null) + { + return; + } + Bitmap bmp = new(pictureBoxExcavator.Width, + pictureBoxExcavator.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawnigExcavator.DrawTransport(gr); + pictureBoxExcavator.Image = bmp; + } + /// + /// "" + /// + /// + /// + /// + /// + /// + /// + /// + private void buttonCreate_Click(object sender, EventArgs e) + { + Random random = new(); + _drawnigExcavator = new DrawningExcavator(); + _drawnigExcavator.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)), + pictureBoxExcavator.Width, + pictureBoxExcavator.Height); + _drawnigExcavator.SetPosition(random.Next(10, 100), + random.Next(10, 100)); + Draw(); + } + private void buttonMove_Click(object sender, EventArgs e) + { + if (_drawnigExcavator == null) + { + return; + } + string name = ((Button)sender)?.Name ?? string.Empty; + switch (name) + { + case "buttonUp": + _drawnigExcavator.MoveTransport(DirectionType.Up); + break; + case "buttonDown": + _drawnigExcavator.MoveTransport(DirectionType.Down); + break; + case "buttonLeft": + _drawnigExcavator.MoveTransport(DirectionType.Left); + break; + case "buttonRight": + _drawnigExcavator.MoveTransport(DirectionType.Right); + break; + } + Draw(); + } } } \ No newline at end of file diff --git a/ProjectExcavator/ProjectExcavator/ProjectExcavator.csproj b/ProjectExcavator/ProjectExcavator/ProjectExcavator.csproj index b57c89e..13ee123 100644 --- a/ProjectExcavator/ProjectExcavator/ProjectExcavator.csproj +++ b/ProjectExcavator/ProjectExcavator/ProjectExcavator.csproj @@ -8,4 +8,19 @@ enable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/ProjectExcavator/ProjectExcavator/Properties/Resources.Designer.cs b/ProjectExcavator/ProjectExcavator/Properties/Resources.Designer.cs new file mode 100644 index 0000000..4daa007 --- /dev/null +++ b/ProjectExcavator/ProjectExcavator/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectExcavator.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("ProjectExcavator.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/ProjectExcavator/ProjectExcavator/Properties/Resources.resx b/ProjectExcavator/ProjectExcavator/Properties/Resources.resx new file mode 100644 index 0000000..3d5a144 --- /dev/null +++ b/ProjectExcavator/ProjectExcavator/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.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/ProjectExcavator/ProjectExcavator/Resources/down.jpg b/ProjectExcavator/ProjectExcavator/Resources/down.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9647e473492c9de4bee14ceacf2c96a064d74899 GIT binary patch literal 735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%)Q>MJ!PABT`W8MlG62Ev*+2JEm^hZx8~$&eqXv7YS;TZznIncK<mp~~*eo@9&+N%k3m6^c|K9`v D2!!_| literal 0 HcmV?d00001 diff --git a/ProjectExcavator/ProjectExcavator/Resources/up.jpg b/ProjectExcavator/ProjectExcavator/Resources/up.jpg new file mode 100644 index 0000000000000000000000000000000000000000..041c169f7fc73027ba6455975f56ef0fde375d97 GIT binary patch literal 739 zcmex=u@XMpRr`iu~T4?h_PehM4)0(kdILSD;rQ)O%P}X3(ypp5ez^x7+3@q zC$b6|vI#pS7B)^g`2Q9I56}%vg3N*p_6+yFmKFpA`vylE1z&dR`E**jH6*}ln#ym+ zHE$E{g-qAn{Pb(7s9sD=EKXL?R)(8s&TBkaEe%&h`7`7J?j=J5|q_xH{^w${S#LE6@m_Z6qI=V>0TJ=n5; znOup+N|yAC5+RJCyNdsvTlu>=S^HsEo2%T4B%^HC_q|Q4)o-ntb~P_UXxTEB2bVX7 zu%@`Zb5MWzJ2QP+#C!4FS<@x@x^BuGYi>G~9p7MU`>WDw<%_?8x=OAS|9C8~ywsxH zIG?%8>eZbSM;bpWf1Xf3HRCq#oXroue*3eYb5^uXc(jXPY;G3Ml+AKBmm)52?7cdp zulvQLw=dcE^_qNK6}I@;n=h9{)7!cvZmi#^$nf@G#+7FA;%Sy9)7o0=|K9`vXU+hK literal 0 HcmV?d00001 diff --git a/lab_1_pojectExcavator/lab_1_pojectExcavator.sln b/lab_1_pojectExcavator/lab_1_pojectExcavator.sln index ae29961..74b4f55 100644 --- a/lab_1_pojectExcavator/lab_1_pojectExcavator.sln +++ b/lab_1_pojectExcavator/lab_1_pojectExcavator.sln @@ -3,19 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.7.34024.191 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab_1_pojectExcavator", "lab_1_pojectExcavator\lab_1_pojectExcavator.csproj", "{5E25350C-F415-461C-9884-AA91AA76466E}" -EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5E25350C-F415-461C-9884-AA91AA76466E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5E25350C-F415-461C-9884-AA91AA76466E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5E25350C-F415-461C-9884-AA91AA76466E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5E25350C-F415-461C-9884-AA91AA76466E}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection