diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/.CollectionType.cs.swp b/ProjectTank/ProjectTank/CollectionGenericObjects/.CollectionType.cs.swp deleted file mode 100644 index a66b189..0000000 Binary files a/ProjectTank/ProjectTank/CollectionGenericObjects/.CollectionType.cs.swp and /dev/null differ diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/.CollectionType_BASE_1418.cs.swp b/ProjectTank/ProjectTank/CollectionGenericObjects/.CollectionType_BASE_1418.cs.swp deleted file mode 100644 index d624aeb..0000000 Binary files a/ProjectTank/ProjectTank/CollectionGenericObjects/.CollectionType_BASE_1418.cs.swp and /dev/null differ diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/.CollectionType_LOCAL_1418.cs.swp b/ProjectTank/ProjectTank/CollectionGenericObjects/.CollectionType_LOCAL_1418.cs.swp deleted file mode 100644 index 88434f7..0000000 Binary files a/ProjectTank/ProjectTank/CollectionGenericObjects/.CollectionType_LOCAL_1418.cs.swp and /dev/null differ diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/.CollectionType_REMOTE_1418.cs.swp b/ProjectTank/ProjectTank/CollectionGenericObjects/.CollectionType_REMOTE_1418.cs.swp deleted file mode 100644 index 92fd602..0000000 Binary files a/ProjectTank/ProjectTank/CollectionGenericObjects/.CollectionType_REMOTE_1418.cs.swp and /dev/null differ diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType_BACKUP_1418.cs b/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType_BACKUP_1418.cs deleted file mode 100644 index 9e5e365..0000000 --- a/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType_BACKUP_1418.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace ProjectTank.CollectionGenericObjects; -<<<<<<< HEAD -/// -/// Тип коллекции -/// -======= - ->>>>>>> d84f98706403d56e8dae185838815e23bb91f4d7 -public enum CollectionType -{ - /// - /// Неопределено - /// - None = 0, - - /// - /// Массив - /// - Massive = 1, - - /// - /// Список - /// - List = 2 -} \ No newline at end of file diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType_BASE_1418.cs b/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType_BASE_1418.cs deleted file mode 100644 index 75d6067..0000000 --- a/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType_BASE_1418.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace ProjectLinkor.CollectionGenericObjects; - -public enum CollectionType -{ - /// - /// Неопределено - /// - None = 0, - /// - /// Массив - /// - Massive = 1, - /// - /// Список - /// - List = 2 -} \ No newline at end of file diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType_LOCAL_1418.cs b/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType_LOCAL_1418.cs deleted file mode 100644 index 93d9dff..0000000 --- a/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType_LOCAL_1418.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace ProjectTank.CollectionGenericObjects; -/// -/// Тип коллекции -/// -public enum CollectionType -{ - /// - /// Неопределено - /// - None = 0, - - /// - /// Массив - /// - Massive = 1, - - /// - /// Список - /// - List = 2 -} \ No newline at end of file diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType_REMOTE_1418.cs b/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType_REMOTE_1418.cs deleted file mode 100644 index f4bf31f..0000000 --- a/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType_REMOTE_1418.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace ProjectTank.CollectionGenericObjects; - -public enum CollectionType -{ - /// - /// Неопределено - /// - None = 0, - /// - /// Массив - /// - Massive = 1, - /// - /// Список - /// - List = 2 -} \ No newline at end of file diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection.cs b/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection.cs index 360b6d3..983b5a6 100644 --- a/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection.cs +++ b/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection.cs @@ -1,4 +1,7 @@ +using ProjectTank.Drawning; +using System.Text; + namespace ProjectTank.CollectionGenericObjects { /// diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection_BACKUP_1588.cs b/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection_BACKUP_1588.cs deleted file mode 100644 index 24dd440..0000000 --- a/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection_BACKUP_1588.cs +++ /dev/null @@ -1,83 +0,0 @@ -<<<<<<< HEAD - -======= -using ProjectLinkor.CollectionGenericObjects; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - ->>>>>>> parent of 5665ee3 (fix) -namespace ProjectTank.CollectionGenericObjects -{ - public class StorageCollection - where T : class - { - /// - /// Словарь (хранилище) с коллекциями - /// - readonly Dictionary> _storages; - /// - /// Возвращение списка названий коллекций - /// - public List Keys => _storages.Keys.ToList(); - /// - /// Конструктор - /// - public StorageCollection() - { - _storages = new Dictionary>(); - } - /// - /// Добавление коллекции в хранилище - /// - /// Название коллекции - /// тип коллекции - public void AddCollection(string name, CollectionType collectionType) - { - // TODO проверка, что name не пустой и нет в словаре записи с таким ключом - // TODO Прописать логику для добавления - if (name == null || _storages.ContainsKey(name)) - return; - switch (collectionType) - { - case CollectionType.None: - return; - case CollectionType.Massive: - _storages[name] = new MassiveGenericObjects(); - return; - case CollectionType.List: - _storages[name] = new ListGenericObjects(); - return; - } - - } - /// - /// Удаление коллекции - /// - /// Название коллекции - public void DelCollection(string name) - { - // TODO Прописать логику для удаления коллекции - if (_storages.ContainsKey(name)) - _storages.Remove(name); - } - /// - /// Доступ к коллекции - /// - /// Название коллекции - /// - public ICollectionGenericObjects? this[string name] - { - get - { - // TODO Продумать логику получения объекта - if (name == null || !_storages.ContainsKey(name)) - return null; - return _storages[name]; - } - } - - } -} diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection_BASE_1588.cs b/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection_BASE_1588.cs deleted file mode 100644 index 4345763..0000000 --- a/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection_BASE_1588.cs +++ /dev/null @@ -1,75 +0,0 @@ -using ProjectLinkor.CollectionGenericObjects; - - -namespace ProjectTank.CollectionGenericObjects -{ - public class StorageCollection - where T : class - { - /// - /// Словарь (хранилище) с коллекциями - /// - readonly Dictionary> _storages; - /// - /// Возвращение списка названий коллекций - /// - public List Keys => _storages.Keys.ToList(); - /// - /// Конструктор - /// - public StorageCollection() - { - _storages = new Dictionary>(); - } - /// - /// Добавление коллекции в хранилище - /// - /// Название коллекции - /// тип коллекции - public void AddCollection(string name, CollectionType collectionType) - { - // TODO проверка, что name не пустой и нет в словаре записи с таким ключом - // TODO Прописать логику для добавления - if (name == null || _storages.ContainsKey(name)) - return; - switch (collectionType) - { - case CollectionType.None: - return; - case CollectionType.Massive: - _storages[name] = new MassiveGenericObjects(); - return; - case CollectionType.List: - _storages[name] = new ListGenericObjects(); - return; - } - - } - /// - /// Удаление коллекции - /// - /// Название коллекции - public void DelCollection(string name) - { - // TODO Прописать логику для удаления коллекции - if (_storages.ContainsKey(name)) - _storages.Remove(name); - } - /// - /// Доступ к коллекции - /// - /// Название коллекции - /// - public ICollectionGenericObjects? this[string name] - { - get - { - // TODO Продумать логику получения объекта - if (name == null || !_storages.ContainsKey(name)) - return null; - return _storages[name]; - } - } - - } -} diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection_LOCAL_1588.cs b/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection_LOCAL_1588.cs deleted file mode 100644 index 6b0bc15..0000000 --- a/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection_LOCAL_1588.cs +++ /dev/null @@ -1,73 +0,0 @@ - -namespace ProjectTank.CollectionGenericObjects -{ - public class StorageCollection - where T : class - { - /// - /// Словарь (хранилище) с коллекциями - /// - readonly Dictionary> _storages; - /// - /// Возвращение списка названий коллекций - /// - public List Keys => _storages.Keys.ToList(); - /// - /// Конструктор - /// - public StorageCollection() - { - _storages = new Dictionary>(); - } - /// - /// Добавление коллекции в хранилище - /// - /// Название коллекции - /// тип коллекции - public void AddCollection(string name, CollectionType collectionType) - { - // TODO проверка, что name не пустой и нет в словаре записи с таким ключом - // TODO Прописать логику для добавления - if (name == null || _storages.ContainsKey(name)) - return; - switch (collectionType) - { - case CollectionType.None: - return; - case CollectionType.Massive: - _storages[name] = new MassiveGenericObjects(); - return; - case CollectionType.List: - _storages[name] = new ListGenericObjects(); - return; - } - - } - /// - /// Удаление коллекции - /// - /// Название коллекции - public void DelCollection(string name) - { - // TODO Прописать логику для удаления коллекции - if (_storages.ContainsKey(name)) - _storages.Remove(name); - } - /// - /// Доступ к коллекции - /// - /// Название коллекции - /// - public ICollectionGenericObjects? this[string name] - { - get - { - // TODO Продумать логику получения объекта - if (name == null || !_storages.ContainsKey(name)) - return null; - return _storages[name]; - } - } - - } -} diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection_REMOTE_1588.cs b/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection_REMOTE_1588.cs deleted file mode 100644 index 368bdcb..0000000 --- a/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection_REMOTE_1588.cs +++ /dev/null @@ -1,79 +0,0 @@ -using ProjectLinkor.CollectionGenericObjects; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectTank.CollectionGenericObjects -{ - public class StorageCollection - where T : class - { - /// - /// Словарь (хранилище) с коллекциями - /// - readonly Dictionary> _storages; - /// - /// Возвращение списка названий коллекций - /// - public List Keys => _storages.Keys.ToList(); - /// - /// Конструктор - /// - public StorageCollection() - { - _storages = new Dictionary>(); - } - /// - /// Добавление коллекции в хранилище - /// - /// Название коллекции - /// тип коллекции - public void AddCollection(string name, CollectionType collectionType) - { - // TODO проверка, что name не пустой и нет в словаре записи с таким ключом - // TODO Прописать логику для добавления - if (name == null || _storages.ContainsKey(name)) - return; - switch (collectionType) - { - case CollectionType.None: - return; - case CollectionType.Massive: - _storages[name] = new MassiveGenericObjects(); - return; - case CollectionType.List: - _storages[name] = new ListGenericObjects(); - return; - } - - } - /// - /// Удаление коллекции - /// - /// Название коллекции - public void DelCollection(string name) - { - // TODO Прописать логику для удаления коллекции - if (_storages.ContainsKey(name)) - _storages.Remove(name); - } - /// - /// Доступ к коллекции - /// - /// Название коллекции - /// - public ICollectionGenericObjects? this[string name] - { - get - { - // TODO Продумать логику получения объекта - if (name == null || !_storages.ContainsKey(name)) - return null; - return _storages[name]; - } - } - - } -} diff --git a/ProjectTank/ProjectTank/Drawning/DrawningBattleTank.cs.orig b/ProjectTank/ProjectTank/Drawning/DrawningBattleTank.cs.orig deleted file mode 100644 index 86f6e79..0000000 --- a/ProjectTank/ProjectTank/Drawning/DrawningBattleTank.cs.orig +++ /dev/null @@ -1,73 +0,0 @@ -<<<<<<< HEAD -======= -using ProjectTank.Entities; ->>>>>>> 6b2dbf2 (LabWork_2) - -namespace ProjectTank.Drawning; -/// -/// Класс, отвечающий за прорисовку и перемещение объекта-сущности -/// -public class DrawningBattleTank :DrawningTank -{ - /// - /// Конструктор - /// - /// Скорость -<<<<<<< HEAD - /// Вес -======= - /// Вес автомобиля ->>>>>>> 6b2dbf2 (LabWork_2) - /// Основной цвет - /// Дополнительный цвет - /// Признак наличия пушки - /// признак наличия пулемета - /// - public DrawningBattleTank(int speed, double weight, Color bodyColor, Color additionalColor, bool gun, bool machinGun) : base(150, 87) - { - EntityTank = new EntityBattleTank(speed, weight, bodyColor, additionalColor, gun, machinGun); - } - - /// - /// Прорисовка объекта - /// - /// - public override void DrawTransport(Graphics g) - { - if (EntityTank == null || EntityTank is not EntityBattleTank battleTank || !_startPosX.HasValue || !_startPosY.HasValue) - { - return; - } - Pen pen = new(Color.Black); - Brush additionalBrush = new SolidBrush(battleTank.AdditionalColor); - - if (battleTank.Gun) - { - g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 30, 45, 5); - - g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value + 30, 45, 5); - } - - //пулемет - if (battleTank.MachinGun) - { - g.DrawRectangle(pen, _startPosX.Value + 65, _startPosY.Value + 15, 16, 5); - g.DrawRectangle(pen, _startPosX.Value + 72, _startPosY.Value + 10, 5, 5); - g.DrawRectangle(pen, _startPosX.Value + 71, _startPosY.Value + 3, 7, 7); - g.DrawRectangle(pen, _startPosX.Value + 55, _startPosY.Value + 5, 15, 3); - - g.FillRectangle(additionalBrush, _startPosX.Value + 65, _startPosY.Value + 15, 16, 5); - g.FillRectangle(additionalBrush, _startPosX.Value + 72, _startPosY.Value + 10, 5, 5); - g.FillRectangle(additionalBrush, _startPosX.Value + 71, _startPosY.Value + 3, 7, 7); - g.FillRectangle(additionalBrush, _startPosX.Value + 55, _startPosY.Value + 5, 15, 3); - } - _startPosY += 20; - base.DrawTransport(g); - _startPosY -= 20; - - } - -} - - - diff --git a/ProjectTank/ProjectTank/Entities/EntityTank.cs.orig b/ProjectTank/ProjectTank/Entities/EntityTank.cs.orig deleted file mode 100644 index 9803d29..0000000 --- a/ProjectTank/ProjectTank/Entities/EntityTank.cs.orig +++ /dev/null @@ -1,56 +0,0 @@ -<<<<<<< HEAD -namespace ProjectTank.Entities -======= -namespace ProjectTank.Entities ->>>>>>> 6b2dbf2 (LabWork_2) -{ - public class EntityTank - { - - /// - /// Скорость - /// - public int Speed { get; private set; } - - /// - /// Вес - /// - public double Weight { get; private set; } - - /// - /// Основной цвет - /// - public Color BodyColor { get; private set; } - - /// - /// Шаг перемещения танка - /// - public double Step => Speed * 100 / Weight; -<<<<<<< HEAD - public void SetBodyColor(Color color) - { - BodyColor = color; - } -======= ->>>>>>> 6b2dbf2 (LabWork_2) - - /// - /// Конструктор сущности - /// - /// Скорость -<<<<<<< HEAD - /// Веc -======= - /// Вес автомобиля ->>>>>>> 6b2dbf2 (LabWork_2) - /// Основной цвет - - public EntityTank(int speed, double weight, Color bodyColor) - { - Speed = speed; - Weight = weight; - BodyColor = bodyColor; - - } - } -} diff --git a/ProjectTank/ProjectTank/Entities/EntiyBattleTank.cs.orig b/ProjectTank/ProjectTank/Entities/EntiyBattleTank.cs.orig deleted file mode 100644 index 7aae8d2..0000000 --- a/ProjectTank/ProjectTank/Entities/EntiyBattleTank.cs.orig +++ /dev/null @@ -1,52 +0,0 @@ -using ProjectTank.Entities; - -namespace ProjectTank -{ - /// - /// Класс-сущность танк - /// - public class EntityBattleTank : EntityTank - - { - /// - /// Дополнительный цвет (для опциональных элементов) - /// - public Color AdditionalColor { get; private set; } - - /// - /// Признак (опция) наличия пушки - /// - public bool Gun { get; private set; } - - - /// - /// Признак (опция) наличия Пулемета на башне - /// /// - public bool MachinGun { get; private set; } - -<<<<<<< HEAD - public void SetAdditionalColor(Color addColor) - { - AdditionalColor = addColor; - } - -======= ->>>>>>> 6b2dbf2 (LabWork_2) - /// - /// Конструктор объекта-класса Боевого Танка - /// - /// Скорость - /// Вес - /// Основной цвет - /// Дополнительный цвет - /// Пушка танка - /// Пклемет на башне - public EntityBattleTank(int speed, double weight, Color bodyColor, Color additionalColor, bool gun, bool machinGun) : base(speed, weight, bodyColor) - { - AdditionalColor = additionalColor; - MachinGun= machinGun; - Gun = gun; - } - - } -} diff --git a/ProjectTank/ProjectTank/FormBattleTankCollection.cs b/ProjectTank/ProjectTank/FormBattleTankCollection.cs index d81e1d2..689201b 100644 --- a/ProjectTank/ProjectTank/FormBattleTankCollection.cs +++ b/ProjectTank/ProjectTank/FormBattleTankCollection.cs @@ -68,19 +68,12 @@ namespace ProjectTank return; } - return color; - } - - private void ButtonAddTank_Click(object sender, EventArgs e) - { - CreateObject(nameof(DrawningTank)); - } - - private void ButtonAddBattleTank_Click(object sender, EventArgs e) - { - CreateObject(nameof(DrawningBattleTank)); + FormTankConfig form = new(); + form.AddEvent(SetTank); + form.Show(); } + private void buttonRemoveTank_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null) return; @@ -228,5 +221,41 @@ namespace ProjectTank panelCompanyTools.Enabled = true; RerfreshListBoxItems(); } + private void SaveToolStripMenuItem_Click(object sender, EventArgs e) + { + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + if (_storageCollection.SaveData(saveFileDialog.FileName)) + { + MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + else + { + MessageBox.Show("Не сохранилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + /// + /// Обработка нажатия "Загрузка" + /// + /// + /// + private void LoadToolStripMenuItem_Click(object sender, EventArgs e) + { + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + if (_storageCollection.LoadData(openFileDialog.FileName)) + { + MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); + RerfreshListBoxItems(); + } + else + { + MessageBox.Show("не загрузилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + + } + } + } } } \ No newline at end of file diff --git a/ProjectTank/ProjectTank/MovementStrategy/MoveableTank.cs.orig b/ProjectTank/ProjectTank/MovementStrategy/MoveableTank.cs.orig deleted file mode 100644 index a9b935d..0000000 --- a/ProjectTank/ProjectTank/MovementStrategy/MoveableTank.cs.orig +++ /dev/null @@ -1,64 +0,0 @@ -using ProjectTank.Drawning; - -namespace ProjectTank.MovementStrategy -{ - public class MoveableTank : IMoveableObject - { - /// - /// Поле-объект класса или его DrawningTank наследника - /// - private readonly DrawningTank? _tank = null; - /// -<<<<<<< HEAD - /// конструктор - /// - /// Объект класса DrawningTank -======= - /// Конструктор - /// - /// Объект класса DrawningBoat ->>>>>>> 6b2dbf2 (LabWork_2) - public MoveableTank(DrawningTank tank) - { - _tank = tank; - } - public ObjectParameters? GetObjectPosition - { - get - { - if (_tank == null || _tank.EntityTank == null || - !_tank.GetPosX.HasValue || !_tank.GetPosY.HasValue) - { - return null; - } - return new ObjectParameters(_tank.GetPosX.Value, - _tank.GetPosY.Value, _tank.GetWidth, _tank.GetHeight); - } - } - public int GetStep => (int)(_tank?.EntityTank?.Step ?? 0); - public bool TryMoveObject(MovementDirection direction) - { - if (_tank == null || _tank.EntityTank == null) - { - return false; - } - return _tank.MoveTransport(GetDirectionType(direction)); - } - /// - /// Конвертация из MovementDirection в DirectionType - /// - /// MovementDirection - /// DirectionType - private static DirectionType GetDirectionType(MovementDirection direction) - { - return direction switch - { - MovementDirection.Left => DirectionType.Left, - MovementDirection.Right => DirectionType.Right, - MovementDirection.Up => DirectionType.Up, - MovementDirection.Down => DirectionType.Down, - _ => DirectionType.Unknow, - }; - } - } -}