PIbd-13_YazykovaA.I._LABA06_Simple #6
@ -45,7 +45,7 @@ private int GetMaxCount => _pictureWidth * _pictureHeight /(_placeSizeWidth * _p
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_collection = collection;
|
||||
_collection.SetMaxCount = GetMaxCount;
|
||||
_collection.MaxCount = GetMaxCount;
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора сложения для класса
|
||||
|
@ -11,16 +11,17 @@ public interface ICollectionGenericObjects<T>
|
||||
{///Количество объектов в коллекции
|
||||
/// </summary>
|
||||
int Count { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Установка максимального количества элементов
|
||||
/// </summary>
|
||||
int SetMaxCount { set; }
|
||||
int MaxCount { get; set; }
|
||||
/// <summary>
|
||||
/// Добавление объекта в коллекцию
|
||||
/// </summary>
|
||||
/// <param name="obj">Добавляемый объект</param>
|
||||
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
||||
int Insert(T obj);
|
||||
int Insert(T obj);
|
||||
/// <summary>
|
||||
/// Добавление объекта в коллекцию на конкретную позицию
|
||||
/// </summary>
|
||||
@ -40,4 +41,14 @@ int Insert(T obj, int position);
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns>Объект</returns>
|
||||
T? Get(int position);
|
||||
|
||||
/// <summary>
|
||||
/// Получение типа коллекции
|
||||
/// </summary>
|
||||
CollectionType GetCollectionType { get; }
|
||||
/// <summary>
|
||||
/// Получение объектов коллекции по одному
|
||||
/// </summary>
|
||||
/// <returns>Поэлементый вывод элементов коллекции</returns>
|
||||
IEnumerable<T?> GetItems();
|
||||
}
|
||||
|
@ -16,9 +16,20 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
/// Максимально допустимое число объектов в списке
|
||||
/// </summary>
|
||||
private int _maxCount;
|
||||
public int MaxCount
|
||||
{
|
||||
get => _maxCount;
|
||||
set
|
||||
{
|
||||
if (value > 0)
|
||||
{
|
||||
_maxCount = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
public int Count => _collection.Count;
|
||||
public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
|
||||
public int MaxCount => _maxCount;
|
||||
|
||||
public CollectionType GetCollectionType => CollectionType.List;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
@ -68,5 +79,14 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
return obj;
|
||||
}
|
||||
|
||||
public IEnumerable<T?> GetItems()
|
||||
{
|
||||
for (int i = 0; i < _collection.Count; ++i)
|
||||
{
|
||||
yield return _collection[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,8 +16,12 @@ internal class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
|
||||
public int Count => _collection.Length;
|
||||
|
||||
public int SetMaxCount
|
||||
public int MaxCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return _collection.Length;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > 0)
|
||||
@ -34,6 +38,8 @@ internal class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
}
|
||||
}
|
||||
|
||||
public CollectionType GetCollectionType => CollectionType.Massive;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
@ -110,4 +116,11 @@ internal class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
return temp;
|
||||
}
|
||||
|
||||
public IEnumerable<T?> GetItems()
|
||||
{
|
||||
for (int i = 0; i < _collection.Length; ++i)
|
||||
{
|
||||
yield return _collection[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,23 +3,42 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TrolleybusProject.Drawnings;
|
||||
|
||||
namespace TrolleybusProject.CollectionGenericObjects;
|
||||
|
||||
public class StorageCollection<T>
|
||||
where T : class
|
||||
where T :DrawningBus
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Словарь (хранилище) с коллекциями
|
||||
/// </summary>
|
||||
readonly Dictionary<string, ICollectionGenericObjects<T>> _storages;
|
||||
|
||||
/// <summary>
|
||||
/// Возвращение списка названий коллекций
|
||||
/// </summary>
|
||||
public List<string> Keys => _storages.Keys.ToList();
|
||||
|
||||
/// <summary>
|
||||
/// Ключевое слово, с которого должен начинаться файл
|
||||
/// </summary>
|
||||
private readonly string _collectionKey = "CollectionsStorage";
|
||||
/// <summary>
|
||||
/// Разделитель для записи ключа и значения элемента словаря
|
||||
/// </summary>
|
||||
private readonly string _separatorForKeyValue = "|";
|
||||
/// <summary>
|
||||
/// Разделитель для записей коллекции данных в файл
|
||||
/// </summary>
|
||||
private readonly string _separatorItems = ";";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
///
|
||||
public StorageCollection()
|
||||
{
|
||||
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
|
||||
@ -70,6 +89,117 @@ public class StorageCollection<T>
|
||||
return _storages[name];
|
||||
}
|
||||
}
|
||||
|
||||
public bool SaveData(string filename)
|
||||
{
|
||||
if (_storages.Count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
File.Delete(filename);
|
||||
}
|
||||
using (StreamWriter writer = new(filename))
|
||||
{
|
||||
writer.Write(_collectionKey);
|
||||
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages)
|
||||
{
|
||||
writer.Write(Environment.NewLine);
|
||||
// не сохраняем пустые коллекции
|
||||
if (value.Value.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
writer.Write(value.Key);
|
||||
writer.Write(_separatorForKeyValue);
|
||||
writer.Write(value.Value.GetCollectionType);
|
||||
writer.Write(_separatorForKeyValue);
|
||||
writer.Write(value.Value.MaxCount);
|
||||
writer.Write(_separatorForKeyValue);
|
||||
|
||||
foreach (T? item in value.Value.GetItems())
|
||||
{
|
||||
string data = item?.GetDataForSave() ?? string.Empty;
|
||||
if (string.IsNullOrEmpty(data))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
writer.Write(data);
|
||||
writer.Write(_separatorItems);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool LoadData(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
using (StreamReader reader = new(filename))
|
||||
{
|
||||
string line = reader.ReadLine();
|
||||
if (line == null || line.Length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!line.Equals(_collectionKey))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_storages.Clear();
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
{
|
||||
string[] record = line.Split(_separatorForKeyValue,
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
if (record.Length != 4)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
|
||||
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionType);
|
||||
if (collection == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
collection.MaxCount = Convert.ToInt32(record[2]);
|
||||
string[] set = record[3].Split(_separatorItems,
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string elem in set)
|
||||
{
|
||||
if (elem?.CreateDrawningBus() is T bus)
|
||||
{
|
||||
if (collection.Insert(bus) <0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
_storages.Add(record[0], collection);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создание коллекции по типу
|
||||
/// </summary>
|
||||
/// <param name="collectionType"></param>
|
||||
/// <returns></returns>
|
||||
private static ICollectionGenericObjects<T>?
|
||||
CreateCollection(CollectionType collectionType)
|
||||
{
|
||||
return collectionType switch
|
||||
{
|
||||
CollectionType.Massive => new MassiveGenericObjects<T>(),
|
||||
CollectionType.List => new ListGenericObjects<T>(),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,11 +33,11 @@ public class DrawningBus
|
||||
/// <summary>
|
||||
/// Ширина прорисовки троллейбуса
|
||||
/// </summary>
|
||||
public readonly int _drawningBusWidth = 150;
|
||||
private readonly int _drawningBusWidth = 150;
|
||||
/// <summary>
|
||||
/// Высота прорисовки троллейбуса
|
||||
/// </summary>
|
||||
public readonly int _drawningBusHeight = 86;
|
||||
private readonly int _drawningBusHeight = 86;
|
||||
/// <summary>
|
||||
/// Координата X объекта
|
||||
/// </summary>
|
||||
@ -55,12 +55,10 @@ public class DrawningBus
|
||||
/// </summary>
|
||||
public int GetHeight => _drawningBusHeight;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор пустой
|
||||
/// </summary>
|
||||
private DrawningBus()
|
||||
public DrawningBus()
|
||||
{
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
@ -68,9 +66,6 @@ public class DrawningBus
|
||||
_startPosY = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
@ -84,14 +79,12 @@ public class DrawningBus
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор для наследников
|
||||
/// </summary>
|
||||
/// <param name="drawningBusWidth">Ширина прорисовки автобуса</param>
|
||||
/// <param name="drawningBusHeight">Высота прорисовки автобуса</param>
|
||||
|
||||
|
||||
protected DrawningBus(int drawningBusWidth, int drawningBusHeight) : this()
|
||||
{
|
||||
_drawningBusWidth= drawningBusWidth;
|
||||
@ -99,10 +92,13 @@ public class DrawningBus
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public DrawningBus(EntityBus? entityBus)
|
||||
{
|
||||
if (entityBus != null)
|
||||
{
|
||||
EntityBus = entityBus;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Установка границ поля
|
||||
@ -117,23 +113,17 @@ public class DrawningBus
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
|
||||
|
||||
|
||||
if (_startPosY.HasValue && _startPosX.HasValue)
|
||||
{
|
||||
if (_startPosX + _drawningBusWidth > width)
|
||||
{
|
||||
|
||||
_startPosX = width - _drawningBusWidth;
|
||||
|
||||
|
||||
}
|
||||
if (_startPosY + _drawningBusHeight > height)
|
||||
{
|
||||
|
||||
_startPosY = height - _drawningBusHeight;
|
||||
|
||||
|
||||
}
|
||||
if (_startPosX < 0)
|
||||
{
|
||||
@ -144,20 +134,11 @@ public class DrawningBus
|
||||
_startPosY = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
@ -171,13 +152,9 @@ public class DrawningBus
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
|
||||
|
||||
|
||||
if (_startPosX < 0)
|
||||
{ _startPosX = 0; }
|
||||
if (_startPosY < 0)
|
||||
@ -185,20 +162,15 @@ public class DrawningBus
|
||||
|
||||
if (x + _drawningBusWidth > _pictureWidth)
|
||||
{
|
||||
|
||||
_startPosX = _pictureWidth - _drawningBusWidth;
|
||||
|
||||
|
||||
}
|
||||
if (y + _drawningBusHeight > _pictureHeight)
|
||||
{
|
||||
|
||||
_startPosY = _pictureHeight - _drawningBusHeight;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение направления перемещения
|
||||
@ -259,30 +231,21 @@ public class DrawningBus
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
|
||||
|
||||
Brush brushBodyColor = new SolidBrush(EntityBus.BodyColor);
|
||||
|
||||
//троллейбус границы
|
||||
//троллейбус границы
|
||||
g.DrawEllipse(pen, _startPosX.Value + 22, _startPosY.Value +
|
||||
42, 20, 20);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 104, _startPosY.Value +
|
||||
42, 20, 20);
|
||||
|
||||
|
||||
g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value +
|
||||
8, 140, 41);
|
||||
|
||||
|
||||
//троллейбус
|
||||
g.FillRectangle(brushBodyColor, _startPosX.Value + 5, _startPosY.Value +
|
||||
8, 140, 41);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value +
|
||||
8, 140, 41);
|
||||
|
||||
|
||||
|
||||
|
||||
//дверь
|
||||
g.DrawRectangle(pen, _startPosX.Value + 52, _startPosY.Value +
|
||||
18, 24, 31);
|
||||
@ -308,14 +271,6 @@ public class DrawningBus
|
||||
g.FillEllipse(brBlue, _startPosX.Value + 129, _startPosY.Value +
|
||||
12, 15, 20);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
g.DrawEllipse(pen, _startPosX.Value + 8, _startPosY.Value +
|
||||
12, 15, 20);
|
||||
|
||||
@ -333,19 +288,5 @@ public class DrawningBus
|
||||
12, 15, 20);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,13 @@ public class DrawningTrolleybus:DrawningBus
|
||||
doors, roga, otsek);
|
||||
|
||||
}
|
||||
|
||||
public DrawningTrolleybus(EntityBus? entityBus)
|
||||
{
|
||||
if (entityBus != null)
|
||||
{
|
||||
EntityBus = entityBus;
|
||||
}
|
||||
}
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityBus == null || EntityBus is not EntityTrolleybus trolleybus|| !_startPosX.HasValue ||
|
||||
|
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TrolleybusProject.Entities;
|
||||
|
||||
namespace TrolleybusProject.Drawnings {
|
||||
|
||||
public static class ExtentionDrawningBus
|
||||
{
|
||||
/// <summary>
|
||||
/// Разделитель для записи информации по объекту в файл
|
||||
/// </summary>
|
||||
private static readonly string _separatorForObject = ":";
|
||||
/// <summary>
|
||||
/// Создание объекта из строки
|
||||
/// </summary>
|
||||
/// <param name="info">Строка с данными для создания объекта</param>
|
||||
/// <returns>Объект</returns>
|
||||
public static DrawningBus? CreateDrawningBus(this string info)
|
||||
{
|
||||
string[] strs = info.Split(_separatorForObject);
|
||||
EntityBus? bus = EntityTrolleybus.CreateEntityTrolleybus(strs);
|
||||
if (bus != null)
|
||||
{
|
||||
return new DrawningTrolleybus(bus);
|
||||
}
|
||||
bus = EntityBus.CreateEntityBus(strs);
|
||||
if (bus != null)
|
||||
{
|
||||
return new DrawningBus(bus);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение данных для сохранения в файл
|
||||
/// </summary>
|
||||
/// <param name="drawningBus">Сохраняемый объект</param>
|
||||
/// <returns>Строка с данными по объекту</returns>
|
||||
public static string GetDataForSave(this DrawningBus drawningBus)
|
||||
{
|
||||
string[]? array = drawningBus?.EntityBus?.GetStringRepresentation();
|
||||
if (array == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
return string.Join(_separatorForObject, array);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -7,12 +7,6 @@ using System.Threading.Tasks;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace TrolleybusProject.Entities;
|
||||
|
||||
/// <summary>
|
||||
@ -54,4 +48,33 @@ public class EntityBus
|
||||
BodyColor = bodyColor;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение строк со значениями свойств объекта класса-сущности
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual string[] GetStringRepresentation()
|
||||
{
|
||||
return new[] { nameof(EntityBus), Speed.ToString(),Weight.ToString(), BodyColor.Name };
|
||||
}
|
||||
/// <summary>
|
||||
/// Создание объекта из массива строк
|
||||
/// </summary>
|
||||
/// <param name="strs"></param>
|
||||
/// <returns></returns>
|
||||
public static EntityBus? CreateEntityBus(string[] strs)
|
||||
{
|
||||
if (strs.Length != 4 || strs[0] != nameof(EntityBus))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new EntityBus(Convert.ToInt32(strs[1]),
|
||||
Convert.ToDouble(strs[2]), Color.FromName(strs[3]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
|
||||
namespace TrolleybusProject.Entities;
|
||||
@ -57,7 +58,22 @@ public class EntityTrolleybus: EntityBus
|
||||
Doors = doors;
|
||||
}
|
||||
|
||||
public override string[] GetStringRepresentation()
|
||||
{
|
||||
return new[] { nameof(EntityTrolleybus), Speed.ToString(), Weight.ToString(), BodyColor.Name,
|
||||
AdditionalColor.Name, Roga.ToString(),Otsek.ToString(),Doors.ToString() };
|
||||
}
|
||||
|
||||
public static EntityTrolleybus? CreateEntityTrolleybus(string[] strs)
|
||||
{
|
||||
if (strs.Length != 8 || strs[0] != nameof(EntityTrolleybus))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new EntityTrolleybus(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]), Color.FromName(strs[4]),
|
||||
Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]), Convert.ToBoolean(strs[7]));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -46,10 +46,20 @@
|
||||
labelCollectionName = new Label();
|
||||
comboBoxSelectionCompany = new ComboBox();
|
||||
pictureBox = new PictureBox();
|
||||
menuStrip = new MenuStrip();
|
||||
FileToolStripMenuItem = new ToolStripMenuItem();
|
||||
файлToolStripMenuItem = new ToolStripMenuItem();
|
||||
save_ToolStripMenuItem = new ToolStripMenuItem();
|
||||
load_ToolStripMenuItem = new ToolStripMenuItem();
|
||||
SaveToolStripMenuItem = new ToolStripMenuItem();
|
||||
LoadToolStripMenuItem = new ToolStripMenuItem();
|
||||
saveFileDialog = new SaveFileDialog();
|
||||
openFileDialog = new OpenFileDialog();
|
||||
groupBoxTools.SuspendLayout();
|
||||
panelCompanyTools.SuspendLayout();
|
||||
panelStorage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxTools
|
||||
@ -59,9 +69,9 @@
|
||||
groupBoxTools.Controls.Add(panelStorage);
|
||||
groupBoxTools.Controls.Add(comboBoxSelectionCompany);
|
||||
groupBoxTools.Dock = DockStyle.Right;
|
||||
groupBoxTools.Location = new Point(904, 0);
|
||||
groupBoxTools.Location = new Point(904, 33);
|
||||
groupBoxTools.Name = "groupBoxTools";
|
||||
groupBoxTools.Size = new Size(300, 656);
|
||||
groupBoxTools.Size = new Size(300, 623);
|
||||
groupBoxTools.TabIndex = 0;
|
||||
groupBoxTools.TabStop = false;
|
||||
groupBoxTools.Text = "Инструменты";
|
||||
@ -92,7 +102,7 @@
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonRefresh.Location = new Point(24, 215);
|
||||
buttonRefresh.Location = new Point(26, 175);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(246, 34);
|
||||
buttonRefresh.TabIndex = 6;
|
||||
@ -103,7 +113,7 @@
|
||||
// buttonGoToCheck
|
||||
//
|
||||
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonGoToCheck.Location = new Point(24, 175);
|
||||
buttonGoToCheck.Location = new Point(26, 135);
|
||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||
buttonGoToCheck.Size = new Size(246, 34);
|
||||
buttonGoToCheck.TabIndex = 5;
|
||||
@ -125,7 +135,7 @@
|
||||
// buttonDelTrolleybus
|
||||
//
|
||||
buttonDelTrolleybus.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonDelTrolleybus.Location = new Point(22, 135);
|
||||
buttonDelTrolleybus.Location = new Point(26, 95);
|
||||
buttonDelTrolleybus.Name = "buttonDelTrolleybus";
|
||||
buttonDelTrolleybus.Size = new Size(244, 34);
|
||||
buttonDelTrolleybus.TabIndex = 4;
|
||||
@ -135,7 +145,7 @@
|
||||
//
|
||||
// maskedTextBox
|
||||
//
|
||||
maskedTextBox.Location = new Point(68, 98);
|
||||
maskedTextBox.Location = new Point(68, 58);
|
||||
maskedTextBox.Mask = "00";
|
||||
maskedTextBox.Name = "maskedTextBox";
|
||||
maskedTextBox.Size = new Size(150, 31);
|
||||
@ -238,12 +248,73 @@
|
||||
// pictureBox
|
||||
//
|
||||
pictureBox.Dock = DockStyle.Fill;
|
||||
pictureBox.Location = new Point(0, 0);
|
||||
pictureBox.Location = new Point(0, 33);
|
||||
pictureBox.Name = "pictureBox";
|
||||
pictureBox.Size = new Size(904, 656);
|
||||
pictureBox.Size = new Size(904, 623);
|
||||
pictureBox.TabIndex = 1;
|
||||
pictureBox.TabStop = false;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(24, 24);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { FileToolStripMenuItem, файлToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(1204, 33);
|
||||
menuStrip.TabIndex = 2;
|
||||
menuStrip.Text = "Фаил";
|
||||
|
||||
//
|
||||
// FileToolStripMenuItem
|
||||
//
|
||||
FileToolStripMenuItem.Name = "FileToolStripMenuItem";
|
||||
FileToolStripMenuItem.Size = new Size(16, 29);
|
||||
//
|
||||
// файлToolStripMenuItem
|
||||
//
|
||||
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { save_ToolStripMenuItem, load_ToolStripMenuItem });
|
||||
файлToolStripMenuItem.Name = "файлToolStripMenuItem";
|
||||
файлToolStripMenuItem.Size = new Size(69, 29);
|
||||
файлToolStripMenuItem.Text = "Фаил";
|
||||
//
|
||||
// save_ToolStripMenuItem
|
||||
//
|
||||
save_ToolStripMenuItem.Name = "save_ToolStripMenuItem";
|
||||
save_ToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||
save_ToolStripMenuItem.Size = new Size(270, 34);
|
||||
save_ToolStripMenuItem.Text = "Сохранить";
|
||||
save_ToolStripMenuItem.Click += save_ToolStripMenuItem_Click;
|
||||
//
|
||||
// load_ToolStripMenuItem
|
||||
//
|
||||
load_ToolStripMenuItem.Name = "load_ToolStripMenuItem";
|
||||
load_ToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
|
||||
load_ToolStripMenuItem.Size = new Size(270, 34);
|
||||
load_ToolStripMenuItem.Text = "Загрузить";
|
||||
load_ToolStripMenuItem.Click += load_ToolStripMenuItem_Click;
|
||||
//
|
||||
// SaveToolStripMenuItem
|
||||
//
|
||||
SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||
SaveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||
SaveToolStripMenuItem.Size = new Size(273, 34);
|
||||
SaveToolStripMenuItem.Text = "Сохранение";
|
||||
//
|
||||
// LoadToolStripMenuItem
|
||||
//
|
||||
LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||
LoadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
|
||||
LoadToolStripMenuItem.Size = new Size(273, 34);
|
||||
LoadToolStripMenuItem.Text = "Загрузка";
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
saveFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
openFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// FormBusCollection
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
@ -251,6 +322,8 @@
|
||||
ClientSize = new Size(1204, 656);
|
||||
Controls.Add(pictureBox);
|
||||
Controls.Add(groupBoxTools);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Name = "FormBusCollection";
|
||||
Text = "Коллекция автобусов";
|
||||
groupBoxTools.ResumeLayout(false);
|
||||
@ -259,7 +332,10 @@
|
||||
panelStorage.ResumeLayout(false);
|
||||
panelStorage.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -282,5 +358,14 @@
|
||||
private Button buttonCreateCompany;
|
||||
private Button buttonCollectionDel;
|
||||
private Panel panelCompanyTools;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem FileToolStripMenuItem;
|
||||
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private ToolStripMenuItem файлToolStripMenuItem;
|
||||
private ToolStripMenuItem save_ToolStripMenuItem;
|
||||
private ToolStripMenuItem load_ToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -29,11 +29,9 @@ public partial class FormBusCollection : Form
|
||||
_storageCollection = new();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void buttonAddBus_Click(object sender, EventArgs e)
|
||||
{
|
||||
BusConfig form= new ();
|
||||
BusConfig form = new();
|
||||
form.Show();
|
||||
form.AddEvent(SetBus);
|
||||
}
|
||||
@ -60,9 +58,9 @@ public partial class FormBusCollection : Form
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void buttonDelTrolleybus_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null)
|
||||
@ -117,11 +115,10 @@ public partial class FormBusCollection : Form
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pictureBox.Image = _company.Show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void buttonCollectionAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCollectionName.Text) ||
|
||||
@ -203,8 +200,44 @@ public partial class FormBusCollection : Form
|
||||
panelCompanyTools.Enabled = true;
|
||||
RerfreshListBoxItems();
|
||||
}
|
||||
|
||||
|
||||
private void save_ToolStripMenuItem_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 load_ToolStripMenuItem_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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -117,4 +117,13 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>165, 17</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>355, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -64,7 +64,5 @@ namespace TrolleybusProject.MovementStrategy
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -21,5 +21,4 @@ public enum StrategyStatus
|
||||
/// </summary>
|
||||
Finish
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user