Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
af92c80989 | |||
02f8cc514d |
28
TrolleybusProject/TrolleybusProject/DirectionType.cs
Normal file
28
TrolleybusProject/TrolleybusProject/DirectionType.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TrolleybusProject;
|
||||
|
||||
public enum DirectionType
|
||||
{
|
||||
/// <summary>
|
||||
/// Вверх
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
/// <summary>
|
||||
/// Вниз
|
||||
/// </summary>
|
||||
Down = 2,
|
||||
/// <summary>
|
||||
/// Влево
|
||||
/// </summary>
|
||||
Left = 3,
|
||||
/// <summary>
|
||||
/// Вправо
|
||||
/// </summary>
|
||||
Right = 4
|
||||
|
||||
}
|
345
TrolleybusProject/TrolleybusProject/DrawningTrolleybus.cs
Normal file
345
TrolleybusProject/TrolleybusProject/DrawningTrolleybus.cs
Normal file
@ -0,0 +1,345 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TrolleybusProject;
|
||||
|
||||
public class DrawningTrolleybus
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public EntityTrolleybus? EntityTrolleybus { 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>
|
||||
public readonly int _drawningTrolleybusWidth = 150;
|
||||
/// <summary>
|
||||
/// Высота прорисовки троллейбуса
|
||||
/// </summary>
|
||||
public readonly int _drawningTrolleybusHeight = 86;
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="roga">Признак наличия рогов</param>
|
||||
/// <param name="doors">Признак наличия дверей</param>
|
||||
/// <param name="otsek">Признак наличия отсека</param>
|
||||
public void Init(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool doors, bool roga, bool otsek)
|
||||
{
|
||||
EntityTrolleybus = new EntityTrolleybus();
|
||||
EntityTrolleybus.Init(speed, weight, bodyColor, additionalColor,
|
||||
doors, roga, otsek);
|
||||
_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)
|
||||
{
|
||||
if (width> _drawningTrolleybusWidth || height > _drawningTrolleybusHeight)
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
|
||||
|
||||
|
||||
if (_startPosY.HasValue && _startPosX.HasValue)
|
||||
{
|
||||
if (_startPosX + _drawningTrolleybusWidth > width)
|
||||
{
|
||||
|
||||
_startPosX = width - _drawningTrolleybusWidth;
|
||||
|
||||
|
||||
}
|
||||
if (_startPosY + _drawningTrolleybusHeight > height)
|
||||
{
|
||||
|
||||
_startPosY = height - _drawningTrolleybusHeight;
|
||||
|
||||
|
||||
}
|
||||
if (_startPosX < 0)
|
||||
{
|
||||
_startPosX = 0;
|
||||
}
|
||||
if (_startPosY < 0)
|
||||
{
|
||||
_startPosY = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
/// <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;
|
||||
}
|
||||
|
||||
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
|
||||
|
||||
|
||||
if (_startPosX < 0)
|
||||
{ _startPosX = 0; }
|
||||
if (_startPosY < 0)
|
||||
{ _startPosY = 0; }
|
||||
|
||||
if (x + _drawningTrolleybusWidth > _pictureWidth)
|
||||
{
|
||||
|
||||
_startPosX = _pictureWidth - _drawningTrolleybusWidth;
|
||||
|
||||
|
||||
}
|
||||
if (y + _drawningTrolleybusHeight > _pictureHeight)
|
||||
{
|
||||
|
||||
_startPosY = _pictureHeight - _drawningTrolleybusHeight;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение направления перемещения
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
/// <returns>true - перемещене выполнено, false - перемещение невозможно</returns>
|
||||
public bool MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (EntityTrolleybus == null || !_startPosX.HasValue ||
|
||||
!_startPosY.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
//влево
|
||||
case DirectionType.Left:
|
||||
if (_startPosX.Value - EntityTrolleybus.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityTrolleybus.Step;
|
||||
}
|
||||
return true;
|
||||
//вверх
|
||||
case DirectionType.Up:
|
||||
if (_startPosY.Value - EntityTrolleybus.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityTrolleybus.Step;
|
||||
}
|
||||
return true;
|
||||
// вправо
|
||||
case DirectionType.Right:
|
||||
if (_startPosX.Value + EntityTrolleybus.Step < _pictureWidth - _drawningTrolleybusWidth)
|
||||
{
|
||||
_startPosX += (int)EntityTrolleybus.Step;
|
||||
}
|
||||
return true;
|
||||
|
||||
//вниз
|
||||
case DirectionType.Down:
|
||||
if (_startPosY.Value + EntityTrolleybus.Step < _pictureHeight - _drawningTrolleybusHeight)
|
||||
{
|
||||
_startPosY += (int)EntityTrolleybus.Step;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Прорисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityTrolleybus == null || !_startPosX.HasValue ||
|
||||
!_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new
|
||||
SolidBrush(EntityTrolleybus.AdditionalColor);
|
||||
Brush brushBodyColor = new SolidBrush(EntityTrolleybus.BodyColor);
|
||||
Pen addpen = new(EntityTrolleybus.AdditionalColor);
|
||||
//троллейбус границы
|
||||
g.DrawEllipse(pen, _startPosX.Value + 27, _startPosY.Value +
|
||||
64, 20, 20);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 109, _startPosY.Value +
|
||||
64, 20, 20);
|
||||
|
||||
|
||||
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value +
|
||||
30, 140, 41);
|
||||
|
||||
|
||||
//троллейбус
|
||||
g.FillRectangle(brushBodyColor, _startPosX.Value + 10, _startPosY.Value +
|
||||
30, 140, 41);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value +
|
||||
30, 140, 41);
|
||||
|
||||
|
||||
|
||||
|
||||
//дверь
|
||||
g.DrawRectangle(pen, _startPosX.Value + 57, _startPosY.Value +
|
||||
40, 24, 31);
|
||||
|
||||
|
||||
//окна
|
||||
|
||||
Brush brBlue = new SolidBrush(Color.LightBlue);
|
||||
|
||||
g.FillEllipse(brBlue, _startPosX.Value + 13, _startPosY.Value +
|
||||
34, 15, 20);
|
||||
|
||||
g.FillEllipse(brBlue, _startPosX.Value + 38, _startPosY.Value +
|
||||
34, 15, 20);
|
||||
|
||||
|
||||
g.FillEllipse(brBlue, _startPosX.Value + 85, _startPosY.Value +
|
||||
34, 15, 20);
|
||||
g.FillEllipse(brBlue, _startPosX.Value + 102, _startPosY.Value +
|
||||
34, 15, 20);
|
||||
g.FillEllipse(brBlue, _startPosX.Value + 118, _startPosY.Value +
|
||||
34, 15, 20);
|
||||
g.FillEllipse(brBlue, _startPosX.Value + 134, _startPosY.Value +
|
||||
34, 15, 20);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
g.DrawEllipse(pen, _startPosX.Value + 13, _startPosY.Value +
|
||||
34, 15, 20);
|
||||
|
||||
g.DrawEllipse(pen, _startPosX.Value + 38, _startPosY.Value +
|
||||
34, 15, 20);
|
||||
|
||||
|
||||
g.DrawEllipse(pen, _startPosX.Value + 85, _startPosY.Value +
|
||||
34, 15, 20);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 102, _startPosY.Value +
|
||||
34, 15, 20);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 118, _startPosY.Value +
|
||||
34, 15, 20);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 134, _startPosY.Value +
|
||||
34, 15, 20);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//рога
|
||||
|
||||
if (EntityTrolleybus.Roga)
|
||||
{
|
||||
g.DrawLine(addpen, _startPosX.Value + 42, _startPosY.Value + 7,
|
||||
_startPosX.Value + 124, _startPosY.Value + 29);
|
||||
g.DrawLine(addpen, _startPosX.Value + 62, _startPosY.Value + 2,
|
||||
_startPosX.Value + 124, _startPosY.Value + 29);
|
||||
|
||||
|
||||
}
|
||||
//отсек для батареек
|
||||
|
||||
if (EntityTrolleybus.Otsek)
|
||||
{
|
||||
g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value +
|
||||
48, 5, 20);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 5, _startPosY.Value +
|
||||
48, 5, 20);
|
||||
|
||||
g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value +
|
||||
48, 5, 20);
|
||||
}
|
||||
|
||||
//двойная дверь
|
||||
|
||||
if (EntityTrolleybus.Doors)
|
||||
{
|
||||
g.DrawLine(addpen, _startPosX.Value + 66, _startPosY.Value + 40,
|
||||
_startPosX.Value + 66, _startPosY.Value + 70);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
72
TrolleybusProject/TrolleybusProject/EntityTrolleybus.cs
Normal file
72
TrolleybusProject/TrolleybusProject/EntityTrolleybus.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TrolleybusProject;
|
||||
|
||||
public class EntityTrolleybus
|
||||
{
|
||||
|
||||
/// <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 Roga { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличие отсека
|
||||
/// </summary>
|
||||
|
||||
public bool Otsek { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия двойной двери
|
||||
/// </summary>
|
||||
public bool Doors { 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="roga">Признак наличия рогов</param>
|
||||
/// <param name="otsek">Признак наличия отсека</param>
|
||||
/// <param name="doors">Признак наличия двойной двери</param>
|
||||
public void Init(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool roga, bool otsek, bool doors)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
AdditionalColor = additionalColor;
|
||||
Roga = roga;
|
||||
Otsek = otsek;
|
||||
Doors = doors;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
namespace TrolleybusProject
|
||||
{
|
||||
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 TrolleybusProject
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
134
TrolleybusProject/TrolleybusProject/FormTrolleybus.Designer.cs
generated
Normal file
134
TrolleybusProject/TrolleybusProject/FormTrolleybus.Designer.cs
generated
Normal file
@ -0,0 +1,134 @@
|
||||
namespace TrolleybusProject
|
||||
{
|
||||
partial class FormTrolleybus
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
pictureBoxTrolleybus = new PictureBox();
|
||||
buttonCreate = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonUp = new Button();
|
||||
buttonDown = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxTrolleybus).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxTrolleybus
|
||||
//
|
||||
pictureBoxTrolleybus.Dock = DockStyle.Fill;
|
||||
pictureBoxTrolleybus.Location = new Point(0, 0);
|
||||
pictureBoxTrolleybus.Name = "pictureBoxTrolleybus";
|
||||
pictureBoxTrolleybus.Size = new Size(1273, 561);
|
||||
pictureBoxTrolleybus.TabIndex = 0;
|
||||
pictureBoxTrolleybus.TabStop = false;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreate.Location = new Point(21, 515);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(112, 34);
|
||||
buttonCreate.TabIndex = 1;
|
||||
buttonCreate.Text = "Создать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += buttonCreate_Click;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonLeft.BackgroundImage = Properties.Resources.VrOGN5g4L9w;
|
||||
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonLeft.Location = new Point(963, 488);
|
||||
buttonLeft.Name = "buttonLeft";
|
||||
buttonLeft.Size = new Size(91, 63);
|
||||
buttonLeft.TabIndex = 2;
|
||||
buttonLeft.UseVisualStyleBackColor = true;
|
||||
buttonLeft.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonRight.BackgroundImage = Properties.Resources.png_transparent_arrow_computer_icons_arrow_pointing_right_infographic_purple_angle;
|
||||
buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonRight.Location = new Point(1137, 490);
|
||||
buttonRight.Name = "buttonRight";
|
||||
buttonRight.Size = new Size(88, 61);
|
||||
buttonRight.TabIndex = 3;
|
||||
buttonRight.UseVisualStyleBackColor = true;
|
||||
buttonRight.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonUp.BackgroundImage = Properties.Resources.DvwLovXGanw;
|
||||
buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonUp.Location = new Point(1060, 393);
|
||||
buttonUp.Name = "buttonUp";
|
||||
buttonUp.Size = new Size(71, 80);
|
||||
buttonUp.TabIndex = 4;
|
||||
buttonUp.UseVisualStyleBackColor = true;
|
||||
buttonUp.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonDown.BackgroundImage = Properties.Resources.hOo2qaYtvmQ;
|
||||
buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDown.Location = new Point(1060, 479);
|
||||
buttonDown.Name = "buttonDown";
|
||||
buttonDown.Size = new Size(71, 82);
|
||||
buttonDown.TabIndex = 5;
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += buttonMove_Click;
|
||||
//
|
||||
// FormTrolleybus
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1273, 561);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(pictureBoxTrolleybus);
|
||||
Name = "FormTrolleybus";
|
||||
Text = "Троллейбус";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxTrolleybus).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxTrolleybus;
|
||||
private Button buttonCreate;
|
||||
private Button buttonLeft;
|
||||
private Button buttonRight;
|
||||
private Button buttonUp;
|
||||
private Button buttonDown;
|
||||
}
|
||||
}
|
82
TrolleybusProject/TrolleybusProject/FormTrolleybus.cs
Normal file
82
TrolleybusProject/TrolleybusProject/FormTrolleybus.cs
Normal file
@ -0,0 +1,82 @@
|
||||
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 TrolleybusProject
|
||||
{
|
||||
public partial class FormTrolleybus : Form
|
||||
{
|
||||
private DrawningTrolleybus? _drawningTrolleybus;
|
||||
public FormTrolleybus()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
_drawningTrolleybus = new DrawningTrolleybus();
|
||||
_drawningTrolleybus.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)));
|
||||
|
||||
_drawningTrolleybus.SetPictureSize(pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
||||
|
||||
_drawningTrolleybus.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
|
||||
Bitmap bmp = new(pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningTrolleybus.DrawTransport(gr);
|
||||
pictureBoxTrolleybus.Image = bmp;
|
||||
|
||||
}
|
||||
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningTrolleybus == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
bool result = false;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
result = _drawningTrolleybus.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
result = _drawningTrolleybus.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
result = _drawningTrolleybus.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
result = _drawningTrolleybus.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningTrolleybus.DrawTransport(gr);
|
||||
pictureBoxTrolleybus.Image = bmp;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ namespace TrolleybusProject
|
||||
// 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 FormTrolleybus());
|
||||
}
|
||||
}
|
||||
}
|
104
TrolleybusProject/TrolleybusProject/Properties/Resources.Designer.cs
generated
Normal file
104
TrolleybusProject/TrolleybusProject/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,104 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace TrolleybusProject.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||
/// </summary>
|
||||
// Этот класс создан автоматически классом 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() {
|
||||
}
|
||||
|
||||
/// <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("TrolleybusProject.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 DvwLovXGanw {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("DvwLovXGanw", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap hOo2qaYtvmQ {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("hOo2qaYtvmQ", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap png_transparent_arrow_computer_icons_arrow_pointing_right_infographic_purple_angle {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("png-transparent-arrow-computer-icons-arrow-pointing-right-infographic-purple-angl" +
|
||||
"e", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap VrOGN5g4L9w {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("VrOGN5g4L9w", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
TrolleybusProject/TrolleybusProject/Properties/Resources.resx
Normal file
133
TrolleybusProject/TrolleybusProject/Properties/Resources.resx
Normal 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="VrOGN5g4L9w" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\VrOGN5g4L9w.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="DvwLovXGanw" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\DvwLovXGanw.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="hOo2qaYtvmQ" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\hOo2qaYtvmQ.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="png-transparent-arrow-computer-icons-arrow-pointing-right-infographic-purple-angle" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\png-transparent-arrow-computer-icons-arrow-pointing-right-infographic-purple-angle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
TrolleybusProject/TrolleybusProject/Resources/DvwLovXGanw.jpg
Normal file
BIN
TrolleybusProject/TrolleybusProject/Resources/DvwLovXGanw.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 292 KiB |
BIN
TrolleybusProject/TrolleybusProject/Resources/VrOGN5g4L9w.jpg
Normal file
BIN
TrolleybusProject/TrolleybusProject/Resources/VrOGN5g4L9w.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 129 KiB |
BIN
TrolleybusProject/TrolleybusProject/Resources/hOo2qaYtvmQ.jpg
Normal file
BIN
TrolleybusProject/TrolleybusProject/Resources/hOo2qaYtvmQ.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 284 KiB |
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
@ -8,4 +8,19 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user