ISEbd-22. Baygulov A.A. Lab work 1 (hard) #4
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
public enum Direction
|
||||
{
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
Right = 4
|
||||
}
|
||||
}
|
@ -0,0 +1,211 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
public class DrawningElectricLocomotive
|
||||
{
|
||||
public EntityElectricLocomotive? EntityElectricLocomotive { get; private set; }
|
||||
private int _pictureWidth;
|
||||
private int _pictureHeight;
|
||||
private int _startPosX;
|
||||
private int _startPosY;
|
||||
private readonly int _locomWidth = 150;
|
||||
private readonly int _locomHeight = 52;
|
||||
private DrawningWheels drawningWheels;
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="pantograph">Признак наличия токоприемника</param>
|
||||
/// <param name="compartment">Признак наличия отсеков под электрические батареи</param>
|
||||
/// <param name="width">Ширина картинки</param>
|
||||
/// <param name="height">Высота картинки</param>
|
||||
/// <returns>true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах</returns>
|
||||
public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool pantograph, bool compartment, int wheels, int width, int height)
|
||||
{
|
||||
if (width < _locomWidth || height < _locomHeight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityElectricLocomotive = new EntityElectricLocomotive();
|
||||
EntityElectricLocomotive.Init(speed, weight, bodyColor, additionalColor, pantograph, compartment, wheels);
|
||||
|
||||
drawningWheels = new DrawningWheels();
|
||||
drawningWheels.SetAmount(wheels);
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
/// <param name="x">Координата X</param>
|
||||
/// <param name="y">Координата Y</param>
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (x < 0 || x + _locomWidth > _pictureWidth)
|
||||
{
|
||||
x = _pictureWidth - _locomWidth;
|
||||
}
|
||||
if (y < 0 || y + _locomHeight > _pictureHeight)
|
||||
{
|
||||
y = _pictureHeight - _locomHeight;
|
||||
}
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
/// <param name="direction">Направление</param>
|
||||
public void MoveTransport(Direction direction)
|
||||
{
|
||||
if (EntityElectricLocomotive == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
//влево
|
||||
case Direction.Left:
|
||||
if (_startPosX - EntityElectricLocomotive.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityElectricLocomotive.Step;
|
||||
}
|
||||
break;
|
||||
//вверх
|
||||
case Direction.Up:
|
||||
if (_startPosY - EntityElectricLocomotive.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityElectricLocomotive.Step;
|
||||
}
|
||||
break;
|
||||
//вправо
|
||||
case Direction.Right:
|
||||
if (_startPosX + EntityElectricLocomotive.Step + _locomWidth < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityElectricLocomotive.Step;
|
||||
}
|
||||
break;
|
||||
case Direction.Down:
|
||||
if (_startPosY + EntityElectricLocomotive.Step + _locomHeight < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityElectricLocomotive.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/// <param name="g"></param>
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityElectricLocomotive == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush blackBrush = new SolidBrush(Color.Black);
|
||||
Brush windows = new SolidBrush(Color.LightBlue);
|
||||
Brush bodyColor = new SolidBrush(EntityElectricLocomotive.BodyColor);
|
||||
Brush additionalBrush = new SolidBrush(EntityElectricLocomotive.AdditionalColor);
|
||||
|
||||
if (EntityElectricLocomotive.Pantograph)
|
||||
{
|
||||
// Токоприемники
|
||||
g.FillRectangle(blackBrush, _startPosX + 30, _startPosY + 15, 20, 5);
|
||||
g.DrawLine(pen, _startPosX + 30, _startPosY + 15, _startPosX + 50, _startPosY + 2);
|
||||
g.DrawLine(pen, _startPosX + 40, _startPosY + 15, _startPosX + 60, _startPosY + 2);
|
||||
}
|
||||
|
||||
// Локомотив
|
||||
g.FillPolygon(bodyColor, new Point[]
|
||||
{
|
||||
new Point(_startPosX, _startPosY + 40),
|
||||
new Point(_startPosX, _startPosY + 30),
|
||||
new Point(_startPosX + 20, _startPosY + 20),
|
||||
new Point(_startPosX + 70, _startPosY + 20),
|
||||
new Point(_startPosX +80, _startPosY + 20),
|
||||
new Point(_startPosX +80, _startPosY + 40),
|
||||
new Point(_startPosX +75, _startPosY + 45),
|
||||
new Point(_startPosX +5, _startPosY + 45),
|
||||
new Point(_startPosX, _startPosY + 40),
|
||||
}
|
||||
);
|
||||
|
||||
if (EntityElectricLocomotive.Compartment)
|
||||
{
|
||||
g.DrawRectangle(pen, _startPosX + 40, _startPosY + 24, 25, 11);
|
||||
g.FillPolygon(additionalBrush, new Point[]
|
||||
{
|
||||
new Point(_startPosX + 41, _startPosY + 25),
|
||||
new Point(_startPosX + 65, _startPosY + 25),
|
||||
new Point(_startPosX + 65, _startPosY + 35),
|
||||
new Point(_startPosX + 41, _startPosY + 35),
|
||||
new Point(_startPosX + 41, _startPosY + 25),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
g.DrawPolygon(pen, new Point[]
|
||||
{
|
||||
new Point(_startPosX, _startPosY + 40),
|
||||
new Point(_startPosX, _startPosY + 30),
|
||||
new Point(_startPosX + 20, _startPosY + 20),
|
||||
new Point(_startPosX + 70, _startPosY + 20),
|
||||
new Point(_startPosX + 80, _startPosY + 20),
|
||||
new Point(_startPosX + 80, _startPosY + 40),
|
||||
new Point(_startPosX + 75, _startPosY + 45),
|
||||
new Point(_startPosX + 5, _startPosY + 45),
|
||||
new Point(_startPosX, _startPosY + 40),
|
||||
}
|
||||
);
|
||||
|
||||
// Окна
|
||||
g.FillEllipse(windows, _startPosX + 10, _startPosY + 24, 10, 10);
|
||||
g.DrawEllipse(pen, _startPosX + 10, _startPosY + 25, 10, 10);
|
||||
|
||||
g.FillRectangle(windows, _startPosX + 25, _startPosY + 25, 10, 5);
|
||||
g.DrawRectangle(pen, _startPosX + 25, _startPosY + 25, 10, 5);
|
||||
|
||||
// Колёса
|
||||
// Локомотив
|
||||
g.FillEllipse(blackBrush, _startPosX + 10, _startPosY + 45, 10, 10);
|
||||
g.FillEllipse(blackBrush, _startPosX + 25, _startPosY + 45, 10, 10);
|
||||
|
||||
g.FillEllipse(blackBrush, _startPosX + 50, _startPosY + 45, 10, 10);
|
||||
g.FillEllipse(blackBrush, _startPosX + 65, _startPosY + 45, 10, 10);
|
||||
// Вагон
|
||||
g.FillPolygon(additionalBrush, new Point[]
|
||||
{
|
||||
new Point(_startPosX + 90, _startPosY + 25),
|
||||
new Point(_startPosX + 95, _startPosY + 20),
|
||||
new Point(_startPosX + 145, _startPosY + 20),
|
||||
new Point(_startPosX + 150, _startPosY + 25),
|
||||
new Point(_startPosX + 150, _startPosY + 45),
|
||||
new Point(_startPosX + 90, _startPosY + 45),
|
||||
new Point(_startPosX + 90, _startPosY + 25),
|
||||
}
|
||||
);
|
||||
|
||||
g.DrawPolygon(pen, new Point[]
|
||||
{
|
||||
new Point(_startPosX + 90, _startPosY + 25),
|
||||
new Point(_startPosX + 95, _startPosY + 20),
|
||||
new Point(_startPosX + 145, _startPosY + 20),
|
||||
new Point(_startPosX + 150, _startPosY + 25),
|
||||
new Point(_startPosX + 150, _startPosY + 45),
|
||||
new Point(_startPosX + 90, _startPosY + 45),
|
||||
new Point(_startPosX + 90, _startPosY + 25),
|
||||
}
|
||||
);
|
||||
//Окна
|
||||
g.DrawLine(pen, _startPosX + 80, _startPosY + 40, _startPosX + 90, _startPosY + 40);
|
||||
g.FillRectangle(windows, _startPosX + 95, _startPosY + 30, 10, 5);
|
||||
g.FillRectangle(windows, _startPosX + 115, _startPosY + 30, 10, 5);
|
||||
g.FillRectangle(windows, _startPosX + 135, _startPosY + 30, 10, 5);
|
||||
|
||||
//Колеса
|
||||
drawningWheels.DrawWheels(g, _startPosX, _startPosY);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
internal class DrawningWheels
|
||||
{
|
||||
private Wheels amount;
|
||||
public void SetAmount(int a)
|
||||
|
||||
{
|
||||
if (a <= 2)
|
||||
{
|
||||
amount = Wheels.Two;
|
||||
}
|
||||
else if (a == 3)
|
||||
{
|
||||
amount = Wheels.Three;
|
||||
}
|
||||
else if (a >= 4)
|
||||
{
|
||||
amount = Wheels.Four;
|
||||
}
|
||||
}
|
||||
public void DrawWheels(Graphics g, int _startPosX, int _startPosY)
|
||||
{
|
||||
Brush wheelsColor = new SolidBrush(Color.Black);
|
||||
if (amount == Wheels.Two)
|
||||
g.FillEllipse(wheelsColor, _startPosX + 90, _startPosY + 45, 10, 10);
|
||||
g.FillEllipse(wheelsColor, _startPosX + 140, _startPosY + 45, 10, 10);
|
||||
|
||||
if (amount == Wheels.Three)
|
||||
{
|
||||
g.FillEllipse(wheelsColor, _startPosX + 90, _startPosY + 45, 10, 10);
|
||||
eegov
commented
Имеется дублирующийся код Имеется дублирующийся код
|
||||
g.FillEllipse(wheelsColor, _startPosX + 100, _startPosY + 45, 10, 10);
|
||||
g.FillEllipse(wheelsColor, _startPosX + 140, _startPosY + 45, 10, 10);
|
||||
}
|
||||
if (amount == Wheels.Four)
|
||||
{
|
||||
g.FillEllipse(wheelsColor, _startPosX + 90, _startPosY + 45, 10, 10);
|
||||
g.FillEllipse(wheelsColor, _startPosX + 100, _startPosY + 45, 10, 10);
|
||||
g.FillEllipse(wheelsColor, _startPosX + 140, _startPosY + 45, 10, 10);
|
||||
g.FillEllipse(wheelsColor, _startPosX + 130, _startPosY + 45, 10, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
public class EntityElectricLocomotive
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
public double Weight { get; private set; }
|
||||
public Color BodyColor { get; private set; }
|
||||
public Color AdditionalColor { get; private set; }
|
||||
public bool Pantograph { get; private set; }
|
||||
public bool Compartment { get; private set; }
|
||||
public int Wheels { get; private set; }
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес локомотива</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="pantograph">Признак наличия токоприемника</param>
|
||||
/// <param name="compartment">Признак наличия отсеков под электрические батареи</param>
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool pantograph, bool compartment, int wheels)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
AdditionalColor = additionalColor;
|
||||
Pantograph = pantograph;
|
||||
Compartment = compartment;
|
||||
Wheels = wheels;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
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 ProjectElectricLocomotive
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
138
ProjectElectricLocomotive/ProjectElectricLocomotive/FormElectricLocomotive.Designer.cs
generated
Normal file
138
ProjectElectricLocomotive/ProjectElectricLocomotive/FormElectricLocomotive.Designer.cs
generated
Normal file
@ -0,0 +1,138 @@
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
partial class FormElectricLocomotive
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
pictureBoxElectricLocomotive = new PictureBox();
|
||||
buttonCreate = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonUp = new Button();
|
||||
buttonDown = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxElectricLocomotive).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxElectricLocomotive
|
||||
//
|
||||
pictureBoxElectricLocomotive.Cursor = Cursors.No;
|
||||
pictureBoxElectricLocomotive.Dock = DockStyle.Fill;
|
||||
pictureBoxElectricLocomotive.Enabled = false;
|
||||
pictureBoxElectricLocomotive.Location = new Point(0, 0);
|
||||
pictureBoxElectricLocomotive.Name = "pictureBoxElectricLocomotive";
|
||||
pictureBoxElectricLocomotive.Size = new Size(1052, 553);
|
||||
pictureBoxElectricLocomotive.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||
pictureBoxElectricLocomotive.TabIndex = 0;
|
||||
pictureBoxElectricLocomotive.TabStop = false;
|
||||
pictureBoxElectricLocomotive.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreate.Location = new Point(0, 490);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(172, 63);
|
||||
buttonCreate.TabIndex = 1;
|
||||
buttonCreate.Text = "Создать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += buttonCreate_Click;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonLeft.BackgroundImage = Properties.Resources.free_icon_left_arrow_line_symbol_54321;
|
||||
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonLeft.Location = new Point(938, 511);
|
||||
buttonLeft.Name = "buttonLeft";
|
||||
buttonLeft.Size = new Size(30, 30);
|
||||
buttonLeft.TabIndex = 2;
|
||||
buttonLeft.UseVisualStyleBackColor = true;
|
||||
buttonLeft.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonRight.BackgroundImage = Properties.Resources.free_icon_right_arrow_angle_54833;
|
||||
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonRight.Location = new Point(1010, 511);
|
||||
buttonRight.Name = "buttonRight";
|
||||
buttonRight.Size = new Size(30, 30);
|
||||
buttonRight.TabIndex = 3;
|
||||
buttonRight.UseVisualStyleBackColor = true;
|
||||
buttonRight.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonUp.BackgroundImage = Properties.Resources.free_icon_up_arrow_angle_54817;
|
||||
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonUp.Location = new Point(974, 475);
|
||||
buttonUp.Name = "buttonUp";
|
||||
buttonUp.Size = new Size(30, 30);
|
||||
buttonUp.TabIndex = 4;
|
||||
buttonUp.UseVisualStyleBackColor = true;
|
||||
buttonUp.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonDown.BackgroundImage = Properties.Resources.free_icon_down_arrow_54785;
|
||||
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonDown.Location = new Point(974, 511);
|
||||
buttonDown.Name = "buttonDown";
|
||||
buttonDown.Size = new Size(30, 30);
|
||||
buttonDown.TabIndex = 5;
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += buttonMove_Click;
|
||||
//
|
||||
// FormElectricLocomotive
|
||||
//
|
||||
ClientSize = new Size(1052, 553);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(pictureBoxElectricLocomotive);
|
||||
Name = "FormElectricLocomotive";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "ElectricLocomotive";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxElectricLocomotive).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxElectricLocomotive;
|
||||
private Button buttonCreate;
|
||||
private Button buttonLeft;
|
||||
private Button buttonRight;
|
||||
private Button buttonUp;
|
||||
private Button buttonDown;
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
public partial class FormElectricLocomotive : Form
|
||||
{
|
||||
private DrawningElectricLocomotive? _drawningElectricLocomotive;
|
||||
public FormElectricLocomotive()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningElectricLocomotive == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBoxElectricLocomotive.Width,
|
||||
pictureBoxElectricLocomotive.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningElectricLocomotive.DrawTransport(gr);
|
||||
pictureBoxElectricLocomotive.Image = bmp;
|
||||
}
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
_drawningElectricLocomotive = new DrawningElectricLocomotive();
|
||||
_drawningElectricLocomotive.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)),
|
||||
random.Next(1, 5),
|
||||
pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height) ; ;
|
||||
_drawningElectricLocomotive.SetPosition(random.Next(1, 100), random.Next(1, 100));
|
||||
Draw();
|
||||
}
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningElectricLocomotive == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawningElectricLocomotive.MoveTransport(Direction.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_drawningElectricLocomotive.MoveTransport(Direction.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_drawningElectricLocomotive.MoveTransport(Direction.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_drawningElectricLocomotive.MoveTransport(Direction.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
<?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>
|
@ -11,7 +11,7 @@ namespace ProjectElectricLocomotive
|
||||
// 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 FormElectricLocomotive());
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
103
ProjectElectricLocomotive/ProjectElectricLocomotive/Properties/Resources.Designer.cs
generated
Normal file
103
ProjectElectricLocomotive/ProjectElectricLocomotive/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ProjectElectricLocomotive.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("ProjectElectricLocomotive.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 free_icon_down_arrow_54785 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("free-icon-down-arrow-54785", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap free_icon_left_arrow_line_symbol_54321 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("free-icon-left-arrow-line-symbol-54321", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap free_icon_right_arrow_angle_54833 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("free-icon-right-arrow-angle-54833", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap free_icon_up_arrow_angle_54817 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("free-icon-up-arrow-angle-54817", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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="free-icon-down-arrow-54785" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\free-icon-down-arrow-54785.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="free-icon-left-arrow-line-symbol-54321" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\free-icon-left-arrow-line-symbol-54321.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="free-icon-up-arrow-angle-54817" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\free-icon-up-arrow-angle-54817.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="free-icon-right-arrow-angle-54833" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\free-icon-right-arrow-angle-54833.png;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: 5.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
public enum Wheels
|
||||
{
|
||||
Two,
|
||||
Three,
|
||||
Four
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user
Требовалось сделать свойство числовое