laba5 Кувшинов Тимур ПИбд-21 простая #8

Closed
TImourka wants to merge 7 commits from laba5 into laba4
11 changed files with 740 additions and 18 deletions
Showing only changes of commit 98e70fff81 - Show all commits

View File

@ -10,6 +10,10 @@ namespace Laba1Loco
{
internal class DrawingLoco : DrawingTrain
{
public void setAdditionalColor(Color color)
{
(EntityTrain as EntityLoco).AdditionalColor = color;
}
/// <summary>
/// Инициализация свойств
/// </summary>

View File

@ -10,6 +10,10 @@ namespace Laba1Loco
{
internal class DrawingTrain
{
public void setBodyColor(Color color)
{
EntityTrain.BodyColor = color;
}
public IMoveableObject GetMoveableObject => new DrawningObjectTrain(this);
/// <summary>
/// Класс-сущность
@ -18,11 +22,11 @@ namespace Laba1Loco
/// <summary>
/// Ширина окна
/// </summary>
protected int _pictureWidth;
public int _pictureWidth;
/// <summary>
/// Высота окна
/// </summary>
protected int _pictureHeight;
public int _pictureHeight;
/// <summary>
/// Левая координата прорисовки локомотива
/// </summary>

View File

@ -9,7 +9,7 @@ namespace Laba1Loco
{
internal class EntityLoco : EntityTrain
{
public Color AdditionalColor { get; private set; }
public Color AdditionalColor { get; set; }
/// <summary>
/// Признак (опция) наличия трубы
/// </summary>

View File

@ -20,7 +20,7 @@ namespace Laba1Loco
/// <summary>
/// Основной цвет
/// </summary>
public Color BodyColor { get; private set; }
public Color BodyColor { get; set; }
/// <summary>
/// Шаг перемещения поезда
/// </summary>

View File

@ -46,6 +46,28 @@ namespace Laba1Loco
}
}
private void AddTrain(DrawingTrain train)
{
if (listBoxStorage.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
if ((obj + train) != -1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowTrains();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
/// <summary>
/// Добавление объекта в набор
/// </summary>
@ -62,20 +84,9 @@ namespace Laba1Loco
{
return;
}
FormLocomotive form = new FormLocomotive();
if (form.ShowDialog() == DialogResult.OK)
{
if ((obj + form.SelectedTrain) != -1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowTrains();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
form.timer1.Stop();
FormTrainConfig form = new FormTrainConfig();
form.Show();
form.AddEvent(AddTrain);
}
/// <summary>
/// Удаление объекта из набора

View File

@ -0,0 +1,402 @@
namespace Laba1Loco
{
partial class FormTrainConfig
{
/// <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.ParamsGroup = new System.Windows.Forms.GroupBox();
this.labelLoco = new System.Windows.Forms.Label();
this.labelTrain = new System.Windows.Forms.Label();
this.groupBoxColors = new System.Windows.Forms.GroupBox();
this.panel5 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.panel6 = new System.Windows.Forms.Panel();
this.panel3 = new System.Windows.Forms.Panel();
this.panel7 = new System.Windows.Forms.Panel();
this.panel4 = new System.Windows.Forms.Panel();
this.panel8 = new System.Windows.Forms.Panel();
this.panel1 = new System.Windows.Forms.Panel();
this.checkBoxFuelTank = new System.Windows.Forms.CheckBox();
this.checkBoxSmokeTube = new System.Windows.Forms.CheckBox();
this.checkBoxLocoLine = new System.Windows.Forms.CheckBox();
this.numericWeight = new System.Windows.Forms.NumericUpDown();
this.numericSpeed = new System.Windows.Forms.NumericUpDown();
this.weightLabel = new System.Windows.Forms.Label();
this.speedLabel = new System.Windows.Forms.Label();
this.panel9 = new System.Windows.Forms.Panel();
this.pictureBox = new System.Windows.Forms.PictureBox();
this.buttonAdd = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.labelColor = new System.Windows.Forms.Label();
this.labelAdditionalColor = new System.Windows.Forms.Label();
this.ParamsGroup.SuspendLayout();
this.groupBoxColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericWeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericSpeed)).BeginInit();
this.panel9.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
this.SuspendLayout();
//
// ParamsGroup
//
this.ParamsGroup.Controls.Add(this.labelLoco);
this.ParamsGroup.Controls.Add(this.labelTrain);
this.ParamsGroup.Controls.Add(this.groupBoxColors);
this.ParamsGroup.Controls.Add(this.checkBoxFuelTank);
this.ParamsGroup.Controls.Add(this.checkBoxSmokeTube);
this.ParamsGroup.Controls.Add(this.checkBoxLocoLine);
this.ParamsGroup.Controls.Add(this.numericWeight);
this.ParamsGroup.Controls.Add(this.numericSpeed);
this.ParamsGroup.Controls.Add(this.weightLabel);
this.ParamsGroup.Controls.Add(this.speedLabel);
this.ParamsGroup.Location = new System.Drawing.Point(3, 2);
this.ParamsGroup.Name = "ParamsGroup";
this.ParamsGroup.Size = new System.Drawing.Size(180, 481);
this.ParamsGroup.TabIndex = 0;
this.ParamsGroup.TabStop = false;
this.ParamsGroup.Text = "Params Group Box";
//
// labelLoco
//
this.labelLoco.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelLoco.Location = new System.Drawing.Point(90, 419);
this.labelLoco.Name = "labelLoco";
this.labelLoco.Size = new System.Drawing.Size(65, 37);
this.labelLoco.TabIndex = 10;
this.labelLoco.Text = "Loco";
this.labelLoco.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelLoco.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
//
// labelTrain
//
this.labelTrain.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelTrain.Location = new System.Drawing.Point(14, 419);
this.labelTrain.Name = "labelTrain";
this.labelTrain.Size = new System.Drawing.Size(65, 37);
this.labelTrain.TabIndex = 9;
this.labelTrain.Text = "Train";
this.labelTrain.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelTrain.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
//
// groupBoxColors
//
this.groupBoxColors.Controls.Add(this.panel5);
this.groupBoxColors.Controls.Add(this.panel2);
this.groupBoxColors.Controls.Add(this.panel6);
this.groupBoxColors.Controls.Add(this.panel3);
this.groupBoxColors.Controls.Add(this.panel7);
this.groupBoxColors.Controls.Add(this.panel4);
this.groupBoxColors.Controls.Add(this.panel8);
this.groupBoxColors.Controls.Add(this.panel1);
this.groupBoxColors.Location = new System.Drawing.Point(12, 174);
this.groupBoxColors.Name = "groupBoxColors";
this.groupBoxColors.Size = new System.Drawing.Size(158, 226);
this.groupBoxColors.TabIndex = 8;
this.groupBoxColors.TabStop = false;
this.groupBoxColors.Text = "Colors";
//
// panel5
//
this.panel5.BackColor = System.Drawing.Color.Fuchsia;
this.panel5.Location = new System.Drawing.Point(81, 179);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(42, 40);
this.panel5.TabIndex = 3;
this.panel5.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseDown);
//
// panel2
//
this.panel2.BackColor = System.Drawing.Color.Yellow;
this.panel2.Location = new System.Drawing.Point(81, 70);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(42, 40);
this.panel2.TabIndex = 1;
this.panel2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseDown);
//
// panel6
//
this.panel6.BackColor = System.Drawing.Color.Cyan;
this.panel6.Location = new System.Drawing.Point(81, 125);
this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(42, 40);
this.panel6.TabIndex = 4;
this.panel6.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseDown);
//
// panel3
//
this.panel3.BackColor = System.Drawing.Color.Red;
this.panel3.Location = new System.Drawing.Point(81, 16);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(42, 40);
this.panel3.TabIndex = 1;
this.panel3.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseDown);
//
// panel7
//
this.panel7.BackColor = System.Drawing.Color.Blue;
this.panel7.Location = new System.Drawing.Point(25, 179);
this.panel7.Name = "panel7";
this.panel7.Size = new System.Drawing.Size(42, 40);
this.panel7.TabIndex = 5;
this.panel7.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseDown);
//
// panel4
//
this.panel4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
this.panel4.Location = new System.Drawing.Point(25, 70);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(42, 40);
this.panel4.TabIndex = 1;
this.panel4.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseDown);
//
// panel8
//
this.panel8.BackColor = System.Drawing.Color.Lime;
this.panel8.Location = new System.Drawing.Point(25, 125);
this.panel8.Name = "panel8";
this.panel8.Size = new System.Drawing.Size(42, 40);
this.panel8.TabIndex = 2;
this.panel8.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseDown);
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.Silver;
this.panel1.Location = new System.Drawing.Point(25, 16);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(42, 40);
this.panel1.TabIndex = 0;
this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseDown);
//
// checkBoxFuelTank
//
this.checkBoxFuelTank.AutoSize = true;
this.checkBoxFuelTank.Location = new System.Drawing.Point(14, 117);
this.checkBoxFuelTank.Name = "checkBoxFuelTank";
this.checkBoxFuelTank.Size = new System.Drawing.Size(70, 17);
this.checkBoxFuelTank.TabIndex = 7;
this.checkBoxFuelTank.Text = "Fuel tank";
this.checkBoxFuelTank.UseVisualStyleBackColor = true;
//
// checkBoxSmokeTube
//
this.checkBoxSmokeTube.AutoSize = true;
this.checkBoxSmokeTube.Location = new System.Drawing.Point(14, 97);
this.checkBoxSmokeTube.Name = "checkBoxSmokeTube";
this.checkBoxSmokeTube.Size = new System.Drawing.Size(83, 17);
this.checkBoxSmokeTube.TabIndex = 6;
this.checkBoxSmokeTube.Text = "Smoke tube";
this.checkBoxSmokeTube.UseVisualStyleBackColor = true;
//
// checkBoxLocoLine
//
this.checkBoxLocoLine.AutoSize = true;
this.checkBoxLocoLine.Location = new System.Drawing.Point(14, 140);
this.checkBoxLocoLine.Name = "checkBoxLocoLine";
this.checkBoxLocoLine.Size = new System.Drawing.Size(69, 17);
this.checkBoxLocoLine.TabIndex = 5;
this.checkBoxLocoLine.Text = "Loco line";
this.checkBoxLocoLine.UseVisualStyleBackColor = true;
//
// numericWeight
//
this.numericWeight.Location = new System.Drawing.Point(50, 51);
this.numericWeight.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.numericWeight.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericWeight.Name = "numericWeight";
this.numericWeight.Size = new System.Drawing.Size(120, 20);
this.numericWeight.TabIndex = 4;
this.numericWeight.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// numericSpeed
//
this.numericSpeed.Location = new System.Drawing.Point(50, 23);
this.numericSpeed.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.numericSpeed.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericSpeed.Name = "numericSpeed";
this.numericSpeed.Size = new System.Drawing.Size(120, 20);
this.numericSpeed.TabIndex = 3;
this.numericSpeed.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// weightLabel
//
this.weightLabel.AutoSize = true;
this.weightLabel.Location = new System.Drawing.Point(9, 51);
this.weightLabel.Name = "weightLabel";
this.weightLabel.Size = new System.Drawing.Size(35, 13);
this.weightLabel.TabIndex = 2;
this.weightLabel.Text = "weigh";
//
// speedLabel
//
this.speedLabel.AutoSize = true;
this.speedLabel.Location = new System.Drawing.Point(9, 25);
this.speedLabel.Name = "speedLabel";
this.speedLabel.Size = new System.Drawing.Size(36, 13);
this.speedLabel.TabIndex = 1;
this.speedLabel.Text = "speed";
//
// panel9
//
this.panel9.AllowDrop = true;
this.panel9.Controls.Add(this.pictureBox);
this.panel9.Location = new System.Drawing.Point(200, 75);
this.panel9.Name = "panel9";
this.panel9.Size = new System.Drawing.Size(588, 338);
this.panel9.TabIndex = 11;
this.panel9.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
this.panel9.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
//
// pictureBox
//
this.pictureBox.Location = new System.Drawing.Point(14, 5);
this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(555, 330);
this.pictureBox.TabIndex = 0;
this.pictureBox.TabStop = false;
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(200, 421);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(75, 23);
this.buttonAdd.TabIndex = 12;
this.buttonAdd.Text = "Add";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonOk_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(515, 421);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 13;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// labelColor
//
this.labelColor.AllowDrop = true;
this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelColor.Location = new System.Drawing.Point(200, 25);
this.labelColor.Name = "labelColor";
this.labelColor.Size = new System.Drawing.Size(100, 23);
this.labelColor.TabIndex = 14;
this.labelColor.Text = "Color";
this.labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelColor_DragDrop);
this.labelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter);
//
// labelAdditionalColor
//
this.labelAdditionalColor.AllowDrop = true;
this.labelAdditionalColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelAdditionalColor.Location = new System.Drawing.Point(515, 24);
this.labelAdditionalColor.Name = "labelAdditionalColor";
this.labelAdditionalColor.Size = new System.Drawing.Size(100, 23);
this.labelAdditionalColor.TabIndex = 15;
this.labelAdditionalColor.Text = "Additional color";
this.labelAdditionalColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelAdditionalColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelColor_DragDrop);
this.labelAdditionalColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter);
//
// FormTrainConfig
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 484);
this.Controls.Add(this.labelAdditionalColor);
this.Controls.Add(this.labelColor);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.panel9);
this.Controls.Add(this.ParamsGroup);
this.Name = "FormTrainConfig";
this.Text = "FormTrainConfig";
this.ParamsGroup.ResumeLayout(false);
this.ParamsGroup.PerformLayout();
this.groupBoxColors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericWeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericSpeed)).EndInit();
this.panel9.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox ParamsGroup;
private System.Windows.Forms.CheckBox checkBoxFuelTank;
private System.Windows.Forms.CheckBox checkBoxSmokeTube;
private System.Windows.Forms.CheckBox checkBoxLocoLine;
private System.Windows.Forms.NumericUpDown numericWeight;
private System.Windows.Forms.NumericUpDown numericSpeed;
private System.Windows.Forms.Label weightLabel;
private System.Windows.Forms.Label speedLabel;
private System.Windows.Forms.GroupBox groupBoxColors;
private System.Windows.Forms.Panel panel5;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel panel6;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Panel panel7;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.Panel panel8;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label labelLoco;
private System.Windows.Forms.Label labelTrain;
private System.Windows.Forms.Panel panel9;
private System.Windows.Forms.PictureBox pictureBox;
private System.Windows.Forms.Button buttonAdd;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Label labelColor;
private System.Windows.Forms.Label labelAdditionalColor;
}
}

View File

@ -0,0 +1,155 @@
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 Laba1Loco
{
public partial class FormTrainConfig : Form
{
Color defaultColor;
/// <summary>
/// Переменная-выбранная машина
/// </summary>
DrawingTrain _train = null;
/// <summary>
/// Событие
/// </summary>
private event TrainDelegate EventAddTrain;
/// <summary>
/// Конструктор
/// </summary>
public FormTrainConfig()
{
InitializeComponent();
defaultColor = labelColor.BackColor;
// TODO buttonCancel.Click with lambda
}
/// <summary>
/// Отрисовать поезд
/// </summary>
private void DrawTrain()
{
Bitmap bmp = new Bitmap(pictureBox.Width, pictureBox.Height);
Graphics gr = Graphics.FromImage(bmp);
_train?.SetPosition(5, 5);
if (_train is DrawingLoco)
(_train as DrawingLoco).DrawTransport(gr);
else
_train?.DrawTransport(gr);
pictureBox.Image = bmp;
}
/// <summary>
/// Добавление события
/// </summary>
/// <param name="ev">Привязанный метод</param>
internal void AddEvent(TrainDelegate ev)
{
if (EventAddTrain == null)
{
EventAddTrain = ev;
}
else
{
EventAddTrain += ev;
}
}
/// <summary>
/// Передаем информацию при нажатии на Label
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
}
/// <summary>
/// Проверка получаемой информации (ее типа на соответствие требуемому)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelObject_DragEnter(object sender, DragEventArgs e)
{
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
/// <summary>
/// Действия при приеме перетаскиваемой информации
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelObject_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data?.GetData(DataFormats.Text).ToString())
{
case "labelTrain":
_train = new DrawingTrain((int)numericSpeed.Value,(int)numericWeight.Value, Color.White, pictureBox.Width,pictureBox.Height);
break;
case "labelLoco":
_train = new DrawingLoco((int)numericSpeed.Value,(int)numericWeight.Value, Color.White, Color.Black, checkBoxSmokeTube.Checked, checkBoxFuelTank.Checked, checkBoxLocoLine.Checked, pictureBox.Width, pictureBox.Height);
break;
}
labelColor.BackColor = defaultColor;
labelAdditionalColor.BackColor = defaultColor;
DrawTrain();
}
/// <summary>
/// Добавление машины
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonOk_Click(object sender, EventArgs e)
{
EventAddTrain?.Invoke(_train);
Close();
}
private void panelColor_MouseDown(object sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
}
private void labelColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void labelColor_DragDrop(object sender, DragEventArgs e)
{
if (_train == null)
return;
((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color));
switch (((Label)sender).Name)
{
case "labelColor":
_train.setBodyColor((Color)e.Data.GetData(typeof(Color)));
break;
case "labelAdditionalColor":
if (!(_train is DrawingLoco))
return;
(_train as DrawingLoco).setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
break;
}
DrawTrain();
}
}
}

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

@ -53,6 +53,13 @@
<Compile Include="FormTrainCollection.Designer.cs">
<DependentUpon>FormTrainCollection.cs</DependentUpon>
</Compile>
<Compile Include="FormTrainConfig.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormTrainConfig.Designer.cs">
<DependentUpon>FormTrainConfig.cs</DependentUpon>
</Compile>
<Compile Include="TrainDelegate.cs" />
<Compile Include="TrainsGenericCollection.cs" />
<Compile Include="Direction.cs" />
<Compile Include="DrawingLoco.cs" />
@ -81,6 +88,9 @@
<EmbeddedResource Include="FormTrainCollection.resx">
<DependentUpon>FormTrainCollection.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormTrainConfig.resx">
<DependentUpon>FormTrainConfig.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Laba1Loco
{
/// <summary>
/// Делегат для передачи объекта-автомобиля
/// </summary>
/// <param name="car"></param>
internal delegate void TrainDelegate(DrawingTrain car);
}

View File

@ -124,6 +124,8 @@ where U : IMoveableObject
{
if (train != null)
{
train._pictureHeight = _pictureHeight;
train._pictureWidth = _pictureWidth;
train.SetPosition((i % (_pictureWidth / _placeSizeWidth)) * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight);
if (train is DrawingLoco)
(train as DrawingLoco).DrawTransport(g);