From a8a06c7ebcd6f2437d1d568c2f76d679bc4b512c Mon Sep 17 00:00:00 2001 From: Anastasia Date: Mon, 17 Oct 2022 22:30:08 +0400 Subject: [PATCH 1/6] Generic classes. --- .../AirplaneWithRadar/AbstractMap.cs | 124 ++++++------- .../MapWithSetAirplanesGeneric.cs | 175 ++++++++++++++++++ .../AirplaneWithRadar/SetAirplanesGeneric.cs | 79 ++++++++ 3 files changed, 316 insertions(+), 62 deletions(-) create mode 100644 AirplaneWithRadar/AirplaneWithRadar/MapWithSetAirplanesGeneric.cs create mode 100644 AirplaneWithRadar/AirplaneWithRadar/SetAirplanesGeneric.cs diff --git a/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs b/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs index 1934d8f..8399cdf 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs @@ -33,59 +33,59 @@ namespace AirplaneWithRadar { // TODO проверка, что объект может переместится в требуемом направлении - if (direction == Direction.Right) - { - for (int i = (int)(_drawingObject.GetCurrentPosition().Right / _size_x + 1); i < _drawingObject.GetCurrentPosition().Right + _drawingObject.Step / _size_x + 1; i++) - { - for (int j = (int)(_drawingObject.GetCurrentPosition().Top / _size_y + 1 ); j < _drawingObject.GetCurrentPosition().Bottom / _size_y + 1; j++) - { - if (_map[i, j] == _barrier) - { - break; - } - } - } - } - if (direction == Direction.Up) - { - for (int i = (int)(_drawingObject.GetCurrentPosition().Top - _drawingObject.Step / _size_y); i < _drawingObject.GetCurrentPosition().Top / _size_y; i++) - { - for (int j = (int)(_drawingObject.GetCurrentPosition().Left / _size_x); j < _drawingObject.GetCurrentPosition().Right / _size_x; j++) - { - if (_map[i, j] == _barrier) - { - break; - } - } - } - } - if (direction == Direction.Left) - { - for (int i = (int)(_drawingObject.GetCurrentPosition().Left - _drawingObject.Step / _size_x); i < _drawingObject.GetCurrentPosition().Left / _size_x; i++) - { - for (int j = (int)(_drawingObject.GetCurrentPosition().Top / _size_y); j < _drawingObject.GetCurrentPosition().Bottom / _size_y; j++) - { - if (_map[i, j] == _barrier) - { - break; - } - } - } - } - if (direction == Direction.Down) - { + //if (direction == Direction.Right) + //{ + // for (int i = (int)(_drawingObject.GetCurrentPosition().Right / _size_x + 1); i < _drawingObject.GetCurrentPosition().Right + _drawingObject.Step / _size_x + 1; i++) + // { + // for (int j = (int)(_drawingObject.GetCurrentPosition().Top / _size_y + 1 ); j < _drawingObject.GetCurrentPosition().Bottom / _size_y + 1; j++) + // { + // if (_map[i, j] == _barrier) + // { + // break; + // } + // } + // } + //} + //if (direction == Direction.Up) + //{ + // for (int i = (int)(_drawingObject.GetCurrentPosition().Top - _drawingObject.Step / _size_y); i < _drawingObject.GetCurrentPosition().Top / _size_y; i++) + // { + // for (int j = (int)(_drawingObject.GetCurrentPosition().Left / _size_x); j < _drawingObject.GetCurrentPosition().Right / _size_x; j++) + // { + // if (_map[i, j] == _barrier) + // { + // break; + // } + // } + // } + //} + //if (direction == Direction.Left) + //{ + // for (int i = (int)(_drawingObject.GetCurrentPosition().Left - _drawingObject.Step / _size_x); i < _drawingObject.GetCurrentPosition().Left / _size_x; i++) + // { + // for (int j = (int)(_drawingObject.GetCurrentPosition().Top / _size_y); j < _drawingObject.GetCurrentPosition().Bottom / _size_y; j++) + // { + // if (_map[i, j] == _barrier) + // { + // break; + // } + // } + // } + //} + //if (direction == Direction.Down) + //{ - for (int i = (int)(_drawingObject.GetCurrentPosition().Bottom / _size_y); i < _drawingObject.GetCurrentPosition().Bottom + _drawingObject.Step / _size_y; i++) - { - for (int j = (int)(_drawingObject.GetCurrentPosition().Left / _size_x); j < _drawingObject.GetCurrentPosition().Right / _size_x; j++) - { - if (_map[i, j] == _barrier) - { - break; - } - } - } - } + // for (int i = (int)(_drawingObject.GetCurrentPosition().Bottom / _size_y); i < _drawingObject.GetCurrentPosition().Bottom + _drawingObject.Step / _size_y; i++) + // { + // for (int j = (int)(_drawingObject.GetCurrentPosition().Left / _size_x); j < _drawingObject.GetCurrentPosition().Right / _size_x; j++) + // { + // if (_map[i, j] == _barrier) + // { + // break; + // } + // } + // } + //} if (true) { _drawingObject.MoveObject(direction); @@ -101,16 +101,16 @@ namespace AirplaneWithRadar int x = _random.Next(0, 10); int y = _random.Next(0, 10); _drawingObject.SetObject(x, y, _width, _height); - for (int i = (int)(_drawingObject.GetCurrentPosition().Left/_size_x); i < _drawingObject.GetCurrentPosition().Right/_size_x; i++) - { - for (int j = (int)(_drawingObject.GetCurrentPosition().Top/_size_y); j < _drawingObject.GetCurrentPosition().Bottom/_size_y; j++) - { - if (_map[i,j] == _barrier) - { - return false; - } - } - } + //for (int i = (int)(_drawingObject.GetCurrentPosition().Left/_size_x); i < _drawingObject.GetCurrentPosition().Right/_size_x; i++) + //{ + // for (int j = (int)(_drawingObject.GetCurrentPosition().Top/_size_y); j < _drawingObject.GetCurrentPosition().Bottom/_size_y; j++) + // { + // if (_map[i,j] == _barrier) + // { + // return false; + // } + // } + //} // TODO проверка, что объект не "накладывается" на закрытые участки return true; } diff --git a/AirplaneWithRadar/AirplaneWithRadar/MapWithSetAirplanesGeneric.cs b/AirplaneWithRadar/AirplaneWithRadar/MapWithSetAirplanesGeneric.cs new file mode 100644 index 0000000..80855ad --- /dev/null +++ b/AirplaneWithRadar/AirplaneWithRadar/MapWithSetAirplanesGeneric.cs @@ -0,0 +1,175 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirplaneWithRadar +{ + /// + /// Карта с набром объектов под нее + /// + /// + /// + internal class MapWithSetAirplanesGeneric + where T : class, IDrawingObject + where U : AbstractMap + { + /// + /// Ширина окна отрисовки + /// + private readonly int _pictureWidth; + /// + /// Высота окна отрисовки + /// + private readonly int _pictureHeight; + /// + /// Размер занимаемого объектом места (ширина) + /// + private readonly int _placeSizeWidth = 210; + /// + /// Размер занимаемого объектом места (высота) + /// + private readonly int _placeSizeHeight = 90; + /// + /// Набор объектов + /// + private readonly SetAirplanesGeneric _setAirplanes; + /// + /// Карта + /// + private readonly U _map; + /// + /// Конструктор + /// + /// + /// + /// + public MapWithSetAirplanesGeneric(int picWidth, int picHeight, U map) + { + int width = picWidth / _placeSizeWidth; + int height = picHeight / _placeSizeHeight; + _setAirplanes = new SetAirplanesGeneric(width * height); + _pictureWidth = picWidth; + _pictureHeight = picHeight; + _map = map; + } + /// + /// Перегрузка оператора сложения + /// + /// + /// + /// + public static bool operator +(MapWithSetAirplanesGeneric map, T airplane) + { + return map._setAirplanes.Insert(airplane); + } + /// + /// Перегрузка оператора вычитания + /// + /// + /// + /// + public static bool operator -(MapWithSetAirplanesGeneric map, int position) + { + return map._setAirplanes.Remove(position); + } + /// + /// Вывод всего набора объектов + /// + /// + public Bitmap ShowSet() + { + Bitmap bmp = new(_pictureWidth, _pictureHeight); + Graphics gr = Graphics.FromImage(bmp); + DrawBackground(gr); + DrawAirplanes(gr); + return bmp; + } + /// + /// Просмотр объекта на карте + /// + /// + public Bitmap ShowOnMap() + { + Shaking(); + for (int i = 0; i < _setAirplanes.Count; i++) + { + var airplane = _setAirplanes.Get(i); + if (airplane != null) + { + return _map.CreateMap(_pictureWidth, _pictureHeight, airplane); + } + } + return new(_pictureWidth, _pictureHeight); + } + /// + /// Перемещение объекта по крате + /// + /// + /// + public Bitmap MoveObject(Direction direction) + { + if (_map != null) + { + return _map.MoveObject(direction); + } + return new(_pictureWidth, _pictureHeight); + } + /// + /// "Взбалтываем" набор, чтобы все элементы оказались в начале + /// + private void Shaking() + { + int j = _setAirplanes.Count - 1; + for (int i = 0; i < _setAirplanes.Count; i++) + { + if (_setAirplanes.Get(i) == null) + { + for (; j > i; j--) + { + var car = _setAirplanes.Get(j); + if (car != null) + { + _setAirplanes.Insert(car, i); + _setAirplanes.Remove(j); + break; + } + } + if (j <= i) + { + return; + } + } + } + } + /// + /// Метод отрисовки фона + /// + /// + private void DrawBackground(Graphics g) + { + Pen pen = new(Color.Black, 3); + for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) + { + for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j) + {//линия рамзетки места + g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight); + } + g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, (_pictureHeight / _placeSizeHeight) * _placeSizeHeight); + } + } + /// + /// Метод прорисовки объектов + /// + /// + private void DrawAirplanes(Graphics g) + { + for (int i = 0; i < _setAirplanes.Count; i++) + { + // TODO установка позиции + _setAirplanes.Get(i)?.DrawingObject(g); + } + } + } +} diff --git a/AirplaneWithRadar/AirplaneWithRadar/SetAirplanesGeneric.cs b/AirplaneWithRadar/AirplaneWithRadar/SetAirplanesGeneric.cs new file mode 100644 index 0000000..a678b2a --- /dev/null +++ b/AirplaneWithRadar/AirplaneWithRadar/SetAirplanesGeneric.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirplaneWithRadar +{ + /// + /// Параметризованный набор объектов + /// + /// + internal class SetAirplanesGeneric + where T : class + { + /// + /// Массив объектов, которые храним + /// + private readonly T[] _places; + /// + /// Количество объектов в массиве + /// + public int Count => _places.Length; + /// + /// Конструктор + /// + /// + public SetAirplanesGeneric(int count) + { + _places = new T[count]; + } + /// + /// Добавление объекта в набор + /// + /// Добавляемый автомобиль + /// + public bool Insert(T airplane) + { + // TODO вставка в начало набора + return true; + } + /// + /// Добавление объекта в набор на конкретную позицию + /// + /// Добавляемый автомобиль + /// Позиция + /// + public bool Insert(T airplane, int position) + { + // TODO проверка позиции + // TODO проверка, что элемент массива по этой позиции пустой, если нет, то проверка, что после вставляемого элемента в массиве есть пустой элемент + // сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента + // TODO вставка по позиции + _places[position] = airplane; + return true; + } + /// + /// Удаление объекта из набора с конкретной позиции + /// + /// + /// + public bool Remove(int position) + { + // TODO проверка позиции + // TODO удаление объекта из массива, присовив элементу массива значение null + return true; + } + /// + /// Получение объекта из набора по позиции + /// + /// + /// + public T Get(int position) + { + // TODO проверка позиции + return _places[position]; + } + } +} -- 2.25.1 From 2263aa7c83f99e06a57c3490935d22eb2c874617 Mon Sep 17 00:00:00 2001 From: Anastasia Date: Tue, 1 Nov 2022 10:17:49 +0400 Subject: [PATCH 2/6] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D1=84=D0=BE=D1=80=D0=BC=20=D0=B8=20=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D0=BE=D0=B4=D0=BE=D0=B2=20=D0=BE=D1=82=D1=80=D0=B8=D1=81?= =?UTF-8?q?=D0=BE=D0=B2=D0=BA=D0=B8=20=D1=84=D0=BE=D0=BD=D0=B0=20=D0=B8=20?= =?UTF-8?q?=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D0=B0=20=D0=BE=D0=B1=D1=8A=D0=B5?= =?UTF-8?q?=D0=BA=D1=82=D0=BE=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AirplaneWithRadar/AbstractMap.cs | 122 +++++----- .../AirplaneWithRadar/BlockMap.cs | 80 +++++++ .../AirplaneWithRadar/Direction.cs | 2 +- .../AirplaneWithRadar/DrawingAirplane.cs | 2 +- .../AirplaneWithRadar/EntityAirplane.cs | 2 +- .../FormAirplaneWithRadar.Designer.cs | 13 ++ .../FormAirplaneWithRadar.cs | 14 ++ .../AirplaneWithRadar/FormMap.Designer.cs | 208 ----------------- .../AirplaneWithRadar/FormMap.cs | 102 --------- .../FormMapWithSetAirplanes.Designer.cs | 212 ++++++++++++++++++ .../FormMapWithSetAirplanes.cs | 166 ++++++++++++++ ...mMap.resx => FormMapWithSetAirplanes.resx} | 3 - .../{MyMap.cs => LineMap.cs} | 31 +-- .../MapWithSetAirplanesGeneric.cs | 47 ++-- .../AirplaneWithRadar/Program.cs | 2 +- .../AirplaneWithRadar/SetAirplanesGeneric.cs | 45 +++- 16 files changed, 621 insertions(+), 430 deletions(-) create mode 100644 AirplaneWithRadar/AirplaneWithRadar/BlockMap.cs delete mode 100644 AirplaneWithRadar/AirplaneWithRadar/FormMap.Designer.cs delete mode 100644 AirplaneWithRadar/AirplaneWithRadar/FormMap.cs create mode 100644 AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplanes.Designer.cs create mode 100644 AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplanes.cs rename AirplaneWithRadar/AirplaneWithRadar/{FormMap.resx => FormMapWithSetAirplanes.resx} (93%) rename AirplaneWithRadar/AirplaneWithRadar/{MyMap.cs => LineMap.cs} (68%) diff --git a/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs b/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs index 8399cdf..ea02d63 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs @@ -31,67 +31,62 @@ namespace AirplaneWithRadar } public Bitmap MoveObject(Direction direction) { - // TODO проверка, что объект может переместится в требуемом направлении - - //if (direction == Direction.Right) - //{ - // for (int i = (int)(_drawingObject.GetCurrentPosition().Right / _size_x + 1); i < _drawingObject.GetCurrentPosition().Right + _drawingObject.Step / _size_x + 1; i++) - // { - // for (int j = (int)(_drawingObject.GetCurrentPosition().Top / _size_y + 1 ); j < _drawingObject.GetCurrentPosition().Bottom / _size_y + 1; j++) - // { - // if (_map[i, j] == _barrier) - // { - // break; - // } - // } - // } - //} - //if (direction == Direction.Up) - //{ - // for (int i = (int)(_drawingObject.GetCurrentPosition().Top - _drawingObject.Step / _size_y); i < _drawingObject.GetCurrentPosition().Top / _size_y; i++) - // { - // for (int j = (int)(_drawingObject.GetCurrentPosition().Left / _size_x); j < _drawingObject.GetCurrentPosition().Right / _size_x; j++) - // { - // if (_map[i, j] == _barrier) - // { - // break; - // } - // } - // } - //} - //if (direction == Direction.Left) - //{ - // for (int i = (int)(_drawingObject.GetCurrentPosition().Left - _drawingObject.Step / _size_x); i < _drawingObject.GetCurrentPosition().Left / _size_x; i++) - // { - // for (int j = (int)(_drawingObject.GetCurrentPosition().Top / _size_y); j < _drawingObject.GetCurrentPosition().Bottom / _size_y; j++) - // { - // if (_map[i, j] == _barrier) - // { - // break; - // } - // } - // } - //} - //if (direction == Direction.Down) - //{ - - // for (int i = (int)(_drawingObject.GetCurrentPosition().Bottom / _size_y); i < _drawingObject.GetCurrentPosition().Bottom + _drawingObject.Step / _size_y; i++) - // { - // for (int j = (int)(_drawingObject.GetCurrentPosition().Left / _size_x); j < _drawingObject.GetCurrentPosition().Right / _size_x; j++) - // { - // if (_map[i, j] == _barrier) - // { - // break; - // } - // } - // } - //} - if (true) + if (_drawingObject == null) return DrawMapWithObject(); + bool canMoveObject = true; + switch (direction) + { + case Direction.Left: + if (!CheckBarriers(-1 * _drawingObject.Step, -1 * _drawingObject.Step, 0, 0)) + { + canMoveObject = false; + } + break; + case Direction.Right: + if (!CheckBarriers(_drawingObject.Step, _drawingObject.Step, 0, 0)) + { + canMoveObject = false; + } + break; + case Direction.Up: + if (!CheckBarriers(0, 0, -1 * _drawingObject.Step, -1 * _drawingObject.Step)) + { + canMoveObject = false; + } + break; + case Direction.Down: + if (!CheckBarriers(0, 0, _drawingObject.Step, _drawingObject.Step)) + { + canMoveObject = false; + } + break; + } + if (canMoveObject) { _drawingObject.MoveObject(direction); } return DrawMapWithObject(); } + + private bool CheckBarriers(float leftMove, float rightMove, float topMove, float bottomMove) + { + int left = Convert.ToInt32((_drawingObject.GetCurrentPosition().Left + leftMove) / _size_x); + int right = Convert.ToInt32((_drawingObject.GetCurrentPosition().Right + rightMove) / _size_x); + int top = Convert.ToInt32((_drawingObject.GetCurrentPosition().Top + topMove) / _size_y); + int bottom = Convert.ToInt32((_drawingObject.GetCurrentPosition().Bottom + bottomMove) / _size_y); + if (top < 0 || left < 0 || right >= _map.GetLength(1) || bottom >= _map.GetLength(0)) + { + return false; + } + for (int i = top; i <= bottom; i++) + { + for (int j = left; j <= right; j++) + { + if (_map[j, i] == 1) return false; + } + } + return true; + } + private bool SetObjectOnMap() { if (_drawingObject == null || _map == null) @@ -101,18 +96,13 @@ namespace AirplaneWithRadar int x = _random.Next(0, 10); int y = _random.Next(0, 10); _drawingObject.SetObject(x, y, _width, _height); - //for (int i = (int)(_drawingObject.GetCurrentPosition().Left/_size_x); i < _drawingObject.GetCurrentPosition().Right/_size_x; i++) - //{ - // for (int j = (int)(_drawingObject.GetCurrentPosition().Top/_size_y); j < _drawingObject.GetCurrentPosition().Bottom/_size_y; j++) - // { - // if (_map[i,j] == _barrier) - // { - // return false; - // } - // } - //} // TODO проверка, что объект не "накладывается" на закрытые участки + if (!CheckBarriers(0, 0, 0, 0)) + { + return false; + } return true; + } private Bitmap DrawMapWithObject() { diff --git a/AirplaneWithRadar/AirplaneWithRadar/BlockMap.cs b/AirplaneWithRadar/AirplaneWithRadar/BlockMap.cs new file mode 100644 index 0000000..2c920c7 --- /dev/null +++ b/AirplaneWithRadar/AirplaneWithRadar/BlockMap.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace AirplaneWithRadar +{ + internal class BlockMap : AbstractMap + { + /// + /// Цвет участка закрытого + /// + private readonly Brush barrierColor = new SolidBrush(Color.Beige); + /// + /// Цвет участка открытого + /// + private readonly Brush roadColor = new SolidBrush(Color.LightBlue); + + protected override void DrawBarrierPart(Graphics g, int i, int j) + { + g.FillRectangle(barrierColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1)); + } + protected override void DrawRoadPart(Graphics g, int i, int j) + { + g.FillRectangle(roadColor, i * _size_x, j * _size_y, (i + 1) * (_size_x + 1), (j + 1) * (_size_y + 1)); + + } + + protected override void GenerateMap() + { + _map = new int[100, 100]; + _size_x = (float)_width / _map.GetLength(0); + _size_y = (float)_height / _map.GetLength(1); + int block = 0; + for (int i = 0; i < _map.GetLength(0); i++) + { + for (int j = 0; j < _map.GetLength(1); j++) + { + _map[i, j] = _freeRoad; + } + } + int numberBlocks = _random.Next(10, 15); + while (block < numberBlocks) + { + int x = _random.Next(0, 80); + int y = _random.Next(0, 80); + int blockWidth = _random.Next(0, 19); + int blockHeight = _random.Next(0, 19); + + bool isFree = true; + for (int i = x; i < x + blockWidth; i++) + { + for (int j = y; j < y + blockHeight; j++) + { + if (_map[i, j] != _freeRoad) + { + isFree = false; + break; + } + + } + } + if (isFree) + { + for (int i = x; i < x + blockWidth; i++) + { + for (int j = y; j < y + blockHeight; j++) + { + _map[i, j] = _barrier; + } + } + block++; + } + } + } + } +} diff --git a/AirplaneWithRadar/AirplaneWithRadar/Direction.cs b/AirplaneWithRadar/AirplaneWithRadar/Direction.cs index 9a262a7..9e6fc28 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/Direction.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/Direction.cs @@ -9,7 +9,7 @@ namespace AirplaneWithRadar /// /// Направление перемещения /// - internal enum Direction + public enum Direction { None = 0, Up = 1, diff --git a/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs b/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs index ffadaa1..efeeeb9 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs @@ -9,7 +9,7 @@ namespace AirplaneWithRadar /// /// Класс, отвечающий за прорисовку и перемещение объекта-сущности /// - internal class DrawingAirplane + public class DrawingAirplane { /// /// Класс-сущность diff --git a/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs b/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs index eeb5690..bddb2ba 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs @@ -10,7 +10,7 @@ namespace AirplaneWithRadar /// /// Класс-сущность "Самолет" /// - internal class EntityAirplane + public class EntityAirplane { /// /// Скорость diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.Designer.cs b/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.Designer.cs index 0c78545..c21cf85 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.Designer.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.Designer.cs @@ -39,6 +39,7 @@ this.buttonDown = new System.Windows.Forms.Button(); this.buttonRight = new System.Windows.Forms.Button(); this.buttonCreateModif = new System.Windows.Forms.Button(); + this.buttonSelectAirplane = new System.Windows.Forms.Button(); this.statusStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).BeginInit(); this.SuspendLayout(); @@ -153,11 +154,22 @@ this.buttonCreateModif.UseVisualStyleBackColor = true; this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click); // + // buttonSelectAirplane + // + this.buttonSelectAirplane.Location = new System.Drawing.Point(529, 372); + this.buttonSelectAirplane.Name = "buttonSelectAirplane"; + this.buttonSelectAirplane.Size = new System.Drawing.Size(112, 34); + this.buttonSelectAirplane.TabIndex = 8; + this.buttonSelectAirplane.Text = "Выбрать"; + this.buttonSelectAirplane.UseVisualStyleBackColor = true; + this.buttonSelectAirplane.Click += new System.EventHandler(this.ButtonSelectAirplane_Click); + // // FormAirplaneWithRadar // this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.buttonSelectAirplane); this.Controls.Add(this.buttonCreateModif); this.Controls.Add(this.buttonRight); this.Controls.Add(this.buttonDown); @@ -189,5 +201,6 @@ private Button buttonDown; private Button buttonRight; private Button buttonCreateModif; + private Button buttonSelectAirplane; } } \ No newline at end of file diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.cs b/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.cs index f93bb8a..d98ab40 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.cs @@ -4,6 +4,8 @@ namespace AirplaneWithRadar { private DrawingAirplane _airplane; + public DrawingAirplane SelectedAirplane { get; private set; } + public FormAirplaneWithRadar() { InitializeComponent(); @@ -91,5 +93,17 @@ namespace AirplaneWithRadar SetData(); Draw(); } + + private void ButtonSelectAirplane_Click(object sender, EventArgs e) + { + SelectedAirplane = _airplane; + DialogResult = DialogResult.OK; + + } + + private void FormAirplaneWithRadar_Load_1(object sender, EventArgs e) + { + + } } } \ No newline at end of file diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormMap.Designer.cs b/AirplaneWithRadar/AirplaneWithRadar/FormMap.Designer.cs deleted file mode 100644 index 977ebcf..0000000 --- a/AirplaneWithRadar/AirplaneWithRadar/FormMap.Designer.cs +++ /dev/null @@ -1,208 +0,0 @@ -namespace AirplaneWithRadar -{ - partial class FormMap - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.statusStrip = new System.Windows.Forms.StatusStrip(); - this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel(); - this.pictureBoxAirplane = new System.Windows.Forms.PictureBox(); - this.buttonCreate = new System.Windows.Forms.Button(); - this.buttonUp = new System.Windows.Forms.Button(); - this.buttonLeft = new System.Windows.Forms.Button(); - this.buttonDown = new System.Windows.Forms.Button(); - this.buttonRight = new System.Windows.Forms.Button(); - this.buttonCreateModif = new System.Windows.Forms.Button(); - this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); - this.statusStrip.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).BeginInit(); - this.SuspendLayout(); - // - // statusStrip - // - this.statusStrip.ImageScalingSize = new System.Drawing.Size(24, 24); - this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabelSpeed, - this.toolStripStatusLabelWeight, - this.toolStripStatusLabelBodyColor}); - this.statusStrip.Location = new System.Drawing.Point(0, 418); - this.statusStrip.Name = "statusStrip"; - this.statusStrip.Size = new System.Drawing.Size(800, 32); - this.statusStrip.TabIndex = 0; - // - // toolStripStatusLabelSpeed - // - this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed"; - this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(93, 25); - this.toolStripStatusLabelSpeed.Text = "Скорость:"; - // - // toolStripStatusLabelWeight - // - this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight"; - this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(43, 25); - this.toolStripStatusLabelWeight.Text = "Вес:"; - // - // toolStripStatusLabelBodyColor - // - this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor"; - this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(55, 25); - this.toolStripStatusLabelBodyColor.Text = "Цвет:"; - // - // pictureBoxAirplane - // - this.pictureBoxAirplane.Dock = System.Windows.Forms.DockStyle.Fill; - this.pictureBoxAirplane.Location = new System.Drawing.Point(0, 0); - this.pictureBoxAirplane.Name = "pictureBoxAirplane"; - this.pictureBoxAirplane.Size = new System.Drawing.Size(800, 450); - this.pictureBoxAirplane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.pictureBoxAirplane.TabIndex = 1; - this.pictureBoxAirplane.TabStop = false; - // - // buttonCreate - // - this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonCreate.Location = new System.Drawing.Point(12, 372); - this.buttonCreate.Name = "buttonCreate"; - this.buttonCreate.Size = new System.Drawing.Size(112, 34); - this.buttonCreate.TabIndex = 2; - this.buttonCreate.Text = "Создать"; - this.buttonCreate.UseVisualStyleBackColor = true; - this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click); - // - // buttonUp - // - this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonUp.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.up; - this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonUp.Location = new System.Drawing.Point(711, 340); - this.buttonUp.Name = "buttonUp"; - this.buttonUp.Size = new System.Drawing.Size(30, 30); - this.buttonUp.TabIndex = 3; - this.buttonUp.UseVisualStyleBackColor = true; - this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonLeft - // - this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonLeft.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.left; - this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonLeft.Location = new System.Drawing.Point(675, 376); - this.buttonLeft.Name = "buttonLeft"; - this.buttonLeft.Size = new System.Drawing.Size(30, 30); - this.buttonLeft.TabIndex = 4; - this.buttonLeft.UseVisualStyleBackColor = true; - this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonDown - // - this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonDown.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.down; - this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonDown.Location = new System.Drawing.Point(711, 376); - this.buttonDown.Name = "buttonDown"; - this.buttonDown.Size = new System.Drawing.Size(30, 30); - this.buttonDown.TabIndex = 5; - this.buttonDown.UseVisualStyleBackColor = true; - this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonRight - // - this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonRight.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.right; - this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonRight.Location = new System.Drawing.Point(747, 376); - this.buttonRight.Name = "buttonRight"; - this.buttonRight.Size = new System.Drawing.Size(30, 30); - this.buttonRight.TabIndex = 6; - this.buttonRight.UseVisualStyleBackColor = true; - this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonCreateModif - // - this.buttonCreateModif.Location = new System.Drawing.Point(130, 372); - this.buttonCreateModif.Name = "buttonCreateModif"; - this.buttonCreateModif.Size = new System.Drawing.Size(140, 34); - this.buttonCreateModif.TabIndex = 7; - this.buttonCreateModif.Text = "Модификация"; - this.buttonCreateModif.UseVisualStyleBackColor = true; - this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click); - // - // comboBoxSelectorMap - // - this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxSelectorMap.FormattingEnabled = true; - this.comboBoxSelectorMap.Items.AddRange(new object[] { - "Простая карта", - "Собственная карта"}); - this.comboBoxSelectorMap.Location = new System.Drawing.Point(12, 12); - this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; - this.comboBoxSelectorMap.Size = new System.Drawing.Size(182, 33); - this.comboBoxSelectorMap.TabIndex = 8; - this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged); - // - // FormMap - // - this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Controls.Add(this.comboBoxSelectorMap); - this.Controls.Add(this.statusStrip); - this.Controls.Add(this.buttonCreateModif); - this.Controls.Add(this.buttonRight); - this.Controls.Add(this.buttonDown); - this.Controls.Add(this.buttonLeft); - this.Controls.Add(this.buttonUp); - this.Controls.Add(this.buttonCreate); - this.Controls.Add(this.pictureBoxAirplane); - this.Name = "FormMap"; - this.Text = "Карта"; - this.statusStrip.ResumeLayout(false); - this.statusStrip.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private StatusStrip statusStrip; - private ToolStripStatusLabel toolStripStatusLabelSpeed; - private ToolStripStatusLabel toolStripStatusLabelWeight; - private ToolStripStatusLabel toolStripStatusLabelBodyColor; - private PictureBox pictureBoxAirplane; - private Button buttonCreate; - private Button buttonUp; - private Button buttonLeft; - private Button buttonDown; - private Button buttonRight; - private Button buttonCreateModif; - private ComboBox comboBoxSelectorMap; - } -} \ No newline at end of file diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormMap.cs b/AirplaneWithRadar/AirplaneWithRadar/FormMap.cs deleted file mode 100644 index 9313a2d..0000000 --- a/AirplaneWithRadar/AirplaneWithRadar/FormMap.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace AirplaneWithRadar -{ - public partial class FormMap : Form - { - private AbstractMap _abstractMap; - public FormMap() - { - InitializeComponent(); - _abstractMap = new SimpleMap(); - } - /// - /// Заполнение информации по объекту - /// - /// - private void SetData(DrawingAirplane airplane) - { - toolStripStatusLabelSpeed.Text = $"Скорость: {airplane.Airplane.Speed}"; - toolStripStatusLabelWeight.Text = $"Вес: {airplane.Airplane.Weight}"; - toolStripStatusLabelBodyColor.Text = $"Цвет:{airplane.Airplane.BodyColor.Name}"; - pictureBoxAirplane.Image = _abstractMap.CreateMap(pictureBoxAirplane.Width,pictureBoxAirplane.Height,new DrawingObjectAirplane(airplane)); - } - /// - /// Обработка нажатия кнопки "Создать" - /// - /// - /// - private void ButtonCreate_Click(object sender, EventArgs e) - { - Random rnd = new(); - var airplane = new DrawingAirplane(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); - SetData(airplane); - - } - - private void ButtonMove_Click(object sender, EventArgs e) - { - //получаем имя кнопки - string name = ((Button)sender)?.Name ?? string.Empty; - Direction dir = Direction.None; - switch (name) - { - case "buttonUp": - dir = Direction.Up; - break; - case "buttonDown": - dir = Direction.Down; - break; - case "buttonLeft": - dir = Direction.Left; - break; - case "buttonRight": - dir = Direction.Right; - break; - } - pictureBoxAirplane.Image = _abstractMap?.MoveObject(dir); - - } - - /// - /// Обработка нажатия кнопки "Модификация" - /// - /// - /// - private void ButtonCreateModif_Click(object sender, EventArgs e) - { - Random rnd = new(); - var airplane = new DrawingAirplaneWithRadar(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), - Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2))); - SetData(airplane); - - } - - - private void FormMap_Load(object sender, EventArgs e) - { - - } - - private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) - { - switch (comboBoxSelectorMap.Text) - { - case "Простая карта": - _abstractMap = new SimpleMap(); - break; - case "Собственная карта": - _abstractMap = new MyMap(); - break; - } - } - } -} diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplanes.Designer.cs b/AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplanes.Designer.cs new file mode 100644 index 0000000..23df6e0 --- /dev/null +++ b/AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplanes.Designer.cs @@ -0,0 +1,212 @@ +namespace AirplaneWithRadar +{ + partial class FormMapWithSetAirplanes + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBox = new System.Windows.Forms.GroupBox(); + this.buttonRight = new System.Windows.Forms.Button(); + this.buttonDown = new System.Windows.Forms.Button(); + this.buttonLeft = new System.Windows.Forms.Button(); + this.buttonUp = new System.Windows.Forms.Button(); + this.buttonShowOnMap = new System.Windows.Forms.Button(); + this.buttonShowStorage = new System.Windows.Forms.Button(); + this.buttonRemoveAirplane = new System.Windows.Forms.Button(); + this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox(); + this.buttonAddAirplane = new System.Windows.Forms.Button(); + this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); + this.pictureBox = new System.Windows.Forms.PictureBox(); + this.groupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); + this.SuspendLayout(); + // + // groupBox + // + this.groupBox.Controls.Add(this.buttonRight); + this.groupBox.Controls.Add(this.buttonDown); + this.groupBox.Controls.Add(this.buttonLeft); + this.groupBox.Controls.Add(this.buttonUp); + this.groupBox.Controls.Add(this.buttonShowOnMap); + this.groupBox.Controls.Add(this.buttonShowStorage); + this.groupBox.Controls.Add(this.buttonRemoveAirplane); + this.groupBox.Controls.Add(this.maskedTextBoxPosition); + this.groupBox.Controls.Add(this.buttonAddAirplane); + this.groupBox.Controls.Add(this.comboBoxSelectorMap); + this.groupBox.Dock = System.Windows.Forms.DockStyle.Right; + this.groupBox.Location = new System.Drawing.Point(723, 0); + this.groupBox.Name = "groupBox"; + this.groupBox.Size = new System.Drawing.Size(257, 526); + this.groupBox.TabIndex = 0; + this.groupBox.TabStop = false; + this.groupBox.Text = "Инструменты"; + // + // buttonRight + // + this.buttonRight.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.right; + this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonRight.Location = new System.Drawing.Point(160, 433); + this.buttonRight.Name = "buttonRight"; + this.buttonRight.Size = new System.Drawing.Size(30, 30); + this.buttonRight.TabIndex = 10; + this.buttonRight.UseVisualStyleBackColor = true; + this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonDown + // + this.buttonDown.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.down; + this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonDown.Location = new System.Drawing.Point(124, 433); + this.buttonDown.Name = "buttonDown"; + this.buttonDown.Size = new System.Drawing.Size(30, 30); + this.buttonDown.TabIndex = 9; + this.buttonDown.UseVisualStyleBackColor = true; + this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonLeft + // + this.buttonLeft.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.left; + this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonLeft.Location = new System.Drawing.Point(88, 433); + this.buttonLeft.Name = "buttonLeft"; + this.buttonLeft.Size = new System.Drawing.Size(30, 30); + this.buttonLeft.TabIndex = 8; + this.buttonLeft.UseVisualStyleBackColor = true; + this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonUp + // + this.buttonUp.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.up; + this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonUp.Location = new System.Drawing.Point(124, 397); + this.buttonUp.Name = "buttonUp"; + this.buttonUp.Size = new System.Drawing.Size(30, 30); + this.buttonUp.TabIndex = 7; + this.buttonUp.UseVisualStyleBackColor = true; + this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonShowOnMap + // + this.buttonShowOnMap.Location = new System.Drawing.Point(23, 319); + this.buttonShowOnMap.Name = "buttonShowOnMap"; + this.buttonShowOnMap.Size = new System.Drawing.Size(222, 34); + this.buttonShowOnMap.TabIndex = 6; + this.buttonShowOnMap.Text = "Посмотреть карту"; + this.buttonShowOnMap.UseVisualStyleBackColor = true; + this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click); + // + // buttonShowStorage + // + this.buttonShowStorage.Location = new System.Drawing.Point(23, 251); + this.buttonShowStorage.Name = "buttonShowStorage"; + this.buttonShowStorage.Size = new System.Drawing.Size(222, 37); + this.buttonShowStorage.TabIndex = 5; + this.buttonShowStorage.Text = "Посмотреть хранилище"; + this.buttonShowStorage.UseVisualStyleBackColor = true; + this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click); + // + // buttonRemoveAirplane + // + this.buttonRemoveAirplane.Location = new System.Drawing.Point(23, 186); + this.buttonRemoveAirplane.Name = "buttonRemoveAirplane"; + this.buttonRemoveAirplane.Size = new System.Drawing.Size(222, 34); + this.buttonRemoveAirplane.TabIndex = 4; + this.buttonRemoveAirplane.Text = "Удалить самолет"; + this.buttonRemoveAirplane.UseVisualStyleBackColor = true; + this.buttonRemoveAirplane.Click += new System.EventHandler(this.ButtonRemoveAirplane_Click); + // + // maskedTextBoxPosition + // + this.maskedTextBoxPosition.Location = new System.Drawing.Point(23, 149); + this.maskedTextBoxPosition.Mask = "00"; + this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; + this.maskedTextBoxPosition.Size = new System.Drawing.Size(222, 31); + this.maskedTextBoxPosition.TabIndex = 3; + // + // buttonAddAirplane + // + this.buttonAddAirplane.Location = new System.Drawing.Point(23, 94); + this.buttonAddAirplane.Name = "buttonAddAirplane"; + this.buttonAddAirplane.Size = new System.Drawing.Size(222, 34); + this.buttonAddAirplane.TabIndex = 2; + this.buttonAddAirplane.Text = "Добавить самолет"; + this.buttonAddAirplane.UseVisualStyleBackColor = true; + this.buttonAddAirplane.Click += new System.EventHandler(this.ButtonAddAirplane_Click); + // + // comboBoxSelectorMap + // + this.comboBoxSelectorMap.FormattingEnabled = true; + this.comboBoxSelectorMap.Items.AddRange(new object[] { + "Простая карта", + "Карта с линиями", + "Карта с блоками"}); + this.comboBoxSelectorMap.Location = new System.Drawing.Point(23, 44); + this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; + this.comboBoxSelectorMap.Size = new System.Drawing.Size(222, 33); + this.comboBoxSelectorMap.TabIndex = 0; + this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged); + // + // pictureBox + // + this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBox.Location = new System.Drawing.Point(0, 0); + this.pictureBox.Name = "pictureBox"; + this.pictureBox.Size = new System.Drawing.Size(723, 526); + this.pictureBox.TabIndex = 1; + this.pictureBox.TabStop = false; + // + // FormMapWithSetAirplanes + // + this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(980, 526); + this.Controls.Add(this.pictureBox); + this.Controls.Add(this.groupBox); + this.Name = "FormMapWithSetAirplanes"; + this.Text = "FormMapWithSetAirplanes"; + this.groupBox.ResumeLayout(false); + this.groupBox.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private GroupBox groupBox; + private Button buttonRight; + private Button buttonDown; + private Button buttonLeft; + private Button buttonUp; + private Button buttonShowOnMap; + private Button buttonShowStorage; + private Button buttonRemoveAirplane; + private MaskedTextBox maskedTextBoxPosition; + private Button buttonAddAirplane; + private ComboBox comboBoxSelectorMap; + private PictureBox pictureBox; + } +} \ No newline at end of file diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplanes.cs b/AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplanes.cs new file mode 100644 index 0000000..a55908f --- /dev/null +++ b/AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplanes.cs @@ -0,0 +1,166 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using static System.Windows.Forms.DataFormats; + +namespace AirplaneWithRadar +{ + public partial class FormMapWithSetAirplanes : Form + { + /// + /// Объект от класса карты с набором объектов + /// + private MapWithSetAirplanesGeneric _mapAirplanesCollectionGeneric; + /// + /// Конструктор + /// + public FormMapWithSetAirplanes() + { + InitializeComponent(); + } + /// + /// Выбор карты + /// + /// + /// + private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) + { + AbstractMap map = null; + switch (comboBoxSelectorMap.Text) + { + case "Простая карта": + map = new SimpleMap(); + break; + case "Карта с линиями": + map = new LineMap(); + break; + case "Карта с блоками": + map = new BlockMap(); + break; + } + if (map != null) + { + _mapAirplanesCollectionGeneric = new MapWithSetAirplanesGeneric(pictureBox.Width, pictureBox.Height, map); + } + else + { + _mapAirplanesCollectionGeneric = null; + } + } + /// + /// Добавление объекта + /// + /// + /// + private void ButtonAddAirplane_Click(object sender, EventArgs e) + { + if (_mapAirplanesCollectionGeneric == null) + { + return; + } + FormAirplaneWithRadar form = new(); + if (form.ShowDialog() == DialogResult.OK) + { + DrawingObjectAirplane airplane = new(form.SelectedAirplane); + if (_mapAirplanesCollectionGeneric + airplane != -1) + { + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } + } + /// + /// Удаление объекта + /// + /// + /// + private void ButtonRemoveAirplane_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(maskedTextBoxPosition.Text)) + { + return; + } + if (MessageBox.Show("Удалить объект?", "Удаление",MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + return; + } + int pos = Convert.ToInt32(maskedTextBoxPosition.Text); + if (_mapAirplanesCollectionGeneric - pos != null) + { + MessageBox.Show("Объект удален"); + pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet(); + } + else + { + MessageBox.Show("Не удалось удалить объект"); + } + } + /// + /// Вывод набора + /// + /// + /// + private void ButtonShowStorage_Click(object sender, EventArgs e) + { + if (_mapAirplanesCollectionGeneric == null) + { + return; + } + pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet(); + } + /// + /// Вывод карты + /// + /// + /// + private void ButtonShowOnMap_Click(object sender, EventArgs e) + { + if (_mapAirplanesCollectionGeneric == null) + { + return; + } + pictureBox.Image = _mapAirplanesCollectionGeneric.ShowOnMap(); + } + /// + /// Перемещение + /// + /// + /// + private void ButtonMove_Click(object sender, EventArgs e) + { + if (_mapAirplanesCollectionGeneric == null) + { + return; + } + //получаем имя кнопки + string name = ((Button)sender)?.Name ?? string.Empty; + Direction dir = Direction.None; + switch (name) + { + case "buttonUp": + dir = Direction.Up; + break; + case "buttonDown": + dir = Direction.Down; + break; + case "buttonLeft": + dir = Direction.Left; + break; + case "buttonRight": + dir = Direction.Right; + break; + } + pictureBox.Image = _mapAirplanesCollectionGeneric.MoveObject(dir); + } + } +} diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormMap.resx b/AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplanes.resx similarity index 93% rename from AirplaneWithRadar/AirplaneWithRadar/FormMap.resx rename to AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplanes.resx index 2c0949d..f298a7b 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/FormMap.resx +++ b/AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplanes.resx @@ -57,7 +57,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - \ No newline at end of file diff --git a/AirplaneWithRadar/AirplaneWithRadar/MyMap.cs b/AirplaneWithRadar/AirplaneWithRadar/LineMap.cs similarity index 68% rename from AirplaneWithRadar/AirplaneWithRadar/MyMap.cs rename to AirplaneWithRadar/AirplaneWithRadar/LineMap.cs index a789586..2982b2d 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/MyMap.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/LineMap.cs @@ -9,7 +9,7 @@ namespace AirplaneWithRadar /// /// Собственная реализация абсрактного класса AbstractMap /// - internal class MyMap : AbstractMap + internal class LineMap : AbstractMap { /// /// Цвет участка закрытого @@ -57,34 +57,9 @@ namespace AirplaneWithRadar counter++; } } - j++; + j += 3; } - //for (int i = 0; i < _map.GetLength(0); ++i) - //{ - // int startX = _random.Next(0, 90); - // int x = _random.Next(0, 100 - startX - 10); - // counter = x; - // while (counter > 0) - // { - // for (int j = 0; j < _map.GetLength(1); ++j) - // { - // _map[i, j] = _barrier; - // counter--; - // } - // } - - //} - //while (counter < 50) - //{ - // int x = _random.Next(0, 100); - // int y = _random.Next(0, 100); - // if (_map[x, y] == _freeRoad) - // { - // _map[x, y] = _barrier; - // counter++; - // } - //} - + } } } diff --git a/AirplaneWithRadar/AirplaneWithRadar/MapWithSetAirplanesGeneric.cs b/AirplaneWithRadar/AirplaneWithRadar/MapWithSetAirplanesGeneric.cs index 80855ad..8194b35 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/MapWithSetAirplanesGeneric.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/MapWithSetAirplanesGeneric.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -26,11 +27,11 @@ namespace AirplaneWithRadar /// /// Размер занимаемого объектом места (ширина) /// - private readonly int _placeSizeWidth = 210; + private readonly int _placeSizeWidth = 314; /// /// Размер занимаемого объектом места (высота) /// - private readonly int _placeSizeHeight = 90; + private readonly int _placeSizeHeight = 128; /// /// Набор объектов /// @@ -60,7 +61,7 @@ namespace AirplaneWithRadar /// /// /// - public static bool operator +(MapWithSetAirplanesGeneric map, T airplane) + public static int operator +(MapWithSetAirplanesGeneric map, T airplane) { return map._setAirplanes.Insert(airplane); } @@ -70,7 +71,7 @@ namespace AirplaneWithRadar /// /// /// - public static bool operator -(MapWithSetAirplanesGeneric map, int position) + public static T operator -(MapWithSetAirplanesGeneric map, int position) { return map._setAirplanes.Remove(position); } @@ -128,10 +129,10 @@ namespace AirplaneWithRadar { for (; j > i; j--) { - var car = _setAirplanes.Get(j); - if (car != null) + var airplane = _setAirplanes.Get(j); + if (airplane != null) { - _setAirplanes.Insert(car, i); + _setAirplanes.Insert(airplane, i); _setAirplanes.Remove(j); break; } @@ -147,29 +148,49 @@ namespace AirplaneWithRadar /// Метод отрисовки фона /// /// - private void DrawBackground(Graphics g) + private void DrawHangar(Graphics g, int x, int y, int width, int height) { Pen pen = new(Color.Black, 3); + g.DrawLine(pen, x, y, x + width, y); + g.DrawLine(pen, x, y, x, y + height + 20); + g.DrawLine(pen, x, y + height + 20, x + width, y + height + 20); + } + /// + /// Метод отрисовки фона + /// + /// + private void DrawBackground(Graphics g) + { + Pen pen = new(Color.White, 3); + g.FillRectangle(Brushes.Gray, 0, 0, _pictureWidth, _pictureHeight); + for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) { - for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j) - {//линия рамзетки места - g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight); + for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++) + { + g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth * 3/4, j * _placeSizeHeight); } g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, (_pictureHeight / _placeSizeHeight) * _placeSizeHeight); + } } + /// /// Метод прорисовки объектов /// /// private void DrawAirplanes(Graphics g) { + + int numInRow = _pictureWidth / _placeSizeWidth; + int maxLeft = (numInRow - 1) * _placeSizeWidth; for (int i = 0; i < _setAirplanes.Count; i++) { - // TODO установка позиции - _setAirplanes.Get(i)?.DrawingObject(g); + var airplane = _setAirplanes.Get(i); + airplane?.SetObject(maxLeft - i % numInRow * _placeSizeWidth + 5, i / numInRow * _placeSizeHeight + 10, _pictureWidth, _pictureHeight); + airplane?.DrawingObject(g); } } + } } diff --git a/AirplaneWithRadar/AirplaneWithRadar/Program.cs b/AirplaneWithRadar/AirplaneWithRadar/Program.cs index f8a0be0..f9ad494 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/Program.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/Program.cs @@ -11,7 +11,7 @@ namespace AirplaneWithRadar // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormMap()); + Application.Run(new FormMapWithSetAirplanes()); } } } \ No newline at end of file diff --git a/AirplaneWithRadar/AirplaneWithRadar/SetAirplanesGeneric.cs b/AirplaneWithRadar/AirplaneWithRadar/SetAirplanesGeneric.cs index a678b2a..8f2ce63 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/SetAirplanesGeneric.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/SetAirplanesGeneric.cs @@ -34,10 +34,10 @@ namespace AirplaneWithRadar /// /// Добавляемый автомобиль /// - public bool Insert(T airplane) + public int Insert(T airplane) { // TODO вставка в начало набора - return true; + return Insert(airplane, 0); } /// /// Добавление объекта в набор на конкретную позицию @@ -45,25 +45,54 @@ namespace AirplaneWithRadar /// Добавляемый автомобиль /// Позиция /// - public bool Insert(T airplane, int position) + public int Insert(T airplane, int position) { // TODO проверка позиции // TODO проверка, что элемент массива по этой позиции пустой, если нет, то проверка, что после вставляемого элемента в массиве есть пустой элемент // сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента // TODO вставка по позиции + if (position >= _places.Length) + { + return -1; + } + if (_places[position] != null) + { + int indexNull = -1; + for (int i = position; i < _places.Length; i++) + { + if (_places[i] == null) + { + indexNull = i; + break; + } + } + if (indexNull == -1) return -1; + for (int i = indexNull; i > position; i--) + { + T tmp = _places[i]; + _places[i] = _places[i - 1]; + _places[i - 1] = tmp; + } + } _places[position] = airplane; - return true; + return position; } /// /// Удаление объекта из набора с конкретной позиции /// /// /// - public bool Remove(int position) + public T Remove(int position) { // TODO проверка позиции // TODO удаление объекта из массива, присовив элементу массива значение null - return true; + if (position >= _places.Length) + { + return null; + } + T removedObject = _places[position]; + _places[position] = null; + return removedObject; } /// /// Получение объекта из набора по позиции @@ -73,6 +102,10 @@ namespace AirplaneWithRadar public T Get(int position) { // TODO проверка позиции + if (position >= _places.Length) + { + return null; + } return _places[position]; } } -- 2.25.1 From 017b18a3db2276cb466429e7688928b7ef47650f Mon Sep 17 00:00:00 2001 From: Anastasia Date: Sun, 13 Nov 2022 09:50:31 +0400 Subject: [PATCH 3/6] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AirplaneWithRadar/AbstractMap.cs | 2 - .../AirplaneWithRadar/BlockMap.cs | 3 - .../AirplaneWithRadar/DrawingAirplane.cs | 32 ++++------- .../DrawingAirplaneWithRadar.cs | 11 +--- .../DrawingObjectAirplane.cs | 1 - .../AirplaneWithRadar/EntityAirplane.cs | 7 +-- .../EntityAirplaneWithRadar.cs | 12 ++-- .../FormAirplaneWithRadar.Designer.cs | 1 - .../FormAirplaneWithRadar.cs | 49 +++++++--------- .../FormMapWithSetAirplanes.cs | 14 +---- .../AirplaneWithRadar/IDrawingObject.cs | 8 +-- .../AirplaneWithRadar/LineMap.cs | 7 +-- .../MapWithSetAirplanesGeneric.cs | 11 +--- .../AirplaneWithRadar/Program.cs | 2 - .../AirplaneWithRadar/SetAirplanesGeneric.cs | 57 ++++++++----------- 15 files changed, 70 insertions(+), 147 deletions(-) diff --git a/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs b/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs index ea02d63..8c78481 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs @@ -96,13 +96,11 @@ namespace AirplaneWithRadar int x = _random.Next(0, 10); int y = _random.Next(0, 10); _drawingObject.SetObject(x, y, _width, _height); - // TODO проверка, что объект не "накладывается" на закрытые участки if (!CheckBarriers(0, 0, 0, 0)) { return false; } return true; - } private Bitmap DrawMapWithObject() { diff --git a/AirplaneWithRadar/AirplaneWithRadar/BlockMap.cs b/AirplaneWithRadar/AirplaneWithRadar/BlockMap.cs index 2c920c7..a845946 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/BlockMap.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/BlockMap.cs @@ -26,7 +26,6 @@ namespace AirplaneWithRadar protected override void DrawRoadPart(Graphics g, int i, int j) { g.FillRectangle(roadColor, i * _size_x, j * _size_y, (i + 1) * (_size_x + 1), (j + 1) * (_size_y + 1)); - } protected override void GenerateMap() @@ -49,7 +48,6 @@ namespace AirplaneWithRadar int y = _random.Next(0, 80); int blockWidth = _random.Next(0, 19); int blockHeight = _random.Next(0, 19); - bool isFree = true; for (int i = x; i < x + blockWidth; i++) { @@ -60,7 +58,6 @@ namespace AirplaneWithRadar isFree = false; break; } - } } if (isFree) diff --git a/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs b/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs index efeeeb9..c82432b 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs @@ -16,11 +16,11 @@ namespace AirplaneWithRadar /// public EntityAirplane Airplane { get; protected set; } /// - /// Левая координата отрисовки автомобиля + /// Левая координата отрисовки самолета /// protected float _startPosX; /// - /// Верхняя кооридната отрисовки автомобиля + /// Верхняя кооридната отрисовки самолета /// protected float _startPosY; /// @@ -32,18 +32,18 @@ namespace AirplaneWithRadar /// private int? _pictureHeight = null; /// - /// Ширина отрисовки автомобиля + /// Ширина отрисовки самолета /// private readonly int _airplaneWidth = 303; /// - /// Высота отрисовки автомобиля + /// Высота отрисовки самолета /// private readonly int _airplaneHeight = 107; /// /// Инициализация свойств /// /// Скорость - /// Вес автомобиля + /// Вес самолета /// Цвет кузова public DrawingAirplane(int speed, float weight, Color bodyColor) { @@ -53,10 +53,10 @@ namespace AirplaneWithRadar /// Инициализация свойств /// /// Скорость - /// Вес автомобиля + /// Вес самолета /// Цвет кузова - /// Ширина отрисовки автомобиля - /// Высота отрисовки автомобиля + /// Ширина отрисовки самолета + /// Высота отрисовки самолета protected DrawingAirplane(int speed, float weight, Color bodyColor, int airplaneWidth, int airplaneHeight) : this(speed, weight, bodyColor) { @@ -64,7 +64,7 @@ namespace AirplaneWithRadar _airplaneHeight = airplaneHeight; } /// - /// Установка позиции автомобиля + /// Установка позиции самолета /// /// Координата X /// Координата Y @@ -72,7 +72,6 @@ namespace AirplaneWithRadar /// Высота картинки public void SetPosition(int x, int y, int width, int height) { - // TODO checks if (x > 0 && x < width) { _startPosX = x; @@ -89,12 +88,6 @@ namespace AirplaneWithRadar { _pictureHeight = height; } - - - //_startPosX = x; - //_startPosY = y; - //_pictureWidth = width; - //_pictureHeight = height; } /// /// Изменение направления пермещения @@ -108,28 +101,24 @@ namespace AirplaneWithRadar } switch (direction) { - // вправо case Direction.Right: if (_startPosX + _airplaneWidth + Airplane.Step < _pictureWidth) { _startPosX += Airplane.Step; } break; - //влево case Direction.Left: if (_startPosX - Airplane.Step > 0) { _startPosX -= Airplane.Step; } break; - //вверх case Direction.Up: if (_startPosY - Airplane.Step > 0) { _startPosY -= Airplane.Step; } break; - //вниз case Direction.Down: if (_startPosY + _airplaneHeight + Airplane.Step < _pictureHeight) { @@ -139,7 +128,7 @@ namespace AirplaneWithRadar } } /// - /// Отрисовка автомобиля + /// Отрисовка самолета /// /// public virtual void DrawTransport(Graphics g) @@ -218,6 +207,5 @@ namespace AirplaneWithRadar { return (_startPosX, _startPosX + _airplaneWidth, _startPosY, _startPosY + _airplaneHeight); } - } } diff --git a/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplaneWithRadar.cs b/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplaneWithRadar.cs index ea5724a..e0b4f4e 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplaneWithRadar.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplaneWithRadar.cs @@ -12,16 +12,15 @@ namespace AirplaneWithRadar /// Инициализация свойств /// /// Скорость - /// Вес автомобиля + /// Вес самолета /// Цвет кузова /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла + /// Признак наличия радара + /// Признак наличия дополнительных топливных баков public DrawingAirplaneWithRadar(int speed, float weight, Color bodyColor, Color dopColor, bool radar, bool extraFuelTank) : base(speed, weight, bodyColor, 303, 102) { Airplane = new EntityAirplaneWithRadar(speed, weight, bodyColor, dopColor, radar, extraFuelTank); } - public override void DrawTransport(Graphics g) { if (Airplane is not EntityAirplaneWithRadar airplaneWithRadar) @@ -30,7 +29,6 @@ namespace AirplaneWithRadar } Pen pen = new(Color.Black, 5); Brush dopBrush = new SolidBrush(airplaneWithRadar.DopColor); - if (airplaneWithRadar.Radar) { g.DrawLine(pen, _startPosX + 120, _startPosY + 30, _startPosX + 110, _startPosY + 60); @@ -43,15 +41,12 @@ namespace AirplaneWithRadar g.FillPolygon(dopBrush, radarPoints); g.DrawEllipse(pen, _startPosX + 85, _startPosY + 15, 90, 20); g.FillEllipse(dopBrush, _startPosX + 85, _startPosY + 15, 90, 20); - } - _startPosX += 10; _startPosY += 5; base.DrawTransport(g); _startPosX -= 10; _startPosY -= 5; - if (airplaneWithRadar.ExtraFuelTank) { g.DrawLine(pen, _startPosX + 145, _startPosY + 98, _startPosX + 145, _startPosY + 108); diff --git a/AirplaneWithRadar/AirplaneWithRadar/DrawingObjectAirplane.cs b/AirplaneWithRadar/AirplaneWithRadar/DrawingObjectAirplane.cs index 08ac4fd..fcd2c62 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/DrawingObjectAirplane.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/DrawingObjectAirplane.cs @@ -30,6 +30,5 @@ namespace AirplaneWithRadar { _airplane.DrawTransport(g); } - } } diff --git a/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs b/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs index bddb2ba..6502d80 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs @@ -25,11 +25,11 @@ namespace AirplaneWithRadar /// public Color BodyColor { get; private set; } /// - /// Шаг перемещения автомобиля + /// Шаг перемещения самолета /// public float Step => Speed * 100 / Weight; /// - /// Инициализация полей объекта-класса автомобиля + /// Инициализация полей объекта-класса самолета /// /// /// @@ -42,8 +42,5 @@ namespace AirplaneWithRadar Weight = weight <= 0 ? rnd.Next(40, 70) : weight; BodyColor = bodyColor; } - - - } } diff --git a/AirplaneWithRadar/AirplaneWithRadar/EntityAirplaneWithRadar.cs b/AirplaneWithRadar/AirplaneWithRadar/EntityAirplaneWithRadar.cs index 9026595..5c71fbd 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/EntityAirplaneWithRadar.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/EntityAirplaneWithRadar.cs @@ -13,29 +13,27 @@ namespace AirplaneWithRadar /// public Color DopColor { get; private set; } /// - /// Признак наличия обвеса + /// Признак наличия радара /// public bool Radar { get; private set; } /// - /// Признак наличия антикрыла + /// Признак наличия дополнительных топливных баков /// public bool ExtraFuelTank { get; private set; } /// /// Инициализация свойств /// /// Скорость - /// Вес автомобиля + /// Вес самолета /// Цвет кузова /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла + /// Признак наличия радара + /// Признак наличия дополнительных топливных баков public EntityAirplaneWithRadar(int speed, float weight, Color bodyColor, Color dopColor, bool radar, bool extraFuelTank) : base(speed, weight, bodyColor) { DopColor = dopColor; Radar = radar; ExtraFuelTank = extraFuelTank; } - - } } diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.Designer.cs b/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.Designer.cs index c21cf85..d0040e3 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.Designer.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.Designer.cs @@ -83,7 +83,6 @@ this.pictureBoxAirplane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.pictureBoxAirplane.TabIndex = 1; this.pictureBoxAirplane.TabStop = false; - this.pictureBoxAirplane.Click += new System.EventHandler(this.pictureBoxAirplane_Click); // // buttonCreate // diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.cs b/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.cs index d98ab40..21d57ce 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.cs @@ -3,16 +3,14 @@ namespace AirplaneWithRadar public partial class FormAirplaneWithRadar : Form { private DrawingAirplane _airplane; - public DrawingAirplane SelectedAirplane { get; private set; } public FormAirplaneWithRadar() { InitializeComponent(); } - /// - /// + /// /// private void Draw() { @@ -27,7 +25,6 @@ namespace AirplaneWithRadar private void SetData() { Random rnd = new(); - _airplane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxAirplane.Width, pictureBoxAirplane.Height); toolStripStatusLabelSpeed.Text = $": {_airplane.Airplane.Speed}"; toolStripStatusLabelWeight.Text = $": {_airplane.Airplane.Weight}"; @@ -40,16 +37,20 @@ namespace AirplaneWithRadar /// private void ButtonCreate_Click(object sender, EventArgs e) { - Random rnd = new(); - _airplane = new DrawingAirplane(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)); + ColorDialog dialog = new(); + if (dialog.ShowDialog() == DialogResult.OK) + { + color = dialog.Color; + } + _airplane = new DrawingAirplane(rnd.Next(100, 300), rnd.Next(1000, 2000), color); SetData(); Draw(); } private void ButtonMove_Click(object sender, EventArgs e) { - // string name = ((Button)sender)?.Name ?? string.Empty; switch (name) { @@ -67,18 +68,6 @@ namespace AirplaneWithRadar break; } Draw(); - - } - - - private void FormAirplaneWithRadar_Load(object sender, EventArgs e) - { - - } - - private void pictureBoxAirplane_Click(object sender, EventArgs e) - { - } /// /// "" @@ -88,22 +77,26 @@ namespace AirplaneWithRadar private void ButtonCreateModif_Click(object sender, EventArgs e) { Random rnd = new(); - _airplane = new DrawingAirplaneWithRadar(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), - Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0,2))); + Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)); + ColorDialog dialog = new(); + if (dialog.ShowDialog() == DialogResult.OK) + { + color = dialog.Color; + } + Color dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)); + ColorDialog dialogDop = new(); + if (dialogDop.ShowDialog() == DialogResult.OK) + { + dopColor = dialogDop.Color; + } + _airplane = new DrawingAirplaneWithRadar(rnd.Next(100, 300), rnd.Next(1000, 2000), color, dopColor, Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0,2))); SetData(); Draw(); } - private void ButtonSelectAirplane_Click(object sender, EventArgs e) { SelectedAirplane = _airplane; DialogResult = DialogResult.OK; - - } - - private void FormAirplaneWithRadar_Load_1(object sender, EventArgs e) - { - } } } \ No newline at end of file diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplanes.cs b/AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplanes.cs index a55908f..5c2c226 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplanes.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplanes.cs @@ -1,15 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using static System.Windows.Forms.DataFormats; - -namespace AirplaneWithRadar +namespace AirplaneWithRadar { public partial class FormMapWithSetAirplanes : Form { @@ -142,7 +131,6 @@ namespace AirplaneWithRadar { return; } - //получаем имя кнопки string name = ((Button)sender)?.Name ?? string.Empty; Direction dir = Direction.None; switch (name) diff --git a/AirplaneWithRadar/AirplaneWithRadar/IDrawingObject.cs b/AirplaneWithRadar/AirplaneWithRadar/IDrawingObject.cs index 3e8a16c..0dcd348 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/IDrawingObject.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/IDrawingObject.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AirplaneWithRadar +namespace AirplaneWithRadar { /// /// Интерфейс для работы с объектом, прорисовываемым на форме diff --git a/AirplaneWithRadar/AirplaneWithRadar/LineMap.cs b/AirplaneWithRadar/AirplaneWithRadar/LineMap.cs index 2982b2d..28fc0d0 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/LineMap.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/LineMap.cs @@ -32,7 +32,6 @@ namespace AirplaneWithRadar _map = new int[100, 100]; _size_x = (float)_width / _map.GetLength(0); _size_y = (float)_height / _map.GetLength(1); - //int counter = 0; for (int i = 0; i < _map.GetLength(0); ++i) { for (int j = 0; j < _map.GetLength(1); ++j) @@ -40,10 +39,7 @@ namespace AirplaneWithRadar _map[i, j] = _freeRoad; } } - - - int counter = 0; - + int counter; for (int j = 0; j < _map.GetLength(1); j++) { int startX = _random.Next(0, 80); @@ -59,7 +55,6 @@ namespace AirplaneWithRadar } j += 3; } - } } } diff --git a/AirplaneWithRadar/AirplaneWithRadar/MapWithSetAirplanesGeneric.cs b/AirplaneWithRadar/AirplaneWithRadar/MapWithSetAirplanesGeneric.cs index 8194b35..31b77aa 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/MapWithSetAirplanesGeneric.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/MapWithSetAirplanesGeneric.cs @@ -161,27 +161,23 @@ namespace AirplaneWithRadar /// private void DrawBackground(Graphics g) { - Pen pen = new(Color.White, 3); - g.FillRectangle(Brushes.Gray, 0, 0, _pictureWidth, _pictureHeight); - + Pen pen = new(Color.White, 5); + g.FillRectangle(Brushes.DimGray, 0, 0, _pictureWidth, _pictureHeight); for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) { for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++) { - g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth * 3/4, j * _placeSizeHeight); + g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth * 4/5, j * _placeSizeHeight); } g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, (_pictureHeight / _placeSizeHeight) * _placeSizeHeight); - } } - /// /// Метод прорисовки объектов /// /// private void DrawAirplanes(Graphics g) { - int numInRow = _pictureWidth / _placeSizeWidth; int maxLeft = (numInRow - 1) * _placeSizeWidth; for (int i = 0; i < _setAirplanes.Count; i++) @@ -191,6 +187,5 @@ namespace AirplaneWithRadar airplane?.DrawingObject(g); } } - } } diff --git a/AirplaneWithRadar/AirplaneWithRadar/Program.cs b/AirplaneWithRadar/AirplaneWithRadar/Program.cs index f9ad494..64c7b13 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/Program.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/Program.cs @@ -8,8 +8,6 @@ namespace AirplaneWithRadar [STAThread] static void Main() { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); Application.Run(new FormMapWithSetAirplanes()); } diff --git a/AirplaneWithRadar/AirplaneWithRadar/SetAirplanesGeneric.cs b/AirplaneWithRadar/AirplaneWithRadar/SetAirplanesGeneric.cs index 8f2ce63..2a28e06 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/SetAirplanesGeneric.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/SetAirplanesGeneric.cs @@ -32,47 +32,33 @@ namespace AirplaneWithRadar /// /// Добавление объекта в набор /// - /// Добавляемый автомобиль + /// Добавляемый самолет /// public int Insert(T airplane) { - // TODO вставка в начало набора return Insert(airplane, 0); } /// /// Добавление объекта в набор на конкретную позицию /// - /// Добавляемый автомобиль + /// Добавляемый самолет /// Позиция /// public int Insert(T airplane, int position) { - // TODO проверка позиции - // TODO проверка, что элемент массива по этой позиции пустой, если нет, то проверка, что после вставляемого элемента в массиве есть пустой элемент - // сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента - // TODO вставка по позиции - if (position >= _places.Length) + int positionNullElement = position; + while (Get(positionNullElement) != null) + { + positionNullElement++; + } + if (positionNullElement > Count || positionNullElement < 0) { return -1; } - if (_places[position] != null) + while (positionNullElement != position) { - int indexNull = -1; - for (int i = position; i < _places.Length; i++) - { - if (_places[i] == null) - { - indexNull = i; - break; - } - } - if (indexNull == -1) return -1; - for (int i = indexNull; i > position; i--) - { - T tmp = _places[i]; - _places[i] = _places[i - 1]; - _places[i - 1] = tmp; - } + _places[positionNullElement] = _places[positionNullElement - 1]; + positionNullElement--; } _places[position] = airplane; return position; @@ -84,15 +70,16 @@ namespace AirplaneWithRadar /// public T Remove(int position) { - // TODO проверка позиции - // TODO удаление объекта из массива, присовив элементу массива значение null - if (position >= _places.Length) + if (position > Count || position < 0) { return null; } - T removedObject = _places[position]; - _places[position] = null; - return removedObject; + else + { + var removedObject = _places[position]; + _places[position] = null; + return removedObject; + } } /// /// Получение объекта из набора по позиции @@ -101,12 +88,14 @@ namespace AirplaneWithRadar /// public T Get(int position) { - // TODO проверка позиции - if (position >= _places.Length) + if (position > Count || position < 0) { return null; } - return _places[position]; + else + { + return _places[position]; + } } } } -- 2.25.1 From 36af9579e4cfb3d09af05ec88ebebfd5d2a8138e Mon Sep 17 00:00:00 2001 From: Anastasia Date: Sat, 10 Dec 2022 19:49:35 +0400 Subject: [PATCH 4/6] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F?= =?UTF-8?q?=20=D1=82=D1=80=D0=B5=D1=82=D1=8C=D1=8F=20=D0=BB=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs | 2 -- AirplaneWithRadar/AirplaneWithRadar/BlockMap.cs | 1 - .../AirplaneWithRadar/DrawingAirplane.cs | 3 +-- AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs | 1 - .../AirplaneWithRadar/FormAirplaneWithRadar.cs | 6 +++++- .../AirplaneWithRadar/MapWithSetAirplanesGeneric.cs | 11 ----------- 6 files changed, 6 insertions(+), 18 deletions(-) diff --git a/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs b/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs index 8c78481..4cd43c2 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs @@ -66,7 +66,6 @@ namespace AirplaneWithRadar } return DrawMapWithObject(); } - private bool CheckBarriers(float leftMove, float rightMove, float topMove, float bottomMove) { int left = Convert.ToInt32((_drawingObject.GetCurrentPosition().Left + leftMove) / _size_x); @@ -86,7 +85,6 @@ namespace AirplaneWithRadar } return true; } - private bool SetObjectOnMap() { if (_drawingObject == null || _map == null) diff --git a/AirplaneWithRadar/AirplaneWithRadar/BlockMap.cs b/AirplaneWithRadar/AirplaneWithRadar/BlockMap.cs index a845946..b601672 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/BlockMap.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/BlockMap.cs @@ -27,7 +27,6 @@ namespace AirplaneWithRadar { g.FillRectangle(roadColor, i * _size_x, j * _size_y, (i + 1) * (_size_x + 1), (j + 1) * (_size_y + 1)); } - protected override void GenerateMap() { _map = new int[100, 100]; diff --git a/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs b/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs index c82432b..3f30e8c 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs @@ -57,8 +57,7 @@ namespace AirplaneWithRadar /// Цвет кузова /// Ширина отрисовки самолета /// Высота отрисовки самолета - protected DrawingAirplane(int speed, float weight, Color bodyColor, int airplaneWidth, int airplaneHeight) : - this(speed, weight, bodyColor) + protected DrawingAirplane(int speed, float weight, Color bodyColor, int airplaneWidth, int airplaneHeight) : this(speed, weight, bodyColor) { _airplaneWidth = airplaneWidth; _airplaneHeight = airplaneHeight; diff --git a/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs b/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs index 6502d80..6bf9013 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; namespace AirplaneWithRadar { - /// /// Класс-сущность "Самолет" /// diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.cs b/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.cs index 21d57ce..82937e8 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.cs @@ -48,7 +48,11 @@ namespace AirplaneWithRadar SetData(); Draw(); } - + /// + /// "" + /// + /// + /// private void ButtonMove_Click(object sender, EventArgs e) { string name = ((Button)sender)?.Name ?? string.Empty; diff --git a/AirplaneWithRadar/AirplaneWithRadar/MapWithSetAirplanesGeneric.cs b/AirplaneWithRadar/AirplaneWithRadar/MapWithSetAirplanesGeneric.cs index 31b77aa..059ae83 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/MapWithSetAirplanesGeneric.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/MapWithSetAirplanesGeneric.cs @@ -148,17 +148,6 @@ namespace AirplaneWithRadar /// Метод отрисовки фона /// /// - private void DrawHangar(Graphics g, int x, int y, int width, int height) - { - Pen pen = new(Color.Black, 3); - g.DrawLine(pen, x, y, x + width, y); - g.DrawLine(pen, x, y, x, y + height + 20); - g.DrawLine(pen, x, y + height + 20, x + width, y + height + 20); - } - /// - /// Метод отрисовки фона - /// - /// private void DrawBackground(Graphics g) { Pen pen = new(Color.White, 5); -- 2.25.1 From 4a2e372bbe7de88e1dd27baccdee8c6004d1367f Mon Sep 17 00:00:00 2001 From: Anastasia Date: Sat, 10 Dec 2022 20:17:48 +0400 Subject: [PATCH 5/6] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F?= =?UTF-8?q?=20=D1=82=D1=80=D0=B5=D1=82=D1=8C=D1=8F=20=D0=BB=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20[2].?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirplaneWithRadar/EntityAirplaneWithRadar.cs | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 AirplaneWithRadar/EntityAirplaneWithRadar.cs diff --git a/AirplaneWithRadar/EntityAirplaneWithRadar.cs b/AirplaneWithRadar/EntityAirplaneWithRadar.cs deleted file mode 100644 index d555ecb..0000000 --- a/AirplaneWithRadar/EntityAirplaneWithRadar.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -public class Class1 -{ - public Class1() - { - } -} -- 2.25.1 From fe61d945efe39260c7aa5d07097a2c0f9dd96f27 Mon Sep 17 00:00:00 2001 From: Anastasia Date: Sat, 17 Dec 2022 15:00:17 +0400 Subject: [PATCH 6/6] =?UTF-8?q?=D0=A0=D0=B0=D0=B7=D1=80=D0=B5=D1=88=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=84=D0=BB=D0=B8=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AirplaneWithRadar/FormMap.Designer.cs | 209 ------------------ .../AirplaneWithRadar/LineMap.cs | 3 + 2 files changed, 3 insertions(+), 209 deletions(-) delete mode 100644 AirplaneWithRadar/AirplaneWithRadar/FormMap.Designer.cs diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormMap.Designer.cs b/AirplaneWithRadar/AirplaneWithRadar/FormMap.Designer.cs deleted file mode 100644 index aa2bb3e..0000000 --- a/AirplaneWithRadar/AirplaneWithRadar/FormMap.Designer.cs +++ /dev/null @@ -1,209 +0,0 @@ -namespace AirplaneWithRadar -{ - partial class FormMap - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.statusStrip = new System.Windows.Forms.StatusStrip(); - this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel(); - this.pictureBoxAirplane = new System.Windows.Forms.PictureBox(); - this.buttonCreate = new System.Windows.Forms.Button(); - this.buttonUp = new System.Windows.Forms.Button(); - this.buttonLeft = new System.Windows.Forms.Button(); - this.buttonDown = new System.Windows.Forms.Button(); - this.buttonRight = new System.Windows.Forms.Button(); - this.buttonCreateModif = new System.Windows.Forms.Button(); - this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); - this.statusStrip.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).BeginInit(); - this.SuspendLayout(); - // - // statusStrip - // - this.statusStrip.ImageScalingSize = new System.Drawing.Size(24, 24); - this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabelSpeed, - this.toolStripStatusLabelWeight, - this.toolStripStatusLabelBodyColor}); - this.statusStrip.Location = new System.Drawing.Point(0, 418); - this.statusStrip.Name = "statusStrip"; - this.statusStrip.Size = new System.Drawing.Size(800, 32); - this.statusStrip.TabIndex = 0; - // - // toolStripStatusLabelSpeed - // - this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed"; - this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(93, 25); - this.toolStripStatusLabelSpeed.Text = "Скорость:"; - // - // toolStripStatusLabelWeight - // - this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight"; - this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(43, 25); - this.toolStripStatusLabelWeight.Text = "Вес:"; - // - // toolStripStatusLabelBodyColor - // - this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor"; - this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(55, 25); - this.toolStripStatusLabelBodyColor.Text = "Цвет:"; - // - // pictureBoxAirplane - // - this.pictureBoxAirplane.Dock = System.Windows.Forms.DockStyle.Fill; - this.pictureBoxAirplane.Location = new System.Drawing.Point(0, 0); - this.pictureBoxAirplane.Name = "pictureBoxAirplane"; - this.pictureBoxAirplane.Size = new System.Drawing.Size(800, 450); - this.pictureBoxAirplane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.pictureBoxAirplane.TabIndex = 1; - this.pictureBoxAirplane.TabStop = false; - // - // buttonCreate - // - this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonCreate.Location = new System.Drawing.Point(12, 372); - this.buttonCreate.Name = "buttonCreate"; - this.buttonCreate.Size = new System.Drawing.Size(112, 34); - this.buttonCreate.TabIndex = 2; - this.buttonCreate.Text = "Создать"; - this.buttonCreate.UseVisualStyleBackColor = true; - this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click); - // - // buttonUp - // - this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonUp.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.up; - this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonUp.Location = new System.Drawing.Point(711, 340); - this.buttonUp.Name = "buttonUp"; - this.buttonUp.Size = new System.Drawing.Size(30, 30); - this.buttonUp.TabIndex = 3; - this.buttonUp.UseVisualStyleBackColor = true; - this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonLeft - // - this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonLeft.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.left; - this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonLeft.Location = new System.Drawing.Point(675, 376); - this.buttonLeft.Name = "buttonLeft"; - this.buttonLeft.Size = new System.Drawing.Size(30, 30); - this.buttonLeft.TabIndex = 4; - this.buttonLeft.UseVisualStyleBackColor = true; - this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonDown - // - this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonDown.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.down; - this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonDown.Location = new System.Drawing.Point(711, 376); - this.buttonDown.Name = "buttonDown"; - this.buttonDown.Size = new System.Drawing.Size(30, 30); - this.buttonDown.TabIndex = 5; - this.buttonDown.UseVisualStyleBackColor = true; - this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonRight - // - this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonRight.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.right; - this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonRight.Location = new System.Drawing.Point(747, 376); - this.buttonRight.Name = "buttonRight"; - this.buttonRight.Size = new System.Drawing.Size(30, 30); - this.buttonRight.TabIndex = 6; - this.buttonRight.UseVisualStyleBackColor = true; - this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonCreateModif - // - this.buttonCreateModif.Location = new System.Drawing.Point(130, 372); - this.buttonCreateModif.Name = "buttonCreateModif"; - this.buttonCreateModif.Size = new System.Drawing.Size(140, 34); - this.buttonCreateModif.TabIndex = 7; - this.buttonCreateModif.Text = "Модификация"; - this.buttonCreateModif.UseVisualStyleBackColor = true; - this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click); - // - // comboBoxSelectorMap - // - this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxSelectorMap.FormattingEnabled = true; - this.comboBoxSelectorMap.Items.AddRange(new object[] { - "Простая карта", - "Карта с линиями", - "Карта с блоками"}); - this.comboBoxSelectorMap.Location = new System.Drawing.Point(12, 12); - this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; - this.comboBoxSelectorMap.Size = new System.Drawing.Size(182, 33); - this.comboBoxSelectorMap.TabIndex = 8; - this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged); - // - // FormMap - // - this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Controls.Add(this.comboBoxSelectorMap); - this.Controls.Add(this.statusStrip); - this.Controls.Add(this.buttonCreateModif); - this.Controls.Add(this.buttonRight); - this.Controls.Add(this.buttonDown); - this.Controls.Add(this.buttonLeft); - this.Controls.Add(this.buttonUp); - this.Controls.Add(this.buttonCreate); - this.Controls.Add(this.pictureBoxAirplane); - this.Name = "FormMap"; - this.Text = "Карта"; - this.statusStrip.ResumeLayout(false); - this.statusStrip.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private StatusStrip statusStrip; - private ToolStripStatusLabel toolStripStatusLabelSpeed; - private ToolStripStatusLabel toolStripStatusLabelWeight; - private ToolStripStatusLabel toolStripStatusLabelBodyColor; - private PictureBox pictureBoxAirplane; - private Button buttonCreate; - private Button buttonUp; - private Button buttonLeft; - private Button buttonDown; - private Button buttonRight; - private Button buttonCreateModif; - private ComboBox comboBoxSelectorMap; - } -} \ No newline at end of file diff --git a/AirplaneWithRadar/AirplaneWithRadar/LineMap.cs b/AirplaneWithRadar/AirplaneWithRadar/LineMap.cs index 3c1ae33..28fc0d0 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/LineMap.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/LineMap.cs @@ -6,6 +6,9 @@ using System.Threading.Tasks; namespace AirplaneWithRadar { + /// + /// Собственная реализация абсрактного класса AbstractMap + /// internal class LineMap : AbstractMap { /// -- 2.25.1