ISEbd-21 Melnikov I. O. Lab work 05 advanced #5
@ -29,6 +29,8 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.groupBoxConfig = new System.Windows.Forms.GroupBox();
|
||||
this.labelWheelsNumber = new System.Windows.Forms.Label();
|
||||
this.numericUpDownWheelsNumber = new System.Windows.Forms.NumericUpDown();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonOk = new System.Windows.Forms.Button();
|
||||
this.panelObject = new System.Windows.Forms.Panel();
|
||||
@ -36,6 +38,9 @@
|
||||
this.labelColor = new System.Windows.Forms.Label();
|
||||
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
|
||||
this.labelModifiedObject = new System.Windows.Forms.Label();
|
||||
this.labelRectOrnament = new System.Windows.Forms.Label();
|
||||
this.labelEllipseOrnament = new System.Windows.Forms.Label();
|
||||
this.labelNoOrnament = new System.Windows.Forms.Label();
|
||||
this.labelSimpleObject = new System.Windows.Forms.Label();
|
||||
this.groupBoxColors = new System.Windows.Forms.GroupBox();
|
||||
this.panelBlack = new System.Windows.Forms.Panel();
|
||||
@ -53,6 +58,7 @@
|
||||
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelSpeed = new System.Windows.Forms.Label();
|
||||
this.groupBoxConfig.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWheelsNumber)).BeginInit();
|
||||
this.panelObject.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
|
||||
this.groupBoxColors.SuspendLayout();
|
||||
@ -62,10 +68,15 @@
|
||||
//
|
||||
// groupBoxConfig
|
||||
//
|
||||
this.groupBoxConfig.Controls.Add(this.labelWheelsNumber);
|
||||
this.groupBoxConfig.Controls.Add(this.numericUpDownWheelsNumber);
|
||||
this.groupBoxConfig.Controls.Add(this.buttonCancel);
|
||||
this.groupBoxConfig.Controls.Add(this.buttonOk);
|
||||
this.groupBoxConfig.Controls.Add(this.panelObject);
|
||||
this.groupBoxConfig.Controls.Add(this.labelModifiedObject);
|
||||
this.groupBoxConfig.Controls.Add(this.labelRectOrnament);
|
||||
this.groupBoxConfig.Controls.Add(this.labelEllipseOrnament);
|
||||
this.groupBoxConfig.Controls.Add(this.labelNoOrnament);
|
||||
this.groupBoxConfig.Controls.Add(this.labelSimpleObject);
|
||||
this.groupBoxConfig.Controls.Add(this.groupBoxColors);
|
||||
this.groupBoxConfig.Controls.Add(this.checkBoxHasFuelTank);
|
||||
@ -76,11 +87,43 @@
|
||||
this.groupBoxConfig.Controls.Add(this.labelSpeed);
|
||||
this.groupBoxConfig.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBoxConfig.Name = "groupBoxConfig";
|
||||
this.groupBoxConfig.Size = new System.Drawing.Size(674, 231);
|
||||
this.groupBoxConfig.Size = new System.Drawing.Size(674, 337);
|
||||
this.groupBoxConfig.TabIndex = 0;
|
||||
this.groupBoxConfig.TabStop = false;
|
||||
this.groupBoxConfig.Text = "Параметры";
|
||||
//
|
||||
// labelWheelsNumber
|
||||
//
|
||||
this.labelWheelsNumber.AutoSize = true;
|
||||
this.labelWheelsNumber.Location = new System.Drawing.Point(233, 195);
|
||||
this.labelWheelsNumber.Name = "labelWheelsNumber";
|
||||
this.labelWheelsNumber.Size = new System.Drawing.Size(107, 15);
|
||||
this.labelWheelsNumber.TabIndex = 1;
|
||||
this.labelWheelsNumber.Text = "Количество колёс";
|
||||
//
|
||||
// numericUpDownWheelsNumber
|
||||
//
|
||||
this.numericUpDownWheelsNumber.Location = new System.Drawing.Point(200, 193);
|
||||
this.numericUpDownWheelsNumber.Maximum = new decimal(new int[] {
|
||||
4,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownWheelsNumber.Minimum = new decimal(new int[] {
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownWheelsNumber.Name = "numericUpDownWheelsNumber";
|
||||
this.numericUpDownWheelsNumber.Size = new System.Drawing.Size(27, 23);
|
||||
this.numericUpDownWheelsNumber.TabIndex = 1;
|
||||
this.numericUpDownWheelsNumber.Value = new decimal(new int[] {
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownWheelsNumber.ValueChanged += new System.EventHandler(this.numericUpDownWheelsNumber_ValueChanged);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(544, 193);
|
||||
@ -158,6 +201,39 @@
|
||||
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
|
||||
//
|
||||
// labelRectOrnament
|
||||
//
|
||||
this.labelRectOrnament.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelRectOrnament.Location = new System.Drawing.Point(6, 168);
|
||||
this.labelRectOrnament.Name = "labelRectOrnament";
|
||||
this.labelRectOrnament.Size = new System.Drawing.Size(188, 27);
|
||||
this.labelRectOrnament.TabIndex = 7;
|
||||
this.labelRectOrnament.Text = "Прямоугольный орнамент";
|
||||
this.labelRectOrnament.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelRectOrnament.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelOrnament_MouseDown);
|
||||
//
|
||||
// labelEllipseOrnament
|
||||
//
|
||||
this.labelEllipseOrnament.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelEllipseOrnament.Location = new System.Drawing.Point(6, 195);
|
||||
this.labelEllipseOrnament.Name = "labelEllipseOrnament";
|
||||
this.labelEllipseOrnament.Size = new System.Drawing.Size(188, 27);
|
||||
this.labelEllipseOrnament.TabIndex = 7;
|
||||
this.labelEllipseOrnament.Text = "Круглый орнамент";
|
||||
this.labelEllipseOrnament.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelEllipseOrnament.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelOrnament_MouseDown);
|
||||
//
|
||||
// labelNoOrnament
|
||||
//
|
||||
this.labelNoOrnament.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelNoOrnament.Location = new System.Drawing.Point(6, 141);
|
||||
this.labelNoOrnament.Name = "labelNoOrnament";
|
||||
this.labelNoOrnament.Size = new System.Drawing.Size(188, 27);
|
||||
this.labelNoOrnament.TabIndex = 7;
|
||||
this.labelNoOrnament.Text = "Без орнамента";
|
||||
this.labelNoOrnament.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelNoOrnament.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelOrnament_MouseDown);
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
@ -344,12 +420,13 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(693, 248);
|
||||
this.ClientSize = new System.Drawing.Size(693, 246);
|
||||
this.Controls.Add(this.groupBoxConfig);
|
||||
this.Name = "FormLocomotiveConfig";
|
||||
this.Text = "Создание объекта";
|
||||
this.groupBoxConfig.ResumeLayout(false);
|
||||
this.groupBoxConfig.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWheelsNumber)).EndInit();
|
||||
this.panelObject.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
|
||||
this.groupBoxColors.ResumeLayout(false);
|
||||
@ -385,5 +462,10 @@
|
||||
private Label labelColor;
|
||||
private Button buttonCancel;
|
||||
private Button buttonOk;
|
||||
private Label labelRectOrnament;
|
||||
private Label labelEllipseOrnament;
|
||||
private Label labelNoOrnament;
|
||||
private Label labelWheelsNumber;
|
||||
private NumericUpDown numericUpDownWheelsNumber;
|
||||
}
|
||||
}
|
@ -9,6 +9,10 @@
|
||||
/// Переменная - выбранный локомотив
|
||||
/// </summary>
|
||||
DrawningLocomotive _locomotive = null;
|
||||
/// <summary>
|
||||
/// Делегат
|
||||
/// </summary>
|
||||
/// <param name="locomotive"></param>
|
||||
public delegate void Action(DrawningLocomotive locomotive);
|
||||
/// <summary>
|
||||
/// Событие
|
||||
@ -73,7 +77,7 @@
|
||||
/// <param name="e"></param>
|
||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.Text))
|
||||
if (e.Data.GetDataPresent(DataFormats.Text) || e.Data.GetDataPresent(typeof(IDrawningAdditionalElements)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
@ -89,15 +93,25 @@
|
||||
/// <param name="e"></param>
|
||||
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data.GetData(DataFormats.Text).ToString())
|
||||
if (e.Data.GetDataPresent(DataFormats.Text))
|
||||
{
|
||||
case "labelSimpleObject":
|
||||
_locomotive = new DrawningLocomotive((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White);
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
_locomotive = new DrawningWarmlyLocomotive((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, 160, 85, Color.Black, checkBoxHasPipe.Checked, checkBoxHasFuelTank.Checked);
|
||||
break;
|
||||
_locomotive = new DrawningWarmlyLocomotive((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, 160, 85, Color.Black, checkBoxHasPipe.Checked, checkBoxHasFuelTank.Checked);
|
||||
switch (e.Data.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "labelSimpleObject":
|
||||
_locomotive = new DrawningLocomotive((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White);
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
_locomotive = new DrawningWarmlyLocomotive((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, 160, 85, Color.Black, checkBoxHasPipe.Checked, checkBoxHasFuelTank.Checked);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (_locomotive != null)
|
||||
{
|
||||
var ornament = e.Data.GetData(typeof(IDrawningAdditionalElements));
|
||||
_locomotive.AdditionalElements = (IDrawningAdditionalElements)ornament;
|
||||
}
|
||||
_locomotive.AdditionalElements.WheelsNum = (int)numericUpDownWheelsNumber.Value;
|
||||
DrawLocomotive();
|
||||
}
|
||||
/// <summary>
|
||||
@ -158,5 +172,34 @@
|
||||
EventAddLocomotive?.Invoke(_locomotive);
|
||||
Close();
|
||||
}
|
||||
|
||||
private void LabelOrnament_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
IDrawningAdditionalElements selectedOrnament = new DrawningWheels();
|
||||
switch ((sender as Label).Name)
|
||||
{
|
||||
case "labelNoOrnament":
|
||||
selectedOrnament = new DrawningWheels();
|
||||
break;
|
||||
case "labelRectOrnament":
|
||||
selectedOrnament = new DrawningRectOrnament();
|
||||
break;
|
||||
case "labelEllipseOrnament":
|
||||
selectedOrnament = new DrawningEllipseOrnament();
|
||||
break;
|
||||
}
|
||||
var dataObj = new DataObject();
|
||||
dataObj.SetData(typeof(IDrawningAdditionalElements), selectedOrnament);
|
||||
(sender as Label).DoDragDrop(dataObj, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
private void numericUpDownWheelsNumber_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (_locomotive != null)
|
||||
{
|
||||
_locomotive.AdditionalElements.WheelsNum = (int)numericUpDownWheelsNumber.Value;
|
||||
DrawLocomotive();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user