Fix
This commit is contained in:
parent
ab9fdf006d
commit
2bdfda9ce9
@ -20,16 +20,20 @@ namespace AirPlaneWithRadar
|
||||
{
|
||||
Plain = new EntetyPlain(speed, weight, bodycolor);
|
||||
}
|
||||
protected DrawingPlain(int speed, float weight,Color bodyColor,int plainWidth,int plainHeight):
|
||||
this(speed,weight, bodyColor)
|
||||
protected DrawingPlain(int speed, float weight, Color bodyColor, int plainWidth, int plainHeight) :
|
||||
this(speed, weight, bodyColor)
|
||||
{
|
||||
this.plainWidth = plainWidth;
|
||||
this.plainHeight = plainHeight;
|
||||
}
|
||||
|
||||
public void setPosition(int x,int y,int width,int height)
|
||||
public void ReColor(Color col)
|
||||
{
|
||||
if (x + plainWidth > width || y + plainHeight > height || plainHeight > height || plainWidth > width || x <0 || y<0)
|
||||
Plain.BodyColor = col;
|
||||
}
|
||||
|
||||
public void setPosition(int x, int y, int width, int height)
|
||||
{
|
||||
if (x + plainWidth > width || y + plainHeight > height || plainHeight > height || plainWidth > width || x < 0 || y < 0)
|
||||
return;
|
||||
else
|
||||
{
|
||||
@ -39,11 +43,11 @@ namespace AirPlaneWithRadar
|
||||
pictureHeight = height;
|
||||
}
|
||||
}
|
||||
public void MoveTransport (Direction direction)
|
||||
public void MoveTransport(Direction direction)
|
||||
{
|
||||
if(!pictureWidth.HasValue || !pictureHeight.HasValue)
|
||||
{ return; }
|
||||
switch (direction)
|
||||
if (!pictureWidth.HasValue || !pictureHeight.HasValue)
|
||||
{ return; }
|
||||
switch (direction)
|
||||
{
|
||||
case Direction.Right:
|
||||
if (startPosX + plainWidth + Plain.Step < pictureWidth)
|
||||
@ -51,7 +55,7 @@ namespace AirPlaneWithRadar
|
||||
break;
|
||||
|
||||
case Direction.Left:
|
||||
if (startPosX -Plain.Step > 0)
|
||||
if (startPosX - Plain.Step > 0)
|
||||
startPosX -= Plain.Step;
|
||||
break;
|
||||
case Direction.Down:
|
||||
@ -59,14 +63,14 @@ namespace AirPlaneWithRadar
|
||||
startPosY += Plain.Step;
|
||||
break;
|
||||
case Direction.Up:
|
||||
if (startPosY - Plain.Step >0)
|
||||
if (startPosY - Plain.Step > 0)
|
||||
startPosY -= Plain.Step;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public virtual void DrawTransoprt (Graphics g)
|
||||
public virtual void DrawTransoprt(Graphics g)
|
||||
{
|
||||
if(startPosX < 0 || startPosY < 0 || !pictureHeight.HasValue || !pictureWidth.HasValue)
|
||||
if (startPosX < 0 || startPosY < 0 || !pictureHeight.HasValue || !pictureWidth.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -76,10 +80,10 @@ namespace AirPlaneWithRadar
|
||||
|
||||
g.DrawRectangle(pen, startPosX, startPosY, 20, 30);
|
||||
g.DrawRectangle(pen, startPosX, startPosY + 30, 100, 30);
|
||||
g.DrawRectangle(pen, startPosX+100, startPosY + 40, 20, 15);
|
||||
g.DrawRectangle(pen, startPosX + 100, startPosY + 40, 20, 15);
|
||||
//koleso1
|
||||
g.DrawRectangle(pen, startPosX + 30, startPosY + 60, 5, 10);
|
||||
g.DrawEllipse(pen, startPosX+28, startPosY+70, 9, 9);
|
||||
g.DrawEllipse(pen, startPosX + 28, startPosY + 70, 9, 9);
|
||||
//koleso2
|
||||
g.DrawRectangle(pen, startPosX + 80, startPosY + 60, 5, 10);
|
||||
g.DrawEllipse(pen, startPosX + 78, startPosY + 70, 9, 9);
|
||||
@ -87,8 +91,8 @@ namespace AirPlaneWithRadar
|
||||
|
||||
//Korpys
|
||||
Brush br = new SolidBrush(Plain?.BodyColor ?? Color.Black);
|
||||
g.FillRectangle(br, startPosX+3, startPosY + 33, 94, 24);
|
||||
g.FillRectangle(br, startPosX+1, startPosY+1, 19, 29);
|
||||
g.FillRectangle(br, startPosX + 3, startPosY + 33, 94, 24);
|
||||
g.FillRectangle(br, startPosX + 1, startPosY + 1, 19, 29);
|
||||
|
||||
|
||||
//krilya
|
||||
@ -109,7 +113,7 @@ namespace AirPlaneWithRadar
|
||||
{
|
||||
pictureWidth = width;
|
||||
pictureHeight = height;
|
||||
if(pictureWidth < plainWidth || pictureHeight < plainHeight)
|
||||
if (pictureWidth < plainWidth || pictureHeight < plainHeight)
|
||||
{
|
||||
pictureWidth = null;
|
||||
pictureHeight = null;
|
||||
@ -118,7 +122,7 @@ namespace AirPlaneWithRadar
|
||||
if (startPosX + plainWidth > pictureWidth)
|
||||
startPosX = pictureWidth.Value - plainWidth;
|
||||
|
||||
if(startPosY + plainHeight > pictureHeight)
|
||||
if (startPosY + plainHeight > pictureHeight)
|
||||
startPosY = pictureHeight.Value - plainHeight;
|
||||
}
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
|
@ -9,13 +9,18 @@ namespace AirPlaneWithRadar
|
||||
{
|
||||
internal class DrawingRadarPlane : DrawingPlain
|
||||
{
|
||||
public DrawingRadarPlane(int speed, float weight, Color bodyColor,Color dopColor, bool radar, bool oilBox) : base(speed, weight, bodyColor, 110, 60)
|
||||
public DrawingRadarPlane(int speed, float weight, Color bodyColor, Color dopColor, bool radar, bool oilBox) : base(speed, weight, bodyColor, 110, 60)
|
||||
{
|
||||
Plain = new RadioPlane(speed, weight, bodyColor, dopColor, radar, oilBox);
|
||||
}
|
||||
|
||||
public void ReColorDop(Color dopCol)
|
||||
{
|
||||
(Plain as RadioPlane).DopColor = dopCol;
|
||||
}
|
||||
public override void DrawTransoprt(Graphics g)
|
||||
{
|
||||
if(Plain is not RadioPlane radioPlane)
|
||||
if (Plain is not RadioPlane radioPlane)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -27,7 +32,7 @@ namespace AirPlaneWithRadar
|
||||
g.DrawRectangle(pen, startPosX + 40, startPosY + 48, 20, 10);
|
||||
g.FillRectangle(doBrush, startPosX + 40, startPosY + 48, 20, 10);
|
||||
|
||||
g.DrawRectangle(pen, startPosX , startPosY+15, 30, 10);
|
||||
g.DrawRectangle(pen, startPosX, startPosY + 15, 30, 10);
|
||||
g.FillRectangle(doBrush, startPosX, startPosY + 15, 30, 10);
|
||||
}
|
||||
if (radioPlane.Radar)
|
||||
|
@ -9,9 +9,9 @@ namespace AirPlaneWithRadar
|
||||
public class EntetyPlain
|
||||
|
||||
{
|
||||
public int Speed { get;private set; }
|
||||
public int Speed { get; private set; }
|
||||
public float Weight { get; private set; }
|
||||
public Color BodyColor { get; private set; }
|
||||
public Color BodyColor { get; set; }
|
||||
public float Step => Speed * 100 / Weight;
|
||||
|
||||
public EntetyPlain(int speed, float weight, Color bodyColor)
|
||||
@ -22,6 +22,5 @@ namespace AirPlaneWithRadar
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,26 @@ namespace AirPlaneWithRadar
|
||||
{
|
||||
|
||||
var formPlainConfig = new FormPlaneConfig();
|
||||
formPlainConfig.AddEvent(ReactEv);
|
||||
formPlainConfig.Show();
|
||||
|
||||
}
|
||||
public void ReactEv(DrawingPlain dp)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawingObjectPlane(dp)) >= 0)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
|
||||
}
|
||||
private void ButtonRemovePlain_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ namespace AirPlaneWithRadar
|
||||
{
|
||||
DrawingPlain _Plane = null;
|
||||
|
||||
private event PlainDelegate EventAddPlane;
|
||||
private event Action<DrawingPlain> EventAddPlane;
|
||||
|
||||
public FormPlaneConfig()
|
||||
{
|
||||
@ -40,7 +40,7 @@ namespace AirPlaneWithRadar
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
|
||||
public void AddEvent(PlainDelegate ev)
|
||||
public void AddEvent(Action<DrawingPlain> ev)
|
||||
{
|
||||
if (EventAddPlane == null)
|
||||
{
|
||||
@ -120,12 +120,24 @@ namespace AirPlaneWithRadar
|
||||
|
||||
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
|
||||
if (_Plane is null) return;
|
||||
var col = e.Data.GetData(typeof(Color));
|
||||
Color newCol = (Color)col;
|
||||
labelBaseColor.BackColor = newCol;
|
||||
_Plane?.ReColor(newCol);
|
||||
DrawPlane();
|
||||
}
|
||||
|
||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
|
||||
if (_Plane is DrawingRadarPlane)
|
||||
{
|
||||
var col = e.Data.GetData(typeof(Color));
|
||||
Color newCol = (Color)col;
|
||||
labelDopColor.BackColor = newCol;
|
||||
(_Plane as DrawingRadarPlane).ReColorDop(newCol);
|
||||
DrawPlane();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user