Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5f6dec67ad |
@@ -48,7 +48,7 @@ namespace MotorBoat.CollectionGenericObjects
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_collection = collection;
|
||||
_collection.SetMaxCount = GetMaxCount;
|
||||
_collection.MaxCount = GetMaxCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
/// <summary>
|
||||
/// Установка максимального количества элементов
|
||||
/// </summary>
|
||||
int SetMaxCount { set; }
|
||||
int MaxCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Добавление объекта в коллекцию
|
||||
@@ -45,5 +45,16 @@
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns>Объект</returns>
|
||||
T? Get(int position);
|
||||
|
||||
/// <summary>
|
||||
/// Получение типа коллекции
|
||||
/// </summary>
|
||||
CollectionType GetCollectionType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Получение объектов коллекции по одному
|
||||
/// </summary>
|
||||
/// <returns>Поэлементый вывод элементов коллекции</returns>
|
||||
IEnumerable<T?> GetItems();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,19 @@
|
||||
|
||||
public int Count => _collection.Count;
|
||||
|
||||
public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
|
||||
public int MaxCount
|
||||
{
|
||||
get => _maxCount;
|
||||
set
|
||||
{
|
||||
if (value > 0)
|
||||
{
|
||||
_maxCount = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CollectionType GetCollectionType => CollectionType.List;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
@@ -29,10 +41,6 @@
|
||||
_collection = new();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//---------------TODO ПРОВЕРКА ПО ПОЗИЦИИ----------------------------//
|
||||
//---------------TODO НЕ ВЫХОДИТ ЛИ ЗА ГРАНИЦЫ СПИСКА---------------//
|
||||
/// /////////////////////////////////////////////////////////////////
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public T? Get(int position)
|
||||
@@ -44,10 +52,6 @@
|
||||
return _collection[position];
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//---------------TODO ПРОВЕРКА ВСТАВКИ----------------------//
|
||||
//---------------TODO ВСТАВКА В КОНЕЦ НАБОРА---------------//
|
||||
////////////////////////////////////////////////////////////
|
||||
public bool Insert(T obj)
|
||||
{
|
||||
if (Count == _maxCount)
|
||||
@@ -58,12 +62,6 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//---------------TODO ПРОВЕРКА ВСТАВКИ--------------------------------------------------------//
|
||||
//---------------TODO ОТСУТСТВИЕ ПРЕВЫШЕНИЯ МАКСИМАЛЬНОГО КОЛИЧЕСТВА ЭЛЕМЕНТОВ---------------//
|
||||
//---------------TODO ПРОВЕРКА ПОЗИЦИИ------------------------------------------------------//
|
||||
//---------------TODO ВСТАВКА ПО ПОЗИЦИИ---------------------------------------------------//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
public bool Insert(T obj, int position)
|
||||
{
|
||||
if (position < 0 || position >= _maxCount || Count == _maxCount)
|
||||
@@ -74,10 +72,6 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
//---------------TODO ПРОВЕРКА ПОЗИЦИИ--------------------------//
|
||||
//---------------TODO УДАЛЕНИЕ ОБЪЕКТА ИЗ СПИСКА---------------//
|
||||
////////////////////////////////////////////////////////////////
|
||||
public bool Remove(int position)
|
||||
{
|
||||
if (_collection.Count == 0 || position < 0 || position >= _collection.Count)
|
||||
@@ -87,5 +81,16 @@
|
||||
_collection.RemoveAt(position);
|
||||
return true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//---------------Lab06 - Получение элементов коллекции по одному--------------------------//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
public IEnumerable<T?> GetItems()
|
||||
{
|
||||
for (int i = 0; i < _collection.Count; ++i)
|
||||
{
|
||||
yield return _collection[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
namespace MotorBoat.CollectionGenericObjects
|
||||
|
||||
namespace MotorBoat.CollectionGenericObjects
|
||||
{
|
||||
/// <summary>
|
||||
/// Параметризованный набор объектов
|
||||
@@ -14,8 +15,12 @@
|
||||
|
||||
public int Count => _collection.Length;
|
||||
|
||||
public int SetMaxCount
|
||||
public int MaxCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return _collection.Length;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > 0)
|
||||
@@ -32,6 +37,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
public CollectionType GetCollectionType => CollectionType.Massive;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
@@ -100,5 +107,13 @@
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public IEnumerable<T?> GetItems()
|
||||
{
|
||||
for (int i = 0; i < _collection.Length; ++i)
|
||||
{
|
||||
yield return _collection[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
namespace MotorBoat.CollectionGenericObjects
|
||||
using MotorBoat.Drawnings;
|
||||
using System.Text;
|
||||
|
||||
namespace MotorBoat.CollectionGenericObjects
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-хранилище коллекций
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class StorageCollection<T>
|
||||
where T : class
|
||||
where T : DrawningBoat
|
||||
{
|
||||
/// <summary>
|
||||
/// Словарь (хранилище) с коллекциями
|
||||
@@ -17,6 +20,21 @@
|
||||
/// </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>
|
||||
@@ -25,11 +43,6 @@
|
||||
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//---------------TODO ПРОВЕРКА ЧТО NAME НЕ ПУСТОЙ - ОТСУТСТВУЕТ ЗАПИСЬ В СЛОВАРЕ С ТАКИМ КЛЮЧОМ---------------//
|
||||
//---------------TODO ЛОГИКА ДЛЯ ДОБАВЛЕНИЯ ЗАВИСИМОСТИ ОТ collectionType СОЗДАЕМ ОБЪЕКТ ЛИБО----------------//
|
||||
//---------------TODO В MassiveGenericObjects ЛИБО в ListGenericObjects-------------------------------------//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Добавление коллекции в хранилище
|
||||
/// </summary>
|
||||
@@ -54,9 +67,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
//---------------TODO УДАЛЕНИЕ КОЛЛЕКЦИИ С ПРОВЕРКОЙ НАЛИЧИЯ КЛЮЧА---------------//
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Удаление коллекции
|
||||
/// </summary>
|
||||
@@ -70,9 +80,6 @@
|
||||
_storages.Remove(name);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//---------------TODO ЛОГИКА ПОЛУЧЕНИЯ ОБЪЕКТА---------------//
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Доступ к коллекции
|
||||
/// </summary>
|
||||
@@ -85,6 +92,147 @@
|
||||
return _storages.GetValueOrDefault(name, 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);
|
||||
}
|
||||
|
||||
StringBuilder sb = new();
|
||||
|
||||
sb.Append(_collectionKey);
|
||||
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
using FileStream fs = new(filename, FileMode.Create);
|
||||
byte[] info = new UTF8Encoding(true).GetBytes(sb.ToString());
|
||||
fs.Write(info, 0, info.Length);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Загрузка информации по автомобилям в хранилище из файла
|
||||
/// </summary>
|
||||
/// <param name="filename">Путь и имя файла</param>
|
||||
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
||||
public bool LoadData(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
string bufferTextFromFile = "";
|
||||
using (FileStream fs = new(filename, FileMode.Open))
|
||||
{
|
||||
byte[] b = new byte[fs.Length];
|
||||
UTF8Encoding temp = new(true);
|
||||
while (fs.Read(b, 0, b.Length) > 0)
|
||||
{
|
||||
bufferTextFromFile += temp.GetString(b);
|
||||
}
|
||||
}
|
||||
|
||||
string[] strs = bufferTextFromFile.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (strs == null || strs.Length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!strs[0].Equals(_collectionKey))
|
||||
{
|
||||
//если нет такой записи, то это не те данные
|
||||
return false;
|
||||
}
|
||||
|
||||
_storages.Clear();
|
||||
foreach (string data in strs)
|
||||
{
|
||||
string[] record = data.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?.CreateDrawningBoat() is T car)
|
||||
{
|
||||
if (!collection.Insert(car))
|
||||
{
|
||||
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,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,14 @@ namespace MotorBoat.Drawnings
|
||||
_drawningMotorBoatHeight = drawningMotorBoatHeight;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
//---------------Lab06 - Конструктор---------------//
|
||||
////////////////////////////////////////////////////
|
||||
public DrawningBoat(EntityBoat? entityBoat)
|
||||
{
|
||||
EntityBoat = entityBoat;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Установка границ поля
|
||||
/// </summary>
|
||||
|
||||
@@ -19,6 +19,13 @@ namespace MotorBoat.Drawnings
|
||||
EntityBoat = new EntityMotorBoat(speed, weight, bodyColor, additionalColor, addTwoMotors, sofa, sportLines);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
//---------------Lab06 - Конструктор---------------//
|
||||
////////////////////////////////////////////////////
|
||||
public DrawningMotorBoat(EntityMotorBoat? entityMotorBoat) : base(entityMotorBoat)
|
||||
{
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityBoat == null || EntityBoat is not EntityMotorBoat motorBoat || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
@@ -43,7 +50,6 @@ namespace MotorBoat.Drawnings
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 20, _startPosY.Value + 10, 5, 10);
|
||||
g.FillEllipse(additionalBrush, _startPosX.Value + 10, _startPosY.Value + 40, 10, 10);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 20, _startPosY.Value + 40, 5, 10);
|
||||
|
||||
}
|
||||
|
||||
// добавляем две полоски
|
||||
|
||||
79
MotorBoat/MotorBoat/Drawnings/ExtentionDrawningBoat.cs
Normal file
79
MotorBoat/MotorBoat/Drawnings/ExtentionDrawningBoat.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using MotorBoat.Entities;
|
||||
|
||||
namespace MotorBoat.Drawnings
|
||||
{
|
||||
/// <summary>
|
||||
/// Расширение для класса EntityCar
|
||||
/// </summary>
|
||||
public static class ExtentionDrawningCar
|
||||
{
|
||||
/// <summary>
|
||||
/// Разделитель для записи информации по объекту в файл
|
||||
/// </summary>
|
||||
private static readonly string _separatorForObject = ":";
|
||||
|
||||
/// <summary>
|
||||
/// Создание объекта из строки
|
||||
/// </summary>
|
||||
/// <param name="info">Строка с данными для создания объекта</param>
|
||||
/// <returns>Объект</returns>
|
||||
//public static DrawningBoat? CreateDrawningBoat(this string info)
|
||||
//{
|
||||
// string[] strs = info.Split(_separatorForObject);
|
||||
// EntityBoat? boat = EntityMotorBoat.CreateEntityMotorBoat(strs);
|
||||
// if (boat != null)
|
||||
// {
|
||||
// return new DrawningMotorBoat(boat);
|
||||
// }
|
||||
|
||||
// boat = EntityBoat.CreateEntityBoat(strs);
|
||||
// if (boat != null)
|
||||
// {
|
||||
// return new DrawningBoat(boat);
|
||||
// }
|
||||
|
||||
// return null;
|
||||
//}
|
||||
|
||||
public static DrawningBoat? CreateDrawningBoat(this string info)
|
||||
{
|
||||
string[] strs = info.Split(_separatorForObject);
|
||||
EntityBoat? boat = EntityMotorBoat.CreateEntityMotorBoat(strs);
|
||||
|
||||
DrawningBoat? drawnBoat = null;
|
||||
|
||||
if (boat != null)
|
||||
{
|
||||
EntityMotorBoat? motorBoat = (EntityMotorBoat?)boat;
|
||||
drawnBoat = new DrawningMotorBoat(motorBoat);
|
||||
}
|
||||
else
|
||||
{
|
||||
boat = EntityBoat.CreateEntityBoat(strs);
|
||||
if (boat != null)
|
||||
{
|
||||
drawnBoat = new DrawningBoat(boat);
|
||||
}
|
||||
}
|
||||
|
||||
return drawnBoat;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение данных для сохранения в файл
|
||||
/// </summary>
|
||||
/// <param name="drawningBoat">Сохраняемый объект</param>
|
||||
/// <returns>Строка с данными по объекту</returns>
|
||||
public static string GetDataForSave(this DrawningBoat drawningBoat)
|
||||
{
|
||||
string[]? array = drawningBoat?.EntityBoat?.GetStringRepresentation();
|
||||
|
||||
if (array == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return string.Join(_separatorForObject, array);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,10 +38,6 @@
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
//---------------Новый основной цвет---------------//
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
/// <summary>
|
||||
/// Новый основной цвет
|
||||
/// </summary>
|
||||
@@ -53,6 +49,30 @@
|
||||
//{
|
||||
// BodyColor = color != null ? color : Color.White;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Получение строк со значениями свойств объекта класса-сущности
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual string[] GetStringRepresentation()
|
||||
{
|
||||
return new[] { nameof(EntityBoat), Speed.ToString(), Weight.ToString(), BodyColor.Name };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создание объекта из массива строк
|
||||
/// </summary>
|
||||
/// <param name="strs"></param>
|
||||
/// <returns></returns>
|
||||
public static EntityBoat? CreateEntityBoat(string[] strs)
|
||||
{
|
||||
if (strs.Length != 4 || strs[0] != nameof(EntityBoat))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new EntityBoat(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,10 +48,6 @@
|
||||
SportLines = sportLines;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
//---------------Новый дополнительныйй цвет---------------//
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
/// <summary>
|
||||
/// Новый дополнительный цвет
|
||||
/// </summary>
|
||||
@@ -63,5 +59,38 @@
|
||||
//{
|
||||
// AdditionalColor = color != null ? color : Color.White;
|
||||
//}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//---------------Lab06 - Получение строк со значениями свойств объекта класса-сущности---------------//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Получение строк со значениями свойств объекта класса-сущности
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string[] GetStringRepresentation()
|
||||
{
|
||||
//return new[] { nameof(EntityBoat), Speed.ToString(), Weight.ToString(), BodyColor.Name };
|
||||
|
||||
return new[] { nameof(EntityMotorBoat), Speed.ToString(), Weight.ToString(), BodyColor.Name, AdditionalColor.Name,
|
||||
AddTwoMotors.ToString(), Sofa.ToString(), SportLines.ToString() };
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//---------------Lab06 - Создание объекта из массива строк---------------//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Создание объекта из массива строк
|
||||
/// </summary>
|
||||
/// <param name="strs"></param>
|
||||
/// <returns></returns>
|
||||
public static EntityMotorBoat? CreateEntityMotorBoat(string[] strs)
|
||||
{
|
||||
if (strs.Length != 8 || strs[0] != nameof(EntityMotorBoat))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new EntityMotorBoat(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]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
71
MotorBoat/MotorBoat/FormBoatCollection.Designer.cs
generated
71
MotorBoat/MotorBoat/FormBoatCollection.Designer.cs
generated
@@ -46,10 +46,17 @@
|
||||
labelCollectionName = new Label();
|
||||
comboBoxSelectorCompany = new ComboBox();
|
||||
pictureBox = new PictureBox();
|
||||
menuStrip = new MenuStrip();
|
||||
файл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 +66,9 @@
|
||||
groupBoxTools.Controls.Add(panelStorage);
|
||||
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
||||
groupBoxTools.Dock = DockStyle.Right;
|
||||
groupBoxTools.Location = new Point(884, 0);
|
||||
groupBoxTools.Location = new Point(902, 24);
|
||||
groupBoxTools.Name = "groupBoxTools";
|
||||
groupBoxTools.Size = new Size(200, 561);
|
||||
groupBoxTools.Size = new Size(200, 511);
|
||||
groupBoxTools.TabIndex = 0;
|
||||
groupBoxTools.TabStop = false;
|
||||
groupBoxTools.Text = "Инструменты";
|
||||
@@ -74,7 +81,7 @@
|
||||
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
||||
panelCompanyTools.Controls.Add(buttonRemoveBoat);
|
||||
panelCompanyTools.Dock = DockStyle.Bottom;
|
||||
panelCompanyTools.Location = new Point(3, 384);
|
||||
panelCompanyTools.Location = new Point(3, 334);
|
||||
panelCompanyTools.Name = "panelCompanyTools";
|
||||
panelCompanyTools.Size = new Size(194, 174);
|
||||
panelCompanyTools.TabIndex = 9;
|
||||
@@ -239,21 +246,62 @@
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
pictureBox.Dock = DockStyle.Fill;
|
||||
pictureBox.Enabled = false;
|
||||
pictureBox.Location = new Point(0, 0);
|
||||
pictureBox.Location = new Point(0, 24);
|
||||
pictureBox.Name = "pictureBox";
|
||||
pictureBox.Size = new Size(884, 561);
|
||||
pictureBox.Size = new Size(884, 537);
|
||||
pictureBox.TabIndex = 1;
|
||||
pictureBox.TabStop = false;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(1102, 24);
|
||||
menuStrip.TabIndex = 0;
|
||||
menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// файл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";
|
||||
//
|
||||
// FormBoatCollection
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1084, 561);
|
||||
ClientSize = new Size(1102, 535);
|
||||
Controls.Add(pictureBox);
|
||||
Controls.Add(groupBoxTools);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Name = "FormBoatCollection";
|
||||
Text = "Коллекция лодок";
|
||||
groupBoxTools.ResumeLayout(false);
|
||||
@@ -262,7 +310,10 @@
|
||||
panelStorage.ResumeLayout(false);
|
||||
panelStorage.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -285,5 +336,11 @@
|
||||
private ListBox listBoxCollection;
|
||||
private Button buttonCollectionAdd;
|
||||
private Panel panelCompanyTools;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem файлToolStripMenuItem;
|
||||
private ToolStripMenuItem saveToolStripMenuItem;
|
||||
private ToolStripMenuItem loadToolStripMenuItem;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private OpenFileDialog openFileDialog;
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ namespace MotorBoat
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//---------------передать метод в FormBoatConfig---------------//
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
form.AddEvent(SetBoat);
|
||||
|
||||
form.Show();
|
||||
@@ -218,7 +218,6 @@ namespace MotorBoat
|
||||
listBoxCollection.Items.Add(colName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -251,5 +250,42 @@ namespace MotorBoat
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//---------------Lab06 - Логика загрузки---------------//
|
||||
////////////////////////////////////////////////////////
|
||||
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);
|
||||
}
|
||||
}
|
||||
RerfreshListBoxItems();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,4 +117,16 @@
|
||||
<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>127, 17</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>261, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>105</value>
|
||||
</metadata>
|
||||
</root>
|
||||
Reference in New Issue
Block a user