diff --git a/GasolineTanker/GasolineTanker/Direction.cs b/GasolineTanker/GasolineTanker/Direction.cs
new file mode 100644
index 0000000..8fd3c1c
--- /dev/null
+++ b/GasolineTanker/GasolineTanker/Direction.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GasolineTanker
+{
+ internal enum Direction
+ {
+ Up = 1,
+ Down = 2,
+ Left = 3,
+ Right = 4,
+ }
+}
diff --git a/GasolineTanker/GasolineTanker/DrawingGasolineTanker.cs b/GasolineTanker/GasolineTanker/DrawingGasolineTanker.cs
new file mode 100644
index 0000000..ae56d2a
--- /dev/null
+++ b/GasolineTanker/GasolineTanker/DrawingGasolineTanker.cs
@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GasolineTanker
+{
+ internal class DrawingGasolineTanker
+ {
+ public EnityGasolineTanker GasolineTanker { get; private set; }
+ private float _startPosX;
+ private float _startPosY;
+ private int? _pictureWidth = null;
+ private int? _pictureHeight = null;
+ private readonly int _gasolineTankerWidth = 80;
+ private readonly int _gasolineTankerHeight = 50;
+
+ public void Init(int speed, float weight, Color bodyColor)
+ {
+ GasolineTanker = new EnityGasolineTanker();
+ GasolineTanker.Init(speed, weight, bodyColor);
+ }
+
+ public void SetPosition(int x, int y, int width, int height)
+ {
+ // Check
+ _startPosX = x;
+ _startPosY = y;
+ _pictureWidth = width;
+ _pictureHeight = height;
+ }
+
+ public void MoveTransport(Direction direction)
+ {
+ if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
+ {
+ return;
+ }
+ switch (direction)
+ {
+ // вправо
+ case Direction.Right:
+ if (_startPosX + _gasolineTankerWidth + GasolineTanker.Step < _pictureWidth)
+ {
+ _startPosX += GasolineTanker.Step;
+ }
+ break;
+ //влево
+ case Direction.Left:
+ // TODO: Продумать логику
+ break;
+ //вверх
+ case Direction.Up:
+ // TODO: Продумать логику
+ break;
+ //вниз
+ case Direction.Down:
+ if (_startPosY + _gasolineTankerHeight + GasolineTanker.Step < _pictureHeight)
+ {
+ _startPosY += GasolineTanker.Step;
+ }
+ break;
+ }
+ }
+ public void DrawTransport(Graphics g)
+ {
+
+ }
+ public void ChangeBorders(int width, int height)
+ {
+ _pictureWidth = width;
+ _pictureHeight = height;
+ if (_pictureWidth <= _gasolineTankerWidth || _pictureHeight <= _gasolineTankerHeight)
+ {
+ _pictureWidth = null;
+ _pictureHeight = null;
+ return;
+ }
+ if (_startPosX + _gasolineTankerWidth > _pictureWidth)
+ {
+ _startPosX = _pictureWidth.Value - _gasolineTankerWidth;
+ }
+ if (_startPosY + _gasolineTankerHeight > _pictureHeight)
+ {
+ _startPosY = _pictureHeight.Value - _gasolineTankerHeight;
+ }
+ }
+ }
+}
diff --git a/GasolineTanker/GasolineTanker/EnityGasolineTanker.cs b/GasolineTanker/GasolineTanker/EnityGasolineTanker.cs
new file mode 100644
index 0000000..e3f5b3b
--- /dev/null
+++ b/GasolineTanker/GasolineTanker/EnityGasolineTanker.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GasolineTanker
+{
+ internal class EnityGasolineTanker
+ {
+ 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)
+ {
+ Random rnd = new Random();
+ Speed = speed <= 0 ? rnd.Next(50, 100) : speed;
+ Weight = weight <= 0 ? rnd.Next(30, 60) : weight;
+ BodyColor = bodyColor;
+ }
+ }
+}
diff --git a/GasolineTanker/GasolineTanker/Form1.Designer.cs b/GasolineTanker/GasolineTanker/Form1.Designer.cs
deleted file mode 100644
index 521f5d0..0000000
--- a/GasolineTanker/GasolineTanker/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace GasolineTanker
-{
- 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/GasolineTanker/GasolineTanker/Form1.cs b/GasolineTanker/GasolineTanker/Form1.cs
deleted file mode 100644
index da846e9..0000000
--- a/GasolineTanker/GasolineTanker/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace GasolineTanker
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/GasolineTanker/GasolineTanker/FormGasolineTanker.Designer.cs b/GasolineTanker/GasolineTanker/FormGasolineTanker.Designer.cs
new file mode 100644
index 0000000..667c238
--- /dev/null
+++ b/GasolineTanker/GasolineTanker/FormGasolineTanker.Designer.cs
@@ -0,0 +1,169 @@
+namespace GasolineTanker
+{
+ partial class FormGasolineTanker
+ {
+ ///
+ /// 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.pictureBoxGasolineTanker = new System.Windows.Forms.PictureBox();
+ this.statusStrip1 = new System.Windows.Forms.StatusStrip();
+ this.toolStripStatusSpeed = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripStatusWeight = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripStatusBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
+ this.buttonCreate = new System.Windows.Forms.Button();
+ this.KeyDown = new System.Windows.Forms.Button();
+ this.KeyUp = new System.Windows.Forms.Button();
+ this.KeyLeft = new System.Windows.Forms.Button();
+ this.KeyRight = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxGasolineTanker)).BeginInit();
+ this.statusStrip1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // pictureBoxGasolineTanker
+ //
+ this.pictureBoxGasolineTanker.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.pictureBoxGasolineTanker.Location = new System.Drawing.Point(0, 0);
+ this.pictureBoxGasolineTanker.Name = "pictureBoxGasolineTanker";
+ this.pictureBoxGasolineTanker.Size = new System.Drawing.Size(800, 428);
+ this.pictureBoxGasolineTanker.TabIndex = 0;
+ this.pictureBoxGasolineTanker.TabStop = false;
+ //
+ // statusStrip1
+ //
+ this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.toolStripStatusSpeed,
+ this.toolStripStatusWeight,
+ this.toolStripStatusBodyColor});
+ this.statusStrip1.Location = new System.Drawing.Point(0, 428);
+ this.statusStrip1.Name = "statusStrip1";
+ this.statusStrip1.Size = new System.Drawing.Size(800, 22);
+ this.statusStrip1.TabIndex = 1;
+ this.statusStrip1.Text = "statusStrip1";
+ //
+ // toolStripStatusSpeed
+ //
+ this.toolStripStatusSpeed.Name = "toolStripStatusSpeed";
+ this.toolStripStatusSpeed.Size = new System.Drawing.Size(39, 17);
+ this.toolStripStatusSpeed.Text = "Speed";
+ this.toolStripStatusSpeed.Click += new System.EventHandler(this.toolStripStatusLabel1_Click);
+ //
+ // toolStripStatusWeight
+ //
+ this.toolStripStatusWeight.Name = "toolStripStatusWeight";
+ this.toolStripStatusWeight.Size = new System.Drawing.Size(45, 17);
+ this.toolStripStatusWeight.Text = "Weight";
+ //
+ // toolStripStatusBodyColor
+ //
+ this.toolStripStatusBodyColor.Name = "toolStripStatusBodyColor";
+ this.toolStripStatusBodyColor.Size = new System.Drawing.Size(36, 17);
+ this.toolStripStatusBodyColor.Text = "Color";
+ //
+ // buttonCreate
+ //
+ this.buttonCreate.Location = new System.Drawing.Point(12, 393);
+ this.buttonCreate.Name = "buttonCreate";
+ this.buttonCreate.Size = new System.Drawing.Size(75, 23);
+ this.buttonCreate.TabIndex = 2;
+ this.buttonCreate.Text = "Create";
+ this.buttonCreate.UseVisualStyleBackColor = true;
+ //
+ // KeyDown
+ //
+ this.KeyDown.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyDown;
+ this.KeyDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.KeyDown.Location = new System.Drawing.Point(624, 386);
+ this.KeyDown.Name = "KeyDown";
+ this.KeyDown.Size = new System.Drawing.Size(30, 30);
+ this.KeyDown.TabIndex = 3;
+ this.KeyDown.UseVisualStyleBackColor = true;
+ //
+ // KeyUp
+ //
+ this.KeyUp.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyUp;
+ this.KeyUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.KeyUp.Location = new System.Drawing.Point(624, 350);
+ this.KeyUp.Name = "KeyUp";
+ this.KeyUp.Size = new System.Drawing.Size(30, 30);
+ this.KeyUp.TabIndex = 4;
+ this.KeyUp.UseVisualStyleBackColor = true;
+ //
+ // KeyLeft
+ //
+ this.KeyLeft.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyLeft;
+ this.KeyLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.KeyLeft.Location = new System.Drawing.Point(588, 386);
+ this.KeyLeft.Name = "KeyLeft";
+ this.KeyLeft.Size = new System.Drawing.Size(30, 30);
+ this.KeyLeft.TabIndex = 5;
+ this.KeyLeft.UseVisualStyleBackColor = true;
+ //
+ // KeyRight
+ //
+ this.KeyRight.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyRight;
+ this.KeyRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.KeyRight.Location = new System.Drawing.Point(660, 386);
+ this.KeyRight.Name = "KeyRight";
+ this.KeyRight.Size = new System.Drawing.Size(30, 30);
+ this.KeyRight.TabIndex = 6;
+ this.KeyRight.UseVisualStyleBackColor = true;
+ //
+ // FormGasolineTanker
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.KeyRight);
+ this.Controls.Add(this.KeyLeft);
+ this.Controls.Add(this.KeyUp);
+ this.Controls.Add(this.KeyDown);
+ this.Controls.Add(this.buttonCreate);
+ this.Controls.Add(this.pictureBoxGasolineTanker);
+ this.Controls.Add(this.statusStrip1);
+ this.Name = "FormGasolineTanker";
+ this.Text = "Gasoline tanker";
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxGasolineTanker)).EndInit();
+ this.statusStrip1.ResumeLayout(false);
+ this.statusStrip1.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private PictureBox pictureBoxGasolineTanker;
+ private StatusStrip statusStrip1;
+ private ToolStripStatusLabel toolStripStatusSpeed;
+ private ToolStripStatusLabel toolStripStatusWeight;
+ private ToolStripStatusLabel toolStripStatusBodyColor;
+ private Button buttonCreate;
+ private Button KeyDown;
+ private Button KeyUp;
+ private Button KeyLeft;
+ private Button KeyRight;
+ }
+}
\ No newline at end of file
diff --git a/GasolineTanker/GasolineTanker/FormGasolineTanker.cs b/GasolineTanker/GasolineTanker/FormGasolineTanker.cs
new file mode 100644
index 0000000..eafa89b
--- /dev/null
+++ b/GasolineTanker/GasolineTanker/FormGasolineTanker.cs
@@ -0,0 +1,20 @@
+namespace GasolineTanker
+{
+ public partial class FormGasolineTanker : Form
+ {
+ public FormGasolineTanker()
+ {
+ InitializeComponent();
+ }
+
+ private void toolStripStatusLabel1_Click(object sender, EventArgs e)
+ {
+
+ }
+
+ private void ButtonCreate_Click(object sender, EventArgs e)
+ {
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/GasolineTanker/GasolineTanker/FormGasolineTanker.resx b/GasolineTanker/GasolineTanker/FormGasolineTanker.resx
new file mode 100644
index 0000000..5cb320f
--- /dev/null
+++ b/GasolineTanker/GasolineTanker/FormGasolineTanker.resx
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/GasolineTanker/GasolineTanker/GasolineTanker.csproj b/GasolineTanker/GasolineTanker/GasolineTanker.csproj
index b57c89e..13ee123 100644
--- a/GasolineTanker/GasolineTanker/GasolineTanker.csproj
+++ b/GasolineTanker/GasolineTanker/GasolineTanker.csproj
@@ -8,4 +8,19 @@
enable
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
\ No newline at end of file
diff --git a/GasolineTanker/GasolineTanker/Program.cs b/GasolineTanker/GasolineTanker/Program.cs
index feb86c7..1b6a3e0 100644
--- a/GasolineTanker/GasolineTanker/Program.cs
+++ b/GasolineTanker/GasolineTanker/Program.cs
@@ -11,7 +11,7 @@ namespace GasolineTanker
// 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 FormGasolineTanker());
}
}
}
\ No newline at end of file
diff --git a/GasolineTanker/GasolineTanker/Properties/Resources.Designer.cs b/GasolineTanker/GasolineTanker/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..af947f3
--- /dev/null
+++ b/GasolineTanker/GasolineTanker/Properties/Resources.Designer.cs
@@ -0,0 +1,103 @@
+//------------------------------------------------------------------------------
+//
+// Этот код создан программой.
+// Исполняемая версия:4.0.30319.42000
+//
+// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
+// повторной генерации кода.
+//
+//------------------------------------------------------------------------------
+
+namespace GasolineTanker.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("GasolineTanker.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 KeyDown {
+ get {
+ object obj = ResourceManager.GetObject("KeyDown", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap KeyLeft {
+ get {
+ object obj = ResourceManager.GetObject("KeyLeft", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap KeyRight {
+ get {
+ object obj = ResourceManager.GetObject("KeyRight", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap KeyUp {
+ get {
+ object obj = ResourceManager.GetObject("KeyUp", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+ }
+}
diff --git a/GasolineTanker/GasolineTanker/Form1.resx b/GasolineTanker/GasolineTanker/Properties/Resources.resx
similarity index 83%
rename from GasolineTanker/GasolineTanker/Form1.resx
rename to GasolineTanker/GasolineTanker/Properties/Resources.resx
index 1af7de1..3cca124 100644
--- a/GasolineTanker/GasolineTanker/Form1.resx
+++ b/GasolineTanker/GasolineTanker/Properties/Resources.resx
@@ -117,4 +117,17 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ ..\Resources\KeyDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\KeyLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\KeyRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\KeyUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
\ No newline at end of file
diff --git a/GasolineTanker/GasolineTanker/Resources/KeyDown.png b/GasolineTanker/GasolineTanker/Resources/KeyDown.png
new file mode 100644
index 0000000..ff09b70
Binary files /dev/null and b/GasolineTanker/GasolineTanker/Resources/KeyDown.png differ
diff --git a/GasolineTanker/GasolineTanker/Resources/KeyLeft.png b/GasolineTanker/GasolineTanker/Resources/KeyLeft.png
new file mode 100644
index 0000000..b64110a
Binary files /dev/null and b/GasolineTanker/GasolineTanker/Resources/KeyLeft.png differ
diff --git a/GasolineTanker/GasolineTanker/Resources/KeyRight.png b/GasolineTanker/GasolineTanker/Resources/KeyRight.png
new file mode 100644
index 0000000..478e541
Binary files /dev/null and b/GasolineTanker/GasolineTanker/Resources/KeyRight.png differ
diff --git a/GasolineTanker/GasolineTanker/Resources/KeyUp.png b/GasolineTanker/GasolineTanker/Resources/KeyUp.png
new file mode 100644
index 0000000..0e4bf6f
Binary files /dev/null and b/GasolineTanker/GasolineTanker/Resources/KeyUp.png differ