New form : Transport generator (+ color picker)
This commit is contained in:
parent
4c2d28dc7f
commit
9893edb33b
@ -47,7 +47,7 @@ namespace WinF_Lab2_Cruiser
|
|||||||
RandomGenerator = new Button();
|
RandomGenerator = new Button();
|
||||||
RemoveButton = new Button();
|
RemoveButton = new Button();
|
||||||
maskedTextBox1 = new MaskedTextBox();
|
maskedTextBox1 = new MaskedTextBox();
|
||||||
Add2Button = new Button();
|
// Add2Button = new Button();
|
||||||
AddButton = new Button();
|
AddButton = new Button();
|
||||||
comboBox1 = new ComboBox();
|
comboBox1 = new ComboBox();
|
||||||
pictureBox1 = new PictureBox();
|
pictureBox1 = new PictureBox();
|
||||||
@ -63,7 +63,7 @@ namespace WinF_Lab2_Cruiser
|
|||||||
ToolBox.Controls.Add(RandomGenerator);
|
ToolBox.Controls.Add(RandomGenerator);
|
||||||
ToolBox.Controls.Add(RemoveButton);
|
ToolBox.Controls.Add(RemoveButton);
|
||||||
ToolBox.Controls.Add(maskedTextBox1);
|
ToolBox.Controls.Add(maskedTextBox1);
|
||||||
ToolBox.Controls.Add(Add2Button);
|
// ToolBox.Controls.Add(Add2Button);
|
||||||
ToolBox.Controls.Add(AddButton);
|
ToolBox.Controls.Add(AddButton);
|
||||||
ToolBox.Controls.Add(comboBox1);
|
ToolBox.Controls.Add(comboBox1);
|
||||||
|
|
||||||
@ -173,10 +173,10 @@ namespace WinF_Lab2_Cruiser
|
|||||||
maskedTextBox1.TabIndex = 5;
|
maskedTextBox1.TabIndex = 5;
|
||||||
maskedTextBox1.ValidatingType = typeof(int);
|
maskedTextBox1.ValidatingType = typeof(int);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add2Button
|
// Add2Button
|
||||||
//
|
//
|
||||||
|
/*
|
||||||
Add2Button.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
Add2Button.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
Add2Button.Location = new Point(6, 126);
|
Add2Button.Location = new Point(6, 126);
|
||||||
Add2Button.Name = "Add2Button";
|
Add2Button.Name = "Add2Button";
|
||||||
@ -184,18 +184,23 @@ namespace WinF_Lab2_Cruiser
|
|||||||
Add2Button.TabIndex = 6;
|
Add2Button.TabIndex = 6;
|
||||||
Add2Button.Text = "Advanced";
|
Add2Button.Text = "Advanced";
|
||||||
Add2Button.UseVisualStyleBackColor = true;
|
Add2Button.UseVisualStyleBackColor = true;
|
||||||
Add2Button.Click += Add2Button_Click;
|
// Add2Button.Click += Add2Button_Click;
|
||||||
|
// Add2Button.Click += NewFormCreate;
|
||||||
|
*/
|
||||||
|
|
||||||
//
|
//
|
||||||
// AddButton
|
// AddButton
|
||||||
//
|
//
|
||||||
AddButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
AddButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
AddButton.Location = new Point(6, 84);
|
AddButton.Location = new Point(6, 84);
|
||||||
AddButton.Name = "AddButton";
|
AddButton.Name = "AddButton";
|
||||||
AddButton.Size = new Size(198, 40);
|
AddButton.Size = new Size(198, 70);
|
||||||
AddButton.TabIndex = 7;
|
AddButton.TabIndex = 7;
|
||||||
AddButton.Text = "Base";
|
AddButton.Text = "Create a cruiser";
|
||||||
AddButton.UseVisualStyleBackColor = true;
|
AddButton.UseVisualStyleBackColor = true;
|
||||||
AddButton.Click += AddButton_Click;
|
AddButton.Click += NewFormCreate;
|
||||||
|
// AddButton.Click += AddButton_Click;
|
||||||
|
|
||||||
//
|
//
|
||||||
// comboBox1
|
// comboBox1
|
||||||
//
|
//
|
||||||
@ -249,7 +254,7 @@ namespace WinF_Lab2_Cruiser
|
|||||||
|
|
||||||
private ComboBox comboBox1;
|
private ComboBox comboBox1;
|
||||||
private Button AddButton;
|
private Button AddButton;
|
||||||
private Button Add2Button;
|
// private Button Add2Button;
|
||||||
private MaskedTextBox maskedTextBox1;
|
private MaskedTextBox maskedTextBox1;
|
||||||
private PictureBox pictureBox1;
|
private PictureBox pictureBox1;
|
||||||
private Button RemoveButton;
|
private Button RemoveButton;
|
||||||
|
@ -39,6 +39,7 @@ namespace WinF_Lab2_Cruiser
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private static Color GetColor(Random r)
|
private static Color GetColor(Random r)
|
||||||
{
|
{
|
||||||
Color cl = Color.FromArgb(r.Next(0, 256), r.Next(0, 256), r.Next(0, 256));
|
Color cl = Color.FromArgb(r.Next(0, 256), r.Next(0, 256), r.Next(0, 256));
|
||||||
@ -65,10 +66,10 @@ namespace WinF_Lab2_Cruiser
|
|||||||
Transport = new DrawingBase(rn.Next(100, 300), rn.Next(1000, 3000), GetColor(rn));
|
Transport = new DrawingBase(rn.Next(100, 300), rn.Next(1000, 3000), GetColor(rn));
|
||||||
break;
|
break;
|
||||||
case nameof(DrawingCruiser):
|
case nameof(DrawingCruiser):
|
||||||
Class_CruiserEntity Obj = new Class_CruiserEntity(rn.Next(100, 300), rn.Next(1000, 3000),
|
Transport = new DrawingCruiser(rn.Next(100, 300), rn.Next(1000, 3000),
|
||||||
GetColor(rn), GetColor(rn), Convert.ToBoolean(rn.Next(0, 2)),
|
GetColor(rn), GetColor(rn), Convert.ToBoolean(rn.Next(0, 2)),
|
||||||
Convert.ToBoolean(rn.Next(0, 2)), rn.Next(1, 4), rn.Next(5, 10), rn.Next(1, 3));
|
Convert.ToBoolean(rn.Next(0, 2)), rn.Next(1, 4), rn.Next(5, 10), rn.Next(1, 3));
|
||||||
Transport = new DrawingCruiser(Obj);
|
// (Obj);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
@ -86,6 +87,32 @@ namespace WinF_Lab2_Cruiser
|
|||||||
private void AddButton_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingBase));
|
private void AddButton_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingBase));
|
||||||
|
|
||||||
private void Add2Button_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingCruiser));
|
private void Add2Button_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingCruiser));
|
||||||
|
*/
|
||||||
|
|
||||||
|
private void NewFormCreate(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
FormTransportConfig form = new();
|
||||||
|
// TODO передать метод
|
||||||
|
form.Show();
|
||||||
|
form.AddEvent(SetObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetObj(DrawingBase? ship)
|
||||||
|
{
|
||||||
|
if (_Company == null || ship == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_Company + ship != -1)
|
||||||
|
{
|
||||||
|
MessageBox.Show(" > Object was added");
|
||||||
|
pictureBox1.Image = _Company.Show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show(" > Can't create an object");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void RemoveButton_Click(object sender, EventArgs e)
|
private void RemoveButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -143,7 +170,7 @@ namespace WinF_Lab2_Cruiser
|
|||||||
|
|
||||||
Form.SetTransport = drBase;
|
Form.SetTransport = drBase;
|
||||||
Form.ShowDialog();
|
Form.ShowDialog();
|
||||||
// ----------------------------------------------------------
|
// --------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Check_Click(object sender, EventArgs e)
|
private void Check_Click(object sender, EventArgs e)
|
||||||
|
@ -21,9 +21,12 @@ namespace WinF_Lab2_Cruiser.Drawing_tools
|
|||||||
// BaseEntity = new Class_CruiserEntity(speed, weight, mainc, addtc, pad, hangar, p, d_coordinates, h);
|
// BaseEntity = new Class_CruiserEntity(speed, weight, mainc, addtc, pad, hangar, p, d_coordinates, h);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
public DrawingCruiser(Class_CruiserEntity Obj) : base(302, 72)
|
public DrawingCruiser(int speed, double weight,
|
||||||
|
Color mainc, Color addtc, bool pad,
|
||||||
|
bool hangar, int p, int d_coordinates, int h) : base(302, 72) // Class_CruiserEntity Obj) : base(302, 72)
|
||||||
{
|
{
|
||||||
BaseEntity = Obj;
|
BaseEntity = new Class_CruiserEntity(speed, weight, mainc,
|
||||||
|
addtc, pad, hangar, p, d_coordinates, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawTransport(Graphics g)
|
public override void DrawTransport(Graphics g)
|
||||||
|
@ -12,6 +12,11 @@ namespace WinF_Lab2_Cruiser.Entity_Folder
|
|||||||
public int Speed { get; private set; }
|
public int Speed { get; private set; }
|
||||||
public double Weight { get; private set; }
|
public double Weight { get; private set; }
|
||||||
public Color MainC { get; private set; }
|
public Color MainC { get; private set; }
|
||||||
|
public void setMColor(Color color)
|
||||||
|
{
|
||||||
|
MainC = color;
|
||||||
|
}
|
||||||
|
|
||||||
public double Step => Speed * 100 / Weight;
|
public double Step => Speed * 100 / Weight;
|
||||||
|
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
|
@ -12,6 +12,11 @@ namespace WinF_Lab2_Cruiser.Entity_Folder
|
|||||||
/// ADDITIONAL свойства
|
/// ADDITIONAL свойства
|
||||||
public Color AdditionalC { get; private set; }
|
public Color AdditionalC { get; private set; }
|
||||||
|
|
||||||
|
public void setAdditionalColor(Color color)
|
||||||
|
{
|
||||||
|
AdditionalC = color;
|
||||||
|
}
|
||||||
|
|
||||||
/// признаки (наличия)
|
/// признаки (наличия)
|
||||||
public bool HelicopterPads { get; private set; } /// вертолетная площадка
|
public bool HelicopterPads { get; private set; } /// вертолетная площадка
|
||||||
public bool Hangar { get; private set; } /// ангар
|
public bool Hangar { get; private set; } /// ангар
|
||||||
|
344
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/FormTransportConfig.Designer.cs
generated
Normal file
344
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/FormTransportConfig.Designer.cs
generated
Normal file
@ -0,0 +1,344 @@
|
|||||||
|
namespace WinF_Lab2_Cruiser
|
||||||
|
{
|
||||||
|
partial class FormTransportConfig
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
ParametersBox = new GroupBox();
|
||||||
|
AdvLabel = new Label();
|
||||||
|
BaseLabel = new Label();
|
||||||
|
groupBox2 = new GroupBox();
|
||||||
|
PurpleP = new Panel();
|
||||||
|
GreenP = new Panel();
|
||||||
|
PinkP = new Panel();
|
||||||
|
OrangeP = new Panel();
|
||||||
|
CyanP = new Panel();
|
||||||
|
YellowP = new Panel();
|
||||||
|
RedP = new Panel();
|
||||||
|
BlueP = new Panel();
|
||||||
|
CheckBox_Pads = new CheckBox();
|
||||||
|
CheckBox_Hangars = new CheckBox();
|
||||||
|
WeightN = new NumericUpDown();
|
||||||
|
SpeedN = new NumericUpDown();
|
||||||
|
Label = new Label();
|
||||||
|
Showcase = new PictureBox();
|
||||||
|
AddButton = new Button();
|
||||||
|
CancelButton = new Button();
|
||||||
|
panelObject = new Panel();
|
||||||
|
labelAcolor = new Label();
|
||||||
|
labelMcolor = new Label();
|
||||||
|
ParametersBox.SuspendLayout();
|
||||||
|
groupBox2.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)WeightN).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)SpeedN).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)Showcase).BeginInit();
|
||||||
|
panelObject.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// ParametersBox
|
||||||
|
//
|
||||||
|
ParametersBox.Controls.Add(AdvLabel);
|
||||||
|
ParametersBox.Controls.Add(BaseLabel);
|
||||||
|
ParametersBox.Controls.Add(groupBox2);
|
||||||
|
ParametersBox.Controls.Add(CheckBox_Pads);
|
||||||
|
ParametersBox.Controls.Add(CheckBox_Hangars);
|
||||||
|
ParametersBox.Controls.Add(WeightN);
|
||||||
|
ParametersBox.Controls.Add(SpeedN);
|
||||||
|
ParametersBox.Controls.Add(Label);
|
||||||
|
ParametersBox.Location = new Point(12, 0);
|
||||||
|
ParametersBox.Name = "ParametersBox";
|
||||||
|
ParametersBox.Size = new Size(388, 495);
|
||||||
|
ParametersBox.TabIndex = 0;
|
||||||
|
ParametersBox.TabStop = false;
|
||||||
|
ParametersBox.Text = "Parameters";
|
||||||
|
//
|
||||||
|
// AdvLabel
|
||||||
|
//
|
||||||
|
AdvLabel.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
AdvLabel.Location = new Point(175, 428);
|
||||||
|
AdvLabel.Name = "AdvLabel";
|
||||||
|
AdvLabel.Size = new Size(184, 46);
|
||||||
|
AdvLabel.TabIndex = 5;
|
||||||
|
AdvLabel.Text = "Advanced";
|
||||||
|
AdvLabel.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
AdvLabel.MouseDown += BaseAdvLabel_MouseDown;
|
||||||
|
//
|
||||||
|
// BaseLabel
|
||||||
|
//
|
||||||
|
BaseLabel.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
BaseLabel.Location = new Point(17, 428);
|
||||||
|
BaseLabel.Name = "BaseLabel";
|
||||||
|
BaseLabel.Size = new Size(132, 46);
|
||||||
|
BaseLabel.TabIndex = 4;
|
||||||
|
BaseLabel.Text = "Base";
|
||||||
|
BaseLabel.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
BaseLabel.MouseDown += BaseAdvLabel_MouseDown;
|
||||||
|
//
|
||||||
|
// groupBox2
|
||||||
|
//
|
||||||
|
groupBox2.Controls.Add(PurpleP);
|
||||||
|
groupBox2.Controls.Add(GreenP);
|
||||||
|
groupBox2.Controls.Add(PinkP);
|
||||||
|
groupBox2.Controls.Add(OrangeP);
|
||||||
|
groupBox2.Controls.Add(CyanP);
|
||||||
|
groupBox2.Controls.Add(YellowP);
|
||||||
|
groupBox2.Controls.Add(RedP);
|
||||||
|
groupBox2.Controls.Add(BlueP);
|
||||||
|
groupBox2.Location = new Point(17, 197);
|
||||||
|
groupBox2.Name = "groupBox2";
|
||||||
|
groupBox2.Size = new Size(342, 213);
|
||||||
|
groupBox2.TabIndex = 1;
|
||||||
|
groupBox2.TabStop = false;
|
||||||
|
groupBox2.Text = "Color picker";
|
||||||
|
//
|
||||||
|
// PurpleP
|
||||||
|
//
|
||||||
|
PurpleP.BackColor = Color.DarkViolet;
|
||||||
|
PurpleP.Location = new Point(260, 126);
|
||||||
|
PurpleP.Name = "PurpleP";
|
||||||
|
PurpleP.Size = new Size(63, 59);
|
||||||
|
PurpleP.TabIndex = 12;
|
||||||
|
//
|
||||||
|
// GreenP
|
||||||
|
//
|
||||||
|
GreenP.BackColor = Color.SpringGreen;
|
||||||
|
GreenP.Location = new Point(259, 49);
|
||||||
|
GreenP.Name = "GreenP";
|
||||||
|
GreenP.Size = new Size(63, 59);
|
||||||
|
GreenP.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// PinkP
|
||||||
|
//
|
||||||
|
PinkP.BackColor = Color.DeepPink;
|
||||||
|
PinkP.Location = new Point(180, 126);
|
||||||
|
PinkP.Name = "PinkP";
|
||||||
|
PinkP.Size = new Size(63, 59);
|
||||||
|
PinkP.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// OrangeP
|
||||||
|
//
|
||||||
|
OrangeP.BackColor = Color.DarkOrange;
|
||||||
|
OrangeP.Location = new Point(180, 49);
|
||||||
|
OrangeP.Name = "OrangeP";
|
||||||
|
OrangeP.Size = new Size(63, 59);
|
||||||
|
OrangeP.TabIndex = 8;
|
||||||
|
//
|
||||||
|
// CyanP
|
||||||
|
//
|
||||||
|
CyanP.BackColor = Color.Cyan;
|
||||||
|
CyanP.Location = new Point(100, 126);
|
||||||
|
CyanP.Name = "CyanP";
|
||||||
|
CyanP.Size = new Size(63, 59);
|
||||||
|
CyanP.TabIndex = 10;
|
||||||
|
//
|
||||||
|
// YellowP
|
||||||
|
//
|
||||||
|
YellowP.BackColor = Color.Gold;
|
||||||
|
YellowP.Location = new Point(19, 126);
|
||||||
|
YellowP.Name = "YellowP";
|
||||||
|
YellowP.Size = new Size(63, 59);
|
||||||
|
YellowP.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// RedP
|
||||||
|
//
|
||||||
|
RedP.BackColor = Color.Firebrick;
|
||||||
|
RedP.Location = new Point(100, 49);
|
||||||
|
RedP.Name = "RedP";
|
||||||
|
RedP.Size = new Size(63, 59);
|
||||||
|
RedP.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// BlueP
|
||||||
|
//
|
||||||
|
BlueP.BackColor = SystemColors.Highlight;
|
||||||
|
BlueP.Location = new Point(19, 49);
|
||||||
|
BlueP.Name = "BlueP";
|
||||||
|
BlueP.Size = new Size(63, 59);
|
||||||
|
BlueP.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// CheckBox_Pads
|
||||||
|
//
|
||||||
|
CheckBox_Pads.AutoSize = true;
|
||||||
|
CheckBox_Pads.Location = new Point(24, 142);
|
||||||
|
CheckBox_Pads.Name = "CheckBox_Pads";
|
||||||
|
CheckBox_Pads.Size = new Size(203, 36);
|
||||||
|
CheckBox_Pads.TabIndex = 3;
|
||||||
|
CheckBox_Pads.Text = "Helicopter pad";
|
||||||
|
CheckBox_Pads.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// CheckBox_Hangars
|
||||||
|
//
|
||||||
|
CheckBox_Hangars.AutoSize = true;
|
||||||
|
CheckBox_Hangars.Location = new Point(234, 142);
|
||||||
|
CheckBox_Hangars.Name = "CheckBox_Hangars";
|
||||||
|
CheckBox_Hangars.Size = new Size(133, 36);
|
||||||
|
CheckBox_Hangars.TabIndex = 1;
|
||||||
|
CheckBox_Hangars.Text = "Hangars";
|
||||||
|
CheckBox_Hangars.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// WeightN
|
||||||
|
//
|
||||||
|
WeightN.Location = new Point(198, 88);
|
||||||
|
WeightN.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||||
|
WeightN.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
WeightN.Name = "WeightN";
|
||||||
|
WeightN.Size = new Size(142, 39);
|
||||||
|
WeightN.TabIndex = 2;
|
||||||
|
WeightN.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// SpeedN
|
||||||
|
//
|
||||||
|
SpeedN.Location = new Point(36, 88);
|
||||||
|
SpeedN.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||||
|
SpeedN.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
SpeedN.Name = "SpeedN";
|
||||||
|
SpeedN.Size = new Size(142, 39);
|
||||||
|
SpeedN.TabIndex = 1;
|
||||||
|
SpeedN.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// Label
|
||||||
|
//
|
||||||
|
Label.AutoSize = true;
|
||||||
|
Label.Location = new Point(36, 53);
|
||||||
|
Label.Name = "Label";
|
||||||
|
Label.Size = new Size(304, 32);
|
||||||
|
Label.TabIndex = 1;
|
||||||
|
Label.Text = "Speed Weight";
|
||||||
|
//
|
||||||
|
// Showcase
|
||||||
|
//
|
||||||
|
Showcase.Location = new Point(58, 98);
|
||||||
|
Showcase.Name = "Showcase";
|
||||||
|
Showcase.Size = new Size(458, 272);
|
||||||
|
Showcase.TabIndex = 1;
|
||||||
|
Showcase.TabStop = false;
|
||||||
|
//
|
||||||
|
// AddButton
|
||||||
|
//
|
||||||
|
AddButton.Location = new Point(419, 447);
|
||||||
|
AddButton.Name = "AddButton";
|
||||||
|
AddButton.Size = new Size(268, 46);
|
||||||
|
AddButton.TabIndex = 2;
|
||||||
|
AddButton.Text = "Add";
|
||||||
|
AddButton.UseVisualStyleBackColor = true;
|
||||||
|
AddButton.Click += AddButton_Click;
|
||||||
|
//
|
||||||
|
// CancelButton
|
||||||
|
//
|
||||||
|
CancelButton.Location = new Point(694, 447);
|
||||||
|
CancelButton.Name = "CancelButton";
|
||||||
|
CancelButton.Size = new Size(286, 46);
|
||||||
|
CancelButton.TabIndex = 3;
|
||||||
|
CancelButton.Text = "Cancel";
|
||||||
|
CancelButton.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// panelObject
|
||||||
|
//
|
||||||
|
panelObject.AllowDrop = true;
|
||||||
|
panelObject.Controls.Add(labelAcolor);
|
||||||
|
panelObject.Controls.Add(labelMcolor);
|
||||||
|
panelObject.Controls.Add(Showcase);
|
||||||
|
panelObject.Location = new Point(419, 12);
|
||||||
|
panelObject.Name = "panelObject";
|
||||||
|
panelObject.Size = new Size(561, 410);
|
||||||
|
panelObject.TabIndex = 4;
|
||||||
|
panelObject.DragDrop += PanelObject_DragDrop;
|
||||||
|
panelObject.DragEnter += PanelObject_DragEnter;
|
||||||
|
//
|
||||||
|
// labelAcolor
|
||||||
|
//
|
||||||
|
labelAcolor.AllowDrop = true;
|
||||||
|
labelAcolor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelAcolor.Location = new Point(253, 39);
|
||||||
|
labelAcolor.Name = "labelAcolor";
|
||||||
|
labelAcolor.Size = new Size(263, 42);
|
||||||
|
labelAcolor.TabIndex = 7;
|
||||||
|
labelAcolor.Text = "Additional color";
|
||||||
|
labelAcolor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelAcolor.DragDrop += AdditionalColor_DragDrop;
|
||||||
|
labelAcolor.DragEnter += AdditionalColor_DragEnter;
|
||||||
|
//
|
||||||
|
// labelMcolor
|
||||||
|
//
|
||||||
|
labelMcolor.AllowDrop = true;
|
||||||
|
labelMcolor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelMcolor.Location = new Point(58, 39);
|
||||||
|
labelMcolor.Name = "labelMcolor";
|
||||||
|
labelMcolor.Size = new Size(180, 42);
|
||||||
|
labelMcolor.TabIndex = 6;
|
||||||
|
labelMcolor.Text = "Main color";
|
||||||
|
labelMcolor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelMcolor.DragDrop += BodyColor_DragDrop;
|
||||||
|
labelMcolor.DragEnter += BodyColor_DragEnter;
|
||||||
|
//
|
||||||
|
// FormTransportConfig
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(992, 516);
|
||||||
|
Controls.Add(panelObject);
|
||||||
|
Controls.Add(CancelButton);
|
||||||
|
Controls.Add(AddButton);
|
||||||
|
Controls.Add(ParametersBox);
|
||||||
|
Name = "FormTransportConfig";
|
||||||
|
Text = "FormTransportConfig";
|
||||||
|
ParametersBox.ResumeLayout(false);
|
||||||
|
ParametersBox.PerformLayout();
|
||||||
|
groupBox2.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)WeightN).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)SpeedN).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)Showcase).EndInit();
|
||||||
|
panelObject.ResumeLayout(false);
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox ParametersBox;
|
||||||
|
private Label Label;
|
||||||
|
private CheckBox CheckBox_Pads;
|
||||||
|
private CheckBox CheckBox_Hangars;
|
||||||
|
private NumericUpDown WeightN;
|
||||||
|
private NumericUpDown SpeedN;
|
||||||
|
private GroupBox groupBox2;
|
||||||
|
private Label BaseLabel;
|
||||||
|
private Label AdvLabel;
|
||||||
|
private Panel PurpleP;
|
||||||
|
private Panel GreenP;
|
||||||
|
private Panel PinkP;
|
||||||
|
private Panel OrangeP;
|
||||||
|
private Panel CyanP;
|
||||||
|
private Panel YellowP;
|
||||||
|
private Panel RedP;
|
||||||
|
private Panel BlueP;
|
||||||
|
private PictureBox Showcase;
|
||||||
|
private Button AddButton;
|
||||||
|
private Button CancelButton;
|
||||||
|
private Panel panelObject;
|
||||||
|
private Label labelMcolor;
|
||||||
|
private Label labelAcolor;
|
||||||
|
}
|
||||||
|
}
|
137
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/FormTransportConfig.cs
Normal file
137
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/FormTransportConfig.cs
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
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;
|
||||||
|
using WinF_Lab2_Cruiser.Drawing_tools;
|
||||||
|
using WinF_Lab2_Cruiser.Entity_Folder;
|
||||||
|
|
||||||
|
namespace WinF_Lab2_Cruiser
|
||||||
|
{
|
||||||
|
public partial class FormTransportConfig : Form
|
||||||
|
{
|
||||||
|
private DrawingBase _cruiser;
|
||||||
|
|
||||||
|
// private event Action<DrawingBase>? shipDelegate;
|
||||||
|
private event ShipDelegate? shipDelegate;
|
||||||
|
|
||||||
|
public FormTransportConfig()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
BlueP.MouseDown += Panel_MouseDown;
|
||||||
|
RedP.MouseDown += Panel_MouseDown;
|
||||||
|
PinkP.MouseDown += Panel_MouseDown;
|
||||||
|
YellowP.MouseDown += Panel_MouseDown;
|
||||||
|
CyanP.MouseDown += Panel_MouseDown;
|
||||||
|
PurpleP.MouseDown += Panel_MouseDown;
|
||||||
|
GreenP.MouseDown += Panel_MouseDown;
|
||||||
|
OrangeP.MouseDown += Panel_MouseDown;
|
||||||
|
CancelButton.Click += (sender, e) => Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddEvent(ShipDelegate del)// Action<DrawingBase> delegator)
|
||||||
|
{
|
||||||
|
if (shipDelegate == null) shipDelegate = del;
|
||||||
|
else shipDelegate += del;
|
||||||
|
//shipDelegate += del;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawObject()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(Showcase.Width, Showcase.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_cruiser?.SetPicSize(Showcase.Width, Showcase.Height);
|
||||||
|
_cruiser?.SetPos(Showcase.Width - 400, Showcase.Height - 120);
|
||||||
|
_cruiser?.DrawTransport(gr);
|
||||||
|
Showcase.Image = bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Panel_MouseDown(object? sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
// TODO отправка цвета в Drag&Drop
|
||||||
|
(sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
//private void FormTransportConfig_Load(object sender, EventArgs e)
|
||||||
|
//{
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
|
private void BaseAdvLabel_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, 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 "BaseLabel":
|
||||||
|
_cruiser = new DrawingBase((int)SpeedN.Value, (double)WeightN.Value, Color.White);
|
||||||
|
break;
|
||||||
|
case "AdvLabel":
|
||||||
|
Random rn = new Random();
|
||||||
|
_cruiser = new DrawingCruiser((int)SpeedN.Value, (double)WeightN.Value,
|
||||||
|
Color.White, Color.Black, CheckBox_Pads.Checked, CheckBox_Hangars.Checked,
|
||||||
|
rn.Next(1, 4), rn.Next(5, 10), rn.Next(1, 3));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
labelMcolor.BackColor = Color.Empty;
|
||||||
|
labelAcolor.BackColor = Color.Empty;
|
||||||
|
DrawObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
|
||||||
|
private void BodyColor_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data.GetDataPresent(typeof(Color))) e.Effect = DragDropEffects.Copy;
|
||||||
|
else e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BodyColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_cruiser != null)
|
||||||
|
{
|
||||||
|
_cruiser.BaseEntity.setMColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
DrawObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AdditionalColor_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_cruiser is DrawingCruiser)
|
||||||
|
{
|
||||||
|
if (e.Data.GetDataPresent(typeof(Color))) e.Effect = DragDropEffects.Copy;
|
||||||
|
else e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AdditionalColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_cruiser.BaseEntity is Class_CruiserEntity _ship)
|
||||||
|
{
|
||||||
|
_ship.setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
}
|
||||||
|
DrawObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_cruiser != null)
|
||||||
|
{
|
||||||
|
shipDelegate?.Invoke(_cruiser);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/FormTransportConfig.resx
Normal file
120
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/FormTransportConfig.resx
Normal 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>
|
11
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/shipDelegate.cs
Normal file
11
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/shipDelegate.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using WinF_Lab2_Cruiser.Drawing_tools;
|
||||||
|
|
||||||
|
namespace WinF_Lab2_Cruiser
|
||||||
|
{
|
||||||
|
public delegate void ShipDelegate(DrawingBase transport);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user