3 Commits

Author SHA1 Message Date
64cab8c122 / 2024-03-30 14:41:36 +04:00
6835c4db76 компания ( с ошибками) 2024-03-29 22:52:04 +04:00
8d20120955 Коллекции обьектов 2024-03-29 20:26:34 +04:00
13 changed files with 791 additions and 77 deletions

View File

@@ -0,0 +1,110 @@
using ProjectSportCar.Drawnings;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectSportCar.CollectionGenericObjects;
/// <summary>
/// Абстракция компании, хранящий коллекцию автомобилей
/// </summary>
public abstract class AbstractCompany
{
/// <summary>
/// Размер места (ширина)
/// </summary>
protected readonly int _placeSizeWidth = 210;
/// <summary>
/// Размер места (высота)
/// </summary>
protected readonly int _placeSizeHeight = 80;
/// <summary>
/// Ширина окна
/// </summary>
protected readonly int _pictureWidth;
/// <summary>
/// Высота окна
/// </summary>
protected readonly int _pictureHeight;
/// <summary>
/// Коллекция автомобилей
/// </summary>
protected ICollectionGenericObjects<DrawningCar>? _collection = null;
/// <summary>
/// Вычисление максимального количества элементов, который можно разместитьв окне
/// </summary>
private int GetMaxCount => _pictureWidth * _pictureHeight /
(_placeSizeWidth * _placeSizeHeight);
/// <summary>
/// Конструктор
/// </summary>
/// <param name="picWidth">Ширина окна</param>
/// <param name="picHeight">Высота окна</param>
/// <param name="collection">Коллекция автомобилей</param>
public AbstractCompany(int picWidth, int picHeight,
ICollectionGenericObjects<DrawningCar> collection)
{
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = collection;
_collection.SetMaxCount = GetMaxCount;
}
/// <summary>
/// Перегрузка оператора сложения для класса
/// </summary>
/// <param name="company">Компания</param>
/// <param name="car">Добавляемый объект</param>
/// <returns></returns>
public static bool operator +(AbstractCompany company, DrawningCar car)
{
return company._collection?.Insert(car) ?? false;
}
/// <summary>
/// Перегрузка оператора удаления для класса
/// </summary>
/// <param name="company">Компания</param>
/// <param name="position">Номер удаляемого объекта</param>
/// <returns></returns>
public static bool operator -(AbstractCompany company, int position)
{
return company._collection?.Remove(position) ?? false;
}
/// <summary>
/// Получение случайного объекта из коллекции
/// </summary>
/// <returns></returns>
public DrawningCar? GetRandomObject()
{
Random rnd = new();
return _collection?.Get(rnd.Next(GetMaxCount));
}
/// <summary>
/// Вывод всей коллекции
/// </summary>
/// <returns></returns>
public Bitmap? Show()
{
Bitmap bitmap = new(_pictureWidth, _pictureHeight);
Graphics graphics = Graphics.FromImage(bitmap);
DrawBackgound(graphics);
SetObjectsPosition();
for (int i = 0; i < (_collection?.Count ?? 0); ++i)
{
DrawningCar? obj = _collection?.Get(i);
obj?.DrawTransport(graphics);
}
return bitmap;
}
/// <summary>
/// Вывод заднего фона
/// </summary>
/// <param name="g"></param>
protected abstract void DrawBackgound(Graphics g);
/// <summary>
/// Расстановка объектов
/// </summary>
protected abstract void SetObjectsPosition();
}

View File

@@ -0,0 +1,25 @@
using ProjectSportCar.Drawnings;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectSportCar.CollectionGenericObjects;
public class CarSharingService : AbstractCompany
{
public CarSharingService(int picWidth, int picHeight, ICollectionGenericObjects<DrawningCar> collection) : base(picWidth, picHeight, collection)
{
}
protected override void DrawBackgound(Graphics g)
{
throw new NotImplementedException();
}
protected override void SetObjectsPosition()
{
throw new NotImplementedException();
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectSportCar.CollectionGenericObjects;
public interface ICollectionGenericObjects <T>
where T : class
{
/// <summary>
/// Количество объектов в коллекции
/// </summary>
int Count { get; }
/// <summary>
/// Установка максимального количества элементов
/// </summary>
int SetMaxCount { set; }
/// <summary>
/// Добавление объекта в коллекцию
/// </summary>
/// <param name="obj">Добавляемый объект</param>
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
bool Insert(T obj);
/// <summary>
/// Добавление объекта в коллекцию на конкретную позицию
/// </summary>
/// <param name="obj">Добавляемый объект</param>
/// <param name="position">Позиция</param>
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
bool Insert(T obj, int position);
/// <summary>
/// Удаление объекта из коллекции с конкретной позиции
/// </summary>
/// <param name="position">Позиция</param>
/// <returns>true - удаление прошло удачно, false - удаление не удалось</returns>
bool Remove(int position);
/// <summary>
/// Получение объекта по позиции
/// </summary>
/// <param name="position">Позиция</param>
/// <returns>Объект</returns>
T? Get(int position);
}

View File

@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectSportCar.CollectionGenericObjects;
//прописать логику..
/// <summary>
/// Параметризованный набор обьектов
/// </summary>
/// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam>
public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
where T : class
{
/// <summary>
/// Массив объектов, которые храним
/// </summary>
private T?[] _collection;
public int Count => _collection.Length;
public int SetMaxCount { set { if (value > 0) { _collection = new T?[value]; } } }
/// <summary>
/// Конструктор
/// </summary>
public MassiveGenericObjects()
{
_collection = Array.Empty<T?>();
}
public T? Get(int position)
{
// TODO проверка позиции
return _collection[position];
}
public bool Insert(T obj)
{
// TODO вставка в свободное место набора
return false;
}
public bool Insert(T obj, int position)
{
// TODO проверка позиции
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
// ищется свободное место после этой позиции и идет вставка туда
// если нет после, ищем до
// TODO вставка
return false;
}
public bool Remove(int position)
{
// TODO проверка позиции
// TODO удаление объекта из массива, присвоив элементу массива значение null
return true;
}
}

View File

@@ -239,4 +239,8 @@ public class DrawningCar
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 15, 15, 30); g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 15, 15, 30);
} }
public static implicit operator DrawningCar?(DrawningCar? v)
{
throw new NotImplementedException();
}
} }

View File

@@ -0,0 +1,175 @@
namespace ProjectSportCar
{
public partial class FormCarCollection : Form
{
/// <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()
{
groupBoxTools = new GroupBox();
buttonRefresh = new Button();
buttonGoToCheck = new Button();
buttonRemoveCar = new Button();
maskedTextBox = new MaskedTextBox();
buttonAddSportCar = new Button();
buttonAddCar = new Button();
comboBoxSelectionCompany = new ComboBox();
pictureBox = new PictureBox();
groupBoxTools.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
SuspendLayout();
//
// groupBoxTools
//
groupBoxTools.Controls.Add(buttonRefresh);
groupBoxTools.Controls.Add(buttonGoToCheck);
groupBoxTools.Controls.Add(buttonRemoveCar);
groupBoxTools.Controls.Add(maskedTextBox);
groupBoxTools.Controls.Add(buttonAddSportCar);
groupBoxTools.Controls.Add(buttonAddCar);
groupBoxTools.Controls.Add(comboBoxSelectionCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(746, 0);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(182, 518);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(12, 443);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(164, 49);
buttonRefresh.TabIndex = 5;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += ButtonRefresh_Click;
//
// buttonGoToCheck
//
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonGoToCheck.Location = new Point(12, 370);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(164, 49);
buttonGoToCheck.TabIndex = 4;
buttonGoToCheck.Text = "Передать на тесты";
buttonGoToCheck.UseVisualStyleBackColor = true;
buttonGoToCheck.Click += buttonGoToCheck_Click;
//
// buttonRemoveCar
//
buttonRemoveCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRemoveCar.Location = new Point(12, 298);
buttonRemoveCar.Name = "buttonRemoveCar";
buttonRemoveCar.Size = new Size(164, 49);
buttonRemoveCar.TabIndex = 3;
buttonRemoveCar.Text = "Удалить автомобиль";
buttonRemoveCar.UseVisualStyleBackColor = true;
buttonRemoveCar.Click += ButtonRemoveCar_Click;
//
// maskedTextBox
//
maskedTextBox.Location = new Point(6, 237);
maskedTextBox.Mask = "00";
maskedTextBox.Name = "maskedTextBox";
maskedTextBox.Size = new Size(170, 23);
maskedTextBox.TabIndex = 3;
maskedTextBox.ValidatingType = typeof(int);
//
// buttonAddSportCar
//
buttonAddSportCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddSportCar.Location = new Point(12, 138);
buttonAddSportCar.Name = "buttonAddSportCar";
buttonAddSportCar.Size = new Size(164, 49);
buttonAddSportCar.TabIndex = 2;
buttonAddSportCar.Text = "Добавление спортивного автомобиля";
buttonAddSportCar.UseVisualStyleBackColor = true;
buttonAddSportCar.Click += ButtonAddSportCar_Click;
//
// buttonAddCar
//
buttonAddCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddCar.Location = new Point(12, 71);
buttonAddCar.Name = "buttonAddCar";
buttonAddCar.Size = new Size(164, 49);
buttonAddCar.TabIndex = 1;
buttonAddCar.Text = "Добавление автомобиля";
buttonAddCar.UseVisualStyleBackColor = true;
buttonAddCar.Click += ButtonAddCar_Click;
//
// comboBoxSelectionCompany
//
comboBoxSelectionCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
comboBoxSelectionCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectionCompany.FormattingEnabled = true;
comboBoxSelectionCompany.Items.AddRange(new object[] { "Хранилище" });
comboBoxSelectionCompany.Location = new Point(6, 22);
comboBoxSelectionCompany.Name = "comboBoxSelectionCompany";
comboBoxSelectionCompany.Size = new Size(170, 23);
comboBoxSelectionCompany.TabIndex = 0;
comboBoxSelectionCompany.SelectedIndexChanged += ComboBoxSelectionCompany_SelectedIndexChanged;
comboBoxSelectionCompany.Validating += comboBoxSelectionCompany_Validating;
//
// pictureBox
//
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(746, 518);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
pictureBox.Click += pictureBox_Click;
//
// FormCarCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(928, 518);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Name = "FormCarCollection";
Text = "Коллекция автомобилей";
groupBoxTools.ResumeLayout(false);
groupBoxTools.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxTools;
private ComboBox comboBoxSelectionCompany;
private Button buttonAddSportCar;
private Button buttonAddCar;
private PictureBox pictureBox;
private Button buttonRemoveCar;
private MaskedTextBox maskedTextBox;
private Button buttonRefresh;
private Button buttonGoToCheck;
}
}

View File

@@ -0,0 +1,208 @@
using ProjectSportCar.CollectionGenericObjects;
using ProjectSportCar.Drawnings;
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 ProjectSportCar;
/// <summary>
///
/// </summary>
public partial class FormCarCollection : Form
{
/// <summary>
///
/// </summary>
private AbstractCompany? _company = null;
/// <summary>
/// Конструктор
/// </summary>
public FormCarCollection()
{
InitializeComponent();
}
private void comboBoxSelectionCompany_Validating(object sender, CancelEventArgs e)
{
}
private void pictureBox_Click(object sender, EventArgs e)
{
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ComboBoxSelectionCompany_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboBoxSelectorCompany.Text) //ИСПРАВИТЬ ОШИБКУ 3 практ раб 20 минута (или ранее на минуту)
{
case "Хранилище":
_company = new CarSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningCar>());
break;
}
}
private void CreateObject(string type)
{
if (_company == null)
{
return;
}
Random random = new();
DrawningCar drawningCar;
switch (type)
{
case nameof(DrawningCar):
drawningCar = new DrawningCar(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
break;
case nameof(DrawningSportCar):
drawningCar = new DrawningSportCar(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)));
break;
default:
return;
}
if (_company + drawningCar)
{
MessageBox.Show("Обьект добавлен");
pictureBox.Image = _company.Show();
}
else
{
MessageBox.Show("Не удалось добавить обьект");
}
}
/// <summary>
/// Получнеие цвета
/// </summary>
/// <param name="random"> Генератор случайных чисел</param>
/// <returns></returns>
private static Color GetColor(Random random)
{
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
ColorDialog dialog = new();
if (dialog.ShowDialog() == DialogResult.OK)
{
color = dialog.Color;
}
return color;
}
private void ButtonAddCar_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningCar));
private void ButtonAddSportCar_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningSportCar));
private void ButtonRemoveCar_Click(object sender, EventArgs e)
{
if (_company == null)
{
return;
}
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null)
{
return;
}
if (MessageBox.Show("Удалить обьект?", "удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
return;
}
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
if (_company - pos)
{
MessageBox.Show("Обьект удален");
pictureBox.Image = _company.Show();
}
else
{
MessageBox.Show("Не удалось удалить обьект");
}
}
private void buttonGoToCheck_Click(object sender, EventArgs e)
{
if (_company == null)
{
return;
}
DrawningCar? car = null;
int counter = 100;
while (car = null)
{
car = _company.GetRandomObject();
counter--;
if (counter <= 0)
{
break;
}
}
if (car == null)
{
return;
}
FormSportCar form = new()
{
SetCar = car
};
form.ShowDialog();
}
private void ButtonRefresh_Click(object sender, EventArgs e)
{
if (_company == null)
{
return;
}
pictureBox.Image = _company.Show();
}
}

View File

@@ -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>

View File

@@ -30,12 +30,10 @@
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormSportCar)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormSportCar));
pictureBoxSportCar = new PictureBox(); pictureBoxSportCar = new PictureBox();
buttonCreateSportCar = new Button();
buttonLeft = new Button(); buttonLeft = new Button();
buttonUp = new Button(); buttonUp = new Button();
buttonRight = new Button(); buttonRight = new Button();
buttonDown = new Button(); buttonDown = new Button();
buttonCreateCar = new Button();
comboBoxStrategy = new ComboBox(); comboBoxStrategy = new ComboBox();
buttonStrategyStep = new Button(); buttonStrategyStep = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxSportCar).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBoxSportCar).BeginInit();
@@ -49,17 +47,7 @@
pictureBoxSportCar.Size = new Size(934, 450); pictureBoxSportCar.Size = new Size(934, 450);
pictureBoxSportCar.TabIndex = 0; pictureBoxSportCar.TabIndex = 0;
pictureBoxSportCar.TabStop = false; pictureBoxSportCar.TabStop = false;
// pictureBoxSportCar.Click += pictureBoxSportCar_Click;
// buttonCreateSportCar
//
buttonCreateSportCar.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreateSportCar.Location = new Point(12, 415);
buttonCreateSportCar.Name = "buttonCreateSportCar";
buttonCreateSportCar.Size = new Size(227, 23);
buttonCreateSportCar.TabIndex = 1;
buttonCreateSportCar.Text = "Создать спортивный автомобиль";
buttonCreateSportCar.UseVisualStyleBackColor = true;
buttonCreateSportCar.Click += buttonCreateSportCar_Click;
// //
// buttonLeft // buttonLeft
// //
@@ -109,17 +97,6 @@
buttonDown.UseVisualStyleBackColor = true; buttonDown.UseVisualStyleBackColor = true;
buttonDown.Click += buttonMove_Click; buttonDown.Click += buttonMove_Click;
// //
// buttonCreateCar
//
buttonCreateCar.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreateCar.Location = new Point(276, 415);
buttonCreateCar.Name = "buttonCreateCar";
buttonCreateCar.Size = new Size(227, 23);
buttonCreateCar.TabIndex = 6;
buttonCreateCar.Text = "Создать автомобиль";
buttonCreateCar.UseVisualStyleBackColor = true;
buttonCreateCar.Click += ButtonCreateCar_Click;
//
// comboBoxStrategy // comboBoxStrategy
// //
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
@@ -147,12 +124,10 @@
ClientSize = new Size(934, 450); ClientSize = new Size(934, 450);
Controls.Add(buttonStrategyStep); Controls.Add(buttonStrategyStep);
Controls.Add(comboBoxStrategy); Controls.Add(comboBoxStrategy);
Controls.Add(buttonCreateCar);
Controls.Add(buttonDown); Controls.Add(buttonDown);
Controls.Add(buttonRight); Controls.Add(buttonRight);
Controls.Add(buttonUp); Controls.Add(buttonUp);
Controls.Add(buttonLeft); Controls.Add(buttonLeft);
Controls.Add(buttonCreateSportCar);
Controls.Add(pictureBoxSportCar); Controls.Add(pictureBoxSportCar);
Name = "FormSportCar"; Name = "FormSportCar";
Text = "Спортивный автомобиль"; Text = "Спортивный автомобиль";
@@ -164,12 +139,10 @@
#endregion #endregion
private PictureBox pictureBoxSportCar; private PictureBox pictureBoxSportCar;
private Button buttonCreateSportCar;
private Button buttonLeft; private Button buttonLeft;
private Button buttonUp; private Button buttonUp;
private Button buttonRight; private Button buttonRight;
private Button buttonDown; private Button buttonDown;
private Button buttonCreateCar;
private ComboBox comboBoxStrategy; private ComboBox comboBoxStrategy;
private Button buttonStrategyStep; private Button buttonStrategyStep;
} }

View File

@@ -23,6 +23,26 @@ public partial class FormSportCar : Form
private AbstractStrategy? _strategy; private AbstractStrategy? _strategy;
/// <summary>
/// Получение обьекта
/// </summary>
public DrawningCar SetCar
{
set
{
_drawningCar = value;
_drawningCar.SetPictureSize(pictureBoxSportCar.Width, pictureBoxSportCar.Height);
comboBoxStrategy.Enabled = true;
_strategy = null;
Draw();
}
}
/// <summary> /// <summary>
/// Конструктор формы /// Конструктор формы
/// </summary> /// </summary>
@@ -51,51 +71,6 @@ public partial class FormSportCar : Form
} }
private void CreateObject(string type)
{
Random random = new();
switch (type)
{
case nameof(DrawningCar):
_drawningCar = new DrawningCar(random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
break;
case nameof(DrawningSportCar):
_drawningCar = new DrawningSportCar(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)));
break;
default:
return;
}
_drawningCar.SetPictureSize(pictureBoxSportCar.Width, pictureBoxSportCar.Height);
_drawningCar.SetPosition(random.Next(10, 100), random.Next(10, 100));
_strategy = null;
comboBoxStrategy.Enabled = true;
Draw();
}
/// <summary>
/// Обработка нажатия кнопки "создать спортивный авто"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonCreateSportCar_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningSportCar));
/// <summary>
/// Обработка нажатия кнопки "создать авто"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonCreateCar_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningCar));
private void buttonMove_Click(object sender, EventArgs e) private void buttonMove_Click(object sender, EventArgs e)
{ {
if (_drawningCar == null) if (_drawningCar == null)
@@ -165,6 +140,11 @@ public partial class FormSportCar : Form
_strategy = null; _strategy = null;
} }
} }
private void pictureBoxSportCar_Click(object sender, EventArgs e)
{
}
} }

View File

@@ -121,7 +121,7 @@
<data name="buttonLeft.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="buttonLeft.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAAOgAAADsCAIAAADxWn05AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO iVBORw0KGgoAAAANSUhEUgAAAOgAAADsCAIAAADxWn05AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vgAADr4B6kKxwAAABn5JREFUeF7t0lty3DAQQ9Hsf9OOXXVTipPxQx6RBKh7/uyRyFYDv16kQhZXlSyu vAAADrwBlbxySQAABn5JREFUeF7t0lty3DAQQ9Hsf9OOXXVTipPxQx6RBKh7/uyRyFYDv16kQhZXlSyu
KllcVbK4qmRxVcniqpLFVSWLq0oWV5UsripZXFWyuKpkcVXJ4qqSxVUli6tKFleVLK4qWVxVsrhf+PUH KllcVbK4qmRxVcniqpLFVSWLq0oWV5UsripZXFWyuKpkcVXJ4qqSxVUli6tKFleVLK4qWVxVsrhf+PUH
fyuDeXyGzv7BfxXAMD5EW//CDwpgGI9R1ff4TQEM4zGq+h6/KYBhPEBP/8PPCmAY/6Kkj/CEAhjGOzT0 fyuDeXyGzv7BfxXAMD5EW//CDwpgGI9R1ff4TQEM4zGq+h6/KYBhPEBP/8PPCmAY/6Kkj/CEAhjGOzT0
AzykAIZxoJ4f4zkFMAzQzU/xqAIYxhuK+RWeVgDDeEMxv8LTCmAY323tK15QgLuHQSW/h3cU4NZh0Mdv AzykAIZxoJ4f4zkFMAzQzU/xqAIYxhuK+RWeVgDDeEMxv8LTCmAY323tK15QgLuHQSW/h3cU4NZh0Mdv
@@ -155,7 +155,7 @@
<data name="buttonUp.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="buttonUp.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAAOwAAADoCAIAAABjIJ9VAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO iVBORw0KGgoAAAANSUhEUgAAAOwAAADoCAIAAABjIJ9VAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vgAADr4B6kKxwAAABU5JREFUeF7t0tF200oUBFH+/6dDgPICs5zYkqXR9HTtt3uBRNOnfnxI4YxY8YxY vAAADrwBlbxySQAABU5JREFUeF7t0tF200oUBFH+/6dDgPICs5zYkqXR9HTtt3uBRNOnfnxI4YxY8YxY
8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8Yx4tB83/Lfe 8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8YxY8Yx4tB83/Lfe
5pRD0e8N/1fvccdxKPcef6Y3OOIIBPs1/p52cb7T0ekz/G1t53bnotDX8G+0kcOdiDa34F9qC1c7C1Vu 5pRD0e8N/1fvccdxKPcef6Y3OOIIBPs1/p52cb7T0ekz/G1t53bnotDX8G+0kcOdiDa34F9qC1c7C1Vu
x7/Xy5zsFPT4Bn6QXuBYB6PBI/AT9YxLHYn6jsPP1bec6TB0dzR+ur7mRseguHPwO/QFBzoArZ2J36RH x7/Xy5zsFPT4Bn6QXuBYB6PBI/AT9YxLHYn6jsPP1bec6TB0dzR+ur7mRseguHPwO/QFBzoArZ2J36RH
@@ -184,7 +184,7 @@
<data name="buttonRight.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="buttonRight.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAAOgAAADsCAIAAADxWn05AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO iVBORw0KGgoAAAANSUhEUgAAAOgAAADsCAIAAADxWn05AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vgAADr4B6kKxwAAABetJREFUeF7t0tly4zgQBdH+/5/2THSkoi1bG4mFt4A8bzZJQFGVf76kggxXJRmu vAAADrwBlbxySQAABetJREFUeF7t0tly4zgQBdH+/5/2THSkoi1bG4mFt4A8bzZJQFGVf76kggxXJRmu
SjJclWS4KslwVZLhqiTDVUmGq5IMVyUZrkoyXJVkuCrJcFWS4aokw1VJhquSDFclGa5KMlyVZLgqyXBV SjJclWS4KslwVZLhqiTDVUmGq5IMVyUZrkoyXJVkuCrJcFWS4aokw1VJhquSDFclGa5KMlyVZLgqyXBV
kuGqJMNVSYarkgxXJRmuSjJclWS4KslwVZLhqiTDVUmGq5IMN8ufG/7WEw4oCM3e8F894nSCEOw3PNAv kuGqJMNVSYarkgxXJRmuSjJclWS4KslwVZLhqiTDVUmGq5IMN8ufG/7WEw4oCM3e8F894nSCEOw3PNAv
jiYItd7jme45lyCkeo9nuudcgpDqLzzWNw4lCJ0+whu6cSJBiPQJXtJfjiMIhT7HezLcKOT5Eq9uz0EE jiYItd7jme45lyCkeo9nuudcgpDqLzzWNw4lCJ0+whu6cSJBiPQJXtJfjiMIhT7HezLcKOT5Eq9uz0EE
@@ -215,7 +215,7 @@
<data name="buttonDown.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="buttonDown.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAAOwAAADoCAIAAABjIJ9VAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO iVBORw0KGgoAAAANSUhEUgAAAOwAAADoCAIAAABjIJ9VAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vgAADr4B6kKxwAAABVlJREFUeF7t0uFS3EYABGG//0s7TqqphBQ2HCedNDP9/bQB7c72j59SOCNWPCNW vAAADrwBlbxySQAABVlJREFUeF7t0uFS3EYABGG//0s7TqqphBQ2HCedNDP9/bQB7c72j59SOCNWPCNW
PCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNW PCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNW
PCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNW PCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNW
PCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWvJKIf+g9dtnQcFveTe+xzgAj PCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWPCNWvJKIf+g9dtnQcFveTe+xzgAj

View File

@@ -0,0 +1,7 @@
namespace ProjectSportCar
{
internal class comboBoxSelectorCompany
{
internal static readonly string Text;
}
}

View File

@@ -0,0 +1,7 @@
namespace ProjectSportCar
{
internal class maskedTextBoxPosition
{
internal static bool Text;
}
}