Done
This commit is contained in:
parent
fb2673aa4d
commit
0bda3325cc
@ -14,7 +14,7 @@ namespace Cruiser.Generics
|
||||
where T : DrawningCruiser
|
||||
where U : IMoveableObject
|
||||
{
|
||||
public IEnumerable<T?> GetTheBuses => _collection.GetCruiser();
|
||||
public IEnumerable<T?> GetCruiser => _collection.GetCruiser();
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
private readonly int _placeSizeWidth = 210;
|
||||
|
@ -16,13 +16,7 @@ namespace Cruiser.Generics
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
private static readonly char _separatorForKeyValue = '|';
|
||||
/// <summary>
|
||||
/// Разделитель для записей коллекции данных в файл
|
||||
/// </summary>
|
||||
private readonly char _separatorRecords = ';';
|
||||
/// <summary>
|
||||
/// Разделитель для записи информации по объекту в файл
|
||||
/// </summary>
|
||||
private static readonly char _separatorForObject = ':';
|
||||
public CruiserGenericStorage(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
@ -64,7 +58,7 @@ namespace Cruiser.Generics
|
||||
foreach (KeyValuePair<string, CruiserGenericCollection<DrawningCruiser, DrawningObjectCruiser>> record in _cruiserStorages)
|
||||
{
|
||||
StringBuilder records = new();
|
||||
foreach (DrawningCruiser? elem in record.Value.GetTheBuses)
|
||||
foreach (DrawningCruiser? elem in record.Value.GetCruiser)
|
||||
{
|
||||
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
||||
}
|
||||
@ -75,7 +69,7 @@ namespace Cruiser.Generics
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string toWrite = $"BusStorage{Environment.NewLine}{data}";
|
||||
string toWrite = $"CruiserStorage{Environment.NewLine}{data}";
|
||||
var strs = toWrite.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
using (StreamWriter sw = new(filename))
|
||||
@ -88,11 +82,6 @@ namespace Cruiser.Generics
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Загрузка информации по автобусам в хранилище из файла
|
||||
/// </summary>
|
||||
/// <param name="filename">Путь и имя файла</param>
|
||||
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
||||
public bool LoadData(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
@ -107,7 +96,7 @@ namespace Cruiser.Generics
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!strs[0].StartsWith("BusStorage"))
|
||||
if (!strs[0].StartsWith("CruiserStorage"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -124,11 +113,11 @@ namespace Cruiser.Generics
|
||||
string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string elem in set)
|
||||
{
|
||||
DrawningCruiser? bus =
|
||||
DrawningCruiser? cruiser =
|
||||
elem?.CreateDrawningCruiser(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||
if (bus != null)
|
||||
if (cruiser != null)
|
||||
{
|
||||
if (!(collection + bus))
|
||||
if (!(collection + cruiser))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -141,7 +130,5 @@ namespace Cruiser.Generics
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,4 +41,3 @@ namespace Cruiser.DrawningObjects
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
11
Cruiser/Cruiser/FormCruiserCollection.Designer.cs
generated
11
Cruiser/Cruiser/FormCruiserCollection.Designer.cs
generated
@ -148,6 +148,11 @@
|
||||
// openFileDialog
|
||||
//
|
||||
this.openFileDialog.FileName = "openFileDialog";
|
||||
this.openFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
this.saveFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
@ -158,7 +163,7 @@
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Size = new System.Drawing.Size(904, 33);
|
||||
this.menuStrip.TabIndex = 2;
|
||||
this.menuStrip.Text = "menuStrip1";
|
||||
this.menuStrip.Text = "menuStrip";
|
||||
//
|
||||
// FileToolStripMenuItem
|
||||
//
|
||||
@ -172,14 +177,16 @@
|
||||
// SaveToolStripMenuItem
|
||||
//
|
||||
this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||
this.SaveToolStripMenuItem.Size = new System.Drawing.Size(273, 34);
|
||||
this.SaveToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
|
||||
this.SaveToolStripMenuItem.Text = "Сохранить";
|
||||
this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click);
|
||||
//
|
||||
// LoadToolStripMenuItem
|
||||
//
|
||||
this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||
this.LoadToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
|
||||
this.LoadToolStripMenuItem.Text = "Загрузить";
|
||||
this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click);
|
||||
//
|
||||
// FormCruiserCollection
|
||||
//
|
||||
|
@ -155,11 +155,6 @@ namespace Cruiser
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработка нажатия "Загрузка"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
|
8
Cruiser/Cruiser/FormCruiserConfig.Designer.cs
generated
8
Cruiser/Cruiser/FormCruiserConfig.Designer.cs
generated
@ -120,6 +120,8 @@
|
||||
this.panelOrchid.Name = "panelOrchid";
|
||||
this.panelOrchid.Size = new System.Drawing.Size(312, 261);
|
||||
this.panelOrchid.TabIndex = 9;
|
||||
this.panelOrchid.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
|
||||
this.panelOrchid.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
|
||||
//
|
||||
// label_addit_color
|
||||
//
|
||||
@ -204,7 +206,7 @@
|
||||
//
|
||||
// panelPink
|
||||
//
|
||||
this.panelPink.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
|
||||
this.panelPink.BackColor = System.Drawing.Color.Violet;
|
||||
this.panelPink.Location = new System.Drawing.Point(180, 153);
|
||||
this.panelPink.Name = "panelPink";
|
||||
this.panelPink.Size = new System.Drawing.Size(53, 49);
|
||||
@ -212,7 +214,7 @@
|
||||
//
|
||||
// panelViolet
|
||||
//
|
||||
this.panelViolet.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
|
||||
this.panelViolet.BackColor = System.Drawing.Color.DarkTurquoise;
|
||||
this.panelViolet.Location = new System.Drawing.Point(108, 153);
|
||||
this.panelViolet.Name = "panelViolet";
|
||||
this.panelViolet.Size = new System.Drawing.Size(53, 49);
|
||||
@ -220,7 +222,7 @@
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
this.panelBlue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
|
||||
this.panelBlue.BackColor = System.Drawing.Color.PaleTurquoise;
|
||||
this.panelBlue.Location = new System.Drawing.Point(34, 153);
|
||||
this.panelBlue.Name = "panelBlue";
|
||||
this.panelBlue.Size = new System.Drawing.Size(53, 49);
|
||||
|
Loading…
Reference in New Issue
Block a user