ISEbd-21 Melnikov I. O. Lab work 03 advanced #4

Closed
Igor-Melnikov wants to merge 3 commits from Lab03 into Lab02
9 changed files with 641 additions and 4 deletions
Showing only changes of commit e198915d98 - Show all commits

View File

@ -0,0 +1,55 @@
namespace WarmlyLocomotove
{
internal class AdvancedObjectGeneric<T, U>
where T : EntityLocomotive
where U : class, IDrawningAdditionalElements
{
T[] Entities = new T[10];
public int CurrentEntityIndex = 0;
public U[] AdditionalElementsSetups = new U[10];
public int CurrentAdditionalElementSetupIndex = 0;
public void AddEntity(T NewEntity)
{
if (CurrentEntityIndex >= 9)
{
return;
}
Entities[CurrentEntityIndex] = NewEntity;
CurrentEntityIndex++;
}
public void AddAdditionalElementSetup(U NewAdditionalElementSetup)
{
if (CurrentAdditionalElementSetupIndex >= 9)
{
return;
}
AdditionalElementsSetups[CurrentAdditionalElementSetupIndex] = NewAdditionalElementSetup;
CurrentAdditionalElementSetupIndex++;
}
public DrawningLocomotive GeneratedObject()
{
Random rnd = new();
int SelectedEntityIndex = rnd.Next(0, 9);
Review

Методы должны были быть полиморфные

Методы должны были быть полиморфные
int SelectedAdditionalElementSetupIndex = rnd.Next(0, 9);
DrawningLocomotive Object;
if (Entities[SelectedEntityIndex] is EntityLocomotive)
{
Object = new DrawningLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
Object.Locomotive = Entities[SelectedEntityIndex];
Object.AdditionalElements = AdditionalElementsSetups[SelectedAdditionalElementSetupIndex];
}
else
{
Object = new DrawningWarmlyLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
160, 115,
Review

Методы должны были быть полиморфные

Методы должны были быть полиморфные
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
Convert.ToBoolean(rnd.Next(0, 2)),
Convert.ToBoolean(rnd.Next(0, 2)));
Object.Locomotive = Entities[SelectedEntityIndex];
Object.AdditionalElements = AdditionalElementsSetups[SelectedAdditionalElementSetupIndex];
}
return Object;
}
}
}

View File

@ -8,7 +8,7 @@
/// <summary>
/// Класс-сущность
/// </summary>
public EntityLocomotive Locomotive { get; protected set; }
public EntityLocomotive Locomotive { get; set; }
/// <summary>
/// Класс отрисовки колёс
/// </summary>

View File

@ -0,0 +1,317 @@
namespace WarmlyLocomotove
{
partial class FormLocomotiveAdditional
{
/// <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.pictureBoxLocomotive = new System.Windows.Forms.PictureBox();
this.statusStrip = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelAdditionalColor = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelHasPipe = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelHasFuelTank = new System.Windows.Forms.ToolStripStatusLabel();
this.buttonCreate = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.buttonUp = new System.Windows.Forms.Button();
this.numericUpDownWheelsNumber = new System.Windows.Forms.NumericUpDown();
this.labelWheelsNumber = new System.Windows.Forms.Label();
this.buttonCreateModif = new System.Windows.Forms.Button();
this.buttonSelectLocomotive = new System.Windows.Forms.Button();
this.buttonGenerateEntities = new System.Windows.Forms.Button();
this.buttonGenerateAdditionalElementsSetup = new System.Windows.Forms.Button();
this.buttonShowGeneratedObject = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).BeginInit();
this.statusStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWheelsNumber)).BeginInit();
this.SuspendLayout();
//
// pictureBoxLocomotive
//
this.pictureBoxLocomotive.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxLocomotive.Location = new System.Drawing.Point(0, 0);
this.pictureBoxLocomotive.MinimumSize = new System.Drawing.Size(1, 1);
this.pictureBoxLocomotive.Name = "pictureBoxLocomotive";
this.pictureBoxLocomotive.Size = new System.Drawing.Size(800, 450);
this.pictureBoxLocomotive.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBoxLocomotive.TabIndex = 0;
this.pictureBoxLocomotive.TabStop = false;
this.pictureBoxLocomotive.Resize += new System.EventHandler(this.PictureBoxLocomotive_Resize);
//
// statusStrip
//
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabelSpeed,
this.toolStripStatusLabelWeight,
this.toolStripStatusLabelBodyColor,
this.toolStripStatusLabelAdditionalColor,
this.toolStripStatusLabelHasPipe,
this.toolStripStatusLabelHasFuelTank});
this.statusStrip.Location = new System.Drawing.Point(0, 428);
this.statusStrip.Name = "statusStrip";
this.statusStrip.Size = new System.Drawing.Size(800, 22);
this.statusStrip.TabIndex = 1;
this.statusStrip.Text = "statusStrip1";
//
// toolStripStatusLabelSpeed
//
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(65, 17);
this.toolStripStatusLabelSpeed.Text = "Скорость: ";
//
// toolStripStatusLabelWeight
//
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(32, 17);
this.toolStripStatusLabelWeight.Text = "Вес: ";
//
// toolStripStatusLabelBodyColor
//
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(39, 17);
this.toolStripStatusLabelBodyColor.Text = "Цвет: ";
//
// toolStripStatusLabelAdditionalColor
//
this.toolStripStatusLabelAdditionalColor.Name = "toolStripStatusLabelAdditionalColor";
this.toolStripStatusLabelAdditionalColor.Size = new System.Drawing.Size(137, 17);
this.toolStripStatusLabelAdditionalColor.Text = "Дополнительный цвет: ";
//
// toolStripStatusLabelHasPipe
//
this.toolStripStatusLabelHasPipe.Name = "toolStripStatusLabelHasPipe";
this.toolStripStatusLabelHasPipe.Size = new System.Drawing.Size(99, 17);
this.toolStripStatusLabelHasPipe.Text = "Наличие трубы: ";
//
// toolStripStatusLabelHasFuelTank
//
this.toolStripStatusLabelHasFuelTank.Name = "toolStripStatusLabelHasFuelTank";
this.toolStripStatusLabelHasFuelTank.Size = new System.Drawing.Size(158, 17);
this.toolStripStatusLabelHasFuelTank.Text = "Наличие топливного бака: ";
//
// buttonCreate
//
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonCreate.Location = new System.Drawing.Point(12, 395);
this.buttonCreate.Name = "buttonCreate";
this.buttonCreate.Size = new System.Drawing.Size(90, 30);
this.buttonCreate.TabIndex = 2;
this.buttonCreate.Text = "Создать";
this.buttonCreate.UseVisualStyleBackColor = true;
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
//
// buttonRight
//
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRight.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.ArrowRight;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonRight.Location = new System.Drawing.Point(758, 395);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(30, 30);
this.buttonRight.TabIndex = 3;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonLeft
//
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonLeft.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.ArrowLeft;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonLeft.Location = new System.Drawing.Point(686, 395);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
this.buttonLeft.TabIndex = 4;
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonDown
//
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDown.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.ArrowDown;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonDown.Location = new System.Drawing.Point(722, 395);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(30, 30);
this.buttonDown.TabIndex = 5;
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonUp
//
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUp.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.ArrowUp;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonUp.Location = new System.Drawing.Point(722, 359);
this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(30, 30);
this.buttonUp.TabIndex = 6;
this.buttonUp.UseVisualStyleBackColor = true;
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
//
// numericUpDownWheelsNumber
//
this.numericUpDownWheelsNumber.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.numericUpDownWheelsNumber.Location = new System.Drawing.Point(651, 402);
this.numericUpDownWheelsNumber.Maximum = new decimal(new int[] {
4,
0,
0,
0});
this.numericUpDownWheelsNumber.Minimum = new decimal(new int[] {
2,
0,
0,
0});
this.numericUpDownWheelsNumber.Name = "numericUpDownWheelsNumber";
this.numericUpDownWheelsNumber.ReadOnly = true;
this.numericUpDownWheelsNumber.Size = new System.Drawing.Size(29, 23);
this.numericUpDownWheelsNumber.TabIndex = 7;
this.numericUpDownWheelsNumber.Value = new decimal(new int[] {
2,
0,
0,
0});
//
// labelWheelsNumber
//
this.labelWheelsNumber.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.labelWheelsNumber.AutoSize = true;
this.labelWheelsNumber.Location = new System.Drawing.Point(565, 404);
this.labelWheelsNumber.Name = "labelWheelsNumber";
this.labelWheelsNumber.Size = new System.Drawing.Size(80, 15);
this.labelWheelsNumber.TabIndex = 8;
this.labelWheelsNumber.Text = "Число колёс:";
//
// buttonCreateModif
//
this.buttonCreateModif.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonCreateModif.Location = new System.Drawing.Point(108, 395);
this.buttonCreateModif.Name = "buttonCreateModif";
this.buttonCreateModif.Size = new System.Drawing.Size(98, 30);
this.buttonCreateModif.TabIndex = 9;
this.buttonCreateModif.Text = "Модификация";
this.buttonCreateModif.UseVisualStyleBackColor = true;
this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
//
// buttonSelectLocomotive
//
this.buttonSelectLocomotive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonSelectLocomotive.Location = new System.Drawing.Point(461, 396);
this.buttonSelectLocomotive.Name = "buttonSelectLocomotive";
this.buttonSelectLocomotive.Size = new System.Drawing.Size(98, 30);
this.buttonSelectLocomotive.TabIndex = 10;
this.buttonSelectLocomotive.Text = "Выбрать";
this.buttonSelectLocomotive.UseVisualStyleBackColor = true;
this.buttonSelectLocomotive.Click += new System.EventHandler(this.ButtonSelectLocomotive_Click);
//
// buttonGenerateEntities
//
this.buttonGenerateEntities.Location = new System.Drawing.Point(12, 294);
this.buttonGenerateEntities.Name = "buttonGenerateEntities";
this.buttonGenerateEntities.Size = new System.Drawing.Size(90, 32);
this.buttonGenerateEntities.TabIndex = 11;
this.buttonGenerateEntities.Text = "button1";
this.buttonGenerateEntities.UseVisualStyleBackColor = true;
this.buttonGenerateEntities.Click += new System.EventHandler(this.ButtonGenerateEntities_Click_1);
//
// buttonGenerateAdditionalElementsSetup
//
this.buttonGenerateAdditionalElementsSetup.Location = new System.Drawing.Point(188, 294);
this.buttonGenerateAdditionalElementsSetup.Name = "buttonGenerateAdditionalElementsSetup";
this.buttonGenerateAdditionalElementsSetup.Size = new System.Drawing.Size(90, 32);
this.buttonGenerateAdditionalElementsSetup.TabIndex = 12;
this.buttonGenerateAdditionalElementsSetup.Text = "button1";
this.buttonGenerateAdditionalElementsSetup.UseVisualStyleBackColor = true;
this.buttonGenerateAdditionalElementsSetup.Click += new System.EventHandler(this.ButtonGenerateAdditionalElementsSetup_Click);
//
// buttonShowGeneratedObject
//
this.buttonShowGeneratedObject.Location = new System.Drawing.Point(98, 216);
this.buttonShowGeneratedObject.Name = "buttonShowGeneratedObject";
this.buttonShowGeneratedObject.Size = new System.Drawing.Size(90, 32);
this.buttonShowGeneratedObject.TabIndex = 13;
this.buttonShowGeneratedObject.Text = "button1";
this.buttonShowGeneratedObject.UseVisualStyleBackColor = true;
this.buttonShowGeneratedObject.Click += new System.EventHandler(this.ButtonShowGeneratedObject_Click);
//
// FormLocomotiveAdditional
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.buttonShowGeneratedObject);
this.Controls.Add(this.buttonGenerateAdditionalElementsSetup);
this.Controls.Add(this.buttonGenerateEntities);
this.Controls.Add(this.buttonSelectLocomotive);
this.Controls.Add(this.buttonCreateModif);
this.Controls.Add(this.labelWheelsNumber);
this.Controls.Add(this.numericUpDownWheelsNumber);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.statusStrip);
this.Controls.Add(this.pictureBoxLocomotive);
this.Name = "FormLocomotiveAdditional";
this.Text = "Локомотив";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).EndInit();
this.statusStrip.ResumeLayout(false);
this.statusStrip.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWheelsNumber)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private PictureBox pictureBoxLocomotive;
private StatusStrip statusStrip;
private ToolStripStatusLabel toolStripStatusLabelSpeed;
private ToolStripStatusLabel toolStripStatusLabelWeight;
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
private Button buttonCreate;
private Button buttonRight;
private Button buttonLeft;
private Button buttonDown;
private Button buttonUp;
private NumericUpDown numericUpDownWheelsNumber;
private Label labelWheelsNumber;
private Button buttonCreateModif;
private ToolStripStatusLabel toolStripStatusLabelAdditionalColor;
private ToolStripStatusLabel toolStripStatusLabelHasPipe;
private ToolStripStatusLabel toolStripStatusLabelHasFuelTank;
private Button buttonSelectLocomotive;
private Button buttonGenerateEntities;
private Button buttonGenerateAdditionalElementsSetup;
private Button buttonShowGeneratedObject;
}
}

View File

@ -0,0 +1,194 @@
namespace WarmlyLocomotove
{
public partial class FormLocomotiveAdditional : Form
{
/// <summary>
/// Объект от класса отрисовки локомотива
/// </summary>
private DrawningLocomotive _locomotive;
/// <summary>
/// Выбранный объект
/// </summary>
public DrawningLocomotive SelectedLocomotive { get; private set; }
private AdvancedObjectGeneric<EntityLocomotive,IDrawningAdditionalElements> AdvancedObject = new AdvancedObjectGeneric<EntityLocomotive, IDrawningAdditionalElements>();
public FormLocomotiveAdditional()
{
InitializeComponent();
}
/// <summary>
/// Метод отрисовки локомотива
/// </summary>
private void Draw()
{
Bitmap bmp = new(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
Graphics gr = Graphics.FromImage(bmp);
_locomotive?.DrawTransport(gr);
pictureBoxLocomotive.Image = bmp;
}
/// <summary>
/// Заполнение информации по объекту
/// </summary>
/// <param name="locomotive">Объект от класса отрисовки или его наследника</param>
private void SetData(DrawningLocomotive locomotive)
{
Random rnd = new();
toolStripStatusLabelSpeed.Text = $"Скорость: {locomotive.Locomotive.Speed}";
toolStripStatusLabelWeight.Text = $"Вес: {locomotive.Locomotive.Weight}";
toolStripStatusLabelBodyColor.Text = $"Цвет: {locomotive.Locomotive.BodyColor.Name}";
toolStripStatusLabelAdditionalColor.Text = $"Дополнительный цвет: н/д";
toolStripStatusLabelHasPipe.Text = $"Наличие трубы: н/д";
toolStripStatusLabelHasFuelTank.Text = $"Наличие топливного бака: н/д";
_locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
}
/// <summary>
/// Заполнение дополнительной информации по объекту (только для усложнённого объекта)
/// </summary>
/// <param name="warmlylocomotive">Объект от наследника класса отрисовки</param>
private void SetAdditionalData(DrawningWarmlyLocomotive warmlylocomotive)
{
if (warmlylocomotive.Locomotive is EntityWarmlyLocomotive entityWarmlyLocomotive)
{
toolStripStatusLabelAdditionalColor.Text = $"Дополнительный цвет: {entityWarmlyLocomotive.AdditionalColor.Name}";
toolStripStatusLabelHasPipe.Text = $"Наличие трубы: {entityWarmlyLocomotive.HasPipe}";
toolStripStatusLabelHasFuelTank.Text = $"Наличие топливного бака: {entityWarmlyLocomotive.HasFuelTank}";
}
}
/// <summary>
/// Метод обработки нажатия на кнопку "Создать"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
_locomotive = new DrawningLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
SetData(_locomotive);
_locomotive.AdditionalElements.WheelsNum = (int)numericUpDownWheelsNumber.Value;
Draw();
}
/// <summary>
/// Метод обработки нажатия на кнопки перемещения
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonMove_Click(object sender, EventArgs e)
{
//получаем имя кнопки
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "buttonUp":
_locomotive?.MoveLocomotive(Direction.Up);
break;
case "buttonDown":
_locomotive?.MoveLocomotive(Direction.Down);
break;
case "buttonLeft":
_locomotive?.MoveLocomotive(Direction.Left);
break;
case "buttonRight":
_locomotive?.MoveLocomotive(Direction.Right);
break;
}
Draw();
}
/// <summary>
/// Изменение размеров формы
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PictureBoxLocomotive_Resize(object sender, EventArgs e)
{
_locomotive?.ChangeBorders(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
Draw();
}
/// <summary>
/// Метод обработки нажатия на кнопку "Модификация"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonCreateModif_Click(object sender, EventArgs e)
{
Random rnd = new();
_locomotive = new DrawningWarmlyLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
160, 115,
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
Convert.ToBoolean(rnd.Next(0, 2)),
Convert.ToBoolean(rnd.Next(0, 2)));
SetData(_locomotive);
SetAdditionalData((DrawningWarmlyLocomotive)_locomotive);
_locomotive.AdditionalElements.WheelsNum = (int)numericUpDownWheelsNumber.Value;
Draw();
}
/// <summary>
/// Метод обработки нажатия на кнопку "Выбрать"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonSelectLocomotive_Click(object sender, EventArgs e)
{
SelectedLocomotive = _locomotive;
DialogResult = DialogResult.OK;
}
private void ButtonGenerateEntities_Click_1(object sender, EventArgs e)
{
Random rnd = new();
AdvancedObject.CurrentEntityIndex = 0;
for (int i = 0; i < 10; i++)
{
bool IsAdvancedEntity = Convert.ToBoolean(rnd.Next(0, 2));
EntityLocomotive Entity;
if (!IsAdvancedEntity)
{
Entity = new EntityLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
}
else
{
Entity = new EntityWarmlyLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
Convert.ToBoolean(rnd.Next(0, 2)),
Convert.ToBoolean(rnd.Next(0, 2)));
}
AdvancedObject.AddEntity(Entity);
}
}
private void ButtonGenerateAdditionalElementsSetup_Click(object sender, EventArgs e)
{
Random rnd = new();
for (int i = 0; i < 10; i++)
{
int AdditionalElementSetupType = rnd.Next(0, 2);
switch (AdditionalElementSetupType)
{
case 0:
AdvancedObject.AddAdditionalElementSetup(new DrawningWheels());
break;
case 1:
AdvancedObject.AddAdditionalElementSetup(new DrawningRectOrnament());
break;
case 2:
AdvancedObject.AddAdditionalElementSetup(new DrawningEllipseOrnament());
break;
}
}
}
private void ButtonShowGeneratedObject_Click(object sender, EventArgs e)
{
Random rnd = new();
_locomotive = AdvancedObject.GeneratedObject();
_locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
SetData(_locomotive);
_locomotive.AdditionalElements.WheelsNum = 2;
_locomotive.AdditionalElements.WheelsNum = (int)numericUpDownWheelsNumber.Value;
Draw();
}
}
}

View File

@ -0,0 +1,63 @@
<root>
<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>
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -228,7 +228,7 @@
this.buttonSelectLocomotive.UseVisualStyleBackColor = true;
this.buttonSelectLocomotive.Click += new System.EventHandler(this.ButtonSelectLocomotive_Click);
//
// FormLocomotive
// FormLocomotiveAdditional
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
@ -244,7 +244,7 @@
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.statusStrip);
this.Controls.Add(this.pictureBoxLocomotive);
this.Name = "FormLocomotive";
this.Name = "FormLocomotiveAdditional";
this.Text = "Локомотив";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).EndInit();
this.statusStrip.ResumeLayout(false);

View File

@ -132,5 +132,10 @@
SelectedLocomotive = _locomotive;
DialogResult = DialogResult.OK;
}
private void buttonGenerateEntities_Click(object sender, EventArgs e)
{
}
}
}

View File

@ -8,7 +8,7 @@ namespace WarmlyLocomotove
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new FormMapWithSetLocomotives());
Application.Run(new FormLocomotiveAdditional());
}
}
}

View File

@ -9,6 +9,9 @@
</PropertyGroup>
<ItemGroup>
<Compile Update="FormLocomotive - Копировать.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>