ISEbd-21 Melnikov I.O. Lab work 02 Base #2
43
Locomotives/Locomotives/FormLocomotive.Designer.cs
generated
43
Locomotives/Locomotives/FormLocomotive.Designer.cs
generated
@ -33,11 +33,15 @@
|
||||
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.buttonCreateModif = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).BeginInit();
|
||||
this.statusStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@ -59,7 +63,10 @@
|
||||
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripStatusLabelSpeed,
|
||||
this.toolStripStatusLabelWeight,
|
||||
this.toolStripStatusLabelBodyColor});
|
||||
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);
|
||||
@ -84,6 +91,24 @@
|
||||
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)));
|
||||
@ -143,11 +168,23 @@
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// 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(109, 30);
|
||||
this.buttonCreateModif.TabIndex = 8;
|
||||
this.buttonCreateModif.Text = "Модификация";
|
||||
this.buttonCreateModif.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
|
||||
//
|
||||
// FormLocomotive
|
||||
//
|
||||
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.buttonCreateModif);
|
||||
this.Controls.Add(this.buttonUp);
|
||||
this.Controls.Add(this.buttonDown);
|
||||
this.Controls.Add(this.buttonLeft);
|
||||
@ -177,5 +214,9 @@
|
||||
private Button buttonLeft;
|
||||
private Button buttonDown;
|
||||
private Button buttonUp;
|
||||
private ToolStripStatusLabel toolStripStatusLabelAdditionalColor;
|
||||
private ToolStripStatusLabel toolStripStatusLabelHasPipe;
|
||||
private ToolStripStatusLabel toolStripStatusLabelHasFuelTank;
|
||||
private Button buttonCreateModif;
|
||||
}
|
||||
}
|
@ -22,6 +22,34 @@
|
||||
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>
|
||||
@ -30,10 +58,7 @@
|
||||
{
|
||||
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);
|
||||
toolStripStatusLabelSpeed.Text = $"Скорость: {_locomotive.Locomotive.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Вес: {_locomotive.Locomotive.Weight}";
|
||||
toolStripStatusLabelBodyColor.Text = $"Цвет: {_locomotive.Locomotive.BodyColor.Name}";
|
||||
SetData(_locomotive);
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
@ -72,5 +97,23 @@
|
||||
_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, 85,
|
||||
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);
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user