Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
df47846cd5 | ||
|
18b809d6b8 | ||
|
fe2b37f882 | ||
|
c444b307c1 | ||
|
4c767e5573 | ||
|
149fcacbcb | ||
|
ed3d9b6f80 | ||
|
ec4a056798 | ||
aa09b6df1f | |||
4c1b04c199 | |||
dfefab6682 | |||
|
f7aa2de3dc | ||
ab95f876c5 | |||
|
0fb498e55d | ||
|
db900bee31 | ||
|
3c394c5451 | ||
|
52377c82d3 | ||
|
6638bb7e9b | ||
|
7d15ea92da |
@ -1,26 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,63 +0,0 @@
|
||||
namespace Bulldozer
|
||||
{
|
||||
public partial class FormBulldozer : Form
|
||||
{
|
||||
private DrawingBulldozer? _bulldozer;
|
||||
private EntityBulldozer? Bulldozer { get; set; }
|
||||
public FormBulldozer()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxBulldozer.Width, pictureBoxBulldozer.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_bulldozer?.DrawTransport(gr, Bulldozer);
|
||||
pictureBoxBulldozer.Image = bmp;
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_bulldozer = new DrawingBulldozer();
|
||||
Bulldozer = new EntityBulldozer();
|
||||
|
||||
_bulldozer.Init(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), Bulldozer);
|
||||
_bulldozer.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
||||
pictureBoxBulldozer.Width, pictureBoxBulldozer.Height);
|
||||
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {Bulldozer.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Âåñ: {Bulldozer.Weight}";
|
||||
toolStripStatusLabelBodyColor.Text = $"Öâåò: {Bulldozer.BodyColor.Name} ";
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_bulldozer?.MoveTransport(Direction.Up, Bulldozer);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_bulldozer?.MoveTransport(Direction.Down, Bulldozer);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_bulldozer?.MoveTransport(Direction.Left, Bulldozer);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_bulldozer?.MoveTransport(Direction.Right, Bulldozer);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void pictureBoxBulldozer_Resize(object sender, EventArgs e)
|
||||
{
|
||||
_bulldozer?.ChangeBorders(pictureBoxBulldozer.Width, pictureBoxBulldozer.Height);
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32825.248
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bulldozer", "Bulldozer\Bulldozer.csproj", "{E5F857A0-7B7F-4F53-8C92-330D2F451FBA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E5F857A0-7B7F-4F53-8C92-330D2F451FBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E5F857A0-7B7F-4F53-8C92-330D2F451FBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E5F857A0-7B7F-4F53-8C92-330D2F451FBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E5F857A0-7B7F-4F53-8C92-330D2F451FBA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {A2E69D0E-100A-4D29-BF23-5EB2E6ED3E33}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.32112.339
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HoistingCrane", "HoistingCrane\HoistingCrane.csproj", "{D80E7B00-5088-4976-A795-E42A2FE183D6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D80E7B00-5088-4976-A795-E42A2FE183D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D80E7B00-5088-4976-A795-E42A2FE183D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D80E7B00-5088-4976-A795-E42A2FE183D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D80E7B00-5088-4976-A795-E42A2FE183D6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {F67B9958-A88C-4E5E-9405-BA7150E626AF}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bulldozer
|
||||
namespace HoistingCrane
|
||||
{
|
||||
internal enum Direction
|
||||
{
|
||||
@ -13,4 +13,4 @@ namespace Bulldozer
|
||||
Left = 3,
|
||||
Right = 4
|
||||
}
|
||||
}
|
||||
}
|
@ -4,37 +4,35 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bulldozer
|
||||
namespace HoistingCrane
|
||||
{
|
||||
internal class DrawingBulldozer
|
||||
internal class DrawingHoistingCrane
|
||||
{
|
||||
|
||||
|
||||
public EntityHoistingCrane HoistingCrane { get; private set; }
|
||||
|
||||
private float _startPosX;
|
||||
private float _startPosY;
|
||||
private int? _pictureWidth = null;
|
||||
private int? _pictureHeight = null;
|
||||
private readonly int _bulldozerWidth = 80;
|
||||
private readonly int _bulldozerHeight = 80;
|
||||
private readonly int _hoistingCraneWidth = 80;
|
||||
private readonly int _hoistingCraneHeight = 50;
|
||||
|
||||
public void Init(int speed, float weight, Color bodyColor, EntityBulldozer Bulldozer)
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
|
||||
Bulldozer.Init(speed, weight, bodyColor);
|
||||
HoistingCrane = new EntityHoistingCrane();
|
||||
HoistingCrane.Init(speed, weight, bodyColor);
|
||||
}
|
||||
|
||||
public void SetPosition(int x, int y, int width, int height)
|
||||
{
|
||||
|
||||
if (x < 0 || x + _bulldozerWidth >= width || y < 0 || y + _bulldozerHeight >= height) return;
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
// TODO checks
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
}
|
||||
|
||||
public void MoveTransport(Direction direction, EntityBulldozer Bulldozer)
|
||||
public void MoveTransport(Direction direction)
|
||||
{
|
||||
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
|
||||
{
|
||||
@ -42,33 +40,37 @@ namespace Bulldozer
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
// вправо
|
||||
case Direction.Right:
|
||||
if (_startPosX + _bulldozerWidth + Bulldozer.Step < _pictureWidth)
|
||||
if (_startPosX + _hoistingCraneWidth + HoistingCrane.Step < _pictureWidth)
|
||||
{
|
||||
_startPosX += Bulldozer.Step;
|
||||
_startPosX += HoistingCrane.Step;
|
||||
}
|
||||
break;
|
||||
//влево
|
||||
case Direction.Left:
|
||||
if (_startPosX - Bulldozer.Step > 0)
|
||||
if (_startPosX - HoistingCrane.Step > 0)
|
||||
{
|
||||
_startPosX -= Bulldozer.Step;
|
||||
_startPosX -= HoistingCrane.Step;
|
||||
}
|
||||
break;
|
||||
//вверх
|
||||
case Direction.Up:
|
||||
if (_startPosY - Bulldozer.Step > 0)
|
||||
if (_startPosY - HoistingCrane.Step > 0)
|
||||
{
|
||||
_startPosY -= Bulldozer.Step;
|
||||
_startPosY -= HoistingCrane.Step;
|
||||
}
|
||||
break;
|
||||
//вниз
|
||||
case Direction.Down:
|
||||
if (_startPosY + _bulldozerHeight + Bulldozer.Step < _pictureHeight)
|
||||
if (_startPosY + _hoistingCraneHeight + HoistingCrane.Step < _pictureHeight)
|
||||
{
|
||||
_startPosY += Bulldozer.Step;
|
||||
_startPosY += HoistingCrane.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void DrawTransport(Graphics g, EntityBulldozer Bulldozer)
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if (_startPosX < 0 || _startPosY < 0
|
||||
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||
@ -93,7 +95,7 @@ namespace Bulldozer
|
||||
g.DrawRectangle(pen, _startPosX + 45, _startPosY + 45, 4, 6);
|
||||
|
||||
//корпус
|
||||
Brush br = new SolidBrush(Bulldozer?.BodyColor ?? Color.Black);
|
||||
Brush br = new SolidBrush(HoistingCrane?.BodyColor ?? Color.Black);
|
||||
g.FillRectangle(br, _startPosX, _startPosY + 25, 75, 25);
|
||||
g.FillRectangle(br, _startPosX, _startPosY, 25, 25);
|
||||
|
||||
@ -119,28 +121,26 @@ namespace Bulldozer
|
||||
g.FillEllipse(brBlack, _startPosX + 50, _startPosY + 53, 10, 10);
|
||||
g.FillRectangle(brBlack, _startPosX + 30, _startPosY + 45, 4, 6);
|
||||
g.FillRectangle(brBlack, _startPosX + 45, _startPosY + 45, 4, 6);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void ChangeBorders(int width, int height)
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
if (_pictureWidth <= _bulldozerWidth || _pictureHeight <= _bulldozerHeight)
|
||||
if (_pictureWidth <= _hoistingCraneWidth || _pictureHeight <= _hoistingCraneHeight)
|
||||
{
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
return;
|
||||
}
|
||||
if (_startPosX + _bulldozerWidth > _pictureWidth)
|
||||
if (_startPosX + _hoistingCraneWidth > _pictureWidth)
|
||||
{
|
||||
_startPosX = _pictureWidth.Value - _bulldozerWidth;
|
||||
_startPosX = _pictureWidth.Value - _hoistingCraneWidth;
|
||||
}
|
||||
if (_startPosY + _bulldozerHeight > _pictureHeight)
|
||||
if (_startPosY + _hoistingCraneHeight > _pictureHeight)
|
||||
{
|
||||
_startPosY = _pictureHeight.Value - _bulldozerHeight;
|
||||
_startPosY = _pictureHeight.Value - _hoistingCraneHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -4,9 +4,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bulldozer
|
||||
namespace HoistingCrane
|
||||
{
|
||||
internal class EntityBulldozer
|
||||
internal class EntityHoistingCrane
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
|
@ -1,11 +1,8 @@
|
||||
namespace Bulldozer
|
||||
namespace HoistingCrane
|
||||
{
|
||||
partial class FormBulldozer
|
||||
partial class FormHoistingCrane
|
||||
{
|
||||
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
@ -16,8 +13,6 @@
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
@ -29,15 +24,13 @@
|
||||
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.pictureBoxBulldozer = new System.Windows.Forms.PictureBox();
|
||||
this.pictureBoxHoistingCrane = new System.Windows.Forms.PictureBox();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBulldozer)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxHoistingCrane)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::Bulldozer.Properties.Resources.up;
|
||||
this.buttonUp.BackgroundImage = global::HoistingCrane.Properties.Resources.up;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonUp.Location = new System.Drawing.Point(722, 353);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
@ -45,11 +38,9 @@
|
||||
this.buttonUp.TabIndex = 0;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::Bulldozer.Properties.Resources.left;
|
||||
this.buttonLeft.BackgroundImage = global::HoistingCrane.Properties.Resources.left;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(686, 389);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
@ -57,11 +48,9 @@
|
||||
this.buttonLeft.TabIndex = 1;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::Bulldozer.Properties.Resources.right;
|
||||
this.buttonRight.BackgroundImage = global::HoistingCrane.Properties.Resources.right;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonRight.Location = new System.Drawing.Point(758, 389);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
@ -69,11 +58,9 @@
|
||||
this.buttonRight.TabIndex = 2;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::Bulldozer.Properties.Resources.down;
|
||||
this.buttonDown.BackgroundImage = global::HoistingCrane.Properties.Resources.down;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonDown.Location = new System.Drawing.Point(722, 389);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
@ -81,9 +68,7 @@
|
||||
this.buttonDown.TabIndex = 3;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
|
||||
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonCreate.Location = new System.Drawing.Point(12, 393);
|
||||
this.buttonCreate.Name = "buttonCreate";
|
||||
@ -92,9 +77,7 @@
|
||||
this.buttonCreate.Text = "Создать";
|
||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
|
||||
//
|
||||
// statusStrip1
|
||||
//
|
||||
|
||||
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripStatusLabelSpeed,
|
||||
this.toolStripStatusLabelWeight,
|
||||
@ -104,40 +87,27 @@
|
||||
this.statusStrip1.Size = new System.Drawing.Size(800, 22);
|
||||
this.statusStrip1.TabIndex = 5;
|
||||
this.statusStrip1.Text = "statusStrip1";
|
||||
//
|
||||
// toolStripStatusLabelSpeed
|
||||
//
|
||||
|
||||
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
|
||||
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(62, 17);
|
||||
this.toolStripStatusLabelSpeed.Text = "Скорость:";
|
||||
//
|
||||
// toolStripStatusLabelWeight
|
||||
//
|
||||
|
||||
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
|
||||
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(29, 17);
|
||||
this.toolStripStatusLabelWeight.Text = "Вес:";
|
||||
//
|
||||
// toolStripStatusLabelBodyColor
|
||||
//
|
||||
|
||||
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
|
||||
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(36, 17);
|
||||
this.toolStripStatusLabelBodyColor.Text = "Цвет:";
|
||||
//
|
||||
// pictureBoxBulldozer
|
||||
//
|
||||
this.pictureBoxBulldozer.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
|
||||
this.pictureBoxBulldozer.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxBulldozer.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxBulldozer.Name = "pictureBoxBulldozer";
|
||||
this.pictureBoxBulldozer.Size = new System.Drawing.Size(800, 450);
|
||||
this.pictureBoxBulldozer.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBoxBulldozer.TabIndex = 6;
|
||||
this.pictureBoxBulldozer.TabStop = false;
|
||||
this.pictureBoxBulldozer.Click += new System.EventHandler(this.pictureBoxBulldozer_Resize);
|
||||
this.pictureBoxBulldozer.Resize += new System.EventHandler(this.pictureBoxBulldozer_Resize);
|
||||
//
|
||||
// FormBulldozer
|
||||
//
|
||||
|
||||
this.pictureBoxHoistingCrane.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxHoistingCrane.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxHoistingCrane.Name = "pictureBoxHoistingCrane";
|
||||
this.pictureBoxHoistingCrane.Size = new System.Drawing.Size(800, 450);
|
||||
this.pictureBoxHoistingCrane.TabIndex = 6;
|
||||
this.pictureBoxHoistingCrane.TabStop = false;
|
||||
this.pictureBoxHoistingCrane.Click += new System.EventHandler(this.pictureBoxHoistingCrane_Resize);
|
||||
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
@ -147,19 +117,18 @@
|
||||
this.Controls.Add(this.buttonRight);
|
||||
this.Controls.Add(this.buttonLeft);
|
||||
this.Controls.Add(this.buttonUp);
|
||||
this.Controls.Add(this.pictureBoxBulldozer);
|
||||
this.Name = "FormBulldozer";
|
||||
this.Text = "Трактор";
|
||||
this.Controls.Add(this.pictureBoxHoistingCrane);
|
||||
this.Name = "FormHoistingCrane";
|
||||
this.Text = "Подъёмный кран";
|
||||
this.statusStrip1.ResumeLayout(false);
|
||||
this.statusStrip1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBulldozer)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxHoistingCrane)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonUp;
|
||||
private Button buttonLeft;
|
||||
private Button buttonRight;
|
||||
@ -169,6 +138,6 @@
|
||||
private ToolStripStatusLabel toolStripStatusLabelSpeed;
|
||||
private ToolStripStatusLabel toolStripStatusLabelWeight;
|
||||
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
|
||||
private PictureBox pictureBoxBulldozer;
|
||||
private PictureBox pictureBoxHoistingCrane;
|
||||
}
|
||||
}
|
75
HoistingCrane/HoistingCrane/FormHoistingCrane.cs
Normal file
@ -0,0 +1,75 @@
|
||||
namespace HoistingCrane
|
||||
{
|
||||
public partial class FormHoistingCrane : Form
|
||||
{
|
||||
private DrawingHoistingCrane _hoistingCrane;
|
||||
public FormHoistingCrane()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_hoistingCrane?.DrawTransport(gr);
|
||||
pictureBoxHoistingCrane.Image = bmp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Ñîçäàòü"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_hoistingCrane = new DrawingHoistingCrane();
|
||||
_hoistingCrane.Init(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
_hoistingCrane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
||||
pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
|
||||
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_hoistingCrane.HoistingCrane.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Âåñ: {_hoistingCrane.HoistingCrane.Weight}";
|
||||
toolStripStatusLabelBodyColor.Text = $"Öâåò: {_hoistingCrane.HoistingCrane.BodyColor.Name} ";
|
||||
Draw();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Èçìåíåíèå ðàçìåðîâ ôîðìû
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_hoistingCrane?.MoveTransport(Direction.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_hoistingCrane?.MoveTransport(Direction.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_hoistingCrane?.MoveTransport(Direction.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_hoistingCrane?.MoveTransport(Direction.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Èçìåíåíèå ðàçìåðîâ ôîðìû
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void pictureBoxHoistingCrane_Resize(object sender, EventArgs e)
|
||||
{
|
||||
_hoistingCrane?.ChangeBorders(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
@ -57,10 +57,4 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>25</value>
|
||||
</metadata>
|
||||
</root>
|
11
HoistingCrane/HoistingCrane/HoistingCrane.csproj
Normal file
@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
@ -1,14 +1,17 @@
|
||||
namespace Bulldozer
|
||||
namespace HoistingCrane
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[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 FormBulldozer());
|
||||
Application.Run(new FormHoistingCrane());
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Bulldozer.Properties {
|
||||
namespace HoistingCrane.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ namespace Bulldozer.Properties {
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Bulldozer.Properties.Resources", typeof(Resources).Assembly);
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HoistingCrane.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |