diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/DrawningElectricLocomotive.cs b/ProjectElectricLocomotive/ProjectElectricLocomotive/DrawningElectricLocomotive.cs
index 616d472..1842639 100644
--- a/ProjectElectricLocomotive/ProjectElectricLocomotive/DrawningElectricLocomotive.cs
+++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/DrawningElectricLocomotive.cs
@@ -34,13 +34,13 @@ public class DrawningElectricLocomotive
///
/// Ширина прорисовки электровоза
///
- private readonly int _drawningElectricLocomotiveWidth = 100;
+ private readonly int _drawningElectricLocomotiveWidth = 83;
///
/// Высота прорисовки электровоза
///
- private readonly int _drawingElectricLocomotiveHeight = 45;
+ private readonly int _drawningElectricLocomotiveHeight = 45;
///
/// Инициализация свойств
@@ -71,13 +71,19 @@ public class DrawningElectricLocomotive
/// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах
public bool SetPictureSize(int width, int height)
{
- // Проверка, что объект "влезает" в размеры поля
- // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена
- if(_drawingElectricLocomotiveHeight > height || _drawningElectricLocomotiveWidth > width)
+ if(_drawningElectricLocomotiveHeight > height || _drawningElectricLocomotiveWidth > width)
{
return false;
}
+ if(_startPosY.HasValue && _startPosY - _drawningElectricLocomotiveHeight < _pictureHeight )
+ {
+ _startPosY -= _drawningElectricLocomotiveHeight;
+ }
+ if (_startPosX.HasValue && _startPosX - _drawningElectricLocomotiveWidth < _pictureWidth )
+ {
+ _startPosX -= _drawningElectricLocomotiveWidth;
+ }
_pictureWidth = width;
_pictureHeight = height;
return true;
@@ -94,17 +100,30 @@ public class DrawningElectricLocomotive
return;
}
- if (_drawingElectricLocomotiveHeight + y > _pictureHeight || _drawningElectricLocomotiveWidth + x > _pictureWidth)
+
+ _startPosX = x;
+ _startPosY = y;
+
+ if ( _drawningElectricLocomotiveHeight + y > _pictureHeight)
+ {
+ _startPosY = _pictureHeight - _drawningElectricLocomotiveHeight;
+ }
+ if ( _drawningElectricLocomotiveWidth + x > _pictureWidth)
+ {
+ _startPosX = _pictureWidth - _drawningElectricLocomotiveWidth;
+
+ }
+ if (x < 0)
{
_startPosX = 0;
- _startPosY = 0;
+
}
- else
+ if (y < 0)
{
- _startPosX = x;
- _startPosY = y;
+ _startPosY = 0;
+
}
-
+
}
///
@@ -123,14 +142,14 @@ public class DrawningElectricLocomotive
{
//влево
case DirectionType.Left:
- if(_startPosX.Value - EntityElectricLocomotive.Step + 20 > 0)
+ if(_startPosX.Value - EntityElectricLocomotive.Step > 0)
{
_startPosX -= (int)EntityElectricLocomotive.Step;
}
return true;
//вверх
case DirectionType.Up:
- if(_startPosY.Value - EntityElectricLocomotive.Step + 3 > 0)
+ if(_startPosY.Value - EntityElectricLocomotive.Step > 0)
{
_startPosY -= (int)EntityElectricLocomotive.Step;
}
@@ -144,7 +163,7 @@ public class DrawningElectricLocomotive
return true;
//вниз
case DirectionType.Down:
- if (_startPosY.Value + _drawingElectricLocomotiveHeight + EntityElectricLocomotive.Step < _pictureHeight)
+ if (_startPosY.Value + _drawningElectricLocomotiveHeight + EntityElectricLocomotive.Step < _pictureHeight)
{
_startPosY += (int)EntityElectricLocomotive.Step;
}
@@ -175,31 +194,31 @@ public class DrawningElectricLocomotive
Brush whiteBrush = new SolidBrush(Color.White);
//Инициализация опорных точек для прорисовки корпуса
- Point pointStart = new Point(_startPosX.Value + 90, _startPosY.Value + 20);
- Point point1 = new Point(_startPosX.Value + 90, _startPosY.Value + 5);
- Point point2 = new Point(_startPosX.Value + 25, _startPosY.Value + 5);
- Point pointFinish = new Point(_startPosX.Value + 20, _startPosY.Value + 20);
+ Point pointStart = new Point(_startPosX.Value + 75, _startPosY.Value + 20);
+ Point point1 = new Point(_startPosX.Value + 75, _startPosY.Value + 5);
+ Point point2 = new Point(_startPosX.Value + 10, _startPosY.Value + 5);
+ Point pointFinish = new Point(_startPosX.Value + 5, _startPosY.Value + 20);
//Инициализация опорных точек для прорисовки первой "юбки"
- Point point3 = new Point(_startPosX.Value + 22, _startPosY.Value + 37);
- Point point4 = new Point(_startPosX.Value + 15, _startPosY.Value + 37 +6 );
- Point point5 = new Point(_startPosX.Value + 22, _startPosY.Value + 37 + 6 );
+ Point point3 = new Point(_startPosX.Value + 7, _startPosY.Value + 37);
+ Point point4 = new Point(_startPosX.Value + 0, _startPosY.Value + 37 +6 );
+ Point point5 = new Point(_startPosX.Value + 7, _startPosY.Value + 37 + 6 );
//Инициализация опорных точек для прорисовки второй "юбки"
- Point point6 = new Point(_startPosX.Value + 84, _startPosY.Value + 37);
- Point point7 = new Point(_startPosX.Value + 90 + 7, _startPosY.Value + 37 + 6);
- Point point8 = new Point(_startPosX.Value + 84, _startPosY.Value + 37 + 6);
+ Point point6 = new Point(_startPosX.Value + 69, _startPosY.Value + 37);
+ Point point7 = new Point(_startPosX.Value + 75 + 7, _startPosY.Value + 37 + 6);
+ Point point8 = new Point(_startPosX.Value + 69, _startPosY.Value + 37 + 6);
//Инициализация опорных точек для прорисовки "рогов"
- Point pointHorns1 = new Point(_startPosX.Value + 28, _startPosY.Value+5);
- Point pointHorns2 = new Point(_startPosX.Value + 31, _startPosY.Value + 2);
- Point pointHorns3 = new Point(_startPosX.Value + 26, _startPosY.Value);
+ Point pointHorns1 = new Point(_startPosX.Value + 13, _startPosY.Value+5);
+ Point pointHorns2 = new Point(_startPosX.Value + 16, _startPosY.Value + 2);
+ Point pointHorns3 = new Point(_startPosX.Value + 11, _startPosY.Value);
//Инициализация опорных точек для прорисовки молнии на хранилище батарей
- Point pointLightning1 = new Point(_startPosX.Value + 54, _startPosY.Value + 37);
- Point pointLightning2 = new Point(_startPosX.Value + 52, _startPosY.Value + 39);
- Point pointLightning3 = new Point(_startPosX.Value + 54, _startPosY.Value + 40);
- Point pointLightning4 = new Point(_startPosX.Value + 52, _startPosY.Value + 41);
+ Point pointLightning1 = new Point(_startPosX.Value + 39, _startPosY.Value + 37);
+ Point pointLightning2 = new Point(_startPosX.Value + 37, _startPosY.Value + 39);
+ Point pointLightning3 = new Point(_startPosX.Value + 39, _startPosY.Value + 40);
+ Point pointLightning4 = new Point(_startPosX.Value + 37, _startPosY.Value + 41);
//Совокупность точек полигона уголка первой "юбки"
Point[] firstTrianglePoints =
@@ -225,7 +244,7 @@ public class DrawningElectricLocomotive
g.FillPolygon(blackBrush, secondTrianglePoints);
//Прорисовка корпуса
- g.DrawRectangle(pen, _startPosX.Value + 20, _startPosY.Value + 20, 70, 17);
+ g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value + 20, 70, 17);
g.DrawLine(pen, point3, point4);
g.DrawLine(pen, pointStart, point1);
@@ -235,41 +254,41 @@ public class DrawningElectricLocomotive
//Прорисовка передней и задней "юбки"
- g.FillRectangle(blackBrush, _startPosX.Value + 22, _startPosY.Value + 37, 25, 5.3f);
- g.FillRectangle(blackBrush, _startPosX.Value + 62, _startPosY.Value + 37, 22, 5.3f);
+ g.FillRectangle(blackBrush, _startPosX.Value + 7, _startPosY.Value + 37, 25, 5.3f);
+ g.FillRectangle(blackBrush, _startPosX.Value + 47, _startPosY.Value + 37, 22, 5.3f);
//Прорисовка двух передних колёс
- g.FillEllipse(whiteBrush, _startPosX.Value + 21.3f, _startPosY.Value + 37, 10, 10);
+ g.FillEllipse(whiteBrush, _startPosX.Value + 6.3f, _startPosY.Value + 37, 10, 10);
+ g.DrawEllipse(penSolid, _startPosX.Value + 9, _startPosY.Value + 37, 8, 8);
+ g.FillEllipse(additionalBrush, _startPosX.Value + 9, _startPosY.Value + 37, 8, 8);
g.DrawEllipse(penSolid, _startPosX.Value + 24, _startPosY.Value + 37, 8, 8);
g.FillEllipse(additionalBrush, _startPosX.Value + 24, _startPosY.Value + 37, 8, 8);
- g.DrawEllipse(penSolid, _startPosX.Value + 39, _startPosY.Value + 37, 8, 8);
- g.FillEllipse(additionalBrush, _startPosX.Value + 39, _startPosY.Value + 37, 8, 8);
//Прорисовка "рогов" электровоза
g.DrawLine(penSolid, pointHorns1, pointHorns2);
g.DrawLine(penSolid, pointHorns2, pointHorns3);
//Прорисовка "хранилища батарей" электровоза
- g.FillRectangle(blackBrush, _startPosX.Value + 51, _startPosY.Value + 37, 8, 4.5f);
+ g.FillRectangle(blackBrush, _startPosX.Value + 36, _startPosY.Value + 37, 8, 4.5f);
g.DrawLine(penSolidYellow, pointLightning1, pointLightning2);
g.DrawLine(penSolidYellow, pointLightning2, pointLightning3);
g.DrawLine(penSolidYellow, pointLightning3, pointLightning4);
//Прорисовка двух задних колёс
- g.FillEllipse(whiteBrush, _startPosX.Value + 40 + 38, _startPosY.Value + 37, 10, 10);
- g.DrawEllipse(penSolid, _startPosX.Value + 40 + 26, _startPosY.Value + 37, 8, 8);
- g.FillEllipse(additionalBrush, _startPosX.Value + 40 + 26, _startPosY.Value + 37, 8, 8);
- g.DrawEllipse(penSolid, _startPosX.Value+ 40 + 37, _startPosY.Value + 37, 8, 8);
- g.FillEllipse(additionalBrush, _startPosX.Value + 40 + 37, _startPosY.Value + 37, 8, 8);
+ g.FillEllipse(whiteBrush, _startPosX.Value + 25 + 38, _startPosY.Value + 37, 10, 10);
+ g.DrawEllipse(penSolid, _startPosX.Value + 25 + 26, _startPosY.Value + 37, 8, 8);
+ g.FillEllipse(additionalBrush, _startPosX.Value + 25 + 26, _startPosY.Value + 37, 8, 8);
+ g.DrawEllipse(penSolid, _startPosX.Value+ 25 + 37, _startPosY.Value + 37, 8, 8);
+ g.FillEllipse(additionalBrush, _startPosX.Value + 25 + 37, _startPosY.Value + 37, 8, 8);
//Прорисовка заднего "шлюза"
- g.FillRectangle(blackBrush, _startPosX.Value + 90, _startPosY.Value + 9, 5.7f, 27.4f);
+ g.FillRectangle(blackBrush, _startPosX.Value + 75, _startPosY.Value + 9, 5.7f, 27.4f);
//Прорисовка первого и третьего окна
- g.DrawRectangle(windowPen, _startPosX.Value + 27, _startPosY.Value + 9, 8, 8);
- g.DrawRectangle(windowPen, _startPosX.Value + 78, _startPosY.Value + 9, 8, 8);
+ g.DrawRectangle(windowPen, _startPosX.Value + 12, _startPosY.Value + 9, 8, 8);
+ g.DrawRectangle(windowPen, _startPosX.Value + 63, _startPosY.Value + 9, 8, 8);
//TODO Опциональная прорисовка колёс для усложненной работы
@@ -294,11 +313,11 @@ public class DrawningElectricLocomotive
if (EntityElectricLocomotive.BodyKit)
{
Brush brWhite = new SolidBrush(Color.White);
- g.DrawRectangle(windowPen, _startPosX.Value + 39.3f, _startPosY.Value + 9, 8, 8);
+ g.DrawRectangle(windowPen, _startPosX.Value + 24.3f, _startPosY.Value + 9, 8, 8);
- g.DrawRectangle(pen, _startPosX.Value + 50, _startPosY.Value + 14, 8, 12);
+ g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value + 14, 8, 12);
- g.FillRectangle(brWhite, _startPosX.Value + 51, _startPosY.Value + 16, 7, 10);
+ g.FillRectangle(brWhite, _startPosX.Value + 36, _startPosY.Value + 16, 7, 10);
}
}
diff --git a/cfdiv3/cfdiv3.sln b/cfdiv3/cfdiv3.sln
new file mode 100644
index 0000000..7695ced
--- /dev/null
+++ b/cfdiv3/cfdiv3.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.7.34024.191
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cfdiv3", "cfdiv3\cfdiv3.vcxproj", "{A580EAEA-AEBB-4210-8DFA-E3E1241D9FCF}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A580EAEA-AEBB-4210-8DFA-E3E1241D9FCF}.Debug|x64.ActiveCfg = Debug|x64
+ {A580EAEA-AEBB-4210-8DFA-E3E1241D9FCF}.Debug|x64.Build.0 = Debug|x64
+ {A580EAEA-AEBB-4210-8DFA-E3E1241D9FCF}.Debug|x86.ActiveCfg = Debug|Win32
+ {A580EAEA-AEBB-4210-8DFA-E3E1241D9FCF}.Debug|x86.Build.0 = Debug|Win32
+ {A580EAEA-AEBB-4210-8DFA-E3E1241D9FCF}.Release|x64.ActiveCfg = Release|x64
+ {A580EAEA-AEBB-4210-8DFA-E3E1241D9FCF}.Release|x64.Build.0 = Release|x64
+ {A580EAEA-AEBB-4210-8DFA-E3E1241D9FCF}.Release|x86.ActiveCfg = Release|Win32
+ {A580EAEA-AEBB-4210-8DFA-E3E1241D9FCF}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {C6324E34-5959-487B-98C6-891D3D3A1B32}
+ EndGlobalSection
+EndGlobal
diff --git a/cfdiv3/cfdiv3/A.cpp b/cfdiv3/cfdiv3/A.cpp
new file mode 100644
index 0000000..e2cb95d
--- /dev/null
+++ b/cfdiv3/cfdiv3/A.cpp
@@ -0,0 +1,70 @@
+#define _USE_MATH_DEFINES
+#define _CRT_SECURE_NO_WARNINGS
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include