лаба 6
This commit is contained in:
parent
fd828b12d0
commit
d65e45ef34
@ -51,7 +51,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>
|
||||||
|
@ -21,7 +21,7 @@ public interface ICollectionGenericObjects<T>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка максимального количества элементов
|
/// Установка максимального количества элементов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int SetMaxCount { set; }
|
int MaxCount { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в коллекцию
|
/// Добавление объекта в коллекцию
|
||||||
@ -51,4 +51,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();
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,6 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
|
|
||||||
public int Count => _collection.Count;
|
public int Count => _collection.Count;
|
||||||
|
|
||||||
public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -31,6 +29,24 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
_collection = new();
|
_collection = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CollectionType GetCollectionType => CollectionType.List;
|
||||||
|
|
||||||
|
public int MaxCount
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _maxCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value > 0)
|
||||||
|
{
|
||||||
|
_maxCount = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public T? Get(int position)
|
public T? Get(int position)
|
||||||
{
|
{
|
||||||
if (position >= Count || position < 0)
|
if (position >= Count || position < 0)
|
||||||
@ -66,4 +82,12 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
_collection.RemoveAt(position);
|
_collection.RemoveAt(position);
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<T?> GetItems()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _collection.Count; ++i)
|
||||||
|
{
|
||||||
|
yield return _collection[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,13 @@ 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)
|
||||||
@ -34,6 +39,8 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CollectionType GetCollectionType => CollectionType.Massive;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -112,4 +119,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,4 +1,5 @@
|
|||||||
using System;
|
using ProjectGasolineTanker.Drawings;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -7,7 +8,7 @@ using System.Threading.Tasks;
|
|||||||
namespace ProjectGasolineTanker.CollectionGenericObjects;
|
namespace ProjectGasolineTanker.CollectionGenericObjects;
|
||||||
|
|
||||||
public class StorageCollection<T>
|
public class StorageCollection<T>
|
||||||
where T : class
|
where T : DrawingTanker
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Словарь (хранилище) с коллекциями
|
/// Словарь (хранилище) с коллекциями
|
||||||
@ -19,6 +20,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>
|
||||||
@ -75,4 +91,110 @@ public class StorageCollection<T>
|
|||||||
return _storages[name];
|
return _storages[name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool SaveData(string filename)
|
||||||
|
{
|
||||||
|
if (_storages.Count == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (File.Exists(filename))
|
||||||
|
File.Delete(filename);
|
||||||
|
|
||||||
|
using FileStream fs = new(filename, FileMode.Create);
|
||||||
|
using StreamWriter sw = new StreamWriter(fs);
|
||||||
|
sw.Write(_collectionKey);
|
||||||
|
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages)
|
||||||
|
{
|
||||||
|
sw.Write(Environment.NewLine);
|
||||||
|
if (value.Value.Count == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
sw.Write(value.Key);
|
||||||
|
sw.Write(_separatorForKeyValue);
|
||||||
|
sw.Write(value.Value.GetCollectionType);
|
||||||
|
sw.Write(_separatorForKeyValue);
|
||||||
|
sw.Write(value.Value.MaxCount);
|
||||||
|
sw.Write(_separatorForKeyValue);
|
||||||
|
|
||||||
|
foreach (T? item in value.Value.GetItems())
|
||||||
|
{
|
||||||
|
string data = item?.GetDataForSave() ?? string.Empty;
|
||||||
|
if (string.IsNullOrEmpty(data))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
sw.Write(data);
|
||||||
|
sw.Write(_separatorItems);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool LoadData(string filename)
|
||||||
|
{
|
||||||
|
if (!File.Exists(filename))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (FileStream fs = new(filename, FileMode.Open))
|
||||||
|
{
|
||||||
|
using StreamReader sr = new StreamReader(fs);
|
||||||
|
|
||||||
|
string str = sr.ReadLine();
|
||||||
|
if (str == null || str.Length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!str.Equals(_collectionKey))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_storages.Clear();
|
||||||
|
|
||||||
|
while (!sr.EndOfStream)
|
||||||
|
{
|
||||||
|
string[] record = sr.ReadLine().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?.CreateDrawingTanker() is T airplane)
|
||||||
|
{
|
||||||
|
if (collection.Insert(airplane) == -1)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_storages.Add(record[0], collection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ICollectionGenericObjects<T>? CreateCollection(CollectionType collectionType)
|
||||||
|
{
|
||||||
|
return collectionType switch
|
||||||
|
{
|
||||||
|
CollectionType.Massive => new MassiveGenericObjects<T>(),
|
||||||
|
CollectionType.List => new ListGenericObjects<T>(),
|
||||||
|
_ => null,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,12 @@ public class DrawingGasolineTanker : DrawingTanker
|
|||||||
EntityTanker = new EntityGasolineTanker(speed, weight, bodyColor, additionalColor, tank, ornamentWheels);
|
EntityTanker = new EntityGasolineTanker(speed, weight, bodyColor, additionalColor, tank, ornamentWheels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DrawingGasolineTanker(EntityTanker? tanker) : base(tanker)
|
||||||
|
{
|
||||||
|
if (tanker != null)
|
||||||
|
EntityTanker = tanker;
|
||||||
|
}
|
||||||
|
|
||||||
public override void DrawTransport(Graphics g)
|
public override void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
if (EntityTanker == null || EntityTanker is not EntityGasolineTanker tanker || !_startPosX.HasValue || !_startPosY.HasValue)
|
if (EntityTanker == null || EntityTanker is not EntityGasolineTanker tanker || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||||
|
@ -85,6 +85,10 @@ public class DrawingTanker
|
|||||||
EntityTanker = new EntityTanker(speed, weight, bodyColor);
|
EntityTanker = new EntityTanker(speed, weight, bodyColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DrawingTanker(EntityTanker? tanker) : this()
|
||||||
|
{
|
||||||
|
EntityTanker = tanker;
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор для наследников
|
/// Конструктор для наследников
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ProjectGasolineTanker.Entities;
|
||||||
|
|
||||||
|
namespace ProjectGasolineTanker.Drawings;
|
||||||
|
|
||||||
|
public static class ExtentionDrawingTanker
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Разделитель для записи информации по объекту в файл
|
||||||
|
/// </summary>
|
||||||
|
private static readonly string _separatorForObject = ":";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создание объекта из строки
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">Строка с данными для создания объекта</param>
|
||||||
|
/// <returns>Объект</returns>
|
||||||
|
public static DrawingTanker? CreateDrawingTanker(this string info)
|
||||||
|
{
|
||||||
|
string[] strs = info.Split(_separatorForObject);
|
||||||
|
EntityTanker? tanker = EntityGasolineTanker.CreateEntityGasolineTanker(strs);
|
||||||
|
|
||||||
|
if (tanker != null)
|
||||||
|
{
|
||||||
|
return new DrawingGasolineTanker(tanker);
|
||||||
|
}
|
||||||
|
|
||||||
|
tanker = EntityTanker.CreateEntityTanker(strs);
|
||||||
|
|
||||||
|
if (tanker != null)
|
||||||
|
{
|
||||||
|
return new DrawingTanker(tanker);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetDataForSave(this DrawingTanker drawingTanker)
|
||||||
|
{
|
||||||
|
string[]? array = drawingTanker?.EntityTanker?.GetStringRepresentation();
|
||||||
|
|
||||||
|
if (array == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Join(_separatorForObject, array);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||||
|
|
||||||
namespace ProjectGasolineTanker.Entities
|
namespace ProjectGasolineTanker.Entities
|
||||||
{
|
{
|
||||||
@ -26,20 +27,24 @@ namespace ProjectGasolineTanker.Entities
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool OrnamentWheels { get; private set; }
|
public bool OrnamentWheels { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
public override string[] GetStringRepresentation()
|
||||||
/// Инициализация полей объекта-класса газовоза
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес газовоза</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
|
||||||
/// <param name="tank">Признак наличия цистерны</param>
|
|
||||||
/// <param name="ornamentWheels">Признак наличия украшенных колес</param>
|
|
||||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool tank, bool ornamentWheels)
|
|
||||||
{
|
{
|
||||||
AdditionalColor = additionalColor;
|
return new[] { nameof(EntityGasolineTanker), Speed.ToString(), Weight.ToString(), BodyColor.Name, AdditionalColor.Name, Tank.ToString(), OrnamentWheels.ToString() };
|
||||||
Tank = tank;
|
}
|
||||||
OrnamentWheels = ornamentWheels;
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создание объекта из массива строк
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strs"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static EntityGasolineTanker? CreateEntityGasolineTanker(string[] strs)
|
||||||
|
{
|
||||||
|
if (strs.Length != 7 || strs[0] != nameof(EntityGasolineTanker))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new EntityGasolineTanker(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]),
|
||||||
|
Color.FromName(strs[3]), Color.FromName(strs[4]),
|
||||||
|
Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAdditionalColor(Color additionalColor)
|
public void SetAdditionalColor(Color additionalColor)
|
||||||
|
@ -49,5 +49,18 @@ public class EntityTanker
|
|||||||
{
|
{
|
||||||
BodyColor = bodyColor;
|
BodyColor = bodyColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual string[] GetStringRepresentation()
|
||||||
|
{
|
||||||
|
return new[] { nameof(EntityTanker), Speed.ToString(), Weight.ToString(), BodyColor.Name };
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EntityTanker? CreateEntityTanker(string[] strs)
|
||||||
|
{
|
||||||
|
if (strs.Length != 4 || strs[0] != nameof(EntityTanker))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new EntityTanker(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,10 +46,17 @@
|
|||||||
labelCollectionName = new Label();
|
labelCollectionName = new Label();
|
||||||
comboBoxSelectorCompany = new ComboBox();
|
comboBoxSelectorCompany = new ComboBox();
|
||||||
pictureBox = new PictureBox();
|
pictureBox = new PictureBox();
|
||||||
|
menuStrip = new MenuStrip();
|
||||||
|
файлToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
saveToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
loadToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
saveFileDialog = new SaveFileDialog();
|
||||||
|
openFileDialog = new OpenFileDialog();
|
||||||
groupBoxTools.SuspendLayout();
|
groupBoxTools.SuspendLayout();
|
||||||
panelCompanyTools.SuspendLayout();
|
panelCompanyTools.SuspendLayout();
|
||||||
panelStorage.SuspendLayout();
|
panelStorage.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||||
|
menuStrip.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
@ -59,9 +66,9 @@
|
|||||||
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(1222, 0);
|
groupBoxTools.Location = new Point(1222, 33);
|
||||||
groupBoxTools.Name = "groupBoxTools";
|
groupBoxTools.Name = "groupBoxTools";
|
||||||
groupBoxTools.Size = new Size(258, 810);
|
groupBoxTools.Size = new Size(258, 784);
|
||||||
groupBoxTools.TabIndex = 0;
|
groupBoxTools.TabIndex = 0;
|
||||||
groupBoxTools.TabStop = false;
|
groupBoxTools.TabStop = false;
|
||||||
groupBoxTools.Text = "Инструменты";
|
groupBoxTools.Text = "Инструменты";
|
||||||
@ -75,9 +82,9 @@
|
|||||||
panelCompanyTools.Controls.Add(buttonDelTanker);
|
panelCompanyTools.Controls.Add(buttonDelTanker);
|
||||||
panelCompanyTools.Dock = DockStyle.Bottom;
|
panelCompanyTools.Dock = DockStyle.Bottom;
|
||||||
panelCompanyTools.Enabled = false;
|
panelCompanyTools.Enabled = false;
|
||||||
panelCompanyTools.Location = new Point(3, 456);
|
panelCompanyTools.Location = new Point(3, 463);
|
||||||
panelCompanyTools.Name = "panelCompanyTools";
|
panelCompanyTools.Name = "panelCompanyTools";
|
||||||
panelCompanyTools.Size = new Size(252, 351);
|
panelCompanyTools.Size = new Size(252, 318);
|
||||||
panelCompanyTools.TabIndex = 2;
|
panelCompanyTools.TabIndex = 2;
|
||||||
//
|
//
|
||||||
// buttonAddTanker
|
// buttonAddTanker
|
||||||
@ -94,7 +101,7 @@
|
|||||||
// buttonRefresh
|
// buttonRefresh
|
||||||
//
|
//
|
||||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonRefresh.Location = new Point(13, 268);
|
buttonRefresh.Location = new Point(13, 237);
|
||||||
buttonRefresh.Name = "buttonRefresh";
|
buttonRefresh.Name = "buttonRefresh";
|
||||||
buttonRefresh.Size = new Size(226, 55);
|
buttonRefresh.Size = new Size(226, 55);
|
||||||
buttonRefresh.TabIndex = 6;
|
buttonRefresh.TabIndex = 6;
|
||||||
@ -104,7 +111,7 @@
|
|||||||
//
|
//
|
||||||
// maskedTextBox1
|
// maskedTextBox1
|
||||||
//
|
//
|
||||||
maskedTextBox1.Location = new Point(13, 109);
|
maskedTextBox1.Location = new Point(13, 78);
|
||||||
maskedTextBox1.Mask = "00";
|
maskedTextBox1.Mask = "00";
|
||||||
maskedTextBox1.Name = "maskedTextBox1";
|
maskedTextBox1.Name = "maskedTextBox1";
|
||||||
maskedTextBox1.Size = new Size(230, 31);
|
maskedTextBox1.Size = new Size(230, 31);
|
||||||
@ -114,7 +121,7 @@
|
|||||||
// buttonGoToCheck
|
// buttonGoToCheck
|
||||||
//
|
//
|
||||||
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonGoToCheck.Location = new Point(13, 207);
|
buttonGoToCheck.Location = new Point(13, 176);
|
||||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||||
buttonGoToCheck.Size = new Size(230, 55);
|
buttonGoToCheck.Size = new Size(230, 55);
|
||||||
buttonGoToCheck.TabIndex = 5;
|
buttonGoToCheck.TabIndex = 5;
|
||||||
@ -125,7 +132,7 @@
|
|||||||
// buttonDelTanker
|
// buttonDelTanker
|
||||||
//
|
//
|
||||||
buttonDelTanker.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonDelTanker.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonDelTanker.Location = new Point(13, 146);
|
buttonDelTanker.Location = new Point(13, 115);
|
||||||
buttonDelTanker.Name = "buttonDelTanker";
|
buttonDelTanker.Name = "buttonDelTanker";
|
||||||
buttonDelTanker.Size = new Size(230, 55);
|
buttonDelTanker.Size = new Size(230, 55);
|
||||||
buttonDelTanker.TabIndex = 4;
|
buttonDelTanker.TabIndex = 4;
|
||||||
@ -240,19 +247,62 @@
|
|||||||
// pictureBox
|
// pictureBox
|
||||||
//
|
//
|
||||||
pictureBox.Dock = DockStyle.Fill;
|
pictureBox.Dock = DockStyle.Fill;
|
||||||
pictureBox.Location = new Point(0, 0);
|
pictureBox.Location = new Point(0, 33);
|
||||||
pictureBox.Name = "pictureBox";
|
pictureBox.Name = "pictureBox";
|
||||||
pictureBox.Size = new Size(1222, 810);
|
pictureBox.Size = new Size(1222, 784);
|
||||||
pictureBox.TabIndex = 1;
|
pictureBox.TabIndex = 1;
|
||||||
pictureBox.TabStop = false;
|
pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
|
// menuStrip
|
||||||
|
//
|
||||||
|
menuStrip.ImageScalingSize = new Size(24, 24);
|
||||||
|
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
|
||||||
|
menuStrip.Location = new Point(0, 0);
|
||||||
|
menuStrip.Name = "menuStrip";
|
||||||
|
menuStrip.Size = new Size(1480, 33);
|
||||||
|
menuStrip.TabIndex = 2;
|
||||||
|
menuStrip.Text = "menuStrip";
|
||||||
|
//
|
||||||
|
// файлToolStripMenuItem
|
||||||
|
//
|
||||||
|
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
|
||||||
|
файлToolStripMenuItem.Name = "файлToolStripMenuItem";
|
||||||
|
файлToolStripMenuItem.Size = new Size(69, 29);
|
||||||
|
файлToolStripMenuItem.Text = "Файл";
|
||||||
|
//
|
||||||
|
// saveToolStripMenuItem
|
||||||
|
//
|
||||||
|
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||||
|
saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||||
|
saveToolStripMenuItem.Size = new Size(273, 34);
|
||||||
|
saveToolStripMenuItem.Text = "Сохранение";
|
||||||
|
saveToolStripMenuItem.Click += saveToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// loadToolStripMenuItem
|
||||||
|
//
|
||||||
|
loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
||||||
|
loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
|
||||||
|
loadToolStripMenuItem.Size = new Size(273, 34);
|
||||||
|
loadToolStripMenuItem.Text = "Загрузка";
|
||||||
|
loadToolStripMenuItem.Click += loadToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// saveFileDialog
|
||||||
|
//
|
||||||
|
saveFileDialog.Filter = "txt file | *.txt";
|
||||||
|
//
|
||||||
|
// openFileDialog
|
||||||
|
//
|
||||||
|
openFileDialog.Filter = "txt file | *.txt";
|
||||||
|
//
|
||||||
// FormTankerCollection
|
// FormTankerCollection
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(1480, 810);
|
ClientSize = new Size(1480, 817);
|
||||||
Controls.Add(pictureBox);
|
Controls.Add(pictureBox);
|
||||||
Controls.Add(groupBoxTools);
|
Controls.Add(groupBoxTools);
|
||||||
|
Controls.Add(menuStrip);
|
||||||
|
MainMenuStrip = menuStrip;
|
||||||
Name = "FormTankerCollection";
|
Name = "FormTankerCollection";
|
||||||
Text = "Коллекция Грузовиков";
|
Text = "Коллекция Грузовиков";
|
||||||
groupBoxTools.ResumeLayout(false);
|
groupBoxTools.ResumeLayout(false);
|
||||||
@ -261,7 +311,10 @@
|
|||||||
panelStorage.ResumeLayout(false);
|
panelStorage.ResumeLayout(false);
|
||||||
panelStorage.PerformLayout();
|
panelStorage.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||||
|
menuStrip.ResumeLayout(false);
|
||||||
|
menuStrip.PerformLayout();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -284,5 +337,11 @@
|
|||||||
private Button buttonCollectionDel;
|
private Button buttonCollectionDel;
|
||||||
private ListBox listBoxCollection;
|
private ListBox listBoxCollection;
|
||||||
private Panel panelCompanyTools;
|
private Panel panelCompanyTools;
|
||||||
|
private MenuStrip menuStrip;
|
||||||
|
private ToolStripMenuItem файлToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem saveToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem loadToolStripMenuItem;
|
||||||
|
private SaveFileDialog saveFileDialog;
|
||||||
|
private OpenFileDialog openFileDialog;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -216,4 +216,35 @@ public partial class FormTankerCollection : Form
|
|||||||
panelCompanyTools.Enabled = true;
|
panelCompanyTools.Enabled = true;
|
||||||
RefreshListBoxItems();
|
RefreshListBoxItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (_storageCollection.SaveData(saveFileDialog.FileName))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не сохранилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (_storageCollection.LoadData(openFileDialog.FileName))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
RefreshListBoxItems();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не сохранилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,4 +117,16 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</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>
|
||||||
|
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>57</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
Loading…
Reference in New Issue
Block a user