Финал
This commit is contained in:
parent
849deb0066
commit
8f8a8ffd62
@ -39,14 +39,21 @@
|
||||
ButtonDelObject = new Button();
|
||||
ButtonAddObject = new Button();
|
||||
textBoxStorageName = new TextBox();
|
||||
menuStrip = new MenuStrip();
|
||||
toolStripMenuItem1 = new ToolStripMenuItem();
|
||||
openFileDialog = new ToolStripMenuItem();
|
||||
saveFileDialog = new ToolStripMenuItem();
|
||||
openFileDialog_ = new OpenFileDialog();
|
||||
saveFileDialog_ = new OpenFileDialog();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
||||
panel1.SuspendLayout();
|
||||
panel2.SuspendLayout();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxCollection
|
||||
//
|
||||
pictureBoxCollection.Location = new Point(12, 12);
|
||||
pictureBoxCollection.Location = new Point(12, 40);
|
||||
pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
pictureBoxCollection.Size = new Size(680, 432);
|
||||
pictureBoxCollection.TabIndex = 0;
|
||||
@ -95,7 +102,7 @@
|
||||
panel1.Controls.Add(ButtonRemoveSPAU);
|
||||
panel1.Controls.Add(ButtonAddSPAU);
|
||||
panel1.Controls.Add(maskedTextBoxNumber);
|
||||
panel1.Location = new Point(711, 217);
|
||||
panel1.Location = new Point(711, 245);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(176, 227);
|
||||
panel1.TabIndex = 5;
|
||||
@ -106,9 +113,9 @@
|
||||
panel2.Controls.Add(ButtonDelObject);
|
||||
panel2.Controls.Add(ButtonAddObject);
|
||||
panel2.Controls.Add(textBoxStorageName);
|
||||
panel2.Location = new Point(711, 12);
|
||||
panel2.Location = new Point(711, 40);
|
||||
panel2.Name = "panel2";
|
||||
panel2.Size = new Size(174, 198);
|
||||
panel2.Size = new Size(174, 199);
|
||||
panel2.TabIndex = 6;
|
||||
//
|
||||
// listBoxStorages
|
||||
@ -148,14 +155,57 @@
|
||||
textBoxStorageName.Size = new Size(143, 27);
|
||||
textBoxStorageName.TabIndex = 0;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem1 });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(899, 28);
|
||||
menuStrip.TabIndex = 7;
|
||||
menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// toolStripMenuItem1
|
||||
//
|
||||
toolStripMenuItem1.DropDownItems.AddRange(new ToolStripItem[] { openFileDialog, saveFileDialog });
|
||||
toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||
toolStripMenuItem1.Size = new Size(59, 24);
|
||||
toolStripMenuItem1.Text = "Файл";
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
openFileDialog.Name = "openFileDialog";
|
||||
openFileDialog.Size = new Size(224, 26);
|
||||
openFileDialog.Text = "Открыть файл";
|
||||
openFileDialog.Click += LoadToolStripMenuItem_Click;
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
saveFileDialog.Name = "saveFileDialog";
|
||||
saveFileDialog.Size = new Size(224, 26);
|
||||
saveFileDialog.Text = "Сохранить файл";
|
||||
saveFileDialog.Click += SaveToolStripMenuItem_Click;
|
||||
//
|
||||
// openFileDialog_
|
||||
//
|
||||
openFileDialog_.FileName = "openFileDialog";
|
||||
openFileDialog_.Filter = "txt file | *.txt";
|
||||
//
|
||||
// saveFileDialog_
|
||||
//
|
||||
saveFileDialog_.FileName = "saveFileDialog";
|
||||
saveFileDialog_.Filter = "txt file | *.txt";
|
||||
//
|
||||
// FormSPAUCollection
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(899, 456);
|
||||
ClientSize = new Size(899, 484);
|
||||
Controls.Add(panel2);
|
||||
Controls.Add(panel1);
|
||||
Controls.Add(pictureBoxCollection);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Name = "FormSPAUCollection";
|
||||
Text = "FormSPAUCollection";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
||||
@ -163,7 +213,10 @@
|
||||
panel1.PerformLayout();
|
||||
panel2.ResumeLayout(false);
|
||||
panel2.PerformLayout();
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -179,5 +232,11 @@
|
||||
private TextBox textBoxStorageName;
|
||||
private Button ButtonDelObject;
|
||||
private ListBox listBoxStorages;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem toolStripMenuItem1;
|
||||
private ToolStripMenuItem openFileDialog;
|
||||
private ToolStripMenuItem saveFileDialog;
|
||||
private OpenFileDialog openFileDialog_;
|
||||
private OpenFileDialog saveFileDialog_;
|
||||
}
|
||||
}
|
@ -208,6 +208,49 @@ namespace SelfPropelledArtilleryUnit
|
||||
pictureBoxCollection.Image = obj.ShowSPAUs();
|
||||
}
|
||||
|
||||
// …
|
||||
/// <summary>
|
||||
/// Обработка нажатия "Сохранение"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (saveFileDialog_.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_storage.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 (_storage.LoadData(openFileDialog_.FileName))
|
||||
{
|
||||
MessageBox.Show("Загрузка прошлa успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
ReloadObjects();
|
||||
}
|
||||
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="openFileDialog_.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>283, 23</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog_.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>130, 23</value>
|
||||
</metadata>
|
||||
</root>
|
@ -119,7 +119,7 @@ namespace SelfPropelledArtilleryUnit.Generics
|
||||
}
|
||||
using FileStream fs = new(filename, FileMode.Create);
|
||||
byte[] info = new
|
||||
UTF8Encoding(true).GetBytes($"SpAUStorage{Environment.NewLine}{data}");
|
||||
UTF8Encoding(true).GetBytes($"SPAUStorage{Environment.NewLine}{data}");
|
||||
fs.Write(info, 0, info.Length);
|
||||
return true;
|
||||
}
|
||||
@ -144,13 +144,12 @@ namespace SelfPropelledArtilleryUnit.Generics
|
||||
bufferTextFromFile += temp.GetString(b);
|
||||
}
|
||||
}
|
||||
var strs = bufferTextFromFile.Split(new char[] { '\n', '\r' },
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
var strs = bufferTextFromFile.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (strs == null || strs.Length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!strs[0].StartsWith("CarStorage"))
|
||||
if (!strs[0].StartsWith("SPAUStorage"))
|
||||
{
|
||||
//если нет такой записи, то это не те данные
|
||||
return false;
|
||||
@ -158,16 +157,14 @@ namespace SelfPropelledArtilleryUnit.Generics
|
||||
_SPAUStorages.Clear();
|
||||
foreach (string data in strs)
|
||||
{
|
||||
string[] record = data.Split(_separatorForKeyValue,
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
string[] record = data.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (record.Length != 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
SPAUGenericCollection<DrawningSPAU, DrawningObjectSPAU>
|
||||
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)
|
||||
{
|
||||
DrawningSPAU? sPAU =
|
||||
|
Loading…
Reference in New Issue
Block a user