Этап 4, движение рисунка
This commit is contained in:
parent
520f30955f
commit
077feaab14
@ -88,6 +88,22 @@ public class DrawningDiselLoko
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (x < 0)
|
||||||
|
{
|
||||||
|
x = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y < 0) { y = 1; }
|
||||||
|
|
||||||
|
if (x + _drawingCarWidth > _pictureWidth.Value) {
|
||||||
|
x = _pictureWidth.Value - _drawingCarWidth - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y + _drawingCarHeight > _pictureHeight.Value)
|
||||||
|
{
|
||||||
|
y = _pictureHeight.Value - _drawingCarHeight - 1;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы
|
// TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы
|
||||||
// то надо изменить координаты, чтобы он оставался в этих границах
|
// то надо изменить координаты, чтобы он оставался в этих границах
|
||||||
_startPosX = x;
|
_startPosX = x;
|
||||||
@ -110,7 +126,7 @@ public class DrawningDiselLoko
|
|||||||
{
|
{
|
||||||
//влево
|
//влево
|
||||||
case Direction.Left:
|
case Direction.Left:
|
||||||
if (_startPosX.Value - DiselLoko.Step > 0)
|
if (_startPosX.Value - DiselLoko.Step - 10 > 0)
|
||||||
{
|
{
|
||||||
_startPosX -= (int)DiselLoko.Step;
|
_startPosX -= (int)DiselLoko.Step;
|
||||||
}
|
}
|
||||||
@ -124,14 +140,14 @@ public class DrawningDiselLoko
|
|||||||
return true;
|
return true;
|
||||||
// вправо
|
// вправо
|
||||||
case Direction.Right:
|
case Direction.Right:
|
||||||
if (_startPosX.Value - DiselLoko.Step > 0)
|
if (_startPosX.Value + DiselLoko.Step + _drawingCarWidth/2 < _pictureWidth.Value - _drawingCarWidth)
|
||||||
{
|
{
|
||||||
_startPosX += (int)DiselLoko.Step;
|
_startPosX += (int)DiselLoko.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
//вниз
|
//вниз
|
||||||
case Direction.Down:
|
case Direction.Down:
|
||||||
if (_startPosX.Value - DiselLoko.Step > 0)
|
if (_startPosY.Value + DiselLoko.Step + _drawingCarWidth / 4 < _pictureHeight.Value - _drawingCarHeight)
|
||||||
{
|
{
|
||||||
_startPosY += (int)DiselLoko.Step;
|
_startPosY += (int)DiselLoko.Step;
|
||||||
}
|
}
|
||||||
@ -155,6 +171,7 @@ public class DrawningDiselLoko
|
|||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
Brush additionalBrush = new SolidBrush(DiselLoko.ColorBody);
|
Brush additionalBrush = new SolidBrush(DiselLoko.ColorBody);
|
||||||
Brush blueBrush = Brushes.Blue;
|
Brush blueBrush = Brushes.Blue;
|
||||||
|
Brush grayBrush = Brushes.Gray;
|
||||||
|
|
||||||
|
|
||||||
Pen blackPen = new Pen(Color.Black, 2);
|
Pen blackPen = new Pen(Color.Black, 2);
|
||||||
@ -257,16 +274,31 @@ public class DrawningDiselLoko
|
|||||||
// труба
|
// труба
|
||||||
if (DiselLoko.IsTube)
|
if (DiselLoko.IsTube)
|
||||||
{
|
{
|
||||||
|
// **Труба (полигон)**
|
||||||
|
Point[] chimney = {
|
||||||
|
new Point(_startPosX.Value + 20, _startPosY.Value - 20),
|
||||||
|
new Point(_startPosX.Value + 35, _startPosY.Value - 20),
|
||||||
|
new Point(_startPosX.Value + 35, _startPosY.Value),
|
||||||
|
new Point(_startPosX.Value + 20, _startPosY.Value)
|
||||||
|
};
|
||||||
|
g.FillPolygon(blackBrush, chimney);
|
||||||
}
|
}
|
||||||
|
|
||||||
// отсек
|
// отсек
|
||||||
if (DiselLoko.IsComportament)
|
if (DiselLoko.IsComportament)
|
||||||
{
|
{
|
||||||
/*g.FillRectangle(additionalBrush, _startPosX.Value + 75, _startPosY.Value + 23, 25, 15);
|
//Топливный отсек(полигон)
|
||||||
g.FillRectangle(additionalBrush, _startPosX.Value + 35, _startPosY.Value + 23, 35, 15);
|
Point[] fuelTank = {
|
||||||
g.FillRectangle(additionalBrush, _startPosX.Value + 10, _startPosY.Value + 23, 20, 15);*/
|
new Point(_startPosX.Value + 110, _startPosY.Value + _drawingCarHeight-20), // Верхний левый угол
|
||||||
|
new Point(_startPosX.Value + 130, _startPosY.Value + _drawingCarHeight -20), // Верхний правый угол
|
||||||
|
new Point(_startPosX.Value +130 , _startPosY.Value + _drawingCarHeight-5), // Нижний правый угол
|
||||||
|
new Point(_startPosX.Value + 110, _startPosY.Value + _drawingCarHeight-5) // Нижний левый угол
|
||||||
|
};
|
||||||
|
g.FillPolygon(grayBrush, fuelTank);
|
||||||
|
g.DrawPolygon(blackPen, fuelTank);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user