ПИбд-23 Валова А. Д. _Lab_5 #6
11
DumpTruck/DumpTruck/ClassDelegate.cs
Normal file
11
DumpTruck/DumpTruck/ClassDelegate.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DumpTruck.DrawningObjects;
|
||||
|
||||
namespace DumpTruck
|
||||
{
|
||||
public delegate void CarDelegate(DrawningCar car);
|
||||
|
||||
}
|
@ -69,6 +69,15 @@ namespace DumpTruck.DrawningObjects
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setAddColor(Color color)
|
||||
{
|
||||
if (EntityCar is EntityDumpTruck dumpTruck)
|
||||
{
|
||||
dumpTruck.setAddColor(color);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ namespace DumpTruck.DrawningObjects
|
||||
|
||||
public DrawningCar(int speed, double weight, Color bodyColor, int width, int height)
|
||||
{
|
||||
if(width < _carWidth || height < _carHeight)
|
||||
if (width < _carWidth || height < _carHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -58,7 +58,7 @@ namespace DumpTruck.DrawningObjects
|
||||
|
||||
EntityCar = new EntityCar(speed, weight, bodyColor);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ width, int height, int carWidth, int carHeight)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool CanMove(DirectionType direction)
|
||||
{
|
||||
if (EntityCar == null)
|
||||
@ -144,7 +144,7 @@ width, int height, int carWidth, int carHeight)
|
||||
|
||||
Pen pen = new Pen(Color.Black);
|
||||
Brush brush = new SolidBrush(EntityCar.BodyColor);
|
||||
|
||||
|
||||
//границы автомобиля
|
||||
g.FillRectangle(brush, _startPosX, _startPosY + 35, 110, 10);
|
||||
g.FillRectangle(brush, _startPosX + 85, _startPosY, 25, 35);
|
||||
@ -154,5 +154,9 @@ width, int height, int carWidth, int carHeight)
|
||||
|
||||
}
|
||||
|
||||
public void setColor(Color color)
|
||||
{
|
||||
EntityCar.setColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,5 +37,10 @@ namespace DumpTruck.Entities
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
|
||||
public void setColor(Color color)
|
||||
{
|
||||
BodyColor = color;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,11 @@ namespace DumpTruck.Entities
|
||||
BodyKit = bodyKit;
|
||||
Tent = tent;
|
||||
}
|
||||
|
||||
public void setAddColor(Color color)
|
||||
{
|
||||
AdditionalColor = color;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace DumpTruck
|
||||
{
|
||||
public partial class FormCarCollection : Form
|
||||
{
|
||||
//private readonly CarsGenericCollection<DrawningCar, DrawningObjectCar> _cars;
|
||||
|
||||
private readonly CarsGenericStorage _storage;
|
||||
public FormCarCollection()
|
||||
{
|
||||
@ -28,16 +28,6 @@ namespace DumpTruck
|
||||
pictureBoxCollection.Height);
|
||||
}
|
||||
|
||||
private void Form2_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void pictureBoxCollection_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void ReloadObjects()
|
||||
{
|
||||
int index = listBoxStorages.SelectedIndex;
|
||||
@ -63,26 +53,27 @@ pictureBoxCollection.Height);
|
||||
|
||||
private void ButtonAddCar_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
|
||||
|
||||
if (obj == null)
|
||||
{
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
FormDumpTruck form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
|
||||
|
||||
FormCarConfig form = new FormCarConfig();
|
||||
form.Show();
|
||||
Action<DrawningCar>? carDelegate = new((m) =>
|
||||
{
|
||||
|
||||
if (obj + form.SelectedCar != -1)
|
||||
int q = obj + m;
|
||||
|
||||
if (q != -1)
|
||||
{
|
||||
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowCars();
|
||||
}
|
||||
@ -90,7 +81,13 @@ pictureBoxCollection.Height);
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Action<Color>? ColorDelegate = new((m) =>
|
||||
{
|
||||
MessageBox.Show(m.ToString());
|
||||
});
|
||||
form.AddEvent(carDelegate);
|
||||
|
||||
}
|
||||
|
||||
|
390
DumpTruck/DumpTruck/FormCarConfig.Designer.cs
generated
Normal file
390
DumpTruck/DumpTruck/FormCarConfig.Designer.cs
generated
Normal file
@ -0,0 +1,390 @@
|
||||
namespace DumpTruck
|
||||
{
|
||||
partial class FormCarConfig
|
||||
{
|
||||
/// <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.groupBoxParameters = new System.Windows.Forms.GroupBox();
|
||||
this.labelAdvancedObject = new System.Windows.Forms.Label();
|
||||
this.labelBaseObject = new System.Windows.Forms.Label();
|
||||
this.groupBoxColors = new System.Windows.Forms.GroupBox();
|
||||
this.panelWhite = new System.Windows.Forms.Panel();
|
||||
this.panelPurple = new System.Windows.Forms.Panel();
|
||||
this.panelLightBlue = new System.Windows.Forms.Panel();
|
||||
this.panelYellow = new System.Windows.Forms.Panel();
|
||||
this.panelBlue = new System.Windows.Forms.Panel();
|
||||
this.panelBlack = new System.Windows.Forms.Panel();
|
||||
this.panelOrange = new System.Windows.Forms.Panel();
|
||||
this.panelRed = new System.Windows.Forms.Panel();
|
||||
this.checkBoxTent = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxKit = new System.Windows.Forms.CheckBox();
|
||||
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
|
||||
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelWeight = new System.Windows.Forms.Label();
|
||||
this.labelSpeed = new System.Windows.Forms.Label();
|
||||
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
|
||||
this.panelObject = new System.Windows.Forms.Panel();
|
||||
this.labelColor = new System.Windows.Forms.Label();
|
||||
this.labelAddColor = new System.Windows.Forms.Label();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.buttonCanel = new System.Windows.Forms.Button();
|
||||
this.groupBoxParameters.SuspendLayout();
|
||||
this.groupBoxColors.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
|
||||
this.panelObject.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBoxParameters
|
||||
//
|
||||
this.groupBoxParameters.Controls.Add(this.labelAdvancedObject);
|
||||
this.groupBoxParameters.Controls.Add(this.labelBaseObject);
|
||||
this.groupBoxParameters.Controls.Add(this.groupBoxColors);
|
||||
this.groupBoxParameters.Controls.Add(this.checkBoxTent);
|
||||
this.groupBoxParameters.Controls.Add(this.checkBoxKit);
|
||||
this.groupBoxParameters.Controls.Add(this.numericUpDownWeight);
|
||||
this.groupBoxParameters.Controls.Add(this.numericUpDownSpeed);
|
||||
this.groupBoxParameters.Controls.Add(this.labelWeight);
|
||||
this.groupBoxParameters.Controls.Add(this.labelSpeed);
|
||||
this.groupBoxParameters.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBoxParameters.Name = "groupBoxParameters";
|
||||
this.groupBoxParameters.Size = new System.Drawing.Size(589, 328);
|
||||
this.groupBoxParameters.TabIndex = 0;
|
||||
this.groupBoxParameters.TabStop = false;
|
||||
this.groupBoxParameters.Text = "Параметры";
|
||||
//
|
||||
// labelAdvancedObject
|
||||
//
|
||||
this.labelAdvancedObject.AllowDrop = true;
|
||||
this.labelAdvancedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelAdvancedObject.Location = new System.Drawing.Point(406, 271);
|
||||
this.labelAdvancedObject.Name = "labelAdvancedObject";
|
||||
this.labelAdvancedObject.Size = new System.Drawing.Size(98, 35);
|
||||
this.labelAdvancedObject.TabIndex = 6;
|
||||
this.labelAdvancedObject.Text = "Продвинутый";
|
||||
this.labelAdvancedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelAdvancedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
|
||||
//
|
||||
// labelBaseObject
|
||||
//
|
||||
this.labelBaseObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelBaseObject.Location = new System.Drawing.Point(295, 271);
|
||||
this.labelBaseObject.Name = "labelBaseObject";
|
||||
this.labelBaseObject.Size = new System.Drawing.Size(98, 35);
|
||||
this.labelBaseObject.TabIndex = 2;
|
||||
this.labelBaseObject.Text = "Простой";
|
||||
this.labelBaseObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelBaseObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
|
||||
//
|
||||
// groupBoxColors
|
||||
//
|
||||
this.groupBoxColors.Controls.Add(this.panelWhite);
|
||||
this.groupBoxColors.Controls.Add(this.panelPurple);
|
||||
this.groupBoxColors.Controls.Add(this.panelLightBlue);
|
||||
this.groupBoxColors.Controls.Add(this.panelYellow);
|
||||
this.groupBoxColors.Controls.Add(this.panelBlue);
|
||||
this.groupBoxColors.Controls.Add(this.panelBlack);
|
||||
this.groupBoxColors.Controls.Add(this.panelOrange);
|
||||
this.groupBoxColors.Controls.Add(this.panelRed);
|
||||
this.groupBoxColors.Location = new System.Drawing.Point(250, 22);
|
||||
this.groupBoxColors.Name = "groupBoxColors";
|
||||
this.groupBoxColors.Size = new System.Drawing.Size(303, 246);
|
||||
this.groupBoxColors.TabIndex = 1;
|
||||
this.groupBoxColors.TabStop = false;
|
||||
this.groupBoxColors.Text = "Цвета";
|
||||
//
|
||||
// panelWhite
|
||||
//
|
||||
this.panelWhite.AllowDrop = true;
|
||||
this.panelWhite.BackColor = System.Drawing.Color.White;
|
||||
this.panelWhite.Location = new System.Drawing.Point(230, 106);
|
||||
this.panelWhite.Name = "panelWhite";
|
||||
this.panelWhite.Size = new System.Drawing.Size(57, 53);
|
||||
this.panelWhite.TabIndex = 1;
|
||||
//
|
||||
// panelPurple
|
||||
//
|
||||
this.panelPurple.AllowDrop = true;
|
||||
this.panelPurple.BackColor = System.Drawing.Color.Fuchsia;
|
||||
this.panelPurple.Location = new System.Drawing.Point(156, 106);
|
||||
this.panelPurple.Name = "panelPurple";
|
||||
this.panelPurple.Size = new System.Drawing.Size(57, 53);
|
||||
this.panelPurple.TabIndex = 1;
|
||||
//
|
||||
// panelLightBlue
|
||||
//
|
||||
this.panelLightBlue.AllowDrop = true;
|
||||
this.panelLightBlue.BackColor = System.Drawing.Color.Cyan;
|
||||
this.panelLightBlue.Location = new System.Drawing.Point(13, 106);
|
||||
this.panelLightBlue.Name = "panelLightBlue";
|
||||
this.panelLightBlue.Size = new System.Drawing.Size(57, 53);
|
||||
this.panelLightBlue.TabIndex = 1;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
this.panelYellow.AllowDrop = true;
|
||||
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
|
||||
this.panelYellow.Location = new System.Drawing.Point(156, 35);
|
||||
this.panelYellow.Name = "panelYellow";
|
||||
this.panelYellow.Size = new System.Drawing.Size(57, 53);
|
||||
this.panelYellow.TabIndex = 1;
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
this.panelBlue.AllowDrop = true;
|
||||
this.panelBlue.BackColor = System.Drawing.Color.Blue;
|
||||
this.panelBlue.Location = new System.Drawing.Point(86, 106);
|
||||
this.panelBlue.Name = "panelBlue";
|
||||
this.panelBlue.Size = new System.Drawing.Size(57, 53);
|
||||
this.panelBlue.TabIndex = 1;
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
this.panelBlack.AllowDrop = true;
|
||||
this.panelBlack.BackColor = System.Drawing.Color.Black;
|
||||
this.panelBlack.Location = new System.Drawing.Point(230, 35);
|
||||
this.panelBlack.Name = "panelBlack";
|
||||
this.panelBlack.Size = new System.Drawing.Size(57, 53);
|
||||
this.panelBlack.TabIndex = 1;
|
||||
//
|
||||
// panelOrange
|
||||
//
|
||||
this.panelOrange.AllowDrop = true;
|
||||
this.panelOrange.BackColor = System.Drawing.Color.Orange;
|
||||
this.panelOrange.Location = new System.Drawing.Point(86, 35);
|
||||
this.panelOrange.Name = "panelOrange";
|
||||
this.panelOrange.Size = new System.Drawing.Size(57, 53);
|
||||
this.panelOrange.TabIndex = 1;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
this.panelRed.AllowDrop = true;
|
||||
this.panelRed.BackColor = System.Drawing.Color.Red;
|
||||
this.panelRed.Location = new System.Drawing.Point(13, 35);
|
||||
this.panelRed.Name = "panelRed";
|
||||
this.panelRed.Size = new System.Drawing.Size(57, 53);
|
||||
this.panelRed.TabIndex = 0;
|
||||
//
|
||||
// checkBoxTent
|
||||
//
|
||||
this.checkBoxTent.AutoSize = true;
|
||||
this.checkBoxTent.Location = new System.Drawing.Point(18, 164);
|
||||
this.checkBoxTent.Name = "checkBoxTent";
|
||||
this.checkBoxTent.Size = new System.Drawing.Size(155, 19);
|
||||
this.checkBoxTent.TabIndex = 1;
|
||||
this.checkBoxTent.Text = "Признак наличия тента";
|
||||
this.checkBoxTent.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxKit
|
||||
//
|
||||
this.checkBoxKit.AutoSize = true;
|
||||
this.checkBoxKit.Location = new System.Drawing.Point(18, 139);
|
||||
this.checkBoxKit.Name = "checkBoxKit";
|
||||
this.checkBoxKit.Size = new System.Drawing.Size(162, 19);
|
||||
this.checkBoxKit.TabIndex = 4;
|
||||
this.checkBoxKit.Text = "Признак наличия кузова";
|
||||
this.checkBoxKit.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
this.numericUpDownWeight.Location = new System.Drawing.Point(88, 87);
|
||||
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(120, 23);
|
||||
this.numericUpDownWeight.TabIndex = 3;
|
||||
this.numericUpDownWeight.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
this.numericUpDownSpeed.Location = new System.Drawing.Point(88, 44);
|
||||
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(120, 23);
|
||||
this.numericUpDownSpeed.TabIndex = 1;
|
||||
this.numericUpDownSpeed.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
this.labelWeight.AutoSize = true;
|
||||
this.labelWeight.Location = new System.Drawing.Point(18, 87);
|
||||
this.labelWeight.Name = "labelWeight";
|
||||
this.labelWeight.Size = new System.Drawing.Size(29, 15);
|
||||
this.labelWeight.TabIndex = 2;
|
||||
this.labelWeight.Text = "Вес:";
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
this.labelSpeed.AutoSize = true;
|
||||
this.labelSpeed.Location = new System.Drawing.Point(18, 44);
|
||||
this.labelSpeed.Name = "labelSpeed";
|
||||
this.labelSpeed.Size = new System.Drawing.Size(62, 15);
|
||||
this.labelSpeed.TabIndex = 1;
|
||||
this.labelSpeed.Text = "Скорость:";
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
this.pictureBoxObject.Location = new System.Drawing.Point(16, 64);
|
||||
this.pictureBoxObject.Name = "pictureBoxObject";
|
||||
this.pictureBoxObject.Size = new System.Drawing.Size(260, 183);
|
||||
this.pictureBoxObject.TabIndex = 7;
|
||||
this.pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// panelObject
|
||||
//
|
||||
this.panelObject.AllowDrop = true;
|
||||
this.panelObject.Controls.Add(this.labelColor);
|
||||
this.panelObject.Controls.Add(this.labelAddColor);
|
||||
this.panelObject.Controls.Add(this.pictureBoxObject);
|
||||
this.panelObject.Location = new System.Drawing.Point(618, 21);
|
||||
this.panelObject.Name = "panelObject";
|
||||
this.panelObject.Size = new System.Drawing.Size(294, 270);
|
||||
this.panelObject.TabIndex = 2;
|
||||
this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
|
||||
this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
|
||||
//
|
||||
// labelColor
|
||||
//
|
||||
this.labelColor.AllowDrop = true;
|
||||
this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelColor.Location = new System.Drawing.Point(16, 23);
|
||||
this.labelColor.Name = "labelColor";
|
||||
this.labelColor.Size = new System.Drawing.Size(124, 35);
|
||||
this.labelColor.TabIndex = 10;
|
||||
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_DragEnter);
|
||||
//
|
||||
// labelAddColor
|
||||
//
|
||||
this.labelAddColor.AllowDrop = true;
|
||||
this.labelAddColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelAddColor.Location = new System.Drawing.Point(150, 23);
|
||||
this.labelAddColor.Name = "labelAddColor";
|
||||
this.labelAddColor.Size = new System.Drawing.Size(126, 35);
|
||||
this.labelAddColor.TabIndex = 9;
|
||||
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_DragEnter);
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(672, 302);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(86, 38);
|
||||
this.buttonAdd.TabIndex = 3;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||
//
|
||||
// buttonCanel
|
||||
//
|
||||
this.buttonCanel.Location = new System.Drawing.Point(768, 302);
|
||||
this.buttonCanel.Name = "buttonCanel";
|
||||
this.buttonCanel.Size = new System.Drawing.Size(86, 38);
|
||||
this.buttonCanel.TabIndex = 4;
|
||||
this.buttonCanel.Text = "Отмена";
|
||||
this.buttonCanel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormCarConfig
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(924, 348);
|
||||
this.Controls.Add(this.buttonCanel);
|
||||
this.Controls.Add(this.buttonAdd);
|
||||
this.Controls.Add(this.panelObject);
|
||||
this.Controls.Add(this.groupBoxParameters);
|
||||
this.Name = "FormCarConfig";
|
||||
this.Text = "FormCarConfig";
|
||||
this.groupBoxParameters.ResumeLayout(false);
|
||||
this.groupBoxParameters.PerformLayout();
|
||||
this.groupBoxColors.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
|
||||
this.panelObject.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxParameters;
|
||||
private Label labelBaseObject;
|
||||
private CheckBox checkBoxTent;
|
||||
private CheckBox checkBoxKit;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private Label labelWeight;
|
||||
private Label labelSpeed;
|
||||
private GroupBox groupBoxColors;
|
||||
private Panel panelWhite;
|
||||
private Panel panelPurple;
|
||||
private Panel panelLightBlue;
|
||||
private Panel panelYellow;
|
||||
private Panel panelBlue;
|
||||
private Panel panelBlack;
|
||||
private Panel panelOrange;
|
||||
private Panel panelRed;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Panel panelObject;
|
||||
private Button buttonAdd;
|
||||
private Button buttonCanel;
|
||||
private Label labelAdvancedObject;
|
||||
private Label labelColor;
|
||||
private Label labelAddColor;
|
||||
}
|
||||
}
|
150
DumpTruck/DumpTruck/FormCarConfig.cs
Normal file
150
DumpTruck/DumpTruck/FormCarConfig.cs
Normal file
@ -0,0 +1,150 @@
|
||||
using DumpTruck.DrawningObjects;
|
||||
using System;
|
||||
using System.Collections;
|
||||
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 DumpTruck
|
||||
{
|
||||
public partial class FormCarConfig : Form
|
||||
{
|
||||
|
||||
DrawningCar? _car = null;
|
||||
public event Action<DrawningCar>? EventAddCar;
|
||||
|
||||
public FormCarConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||
panelOrange.MouseDown += PanelColor_MouseDown;
|
||||
panelLightBlue.MouseDown += PanelColor_MouseDown;
|
||||
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
panelRed.MouseDown += PanelColor_MouseDown;
|
||||
buttonCanel.Click += (s, e) => Close();
|
||||
}
|
||||
|
||||
private void DrawCar()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_car?.SetPosition(5, 5);
|
||||
_car?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
|
||||
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)))
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void LabelColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
{
|
||||
string senderName = ((Label)sender).Name;
|
||||
if (_car == null || e.Data.GetDataPresent(typeof(Color)) == false)
|
||||
return;
|
||||
|
||||
Color droppedColor = (Color)e.Data.GetData(typeof(Color));
|
||||
|
||||
if (senderName == "labelColor")
|
||||
{
|
||||
labelColor.BackColor = droppedColor;
|
||||
((DrawningCar)_car).setColor(labelColor.BackColor);
|
||||
}
|
||||
else if (senderName == "labelAddColor" && _car is DrawningDumpTruck)
|
||||
{
|
||||
labelAddColor.BackColor = droppedColor;
|
||||
((DrawningDumpTruck)_car).setAddColor(labelAddColor.BackColor);
|
||||
}
|
||||
|
||||
DrawCar();
|
||||
}
|
||||
}
|
||||
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name,
|
||||
DragDropEffects.Move | DragDropEffects.Copy);
|
||||
|
||||
}
|
||||
|
||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "labelBaseObject":
|
||||
_car = new DrawningCar((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
||||
pictureBoxObject.Height);
|
||||
labelColor.BackColor = Color.White;
|
||||
labelAddColor.BackColor = Color.Transparent;
|
||||
break;
|
||||
case "labelAdvancedObject":
|
||||
_car = new DrawningDumpTruck((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxKit.Checked,
|
||||
checkBoxTent.Checked, pictureBoxObject.Width,
|
||||
pictureBoxObject.Height);
|
||||
labelColor.BackColor = Color.White;
|
||||
labelAddColor.BackColor = Color.Black;
|
||||
break;
|
||||
}
|
||||
|
||||
DrawCar();
|
||||
}
|
||||
|
||||
public void AddEvent(Action<DrawningCar> ev)
|
||||
{
|
||||
if (EventAddCar == null)
|
||||
{
|
||||
EventAddCar = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddCar += ev;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_car == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
EventAddCar?.Invoke(_car);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
60
DumpTruck/DumpTruck/FormCarConfig.resx
Normal file
60
DumpTruck/DumpTruck/FormCarConfig.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<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>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user
Не используется