ISEbd-22. Baygulov A.A. Lab work 05 #6

Closed
tellsense wants to merge 8 commits from lab5 into lab4
5 changed files with 18 additions and 18 deletions
Showing only changes of commit 559876c90b - Show all commits

View File

@ -46,7 +46,7 @@ namespace ProjectElectricLocomotive.DrawingObjects
g.DrawLine(pen, _startPosX + 40, _startPosY + 15, _startPosX + 60, _startPosY + 2);
base.DrawTransport(g);
}
public void SetAddColor(Color color)
public void SetAdditionalColor(Color color)
{
(EntityLocomotive as EntityElectricLocomotive).SetAdditionalColor(color);
}

View File

@ -13,7 +13,7 @@ namespace ProjectElectricLocomotive.DrawingObjects
{
public class DrawingLocomotive
{
public EntityLocomotive? EntityLocomotive { get; protected set; }
public EntityLocomotive? EntityLocomotive { get; protected set;}
public int _pictureWidth;
public int _pictureHeight;
@ -166,9 +166,9 @@ namespace ProjectElectricLocomotive.DrawingObjects
}
public IMoveableObject GetMoveableObject => new
DrawingObjectLocomotive(this);
public void SetColor(Color color)
public void SetBodyColor(Color color)
{
(EntityLocomotive as EntityLocomotive).SetColor(color);
EntityLocomotive.SetBodyColor(color);
}
}
}

View File

@ -10,8 +10,8 @@ namespace ProjectElectricLocomotive.Entities
public class EntityElectricLocomotive : EntityLocomotive
{
public Color AdditionalColor { get; private set; }
public bool Pantograph { get; private set; }
public bool Compartment { get; private set; }
public bool Pantograph { get; set; }
public bool Compartment { get; set; }
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="pantograph">Признак наличия токоприемника</param>

View File

@ -10,7 +10,7 @@ namespace ProjectElectricLocomotive.Entities
{
public int Speed { get; private set; }
public double Weight { get; private set; }
public Color BodyColor { get; private set; }
public Color BodyColor { get; protected set; }
public double Step => (double)Speed * 100 / Weight;
/// <param name="speed">Скорость</param>
@ -22,7 +22,7 @@ namespace ProjectElectricLocomotive.Entities
Weight = weight;
BodyColor = bodyColor;
}
public void SetColor(Color color)
public void SetBodyColor(Color color)
{
BodyColor = color;
}

View File

@ -9,6 +9,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ProjectElectricLocomotive.Entities;
namespace ProjectElectricLocomotive
{
@ -28,8 +29,6 @@ namespace ProjectElectricLocomotive
panelColorWhite.MouseDown += PanelColor_MouseDown;
panelColorYellow.MouseDown += PanelColor_MouseDown;
panelColorBlue.MouseDown += PanelColor_MouseDown;
labelSimpleObject.MouseDown += LabelObject_MouseDown;
labelAdvancedObject.MouseDown += LabelObject_MouseDown;
buttonCancelObject.Click += (s, e) => Close();
@ -81,8 +80,7 @@ namespace ProjectElectricLocomotive
case "labelAdvancedObject":
_locomotive = new DrawingElectricLocomotive((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxPantograph.Checked,
checkBoxCompartment.Checked, pictureBoxLoco.Width,
pictureBoxLoco.Height);
checkBoxCompartment.Checked, pictureBoxLoco.Width, pictureBoxLoco.Height);
break;
}
DrawLocomotive();
@ -102,18 +100,20 @@ namespace ProjectElectricLocomotive
private void LabelColor_DragDrop(object sender, DragEventArgs e)
{
if (_locomotive == null)
return;
((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color));
switch (((Label)sender).Name)
{
case "labelSimpleObject":
_locomotive.SetColor((Color)e.Data.GetData(typeof(Color)));
case "labelSimpleColor":
_locomotive.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
break;
case "labelAdvancedObject":
if (_locomotive is not DrawingLocomotive) return;
else
case "labelAdvancedColor":
if (!(_locomotive is DrawingElectricLocomotive))
{
(_locomotive as DrawingElectricLocomotive).SetAddColor((Color)e.Data.GetData(typeof(Color)));
return;
}
(_locomotive as DrawingElectricLocomotive).SetAdditionalColor((Color)e.Data.GetData(typeof(Color)));
break;
}
DrawLocomotive();