не база

This commit is contained in:
Мельников Игорь 2022-12-07 20:40:32 +04:00
parent 47e50542c9
commit 299d762c6c
2 changed files with 135 additions and 10 deletions

View File

@ -29,6 +29,8 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.groupBoxConfig = new System.Windows.Forms.GroupBox(); 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.buttonCancel = new System.Windows.Forms.Button();
this.buttonOk = new System.Windows.Forms.Button(); this.buttonOk = new System.Windows.Forms.Button();
this.panelObject = new System.Windows.Forms.Panel(); this.panelObject = new System.Windows.Forms.Panel();
@ -36,6 +38,9 @@
this.labelColor = new System.Windows.Forms.Label(); this.labelColor = new System.Windows.Forms.Label();
this.pictureBoxObject = new System.Windows.Forms.PictureBox(); this.pictureBoxObject = new System.Windows.Forms.PictureBox();
this.labelModifiedObject = new System.Windows.Forms.Label(); 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.labelSimpleObject = new System.Windows.Forms.Label();
this.groupBoxColors = new System.Windows.Forms.GroupBox(); this.groupBoxColors = new System.Windows.Forms.GroupBox();
this.panelBlack = new System.Windows.Forms.Panel(); this.panelBlack = new System.Windows.Forms.Panel();
@ -53,6 +58,7 @@
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown(); this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
this.labelSpeed = new System.Windows.Forms.Label(); this.labelSpeed = new System.Windows.Forms.Label();
this.groupBoxConfig.SuspendLayout(); this.groupBoxConfig.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWheelsNumber)).BeginInit();
this.panelObject.SuspendLayout(); this.panelObject.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
this.groupBoxColors.SuspendLayout(); this.groupBoxColors.SuspendLayout();
@ -62,10 +68,15 @@
// //
// groupBoxConfig // groupBoxConfig
// //
this.groupBoxConfig.Controls.Add(this.labelWheelsNumber);
this.groupBoxConfig.Controls.Add(this.numericUpDownWheelsNumber);
this.groupBoxConfig.Controls.Add(this.buttonCancel); this.groupBoxConfig.Controls.Add(this.buttonCancel);
this.groupBoxConfig.Controls.Add(this.buttonOk); this.groupBoxConfig.Controls.Add(this.buttonOk);
this.groupBoxConfig.Controls.Add(this.panelObject); this.groupBoxConfig.Controls.Add(this.panelObject);
this.groupBoxConfig.Controls.Add(this.labelModifiedObject); 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.labelSimpleObject);
this.groupBoxConfig.Controls.Add(this.groupBoxColors); this.groupBoxConfig.Controls.Add(this.groupBoxColors);
this.groupBoxConfig.Controls.Add(this.checkBoxHasFuelTank); this.groupBoxConfig.Controls.Add(this.checkBoxHasFuelTank);
@ -76,11 +87,43 @@
this.groupBoxConfig.Controls.Add(this.labelSpeed); this.groupBoxConfig.Controls.Add(this.labelSpeed);
this.groupBoxConfig.Location = new System.Drawing.Point(12, 12); this.groupBoxConfig.Location = new System.Drawing.Point(12, 12);
this.groupBoxConfig.Name = "groupBoxConfig"; 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.TabIndex = 0;
this.groupBoxConfig.TabStop = false; this.groupBoxConfig.TabStop = false;
this.groupBoxConfig.Text = "Параметры"; 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 // buttonCancel
// //
this.buttonCancel.Location = new System.Drawing.Point(544, 193); this.buttonCancel.Location = new System.Drawing.Point(544, 193);
@ -158,6 +201,39 @@
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown); 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 // labelSimpleObject
// //
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
@ -344,12 +420,13 @@
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 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.Controls.Add(this.groupBoxConfig);
this.Name = "FormLocomotiveConfig"; this.Name = "FormLocomotiveConfig";
this.Text = "Создание объекта"; this.Text = "Создание объекта";
this.groupBoxConfig.ResumeLayout(false); this.groupBoxConfig.ResumeLayout(false);
this.groupBoxConfig.PerformLayout(); this.groupBoxConfig.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWheelsNumber)).EndInit();
this.panelObject.ResumeLayout(false); this.panelObject.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
this.groupBoxColors.ResumeLayout(false); this.groupBoxColors.ResumeLayout(false);
@ -385,5 +462,10 @@
private Label labelColor; private Label labelColor;
private Button buttonCancel; private Button buttonCancel;
private Button buttonOk; private Button buttonOk;
private Label labelRectOrnament;
private Label labelEllipseOrnament;
private Label labelNoOrnament;
private Label labelWheelsNumber;
private NumericUpDown numericUpDownWheelsNumber;
} }
} }

View File

@ -9,6 +9,10 @@
/// Переменная - выбранный локомотив /// Переменная - выбранный локомотив
/// </summary> /// </summary>
DrawningLocomotive _locomotive = null; DrawningLocomotive _locomotive = null;
/// <summary>
/// Делегат
/// </summary>
/// <param name="locomotive"></param>
public delegate void Action(DrawningLocomotive locomotive); public delegate void Action(DrawningLocomotive locomotive);
/// <summary> /// <summary>
/// Событие /// Событие
@ -73,7 +77,7 @@
/// <param name="e"></param> /// <param name="e"></param>
private void PanelObject_DragEnter(object sender, DragEventArgs e) 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; e.Effect = DragDropEffects.Copy;
} }
@ -89,15 +93,25 @@
/// <param name="e"></param> /// <param name="e"></param>
private void PanelObject_DragDrop(object sender, DragEventArgs e) 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 DrawningWarmlyLocomotive((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, 160, 85, Color.Black, checkBoxHasPipe.Checked, checkBoxHasFuelTank.Checked);
_locomotive = new DrawningLocomotive((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White); switch (e.Data.GetData(DataFormats.Text).ToString())
break; {
case "labelModifiedObject": case "labelSimpleObject":
_locomotive = new DrawningWarmlyLocomotive((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, 160, 85, Color.Black, checkBoxHasPipe.Checked, checkBoxHasFuelTank.Checked); _locomotive = new DrawningLocomotive((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White);
break; 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(); DrawLocomotive();
} }
/// <summary> /// <summary>
@ -158,5 +172,34 @@
EventAddLocomotive?.Invoke(_locomotive); EventAddLocomotive?.Invoke(_locomotive);
Close(); 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();
}
}
} }
} }