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

Closed
TImourka wants to merge 7 commits from laba5 into laba4
13 changed files with 747 additions and 195 deletions

View File

@ -1,9 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33424.131
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Laba1Loco", "Laba1Loco\Laba1Loco.csproj", "{9F9C9603-3EF7-403E-A895-04EA0CBC5586}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Laba1Loco", "Laba1Loco\Laba1Loco.csproj", "{9F9C9603-3EF7-403E-A895-04EA0CBC5586}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
</configuration>
</configuration>

View File

@ -18,11 +18,11 @@ namespace Laba1Loco
/// <summary>
/// Ширина окна
/// </summary>
protected int _pictureWidth;
public int _pictureWidth;
/// <summary>
/// Высота окна
/// </summary>
protected int _pictureHeight;
public int _pictureHeight;
/// <summary>
/// Левая координата прорисовки локомотива
/// </summary>

View File

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

View File

@ -21,6 +21,9 @@ namespace Laba1Loco
/// Основной цвет
/// </summary>
public Color BodyColor { get; private set; }
public void setBodyColor(Color color) { BodyColor = color; }
/// <summary>
/// Шаг перемещения поезда
/// </summary>

View File

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

View File

@ -0,0 +1,397 @@
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()
{
ParamsGroup = new System.Windows.Forms.GroupBox();
labelLoco = new System.Windows.Forms.Label();
labelTrain = new System.Windows.Forms.Label();
groupBoxColors = new System.Windows.Forms.GroupBox();
panelPurple = new System.Windows.Forms.Panel();
panelYellow = new System.Windows.Forms.Panel();
panelBlue = new System.Windows.Forms.Panel();
panelRed = new System.Windows.Forms.Panel();
panelDarkBlue = new System.Windows.Forms.Panel();
panelOrange = new System.Windows.Forms.Panel();
panelGreen = new System.Windows.Forms.Panel();
panelGray = new System.Windows.Forms.Panel();
checkBoxFuelTank = new System.Windows.Forms.CheckBox();
checkBoxSmokeTube = new System.Windows.Forms.CheckBox();
checkBoxLocoLine = new System.Windows.Forms.CheckBox();
numericWeight = new System.Windows.Forms.NumericUpDown();
numericSpeed = new System.Windows.Forms.NumericUpDown();
weightLabel = new System.Windows.Forms.Label();
speedLabel = new System.Windows.Forms.Label();
panel9 = new System.Windows.Forms.Panel();
pictureBox = new System.Windows.Forms.PictureBox();
buttonAdd = new System.Windows.Forms.Button();
buttonCancel = new System.Windows.Forms.Button();
labelColor = new System.Windows.Forms.Label();
labelAdditionalColor = new System.Windows.Forms.Label();
ParamsGroup.SuspendLayout();
groupBoxColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericSpeed).BeginInit();
panel9.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
SuspendLayout();
//
// ParamsGroup
//
ParamsGroup.Controls.Add(labelLoco);
ParamsGroup.Controls.Add(labelTrain);
ParamsGroup.Controls.Add(groupBoxColors);
ParamsGroup.Controls.Add(checkBoxFuelTank);
ParamsGroup.Controls.Add(checkBoxSmokeTube);
ParamsGroup.Controls.Add(checkBoxLocoLine);
ParamsGroup.Controls.Add(numericWeight);
ParamsGroup.Controls.Add(numericSpeed);
ParamsGroup.Controls.Add(weightLabel);
ParamsGroup.Controls.Add(speedLabel);
ParamsGroup.Location = new System.Drawing.Point(4, 2);
ParamsGroup.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
ParamsGroup.Name = "ParamsGroup";
ParamsGroup.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3);
ParamsGroup.Size = new System.Drawing.Size(210, 555);
ParamsGroup.TabIndex = 0;
ParamsGroup.TabStop = false;
ParamsGroup.Text = "Params Group Box";
//
// labelLoco
//
labelLoco.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
labelLoco.Location = new System.Drawing.Point(105, 483);
labelLoco.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
labelLoco.Name = "labelLoco";
labelLoco.Size = new System.Drawing.Size(76, 42);
labelLoco.TabIndex = 10;
labelLoco.Text = "Loco";
labelLoco.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
labelLoco.MouseDown += LabelObject_MouseDown;
//
// labelTrain
//
labelTrain.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
labelTrain.Location = new System.Drawing.Point(16, 483);
labelTrain.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
labelTrain.Name = "labelTrain";
labelTrain.Size = new System.Drawing.Size(76, 42);
labelTrain.TabIndex = 9;
labelTrain.Text = "Train";
labelTrain.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
labelTrain.MouseDown += LabelObject_MouseDown;
//
// groupBoxColors
//
groupBoxColors.Controls.Add(panelPurple);
groupBoxColors.Controls.Add(panelYellow);
groupBoxColors.Controls.Add(panelBlue);
groupBoxColors.Controls.Add(panelRed);
groupBoxColors.Controls.Add(panelDarkBlue);
groupBoxColors.Controls.Add(panelOrange);
groupBoxColors.Controls.Add(panelGreen);
groupBoxColors.Controls.Add(panelGray);
groupBoxColors.Location = new System.Drawing.Point(14, 201);
groupBoxColors.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
groupBoxColors.Name = "groupBoxColors";
groupBoxColors.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3);
groupBoxColors.Size = new System.Drawing.Size(184, 261);
groupBoxColors.TabIndex = 8;
groupBoxColors.TabStop = false;
groupBoxColors.Text = "Colors";
//
// panelPurple
//
panelPurple.BackColor = System.Drawing.Color.Fuchsia;
panelPurple.Location = new System.Drawing.Point(94, 207);
panelPurple.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
panelPurple.Name = "panelPurple";
panelPurple.Size = new System.Drawing.Size(49, 46);
panelPurple.TabIndex = 3;
//
// panelYellow
//
panelYellow.BackColor = System.Drawing.Color.Yellow;
panelYellow.Location = new System.Drawing.Point(94, 81);
panelYellow.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
panelYellow.Name = "panelYellow";
panelYellow.Size = new System.Drawing.Size(49, 46);
panelYellow.TabIndex = 1;
//
// panelBlue
//
panelBlue.BackColor = System.Drawing.Color.Cyan;
panelBlue.Location = new System.Drawing.Point(94, 144);
panelBlue.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
panelBlue.Name = "panelBlue";
panelBlue.Size = new System.Drawing.Size(49, 46);
panelBlue.TabIndex = 4;
//
// panelRed
//
panelRed.BackColor = System.Drawing.Color.Red;
panelRed.Location = new System.Drawing.Point(94, 18);
panelRed.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
panelRed.Name = "panelRed";
panelRed.Size = new System.Drawing.Size(49, 46);
panelRed.TabIndex = 1;
//
// panelDarkBlue
//
panelDarkBlue.BackColor = System.Drawing.Color.Blue;
panelDarkBlue.Location = new System.Drawing.Point(29, 207);
panelDarkBlue.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
panelDarkBlue.Name = "panelDarkBlue";
panelDarkBlue.Size = new System.Drawing.Size(49, 46);
panelDarkBlue.TabIndex = 5;
//
// panelOrange
//
panelOrange.BackColor = System.Drawing.Color.LightSalmon;
panelOrange.Location = new System.Drawing.Point(29, 81);
panelOrange.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
panelOrange.Name = "panelOrange";
panelOrange.Size = new System.Drawing.Size(49, 46);
panelOrange.TabIndex = 1;
//
// panelGreen
//
panelGreen.BackColor = System.Drawing.Color.Lime;
panelGreen.Location = new System.Drawing.Point(29, 144);
panelGreen.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
panelGreen.Name = "panelGreen";
panelGreen.Size = new System.Drawing.Size(49, 46);
panelGreen.TabIndex = 2;
//
// panelGray
//
panelGray.BackColor = System.Drawing.Color.Silver;
panelGray.Location = new System.Drawing.Point(29, 18);
panelGray.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
panelGray.Name = "panelGray";
panelGray.Size = new System.Drawing.Size(49, 46);
panelGray.TabIndex = 0;
//
// checkBoxFuelTank
//
checkBoxFuelTank.AutoSize = true;
checkBoxFuelTank.Location = new System.Drawing.Point(16, 135);
checkBoxFuelTank.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
checkBoxFuelTank.Name = "checkBoxFuelTank";
checkBoxFuelTank.Size = new System.Drawing.Size(74, 19);
checkBoxFuelTank.TabIndex = 7;
checkBoxFuelTank.Text = "Fuel tank";
checkBoxFuelTank.UseVisualStyleBackColor = true;
//
// checkBoxSmokeTube
//
checkBoxSmokeTube.AutoSize = true;
checkBoxSmokeTube.Location = new System.Drawing.Point(16, 112);
checkBoxSmokeTube.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
checkBoxSmokeTube.Name = "checkBoxSmokeTube";
checkBoxSmokeTube.Size = new System.Drawing.Size(89, 19);
checkBoxSmokeTube.TabIndex = 6;
checkBoxSmokeTube.Text = "Smoke tube";
checkBoxSmokeTube.UseVisualStyleBackColor = true;
//
// checkBoxLocoLine
//
checkBoxLocoLine.AutoSize = true;
checkBoxLocoLine.Location = new System.Drawing.Point(16, 162);
checkBoxLocoLine.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
checkBoxLocoLine.Name = "checkBoxLocoLine";
checkBoxLocoLine.Size = new System.Drawing.Size(74, 19);
checkBoxLocoLine.TabIndex = 5;
checkBoxLocoLine.Text = "Loco line";
checkBoxLocoLine.UseVisualStyleBackColor = true;
//
// numericWeight
//
numericWeight.Location = new System.Drawing.Point(58, 59);
numericWeight.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
numericWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericWeight.Name = "numericWeight";
numericWeight.Size = new System.Drawing.Size(140, 23);
numericWeight.TabIndex = 4;
numericWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// numericSpeed
//
numericSpeed.Location = new System.Drawing.Point(58, 27);
numericSpeed.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
numericSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericSpeed.Name = "numericSpeed";
numericSpeed.Size = new System.Drawing.Size(140, 23);
numericSpeed.TabIndex = 3;
numericSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// weightLabel
//
weightLabel.AutoSize = true;
weightLabel.Location = new System.Drawing.Point(10, 59);
weightLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
weightLabel.Name = "weightLabel";
weightLabel.Size = new System.Drawing.Size(39, 15);
weightLabel.TabIndex = 2;
weightLabel.Text = "weigh";
//
// speedLabel
//
speedLabel.AutoSize = true;
speedLabel.Location = new System.Drawing.Point(10, 29);
speedLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
speedLabel.Name = "speedLabel";
speedLabel.Size = new System.Drawing.Size(38, 15);
speedLabel.TabIndex = 1;
speedLabel.Text = "speed";
//
// panel9
//
panel9.AllowDrop = true;
panel9.Controls.Add(pictureBox);
panel9.Location = new System.Drawing.Point(233, 87);
panel9.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
panel9.Name = "panel9";
panel9.Size = new System.Drawing.Size(686, 390);
panel9.TabIndex = 11;
panel9.DragDrop += PanelObject_DragDrop;
panel9.DragEnter += PanelObject_DragEnter;
//
// pictureBox
//
pictureBox.Location = new System.Drawing.Point(16, 6);
pictureBox.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
pictureBox.Name = "pictureBox";
pictureBox.Size = new System.Drawing.Size(648, 381);
pictureBox.TabIndex = 0;
pictureBox.TabStop = false;
//
// buttonAdd
//
buttonAdd.Location = new System.Drawing.Point(233, 486);
buttonAdd.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new System.Drawing.Size(88, 27);
buttonAdd.TabIndex = 12;
buttonAdd.Text = "Add";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonOk_Click;
//
// buttonCancel
//
buttonCancel.Location = new System.Drawing.Point(601, 486);
buttonCancel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new System.Drawing.Size(88, 27);
buttonCancel.TabIndex = 13;
buttonCancel.Text = "Cancel";
buttonCancel.UseVisualStyleBackColor = true;
//
// labelColor
//
labelColor.AllowDrop = true;
labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
labelColor.Location = new System.Drawing.Point(233, 29);
labelColor.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
labelColor.Name = "labelColor";
labelColor.Size = new System.Drawing.Size(116, 26);
labelColor.TabIndex = 14;
labelColor.Text = "Color";
labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
labelColor.DragDrop += labelColor_DragDrop;
labelColor.DragEnter += labelColor_DragEnter;
//
// labelAdditionalColor
//
labelAdditionalColor.AllowDrop = true;
labelAdditionalColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
labelAdditionalColor.Location = new System.Drawing.Point(601, 28);
labelAdditionalColor.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
labelAdditionalColor.Name = "labelAdditionalColor";
labelAdditionalColor.Size = new System.Drawing.Size(116, 26);
labelAdditionalColor.TabIndex = 15;
labelAdditionalColor.Text = "Additional color";
labelAdditionalColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
labelAdditionalColor.DragDrop += labelColor_DragDrop;
labelAdditionalColor.DragEnter += labelColor_DragEnter;
//
// FormTrainConfig
//
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
ClientSize = new System.Drawing.Size(933, 558);
Controls.Add(labelAdditionalColor);
Controls.Add(labelColor);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(panel9);
Controls.Add(ParamsGroup);
Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Name = "FormTrainConfig";
Text = "FormTrainConfig";
ParamsGroup.ResumeLayout(false);
ParamsGroup.PerformLayout();
groupBoxColors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)numericWeight).EndInit();
((System.ComponentModel.ISupportInitialize)numericSpeed).EndInit();
panel9.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
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 panelPurple;
private System.Windows.Forms.Panel panelYellow;
private System.Windows.Forms.Panel panelBlue;
private System.Windows.Forms.Panel panelRed;
private System.Windows.Forms.Panel panelDarkBlue;
private System.Windows.Forms.Panel panelOrange;
private System.Windows.Forms.Panel panelGreen;
private System.Windows.Forms.Panel panelGray;
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,164 @@
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 Action<DrawingTrain> EventAddTrain;
/// <summary>
/// Конструктор
/// </summary>
public FormTrainConfig()
{
InitializeComponent();
panelGray.MouseDown += panelColor_MouseDown;
panelRed.MouseDown += panelColor_MouseDown;
panelOrange.MouseDown += panelColor_MouseDown;
panelYellow.MouseDown += panelColor_MouseDown;
panelGreen.MouseDown += panelColor_MouseDown;
panelBlue.MouseDown += panelColor_MouseDown;
panelDarkBlue.MouseDown += panelColor_MouseDown;
panelPurple.MouseDown += panelColor_MouseDown;
defaultColor = labelColor.BackColor;
buttonCancel.Click += (s, e) => Close();
}
/// <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(Action<DrawingTrain> 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.EntityTrain.setBodyColor((Color)e.Data.GetData(typeof(Color)));
break;
case "labelAdditionalColor":
if (!(_train is DrawingLoco))
return;
(_train.EntityTrain as EntityLoco).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

@ -1,123 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9F9C9603-3EF7-403E-A895-04EA0CBC5586}</ProjectGuid>
<TargetFramework>net7.0-windows</TargetFramework>
<OutputType>WinExe</OutputType>
<RootNamespace>Laba1Loco</RootNamespace>
<AssemblyName>Laba1Loco</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="AbstractStrategy.cs" />
<Compile Include="FormTrainCollection.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormTrainCollection.Designer.cs">
<DependentUpon>FormTrainCollection.cs</DependentUpon>
</Compile>
<Compile Include="TrainsGenericCollection.cs" />
<Compile Include="Direction.cs" />
<Compile Include="DrawingLoco.cs" />
<Compile Include="DrawingTrain.cs" />
<Compile Include="DrawningObjectTrain.cs" />
<Compile Include="EntityLoco.cs" />
<Compile Include="EntityTrain.cs" />
<Compile Include="FormLocomotive.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormLocomotive.Designer.cs">
<DependentUpon>FormLocomotive.cs</DependentUpon>
</Compile>
<Compile Include="IMoveableObject.cs" />
<Compile Include="MoveToBorder.cs" />
<Compile Include="MoveToCenter.cs" />
<Compile Include="ObjectParameters.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SetGeneric.cs" />
<Compile Include="Status.cs" />
<Compile Include="TrainsGenericStorage.cs" />
<EmbeddedResource Include="FormLocomotive.resx">
<DependentUpon>FormLocomotive.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormTrainCollection.resx">
<DependentUpon>FormTrainCollection.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="arow340x259.png" />
</ItemGroup>
<ItemGroup>
<None Include="arowDown340x259.png" />
</ItemGroup>
<ItemGroup>
<None Include="arowL340x259.png" />
</ItemGroup>
<ItemGroup>
<None Include="arowR340x259.png" />
</ItemGroup>
<ItemGroup>
<None Include="arowUp340x259.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанных со сборкой.
[assembly: AssemblyTitle("Laba1Loco")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Laba1Loco")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// COM, следует установить атрибут ComVisible в TRUE для этого типа.
[assembly: ComVisible(false)]
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("9f9c9603-3ef7-403e-a895-04ea0cbc5586")]
// Сведения о версии сборки состоят из указанных ниже четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,28 +1,24 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Laba1Loco.Properties
{
namespace Laba1Loco.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.8.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
public static Settings Default {
get {
return defaultInstance;
}
}

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);