Compare commits

..

1 Commits

Author SHA1 Message Date
Daniel
6d79ecf407 Первая лаба готова 2022-11-13 20:39:23 +04:00
15 changed files with 866 additions and 0 deletions

18
WinFormsApp1/Direction.cs Normal file
View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WinFormsApp1
{
internal enum Direction
{
Up = 1,
Down = 2,
Left = 3,
Right = 4,
DRDiagonal = 5,
DLDiagonal = 6,
ULDiagonal = 7,
URDiagonal = 8
}
}

View File

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Drawing;
namespace WinFormsApp1
{
class EntityTractor
{
/// <summary>
/// Скорость
/// </summary>
public int Speed { get; private set; }
/// <summary>
/// Вес
/// </summary>
public float Weight { get; private set; }
/// <summary>
/// Цвет кузова
/// </summary>
public Color BodyColor { get; private set; }
/// <summary>
/// Шаг перемещения автомобиля
/// </summary>
public float Step => Speed * 100 / Weight;
/// <summary>
/// Инициализация полей объекта-класса автомобиля
/// </summary>
/// <param name="speed"></param>
/// <param name="weight"></param>
/// <param name="bodyColor"></param>
/// <returns></returns>
public void Init(int speed, float weight, Color bodyColor)
{
Random rnd = new Random();
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
BodyColor = bodyColor;
}
}
}

184
WinFormsApp1/FormTractor.Designer.cs generated Normal file
View File

@ -0,0 +1,184 @@

namespace WinFormsApp1
{
partial class FormTractor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pictureBoxTractor = new System.Windows.Forms.PictureBox();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
this.buttonCreate = new System.Windows.Forms.Button();
this.buttonUp = new System.Windows.Forms.Button();
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTractor)).BeginInit();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// pictureBoxTractor
//
this.pictureBoxTractor.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxTractor.Location = new System.Drawing.Point(0, 0);
this.pictureBoxTractor.Name = "pictureBoxTractor";
this.pictureBoxTractor.Size = new System.Drawing.Size(800, 424);
this.pictureBoxTractor.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBoxTractor.TabIndex = 0;
this.pictureBoxTractor.TabStop = false;
this.pictureBoxTractor.Resize += new System.EventHandler(this.pictureBoxTractor_Resize);
//
// statusStrip1
//
this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabelSpeed,
this.toolStripStatusLabelWeight,
this.toolStripStatusLabelBodyColor});
this.statusStrip1.Location = new System.Drawing.Point(0, 424);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(800, 26);
this.statusStrip1.TabIndex = 1;
this.statusStrip1.Text = "statusStrip1";
//
// toolStripStatusLabelSpeed
//
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(73, 20);
this.toolStripStatusLabelSpeed.Text = "Скорость";
//
// toolStripStatusLabelWeight
//
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(32, 20);
this.toolStripStatusLabelWeight.Text = "вес";
//
// toolStripStatusLabelBodyColor
//
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(42, 20);
this.toolStripStatusLabelBodyColor.Text = "Цвет";
this.toolStripStatusLabelBodyColor.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(0, 378);
this.buttonCreate.Name = "buttonCreate";
this.buttonCreate.Size = new System.Drawing.Size(94, 29);
this.buttonCreate.TabIndex = 2;
this.buttonCreate.Text = "создать";
this.buttonCreate.UseVisualStyleBackColor = true;
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
//
// buttonUp
//
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUp.BackgroundImage = global::Tractors.Properties.Resources._2EdzyM4iEKw;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonUp.Location = new System.Drawing.Point(682, 296);
this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(30, 30);
this.buttonUp.TabIndex = 3;
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::Tractors.Properties.Resources.Hhxt4dLqV5g;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonLeft.Location = new System.Drawing.Point(649, 332);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
this.buttonLeft.TabIndex = 4;
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.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::Tractors.Properties.Resources.MbV2DYU_nPM;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonDown.Location = new System.Drawing.Point(682, 332);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(30, 30);
this.buttonDown.TabIndex = 5;
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.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::Tractors.Properties.Resources.RkYIe2_6DuQ;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonRight.Location = new System.Drawing.Point(718, 332);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(30, 30);
this.buttonRight.TabIndex = 6;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
//
// FormTractor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.pictureBoxTractor);
this.Controls.Add(this.statusStrip1);
this.Name = "FormTractor";
this.Text = "Трактор";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTractor)).EndInit();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.PictureBox pictureBoxTractor;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSpeed;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelWeight;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelBodyColor;
private System.Windows.Forms.Button buttonCreate;
private System.Windows.Forms.Button buttonUp;
private System.Windows.Forms.Button buttonLeft;
private System.Windows.Forms.Button buttonDown;
private System.Windows.Forms.Button buttonRight;
}
}

View File

@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WinFormsApp1
{
public partial class FormTractor : Form
{
private TractorDraw _Tractor;
public FormTractor()
{
InitializeComponent();
}
private void Draw()
{
Bitmap bmp = new Bitmap(pictureBoxTractor.Width, pictureBoxTractor.Height);
Graphics gr = Graphics.FromImage(bmp);
_Tractor?.DrawEntity(gr);
pictureBoxTractor.Image = bmp;
}
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random random = new Random();
_Tractor = new TractorDraw();
_Tractor.Init(random.Next(100, 200), random.Next(2500, 5000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
_Tractor.SetPosition(random.Next(10, 50), random.Next(10, 50), pictureBoxTractor.Width, pictureBoxTractor.Height);
toolStripStatusLabelSpeed.Text = $"Скорость: {_Tractor.Tractor.Speed}";
toolStripStatusLabelWeight.Text = $"Вес: {_Tractor.Tractor.Weight}";
toolStripStatusLabelBodyColor.Text = $"Цвет: {_Tractor.Tractor.BodyColor.Name}";
Draw();
}
private void ButtonMove_Click(object sender, EventArgs e)
{
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "buttonUp":
_Tractor?.MoveTransport(Direction.Up);
break;
case "buttonDown":
_Tractor?.MoveTransport(Direction.Down);
break;
case "buttonLeft":
_Tractor?.MoveTransport(Direction.Left);
break;
case "buttonRight":
_Tractor?.MoveTransport(Direction.Right);
break;
}
Draw();
}
private void pictureBoxTractor_Resize(object sender, EventArgs e)
{
_Tractor?.ChangeBorders(pictureBoxTractor.Width, pictureBoxTractor.Height);
Draw();
}
}
}

View File

@ -0,0 +1,63 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<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>
</root>

23
WinFormsApp1/Program.cs Normal file
View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WinFormsApp1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormTractor());
}
}
}

View File

@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Tractors.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.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() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[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("Tractors.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap _2EdzyM4iEKw {
get {
object obj = ResourceManager.GetObject("2EdzyM4iEKw", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Hhxt4dLqV5g {
get {
object obj = ResourceManager.GetObject("Hhxt4dLqV5g", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap MbV2DYU_nPM {
get {
object obj = ResourceManager.GetObject("MbV2DYU_nPM", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap RkYIe2_6DuQ {
get {
object obj = ResourceManager.GetObject("RkYIe2_6DuQ", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="2EdzyM4iEKw" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\2EdzyM4iEKw.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="RkYIe2_6DuQ" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\RkYIe2_6DuQ.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="MbV2DYU_nPM" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\MbV2DYU_nPM.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Hhxt4dLqV5g" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Hhxt4dLqV5g.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

25
WinFormsApp1/Tractor.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31624.102
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tractors", "Tractors.csproj", "{735086BF-1E22-40C3-B173-CBAE6E9F5A81}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{735086BF-1E22-40C3-B173-CBAE6E9F5A81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{735086BF-1E22-40C3-B173-CBAE6E9F5A81}.Debug|Any CPU.Build.0 = Debug|Any CPU
{735086BF-1E22-40C3-B173-CBAE6E9F5A81}.Release|Any CPU.ActiveCfg = Release|Any CPU
{735086BF-1E22-40C3-B173-CBAE6E9F5A81}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {773D5658-5E81-42A9-AD57-BBD613BEBDC0}
EndGlobalSection
EndGlobal

175
WinFormsApp1/TractorDraw.cs Normal file
View File

@ -0,0 +1,175 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Drawing;
namespace WinFormsApp1
{
class TractorDraw
{
//Сущность
public EntityTractor Tractor { get; private set; }
/// Левая координата отрисовки сущности
private float startPosX;
/// Верхняя кооридната отрисовки сущности
private float startPosY;
/// Ширина окна отрисовки
private int? pictureWidth = null;
/// Высота окна отрисовки
private int? pictureHeight = null;
/// Ширина отрисовки сущности
private readonly int entWidth = 130;
/// Высота отрисовки сущности
private readonly int entHeight = 100;
public void Init(int speed, float weight, Color bodycolor)
{
Tractor = new EntityTractor();
Tractor.Init(speed, weight, bodycolor);
}
//Установка позиции сущности
public void SetPosition(int x, int y, int width, int height)
{
if (x < 0 || y < 0 || width < x + entWidth || height < y + entHeight)
{
pictureHeight = null;
pictureWidth = null;
return;
}
startPosX = x;
startPosY = y;
pictureHeight = height;
pictureWidth = width;
}
//Изменение направления перемещения
public void MoveTransport(Direction direction)
{
if (!pictureWidth.HasValue || !pictureHeight.HasValue)
{
return;
}
switch (direction)
{
case Direction.Right:
if (startPosX + entWidth + Tractor.Step < pictureWidth)
{
startPosX += Tractor.Step;
}
break;
case Direction.Left:
if (startPosX - 10 - Tractor.Step > 0)
{
startPosX -= Tractor.Step;
}
break;
case Direction.Down:
if (startPosY + entHeight + Tractor.Step < pictureHeight)
{
startPosY += Tractor.Step;
}
break;
case Direction.Up:
if (startPosY - Tractor.Step > 0)
{
startPosY -= Tractor.Step;
}
break;
case Direction.DRDiagonal:
if (startPosX + entWidth + Tractor.Step < pictureWidth && startPosY + entHeight + Tractor.Step < pictureHeight)
{
startPosX += Tractor.Step;
startPosY += Tractor.Step;
}
break;
case Direction.DLDiagonal:
if (startPosY + entHeight + Tractor.Step < pictureHeight && startPosX - 10 - Tractor.Step > 0)
{
startPosY += Tractor.Step;
startPosX -= Tractor.Step;
}
break;
case Direction.URDiagonal:
if (startPosY - Tractor.Step > 0 && startPosX + entWidth + Tractor.Step < pictureWidth)
{
startPosY -= Tractor.Step;
startPosX += Tractor.Step;
}
break;
case Direction.ULDiagonal:
if (startPosY - Tractor.Step > 0 && startPosX - 10 - Tractor.Step > 0)
{
startPosY -= Tractor.Step;
startPosX -= Tractor.Step;
}
break;
}
}
//Отрисовка сущности
public void DrawEntity(Graphics g)
{
if (startPosX < 0 || startPosY < 0 || !pictureHeight.HasValue || !pictureWidth.HasValue)
{
return;
}
Pen pen_Black_1pxl = new Pen(Color.Black, 1);
Pen pen_Black_2pxl = new Pen(Color.Black, 2);
g.DrawRectangle(pen_Black_1pxl, startPosX, startPosY, 40, 30);
g.DrawRectangle(pen_Black_1pxl, startPosX, startPosY + 30, 100, 35);
g.DrawRectangle(pen_Black_1pxl, startPosX + 72, startPosY + 10, 5, 20);
g.DrawEllipse(pen_Black_1pxl, startPosX - 15, startPosY + 67, 30, 30);
g.DrawEllipse(pen_Black_1pxl, startPosX + 85, startPosY + 67, 30, 30);
g.DrawEllipse(pen_Black_1pxl, startPosX + 20, startPosY + 82, 15, 15);
g.DrawEllipse(pen_Black_1pxl, startPosX + 40, startPosY + 82, 15, 15);
g.DrawEllipse(pen_Black_1pxl, startPosX + 60, startPosY + 82, 15, 15);
g.DrawEllipse(pen_Black_1pxl, startPosX + 35, startPosY + 68, 10, 10);
g.DrawEllipse(pen_Black_1pxl, startPosX + 55, startPosY + 68, 10, 10);
g.DrawLine(pen_Black_2pxl, startPosX, startPosY + 67, startPosX + 100, startPosY + 67);
g.DrawLine(pen_Black_2pxl, startPosX, startPosY + 97, startPosX + 100, startPosY + 97);
Brush br = new SolidBrush(Tractor?.BodyColor ?? Color.Black);
g.FillRectangle(br, startPosX, startPosY, 40, 30);
g.FillRectangle(br, startPosX, startPosY + 30, 100, 35);
Brush brBlack = new SolidBrush(Color.Black);
g.FillRectangle(brBlack, startPosX + 72, startPosY + 10, 5, 20);
g.FillEllipse(brBlack, startPosX - 15, startPosY + 67, 30, 30);
g.FillEllipse(brBlack, startPosX + 85, startPosY + 67, 30, 30);
g.FillEllipse(brBlack, startPosX + 20, startPosY + 82, 15, 15);
g.FillEllipse(brBlack, startPosX + 40, startPosY + 82, 15, 15);
g.FillEllipse(brBlack, startPosX + 60, startPosY + 82, 15, 15);
g.FillEllipse(brBlack, startPosX + 35, startPosY + 68, 10, 10);
g.FillEllipse(brBlack, startPosX + 55, startPosY + 68, 10, 10);
}
//Смена границ формы
public void ChangeBorders(int width, int height)
{
pictureWidth = width;
pictureHeight = height;
if (pictureWidth <= entWidth || pictureHeight <= entHeight)
{
pictureWidth = null;
pictureHeight = null;
return;
}
if (startPosX + entWidth > pictureWidth)
{
startPosX = pictureWidth.Value - entWidth;
}
if (startPosY + entHeight > pictureHeight)
{
startPosY = pictureHeight.Value - entHeight;
}
}
}
}

View File

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</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>