Без теор
This commit is contained in:
parent
c0d6680106
commit
790766694c
@ -10,13 +10,13 @@ namespace ElectricLocomotive
|
|||||||
{
|
{
|
||||||
public class DrawningElectricLocomotive : DrawningLocomotive
|
public class DrawningElectricLocomotive : DrawningLocomotive
|
||||||
{
|
{
|
||||||
public DrawningElectricLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, bool Horns, int width, int height)
|
public DrawningElectricLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, bool Horns_1,bool Horns_2, int width, int height)
|
||||||
: base (speed, weight, bodyColor, width , height)
|
: base (speed, weight, bodyColor, width , height)
|
||||||
{
|
{
|
||||||
if (EntityLocomotive != null)
|
if (EntityLocomotive != null)
|
||||||
{
|
{
|
||||||
EntityLocomotive = new EntityElectroLocomotive(speed, weight, bodyColor,
|
EntityLocomotive = new EntityElectroLocomotive(speed, weight, bodyColor,
|
||||||
additionalColor, Horns);
|
additionalColor, Horns_1,Horns_2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ namespace ElectricLocomotive
|
|||||||
Pen pen = new(electroLocomotive.BodyColor) ;
|
Pen pen = new(electroLocomotive.BodyColor) ;
|
||||||
Brush brush = new SolidBrush(electroLocomotive.AdditionalColor);
|
Brush brush = new SolidBrush(electroLocomotive.AdditionalColor);
|
||||||
// обвесы
|
// обвесы
|
||||||
if (electroLocomotive.Horns)
|
if (electroLocomotive.Horns_1)
|
||||||
{
|
{
|
||||||
g.FillRectangle(brush, _startPosX + 25, _startPosY + 5, 15, 5);
|
g.FillRectangle(brush, _startPosX + 25, _startPosY + 5, 15, 5);
|
||||||
|
|
||||||
@ -44,7 +44,9 @@ namespace ElectricLocomotive
|
|||||||
new Point(_startPosX+40,_startPosY+10)
|
new Point(_startPosX+40,_startPosY+10)
|
||||||
};
|
};
|
||||||
g.DrawPolygon(pen, horns);
|
g.DrawPolygon(pen, horns);
|
||||||
|
}
|
||||||
|
if (electroLocomotive.Horns_2)
|
||||||
|
{
|
||||||
g.FillRectangle(brush, _startPosX + 65, _startPosY + 5, 15, 5);
|
g.FillRectangle(brush, _startPosX + 65, _startPosY + 5, 15, 5);
|
||||||
Point[] horns2 =
|
Point[] horns2 =
|
||||||
{
|
{
|
||||||
@ -57,6 +59,7 @@ namespace ElectricLocomotive
|
|||||||
new Point(_startPosX+80,_startPosY+10)
|
new Point(_startPosX+80,_startPosY+10)
|
||||||
};
|
};
|
||||||
g.DrawPolygon(pen, horns2);
|
g.DrawPolygon(pen, horns2);
|
||||||
|
|
||||||
}
|
}
|
||||||
base.DrawTransport(g);
|
base.DrawTransport(g);
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,9 @@ namespace ElectricLocomotive.DrawningObject
|
|||||||
{
|
{
|
||||||
public EntityLocomotive? EntityLocomotive { get; protected set; }
|
public EntityLocomotive? EntityLocomotive { get; protected set; }
|
||||||
|
|
||||||
protected int _pictureWidth;
|
public int _pictureWidth;
|
||||||
|
|
||||||
protected int _pictureHeight;
|
public int _pictureHeight;
|
||||||
|
|
||||||
protected int _startPosX;
|
protected int _startPosX;
|
||||||
|
|
||||||
|
@ -50,13 +50,15 @@ namespace ElectricLocomotive
|
|||||||
Random random = new();
|
Random random = new();
|
||||||
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||||
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||||
bool Horns = Convert.ToBoolean(random.Next(0, 2));
|
bool Horns_1 = Convert.ToBoolean(random.Next(0, 2));
|
||||||
|
bool Horns_2 = Convert.ToBoolean(random.Next(0, 2));
|
||||||
|
|
||||||
ColorDialog dialog = new();
|
ColorDialog dialog = new();
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
color = dialog.Color;
|
color = dialog.Color;
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
dopColor = dialog.Color;
|
dopColor = dialog.Color;
|
||||||
_drawningLocomotive = new DrawningElectricLocomotive(random.Next(100, 300), random.Next(1000, 3000), color, dopColor, Horns, pictureBoxElectroLocomotiv.Width, pictureBoxElectroLocomotiv.Height);
|
_drawningLocomotive = new DrawningElectricLocomotive(random.Next(100, 300), random.Next(1000, 3000), color, dopColor, Horns_1,Horns_2, pictureBoxElectroLocomotiv.Width, pictureBoxElectroLocomotiv.Height);
|
||||||
_drawningLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
_drawningLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
@ -11,14 +11,18 @@ namespace ElectricLocomotive.Entities
|
|||||||
{
|
{
|
||||||
public Color AdditionalColor { get; private set; }
|
public Color AdditionalColor { get; private set; }
|
||||||
|
|
||||||
public bool Horns { get; private set; }
|
public bool Horns_1 { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Признак (опция) roga
|
/// Признак (опция) roga
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EntityElectroLocomotive(int Speed, double weight, Color bodyColor, Color additionalColor, bool horns) : base(Speed,weight,bodyColor)
|
///
|
||||||
|
public bool Horns_2 { get; private set; }
|
||||||
|
|
||||||
|
public EntityElectroLocomotive(int Speed, double weight, Color bodyColor, Color additionalColor, bool horns_1, bool horns_2) : base(Speed, weight, bodyColor)
|
||||||
{
|
{
|
||||||
AdditionalColor = additionalColor;
|
AdditionalColor = additionalColor;
|
||||||
Horns = horns;
|
Horns_1 = horns_1;
|
||||||
|
Horns_2 = horns_2;
|
||||||
}
|
}
|
||||||
public void SetAdditionalColor(Color color)
|
public void SetAdditionalColor(Color color)
|
||||||
{
|
{
|
||||||
|
@ -82,6 +82,9 @@ namespace ElectricLocomotive
|
|||||||
}
|
}
|
||||||
public void NAddLocomotive(DrawningLocomotive loco)
|
public void NAddLocomotive(DrawningLocomotive loco)
|
||||||
{
|
{
|
||||||
|
loco._pictureWidth = CollectionPictureBox.Width;
|
||||||
|
loco._pictureHeight = CollectionPictureBox.Height;
|
||||||
|
|
||||||
if (listBoxStorage.SelectedIndex == -1) return;
|
if (listBoxStorage.SelectedIndex == -1) return;
|
||||||
|
|
||||||
var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
|
var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
|
||||||
@ -90,19 +93,15 @@ namespace ElectricLocomotive
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ElectricLocomotive form = new();
|
//проверяем, удалось ли нам загрузить объект
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (obj + loco > -1)
|
||||||
{
|
{
|
||||||
//проверяем, удалось ли нам загрузить объект
|
MessageBox.Show("Объект добавлен");
|
||||||
if (obj + form.SelectedLocomotive > -1)
|
CollectionPictureBox.Image = obj.ShowLocomotives();
|
||||||
{
|
}
|
||||||
MessageBox.Show("Объект добавлен");
|
else
|
||||||
CollectionPictureBox.Image = obj.ShowLocomotives();
|
{
|
||||||
}
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
panelColorBlue = new Panel();
|
panelColorBlue = new Panel();
|
||||||
panelColorGreen = new Panel();
|
panelColorGreen = new Panel();
|
||||||
panelColorRed = new Panel();
|
panelColorRed = new Panel();
|
||||||
checkBoxPantograph = new CheckBox();
|
checkBoxPantograph_1 = new CheckBox();
|
||||||
numericUpDownWeight = new NumericUpDown();
|
numericUpDownWeight = new NumericUpDown();
|
||||||
numericUpDownSpeed = new NumericUpDown();
|
numericUpDownSpeed = new NumericUpDown();
|
||||||
labelWeight = new Label();
|
labelWeight = new Label();
|
||||||
@ -51,6 +51,7 @@
|
|||||||
labelSimpleColor = new Label();
|
labelSimpleColor = new Label();
|
||||||
buttonAddObject = new Button();
|
buttonAddObject = new Button();
|
||||||
buttonCancelObject = new Button();
|
buttonCancelObject = new Button();
|
||||||
|
checkBoxPantograph_2 = new CheckBox();
|
||||||
groupBoxConfig.SuspendLayout();
|
groupBoxConfig.SuspendLayout();
|
||||||
groupBoxColors.SuspendLayout();
|
groupBoxColors.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||||
@ -61,10 +62,11 @@
|
|||||||
//
|
//
|
||||||
// groupBoxConfig
|
// groupBoxConfig
|
||||||
//
|
//
|
||||||
|
groupBoxConfig.Controls.Add(checkBoxPantograph_2);
|
||||||
groupBoxConfig.Controls.Add(labelAdvancedObject);
|
groupBoxConfig.Controls.Add(labelAdvancedObject);
|
||||||
groupBoxConfig.Controls.Add(labelSimpleObject);
|
groupBoxConfig.Controls.Add(labelSimpleObject);
|
||||||
groupBoxConfig.Controls.Add(groupBoxColors);
|
groupBoxConfig.Controls.Add(groupBoxColors);
|
||||||
groupBoxConfig.Controls.Add(checkBoxPantograph);
|
groupBoxConfig.Controls.Add(checkBoxPantograph_1);
|
||||||
groupBoxConfig.Controls.Add(numericUpDownWeight);
|
groupBoxConfig.Controls.Add(numericUpDownWeight);
|
||||||
groupBoxConfig.Controls.Add(numericUpDownSpeed);
|
groupBoxConfig.Controls.Add(numericUpDownSpeed);
|
||||||
groupBoxConfig.Controls.Add(labelWeight);
|
groupBoxConfig.Controls.Add(labelWeight);
|
||||||
@ -190,15 +192,15 @@
|
|||||||
panelColorRed.TabIndex = 0;
|
panelColorRed.TabIndex = 0;
|
||||||
panelColorRed.MouseDown += PanelColor_MouseDown;
|
panelColorRed.MouseDown += PanelColor_MouseDown;
|
||||||
//
|
//
|
||||||
// checkBoxPantograph
|
// checkBoxPantograph_1
|
||||||
//
|
//
|
||||||
checkBoxPantograph.AutoSize = true;
|
checkBoxPantograph_1.AutoSize = true;
|
||||||
checkBoxPantograph.Location = new Point(10, 124);
|
checkBoxPantograph_1.Location = new Point(10, 124);
|
||||||
checkBoxPantograph.Name = "checkBoxPantograph";
|
checkBoxPantograph_1.Name = "checkBoxPantograph_1";
|
||||||
checkBoxPantograph.Size = new Size(172, 19);
|
checkBoxPantograph_1.Size = new Size(154, 19);
|
||||||
checkBoxPantograph.TabIndex = 4;
|
checkBoxPantograph_1.TabIndex = 4;
|
||||||
checkBoxPantograph.Text = "Наличие токоприемников";
|
checkBoxPantograph_1.Text = "Первый токоприемник";
|
||||||
checkBoxPantograph.UseVisualStyleBackColor = true;
|
checkBoxPantograph_1.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// numericUpDownWeight
|
// numericUpDownWeight
|
||||||
//
|
//
|
||||||
@ -304,6 +306,16 @@
|
|||||||
buttonCancelObject.Text = "Отмена";
|
buttonCancelObject.Text = "Отмена";
|
||||||
buttonCancelObject.UseVisualStyleBackColor = true;
|
buttonCancelObject.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
|
// checkBoxPantograph_2
|
||||||
|
//
|
||||||
|
checkBoxPantograph_2.AutoSize = true;
|
||||||
|
checkBoxPantograph_2.Location = new Point(10, 149);
|
||||||
|
checkBoxPantograph_2.Name = "checkBoxPantograph_2";
|
||||||
|
checkBoxPantograph_2.Size = new Size(150, 19);
|
||||||
|
checkBoxPantograph_2.TabIndex = 10;
|
||||||
|
checkBoxPantograph_2.Text = "Второй токоприемник";
|
||||||
|
checkBoxPantograph_2.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
// FormLocomotiveConfig
|
// FormLocomotiveConfig
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
@ -332,7 +344,7 @@
|
|||||||
private Label labelSpeed;
|
private Label labelSpeed;
|
||||||
private CheckBox checkBox3;
|
private CheckBox checkBox3;
|
||||||
private CheckBox checkBox2;
|
private CheckBox checkBox2;
|
||||||
private CheckBox checkBoxPantograph;
|
private CheckBox checkBoxPantograph_1;
|
||||||
private NumericUpDown numericUpDownWeight;
|
private NumericUpDown numericUpDownWeight;
|
||||||
private NumericUpDown numericUpDownSpeed;
|
private NumericUpDown numericUpDownSpeed;
|
||||||
private GroupBox groupBoxColors;
|
private GroupBox groupBoxColors;
|
||||||
@ -352,5 +364,6 @@
|
|||||||
private Label labelSimpleColor;
|
private Label labelSimpleColor;
|
||||||
private Button buttonAddObject;
|
private Button buttonAddObject;
|
||||||
private Button buttonCancelObject;
|
private Button buttonCancelObject;
|
||||||
|
private CheckBox checkBoxPantograph_2;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -78,7 +78,7 @@ namespace ElectricLocomotive
|
|||||||
break;
|
break;
|
||||||
case "labelAdvancedObject":
|
case "labelAdvancedObject":
|
||||||
_locomotive = new DrawningElectricLocomotive((int)numericUpDownSpeed.Value,
|
_locomotive = new DrawningElectricLocomotive((int)numericUpDownSpeed.Value,
|
||||||
(int)numericUpDownWeight.Value, Color.Blue, Color.Red, checkBoxPantograph.Checked,
|
(int)numericUpDownWeight.Value, Color.Blue, Color.Red, checkBoxPantograph_1.Checked, checkBoxPantograph_2.Checked,
|
||||||
pictureBoxLoco.Width, pictureBoxLoco.Height);
|
pictureBoxLoco.Width, pictureBoxLoco.Height);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user