финальные изменения по 5 лр
This commit is contained in:
parent
5ae6385332
commit
ccf345af82
@ -181,11 +181,25 @@
|
||||
_startPosY = _pictureHeight.Value - _shipHeight;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение текущей позиции объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
|
||||
public void SetBaseColor(Color color)
|
||||
{
|
||||
if (Ship is EntityWarmlyShip)
|
||||
{
|
||||
Ship = (EntityWarmlyShip)Ship;
|
||||
if (Ship is not null)
|
||||
{
|
||||
Ship = new EntityWarmlyShip(Ship.Speed, Ship.Weight, color, (Ship as EntityWarmlyShip).DopColor, (Ship as EntityWarmlyShip).Pipes, (Ship as EntityWarmlyShip).FuelCompartment);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Ship = new EntityShip(Ship.Speed, Ship.Weight, color);
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение текущей позиции объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return (_startPosX, _startPosY, _startPosX + _shipWidth, _startPosY + _shipHeight);
|
||||
}
|
||||
|
@ -53,5 +53,13 @@ namespace WarmlyShip
|
||||
g.DrawRectangle(pen, _startPosX + 135, _startPosY + 70, 10, 5);
|
||||
}
|
||||
}
|
||||
public void SetDopColor(Color color)
|
||||
{
|
||||
Ship = Ship as EntityWarmlyShip;
|
||||
if (Ship is not null)
|
||||
{
|
||||
Ship = new EntityWarmlyShip(Ship.Speed, Ship.Weight, Ship.BodyColor, color, (Ship as EntityWarmlyShip).Pipes, (Ship as EntityWarmlyShip).FuelCompartment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
4
WarmlyShip/WarmlyShip/FormShipConfig.Designer.cs
generated
4
WarmlyShip/WarmlyShip/FormShipConfig.Designer.cs
generated
@ -275,7 +275,7 @@
|
||||
this.labelDopColor.Text = "Доп. цвет";
|
||||
this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragDrop);
|
||||
this.labelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragEnter);
|
||||
this.labelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
|
||||
//
|
||||
// labelBaseColor
|
||||
//
|
||||
@ -288,7 +288,7 @@
|
||||
this.labelBaseColor.Text = "Цвет";
|
||||
this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelBaseColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragDrop);
|
||||
this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragEnter);
|
||||
this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
|
@ -12,7 +12,7 @@ namespace WarmlyShip
|
||||
{
|
||||
public partial class FormShipConfig : Form
|
||||
{
|
||||
private event ShipDelegate EventAddShip;
|
||||
private event Action<DrawningShip> EventAddShip;
|
||||
|
||||
DrawningShip _ship = null;
|
||||
public FormShipConfig()
|
||||
@ -26,7 +26,7 @@ namespace WarmlyShip
|
||||
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
buttonCancel.Click += (s, e) => Close();
|
||||
buttonCancel.Click += (sender, e) => Close();
|
||||
}
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
@ -41,11 +41,11 @@ namespace WarmlyShip
|
||||
_ship?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
public void AddEvent(ShipDelegate ev)
|
||||
public void AddEvent(Action<DrawningShip> ev)
|
||||
{
|
||||
if (EventAddShip == null)
|
||||
{
|
||||
EventAddShip = new ShipDelegate(ev);
|
||||
EventAddShip = new(ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -91,36 +91,11 @@ namespace WarmlyShip
|
||||
|
||||
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "panelRed":
|
||||
labelBaseColor.BackColor = Color.Red;
|
||||
break;
|
||||
case "panelBlack":
|
||||
labelBaseColor.BackColor = Color.Black;
|
||||
break;
|
||||
case "panelGreen":
|
||||
labelBaseColor.BackColor = Color.Green;
|
||||
break;
|
||||
case "panelYellow":
|
||||
labelBaseColor.BackColor = Color.Yellow;
|
||||
break;
|
||||
case "panelBlue":
|
||||
labelBaseColor.BackColor = Color.Blue;
|
||||
break;
|
||||
case "panelPurple":
|
||||
labelBaseColor.BackColor = Color.Purple;
|
||||
break;
|
||||
case "panelGray":
|
||||
labelBaseColor.BackColor = Color.DarkGray;
|
||||
break;
|
||||
case "panelWhite":
|
||||
labelBaseColor.BackColor = Color.White;
|
||||
break;
|
||||
}
|
||||
_ship.SetBaseColor((Color)e.Data.GetData(typeof(Color)));
|
||||
DrawShip();
|
||||
}
|
||||
|
||||
private void LabelBaseColor_DragEnter(object sender, DragEventArgs e)
|
||||
private void LabelColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
@ -134,45 +109,12 @@ namespace WarmlyShip
|
||||
|
||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data.GetData(DataFormats.Text).ToString())
|
||||
if (_ship is DrawningWarmlyShip)
|
||||
{
|
||||
case "panelRed":
|
||||
labelBaseColor.BackColor = Color.Red;
|
||||
break;
|
||||
case "panelBlack":
|
||||
labelBaseColor.BackColor = Color.Black;
|
||||
break;
|
||||
case "panelGreen":
|
||||
labelBaseColor.BackColor = Color.Green;
|
||||
break;
|
||||
case "panelYellow":
|
||||
labelBaseColor.BackColor = Color.Yellow;
|
||||
break;
|
||||
case "panelBlue":
|
||||
labelBaseColor.BackColor = Color.Blue;
|
||||
break;
|
||||
case "panelPurple":
|
||||
labelBaseColor.BackColor = Color.Purple;
|
||||
break;
|
||||
case "panelGray":
|
||||
labelBaseColor.BackColor = Color.DarkGray;
|
||||
break;
|
||||
case "panelWhite":
|
||||
labelBaseColor.BackColor = Color.White;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void LabelDopColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
var ship = _ship as DrawningWarmlyShip;
|
||||
ship.SetDopColor((Color)e.Data.GetData(typeof(Color)));
|
||||
}
|
||||
DrawShip();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WarmlyShip
|
||||
{
|
||||
/// <summary>
|
||||
/// Делегат для передачи объекта-коробля
|
||||
/// </summary>
|
||||
/// <param name="car"></param>
|
||||
public delegate void ShipDelegate(DrawningShip car);
|
||||
}
|
Loading…
Reference in New Issue
Block a user