PIbd-13 BelkinaM.I. LabWork06 Simple #6
@ -54,7 +54,7 @@ public abstract class AbstractCompany
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_collection = collectoin;
|
||||
_collection.SetMaxCount = GetMaxCount;
|
||||
_collection.MaxCount = GetMaxCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -21,7 +21,7 @@ public interface ICollectoinGenericObjects<T>
|
||||
/// <summary>
|
||||
/// Установка максимального колличества элементов
|
||||
/// </summary>
|
||||
int SetMaxCount { set; }
|
||||
int MaxCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Добавление элемента в коллекцию
|
||||
@ -51,4 +51,15 @@ public interface ICollectoinGenericObjects<T>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns>Объект</returns>
|
||||
T? Get(int position);
|
||||
|
||||
/// <summary>
|
||||
/// Получение типа коллекции
|
||||
/// </summary>
|
||||
CollectionType GetCollectionType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Получение объектов коллекции по одному
|
||||
/// </summary>
|
||||
/// <returns>Поэлементный вывод элементов коллекции</returns>
|
||||
IEnumerable<T> GetItems();
|
||||
}
|
||||
|
@ -25,7 +25,22 @@ public class ListGenericObjects<T> : ICollectoinGenericObjects<T>
|
||||
|
||||
public int Count => _collection.Count;
|
||||
|
||||
public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
|
||||
public int MaxCount {
|
||||
get
|
||||
{
|
||||
return _collection.Count;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value > 0)
|
||||
{
|
||||
_maxCount = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CollectionType GetCollectionType => CollectionType.List;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
@ -90,4 +105,12 @@ public class ListGenericObjects<T> : ICollectoinGenericObjects<T>
|
||||
_collection[position] = null;
|
||||
return obj;
|
||||
}
|
||||
|
||||
public IEnumerable<T?> GetItems()
|
||||
{
|
||||
for (int i = 0; i < _collection.Count; ++i)
|
||||
{
|
||||
yield return _collection[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,12 @@ public class MassiveGenericObject<T> : ICollectoinGenericObjects<T>
|
||||
|
||||
public int Count => _collection.Length;
|
||||
|
||||
public int SetMaxCount
|
||||
{
|
||||
public int MaxCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return _collection.Length;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > 0)
|
||||
@ -34,6 +38,8 @@ public class MassiveGenericObject<T> : ICollectoinGenericObjects<T>
|
||||
}
|
||||
}
|
||||
|
||||
public CollectionType GetCollectionType => CollectionType.Massive;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
@ -130,4 +136,12 @@ public class MassiveGenericObject<T> : ICollectoinGenericObjects<T>
|
||||
_collection[position] = null;
|
||||
return elem;
|
||||
}
|
||||
|
||||
public IEnumerable<T?> GetItems()
|
||||
{
|
||||
for (int i = 0; i < _collection.Length; ++i)
|
||||
{
|
||||
yield return _collection[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectBulldozer.Drawnings;
|
||||
|
||||
namespace ProjectBulldozer.CollectionGenericObjects;
|
||||
|
||||
@ -11,7 +12,7 @@ namespace ProjectBulldozer.CollectionGenericObjects;
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class StorageCollection<T>
|
||||
where T : class
|
||||
where T : DrawningDozer
|
||||
{
|
||||
/// <summary>
|
||||
/// Словарь (хранилище) с коллекциями
|
||||
@ -23,6 +24,21 @@ public class StorageCollection<T>
|
||||
/// </summary>
|
||||
public List<string> Keys => _storages.Keys.ToList();
|
||||
|
||||
/// <summary>
|
||||
/// Ключевое слово, с которого должен начианться файл
|
||||
/// </summary>
|
||||
private readonly string _collectionKey = "CollectionStorage";
|
||||
|
||||
/// <summary>
|
||||
/// Разделитель для записи ключа и значения элемента словаря
|
||||
/// </summary>
|
||||
private readonly string _separatorForKeyValue = "|";
|
||||
|
||||
/// <summary>
|
||||
/// Разделительдля записи коллекций данных в файл
|
||||
/// </summary>
|
||||
private readonly string _separatorItems = ";";
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
@ -84,4 +100,140 @@ public class StorageCollection<T>
|
||||
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);
|
||||
}
|
||||
|
||||
StringBuilder stringBuilder = new();
|
||||
|
||||
stringBuilder.Append(_collectionKey);
|
||||
foreach (KeyValuePair<string, ICollectoinGenericObjects<T>> value in _storages)
|
||||
{
|
||||
stringBuilder.Append(Environment.NewLine);
|
||||
// не сохраняем пустые коллекции.
|
||||
if (value.Value.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
stringBuilder.Append(value.Key);
|
||||
stringBuilder.Append(_separatorForKeyValue);
|
||||
stringBuilder.Append(value.Value.GetCollectionType);
|
||||
stringBuilder.Append(_separatorForKeyValue);
|
||||
stringBuilder.Append(value.Value.MaxCount);
|
||||
stringBuilder.Append(_separatorForKeyValue);
|
||||
|
||||
foreach (T? item in value.Value.GetItems())
|
||||
{
|
||||
string data = item?.GetDataForSave() ?? string.Empty;
|
||||
if (string.IsNullOrEmpty(data))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
stringBuilder.Append(data);
|
||||
stringBuilder.Append(_separatorItems);
|
||||
}
|
||||
}
|
||||
|
||||
using FileStream fileStream = new(filename, FileMode.Create);
|
||||
|
||||
byte[] info = new UTF8Encoding(true).GetBytes(stringBuilder.ToString());
|
||||
fileStream.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 fileStream = new(filename, FileMode.Open))
|
||||
eegov
commented
Чтение следовало делать через StreamReader Чтение следовало делать через StreamReader
|
||||
{
|
||||
byte[] bytes = new byte[fileStream.Length];
|
||||
UTF8Encoding temp = new(true);
|
||||
while (fileStream.Read(bytes, 0, bytes.Length) > 0)
|
||||
{
|
||||
bufferTextfromFile += temp.GetString(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
string[] strs = bufferTextfromFile.Split(new char[] { '\r', '\n'},
|
||||
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]);
|
||||
ICollectoinGenericObjects<T>? collectoin = StorageCollection<T>.CreateCollection(collectionType);
|
||||
|
||||
if (collectoin == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
collectoin.MaxCount = Convert.ToInt32(record[2]);
|
||||
|
||||
string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
foreach (string elem in set)
|
||||
{
|
||||
if (elem?.CreateDrawningDozer() is T dozer)
|
||||
{
|
||||
if (collectoin.Insert(dozer) == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
_storages.Add(record[0], collectoin);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private static ICollectoinGenericObjects<T>? CreateCollection(CollectionType collectionType)
|
||||
{
|
||||
return collectionType switch
|
||||
{
|
||||
CollectionType.Massive => new MassiveGenericObject<T>(),
|
||||
CollectionType.List => new ListGenericObjects<T>(),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectBulldozer.Entities;
|
||||
@ -12,6 +13,20 @@ namespace ProjectBulldozer.Drawnings;
|
||||
/// </summary>
|
||||
public class DrawningBulldozer : DrawningDozer
|
||||
{
|
||||
private EntityDozer dozer;
|
||||
|
||||
/// <summary>
|
||||
/// Другой конструктор.
|
||||
/// </summary>
|
||||
/// <param name="dozer"></param>
|
||||
public DrawningBulldozer(EntityDozer? entityDozer) : base(150, 90)
|
||||
{
|
||||
if (entityDozer != null)
|
||||
{
|
||||
EntityDozer = entityDozer;
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Конструктор
|
||||
/// </summary>
|
||||
|
@ -36,6 +36,7 @@ public class DrawningDozer
|
||||
/// Верхнаяя координата прорисовки бульдозера
|
||||
/// </summary>
|
||||
protected int? _startPosY;
|
||||
private EntityDozer dozer;
|
||||
|
||||
///<summary>
|
||||
///Ширина прорисовки бульдозера
|
||||
@ -102,6 +103,16 @@ public class DrawningDozer
|
||||
_pictureHeight = drawningBulldozerHeigh;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Другой конструктор.
|
||||
/// </summary>
|
||||
/// <param name="dozer"></param>
|
||||
public DrawningDozer(EntityDozer? entityDozer)
|
||||
{
|
||||
if (entityDozer == null) return;
|
||||
EntityDozer = entityDozer;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Установка границ поля
|
||||
/// </summary>
|
||||
@ -243,19 +254,19 @@ public class DrawningDozer
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush bodyBrush = new SolidBrush(EntityDozer.BodyColor);
|
||||
Brush wheelsBrush = new SolidBrush(Color.FromArgb(60, 60, 60));
|
||||
Brush wheelstringBuilderrush = new SolidBrush(Color.FromArgb(60, 60, 60));
|
||||
//BULDOZER
|
||||
//body
|
||||
g.FillRectangle(bodyBrush, _startPosX.Value + 10, _startPosY.Value + 15, _drawningBulldozerWidth - 20, _drawningBulldozerHeight - 30);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 15, _drawningBulldozerWidth - 20, _drawningBulldozerHeight - 30);
|
||||
//wheels
|
||||
g.FillRectangle(wheelsBrush, _startPosX.Value, _startPosY.Value + _drawningBulldozerHeight - 15, 50, 15);
|
||||
g.FillRectangle(wheelstringBuilderrush, _startPosX.Value, _startPosY.Value + _drawningBulldozerHeight - 15, 50, 15);
|
||||
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + _drawningBulldozerHeight - 15, 50, 15);
|
||||
g.FillRectangle(wheelsBrush, _startPosX.Value + _drawningBulldozerWidth - 50, _startPosY.Value + _drawningBulldozerHeight - 15, 50, 15);
|
||||
g.FillRectangle(wheelstringBuilderrush, _startPosX.Value + _drawningBulldozerWidth - 50, _startPosY.Value + _drawningBulldozerHeight - 15, 50, 15);
|
||||
g.DrawRectangle(pen, _startPosX.Value + _drawningBulldozerWidth - 50, _startPosY.Value + _drawningBulldozerHeight - 15, 50, 15);
|
||||
g.FillRectangle(wheelsBrush, _startPosX.Value, _startPosY.Value, 50, 15);
|
||||
g.FillRectangle(wheelstringBuilderrush, _startPosX.Value, _startPosY.Value, 50, 15);
|
||||
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value, 50, 15);
|
||||
g.FillRectangle(wheelsBrush, _startPosX.Value + _drawningBulldozerWidth - 50, _startPosY.Value, 50, 15);
|
||||
g.FillRectangle(wheelstringBuilderrush, _startPosX.Value + _drawningBulldozerWidth - 50, _startPosY.Value, 50, 15);
|
||||
g.DrawRectangle(pen, _startPosX.Value + _drawningBulldozerWidth - 50, _startPosY.Value, 50, 15);
|
||||
//strange rectangles
|
||||
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 25, 3, _drawningBulldozerHeight - 50);
|
||||
|
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectBulldozer.Entities;
|
||||
|
||||
namespace ProjectBulldozer.Drawnings;
|
||||
|
||||
/// <summary>
|
||||
/// Расширение для класса EntityDozer
|
||||
/// </summary>
|
||||
public static class ExtentionDrawningDozer
|
||||
{
|
||||
/// <summary>
|
||||
/// Разделитель строки для записи информации по объекту.
|
||||
/// </summary>
|
||||
private static readonly string _separatorForObject = ":";
|
||||
|
||||
/// <summary>
|
||||
/// Создание объекта из строки.
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
/// <returns></returns>
|
||||
public static DrawningDozer? CreateDrawningDozer(this string info)
|
||||
{
|
||||
string[] strs = info.Split(_separatorForObject);
|
||||
EntityDozer? dozer = EntityBulldozer.CreateEntityBulldozer(strs);
|
||||
if (dozer != null)
|
||||
{
|
||||
return new DrawningBulldozer(dozer);
|
||||
}
|
||||
|
||||
dozer = EntityDozer.CreateEntityDozer(strs);
|
||||
if (dozer != null)
|
||||
{
|
||||
return new DrawningDozer(dozer);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение данных для сохранения в файл.
|
||||
/// </summary>
|
||||
/// <param name="drawningDozer"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetDataForSave(this DrawningDozer drawningDozer)
|
||||
{
|
||||
string[]? array = drawningDozer?.EntityDozer?.GetStringRepresentation();
|
||||
|
||||
if (array == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return string.Join(_separatorForObject, array);
|
||||
}
|
||||
}
|
@ -49,4 +49,30 @@ public class EntityBulldozer : EntityDozer
|
||||
Blade = blade;
|
||||
Caterpillar = caterpillar;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получение строк со значениями свойств объекта класса-сущности.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string[] GetStringRepresentation()
|
||||
{
|
||||
return new[] { nameof(EntityBulldozer), Speed.ToString(), Weight.ToString(), Weight.ToString(), BodyColor.Name,
|
||||
AdditionalColor.Name, Blade.ToString(), Caterpillar.ToString() };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создание объекта из массива строк.
|
||||
/// </summary>
|
||||
/// <param name="strs"></param>
|
||||
/// <returns></returns>
|
||||
public static EntityBulldozer? CreateEntityBulldozer(string[] strs)
|
||||
{
|
||||
if (strs.Length != 7 || strs[0] != nameof(EntityBulldozer))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new EntityBulldozer(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]),
|
||||
Color.FromName(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]));
|
||||
}
|
||||
}
|
||||
|
@ -42,11 +42,31 @@ public class EntityDozer
|
||||
///<param name="speed">Скорость</param>
|
||||
///<param name="weight">Вес</param>
|
||||
///<param name="bodyColor">Основной цвет</param>
|
||||
public EntityDozer(int speed, double weight, Color bodyColor/*, Color additionalColor*/)
|
||||
public EntityDozer(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение строк со значениями свойств объекта класса-сущности.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual string[] GetStringRepresentation()
|
||||
{
|
||||
return new[] { nameof(EntityDozer), Speed.ToString(), Weight.ToString(), BodyColor.Name };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создание объекта из массива строк.
|
||||
/// </summary>
|
||||
/// <param name="strs"></param>
|
||||
/// <returns></returns>
|
||||
public static EntityDozer? CreateEntityDozer(string[] strs)
|
||||
{
|
||||
if (strs.Length != 4 || strs[0] != nameof(EntityDozer)) return null;
|
||||
|
||||
return new EntityDozer(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]));
|
||||
}
|
||||
}
|
||||
|
@ -46,10 +46,17 @@
|
||||
buttonCreateCompany = new Button();
|
||||
comboBoxSelectorCompany = new ComboBox();
|
||||
pictureBox = new PictureBox();
|
||||
menuStrip = new MenuStrip();
|
||||
fileToolStripMenuItem = 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
|
||||
@ -60,9 +67,9 @@
|
||||
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
||||
groupBoxTools.Dock = DockStyle.Right;
|
||||
groupBoxTools.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
groupBoxTools.Location = new Point(1290, 0);
|
||||
groupBoxTools.Location = new Point(1489, 41);
|
||||
groupBoxTools.Name = "groupBoxTools";
|
||||
groupBoxTools.Size = new Size(358, 968);
|
||||
groupBoxTools.Size = new Size(413, 963);
|
||||
groupBoxTools.TabIndex = 0;
|
||||
groupBoxTools.TabStop = false;
|
||||
groupBoxTools.Text = "Инструменты";
|
||||
@ -75,18 +82,18 @@
|
||||
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
||||
panelCompanyTools.Controls.Add(buttonRefresh);
|
||||
panelCompanyTools.Enabled = false;
|
||||
panelCompanyTools.Location = new Point(3, 624);
|
||||
panelCompanyTools.Location = new Point(3, 602);
|
||||
panelCompanyTools.Name = "panelCompanyTools";
|
||||
panelCompanyTools.Size = new Size(400, 345);
|
||||
panelCompanyTools.Size = new Size(406, 356);
|
||||
panelCompanyTools.TabIndex = 7;
|
||||
//
|
||||
// buttonAddDozer
|
||||
//
|
||||
buttonAddDozer.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonAddDozer.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
buttonAddDozer.Location = new Point(11, 14);
|
||||
buttonAddDozer.Location = new Point(13, 14);
|
||||
buttonAddDozer.Name = "buttonAddDozer";
|
||||
buttonAddDozer.Size = new Size(332, 64);
|
||||
buttonAddDozer.Size = new Size(383, 66);
|
||||
buttonAddDozer.TabIndex = 2;
|
||||
buttonAddDozer.Text = "Добавление бульдозера";
|
||||
buttonAddDozer.UseVisualStyleBackColor = true;
|
||||
@ -96,9 +103,9 @@
|
||||
//
|
||||
buttonDelBulldozer.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonDelBulldozer.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
buttonDelBulldozer.Location = new Point(11, 131);
|
||||
buttonDelBulldozer.Location = new Point(13, 135);
|
||||
buttonDelBulldozer.Name = "buttonDelBulldozer";
|
||||
buttonDelBulldozer.Size = new Size(332, 63);
|
||||
buttonDelBulldozer.Size = new Size(383, 65);
|
||||
buttonDelBulldozer.TabIndex = 3;
|
||||
buttonDelBulldozer.Text = "Удаленить бульдозер";
|
||||
buttonDelBulldozer.UseVisualStyleBackColor = true;
|
||||
@ -107,9 +114,10 @@
|
||||
// maskedTextBox
|
||||
//
|
||||
maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
maskedTextBox.Location = new Point(11, 84);
|
||||
maskedTextBox.Location = new Point(13, 87);
|
||||
maskedTextBox.Mask = "00";
|
||||
maskedTextBox.Name = "maskedTextBox";
|
||||
maskedTextBox.Size = new Size(332, 41);
|
||||
maskedTextBox.Size = new Size(382, 41);
|
||||
maskedTextBox.TabIndex = 5;
|
||||
maskedTextBox.ValidatingType = typeof(int);
|
||||
//
|
||||
@ -117,9 +125,9 @@
|
||||
//
|
||||
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonGoToCheck.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
buttonGoToCheck.Location = new Point(11, 200);
|
||||
buttonGoToCheck.Location = new Point(13, 206);
|
||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||
buttonGoToCheck.Size = new Size(332, 63);
|
||||
buttonGoToCheck.Size = new Size(383, 65);
|
||||
buttonGoToCheck.TabIndex = 3;
|
||||
buttonGoToCheck.Text = "Передать на тесты";
|
||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||
@ -129,9 +137,9 @@
|
||||
//
|
||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonRefresh.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
buttonRefresh.Location = new Point(11, 269);
|
||||
buttonRefresh.Location = new Point(13, 277);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(332, 63);
|
||||
buttonRefresh.Size = new Size(383, 65);
|
||||
buttonRefresh.TabIndex = 3;
|
||||
buttonRefresh.Text = "Обновить";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
@ -149,23 +157,23 @@
|
||||
panelStorage.Dock = DockStyle.Top;
|
||||
panelStorage.Location = new Point(3, 37);
|
||||
panelStorage.Name = "panelStorage";
|
||||
panelStorage.Size = new Size(352, 465);
|
||||
panelStorage.Size = new Size(407, 448);
|
||||
panelStorage.TabIndex = 6;
|
||||
//
|
||||
// listBoxCollection
|
||||
//
|
||||
listBoxCollection.FormattingEnabled = true;
|
||||
listBoxCollection.ItemHeight = 33;
|
||||
listBoxCollection.Location = new Point(11, 219);
|
||||
listBoxCollection.Location = new Point(13, 209);
|
||||
listBoxCollection.Name = "listBoxCollection";
|
||||
listBoxCollection.Size = new Size(332, 169);
|
||||
listBoxCollection.Size = new Size(382, 169);
|
||||
listBoxCollection.TabIndex = 5;
|
||||
//
|
||||
// buttonCollectionDel
|
||||
//
|
||||
buttonCollectionDel.Location = new Point(11, 407);
|
||||
buttonCollectionDel.Location = new Point(13, 394);
|
||||
buttonCollectionDel.Name = "buttonCollectionDel";
|
||||
buttonCollectionDel.Size = new Size(332, 46);
|
||||
buttonCollectionDel.Size = new Size(383, 47);
|
||||
buttonCollectionDel.TabIndex = 4;
|
||||
buttonCollectionDel.Text = "Удалить коллекцию";
|
||||
buttonCollectionDel.UseVisualStyleBackColor = true;
|
||||
@ -173,9 +181,9 @@
|
||||
//
|
||||
// buttonCollectionAdd
|
||||
//
|
||||
buttonCollectionAdd.Location = new Point(11, 157);
|
||||
buttonCollectionAdd.Location = new Point(13, 144);
|
||||
buttonCollectionAdd.Name = "buttonCollectionAdd";
|
||||
buttonCollectionAdd.Size = new Size(332, 46);
|
||||
buttonCollectionAdd.Size = new Size(383, 47);
|
||||
buttonCollectionAdd.TabIndex = 4;
|
||||
buttonCollectionAdd.Text = "Добавить коллекцию";
|
||||
buttonCollectionAdd.UseVisualStyleBackColor = true;
|
||||
@ -184,7 +192,7 @@
|
||||
// radioButtonList
|
||||
//
|
||||
radioButtonList.AutoSize = true;
|
||||
radioButtonList.Location = new Point(183, 115);
|
||||
radioButtonList.Location = new Point(211, 99);
|
||||
radioButtonList.Name = "radioButtonList";
|
||||
radioButtonList.Size = new Size(129, 37);
|
||||
radioButtonList.TabIndex = 3;
|
||||
@ -195,7 +203,7 @@
|
||||
// radioButtonMassive
|
||||
//
|
||||
radioButtonMassive.AutoSize = true;
|
||||
radioButtonMassive.Location = new Point(38, 115);
|
||||
radioButtonMassive.Location = new Point(44, 99);
|
||||
radioButtonMassive.Name = "radioButtonMassive";
|
||||
radioButtonMassive.Size = new Size(130, 37);
|
||||
radioButtonMassive.TabIndex = 2;
|
||||
@ -205,15 +213,15 @@
|
||||
//
|
||||
// textBoxCollectionName
|
||||
//
|
||||
textBoxCollectionName.Location = new Point(11, 59);
|
||||
textBoxCollectionName.Location = new Point(13, 48);
|
||||
textBoxCollectionName.Name = "textBoxCollectionName";
|
||||
textBoxCollectionName.Size = new Size(332, 41);
|
||||
textBoxCollectionName.Size = new Size(382, 41);
|
||||
textBoxCollectionName.TabIndex = 1;
|
||||
//
|
||||
// labelCollectionName
|
||||
//
|
||||
labelCollectionName.AutoSize = true;
|
||||
labelCollectionName.Location = new Point(57, 13);
|
||||
labelCollectionName.Location = new Point(54, 5);
|
||||
labelCollectionName.Name = "labelCollectionName";
|
||||
labelCollectionName.Size = new Size(263, 33);
|
||||
labelCollectionName.TabIndex = 0;
|
||||
@ -221,9 +229,9 @@
|
||||
//
|
||||
// buttonCreateCompany
|
||||
//
|
||||
buttonCreateCompany.Location = new Point(14, 572);
|
||||
buttonCreateCompany.Location = new Point(16, 547);
|
||||
buttonCreateCompany.Name = "buttonCreateCompany";
|
||||
buttonCreateCompany.Size = new Size(332, 46);
|
||||
buttonCreateCompany.Size = new Size(383, 47);
|
||||
buttonCreateCompany.TabIndex = 4;
|
||||
buttonCreateCompany.Text = "Создать компанию";
|
||||
buttonCreateCompany.UseVisualStyleBackColor = true;
|
||||
@ -236,28 +244,76 @@
|
||||
comboBoxSelectorCompany.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
comboBoxSelectorCompany.FormattingEnabled = true;
|
||||
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
|
||||
comboBoxSelectorCompany.Location = new Point(14, 525);
|
||||
comboBoxSelectorCompany.Location = new Point(16, 498);
|
||||
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
||||
comboBoxSelectorCompany.Size = new Size(332, 41);
|
||||
comboBoxSelectorCompany.Size = new Size(382, 41);
|
||||
comboBoxSelectorCompany.TabIndex = 1;
|
||||
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
pictureBox.Dock = DockStyle.Fill;
|
||||
pictureBox.Location = new Point(0, 0);
|
||||
pictureBox.Location = new Point(0, 41);
|
||||
pictureBox.Name = "pictureBox";
|
||||
pictureBox.Size = new Size(1290, 968);
|
||||
pictureBox.Size = new Size(1489, 963);
|
||||
pictureBox.TabIndex = 4;
|
||||
pictureBox.TabStop = false;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
menuStrip.ImageScalingSize = new Size(32, 32);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Padding = new Padding(7, 2, 0, 2);
|
||||
menuStrip.Size = new Size(1902, 41);
|
||||
menuStrip.TabIndex = 5;
|
||||
menuStrip.Text = "menuStrip";
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
|
||||
fileToolStripMenuItem.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
fileToolStripMenuItem.Size = new Size(93, 37);
|
||||
fileToolStripMenuItem.Text = "Файл";
|
||||
//
|
||||
// saveToolStripMenuItem
|
||||
//
|
||||
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||
saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||
saveToolStripMenuItem.Size = new Size(369, 44);
|
||||
saveToolStripMenuItem.Text = "Сохранение";
|
||||
saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
||||
//
|
||||
// loadToolStripMenuItem
|
||||
//
|
||||
loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
||||
loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
|
||||
loadToolStripMenuItem.Size = new Size(369, 44);
|
||||
loadToolStripMenuItem.Text = "Загрузка";
|
||||
loadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
saveFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
openFileDialog.FileName = "openFileDialog";
|
||||
openFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// FormBulldozerCollection
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||
AutoScaleDimensions = new SizeF(15F, 33F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1648, 968);
|
||||
ClientSize = new Size(1902, 1004);
|
||||
Controls.Add(pictureBox);
|
||||
Controls.Add(groupBoxTools);
|
||||
Controls.Add(menuStrip);
|
||||
Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
MainMenuStrip = menuStrip;
|
||||
Name = "FormBulldozerCollection";
|
||||
Text = "Коллекция бульдозеров";
|
||||
groupBoxTools.ResumeLayout(false);
|
||||
@ -266,7 +322,10 @@
|
||||
panelStorage.ResumeLayout(false);
|
||||
panelStorage.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -289,5 +348,11 @@
|
||||
private Button buttonCollectionDel;
|
||||
private Button buttonCreateCompany;
|
||||
private Panel panelCompanyTools;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem fileToolStripMenuItem;
|
||||
private ToolStripMenuItem saveToolStripMenuItem;
|
||||
private ToolStripMenuItem loadToolStripMenuItem;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private OpenFileDialog openFileDialog;
|
||||
}
|
||||
}
|
@ -10,6 +10,8 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using ProjectBulldozer.CollectionGenericObjects;
|
||||
using ProjectBulldozer.Drawnings;
|
||||
|
||||
namespace ProjectBulldozer;
|
||||
|
||||
@ -359,4 +361,50 @@ public partial class FormBulldozerCollection : Form
|
||||
panelCompanyTools.Enabled = true;
|
||||
RefreshListBoxItems();
|
||||
}
|
||||
|
||||
/// <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);
|
||||
RefreshListBoxItems();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Загрузка не удалась!", "Результат",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,4 +117,13 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>204, 17</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>447, 17</value>
|
||||
</metadata>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user
Запись следовало делать через StreamWriter