PIbd-21 Bakalskaya E.D. LabWork05 BASE #7

Closed
ekallin wants to merge 6 commits from LabWork05 into LabWork04
10 changed files with 684 additions and 21 deletions

View File

@ -24,10 +24,8 @@ namespace ProjectElectricLocomotive.DrawingObjects
return;
}
Pen pen = new(Color.Black);
Pen pen = new Pen(electricLocomotive.AdditionalColor);
Brush blackBrush = new SolidBrush(Color.Black);
Brush windows = new SolidBrush(Color.LightBlue);
Brush bodyColor = new SolidBrush(electricLocomotive.BodyColor);
Brush additionalBrush = new SolidBrush(electricLocomotive.AdditionalColor);
if (electricLocomotive.Horns)
@ -42,9 +40,14 @@ namespace ProjectElectricLocomotive.DrawingObjects
if (electricLocomotive.SeifBatteries)
{
g.FillRectangle(blackBrush, _startPosX + 80, _startPosY + 30, 5, 10);
g.FillRectangle(additionalBrush, _startPosX + 80, _startPosY + 30, 5, 10);
}
base.DrawTransport(g);
}
public void SetAddColor(Color color)
{
(EntityLocomotive as EntityElectricLocomotive).SetAdditionalColor(color);
}
}
}

View File

@ -14,9 +14,9 @@ namespace ProjectElectricLocomotive.DrawingObjects
{
public EntityLocomotive? EntityLocomotive { get; protected set; }
protected int _pictureWidth;
public int _pictureWidth;
protected int _pictureHeight;
public int _pictureHeight;
protected int _startPosX;
@ -196,5 +196,10 @@ namespace ProjectElectricLocomotive.DrawingObjects
DirectionType.Down => _startPosY + EntityLocomotive.Step < _pictureHeight,
};
}
public void SetColor(Color color)
{
(EntityLocomotive as EntityLocomotive).SetColor(color);
}
}
}

View File

@ -19,5 +19,10 @@ namespace ProjectElectricLocomotive.Entities
Horns = horns;
SeifBatteries = seifBatteries;
}
public void SetAdditionalColor(Color color)
{
AdditionalColor = color;
}
}
}

View File

@ -18,5 +18,10 @@ namespace ProjectElectricLocomotive.Entities
Weight = weight;
BodyColor = bodyColor;
}
public void SetColor(Color color)
{
BodyColor = color;
}
}
}

View File

@ -18,7 +18,6 @@ namespace ProjectElectricLocomotive
public partial class FormLocomotiveCollections : Form
{
private readonly LocomotiveGenericStorage _storage;
//private readonly LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive> _locomotives;
public FormLocomotiveCollections()
{
InitializeComponent();
@ -79,6 +78,15 @@ namespace ProjectElectricLocomotive
private void ButtonAddLocomotive_Click(object sender, EventArgs e)
{
var formLocomotiveConfig = new FormLocomotiveConfig();
formLocomotiveConfig.AddEvent(addLoco);
formLocomotiveConfig.Show();
}
public void addLoco(DrawingLocomotive loco)
{
loco._pictureWidth = pictureBoxCollections.Width;
loco._pictureHeight = pictureBoxCollections.Height;
if (listBoxStorage.SelectedIndex == -1) return;
@ -88,19 +96,15 @@ namespace ProjectElectricLocomotive
return;
}
FormElectricLocomotive form = new();
if (form.ShowDialog() == DialogResult.OK)
//проверяем, удалось ли нам загрузить объект
if (obj + loco > -1)
{
//проверяем, удалось ли нам загрузить объект
if (obj + form.SelectedLocomotive > -1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollections.Image = obj.ShowLocomotives();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
MessageBox.Show("Объект добавлен");
pictureBoxCollections.Image = obj.ShowLocomotives();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}

View File

@ -0,0 +1,394 @@
namespace ProjectElectricLocomotive
{
partial class FormLocomotiveConfig
{
/// <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.groupBoxObjectParameters = new System.Windows.Forms.GroupBox();
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
this.checkBoxSeifBatteries = new System.Windows.Forms.CheckBox();
this.checkBoxHorns = new System.Windows.Forms.CheckBox();
this.labelModifiedObject = new System.Windows.Forms.Label();
this.labelSimpleObject = new System.Windows.Forms.Label();
this.labelWeight = new System.Windows.Forms.Label();
this.labelSpeed = new System.Windows.Forms.Label();
this.groupBoxColors = new System.Windows.Forms.GroupBox();
this.panelPastelViolet = new System.Windows.Forms.FlowLayoutPanel();
this.panelPastelLilac = new System.Windows.Forms.FlowLayoutPanel();
this.panelSkyBlue = new System.Windows.Forms.FlowLayoutPanel();
this.panelPastelGreen = new System.Windows.Forms.FlowLayoutPanel();
this.panelPastelYellow = new System.Windows.Forms.FlowLayoutPanel();
this.panelPastelOrange = new System.Windows.Forms.FlowLayoutPanel();
this.panelPastelPink = new System.Windows.Forms.FlowLayoutPanel();
this.panelPastelRed = new System.Windows.Forms.FlowLayoutPanel();
this.panelObject = new System.Windows.Forms.Panel();
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
this.labelAddColor = new System.Windows.Forms.Label();
this.labelColor = new System.Windows.Forms.Label();
this.ButtonOk = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
this.groupBoxObjectParameters.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
this.groupBoxColors.SuspendLayout();
this.panelObject.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
this.SuspendLayout();
//
// groupBoxObjectParameters
//
this.groupBoxObjectParameters.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBoxObjectParameters.Controls.Add(this.numericUpDownWeight);
this.groupBoxObjectParameters.Controls.Add(this.numericUpDownSpeed);
this.groupBoxObjectParameters.Controls.Add(this.checkBoxSeifBatteries);
this.groupBoxObjectParameters.Controls.Add(this.checkBoxHorns);
this.groupBoxObjectParameters.Controls.Add(this.labelModifiedObject);
this.groupBoxObjectParameters.Controls.Add(this.labelSimpleObject);
this.groupBoxObjectParameters.Controls.Add(this.labelWeight);
this.groupBoxObjectParameters.Controls.Add(this.labelSpeed);
this.groupBoxObjectParameters.Controls.Add(this.groupBoxColors);
this.groupBoxObjectParameters.Location = new System.Drawing.Point(7, 12);
this.groupBoxObjectParameters.Name = "groupBoxObjectParameters";
this.groupBoxObjectParameters.Size = new System.Drawing.Size(792, 395);
this.groupBoxObjectParameters.TabIndex = 0;
this.groupBoxObjectParameters.TabStop = false;
this.groupBoxObjectParameters.Text = "Параметры";
//
// numericUpDownWeight
//
this.numericUpDownWeight.Location = new System.Drawing.Point(108, 92);
this.numericUpDownWeight.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.numericUpDownWeight.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDownWeight.Name = "numericUpDownWeight";
this.numericUpDownWeight.Size = new System.Drawing.Size(150, 27);
this.numericUpDownWeight.TabIndex = 8;
this.numericUpDownWeight.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// numericUpDownSpeed
//
this.numericUpDownSpeed.Location = new System.Drawing.Point(108, 34);
this.numericUpDownSpeed.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.numericUpDownSpeed.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
this.numericUpDownSpeed.Size = new System.Drawing.Size(150, 27);
this.numericUpDownSpeed.TabIndex = 7;
this.numericUpDownSpeed.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// checkBoxSeifBatteries
//
this.checkBoxSeifBatteries.AutoSize = true;
this.checkBoxSeifBatteries.Location = new System.Drawing.Point(19, 259);
this.checkBoxSeifBatteries.Name = "checkBoxSeifBatteries";
this.checkBoxSeifBatteries.Size = new System.Drawing.Size(297, 24);
this.checkBoxSeifBatteries.TabIndex = 6;
this.checkBoxSeifBatteries.Text = "Признак наличия батарейного отсека";
this.checkBoxSeifBatteries.UseVisualStyleBackColor = true;
//
// checkBoxHorns
//
this.checkBoxHorns.AutoSize = true;
this.checkBoxHorns.Location = new System.Drawing.Point(19, 174);
this.checkBoxHorns.Name = "checkBoxHorns";
this.checkBoxHorns.Size = new System.Drawing.Size(199, 24);
this.checkBoxHorns.TabIndex = 5;
this.checkBoxHorns.Text = "Признак наличия рогов";
this.checkBoxHorns.UseVisualStyleBackColor = true;
//
// labelModifiedObject
//
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelModifiedObject.Location = new System.Drawing.Point(655, 239);
this.labelModifiedObject.Name = "labelModifiedObject";
this.labelModifiedObject.Size = new System.Drawing.Size(113, 44);
this.labelModifiedObject.TabIndex = 4;
this.labelModifiedObject.Text = "Продвинутый";
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
//
// labelSimpleObject
//
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelSimpleObject.Location = new System.Drawing.Point(390, 239);
this.labelSimpleObject.Name = "labelSimpleObject";
this.labelSimpleObject.Size = new System.Drawing.Size(113, 44);
this.labelSimpleObject.TabIndex = 3;
this.labelSimpleObject.Text = "Простой";
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
//
// labelWeight
//
this.labelWeight.AutoSize = true;
this.labelWeight.Location = new System.Drawing.Point(19, 94);
this.labelWeight.Name = "labelWeight";
this.labelWeight.Size = new System.Drawing.Size(33, 20);
this.labelWeight.TabIndex = 2;
this.labelWeight.Text = "Вес";
//
// labelSpeed
//
this.labelSpeed.AutoSize = true;
this.labelSpeed.Location = new System.Drawing.Point(19, 36);
this.labelSpeed.Name = "labelSpeed";
this.labelSpeed.Size = new System.Drawing.Size(73, 20);
this.labelSpeed.TabIndex = 1;
this.labelSpeed.Text = "Скорость";
//
// groupBoxColors
//
this.groupBoxColors.Controls.Add(this.panelPastelViolet);
this.groupBoxColors.Controls.Add(this.panelPastelLilac);
this.groupBoxColors.Controls.Add(this.panelSkyBlue);
this.groupBoxColors.Controls.Add(this.panelPastelGreen);
this.groupBoxColors.Controls.Add(this.panelPastelYellow);
this.groupBoxColors.Controls.Add(this.panelPastelOrange);
this.groupBoxColors.Controls.Add(this.panelPastelPink);
this.groupBoxColors.Controls.Add(this.panelPastelRed);
this.groupBoxColors.Location = new System.Drawing.Point(390, 22);
this.groupBoxColors.Name = "groupBoxColors";
this.groupBoxColors.Size = new System.Drawing.Size(378, 176);
this.groupBoxColors.TabIndex = 0;
this.groupBoxColors.TabStop = false;
this.groupBoxColors.Text = "Цвета";
//
// panelPastelViolet
//
this.panelPastelViolet.AllowDrop = true;
this.panelPastelViolet.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
this.panelPastelViolet.Location = new System.Drawing.Point(281, 110);
this.panelPastelViolet.Name = "panelPastelViolet";
this.panelPastelViolet.Size = new System.Drawing.Size(40, 40);
this.panelPastelViolet.TabIndex = 3;
//
// panelPastelLilac
//
this.panelPastelLilac.AllowDrop = true;
this.panelPastelLilac.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
this.panelPastelLilac.Location = new System.Drawing.Point(207, 110);
this.panelPastelLilac.Name = "panelPastelLilac";
this.panelPastelLilac.Size = new System.Drawing.Size(40, 40);
this.panelPastelLilac.TabIndex = 4;
//
// panelSkyBlue
//
this.panelSkyBlue.AllowDrop = true;
this.panelSkyBlue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
this.panelSkyBlue.Location = new System.Drawing.Point(132, 110);
this.panelSkyBlue.Name = "panelSkyBlue";
this.panelSkyBlue.Size = new System.Drawing.Size(40, 40);
this.panelSkyBlue.TabIndex = 5;
//
// panelPastelGreen
//
this.panelPastelGreen.AllowDrop = true;
this.panelPastelGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.panelPastelGreen.Location = new System.Drawing.Point(55, 110);
this.panelPastelGreen.Name = "panelPastelGreen";
this.panelPastelGreen.Size = new System.Drawing.Size(40, 40);
this.panelPastelGreen.TabIndex = 2;
//
// panelPastelYellow
//
this.panelPastelYellow.AllowDrop = true;
this.panelPastelYellow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.panelPastelYellow.Location = new System.Drawing.Point(281, 35);
this.panelPastelYellow.Name = "panelPastelYellow";
this.panelPastelYellow.Size = new System.Drawing.Size(40, 40);
this.panelPastelYellow.TabIndex = 1;
//
// panelPastelOrange
//
this.panelPastelOrange.AllowDrop = true;
this.panelPastelOrange.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
this.panelPastelOrange.Location = new System.Drawing.Point(207, 35);
this.panelPastelOrange.Name = "panelPastelOrange";
this.panelPastelOrange.Size = new System.Drawing.Size(40, 40);
this.panelPastelOrange.TabIndex = 1;
//
// panelPastelPink
//
this.panelPastelPink.AllowDrop = true;
this.panelPastelPink.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
this.panelPastelPink.Location = new System.Drawing.Point(132, 35);
this.panelPastelPink.Name = "panelPastelPink";
this.panelPastelPink.Size = new System.Drawing.Size(40, 40);
this.panelPastelPink.TabIndex = 1;
//
// panelPastelRed
//
this.panelPastelRed.AllowDrop = true;
this.panelPastelRed.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
this.panelPastelRed.Location = new System.Drawing.Point(55, 35);
this.panelPastelRed.Name = "panelPastelRed";
this.panelPastelRed.Size = new System.Drawing.Size(40, 40);
this.panelPastelRed.TabIndex = 0;
this.panelPastelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelObject
//
this.panelObject.AllowDrop = true;
this.panelObject.Controls.Add(this.pictureBoxObject);
this.panelObject.Controls.Add(this.labelAddColor);
this.panelObject.Controls.Add(this.labelColor);
this.panelObject.Location = new System.Drawing.Point(812, 25);
this.panelObject.Name = "panelObject";
this.panelObject.Size = new System.Drawing.Size(392, 300);
this.panelObject.TabIndex = 1;
this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
//
// pictureBoxObject
//
this.pictureBoxObject.Location = new System.Drawing.Point(19, 83);
this.pictureBoxObject.Name = "pictureBoxObject";
this.pictureBoxObject.Size = new System.Drawing.Size(354, 198);
this.pictureBoxObject.TabIndex = 7;
this.pictureBoxObject.TabStop = false;
//
// labelAddColor
//
this.labelAddColor.AllowDrop = true;
this.labelAddColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelAddColor.Location = new System.Drawing.Point(260, 21);
this.labelAddColor.Name = "labelAddColor";
this.labelAddColor.Size = new System.Drawing.Size(113, 44);
this.labelAddColor.TabIndex = 6;
this.labelAddColor.Text = "Доп. Цвет";
this.labelAddColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelAddColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
this.labelAddColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
//
// labelColor
//
this.labelColor.AllowDrop = true;
this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelColor.Location = new System.Drawing.Point(19, 21);
this.labelColor.Name = "labelColor";
this.labelColor.Size = new System.Drawing.Size(113, 44);
this.labelColor.TabIndex = 5;
this.labelColor.Text = "Цвет";
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_DragDrop);
//
// ButtonOk
//
this.ButtonOk.Location = new System.Drawing.Point(813, 341);
this.ButtonOk.Name = "ButtonOk";
this.ButtonOk.Size = new System.Drawing.Size(131, 49);
this.ButtonOk.TabIndex = 2;
this.ButtonOk.Text = "Добавить";
this.ButtonOk.UseVisualStyleBackColor = true;
// this.ButtonOk.Click += new System.EventHandler(this.ButtonOk_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(1072, 341);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(131, 49);
this.buttonCancel.TabIndex = 3;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// FormLocomotiveConfig
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1219, 419);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.ButtonOk);
this.Controls.Add(this.panelObject);
this.Controls.Add(this.groupBoxObjectParameters);
this.Name = "FormLocomotiveConfig";
this.Text = "FormLocomotiveConfig";
this.groupBoxObjectParameters.ResumeLayout(false);
this.groupBoxObjectParameters.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
this.groupBoxColors.ResumeLayout(false);
this.panelObject.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
this.ResumeLayout(false);
}
#endregion
private GroupBox groupBoxObjectParameters;
private Label labelModifiedObject;
private Label labelSimpleObject;
private Label labelWeight;
private Label labelSpeed;
private GroupBox groupBoxColors;
private CheckBox checkBoxSeifBatteries;
private CheckBox checkBoxHorns;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private FlowLayoutPanel panelPastelViolet;
private FlowLayoutPanel panelPastelLilac;
private FlowLayoutPanel panelSkyBlue;
private FlowLayoutPanel panelPastelGreen;
private FlowLayoutPanel panelPastelYellow;
private FlowLayoutPanel panelPastelOrange;
private FlowLayoutPanel panelPastelPink;
private FlowLayoutPanel panelPastelRed;
private Panel panelObject;
private PictureBox pictureBoxObject;
private Label labelAddColor;
private Label labelColor;
private Button ButtonOk;
private Button buttonCancel;
private System.ComponentModel.BackgroundWorker backgroundWorker1;
}
}

View File

@ -0,0 +1,186 @@
using ProjectElectricLocomotive.DrawingObjects;
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 ProjectElectricLocomotive
{
public partial class FormLocomotiveConfig : Form
{
/// <summary>
/// Переменная-выбранный локомотив
/// </summary>
DrawingLocomotive? _loco = null;
/// <summary>
/// Событие
/// </summary>
private event Action<DrawingLocomotive>? EventAddLoco;
public FormLocomotiveConfig()
{
InitializeComponent();
panelPastelRed.MouseDown += PanelColor_MouseDown;
panelPastelPink.MouseDown += PanelColor_MouseDown;
panelPastelOrange.MouseDown += PanelColor_MouseDown;
panelPastelYellow.MouseDown += PanelColor_MouseDown;
panelSkyBlue.MouseDown += PanelColor_MouseDown;
panelPastelGreen.MouseDown += PanelColor_MouseDown;
panelPastelLilac.MouseDown += PanelColor_MouseDown;
panelPastelViolet.MouseDown += PanelColor_MouseDown;
buttonCancel.Click += (sender, e) => Close();
}
/// <summary>
/// Добавление события
/// </summary>
/// <param name="ev">Привязанный метод</param>
public void AddEvent(Action<DrawingLocomotive> ev)
{
if (EventAddLoco == null)
{
EventAddLoco = ev;
}
else
{
EventAddLoco += ev;
}
}
/// <summary>
/// Отрисовать Loco
/// </summary>
private void DrawLoco()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_loco?.SetPosition(10, 10);
_loco?.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
/// <summary>
/// Передаем информацию при нажатии на Label
/// </summary>
/// <param name="sender"><labelSimpleObject/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 "labelSimpleObject":
_loco = new DrawingLocomotive(
(int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value,
Color.White,
pictureBoxObject.Width,
pictureBoxObject.Height
);
break;
case "labelModifiedObject":
_loco = new DrawingElectricLocomotive(
(int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value,
Color.White,
Color.Black,
checkBoxHorns.Checked,
checkBoxSeifBatteries.Checked,
pictureBoxObject.Width,
pictureBoxObject.Height
);
break;
}
DrawLoco();
}
// НЕ УВЕРЕНА, ЧТО ВЕРНО, драгдроп для цветов
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
DragDropEffects.Move | DragDropEffects.Copy);
}
private void LabelColor_DragDrop(object sender, DragEventArgs e)
{
((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color));
switch (((Label)sender).Name)
{
case "labelColor":
_loco.SetColor((Color)e.Data.GetData(typeof(Color)));
break;
case "labelAddColor":
if (_loco is not DrawingLocomotive) return;
else
{
(_loco as DrawingElectricLocomotive).SetAddColor((Color)e.Data.GetData(typeof(Color)));
}
break;
}
DrawLoco();
}
private void LabelColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
// TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
/// <summary>
/// Добавление loco
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonOk_Click(object sender, EventArgs e)
{
EventAddLoco?.Invoke(_loco);
Close();
}
}
}

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="backgroundWorker1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -84,7 +84,6 @@ namespace ProjectElectricLocomotive.Generics
private void DrawObjects(Graphics g)
{
int HeightObjCount = _pictureHeight / _placeSizeHeight;
int WidthObjCount = _pictureWidth / _placeSizeWidth;
for (int i = 0; i < _collection.Count; i++)
{
T? type = _collection[i];

View File

@ -71,7 +71,6 @@ namespace ProjectElectricLocomotive.Generics
{
get
{
// TODO Продумать логику получения набора
if (_locomotivesStorage.ContainsKey(ind))
{
return _locomotivesStorage[ind];