laba6
This commit is contained in:
parent
71b1caa094
commit
c549fc6a3c
@ -150,6 +150,8 @@ namespace Catamaran.Generics
|
|||||||
}
|
}
|
||||||
if (catamaran != null)
|
if (catamaran != null)
|
||||||
{
|
{
|
||||||
|
catamaran._pictureWidth = _pictureWidth;
|
||||||
|
catamaran._pictureHeight = _pictureHeight;
|
||||||
catamaran.SetPosition(i % width * _placeSizeWidth + _placeSizeWidth / 40,
|
catamaran.SetPosition(i % width * _placeSizeWidth + _placeSizeWidth / 40,
|
||||||
(height - diff) * _placeSizeHeight + _placeSizeHeight / 15);
|
(height - diff) * _placeSizeHeight + _placeSizeHeight / 15);
|
||||||
catamaran.DrawTransport(g);
|
catamaran.DrawTransport(g);
|
||||||
|
@ -112,56 +112,49 @@ namespace Catamaran.Generics
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
using FileStream fs = new(filename, FileMode.Create);
|
using (StreamWriter writer = new StreamWriter(filename))
|
||||||
byte[] info = new
|
{
|
||||||
UTF8Encoding(true).GetBytes($"CatamaranStorage{Environment.NewLine}{data}");
|
writer.Write($"CatamaranStorage{Environment.NewLine}{data}");
|
||||||
fs.Write(info, 0, info.Length);
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Загрузка информации по катамаранам в хранилище из файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="filename">Путь и имя файла</param>
|
|
||||||
/// <returns>true - загрузка прошла успешно, false - ошибка призагрузке данных</returns>
|
|
||||||
public bool LoadData(string filename)
|
public bool LoadData(string filename)
|
||||||
{
|
{
|
||||||
if (!File.Exists(filename))
|
if (!File.Exists(filename))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
string bufferTextFromFile = "";
|
|
||||||
using (FileStream fs = new(filename, FileMode.Open))
|
using (StreamReader fs = File.OpenText(filename))
|
||||||
{
|
{
|
||||||
byte[] b = new byte[fs.Length];
|
string str = fs.ReadLine();
|
||||||
UTF8Encoding temp = new(true);
|
if (str == null || str.Length == 0)
|
||||||
while (fs.Read(b, 0, b.Length) > 0)
|
|
||||||
{
|
|
||||||
bufferTextFromFile += temp.GetString(b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var strs = bufferTextFromFile.Split(new char[] { '\n', '\r' },
|
|
||||||
StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
if (strs == null || strs.Length == 0)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!strs[0].StartsWith("CatamaranStorage"))
|
if (!str.StartsWith("CatamaranStorage"))
|
||||||
{
|
{
|
||||||
//если нет такой записи, то это не те данные
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_catamaranStorages.Clear();
|
_catamaranStorages.Clear();
|
||||||
foreach (string data in strs)
|
string strs = "";
|
||||||
|
|
||||||
|
while ((strs = fs.ReadLine()) != null)
|
||||||
{
|
{
|
||||||
string[] record = data.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
if (strs == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (record.Length != 2)
|
if (record.Length != 2)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
CatamaransGenericCollection<DrawningCatamaran, DrawningObjectCatamaran>
|
CatamaransGenericCollection<DrawningCatamaran, DrawningObjectCatamaran> collection = new(_pictureWidth, _pictureHeight);
|
||||||
collection = new(_pictureWidth, _pictureHeight);
|
string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries);
|
||||||
string[] set = record[1].Split(_separatorRecords,
|
|
||||||
StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
foreach (string elem in set)
|
foreach (string elem in set)
|
||||||
{
|
{
|
||||||
DrawningCatamaran? catamaran = elem?.CreateDrawningCatamaran(_separatorForObject, _pictureWidth, _pictureHeight);
|
DrawningCatamaran? catamaran = elem?.CreateDrawningCatamaran(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||||
@ -179,3 +172,4 @@ namespace Catamaran.Generics
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
@ -20,11 +20,11 @@ namespace Catamaran.DrawningObjects
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина окна
|
/// Ширина окна
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int _pictureWidth;
|
public int _pictureWidth;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота окна
|
/// Высота окна
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int _pictureHeight;
|
public int _pictureHeight;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Левая координата прорисовки катамарана
|
/// Левая координата прорисовки катамарана
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -39,9 +39,16 @@
|
|||||||
this.ButtonRefreshCollection = new System.Windows.Forms.Button();
|
this.ButtonRefreshCollection = new System.Windows.Forms.Button();
|
||||||
this.ButtonRemoveCatamaran = new System.Windows.Forms.Button();
|
this.ButtonRemoveCatamaran = new System.Windows.Forms.Button();
|
||||||
this.ButtonAddCatamaran = new System.Windows.Forms.Button();
|
this.ButtonAddCatamaran = new System.Windows.Forms.Button();
|
||||||
|
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||||
|
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.SaveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||||
|
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
|
||||||
this.groupBoxTools.SuspendLayout();
|
this.groupBoxTools.SuspendLayout();
|
||||||
this.groupBoxSets.SuspendLayout();
|
this.groupBoxSets.SuspendLayout();
|
||||||
|
this.menuStrip.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// pictureBoxCollection
|
// pictureBoxCollection
|
||||||
@ -59,6 +66,7 @@
|
|||||||
this.groupBoxTools.Controls.Add(this.ButtonRefreshCollection);
|
this.groupBoxTools.Controls.Add(this.ButtonRefreshCollection);
|
||||||
this.groupBoxTools.Controls.Add(this.ButtonRemoveCatamaran);
|
this.groupBoxTools.Controls.Add(this.ButtonRemoveCatamaran);
|
||||||
this.groupBoxTools.Controls.Add(this.ButtonAddCatamaran);
|
this.groupBoxTools.Controls.Add(this.ButtonAddCatamaran);
|
||||||
|
this.groupBoxTools.Controls.Add(this.menuStrip);
|
||||||
this.groupBoxTools.Location = new System.Drawing.Point(739, 1);
|
this.groupBoxTools.Location = new System.Drawing.Point(739, 1);
|
||||||
this.groupBoxTools.Name = "groupBoxTools";
|
this.groupBoxTools.Name = "groupBoxTools";
|
||||||
this.groupBoxTools.Size = new System.Drawing.Size(147, 460);
|
this.groupBoxTools.Size = new System.Drawing.Size(147, 460);
|
||||||
@ -72,23 +80,23 @@
|
|||||||
this.groupBoxSets.Controls.Add(this.buttonDelObject);
|
this.groupBoxSets.Controls.Add(this.buttonDelObject);
|
||||||
this.groupBoxSets.Controls.Add(this.listBoxStorages);
|
this.groupBoxSets.Controls.Add(this.listBoxStorages);
|
||||||
this.groupBoxSets.Controls.Add(this.buttonAddObject);
|
this.groupBoxSets.Controls.Add(this.buttonAddObject);
|
||||||
this.groupBoxSets.Location = new System.Drawing.Point(3, 21);
|
this.groupBoxSets.Location = new System.Drawing.Point(3, 63);
|
||||||
this.groupBoxSets.Name = "groupBoxSets";
|
this.groupBoxSets.Name = "groupBoxSets";
|
||||||
this.groupBoxSets.Size = new System.Drawing.Size(138, 245);
|
this.groupBoxSets.Size = new System.Drawing.Size(138, 203);
|
||||||
this.groupBoxSets.TabIndex = 4;
|
this.groupBoxSets.TabIndex = 4;
|
||||||
this.groupBoxSets.TabStop = false;
|
this.groupBoxSets.TabStop = false;
|
||||||
this.groupBoxSets.Text = "Наборы";
|
this.groupBoxSets.Text = "Наборы";
|
||||||
//
|
//
|
||||||
// textBoxStorageName
|
// textBoxStorageName
|
||||||
//
|
//
|
||||||
this.textBoxStorageName.Location = new System.Drawing.Point(3, 36);
|
this.textBoxStorageName.Location = new System.Drawing.Point(6, 22);
|
||||||
this.textBoxStorageName.Name = "textBoxStorageName";
|
this.textBoxStorageName.Name = "textBoxStorageName";
|
||||||
this.textBoxStorageName.Size = new System.Drawing.Size(134, 23);
|
this.textBoxStorageName.Size = new System.Drawing.Size(130, 23);
|
||||||
this.textBoxStorageName.TabIndex = 4;
|
this.textBoxStorageName.TabIndex = 4;
|
||||||
//
|
//
|
||||||
// buttonDelObject
|
// buttonDelObject
|
||||||
//
|
//
|
||||||
this.buttonDelObject.Location = new System.Drawing.Point(3, 209);
|
this.buttonDelObject.Location = new System.Drawing.Point(3, 167);
|
||||||
this.buttonDelObject.Name = "buttonDelObject";
|
this.buttonDelObject.Name = "buttonDelObject";
|
||||||
this.buttonDelObject.Size = new System.Drawing.Size(134, 27);
|
this.buttonDelObject.Size = new System.Drawing.Size(134, 27);
|
||||||
this.buttonDelObject.TabIndex = 3;
|
this.buttonDelObject.TabIndex = 3;
|
||||||
@ -100,17 +108,17 @@
|
|||||||
//
|
//
|
||||||
this.listBoxStorages.FormattingEnabled = true;
|
this.listBoxStorages.FormattingEnabled = true;
|
||||||
this.listBoxStorages.ItemHeight = 15;
|
this.listBoxStorages.ItemHeight = 15;
|
||||||
this.listBoxStorages.Location = new System.Drawing.Point(3, 102);
|
this.listBoxStorages.Location = new System.Drawing.Point(6, 82);
|
||||||
this.listBoxStorages.Name = "listBoxStorages";
|
this.listBoxStorages.Name = "listBoxStorages";
|
||||||
this.listBoxStorages.Size = new System.Drawing.Size(134, 94);
|
this.listBoxStorages.Size = new System.Drawing.Size(132, 79);
|
||||||
this.listBoxStorages.TabIndex = 2;
|
this.listBoxStorages.TabIndex = 2;
|
||||||
this.listBoxStorages.SelectedIndexChanged += new System.EventHandler(this.ListBoxObjects_SelectedIndexChanged);
|
this.listBoxStorages.SelectedIndexChanged += new System.EventHandler(this.ListBoxObjects_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
// buttonAddObject
|
// buttonAddObject
|
||||||
//
|
//
|
||||||
this.buttonAddObject.Location = new System.Drawing.Point(3, 65);
|
this.buttonAddObject.Location = new System.Drawing.Point(6, 51);
|
||||||
this.buttonAddObject.Name = "buttonAddObject";
|
this.buttonAddObject.Name = "buttonAddObject";
|
||||||
this.buttonAddObject.Size = new System.Drawing.Size(134, 25);
|
this.buttonAddObject.Size = new System.Drawing.Size(131, 25);
|
||||||
this.buttonAddObject.TabIndex = 1;
|
this.buttonAddObject.TabIndex = 1;
|
||||||
this.buttonAddObject.Text = "Добавить набор";
|
this.buttonAddObject.Text = "Добавить набор";
|
||||||
this.buttonAddObject.UseVisualStyleBackColor = true;
|
this.buttonAddObject.UseVisualStyleBackColor = true;
|
||||||
@ -153,13 +161,51 @@
|
|||||||
this.ButtonAddCatamaran.UseVisualStyleBackColor = true;
|
this.ButtonAddCatamaran.UseVisualStyleBackColor = true;
|
||||||
this.ButtonAddCatamaran.Click += new System.EventHandler(this.ButtonAddCatamaran_Click);
|
this.ButtonAddCatamaran.Click += new System.EventHandler(this.ButtonAddCatamaran_Click);
|
||||||
//
|
//
|
||||||
|
// menuStrip
|
||||||
|
//
|
||||||
|
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.ToolStripMenuItem});
|
||||||
|
this.menuStrip.Location = new System.Drawing.Point(3, 19);
|
||||||
|
this.menuStrip.Name = "menuStrip";
|
||||||
|
this.menuStrip.Size = new System.Drawing.Size(141, 24);
|
||||||
|
this.menuStrip.TabIndex = 5;
|
||||||
|
this.menuStrip.Text = "menuStrip";
|
||||||
|
//
|
||||||
|
// ToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.SaveToolStripMenuItem,
|
||||||
|
this.LoadToolStripMenuItem});
|
||||||
|
this.ToolStripMenuItem.Name = "ToolStripMenuItem";
|
||||||
|
this.ToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
|
||||||
|
this.ToolStripMenuItem.Text = "Файл";
|
||||||
|
//
|
||||||
|
// SaveToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||||
|
this.SaveToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
|
this.SaveToolStripMenuItem.Text = "Сохранение";
|
||||||
|
this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// LoadToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||||
|
this.LoadToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
|
this.LoadToolStripMenuItem.Text = "Загрузка";
|
||||||
|
this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// openFileDialog
|
||||||
|
//
|
||||||
|
this.openFileDialog.FileName = "openFileDialog1";
|
||||||
|
//
|
||||||
// FormCatamaranCollection
|
// FormCatamaranCollection
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(884, 461);
|
this.ClientSize = new System.Drawing.Size(885, 461);
|
||||||
this.Controls.Add(this.groupBoxTools);
|
this.Controls.Add(this.groupBoxTools);
|
||||||
this.Controls.Add(this.pictureBoxCollection);
|
this.Controls.Add(this.pictureBoxCollection);
|
||||||
|
this.MainMenuStrip = this.menuStrip;
|
||||||
this.Name = "FormCatamaranCollection";
|
this.Name = "FormCatamaranCollection";
|
||||||
this.Text = "Набор катамаранов";
|
this.Text = "Набор катамаранов";
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
|
||||||
@ -167,6 +213,8 @@
|
|||||||
this.groupBoxTools.PerformLayout();
|
this.groupBoxTools.PerformLayout();
|
||||||
this.groupBoxSets.ResumeLayout(false);
|
this.groupBoxSets.ResumeLayout(false);
|
||||||
this.groupBoxSets.PerformLayout();
|
this.groupBoxSets.PerformLayout();
|
||||||
|
this.menuStrip.ResumeLayout(false);
|
||||||
|
this.menuStrip.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -184,5 +232,11 @@
|
|||||||
private Button buttonDelObject;
|
private Button buttonDelObject;
|
||||||
private ListBox listBoxStorages;
|
private ListBox listBoxStorages;
|
||||||
private TextBox textBoxStorageName;
|
private TextBox textBoxStorageName;
|
||||||
|
private MenuStrip menuStrip;
|
||||||
|
private ToolStripMenuItem ToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||||
|
private SaveFileDialog saveFileDialog;
|
||||||
|
private OpenFileDialog openFileDialog;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -60,13 +60,13 @@
|
|||||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>125, 17</value>
|
<value>125, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>258, 17</value>
|
<value>254, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>154</value>
|
<value>96</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
</root>
|
</root>
|
@ -145,7 +145,7 @@
|
|||||||
//
|
//
|
||||||
// panelYellow
|
// panelYellow
|
||||||
//
|
//
|
||||||
this.panelYellow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
|
this.panelYellow.BackColor = System.Drawing.Color.Gold;
|
||||||
this.panelYellow.Location = new System.Drawing.Point(187, 29);
|
this.panelYellow.Location = new System.Drawing.Point(187, 29);
|
||||||
this.panelYellow.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
this.panelYellow.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
this.panelYellow.Name = "panelYellow";
|
this.panelYellow.Name = "panelYellow";
|
||||||
|
Loading…
Reference in New Issue
Block a user