PIbd-23. Panina A. D. Lab _6 #14
@ -14,6 +14,7 @@ namespace Cruiser.Generics
|
||||
where T : DrawningCruiser
|
||||
where U : IMoveableObject
|
||||
{
|
||||
public IEnumerable<T?> GetCruiser => _collection.GetCruiser();
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
private readonly int _placeSizeWidth = 210;
|
||||
@ -89,5 +90,7 @@ namespace Cruiser.Generics
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -15,6 +15,9 @@ namespace Cruiser.Generics
|
||||
public List<string> Keys => _cruiserStorages.Keys.ToList();
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
private static readonly char _separatorForKeyValue = '|';
|
||||
private readonly char _separatorRecords = ';';
|
||||
private static readonly char _separatorForObject = ':';
|
||||
public CruiserGenericStorage(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_cruiserStorages = new Dictionary<string, CruiserGenericCollection<DrawningCruiser, DrawningObjectCruiser>>();
|
||||
@ -45,6 +48,87 @@ namespace Cruiser.Generics
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool SaveData(string filename)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
File.Delete(filename);
|
||||
}
|
||||
StringBuilder data = new();
|
||||
foreach (KeyValuePair<string, CruiserGenericCollection<DrawningCruiser, DrawningObjectCruiser>> record in _cruiserStorages)
|
||||
{
|
||||
StringBuilder records = new();
|
||||
foreach (DrawningCruiser? elem in record.Value.GetCruiser)
|
||||
{
|
||||
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
||||
}
|
||||
data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}");
|
||||
}
|
||||
|
||||
if (data.Length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string toWrite = $"CruiserStorage{Environment.NewLine}{data}";
|
||||
var strs = toWrite.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
using (StreamWriter sw = new(filename))
|
||||
{
|
||||
foreach (var str in strs)
|
||||
{
|
||||
sw.WriteLine(str);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool LoadData(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
using (StreamReader sr = new(filename))
|
||||
{
|
||||
string str = sr.ReadLine();
|
||||
var strs = str.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (strs == null || strs.Length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!strs[0].StartsWith("CruiserStorage"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_cruiserStorages.Clear();
|
||||
do
|
||||
{
|
||||
string[] record = str.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (record.Length != 2)
|
||||
{
|
||||
str = sr.ReadLine();
|
||||
continue;
|
||||
}
|
||||
CruiserGenericCollection<DrawningCruiser, DrawningObjectCruiser> collection = new(_pictureWidth, _pictureHeight);
|
||||
string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string elem in set)
|
||||
{
|
||||
DrawningCruiser? cruiser =
|
||||
elem?.CreateDrawningCruiser(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||
if (cruiser != null)
|
||||
{
|
||||
if (!(collection + cruiser))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
_cruiserStorages.Add(record[0], collection);
|
||||
|
||||
str = sr.ReadLine();
|
||||
} while (str != null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -119,7 +119,7 @@ width, int height, int cruiserWidth, int cruiserHeight)
|
||||
g.FillRectangle(br, _startPosX + 10, _startPosY + 15, 10, 30);
|
||||
g.FillRectangle(br, _startPosX + 90, _startPosY + 15, 10, 30);
|
||||
g.FillRectangle(br, _startPosX + 20, _startPosY + 5, 70, 50);
|
||||
Point[] points = new Point[3];
|
||||
Point[] points = new Point[3];//
|
||||
points[0] = new Point(_startPosX + 100, _startPosY + 5);
|
||||
points[1] = new Point(_startPosX + 100, _startPosY + 55);
|
||||
points[2] = new Point(_startPosX + 100 + 50, _startPosY + 50 / 2);
|
||||
@ -132,4 +132,5 @@ width, int height, int cruiserWidth, int cruiserHeight)
|
||||
_startPosY + 19, 30, 25);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
43
Cruiser/Cruiser/ExtentionDrawingCruiser.cs
Normal file
43
Cruiser/Cruiser/ExtentionDrawingCruiser.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Cruiser.Entities;
|
||||
|
||||
namespace Cruiser.DrawningObjects
|
||||
{
|
||||
public static class ExtentionDrawingCruiser
|
||||
{
|
||||
public static DrawningCruiser? CreateDrawningCruiser(this string info, char separatorForObject, int width, int height)
|
||||
{
|
||||
string[] strs = info.Split(separatorForObject);
|
||||
if (strs.Length == 3)
|
||||
{
|
||||
return new DrawningCruiser(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
|
||||
}
|
||||
if (strs.Length == 7)
|
||||
{
|
||||
return new DrawningAdvancedCruiser(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]),
|
||||
Color.FromName(strs[3]), Convert.ToBoolean(strs[4]), Convert.ToBoolean(strs[5]), width, height);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static string GetDataForSave(this DrawningCruiser drawningcruiser, char separatorForObject)
|
||||
{
|
||||
var cruiser = drawningcruiser.EntityCruiser;
|
||||
if (cruiser == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
var str = $"{cruiser.Speed}{separatorForObject}{cruiser.Weight}{separatorForObject}{cruiser.BodyColor.Name}";
|
||||
if (cruiser is not EntityAdvancedCruiser advancedCruiser)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
return
|
||||
$"{str}{separatorForObject}{advancedCruiser.AdditionalColor.Name}{separatorForObject}" +
|
||||
$"{separatorForObject}{advancedCruiser.HelicopterPad}{separatorForObject}{advancedCruiser.Coating}";
|
||||
}
|
||||
}
|
||||
}
|
222
Cruiser/Cruiser/FormCruiserCollection.Designer.cs
generated
222
Cruiser/Cruiser/FormCruiserCollection.Designer.cs
generated
@ -17,26 +17,33 @@
|
||||
{
|
||||
this.pictureBoxCruiser = new System.Windows.Forms.PictureBox();
|
||||
this.panelCruiser = new System.Windows.Forms.Panel();
|
||||
this.panelSet = new System.Windows.Forms.Panel();
|
||||
this.textBoxSet = new System.Windows.Forms.TextBox();
|
||||
this.ButtonAddObject = new System.Windows.Forms.Button();
|
||||
this.listBoxStorages = new System.Windows.Forms.ListBox();
|
||||
this.ButtonDelObject = new System.Windows.Forms.Button();
|
||||
this.ButtonAddCruiser = new System.Windows.Forms.Button();
|
||||
this.textBoxCruiser = new System.Windows.Forms.TextBox();
|
||||
this.ButtonRemoveCruiser = new System.Windows.Forms.Button();
|
||||
this.ButtonRefreshCollection = new System.Windows.Forms.Button();
|
||||
this.ButtonRemoveCruiser = new System.Windows.Forms.Button();
|
||||
this.textBoxCruiser = new System.Windows.Forms.TextBox();
|
||||
this.ButtonAddCruiser = new System.Windows.Forms.Button();
|
||||
this.panelSet = new System.Windows.Forms.Panel();
|
||||
this.ButtonDelObject = new System.Windows.Forms.Button();
|
||||
this.listBoxStorages = new System.Windows.Forms.ListBox();
|
||||
this.ButtonAddObject = new System.Windows.Forms.Button();
|
||||
this.textBoxSet = new System.Windows.Forms.TextBox();
|
||||
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.FileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SaveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCruiser)).BeginInit();
|
||||
this.panelCruiser.SuspendLayout();
|
||||
this.panelSet.SuspendLayout();
|
||||
this.menuStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxCruiser
|
||||
//
|
||||
this.pictureBoxCruiser.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxCruiser.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxCruiser.Location = new System.Drawing.Point(0, 33);
|
||||
this.pictureBoxCruiser.Name = "pictureBoxCruiser";
|
||||
this.pictureBoxCruiser.Size = new System.Drawing.Size(904, 510);
|
||||
this.pictureBoxCruiser.Size = new System.Drawing.Size(904, 477);
|
||||
this.pictureBoxCruiser.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBoxCruiser.TabIndex = 0;
|
||||
this.pictureBoxCruiser.TabStop = false;
|
||||
@ -53,70 +60,15 @@
|
||||
this.panelCruiser.Size = new System.Drawing.Size(221, 486);
|
||||
this.panelCruiser.TabIndex = 1;
|
||||
//
|
||||
// panelSet
|
||||
// ButtonRefreshCollection
|
||||
//
|
||||
this.panelSet.Controls.Add(this.ButtonDelObject);
|
||||
this.panelSet.Controls.Add(this.listBoxStorages);
|
||||
this.panelSet.Controls.Add(this.ButtonAddObject);
|
||||
this.panelSet.Controls.Add(this.textBoxSet);
|
||||
this.panelSet.Location = new System.Drawing.Point(22, 19);
|
||||
this.panelSet.Name = "panelSet";
|
||||
this.panelSet.Size = new System.Drawing.Size(185, 241);
|
||||
this.panelSet.TabIndex = 0;
|
||||
//
|
||||
// textBoxSet
|
||||
//
|
||||
this.textBoxSet.Location = new System.Drawing.Point(38, 21);
|
||||
this.textBoxSet.Name = "textBoxSet";
|
||||
this.textBoxSet.Size = new System.Drawing.Size(118, 31);
|
||||
this.textBoxSet.TabIndex = 0;
|
||||
//
|
||||
// ButtonAddObject
|
||||
//
|
||||
this.ButtonAddObject.Location = new System.Drawing.Point(18, 58);
|
||||
this.ButtonAddObject.Name = "ButtonAddObject";
|
||||
this.ButtonAddObject.Size = new System.Drawing.Size(153, 51);
|
||||
this.ButtonAddObject.TabIndex = 2;
|
||||
this.ButtonAddObject.Text = "Создать набор";
|
||||
this.ButtonAddObject.UseVisualStyleBackColor = true;
|
||||
this.ButtonAddObject.Click += new System.EventHandler(this.ButtonAddObject_Click);
|
||||
//
|
||||
// listBoxStorages
|
||||
//
|
||||
this.listBoxStorages.FormattingEnabled = true;
|
||||
this.listBoxStorages.ItemHeight = 25;
|
||||
this.listBoxStorages.Location = new System.Drawing.Point(49, 115);
|
||||
this.listBoxStorages.Name = "listBoxStorages";
|
||||
this.listBoxStorages.Size = new System.Drawing.Size(97, 54);
|
||||
this.listBoxStorages.TabIndex = 3;
|
||||
this.listBoxStorages.SelectedIndexChanged += new System.EventHandler(this.listBoxObjects_SelectedIndexChanged);
|
||||
//
|
||||
// ButtonDelObject
|
||||
//
|
||||
this.ButtonDelObject.Location = new System.Drawing.Point(18, 175);
|
||||
this.ButtonDelObject.Name = "ButtonDelObject";
|
||||
this.ButtonDelObject.Size = new System.Drawing.Size(153, 47);
|
||||
this.ButtonDelObject.TabIndex = 2;
|
||||
this.ButtonDelObject.Text = "Удалить набор";
|
||||
this.ButtonDelObject.UseVisualStyleBackColor = true;
|
||||
this.ButtonDelObject.Click += new System.EventHandler(this.ButtonDelObject_Click);
|
||||
//
|
||||
// ButtonAddCruiser
|
||||
//
|
||||
this.ButtonAddCruiser.Location = new System.Drawing.Point(45, 266);
|
||||
this.ButtonAddCruiser.Name = "ButtonAddCruiser";
|
||||
this.ButtonAddCruiser.Size = new System.Drawing.Size(133, 38);
|
||||
this.ButtonAddCruiser.TabIndex = 2;
|
||||
this.ButtonAddCruiser.Text = "Добавить";
|
||||
this.ButtonAddCruiser.UseVisualStyleBackColor = true;
|
||||
this.ButtonAddCruiser.Click += new System.EventHandler(this.ButtonAddCruiser_Click);
|
||||
//
|
||||
// textBoxCruiser
|
||||
//
|
||||
this.textBoxCruiser.Location = new System.Drawing.Point(45, 330);
|
||||
this.textBoxCruiser.Name = "textBoxCruiser";
|
||||
this.textBoxCruiser.Size = new System.Drawing.Size(133, 31);
|
||||
this.textBoxCruiser.TabIndex = 3;
|
||||
this.ButtonRefreshCollection.Location = new System.Drawing.Point(45, 435);
|
||||
this.ButtonRefreshCollection.Name = "ButtonRefreshCollection";
|
||||
this.ButtonRefreshCollection.Size = new System.Drawing.Size(138, 41);
|
||||
this.ButtonRefreshCollection.TabIndex = 2;
|
||||
this.ButtonRefreshCollection.Text = "Обновить";
|
||||
this.ButtonRefreshCollection.UseVisualStyleBackColor = true;
|
||||
this.ButtonRefreshCollection.Click += new System.EventHandler(this.ButtonRefreshCollection_Click);
|
||||
//
|
||||
// ButtonRemoveCruiser
|
||||
//
|
||||
@ -128,15 +80,113 @@
|
||||
this.ButtonRemoveCruiser.UseVisualStyleBackColor = true;
|
||||
this.ButtonRemoveCruiser.Click += new System.EventHandler(this.ButtonRemoveCruiser_Click);
|
||||
//
|
||||
// ButtonRefreshCollection
|
||||
// textBoxCruiser
|
||||
//
|
||||
this.ButtonRefreshCollection.Location = new System.Drawing.Point(45, 435);
|
||||
this.ButtonRefreshCollection.Name = "ButtonRefreshCollection";
|
||||
this.ButtonRefreshCollection.Size = new System.Drawing.Size(138, 41);
|
||||
this.ButtonRefreshCollection.TabIndex = 2;
|
||||
this.ButtonRefreshCollection.Text = "Обновить";
|
||||
this.ButtonRefreshCollection.UseVisualStyleBackColor = true;
|
||||
this.ButtonRefreshCollection.Click += new System.EventHandler(this.ButtonRefreshCollection_Click);
|
||||
this.textBoxCruiser.Location = new System.Drawing.Point(45, 330);
|
||||
this.textBoxCruiser.Name = "textBoxCruiser";
|
||||
this.textBoxCruiser.Size = new System.Drawing.Size(133, 31);
|
||||
this.textBoxCruiser.TabIndex = 3;
|
||||
//
|
||||
// ButtonAddCruiser
|
||||
//
|
||||
this.ButtonAddCruiser.Location = new System.Drawing.Point(45, 266);
|
||||
this.ButtonAddCruiser.Name = "ButtonAddCruiser";
|
||||
this.ButtonAddCruiser.Size = new System.Drawing.Size(133, 38);
|
||||
this.ButtonAddCruiser.TabIndex = 2;
|
||||
this.ButtonAddCruiser.Text = "Добавить";
|
||||
this.ButtonAddCruiser.UseVisualStyleBackColor = true;
|
||||
this.ButtonAddCruiser.Click += new System.EventHandler(this.ButtonAddCruiser_Click);
|
||||
//
|
||||
// panelSet
|
||||
//
|
||||
this.panelSet.Controls.Add(this.ButtonDelObject);
|
||||
this.panelSet.Controls.Add(this.listBoxStorages);
|
||||
this.panelSet.Controls.Add(this.ButtonAddObject);
|
||||
this.panelSet.Controls.Add(this.textBoxSet);
|
||||
this.panelSet.Location = new System.Drawing.Point(22, 19);
|
||||
this.panelSet.Name = "panelSet";
|
||||
this.panelSet.Size = new System.Drawing.Size(185, 241);
|
||||
this.panelSet.TabIndex = 0;
|
||||
//
|
||||
// ButtonDelObject
|
||||
//
|
||||
this.ButtonDelObject.Location = new System.Drawing.Point(18, 175);
|
||||
this.ButtonDelObject.Name = "ButtonDelObject";
|
||||
this.ButtonDelObject.Size = new System.Drawing.Size(153, 47);
|
||||
this.ButtonDelObject.TabIndex = 2;
|
||||
this.ButtonDelObject.Text = "Удалить набор";
|
||||
this.ButtonDelObject.UseVisualStyleBackColor = true;
|
||||
this.ButtonDelObject.Click += new System.EventHandler(this.ButtonDelObject_Click);
|
||||
//
|
||||
// listBoxStorages
|
||||
//
|
||||
this.listBoxStorages.FormattingEnabled = true;
|
||||
this.listBoxStorages.ItemHeight = 25;
|
||||
this.listBoxStorages.Location = new System.Drawing.Point(49, 115);
|
||||
this.listBoxStorages.Name = "listBoxStorages";
|
||||
this.listBoxStorages.Size = new System.Drawing.Size(97, 54);
|
||||
this.listBoxStorages.TabIndex = 3;
|
||||
this.listBoxStorages.SelectedIndexChanged += new System.EventHandler(this.listBoxObjects_SelectedIndexChanged);
|
||||
//
|
||||
// ButtonAddObject
|
||||
//
|
||||
this.ButtonAddObject.Location = new System.Drawing.Point(18, 58);
|
||||
this.ButtonAddObject.Name = "ButtonAddObject";
|
||||
this.ButtonAddObject.Size = new System.Drawing.Size(153, 51);
|
||||
this.ButtonAddObject.TabIndex = 2;
|
||||
this.ButtonAddObject.Text = "Создать набор";
|
||||
this.ButtonAddObject.UseVisualStyleBackColor = true;
|
||||
this.ButtonAddObject.Click += new System.EventHandler(this.ButtonAddObject_Click);
|
||||
//
|
||||
// textBoxSet
|
||||
//
|
||||
this.textBoxSet.Location = new System.Drawing.Point(38, 21);
|
||||
this.textBoxSet.Name = "textBoxSet";
|
||||
this.textBoxSet.Size = new System.Drawing.Size(118, 31);
|
||||
this.textBoxSet.TabIndex = 0;
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
this.openFileDialog.FileName = "openFileDialog";
|
||||
this.openFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
this.saveFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
this.menuStrip.ImageScalingSize = new System.Drawing.Size(24, 24);
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.FileToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Size = new System.Drawing.Size(904, 33);
|
||||
this.menuStrip.TabIndex = 2;
|
||||
this.menuStrip.Text = "menuStrip";
|
||||
//
|
||||
// FileToolStripMenuItem
|
||||
//
|
||||
this.FileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.SaveToolStripMenuItem,
|
||||
this.LoadToolStripMenuItem});
|
||||
this.FileToolStripMenuItem.Name = "FileToolStripMenuItem";
|
||||
this.FileToolStripMenuItem.Size = new System.Drawing.Size(69, 29);
|
||||
this.FileToolStripMenuItem.Text = "Файл";
|
||||
//
|
||||
// SaveToolStripMenuItem
|
||||
//
|
||||
this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||
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
|
||||
//
|
||||
@ -145,6 +195,8 @@
|
||||
this.ClientSize = new System.Drawing.Size(904, 510);
|
||||
this.Controls.Add(this.panelCruiser);
|
||||
this.Controls.Add(this.pictureBoxCruiser);
|
||||
this.Controls.Add(this.menuStrip);
|
||||
this.MainMenuStrip = this.menuStrip;
|
||||
this.Name = "FormCruiserCollection";
|
||||
this.Text = "FormCruiserCollection";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCruiser)).EndInit();
|
||||
@ -152,6 +204,8 @@
|
||||
this.panelCruiser.PerformLayout();
|
||||
this.panelSet.ResumeLayout(false);
|
||||
this.panelSet.PerformLayout();
|
||||
this.menuStrip.ResumeLayout(false);
|
||||
this.menuStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -169,5 +223,11 @@
|
||||
private Button ButtonRemoveCruiser;
|
||||
private TextBox textBoxCruiser;
|
||||
private Button ButtonRefreshCollection;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem FileToolStripMenuItem;
|
||||
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -140,5 +140,38 @@ namespace Cruiser
|
||||
}
|
||||
pictureBoxCruiser.Image = obj.ShowCruisers();
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_storage.LoadData(openFileDialog.FileName))
|
||||
{
|
||||
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
foreach (var collection in _storage.Keys)
|
||||
{
|
||||
listBoxStorages.Items.Add(collection);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не загрузилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -57,4 +57,13 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="openFileDialog.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>201, 17</value>
|
||||
</metadata>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>379, 17</value>
|
||||
</metadata>
|
||||
</root>
|
56
Cruiser/Cruiser/FormCruiserConfig.Designer.cs
generated
56
Cruiser/Cruiser/FormCruiserConfig.Designer.cs
generated
@ -32,14 +32,14 @@
|
||||
this.checkBoxMissileSilos = new System.Windows.Forms.CheckBox();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.panelColor = new System.Windows.Forms.Panel();
|
||||
this.panelOrchid = new System.Windows.Forms.Panel();
|
||||
this.label_addit_color = new System.Windows.Forms.Label();
|
||||
this.label_color = new System.Windows.Forms.Label();
|
||||
this.pictureBoxCruiser = new System.Windows.Forms.PictureBox();
|
||||
this.labelAdvanced = new System.Windows.Forms.Label();
|
||||
this.labelBasic = new System.Windows.Forms.Label();
|
||||
this.groupBoxColor = new System.Windows.Forms.GroupBox();
|
||||
this.panelOrchid = new System.Windows.Forms.Panel();
|
||||
this.panelColor = new System.Windows.Forms.Panel();
|
||||
this.panelPink = new System.Windows.Forms.Panel();
|
||||
this.panelViolet = new System.Windows.Forms.Panel();
|
||||
this.panelBlue = new System.Windows.Forms.Panel();
|
||||
@ -53,7 +53,7 @@
|
||||
this.labelWeight = new System.Windows.Forms.Label();
|
||||
this.labelSpeed = new System.Windows.Forms.Label();
|
||||
this.groupBoxCruiser.SuspendLayout();
|
||||
this.panelColor.SuspendLayout();
|
||||
this.panelOrchid.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCruiser)).BeginInit();
|
||||
this.groupBoxColor.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
|
||||
@ -65,7 +65,7 @@
|
||||
this.groupBoxCruiser.Controls.Add(this.checkBoxMissileSilos);
|
||||
this.groupBoxCruiser.Controls.Add(this.buttonCancel);
|
||||
this.groupBoxCruiser.Controls.Add(this.buttonAdd);
|
||||
this.groupBoxCruiser.Controls.Add(this.panelColor);
|
||||
this.groupBoxCruiser.Controls.Add(this.panelOrchid);
|
||||
this.groupBoxCruiser.Controls.Add(this.labelAdvanced);
|
||||
this.groupBoxCruiser.Controls.Add(this.labelBasic);
|
||||
this.groupBoxCruiser.Controls.Add(this.groupBoxColor);
|
||||
@ -110,18 +110,18 @@
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// panelColor
|
||||
// panelOrchid
|
||||
//
|
||||
this.panelColor.AllowDrop = true;
|
||||
this.panelColor.Controls.Add(this.label_addit_color);
|
||||
this.panelColor.Controls.Add(this.label_color);
|
||||
this.panelColor.Controls.Add(this.pictureBoxCruiser);
|
||||
this.panelColor.Location = new System.Drawing.Point(822, 45);
|
||||
this.panelColor.Name = "panelColor";
|
||||
this.panelColor.Size = new System.Drawing.Size(312, 261);
|
||||
this.panelColor.TabIndex = 9;
|
||||
this.panelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
|
||||
this.panelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
|
||||
this.panelOrchid.AllowDrop = true;
|
||||
this.panelOrchid.Controls.Add(this.label_addit_color);
|
||||
this.panelOrchid.Controls.Add(this.label_color);
|
||||
this.panelOrchid.Controls.Add(this.pictureBoxCruiser);
|
||||
this.panelOrchid.Location = new System.Drawing.Point(822, 45);
|
||||
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
|
||||
//
|
||||
@ -181,7 +181,7 @@
|
||||
//
|
||||
// groupBoxColor
|
||||
//
|
||||
this.groupBoxColor.Controls.Add(this.panelOrchid);
|
||||
this.groupBoxColor.Controls.Add(this.panelColor);
|
||||
this.groupBoxColor.Controls.Add(this.panelPink);
|
||||
this.groupBoxColor.Controls.Add(this.panelViolet);
|
||||
this.groupBoxColor.Controls.Add(this.panelBlue);
|
||||
@ -196,17 +196,17 @@
|
||||
this.groupBoxColor.TabStop = false;
|
||||
this.groupBoxColor.Text = "Цвета";
|
||||
//
|
||||
// panelOrchid
|
||||
// panelColor
|
||||
//
|
||||
this.panelOrchid.BackColor = System.Drawing.Color.Fuchsia;
|
||||
this.panelOrchid.Location = new System.Drawing.Point(264, 153);
|
||||
this.panelOrchid.Name = "panelOrchid";
|
||||
this.panelOrchid.Size = new System.Drawing.Size(53, 49);
|
||||
this.panelOrchid.TabIndex = 7;
|
||||
this.panelColor.BackColor = System.Drawing.Color.Fuchsia;
|
||||
this.panelColor.Location = new System.Drawing.Point(264, 153);
|
||||
this.panelColor.Name = "panelColor";
|
||||
this.panelColor.Size = new System.Drawing.Size(53, 49);
|
||||
this.panelColor.TabIndex = 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);
|
||||
@ -214,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);
|
||||
@ -222,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);
|
||||
@ -342,7 +342,7 @@
|
||||
this.Text = "Создание объекта";
|
||||
this.groupBoxCruiser.ResumeLayout(false);
|
||||
this.groupBoxCruiser.PerformLayout();
|
||||
this.panelColor.ResumeLayout(false);
|
||||
this.panelOrchid.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCruiser)).EndInit();
|
||||
this.groupBoxColor.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
|
||||
@ -356,7 +356,7 @@
|
||||
private GroupBox groupBoxCruiser;
|
||||
private Button buttonCancel;
|
||||
private Button buttonAdd;
|
||||
private Panel panelColor;
|
||||
private Panel panelOrchid;
|
||||
private Label label_addit_color;
|
||||
private Label label_color;
|
||||
private PictureBox pictureBoxCruiser;
|
||||
@ -371,7 +371,7 @@
|
||||
private Label labelWeight;
|
||||
private Label labelSpeed;
|
||||
private CheckBox checkBoxMissileSilos;
|
||||
private Panel panelOrchid;
|
||||
private Panel panelColor;
|
||||
private Panel panelPink;
|
||||
private Panel panelViolet;
|
||||
private Panel panelBlue;
|
||||
|
@ -27,7 +27,7 @@ namespace Cruiser
|
||||
panelPink.MouseDown += PanelColor_MouseDown;
|
||||
panelViolet.MouseDown += PanelColor_MouseDown;
|
||||
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||
panelColor.MouseDown += PanelColor_MouseDown;
|
||||
panelOrchid.MouseDown += PanelColor_MouseDown;
|
||||
buttonCancel.Click += (s, e) => Close();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user