PIBD-14 Boyko_M.S, LabWork06 Simple #7
@ -48,7 +48,7 @@ public abstract class AbstractCompany
|
|||||||
_pictureWidth = picWidth;
|
_pictureWidth = picWidth;
|
||||||
_pictureHeight = picHeight;
|
_pictureHeight = picHeight;
|
||||||
_collection = collection;
|
_collection = collection;
|
||||||
_collection.SetMaxCount = GetMaxCount;
|
_collection.MaxCount = GetMaxCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using ProjectElectroTrans.Drawnings;
|
namespace ProjectElectroTrans.CollectionGenericObjects;
|
||||||
|
|
||||||
namespace ProjectElectroTrans.CollectionGenericObjects;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Интерфейс описания действий для набора хранимых объектов
|
/// Интерфейс описания действий для набора хранимых объектов
|
||||||
@ -17,7 +15,7 @@ public interface ICollectionGenericObjects<T>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка максимального количества элементов
|
/// Установка максимального количества элементов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int SetMaxCount { set; }
|
int MaxCount { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в коллекцию
|
/// Добавление объекта в коллекцию
|
||||||
@ -39,7 +37,7 @@ public interface ICollectionGenericObjects<T>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="position">Позиция</param>
|
/// <param name="position">Позиция</param>
|
||||||
/// <returns>true - удаление прошло удачно, false - удаление не удалось</returns>
|
/// <returns>true - удаление прошло удачно, false - удаление не удалось</returns>
|
||||||
T? Remove(int position);
|
T Remove(int position);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение объекта по позиции
|
/// Получение объекта по позиции
|
||||||
@ -47,4 +45,15 @@ public interface ICollectionGenericObjects<T>
|
|||||||
/// <param name="position">Позиция</param>
|
/// <param name="position">Позиция</param>
|
||||||
/// <returns>Объект</returns>
|
/// <returns>Объект</returns>
|
||||||
T? Get(int position);
|
T? Get(int position);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение типа коллекции
|
||||||
|
/// </summary>
|
||||||
|
CollectionType GetCollectionType { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение объектов коллекции по одному
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Поэлементый вывод элементов коллекции</returns>
|
||||||
|
IEnumerable<T?> GetItems();
|
||||||
}
|
}
|
@ -11,13 +11,27 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
/// Список объектов, которые храним
|
/// Список объектов, которые храним
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly List<T?> _collection;
|
private readonly List<T?> _collection;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Максимально допустимое число объектов в списке
|
/// Максимально допустимое число объектов в списке
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int _maxCount;
|
private int _maxCount;
|
||||||
|
|
||||||
public int Count => _collection.Count;
|
public int Count => _collection.Count;
|
||||||
|
|
||||||
public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
|
public int MaxCount
|
||||||
|
{
|
||||||
|
get { return Count; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value > 0)
|
||||||
|
{
|
||||||
|
_maxCount = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CollectionType GetCollectionType => CollectionType.List;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
@ -27,43 +41,40 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
_collection = new();
|
_collection = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public T? Get(int position)
|
public T Get(int position)
|
||||||
{
|
{
|
||||||
|
if (position >= Count || position < 0) return null;
|
||||||
if (position < 0 || position > _collection.Count - 1)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return _collection[position];
|
return _collection[position];
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Insert(T obj)
|
public int Insert(T obj)
|
||||||
{
|
{
|
||||||
if (_collection.Count + 1 > _maxCount) { return 0; }
|
if (Count == _maxCount) return -1;
|
||||||
_collection.Add(obj);
|
_collection.Add(obj);
|
||||||
|
return Count;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Insert(T obj, int position)
|
public int Insert(T obj, int position)
|
||||||
{
|
{
|
||||||
if (_collection.Count + 1 < _maxCount) { return 0; }
|
if (Count == _maxCount) return -1;
|
||||||
if (position > _collection.Count || position < 0)
|
if (position >= Count || position < 0) return -1;
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
_collection.Insert(position, obj);
|
_collection.Insert(position, obj);
|
||||||
return 1;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T Remove(int position)
|
public T Remove(int position)
|
||||||
{
|
{
|
||||||
if (position > _collection.Count || position < 0)
|
if (position >= _collection.Count || position < 0) return null;
|
||||||
{
|
T obj = _collection[position];
|
||||||
return null;
|
|
||||||
}
|
|
||||||
T temp = _collection[position];
|
|
||||||
_collection.RemoveAt(position);
|
_collection.RemoveAt(position);
|
||||||
return temp;
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<T?> GetItems()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < Count; ++i)
|
||||||
|
{
|
||||||
|
yield return _collection[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,4 @@
|
|||||||
using System.Runtime.Remoting;
|
|
||||||
using ProjectElectroTrans.Drawnings;
|
|
||||||
|
|
||||||
namespace ProjectElectroTrans.CollectionGenericObjects;
|
namespace ProjectElectroTrans.CollectionGenericObjects;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -17,8 +15,12 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
|
|
||||||
public int Count => _collection.Length;
|
public int Count => _collection.Length;
|
||||||
|
|
||||||
public int SetMaxCount
|
public int MaxCount
|
||||||
{
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _collection.Length;
|
||||||
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value > 0)
|
if (value > 0)
|
||||||
@ -35,6 +37,8 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CollectionType GetCollectionType => CollectionType.Massive;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -130,4 +134,12 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
_collection[position] = null;
|
_collection[position] = null;
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<T?> GetItems()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _collection.Length; ++i)
|
||||||
|
{
|
||||||
|
yield return _collection[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,11 +1,15 @@
|
|||||||
namespace ProjectElectroTrans.CollectionGenericObjects;
|
using ProjectElectroTrans.Drawnings;
|
||||||
|
using System.Text;
|
||||||
|
using ProjectElectroTrans.CollectionGenericObjects;
|
||||||
|
|
||||||
|
namespace ProjectElectroTrans.CollectionGenericObjects;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Класс-хранилище коллекций
|
/// Класс-хранилище коллекций
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
public class StorageCollection<T>
|
public class StorageCollection<T>
|
||||||
where T : class
|
where T : DrawingTrans
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Словарь (хранилище) с коллекциями
|
/// Словарь (хранилище) с коллекциями
|
||||||
@ -17,6 +21,21 @@ public class StorageCollection<T>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> Keys => _storages.Keys.ToList();
|
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>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -32,20 +51,12 @@ public class StorageCollection<T>
|
|||||||
/// <param name="collectionType">тип коллекции</param>
|
/// <param name="collectionType">тип коллекции</param>
|
||||||
public void AddCollection(string name, CollectionType collectionType)
|
public void AddCollection(string name, CollectionType collectionType)
|
||||||
{
|
{
|
||||||
if (name == null || _storages.ContainsKey(name)) { return; }
|
if (_storages.ContainsKey(name)) return;
|
||||||
switch (collectionType)
|
if (collectionType == CollectionType.None) return;
|
||||||
|
else if (collectionType == CollectionType.Massive)
|
||||||
{
|
_storages[name] = new MassiveGenericObjects<T>();
|
||||||
case CollectionType.None:
|
else if (collectionType == CollectionType.List)
|
||||||
return;
|
_storages[name] = new ListGenericObjects<T>();
|
||||||
case CollectionType.Massive:
|
|
||||||
_storages.Add(name, new MassiveGenericObjects<T> { });
|
|
||||||
return;
|
|
||||||
case CollectionType.List:
|
|
||||||
_storages.Add(name, new ListGenericObjects<T> { });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -54,7 +65,7 @@ public class StorageCollection<T>
|
|||||||
/// <param name="name">Название коллекции</param>
|
/// <param name="name">Название коллекции</param>
|
||||||
public void DelCollection(string name)
|
public void DelCollection(string name)
|
||||||
{
|
{
|
||||||
if (name == null || !_storages.ContainsKey(name)) { return; }
|
if (_storages.ContainsKey(name))
|
||||||
_storages.Remove(name);
|
_storages.Remove(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,8 +78,141 @@ public class StorageCollection<T>
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (name == null || !_storages.ContainsKey(name)) { return null; }
|
if (_storages.ContainsKey(name))
|
||||||
return _storages[name];
|
return _storages[name];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Сохранение информации по автомобилям в хранилище в файл
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename">Путь и имя файла</param>
|
||||||
|
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
|
||||||
|
public bool SaveData(string filename)
|
||||||
|
{
|
||||||
|
if (_storages.Count == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(filename))
|
||||||
|
{
|
||||||
|
File.Delete(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
using (StreamWriter writer = new StreamWriter(filename))
|
||||||
|
{
|
||||||
|
writer.Write(_collectionKey);
|
||||||
|
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new();
|
||||||
|
sb.Append(Environment.NewLine);
|
||||||
|
|||||||
|
// не сохраняем пустые коллекции
|
||||||
|
if (value.Value.Count == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.Append(value.Key);
|
||||||
|
sb.Append(_separatorForKeyValue);
|
||||||
|
sb.Append(value.Value.GetCollectionType);
|
||||||
|
sb.Append(_separatorForKeyValue);
|
||||||
|
sb.Append(value.Value.MaxCount);
|
||||||
|
sb.Append(_separatorForKeyValue);
|
||||||
|
foreach (T? item in value.Value.GetItems())
|
||||||
|
{
|
||||||
|
string data = item?.GetDataForSave() ?? string.Empty;
|
||||||
|
if (string.IsNullOrEmpty(data))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.Append(data);
|
||||||
|
sb.Append(_separatorItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.Write(sb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Загрузка информации по автомобилям в хранилище из файла
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename">Путь и имя файла</param>
|
||||||
|
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
||||||
|
public bool LoadData(string filename)
|
||||||
|
{
|
||||||
|
if (!File.Exists(filename))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (StreamReader fs = File.OpenText(filename))
|
||||||
|
{
|
||||||
|
string str = fs.ReadLine();
|
||||||
|
if (str == null || str.Length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!str.StartsWith(_collectionKey))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_storages.Clear();
|
||||||
|
string strs = "";
|
||||||
|
while ((strs = fs.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
string[] record = strs.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?.CreateDrawningTrans() is T ship)
|
||||||
|
{
|
||||||
|
if (collection.Insert(ship) == -1)
|
||||||
|
{
|
||||||
|
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,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,15 @@ public class DrawingElectroTrans : DrawingTrans
|
|||||||
{
|
{
|
||||||
EntityTrans = new EntityElectroTrans(speed, weight, bodyColor, additionalColor, horns, battery);
|
EntityTrans = new EntityElectroTrans(speed, weight, bodyColor, additionalColor, horns, battery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DrawingElectroTrans(EntityTrans trans) : base(110, 60)
|
||||||
|
{
|
||||||
|
if (trans != null && trans is EntityElectroTrans electroTrans)
|
||||||
|
{
|
||||||
|
EntityTrans = new EntityElectroTrans(electroTrans.Speed, electroTrans.Weight, electroTrans.BodyColor, electroTrans.AdditionalColor, electroTrans.Horns, electroTrans.Battery);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void DrawTransport(Graphics g)
|
public override void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
if (EntityTrans == null || EntityTrans is not EntityElectroTrans electroTrans ||
|
if (EntityTrans == null || EntityTrans is not EntityElectroTrans electroTrans ||
|
||||||
|
@ -76,6 +76,19 @@ public class DrawingTrans
|
|||||||
{
|
{
|
||||||
EntityTrans = new EntityTrans(speed, weight, bodyColor);
|
EntityTrans = new EntityTrans(speed, weight, bodyColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="car">Класс-сущность</param>
|
||||||
|
public DrawingTrans(EntityTrans trans) : this()
|
||||||
|
{
|
||||||
|
if (trans != null)
|
||||||
|
{
|
||||||
|
EntityTrans = new EntityTrans(trans.Speed, trans.Weight, trans.BodyColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор для наследников
|
/// Конструктор для наследников
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
53
ProjectElectroTrans/Drawnings/ExtentionDrawningTrans.cs
Normal file
53
ProjectElectroTrans/Drawnings/ExtentionDrawningTrans.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using ProjectElectroTrans.Drawnings;
|
||||||
|
using ProjectElectroTrans.Entities;
|
||||||
|
|
||||||
|
namespace ProjectElectroTrans;
|
||||||
|
|
||||||
|
public static class ExtentionDrawningTrans
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Разделитель для записи информации по объекту в файл
|
||||||
|
/// </summary>
|
||||||
|
private static readonly string _separatorForObject = ":";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создание объекта из строки
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">Строка с данными для создания объекта</param>
|
||||||
|
/// <returns>Объект</returns>
|
||||||
|
public static DrawingTrans? CreateDrawningTrans(this string info)
|
||||||
|
{
|
||||||
|
string[] strs = info.Split(_separatorForObject);
|
||||||
|
EntityTrans? airplan = EntityElectroTrans.CreateEntityElectroTrans(strs);
|
||||||
|
if (airplan != null)
|
||||||
|
{
|
||||||
|
return new DrawingElectroTrans((EntityElectroTrans)airplan);
|
||||||
|
}
|
||||||
|
|
||||||
|
airplan = EntityTrans.CreateEntityTrans(strs);
|
||||||
|
if (airplan != null)
|
||||||
|
{
|
||||||
|
return new DrawingTrans(airplan);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение данных для сохранения в файл
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="DrawingTrans">Сохраняемый объект</param>
|
||||||
|
/// <returns>Строка с данными по объекту</returns>
|
||||||
|
public static string GetDataForSave(this DrawingTrans DrawingTrans)
|
||||||
|
{
|
||||||
|
string[]? array = DrawingTrans?.EntityTrans?.GetStringRepresentation();
|
||||||
|
|
||||||
|
if (array == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Join(_separatorForObject, array);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -48,4 +48,34 @@ internal class EntityElectroTrans : EntityTrans
|
|||||||
Horns = horns;
|
Horns = horns;
|
||||||
Battery = battery;
|
Battery = battery;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение строк со значениями свойств объекта класса-сущности
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override string[] GetStringRepresentation()
|
||||||
|
{
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
nameof(EntityElectroTrans), Speed.ToString(),
|
||||||
|
Weight.ToString(), BodyColor.Name, AdditionalColor.Name, Horns.ToString(), Battery.ToString()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создание объекта из массива строк
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strs"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static EntityTrans? CreateEntityElectroTrans(string[] strs)
|
||||||
|
{
|
||||||
|
if (strs.Length != 7 || strs[0] != nameof(EntityElectroTrans))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new EntityElectroTrans(Convert.ToInt32(strs[1]),
|
||||||
|
Convert.ToDouble(strs[2]), Color.FromName(strs[3]),
|
||||||
|
Color.FromName(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[5]));
|
||||||
|
}
|
||||||
}
|
}
|
@ -44,4 +44,29 @@ public class EntityTrans
|
|||||||
BodyColor = bodyColor;
|
BodyColor = bodyColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение строк со значениями свойств объекта класса-сущности
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual string[] GetStringRepresentation()
|
||||||
|
{
|
||||||
|
return new[] { nameof(EntityTrans), Speed.ToString(),
|
||||||
|
Weight.ToString(), BodyColor.Name };
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Создание объекта из массива строк
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strs"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static EntityTrans? CreateEntityTrans(string[] strs)
|
||||||
|
{
|
||||||
|
if (strs.Length != 4 || strs[0] != nameof(EntityTrans))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new EntityTrans(Convert.ToInt32(strs[1]),
|
||||||
|
Convert.ToDouble(strs[2]), Color.FromName(strs[3]));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
225
ProjectElectroTrans/FormTransCollection.Designer.cs
generated
225
ProjectElectroTrans/FormTransCollection.Designer.cs
generated
@ -33,6 +33,12 @@ namespace ProjectElectroTrans
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
groupBoxTools = new GroupBox();
|
groupBoxTools = new GroupBox();
|
||||||
|
panelCompanyTools = new Panel();
|
||||||
|
buttonAddCar = new Button();
|
||||||
|
maskedTextBoxPosition = new MaskedTextBox();
|
||||||
|
buttonRefresh = new Button();
|
||||||
|
buttonRemoveCar = new Button();
|
||||||
|
buttonGoToCheck = new Button();
|
||||||
buttonCreateCompany = new Button();
|
buttonCreateCompany = new Button();
|
||||||
panelStorage = new Panel();
|
panelStorage = new Panel();
|
||||||
buttonCollectionDel = new Button();
|
buttonCollectionDel = new Button();
|
||||||
@ -42,18 +48,19 @@ namespace ProjectElectroTrans
|
|||||||
radioButtonMassive = new RadioButton();
|
radioButtonMassive = new RadioButton();
|
||||||
textBoxCollectionName = new TextBox();
|
textBoxCollectionName = new TextBox();
|
||||||
labelCollectionName = new Label();
|
labelCollectionName = new Label();
|
||||||
buttonRefresh = new Button();
|
|
||||||
buttonGoToCheck = new Button();
|
|
||||||
buttonRemoveTrans = new Button();
|
|
||||||
maskedTextBoxPosition = new MaskedTextBox();
|
|
||||||
buttonAddTrans = new Button();
|
|
||||||
comboBoxSelectorCompany = new ComboBox();
|
comboBoxSelectorCompany = new ComboBox();
|
||||||
pictureBox = new PictureBox();
|
pictureBox = new PictureBox();
|
||||||
panelCompanyTools = new Panel();
|
menuStrip = new MenuStrip();
|
||||||
|
файлToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
saveToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
loadToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
saveFileDialog = new SaveFileDialog();
|
||||||
|
openFileDialog = new OpenFileDialog();
|
||||||
groupBoxTools.SuspendLayout();
|
groupBoxTools.SuspendLayout();
|
||||||
|
panelCompanyTools.SuspendLayout();
|
||||||
panelStorage.SuspendLayout();
|
panelStorage.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||||
panelCompanyTools.SuspendLayout();
|
menuStrip.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
@ -63,13 +70,80 @@ namespace ProjectElectroTrans
|
|||||||
groupBoxTools.Controls.Add(panelStorage);
|
groupBoxTools.Controls.Add(panelStorage);
|
||||||
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
||||||
groupBoxTools.Dock = DockStyle.Right;
|
groupBoxTools.Dock = DockStyle.Right;
|
||||||
groupBoxTools.Location = new Point(783, 0);
|
groupBoxTools.Location = new Point(783, 24);
|
||||||
groupBoxTools.Name = "groupBoxTools";
|
groupBoxTools.Name = "groupBoxTools";
|
||||||
groupBoxTools.Size = new Size(179, 616);
|
groupBoxTools.Size = new Size(179, 608);
|
||||||
groupBoxTools.TabIndex = 0;
|
groupBoxTools.TabIndex = 0;
|
||||||
groupBoxTools.TabStop = false;
|
groupBoxTools.TabStop = false;
|
||||||
groupBoxTools.Text = "Инструменты";
|
groupBoxTools.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
|
// panelCompanyTools
|
||||||
|
//
|
||||||
|
panelCompanyTools.Controls.Add(buttonAddCar);
|
||||||
|
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
|
||||||
|
panelCompanyTools.Controls.Add(buttonRefresh);
|
||||||
|
panelCompanyTools.Controls.Add(buttonRemoveCar);
|
||||||
|
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
||||||
|
panelCompanyTools.Dock = DockStyle.Bottom;
|
||||||
|
panelCompanyTools.Enabled = false;
|
||||||
|
panelCompanyTools.Location = new Point(3, 352);
|
||||||
|
panelCompanyTools.Name = "panelCompanyTools";
|
||||||
|
panelCompanyTools.Size = new Size(173, 253);
|
||||||
|
panelCompanyTools.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// buttonAddCar
|
||||||
|
//
|
||||||
|
buttonAddCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonAddCar.Location = new Point(3, 3);
|
||||||
|
buttonAddCar.Name = "buttonAddCar";
|
||||||
|
buttonAddCar.Size = new Size(167, 40);
|
||||||
|
buttonAddCar.TabIndex = 1;
|
||||||
|
buttonAddCar.Text = "Добавление автомобиля";
|
||||||
|
buttonAddCar.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddCar.Click += ButtonAddTrans_Click;
|
||||||
|
//
|
||||||
|
// maskedTextBoxPosition
|
||||||
|
//
|
||||||
|
maskedTextBoxPosition.Location = new Point(3, 95);
|
||||||
|
maskedTextBoxPosition.Mask = "00";
|
||||||
|
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
|
maskedTextBoxPosition.Size = new Size(167, 23);
|
||||||
|
maskedTextBoxPosition.TabIndex = 3;
|
||||||
|
maskedTextBoxPosition.ValidatingType = typeof(int);
|
||||||
|
//
|
||||||
|
// buttonRefresh
|
||||||
|
//
|
||||||
|
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonRefresh.Location = new Point(3, 210);
|
||||||
|
buttonRefresh.Name = "buttonRefresh";
|
||||||
|
buttonRefresh.Size = new Size(167, 40);
|
||||||
|
buttonRefresh.TabIndex = 6;
|
||||||
|
buttonRefresh.Text = "Обновить";
|
||||||
|
buttonRefresh.UseVisualStyleBackColor = true;
|
||||||
|
buttonRefresh.Click += ButtonRefresh_Click;
|
||||||
|
//
|
||||||
|
// buttonRemoveCar
|
||||||
|
//
|
||||||
|
buttonRemoveCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonRemoveCar.Location = new Point(3, 124);
|
||||||
|
buttonRemoveCar.Name = "buttonRemoveCar";
|
||||||
|
buttonRemoveCar.Size = new Size(167, 40);
|
||||||
|
buttonRemoveCar.TabIndex = 4;
|
||||||
|
buttonRemoveCar.Text = "Удалить автомобиль";
|
||||||
|
buttonRemoveCar.UseVisualStyleBackColor = true;
|
||||||
|
buttonRemoveCar.Click += ButtonRemoveTrans_Click;
|
||||||
|
//
|
||||||
|
// buttonGoToCheck
|
||||||
|
//
|
||||||
|
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonGoToCheck.Location = new Point(3, 170);
|
||||||
|
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||||
|
buttonGoToCheck.Size = new Size(167, 40);
|
||||||
|
buttonGoToCheck.TabIndex = 5;
|
||||||
|
buttonGoToCheck.Text = "Передать на тесты";
|
||||||
|
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||||
|
buttonGoToCheck.Click += ButtonGoToCheck_Click;
|
||||||
|
//
|
||||||
// buttonCreateCompany
|
// buttonCreateCompany
|
||||||
//
|
//
|
||||||
buttonCreateCompany.Location = new Point(6, 320);
|
buttonCreateCompany.Location = new Point(6, 320);
|
||||||
@ -162,58 +236,6 @@ namespace ProjectElectroTrans
|
|||||||
labelCollectionName.TabIndex = 0;
|
labelCollectionName.TabIndex = 0;
|
||||||
labelCollectionName.Text = "Название коллекции:";
|
labelCollectionName.Text = "Название коллекции:";
|
||||||
//
|
//
|
||||||
// buttonRefresh
|
|
||||||
//
|
|
||||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
buttonRefresh.Location = new Point(3, 210);
|
|
||||||
buttonRefresh.Name = "buttonRefresh";
|
|
||||||
buttonRefresh.Size = new Size(167, 40);
|
|
||||||
buttonRefresh.TabIndex = 6;
|
|
||||||
buttonRefresh.Text = "Обновить";
|
|
||||||
buttonRefresh.UseVisualStyleBackColor = true;
|
|
||||||
buttonRefresh.Click += ButtonRefresh_Click;
|
|
||||||
//
|
|
||||||
// buttonGoToCheck
|
|
||||||
//
|
|
||||||
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
buttonGoToCheck.Location = new Point(3, 170);
|
|
||||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
|
||||||
buttonGoToCheck.Size = new Size(167, 40);
|
|
||||||
buttonGoToCheck.TabIndex = 5;
|
|
||||||
buttonGoToCheck.Text = "Передать на тесты";
|
|
||||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
|
||||||
buttonGoToCheck.Click += ButtonGoToCheck_Click;
|
|
||||||
//
|
|
||||||
// buttonRemoveTrans
|
|
||||||
//
|
|
||||||
buttonRemoveTrans.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
buttonRemoveTrans.Location = new Point(3, 124);
|
|
||||||
buttonRemoveTrans.Name = "buttonRemoveTrans";
|
|
||||||
buttonRemoveTrans.Size = new Size(167, 40);
|
|
||||||
buttonRemoveTrans.TabIndex = 4;
|
|
||||||
buttonRemoveTrans.Text = "Удалить поезд";
|
|
||||||
buttonRemoveTrans.UseVisualStyleBackColor = true;
|
|
||||||
buttonRemoveTrans.Click += ButtonRemoveTrans_Click;
|
|
||||||
//
|
|
||||||
// maskedTextBoxPosition
|
|
||||||
//
|
|
||||||
maskedTextBoxPosition.Location = new Point(3, 95);
|
|
||||||
maskedTextBoxPosition.Mask = "00";
|
|
||||||
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
|
||||||
maskedTextBoxPosition.Size = new Size(167, 23);
|
|
||||||
maskedTextBoxPosition.TabIndex = 3;
|
|
||||||
maskedTextBoxPosition.ValidatingType = typeof(int);
|
|
||||||
// buttonAddTrans
|
|
||||||
//
|
|
||||||
buttonAddTrans.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
buttonAddTrans.Location = new Point(3, 3);
|
|
||||||
buttonAddTrans.Name = "buttonAddTrans";
|
|
||||||
buttonAddTrans.Size = new Size(167, 40);
|
|
||||||
buttonAddTrans.TabIndex = 1;
|
|
||||||
buttonAddTrans.Text = "Добавление поезд";
|
|
||||||
buttonAddTrans.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddTrans.Click += ButtonAddTrans_Click;
|
|
||||||
//
|
|
||||||
// comboBoxSelectorCompany
|
// comboBoxSelectorCompany
|
||||||
//
|
//
|
||||||
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
@ -229,50 +251,81 @@ namespace ProjectElectroTrans
|
|||||||
// pictureBox
|
// pictureBox
|
||||||
//
|
//
|
||||||
pictureBox.Dock = DockStyle.Fill;
|
pictureBox.Dock = DockStyle.Fill;
|
||||||
pictureBox.Location = new Point(0, 0);
|
pictureBox.Location = new Point(0, 24);
|
||||||
pictureBox.Name = "pictureBox";
|
pictureBox.Name = "pictureBox";
|
||||||
pictureBox.Size = new Size(783, 616);
|
pictureBox.Size = new Size(783, 608);
|
||||||
pictureBox.TabIndex = 1;
|
pictureBox.TabIndex = 1;
|
||||||
pictureBox.TabStop = false;
|
pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
// panelCompanyTools
|
// menuStrip
|
||||||
//
|
//
|
||||||
panelCompanyTools.Controls.Add(buttonAddTrans);
|
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
|
||||||
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
|
menuStrip.Location = new Point(0, 0);
|
||||||
panelCompanyTools.Controls.Add(buttonRefresh);
|
menuStrip.Name = "menuStrip";
|
||||||
panelCompanyTools.Controls.Add(buttonRemoveTrans);
|
menuStrip.Size = new Size(962, 24);
|
||||||
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
menuStrip.TabIndex = 2;
|
||||||
panelCompanyTools.Dock = DockStyle.Bottom;
|
menuStrip.Text = "menuStrip";
|
||||||
panelCompanyTools.Enabled = false;
|
|
||||||
panelCompanyTools.Location = new Point(3, 360);
|
|
||||||
panelCompanyTools.Name = "panelCompanyTools";
|
|
||||||
panelCompanyTools.Size = new Size(173, 253);
|
|
||||||
panelCompanyTools.TabIndex = 9;
|
|
||||||
//
|
//
|
||||||
// FormTransCollection
|
// файлToolStripMenuItem
|
||||||
|
//
|
||||||
|
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
|
||||||
|
файлToolStripMenuItem.Name = "файлToolStripMenuItem";
|
||||||
|
файлToolStripMenuItem.Size = new Size(48, 20);
|
||||||
|
файлToolStripMenuItem.Text = "Файл";
|
||||||
|
//
|
||||||
|
// saveToolStripMenuItem
|
||||||
|
//
|
||||||
|
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||||
|
saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||||
|
saveToolStripMenuItem.Size = new Size(181, 22);
|
||||||
|
saveToolStripMenuItem.Text = "Сохранение";
|
||||||
|
saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// loadToolStripMenuItem
|
||||||
|
//
|
||||||
|
loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
||||||
|
loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
|
||||||
|
loadToolStripMenuItem.Size = new Size(181, 22);
|
||||||
|
loadToolStripMenuItem.Text = "Загрузка";
|
||||||
|
loadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// saveFileDialog
|
||||||
|
//
|
||||||
|
saveFileDialog.Filter = "txt file | *.txt";
|
||||||
|
//
|
||||||
|
// openFileDialog
|
||||||
|
//
|
||||||
|
openFileDialog.Filter = "txt file | *.txt";
|
||||||
|
//
|
||||||
|
// FormCarCollection
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(962, 616);
|
ClientSize = new Size(962, 632);
|
||||||
Controls.Add(pictureBox);
|
Controls.Add(pictureBox);
|
||||||
Controls.Add(groupBoxTools);
|
Controls.Add(groupBoxTools);
|
||||||
Name = "FormTransCollection";
|
Controls.Add(menuStrip);
|
||||||
Text = "Коллекция поездов";
|
MainMenuStrip = menuStrip;
|
||||||
|
Name = "FormCarCollection";
|
||||||
|
Text = "Коллекция автомобилей";
|
||||||
groupBoxTools.ResumeLayout(false);
|
groupBoxTools.ResumeLayout(false);
|
||||||
|
panelCompanyTools.ResumeLayout(false);
|
||||||
|
panelCompanyTools.PerformLayout();
|
||||||
panelStorage.ResumeLayout(false);
|
panelStorage.ResumeLayout(false);
|
||||||
panelStorage.PerformLayout();
|
panelStorage.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||||
panelCompanyTools.ResumeLayout(false);
|
menuStrip.ResumeLayout(false);
|
||||||
panelCompanyTools.PerformLayout();
|
menuStrip.PerformLayout();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private GroupBox groupBoxTools;
|
private GroupBox groupBoxTools;
|
||||||
private ComboBox comboBoxSelectorCompany;
|
private ComboBox comboBoxSelectorCompany;
|
||||||
private Button buttonAddTrans;
|
private Button buttonAddCar;
|
||||||
private Button buttonRemoveTrans;
|
private Button buttonRemoveCar;
|
||||||
private MaskedTextBox maskedTextBoxPosition;
|
private MaskedTextBox maskedTextBoxPosition;
|
||||||
private PictureBox pictureBox;
|
private PictureBox pictureBox;
|
||||||
private Button buttonGoToCheck;
|
private Button buttonGoToCheck;
|
||||||
@ -287,5 +340,11 @@ namespace ProjectElectroTrans
|
|||||||
private Button buttonCollectionDel;
|
private Button buttonCollectionDel;
|
||||||
private Button buttonCreateCompany;
|
private Button buttonCreateCompany;
|
||||||
private Panel panelCompanyTools;
|
private Panel panelCompanyTools;
|
||||||
|
private MenuStrip menuStrip;
|
||||||
|
private ToolStripMenuItem файлToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem saveToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem loadToolStripMenuItem;
|
||||||
|
private SaveFileDialog saveFileDialog;
|
||||||
|
private OpenFileDialog openFileDialog;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -253,4 +253,49 @@ public partial class FormTransCollection : Form
|
|||||||
panelCompanyTools.Enabled = true;
|
panelCompanyTools.Enabled = true;
|
||||||
RerfreshListBoxItems();
|
RerfreshListBoxItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Обработка нажатия "Сохранение"
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Обработка нажатия "Загрузка"
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user
Записывать в файл можно сразу, без использования StringBuilder