Осталось доработать
This commit is contained in:
parent
ccc5ae5227
commit
77a1def62e
@ -39,7 +39,7 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
pictureWidth = picWidth;
|
||||
pictureHeight = picHeight;
|
||||
arr = array;
|
||||
arr.SetMaxCount = GetMaxCount;
|
||||
arr.MaxCount = GetMaxCount;
|
||||
}
|
||||
|
||||
public static int operator +(AbstractCompany company, DrawningTrackedVehicle car)
|
||||
|
@ -8,10 +8,10 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
/// Кол-во объектов в коллекции
|
||||
/// </summary>
|
||||
int Count { get; }
|
||||
/// <summary>
|
||||
/// Максимальное количество элементов
|
||||
/// /// <summary>
|
||||
/// Установка максимального количества элементов
|
||||
/// </summary>
|
||||
int SetMaxCount { set; }
|
||||
int MaxCount { get; set; }
|
||||
/// <summary>
|
||||
/// Добавление элемента в коллекцию
|
||||
/// </summary>
|
||||
@ -37,5 +37,14 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
T? Get(int position);
|
||||
/// <summary>
|
||||
/// Получение типа коллекции
|
||||
/// </summary>
|
||||
CollectionType GetCollectionType { get; }
|
||||
/// <summary>
|
||||
/// Получение объектов коллекции по одному
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IEnumerable<T?> GetItems();
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,12 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
get { return list.Count; }
|
||||
}
|
||||
|
||||
public int SetMaxCount
|
||||
public int MaxCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return list.Count;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > 0)
|
||||
@ -36,6 +40,8 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
}
|
||||
}
|
||||
|
||||
public CollectionType GetCollectionType => CollectionType.List;
|
||||
|
||||
public T? Get(int position)
|
||||
{
|
||||
// TODO проверка позиции
|
||||
@ -80,5 +86,13 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IEnumerable<T?> GetItems()
|
||||
{
|
||||
for(int i = 0; i < list.Count; i++)
|
||||
{
|
||||
yield return list[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
namespace HoistingCrane.CollectionGenericObjects
|
||||
{
|
||||
public class MassivGenericObjects<T> : ICollectionGenericObjects<T> where T : class
|
||||
@ -12,8 +13,12 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
{
|
||||
get { return arr.Length; }
|
||||
}
|
||||
public int SetMaxCount
|
||||
public int MaxCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return arr.Length;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > 0)
|
||||
@ -29,6 +34,9 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CollectionType GetCollectionType => CollectionType.Massive;
|
||||
|
||||
public T? Get(int position)
|
||||
{
|
||||
if (position >= 0 && position < arr.Length)
|
||||
@ -38,6 +46,14 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
return null;
|
||||
}
|
||||
|
||||
public IEnumerable<T?> GetItems()
|
||||
{
|
||||
for(int i = 0; i < arr.Length; i++)
|
||||
{
|
||||
yield return arr[i];
|
||||
}
|
||||
}
|
||||
|
||||
public int Insert(T obj)
|
||||
{
|
||||
return Insert(obj, 0);
|
||||
|
@ -1,7 +1,10 @@
|
||||
using System;
|
||||
using HoistingCrane.Drawning;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace HoistingCrane.CollectionGenericObjects
|
||||
{
|
||||
public class StorageCollection<T> where T : class
|
||||
public class StorageCollection<T> where T : DrawningTrackedVehicle
|
||||
{
|
||||
/// <summary>
|
||||
/// Словарь (хранилище) с коллекциями
|
||||
@ -12,6 +15,18 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
/// </summary>
|
||||
public List<string> Keys => dict.Keys.ToList();
|
||||
/// <summary>
|
||||
/// Ключевое слово, с которого должен начинаться файл
|
||||
/// </summary>
|
||||
private readonly string _collectionKey = "CollectionsStorage";
|
||||
/// <summary>
|
||||
/// Разделитель для записи ключа и значения элемента словаря
|
||||
/// </summary>
|
||||
private readonly string _separatorForKeyValue = "|";
|
||||
/// <summary>
|
||||
/// Разделитель для записей коллекции данных в файл
|
||||
/// </summary>
|
||||
private readonly string _separatorItems = ";";
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public StorageCollection()
|
||||
@ -59,5 +74,128 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
return dict[name];
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Сохранение информации по автомобилям в хранилище в файл
|
||||
/// </summary>
|
||||
/// <param name="filename">Путь и имя файла</param>
|
||||
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
|
||||
public bool SaveData(string filename)
|
||||
{
|
||||
if (dict.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 dict)
|
||||
{
|
||||
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;
|
||||
}
|
||||
dict.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?.CreateDrawningTrackedVehicle() is T truck)
|
||||
{
|
||||
if (collection.Insert(truck) == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
dict.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 MassivGenericObjects<T>(),
|
||||
CollectionType.List => new ListGenericObjects<T>(),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using HoistingCrane.Entities;
|
||||
using System.Configuration;
|
||||
using System.Reflection.PortableExecutable;
|
||||
|
||||
namespace HoistingCrane.Drawning;
|
||||
|
||||
@ -39,6 +40,15 @@ public class DrawningHoistingCrane : DrawningTrackedVehicle
|
||||
EntityTrackedVehicle = new EntityHoistingCrane(speed, weight, bodyColor, additionalColor, counterweight, platform);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор для Extention
|
||||
/// </summary>
|
||||
/// <param name="entityHoistingCrane"></param>
|
||||
public DrawningHoistingCrane(EntityHoistingCrane entityHoistingCrane) : base(115, 63)
|
||||
{
|
||||
EntityTrackedVehicle = new EntityHoistingCrane(entityHoistingCrane.Speed, entityHoistingCrane.Weight, entityHoistingCrane.BodyColor, entityHoistingCrane.AdditionalColor, entityHoistingCrane.Counterweight, entityHoistingCrane.Platform);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Метод отрисовки объекта
|
||||
/// </summary>
|
||||
@ -49,7 +59,6 @@ public class DrawningHoistingCrane : DrawningTrackedVehicle
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base.DrawTransport(gr);
|
||||
Brush b = new SolidBrush(EntityHoistingCrane.AdditionalColor);
|
||||
Pen pen = new Pen(EntityHoistingCrane.AdditionalColor);
|
||||
|
@ -1,4 +1,5 @@
|
||||
using HoistingCrane.Entities;
|
||||
using System.Reflection.PortableExecutable;
|
||||
|
||||
namespace HoistingCrane.Drawning
|
||||
{
|
||||
@ -80,6 +81,15 @@ namespace HoistingCrane.Drawning
|
||||
_startPosY = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор для Extention
|
||||
/// </summary>
|
||||
/// <param name="drawningTrackedVehicle"></param>
|
||||
public DrawningTrackedVehicle(EntityTrackedVehicle entityTrackedVehicle) : this()
|
||||
{
|
||||
EntityTrackedVehicle = new EntityTrackedVehicle(entityTrackedVehicle.Speed, entityTrackedVehicle.Weight, entityTrackedVehicle.BodyColor);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Метод отрисовки игрового поля
|
||||
|
@ -0,0 +1,55 @@
|
||||
using HoistingCrane.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HoistingCrane.Drawning
|
||||
{
|
||||
public static class ExtentionDrawningCrane
|
||||
{
|
||||
/// <summary>
|
||||
/// Разделитель для записи информации по объекту в файл
|
||||
/// </summary>
|
||||
private static readonly string _separatorForObject = ":";
|
||||
|
||||
/// <summary>
|
||||
/// Создание объекта из строки
|
||||
/// </summary>
|
||||
/// <param name="info">Строка с данными для создания объекта</param>
|
||||
/// <returns>Объект</returns>
|
||||
public static DrawningTrackedVehicle? CreateDrawningTrackedVehicle(this string info)
|
||||
{
|
||||
string[] strs = info.Split(_separatorForObject);
|
||||
EntityTrackedVehicle? trackedVehicle = EntityHoistingCrane.CreateEntityHoistingCrane(strs);
|
||||
if (trackedVehicle != null)
|
||||
{
|
||||
return new DrawningHoistingCrane((EntityHoistingCrane)trackedVehicle);
|
||||
}
|
||||
trackedVehicle = EntityTrackedVehicle.CreateEntityTrackedVehicle(strs);
|
||||
if (trackedVehicle != null)
|
||||
{
|
||||
return new DrawningTrackedVehicle(trackedVehicle);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение данных для сохранения в файл
|
||||
/// </summary>
|
||||
/// <param name="drawningTrackedMachine">Сохраняемый объект</param>
|
||||
/// <returns>Строка с данными по объекту</returns>
|
||||
public static string GetDataForSave(this DrawningTrackedVehicle drawningTrackedVehicle)
|
||||
{
|
||||
string[]? array = drawningTrackedVehicle?.EntityTrackedVehicle?.GetStringRepresentation();
|
||||
|
||||
if (array == null)
|
||||
{
|
||||
return string.Empty;
|
||||
|
||||
}
|
||||
return string.Join(_separatorForObject, array);
|
||||
}
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ public class EntityHoistingCrane : EntityTrackedVehicle
|
||||
|
||||
|
||||
// Äîïîëíÿåò íåäîñòîþùèå ýëåìåíòû èç ðîä. êëàññà
|
||||
public EntityHoistingCrane(int Speed, int Weight, Color BodyColor, Color AdditionalColor, bool Counterweight, bool Platform) : base(Speed, Weight, BodyColor)
|
||||
public EntityHoistingCrane(int Speed, double Weight, Color BodyColor, Color AdditionalColor, bool Counterweight, bool Platform) : base(Speed, Weight, BodyColor)
|
||||
{
|
||||
this.AdditionalColor = AdditionalColor;
|
||||
this.Counterweight = Counterweight;
|
||||
@ -42,4 +42,27 @@ public class EntityHoistingCrane : EntityTrackedVehicle
|
||||
{
|
||||
AdditionalColor = newColor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ïîëó÷óåèí ñòðîê ñî çíà÷åíèÿìè ñâîéñòâ îáúåêòà êëàññà-ñóùíîñòè
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string[] GetStringRepresentation()
|
||||
{
|
||||
return new[] { nameof(EntityHoistingCrane), Speed.ToString(), Weight.ToString(), BodyColor.Name, AdditionalColor.Name, Counterweight.ToString(), Platform.ToString()};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ñîçäàíèå îáúåêòà èç ìàññèâà ñòðîê
|
||||
/// </summary>
|
||||
/// <param name="strs"></param>
|
||||
/// <returns></returns>
|
||||
public static EntityHoistingCrane? CreateEntityHoistingCrane(string[] strs)
|
||||
{
|
||||
if (strs.Length != 7 || strs[0] != nameof(EntityHoistingCrane))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new EntityHoistingCrane(Convert.ToInt32(strs[1]), Convert.ToInt32(strs[2]), Color.FromName(strs[3]), Color.FromName(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]));
|
||||
}
|
||||
}
|
@ -43,11 +43,34 @@
|
||||
this.Weight = Weight;
|
||||
this.BodyColor = BodyColor;
|
||||
}
|
||||
|
||||
|
||||
public void SetBodyColor(Color newBodyColor)
|
||||
{
|
||||
BodyColor = newBodyColor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получуеин строк со значениями свойств объекта класса-сущности
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual string[] GetStringRepresentation()
|
||||
{
|
||||
return new[] { nameof(EntityTrackedVehicle), Speed.ToString(), Weight.ToString(), BodyColor.Name };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создание объекта из массива строк
|
||||
/// </summary>
|
||||
/// <param name="strs"></param>
|
||||
/// <returns></returns>
|
||||
public static EntityTrackedVehicle? CreateEntityTrackedVehicle(string[] strs)
|
||||
{
|
||||
if(strs.Length != 4 || strs[0] != nameof(EntityTrackedVehicle))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new EntityTrackedVehicle(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,12 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
groupBoxTools = new GroupBox();
|
||||
panelCompanyTool = new Panel();
|
||||
buttonCreateHoistingCrane = new Button();
|
||||
maskedTextBox = new MaskedTextBox();
|
||||
buttonRefresh = new Button();
|
||||
buttonGoToChek = new Button();
|
||||
buttonDeleteCar = new Button();
|
||||
buttonCreateCompany = new Button();
|
||||
panelStorage = new Panel();
|
||||
buttonDeleteCollection = new Button();
|
||||
@ -38,18 +44,19 @@
|
||||
radioButtonMassive = new RadioButton();
|
||||
textBoxCollectionName = new TextBox();
|
||||
labelCollectionName = new Label();
|
||||
buttonGoToChek = new Button();
|
||||
buttonRefresh = new Button();
|
||||
buttonDeleteCar = new Button();
|
||||
maskedTextBox = new MaskedTextBox();
|
||||
comboBoxSelectorCompany = new ComboBox();
|
||||
buttonCreateHoistingCrane = new Button();
|
||||
pictureBox = new PictureBox();
|
||||
panelCompanyTool = new Panel();
|
||||
menuStrip = new MenuStrip();
|
||||
файлToolStripMenuItem = new ToolStripMenuItem();
|
||||
saveToolStripMenuItem = new ToolStripMenuItem();
|
||||
loadToolStripMenuItem = new ToolStripMenuItem();
|
||||
saveFileDialog = new SaveFileDialog();
|
||||
openFileDialog = new OpenFileDialog();
|
||||
groupBoxTools.SuspendLayout();
|
||||
panelCompanyTool.SuspendLayout();
|
||||
panelStorage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||
panelCompanyTool.SuspendLayout();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxTools
|
||||
@ -59,13 +66,79 @@
|
||||
groupBoxTools.Controls.Add(panelStorage);
|
||||
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
||||
groupBoxTools.Dock = DockStyle.Right;
|
||||
groupBoxTools.Location = new Point(763, 0);
|
||||
groupBoxTools.Location = new Point(763, 24);
|
||||
groupBoxTools.Name = "groupBoxTools";
|
||||
groupBoxTools.Size = new Size(210, 509);
|
||||
groupBoxTools.Size = new Size(210, 485);
|
||||
groupBoxTools.TabIndex = 0;
|
||||
groupBoxTools.TabStop = false;
|
||||
groupBoxTools.Text = "Инструменты";
|
||||
//
|
||||
// panelCompanyTool
|
||||
//
|
||||
panelCompanyTool.Anchor = AnchorStyles.None;
|
||||
panelCompanyTool.Controls.Add(buttonCreateHoistingCrane);
|
||||
panelCompanyTool.Controls.Add(maskedTextBox);
|
||||
panelCompanyTool.Controls.Add(buttonRefresh);
|
||||
panelCompanyTool.Controls.Add(buttonGoToChek);
|
||||
panelCompanyTool.Controls.Add(buttonDeleteCar);
|
||||
panelCompanyTool.Location = new Point(6, 312);
|
||||
panelCompanyTool.Name = "panelCompanyTool";
|
||||
panelCompanyTool.Size = new Size(204, 185);
|
||||
panelCompanyTool.TabIndex = 8;
|
||||
//
|
||||
// buttonCreateHoistingCrane
|
||||
//
|
||||
buttonCreateHoistingCrane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonCreateHoistingCrane.Location = new Point(9, 13);
|
||||
buttonCreateHoistingCrane.Name = "buttonCreateHoistingCrane";
|
||||
buttonCreateHoistingCrane.Size = new Size(192, 22);
|
||||
buttonCreateHoistingCrane.TabIndex = 0;
|
||||
buttonCreateHoistingCrane.Text = "Добавить транспорт";
|
||||
buttonCreateHoistingCrane.UseVisualStyleBackColor = true;
|
||||
buttonCreateHoistingCrane.Click += buttonCreateHoistingCrane_Click;
|
||||
//
|
||||
// maskedTextBox
|
||||
//
|
||||
maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
maskedTextBox.Location = new Point(9, 41);
|
||||
maskedTextBox.Mask = "00";
|
||||
maskedTextBox.Name = "maskedTextBox";
|
||||
maskedTextBox.Size = new Size(192, 23);
|
||||
maskedTextBox.TabIndex = 3;
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonRefresh.Location = new Point(9, 129);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(192, 27);
|
||||
buttonRefresh.TabIndex = 5;
|
||||
buttonRefresh.Text = "Обновить";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += buttonRefresh_Click;
|
||||
//
|
||||
// buttonGoToChek
|
||||
//
|
||||
buttonGoToChek.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonGoToChek.Location = new Point(9, 99);
|
||||
buttonGoToChek.Name = "buttonGoToChek";
|
||||
buttonGoToChek.Size = new Size(192, 24);
|
||||
buttonGoToChek.TabIndex = 6;
|
||||
buttonGoToChek.Text = "Передать на тесты";
|
||||
buttonGoToChek.UseVisualStyleBackColor = true;
|
||||
buttonGoToChek.Click += buttonGoToChek_Click;
|
||||
//
|
||||
// buttonDeleteCar
|
||||
//
|
||||
buttonDeleteCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonDeleteCar.Location = new Point(9, 70);
|
||||
buttonDeleteCar.Name = "buttonDeleteCar";
|
||||
buttonDeleteCar.Size = new Size(192, 23);
|
||||
buttonDeleteCar.TabIndex = 4;
|
||||
buttonDeleteCar.Text = "Удалить автомобиль";
|
||||
buttonDeleteCar.UseVisualStyleBackColor = true;
|
||||
buttonDeleteCar.Click += buttonDeleteCar_Click;
|
||||
//
|
||||
// buttonCreateCompany
|
||||
//
|
||||
buttonCreateCompany.Location = new Point(12, 295);
|
||||
@ -158,48 +231,6 @@
|
||||
labelCollectionName.TabIndex = 0;
|
||||
labelCollectionName.Text = "Название коллекции:";
|
||||
//
|
||||
// buttonGoToChek
|
||||
//
|
||||
buttonGoToChek.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonGoToChek.Location = new Point(9, 99);
|
||||
buttonGoToChek.Name = "buttonGoToChek";
|
||||
buttonGoToChek.Size = new Size(192, 24);
|
||||
buttonGoToChek.TabIndex = 6;
|
||||
buttonGoToChek.Text = "Передать на тесты";
|
||||
buttonGoToChek.UseVisualStyleBackColor = true;
|
||||
buttonGoToChek.Click += buttonGoToChek_Click;
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonRefresh.Location = new Point(9, 129);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(192, 27);
|
||||
buttonRefresh.TabIndex = 5;
|
||||
buttonRefresh.Text = "Обновить";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += buttonRefresh_Click;
|
||||
//
|
||||
// buttonDeleteCar
|
||||
//
|
||||
buttonDeleteCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonDeleteCar.Location = new Point(9, 70);
|
||||
buttonDeleteCar.Name = "buttonDeleteCar";
|
||||
buttonDeleteCar.Size = new Size(192, 23);
|
||||
buttonDeleteCar.TabIndex = 4;
|
||||
buttonDeleteCar.Text = "Удалить автомобиль";
|
||||
buttonDeleteCar.UseVisualStyleBackColor = true;
|
||||
buttonDeleteCar.Click += buttonDeleteCar_Click;
|
||||
//
|
||||
// maskedTextBox
|
||||
//
|
||||
maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
maskedTextBox.Location = new Point(9, 41);
|
||||
maskedTextBox.Mask = "00";
|
||||
maskedTextBox.Name = "maskedTextBox";
|
||||
maskedTextBox.Size = new Size(192, 23);
|
||||
maskedTextBox.TabIndex = 3;
|
||||
//
|
||||
// comboBoxSelectorCompany
|
||||
//
|
||||
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
@ -212,38 +243,54 @@
|
||||
comboBoxSelectorCompany.TabIndex = 2;
|
||||
comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged;
|
||||
//
|
||||
// buttonCreateHoistingCrane
|
||||
//
|
||||
buttonCreateHoistingCrane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonCreateHoistingCrane.Location = new Point(9, 13);
|
||||
buttonCreateHoistingCrane.Name = "buttonCreateHoistingCrane";
|
||||
buttonCreateHoistingCrane.Size = new Size(192, 22);
|
||||
buttonCreateHoistingCrane.TabIndex = 0;
|
||||
buttonCreateHoistingCrane.Text = "Добавить транспорт";
|
||||
buttonCreateHoistingCrane.UseVisualStyleBackColor = true;
|
||||
buttonCreateHoistingCrane.Click += buttonCreateHoistingCrane_Click;
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
pictureBox.Dock = DockStyle.Fill;
|
||||
pictureBox.Location = new Point(0, 0);
|
||||
pictureBox.Location = new Point(0, 24);
|
||||
pictureBox.Name = "pictureBox";
|
||||
pictureBox.Size = new Size(763, 509);
|
||||
pictureBox.Size = new Size(763, 485);
|
||||
pictureBox.TabIndex = 1;
|
||||
pictureBox.TabStop = false;
|
||||
//
|
||||
// panelCompanyTool
|
||||
// menuStrip
|
||||
//
|
||||
panelCompanyTool.Anchor = AnchorStyles.None;
|
||||
panelCompanyTool.Controls.Add(buttonCreateHoistingCrane);
|
||||
panelCompanyTool.Controls.Add(maskedTextBox);
|
||||
panelCompanyTool.Controls.Add(buttonRefresh);
|
||||
panelCompanyTool.Controls.Add(buttonGoToChek);
|
||||
panelCompanyTool.Controls.Add(buttonDeleteCar);
|
||||
panelCompanyTool.Location = new Point(6, 324);
|
||||
panelCompanyTool.Name = "panelCompanyTool";
|
||||
panelCompanyTool.Size = new Size(204, 185);
|
||||
panelCompanyTool.TabIndex = 8;
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(973, 24);
|
||||
menuStrip.TabIndex = 2;
|
||||
menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// файлToolStripMenuItem
|
||||
//
|
||||
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
|
||||
файлToolStripMenuItem.Name = "файлToolStripMenuItem";
|
||||
файлToolStripMenuItem.Size = new Size(50, 20);
|
||||
файлToolStripMenuItem.Text = "Файл";
|
||||
//
|
||||
// saveToolStripMenuItem
|
||||
//
|
||||
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||
saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||
saveToolStripMenuItem.Size = new Size(186, 22);
|
||||
saveToolStripMenuItem.Text = "Сохранение";
|
||||
saveToolStripMenuItem.Click += saveToolStripMenuItem_Click;
|
||||
//
|
||||
// loadToolStripMenuItem
|
||||
//
|
||||
loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
||||
loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
|
||||
loadToolStripMenuItem.Size = new Size(186, 22);
|
||||
loadToolStripMenuItem.Text = "Загрузка";
|
||||
loadToolStripMenuItem.Click += loadToolStripMenuItem_Click;
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
saveFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
openFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// FormCarCollection
|
||||
//
|
||||
@ -252,15 +299,20 @@
|
||||
ClientSize = new Size(973, 509);
|
||||
Controls.Add(pictureBox);
|
||||
Controls.Add(groupBoxTools);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Name = "FormCarCollection";
|
||||
Text = "FormCarCollections";
|
||||
groupBoxTools.ResumeLayout(false);
|
||||
panelCompanyTool.ResumeLayout(false);
|
||||
panelCompanyTool.PerformLayout();
|
||||
panelStorage.ResumeLayout(false);
|
||||
panelStorage.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||
panelCompanyTool.ResumeLayout(false);
|
||||
panelCompanyTool.PerformLayout();
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -283,5 +335,11 @@
|
||||
private ListBox listBoxCollection;
|
||||
private Button buttonCollectionAdd;
|
||||
private Panel panelCompanyTool;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem файлToolStripMenuItem;
|
||||
private ToolStripMenuItem saveToolStripMenuItem;
|
||||
private ToolStripMenuItem loadToolStripMenuItem;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private OpenFileDialog openFileDialog;
|
||||
}
|
||||
}
|
@ -204,6 +204,47 @@ namespace HoistingCrane
|
||||
panelCompanyTool.Enabled = true;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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, 5</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>130, 5</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>270, 5</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>25</value>
|
||||
</metadata>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user