Laba_1_100%

This commit is contained in:
gavrilov 2023-09-23 18:11:44 +04:00
parent 4ed2f2ff4e
commit 5f98a27ad4
9 changed files with 24 additions and 194 deletions

View File

@ -24,6 +24,5 @@ namespace DumpTruck
/// Вправо /// Вправо
/// </summary> /// </summary>
Right = 4 Right = 4
} }
} }

View File

@ -31,11 +31,11 @@ namespace DumpTruck
/// <summary> /// <summary>
/// Ширина прорисовки автомобиля /// Ширина прорисовки автомобиля
/// </summary> /// </summary>
// private readonly int _DumpTruckWidth = 200; private readonly int _DumpTruckWidth = 110;
/// <summary> /// <summary>
/// Высота прорисовки автомобиля /// Высота прорисовки автомобиля
/// </summary> /// </summary>
// private readonly int _DumpTruckHeight = 150; private readonly int _DumpTruckHeight = 85;
/// <summary> /// <summary>
/// Инициализация свойств /// Инициализация свойств
/// </summary> /// </summary>
@ -51,6 +51,10 @@ namespace DumpTruck
{ {
_pictureWidth = width; _pictureWidth = width;
_pictureHeight = height; _pictureHeight = height;
if ((_pictureHeight < _DumpTruckHeight) || (_pictureWidth < _DumpTruckWidth))
{
return false;
}
DumpTruck = new DumpTruck(); DumpTruck = new DumpTruck();
DumpTruck.Init(speed, weight, bodyColor, additionalColor, DumpTruck.Init(speed, weight, bodyColor, additionalColor,
body, trailer); body, trailer);
@ -63,10 +67,17 @@ namespace DumpTruck
/// <param name="y">Координата Y</param> /// <param name="y">Координата Y</param>
public void SetPosition(int x, int y) public void SetPosition(int x, int y)
{ {
// TODO: Изменение x, y if ((x < 0 || y < 0) || (x + _DumpTruckWidth > _pictureWidth || y + _DumpTruckHeight > _pictureHeight))
{
_startPosX = 0;
_startPosY = 0;
}
else
{
_startPosX = x; _startPosX = x;
_startPosY = y; _startPosY = y;
} }
}
/// <summary> /// <summary>
/// Изменение направления перемещения /// Изменение направления перемещения
/// </summary> /// </summary>
@ -95,14 +106,14 @@ namespace DumpTruck
break; break;
// вправо // вправо
case DirectionType.Right: case DirectionType.Right:
if (_startPosX + _pictureWidth + DumpTruck.Step > FormDumpTruck.ActiveForm.ClientSize.Width) if (_startPosX + _DumpTruckWidth + DumpTruck.Step < _pictureWidth)
{ {
_startPosX += (int)DumpTruck.Step; _startPosX += (int)DumpTruck.Step;
} }
break; break;
//вниз //вниз
case DirectionType.Down: case DirectionType.Down:
if (_startPosX + _pictureHeight + DumpTruck.Step > FormDumpTruck.ActiveForm.ClientSize.Height) if (_startPosY + _DumpTruckHeight + DumpTruck.Step < _pictureHeight)
{ {
_startPosY += (int)DumpTruck.Step; _startPosY += (int)DumpTruck.Step;
} }
@ -117,7 +128,6 @@ namespace DumpTruck
} }
Pen pen = new(Color.Black); Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(DumpTruck.AdditionalColor); Brush additionalBrush = new SolidBrush(DumpTruck.AdditionalColor);
//грани //грани
g.DrawRectangle(pen, _startPosX + 80, _startPosY, 30, 40); g.DrawRectangle(pen, _startPosX + 80, _startPosY, 30, 40);
g.DrawRectangle(pen, _startPosX, _startPosY + 40, 110, 20); g.DrawRectangle(pen, _startPosX, _startPosY + 40, 110, 20);
@ -126,21 +136,19 @@ namespace DumpTruck
g.FillRectangle(br, _startPosX + 81, _startPosY + 1, 29, 40); g.FillRectangle(br, _startPosX + 81, _startPosY + 1, 29, 40);
Brush br1 = new SolidBrush(DumpTruck.AdditionalColor); Brush br1 = new SolidBrush(DumpTruck.AdditionalColor);
g.FillRectangle(br1, _startPosX + 1, _startPosY + 41, 109, 19); g.FillRectangle(br1, _startPosX + 1, _startPosY + 41, 109, 19);
//колеса
Brush wheels = new SolidBrush(Color.Black); Brush wheels = new SolidBrush(Color.Black);
g.FillEllipse(wheels, _startPosX, _startPosY + 63, 25, 25); g.FillEllipse(wheels, _startPosX, _startPosY + 63, 25, 25);
g.FillEllipse(wheels, _startPosX + 25, _startPosY + 63, 25, 25); g.FillEllipse(wheels, _startPosX + 25, _startPosY + 63, 25, 25);
g.FillEllipse(wheels, _startPosX + 85, _startPosY + 63, 25, 25); g.FillEllipse(wheels, _startPosX + 85, _startPosY + 63, 25, 25);
if (DumpTruck.Trailer) if (DumpTruck.Trailer)
{ {
//прицеп
Brush trailer = new SolidBrush(Color.Black); Brush trailer = new SolidBrush(Color.Black);
g.FillRectangle(trailer, _startPosX, _startPosY, 5, 38); g.FillRectangle(trailer, _startPosX, _startPosY, 5, 38);
g.FillRectangle(trailer, _startPosX + 5, _startPosY + 33, 70, 5); g.FillRectangle(trailer, _startPosX + 5, _startPosY + 33, 70, 5);
g.FillRectangle(trailer, _startPosX + 70, _startPosY, 5, 38); g.FillRectangle(trailer, _startPosX + 70, _startPosY, 5, 38);
}
}
} }
} }
} }

View File

@ -53,6 +53,5 @@ namespace DumpTruck
Body = body; Body = body;
Trailer = trailer; Trailer = trailer;
} }
} }
} }

View File

@ -1,39 +0,0 @@
namespace DumpTruck
{
partial class Form1
{
/// <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.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace DumpTruck
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -1,120 +0,0 @@
<?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>
</root>

View File

@ -19,7 +19,6 @@
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
#region Windows Form Designer generated code #region Windows Form Designer generated code
/// <summary> /// <summary>
@ -46,7 +45,6 @@
this.pictureBoxDumpTruck.Size = new System.Drawing.Size(800, 450); this.pictureBoxDumpTruck.Size = new System.Drawing.Size(800, 450);
this.pictureBoxDumpTruck.TabIndex = 0; this.pictureBoxDumpTruck.TabIndex = 0;
this.pictureBoxDumpTruck.TabStop = false; this.pictureBoxDumpTruck.TabStop = false;
this.pictureBoxDumpTruck.Click += new System.EventHandler(this.ButtonMove_Click);
// //
// Button_Create // Button_Create
// //
@ -120,7 +118,6 @@
this.Controls.Add(this.pictureBoxDumpTruck); this.Controls.Add(this.pictureBoxDumpTruck);
this.Name = "FormDumpTruck"; this.Name = "FormDumpTruck";
this.Text = "FormDumpTruck"; this.Text = "FormDumpTruck";
this.Load += new System.EventHandler(this.FormDumpTruck_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxDumpTruck)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxDumpTruck)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);

View File

@ -70,9 +70,5 @@ namespace DumpTruck
} }
Draw(); Draw();
} }
private void FormDumpTruck_Load(object sender, EventArgs e)
{
}
} }
} }

View File

@ -61,7 +61,7 @@
<data name="buttonUp.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="buttonUp.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAA4QAAAOEBAMAAAALYOIIAAAABGdBTUEAALGPC/xhBQAAABJQTFRF5ubm iVBORw0KGgoAAAANSUhEUgAAA4QAAAOEBAMAAAALYOIIAAAABGdBTUEAALGPC/xhBQAAABJQTFRF5ubm
AQEB////AAAAa2trubm55kNtzgAAAAlwSFlzAAAOwQAADsEBuJFr7QAAGRlJREFUeNrt3Vt26jy2huHg AQEB////AAAAa2trubm55kNtzgAAAAlwSFlzAAAOwAAADsABataJCQAAGRlJREFUeNrt3Vt26jy2huHg
dCDC1QCTsu+jobUaALQgofrflkIHOySLEA4+aE69vvH49kX9yM/WXIEpyU/pql7jRZQaeRziI49DfORx dCDC1QCTsu+jobUaALQgofrflkIHOySLEA4+aE69vvH49kX9yM/WXIEpyU/pql7jRZQaeRziI49DfORx
iI88DvGRxyE+8jjERx6H+MjjEB95HOIjj0N85HGIjzwO8ZHHIT7yOATHdG/S/50oLvI4xEfVI6z+10Ao iI88DvGRxyE+8jjERx6H+MjjEB95HOIjj0N85HGIjzwO8ZHHIT7yOATHdG/S/50oLvI4xEfVI6z+10Ao
Ozb1B4SyY2teGgglx+q9/gOh6FgZaz8glBxbU7s1hILjsY66YyXVO8AntUPq47GOumMl1TvAJ7VD6mNn Ozb1B4SyY2teGgglx+q9/gOh6FgZaz8glBxbU7s1hILjsY66YyXVO8AntUPq47GOumMl1TvAJ7VD6mNn
@ -175,7 +175,7 @@
<data name="buttonLeft.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="buttonLeft.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAA4QAAAOEBAMAAAALYOIIAAAABGdBTUEAALGPC/xhBQAAABJQTFRF5ubm iVBORw0KGgoAAAANSUhEUgAAA4QAAAOEBAMAAAALYOIIAAAABGdBTUEAALGPC/xhBQAAABJQTFRF5ubm
AQEB////AAAAa2trubm55kNtzgAAAAlwSFlzAAAOvwAADr8BOAVTJAAAFy1JREFUeNrtnV2S6ka2RkFB AQEB////AAAAa2trubm55kNtzgAAAAlwSFlzAAAOvgAADr4B6kKxwAAAFy1JREFUeNrtnV2S6ka2RkFB
v7ese98VCmkA6hwBlzsB4tjzn0qTPxLC5lBCKH++qsVDVy932yf5VmxD1lbmPnT+1R78C5RD4pBH4pBH v7ese98VCmkA6hwBlzsB4tjzn0qTPxLC5lBCKH++qsVDVy932yf5VmxD1lbmPnT+1R78C5RD4pBH4pBH
4pBH4pBH4pBH4pBH4pBH4pBH4pBH4pBH4pBH4pBH4pBH4pDH6VWFvw6qInHII3HII3HII3HII3HII3HI 4pBH4pBH4pBH4pBH4pBH4pBH4pBH4pBH4pBH4pBH4pBH4pDH6VWFvw6qInHII3HII3HII3HII3HII3HI
I3HII3HII3HII3HII3HII3HII3HII3EIY/hJ700WiUMeiUMeiUMeiUMeiUMeiUMeiUMeiUMeiUMeiUMe I3HII3HII3HII3HII3HII3HII3HII3EIY/hJ700WiUMeiUMeiUMeiUMeiUMeiUMeiUMeiUMeiUMeiUMe
@ -280,7 +280,7 @@
<data name="buttonRight.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="buttonRight.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAA4QAAAOEBAMAAAALYOIIAAAABGdBTUEAALGPC/xhBQAAABJQTFRF5ubm iVBORw0KGgoAAAANSUhEUgAAA4QAAAOEBAMAAAALYOIIAAAABGdBTUEAALGPC/xhBQAAABJQTFRF5ubm
AQEB////AAAAa2trubm55kNtzgAAAAlwSFlzAAAOwQAADsEBuJFr7QAAFlpJREFUeNrtndFy47h2RT36 AQEB////AAAAa2trubm55kNtzgAAAAlwSFlzAAAOwAAADsABataJCQAAFlpJREFUeNrtndFy47h2RT36
ArNov8tKfgAF3XdHlfueuCr//ysRQJCy3W7LkkUSC1p80aypm+45e+W0dRoE8LAbnu3D8Ig4NA48Ggce ArNov8tKfgAF3XdHlfueuCr//ysRQJCy3W7LkkUSC1p80aypm+45e+W0dRoE8LAbnu3D8Ig4NA48Ggce
jQOPxoFH48CjceDROPBoHHg0DjwaBx6NA4/GgUfjwKNx4HF8NuXfi1Q0DjwaBx6NA4/GgUfjwKNx4NE4 jQOPxoFH48CjceDROPBoHHg0DjwaBx6NA4/GgUfjwKNx4HF8NuXfi1Q0DjwaBx6NA4/GgUfjwKNx4NE4
8GgceDQOPBoHHo0Dj8aBR+PAo3GAsXy69oZF48CjceDROPBoHHg0DjwaBx6NA4/GgUfjwKNx4NE48Ggc 8GgceDQOPBoHHo0Dj8aBR+PAo3GAsXy69oZF48CjceDROPBoHHg0DjwaBx6NA4/GgUfjwKNx4NE48Ggc
@ -382,7 +382,7 @@
<data name="buttonDown.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="buttonDown.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAA4QAAAOEBAMAAAALYOIIAAAABGdBTUEAALGPC/xhBQAAABJQTFRF5ubm iVBORw0KGgoAAAANSUhEUgAAA4QAAAOEBAMAAAALYOIIAAAABGdBTUEAALGPC/xhBQAAABJQTFRF5ubm
AQEB////AAAAa2trubm55kNtzgAAAAlwSFlzAAAOwQAADsEBuJFr7QAAGBNJREFUeNrt3V9y+r7Vx3Fj AQEB////AAAAa2trubm55kNtzgAAAAlwSFlzAAAOwAAADsABataJCQAAGBNJREFUeNrt3V9y+r7Vx3Fj
NoARuTeacB9VYQGPM92A2f9eimTZSb5PSAD/05Hens7QTy/6i/WqjqFHkotwlbq7oosf1fWy3WWq7lo+ NoARuTeacB9VYQGPM92A2f9eimTZSb5PSAD/05Hens7QTy/6i/WqjqFHkotwlbq7oosf1fWy3WWq7lo+
WvsW4+B8jRBCmDahglA6oYUQQgghhBBCCCGEEEIIIRwT+V0IIYQQQjg2KgilE1bqJV7C8FmH/zy2WH5c WvsW4+B8jRBCmDahglA6oYUQQgghhBBCCCGEEEIIIRwT+V0IIYQQQjg2KgilE1bqJV7C8FmH/zy2WH5c
i5gNI6rCkK4Qq5e6iHSsIIQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGE8K+oIJROaM/xEoaLfuGvka49 i5gNI6rCkK4Qq5e6iHSsIIQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGE8K+oIJROaM/xEoaLfuGvka49