Лабораторная1
This commit is contained in:
parent
1af2084dd6
commit
f8c0112e97
23
ProjectBus/ProjectBus/DirectionType.cs
Normal file
23
ProjectBus/ProjectBus/DirectionType.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
namespace ProjectBus;
|
||||||
|
/// <summary>
|
||||||
|
/// Направление перемещения
|
||||||
|
/// </summary>
|
||||||
|
public enum DirectionType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Вверх
|
||||||
|
/// </summary>
|
||||||
|
Up = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// Вниз
|
||||||
|
/// </summary>
|
||||||
|
Down = 2,
|
||||||
|
/// <summary>
|
||||||
|
/// Влево
|
||||||
|
/// </summary>
|
||||||
|
Left = 3,
|
||||||
|
/// <summary>
|
||||||
|
/// Вправо
|
||||||
|
/// </summary>
|
||||||
|
Right = 4
|
||||||
|
}
|
239
ProjectBus/ProjectBus/DrawningBus.cs
Normal file
239
ProjectBus/ProjectBus/DrawningBus.cs
Normal file
@ -0,0 +1,239 @@
|
|||||||
|
using ProjectBus;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.Security.Cryptography.Xml;
|
||||||
|
|
||||||
|
namespace ProjectBus;
|
||||||
|
/// <summary>
|
||||||
|
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||||||
|
/// </summary>
|
||||||
|
public class DrawningBus
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Класс-сущность
|
||||||
|
/// </summary>
|
||||||
|
public EntityBus? EntityBus { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Ширина окна
|
||||||
|
/// </summary>
|
||||||
|
private int? _pictureWidth;
|
||||||
|
/// <summary>
|
||||||
|
/// Высота окна
|
||||||
|
/// </summary>
|
||||||
|
private int? _pictureHeight;
|
||||||
|
/// <summary>
|
||||||
|
/// Левая координата прорисовки автомобиля
|
||||||
|
/// </summary>
|
||||||
|
private int? _startPosX;
|
||||||
|
/// <summary>
|
||||||
|
/// Верхняя кооридната прорисовки автомобиля
|
||||||
|
/// </summary>
|
||||||
|
private int? _startPosY;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ширина прорисовки крейсера
|
||||||
|
/// </summary>
|
||||||
|
private readonly int _drawningBusWidth = 150;
|
||||||
|
/// <summary>
|
||||||
|
/// Высота прорисовки крейсера
|
||||||
|
/// </summary>
|
||||||
|
private readonly int _drawningBusHeight = 50;
|
||||||
|
private readonly int _drawningEnginesWidth = 3;
|
||||||
|
/// <summary>
|
||||||
|
/// Инициализация свойств
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="speed">Скорость</param>
|
||||||
|
/// <param name="weight">Вес</param>
|
||||||
|
/// <param name="bodyColor">Основной цвет</param>
|
||||||
|
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||||
|
/// <param name="secondFloor">Признак наличия второго этажа</param>
|
||||||
|
/// <param name="ladder">Признак наличия лестнницы</param>
|
||||||
|
/// <param name="headlights">Признак наличия фар</param>
|
||||||
|
public void Init(int speed, double weight, Color bodyColor, Color
|
||||||
|
additionalColor, bool secondFloor, bool ladder, bool headlights)
|
||||||
|
{
|
||||||
|
EntityBus = new EntityBus();
|
||||||
|
EntityBus.Init(speed, weight, bodyColor, additionalColor,
|
||||||
|
secondFloor, ladder, headlights);
|
||||||
|
_pictureWidth = null;
|
||||||
|
_pictureHeight = null;
|
||||||
|
_startPosX = null;
|
||||||
|
_startPosY = null;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Установка границ поля
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="width">Ширина поля</param>
|
||||||
|
/// <param name="height">Высота поля</param>
|
||||||
|
/// <returns>true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах</returns>
|
||||||
|
public bool SetPictureSize(int width, int height)
|
||||||
|
{
|
||||||
|
// TODO проверка, что объект "влезает" в размеры поля
|
||||||
|
// если влезает, сохраняем границы и корректируем позицию объекта,если она была уже установлена
|
||||||
|
|
||||||
|
if (_drawningBusHeight > height || _drawningBusWidth > width)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
|
|
||||||
|
if (_startPosX.HasValue && _startPosY.HasValue)
|
||||||
|
{
|
||||||
|
SetPosition(_startPosX.Value, _startPosY.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Установка позиции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x">Координата X</param>
|
||||||
|
/// <param name="y">Координата Y</param>
|
||||||
|
public void SetPosition(int x, int y)
|
||||||
|
{
|
||||||
|
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x < 0 || x + _drawningBusWidth > _pictureWidth || y < 0 || y + _drawningBusHeight > _pictureHeight)
|
||||||
|
{
|
||||||
|
_startPosX = _pictureWidth - _drawningBusWidth;
|
||||||
|
_startPosY = _pictureHeight - _drawningBusHeight;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_startPosX = x;
|
||||||
|
_startPosY = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Изменение направления перемещения
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="direction">Направление</param>
|
||||||
|
/// <returns>true - перемещене выполнено, false - перемещение невозможно</returns>
|
||||||
|
public bool MoveTransport(DirectionType direction)
|
||||||
|
{
|
||||||
|
if (EntityBus == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
//влево
|
||||||
|
case DirectionType.Left:
|
||||||
|
if (_startPosX.Value - EntityBus.Step - _drawningEnginesWidth > 0)
|
||||||
|
{
|
||||||
|
_startPosX -= (int)EntityBus.Step;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
//вверх
|
||||||
|
case DirectionType.Up:
|
||||||
|
if (_startPosY.Value - EntityBus.Step > 0)
|
||||||
|
{
|
||||||
|
_startPosY -= (int)EntityBus.Step;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
// вправо
|
||||||
|
case DirectionType.Right:
|
||||||
|
//TODO прописать логику сдвига в право
|
||||||
|
if (_startPosX.Value + EntityBus.Step + _drawningBusWidth < _pictureWidth)
|
||||||
|
{
|
||||||
|
_startPosX += (int)EntityBus.Step;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
//вниз
|
||||||
|
case DirectionType.Down:
|
||||||
|
if (_startPosY.Value + EntityBus.Step + _drawningBusHeight < _pictureHeight)
|
||||||
|
{
|
||||||
|
_startPosY += (int)EntityBus.Step;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Прорисовка объекта
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g"></param>
|
||||||
|
public void DrawTransport(Graphics g)
|
||||||
|
{
|
||||||
|
if (EntityBus == null || !_startPosX.HasValue ||
|
||||||
|
!_startPosY.HasValue)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Pen pen = new(EntityBus.BodyColor, 2);
|
||||||
|
Pen pen2 = new(Color.Black, 2);
|
||||||
|
Brush additionalBrush = new SolidBrush(Color.Black);
|
||||||
|
Brush headlightsBrush = new SolidBrush(Color.Yellow);
|
||||||
|
Brush headlightsBrush2 = new SolidBrush(EntityBus.AdditionalColor);
|
||||||
|
Brush secondFloorBrush = new HatchBrush(HatchStyle.ZigZag, EntityBus.AdditionalColor, Color.FromArgb(163, 163, 163));
|
||||||
|
Brush ladderBrush = new SolidBrush(Color.LightBlue);
|
||||||
|
|
||||||
|
//границы круисера
|
||||||
|
g.FillRectangle(secondFloorBrush, _startPosX.Value, _startPosY.Value + 50, 150, 50);
|
||||||
|
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 50, 150, 50);
|
||||||
|
|
||||||
|
g.FillRectangle(headlightsBrush2, _startPosX.Value + 40, _startPosY.Value + 65, 20, 35);
|
||||||
|
g.DrawRectangle(pen, _startPosX.Value + 40, _startPosY.Value + 65, 20, 35);
|
||||||
|
|
||||||
|
g.FillEllipse(additionalBrush, _startPosX.Value + 15, _startPosY.Value + 90, 22, 22);
|
||||||
|
g.FillEllipse(additionalBrush, _startPosX.Value + 110, _startPosY.Value + 90, 22, 22);
|
||||||
|
|
||||||
|
g.FillEllipse(ladderBrush, _startPosX.Value + 130, _startPosY.Value + 55, 20, 30);
|
||||||
|
g.FillEllipse(ladderBrush, _startPosX.Value + 108, _startPosY.Value + 55, 20, 30);
|
||||||
|
g.FillEllipse(ladderBrush, _startPosX.Value + 86, _startPosY.Value + 55, 20, 30);
|
||||||
|
g.FillEllipse(ladderBrush, _startPosX.Value + 64, _startPosY.Value + 55, 20, 30);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (EntityBus.SecondFloor)
|
||||||
|
{
|
||||||
|
g.FillRectangle(secondFloorBrush, _startPosX.Value, _startPosY.Value, 150, 50);
|
||||||
|
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value, 150, 50);
|
||||||
|
g.FillEllipse(ladderBrush, _startPosX.Value + 130, _startPosY.Value + 5, 20, 30);
|
||||||
|
g.FillEllipse(ladderBrush, _startPosX.Value + 105, _startPosY.Value + 5, 20, 30);
|
||||||
|
g.FillEllipse(ladderBrush, _startPosX.Value + 80, _startPosY.Value + 5, 20, 30);
|
||||||
|
g.FillEllipse(ladderBrush, _startPosX.Value + 55, _startPosY.Value + 5, 20, 30);
|
||||||
|
g.FillEllipse(ladderBrush, _startPosX.Value + 30, _startPosY.Value + 5, 20, 30);
|
||||||
|
//g.FillEllipse(ladderBrush, _startPosX.Value + 5, _startPosY.Value + 5, 20, 30);
|
||||||
|
//g.FillEllipse(ladderBrush, _startPosX.Value + -2, _startPosY.Value + 5, 20, 30);
|
||||||
|
|
||||||
|
if (EntityBus.Ladder)
|
||||||
|
{
|
||||||
|
g.FillRectangle(headlightsBrush2, _startPosX.Value, _startPosY.Value + 15, 20, 35);
|
||||||
|
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 15, 20, 35);
|
||||||
|
g.DrawLine(pen2, _startPosX.Value, _startPosY.Value + 50, _startPosX.Value, _startPosY.Value + 100);
|
||||||
|
g.DrawLine(pen2, _startPosX.Value + 20, _startPosY.Value + 50, _startPosX.Value + 20, _startPosY.Value + 100);
|
||||||
|
g.DrawLine(pen2, _startPosX.Value, _startPosY.Value + 60, _startPosX.Value + 20, _startPosY.Value + 60);
|
||||||
|
g.DrawLine(pen2, _startPosX.Value, _startPosY.Value + 70, _startPosX.Value + 20, _startPosY.Value + 70);
|
||||||
|
g.DrawLine(pen2, _startPosX.Value, _startPosY.Value + 80, _startPosX.Value + 20, _startPosY.Value + 80);
|
||||||
|
g.DrawLine(pen2, _startPosX.Value, _startPosY.Value + 90, _startPosX.Value + 20, _startPosY.Value + 90);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g.FillEllipse(ladderBrush, _startPosX.Value + 5, _startPosY.Value + 5, 20, 30);
|
||||||
|
g.FillEllipse(ladderBrush, _startPosX.Value + 5, _startPosY.Value + 55, 20, 30);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g.FillEllipse(ladderBrush, _startPosX.Value + 5, _startPosY.Value + 55, 20, 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (EntityBus.Headlights)
|
||||||
|
{
|
||||||
|
g.FillEllipse(headlightsBrush, _startPosX.Value + 143, _startPosY.Value + 80, 8, 15);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
62
ProjectBus/ProjectBus/EntityBus.cs
Normal file
62
ProjectBus/ProjectBus/EntityBus.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
namespace ProjectBus;
|
||||||
|
/// <summary>
|
||||||
|
/// Класс-сущность "автобус"
|
||||||
|
/// </summary>
|
||||||
|
public class EntityBus
|
||||||
|
{
|
||||||
|
//свойства
|
||||||
|
/// <summary>
|
||||||
|
/// Скорость
|
||||||
|
/// </summary>
|
||||||
|
public int Speed { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Вес
|
||||||
|
/// </summary>
|
||||||
|
public double Weight { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Основной цвет
|
||||||
|
/// </summary>
|
||||||
|
public Color BodyColor { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Дополнительный цвет (для опциональных элементов)
|
||||||
|
/// </summary>
|
||||||
|
public Color AdditionalColor { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Признак (опция) наличие второго этажа
|
||||||
|
/// </summary>
|
||||||
|
public bool SecondFloor { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Признак (опция) наличие лестницы
|
||||||
|
/// </summary>
|
||||||
|
public bool Ladder { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Признак (опция) наличие фар
|
||||||
|
/// </summary>
|
||||||
|
public bool Headlights { get; private set; }
|
||||||
|
//поле класса
|
||||||
|
/// <summary>
|
||||||
|
/// Шаг перемещения автомобиля
|
||||||
|
/// </summary>
|
||||||
|
public double Step => Speed * 100 / Weight;
|
||||||
|
/// <summary>
|
||||||
|
/// Инициализация полей объекта-класса крейсера
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="speed">скорость</param>
|
||||||
|
/// <param name="weight">вес</param>
|
||||||
|
/// <param name="bodyColor">основной цвет</param>
|
||||||
|
/// <param name="additionalColor">дополнительный цвет</param>
|
||||||
|
/// <param name="secondFloor">второй этаж</param>
|
||||||
|
/// <param name="ladder">лестница</param>
|
||||||
|
/// <param name="headlights">наличие фар</param>
|
||||||
|
public void Init(int speed, double weight, Color bodyColor, Color
|
||||||
|
additionalColor, bool secondFloor, bool ladder, bool headlights)
|
||||||
|
{
|
||||||
|
Speed = speed;
|
||||||
|
Weight = weight;
|
||||||
|
BodyColor = bodyColor;
|
||||||
|
AdditionalColor = additionalColor;
|
||||||
|
SecondFloor = secondFloor;
|
||||||
|
Ladder = ladder;
|
||||||
|
Headlights = headlights;
|
||||||
|
}
|
||||||
|
}
|
39
ProjectBus/ProjectBus/Form1.Designer.cs
generated
39
ProjectBus/ProjectBus/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
|||||||
namespace ProjectBus
|
|
||||||
{
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
namespace ProjectBus
|
|
||||||
{
|
|
||||||
public partial class Form1 : Form
|
|
||||||
{
|
|
||||||
public Form1()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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>
|
|
138
ProjectBus/ProjectBus/FormBus.Designer.cs
generated
Normal file
138
ProjectBus/ProjectBus/FormBus.Designer.cs
generated
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
namespace ProjectBus
|
||||||
|
{
|
||||||
|
partial class FormBus
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormBus));
|
||||||
|
pictureBox1 = new PictureBox();
|
||||||
|
button1 = new Button();
|
||||||
|
buttonUp = new Button();
|
||||||
|
buttonDown = new Button();
|
||||||
|
buttonRight = new Button();
|
||||||
|
buttonLeft = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// pictureBox1
|
||||||
|
//
|
||||||
|
pictureBox1.Dock = DockStyle.Fill;
|
||||||
|
pictureBox1.Location = new Point(0, 0);
|
||||||
|
pictureBox1.Name = "pictureBox1";
|
||||||
|
pictureBox1.Size = new Size(800, 450);
|
||||||
|
pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||||
|
pictureBox1.TabIndex = 0;
|
||||||
|
pictureBox1.TabStop = false;
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
button1.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
|
button1.Location = new Point(12, 409);
|
||||||
|
button1.Name = "button1";
|
||||||
|
button1.Size = new Size(94, 29);
|
||||||
|
button1.TabIndex = 1;
|
||||||
|
button1.Text = "создать";
|
||||||
|
button1.UseVisualStyleBackColor = true;
|
||||||
|
button1.Click += ButtonCreateBus_Click;
|
||||||
|
//
|
||||||
|
// buttonUp
|
||||||
|
//
|
||||||
|
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonUp.BackgroundImage = (Image)resources.GetObject("buttonUp.BackgroundImage");
|
||||||
|
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonUp.Location = new Point(722, 373);
|
||||||
|
buttonUp.Name = "buttonUp";
|
||||||
|
buttonUp.Size = new Size(30, 30);
|
||||||
|
buttonUp.TabIndex = 2;
|
||||||
|
buttonUp.UseVisualStyleBackColor = true;
|
||||||
|
buttonUp.Click += ButtonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonDown
|
||||||
|
//
|
||||||
|
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonDown.BackgroundImage = (Image)resources.GetObject("buttonDown.BackgroundImage");
|
||||||
|
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonDown.Location = new Point(722, 409);
|
||||||
|
buttonDown.Name = "buttonDown";
|
||||||
|
buttonDown.Size = new Size(30, 30);
|
||||||
|
buttonDown.TabIndex = 3;
|
||||||
|
buttonDown.UseVisualStyleBackColor = true;
|
||||||
|
buttonDown.Click += ButtonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonRight
|
||||||
|
//
|
||||||
|
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonRight.BackgroundImage = (Image)resources.GetObject("buttonRight.BackgroundImage");
|
||||||
|
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonRight.Location = new Point(758, 409);
|
||||||
|
buttonRight.Name = "buttonRight";
|
||||||
|
buttonRight.Size = new Size(30, 30);
|
||||||
|
buttonRight.TabIndex = 4;
|
||||||
|
buttonRight.UseVisualStyleBackColor = true;
|
||||||
|
buttonRight.Click += ButtonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonLeft
|
||||||
|
//
|
||||||
|
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonLeft.BackgroundImage = (Image)resources.GetObject("buttonLeft.BackgroundImage");
|
||||||
|
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonLeft.Location = new Point(686, 409);
|
||||||
|
buttonLeft.Name = "buttonLeft";
|
||||||
|
buttonLeft.Size = new Size(30, 30);
|
||||||
|
buttonLeft.TabIndex = 5;
|
||||||
|
buttonLeft.UseVisualStyleBackColor = true;
|
||||||
|
buttonLeft.Click += ButtonMove_Click;
|
||||||
|
//
|
||||||
|
// Form1
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(buttonLeft);
|
||||||
|
Controls.Add(buttonRight);
|
||||||
|
Controls.Add(buttonDown);
|
||||||
|
Controls.Add(buttonUp);
|
||||||
|
Controls.Add(button1);
|
||||||
|
Controls.Add(pictureBox1);
|
||||||
|
Name = "Form1";
|
||||||
|
Text = "FormBus";
|
||||||
|
Click += ButtonMove_Click;
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private PictureBox pictureBox1;
|
||||||
|
private Button button1;
|
||||||
|
private Button buttonUp;
|
||||||
|
private Button buttonDown;
|
||||||
|
private Button buttonRight;
|
||||||
|
private Button buttonLeft;
|
||||||
|
}
|
||||||
|
}
|
91
ProjectBus/ProjectBus/FormBus.cs
Normal file
91
ProjectBus/ProjectBus/FormBus.cs
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
namespace ProjectBus
|
||||||
|
{
|
||||||
|
public partial class FormBus : Form
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Поле-объект для прорисовки объекта
|
||||||
|
/// </summary>
|
||||||
|
private DrawningBus? _drawningBus;
|
||||||
|
public FormBus()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Метод прорисовки круисера
|
||||||
|
/// </summary>
|
||||||
|
private void Draw()
|
||||||
|
{
|
||||||
|
if (_drawningBus == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Bitmap bmp = new(pictureBox1.Width,
|
||||||
|
pictureBox1.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_drawningBus.DrawTransport(gr);
|
||||||
|
pictureBox1.Image = bmp;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Обработка нажатия кнопки "Создать"
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonCreateBus_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Random random = new();
|
||||||
|
_drawningBus = new DrawningBus();
|
||||||
|
_drawningBus.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)), Convert.ToBoolean(random.Next(0, 2)));
|
||||||
|
_drawningBus.SetPictureSize(pictureBox1.Width,
|
||||||
|
pictureBox1.Height);
|
||||||
|
|
||||||
|
//начальное положение круисера
|
||||||
|
_drawningBus.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Перемещение объекта по форме (нажатие кнопок навигации)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_drawningBus == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||||
|
bool result = false;
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case "buttonUp":
|
||||||
|
result =
|
||||||
|
_drawningBus.MoveTransport(DirectionType.Up);
|
||||||
|
break;
|
||||||
|
case "buttonDown":
|
||||||
|
result =
|
||||||
|
_drawningBus.MoveTransport(DirectionType.Down);
|
||||||
|
break;
|
||||||
|
case "buttonLeft":
|
||||||
|
result =
|
||||||
|
_drawningBus.MoveTransport(DirectionType.Left);
|
||||||
|
break;
|
||||||
|
case "buttonRight":
|
||||||
|
result =
|
||||||
|
_drawningBus.MoveTransport(DirectionType.Right);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1540
ProjectBus/ProjectBus/FormBus.resx
Normal file
1540
ProjectBus/ProjectBus/FormBus.resx
Normal file
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,7 @@ namespace ProjectBus
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new Form1());
|
Application.Run(new FormBus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user