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 0000000..9647e47 Binary files /dev/null and b/ProjectExcavator/ProjectExcavator/Resources/down.jpg differ diff --git a/ProjectExcavator/ProjectExcavator/Resources/left.jpg b/ProjectExcavator/ProjectExcavator/Resources/left.jpg new file mode 100644 index 0000000..6025d82 Binary files /dev/null and b/ProjectExcavator/ProjectExcavator/Resources/left.jpg differ diff --git a/ProjectExcavator/ProjectExcavator/Resources/right.jpg b/ProjectExcavator/ProjectExcavator/Resources/right.jpg new file mode 100644 index 0000000..657d1b9 Binary files /dev/null and b/ProjectExcavator/ProjectExcavator/Resources/right.jpg differ diff --git a/ProjectExcavator/ProjectExcavator/Resources/up.jpg b/ProjectExcavator/ProjectExcavator/Resources/up.jpg new file mode 100644 index 0000000..041c169 Binary files /dev/null and b/ProjectExcavator/ProjectExcavator/Resources/up.jpg differ 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