This commit is contained in:
AnnaLioness 2023-11-17 22:12:13 +04:00
parent 086fa9134b
commit 21cf14be5b
11 changed files with 412 additions and 362 deletions

View File

@ -1,9 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33122.133
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab1ContainersShip", "Lab1ContainersShip\Lab1ContainersShip.csproj", "{AFA56719-1551-4DFA-9EC2-1FD7AB801A5E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab1ContainersShip", "Lab1ContainersShip\Lab1ContainersShip.csproj", "{AFA56719-1551-4DFA-9EC2-1FD7AB801A5E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -0,0 +1,68 @@
using Lab1ContainersShip.DrawingObjects;
using Lab1ContainersShip.Entities;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Lab1ContainersShip.Entities;
namespace Lab1ContainersShip.DrawingObjects
{
public static class ExtensionShip
{
/// <summary>
/// Создание объекта из строки
/// </summary>
/// <param name="info">Строка с данными для создания объекта</param>
/// <param name="separatorForObject">Разделитель даннных</param>
/// <param name="width">Ширина</param>
/// <param name="height">Высота</param>
/// <returns>Объект</returns>
public static DrawingShip CreateDrawingShip(this string info, char
separatorForObject, int width, int height)
{
string[] strs = info.Split(separatorForObject);
if (strs.Length == 3)
{
return new DrawingShip(Convert.ToInt32(strs[0]),
Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
}
if (strs.Length == 6)
{
return new DrawingContainerShip(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;
}
/// <summary>
/// Получение данных для сохранения в файл
/// </summary>
/// <param name="drawningCar">Сохраняемый объект</param>
/// <param name="separatorForObject">Разделитель даннных</param>
/// <returns>Строка с данными по объекту</returns>
public static string GetDataForSave(this DrawingShip drawingShip,
char separatorForObject)
{
var ship = drawingShip.EntityShip;
if (ship == null)
{
return string.Empty;
}
var str =
$"{ship.Speed}{separatorForObject}{ship.Weight}{separatorForObject}{ship.BodyColor.Name}";
if (ship is not EntityContainerShip containerShip)
{
return str;
}
return
$"{str}{separatorForObject}{containerShip.AdditionalColor.Name}{separatorForObject}{containerShip.Crane}{separatorForObject}{containerShip.Conteiners}";
}
}
}

View File

@ -37,8 +37,15 @@
this.ButtonRefreshCollection = new System.Windows.Forms.Button();
this.ButtonRemoveCar = new System.Windows.Forms.Button();
this.ButtonAddCar = new System.Windows.Forms.Button();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.файлToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SaveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
this.panel1.SuspendLayout();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
this.SuspendLayout();
//
@ -52,23 +59,27 @@
this.panel1.Controls.Add(this.ButtonRefreshCollection);
this.panel1.Controls.Add(this.ButtonRemoveCar);
this.panel1.Controls.Add(this.ButtonAddCar);
this.panel1.Location = new System.Drawing.Point(646, 0);
this.panel1.Controls.Add(this.menuStrip1);
this.panel1.Location = new System.Drawing.Point(754, 0);
this.panel1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(157, 449);
this.panel1.Size = new System.Drawing.Size(183, 518);
this.panel1.TabIndex = 1;
//
// textBoxStorageName
//
this.textBoxStorageName.Location = new System.Drawing.Point(18, 25);
this.textBoxStorageName.Location = new System.Drawing.Point(21, 29);
this.textBoxStorageName.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.textBoxStorageName.Name = "textBoxStorageName";
this.textBoxStorageName.Size = new System.Drawing.Size(118, 20);
this.textBoxStorageName.Size = new System.Drawing.Size(137, 23);
this.textBoxStorageName.TabIndex = 5;
//
// ButtonAddObject
//
this.ButtonAddObject.Location = new System.Drawing.Point(18, 51);
this.ButtonAddObject.Location = new System.Drawing.Point(21, 59);
this.ButtonAddObject.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.ButtonAddObject.Name = "ButtonAddObject";
this.ButtonAddObject.Size = new System.Drawing.Size(118, 29);
this.ButtonAddObject.Size = new System.Drawing.Size(138, 33);
this.ButtonAddObject.TabIndex = 2;
this.ButtonAddObject.Text = "добавить набор";
this.ButtonAddObject.UseVisualStyleBackColor = true;
@ -77,17 +88,20 @@
// listBoxStorages
//
this.listBoxStorages.FormattingEnabled = true;
this.listBoxStorages.Location = new System.Drawing.Point(18, 86);
this.listBoxStorages.ItemHeight = 15;
this.listBoxStorages.Location = new System.Drawing.Point(21, 99);
this.listBoxStorages.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.listBoxStorages.Name = "listBoxStorages";
this.listBoxStorages.Size = new System.Drawing.Size(120, 95);
this.listBoxStorages.Size = new System.Drawing.Size(139, 109);
this.listBoxStorages.TabIndex = 4;
this.listBoxStorages.SelectedIndexChanged += new System.EventHandler(this.ListBoxObjects_SelectedIndexChanged);
//
// ButtonDelObject
//
this.ButtonDelObject.Location = new System.Drawing.Point(18, 187);
this.ButtonDelObject.Location = new System.Drawing.Point(21, 216);
this.ButtonDelObject.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.ButtonDelObject.Name = "ButtonDelObject";
this.ButtonDelObject.Size = new System.Drawing.Size(118, 30);
this.ButtonDelObject.Size = new System.Drawing.Size(138, 35);
this.ButtonDelObject.TabIndex = 2;
this.ButtonDelObject.Text = "удалить набор";
this.ButtonDelObject.UseVisualStyleBackColor = true;
@ -95,16 +109,18 @@
//
// maskedTextBoxNumber
//
this.maskedTextBoxNumber.Location = new System.Drawing.Point(16, 330);
this.maskedTextBoxNumber.Location = new System.Drawing.Point(19, 381);
this.maskedTextBoxNumber.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
this.maskedTextBoxNumber.Size = new System.Drawing.Size(100, 20);
this.maskedTextBoxNumber.Size = new System.Drawing.Size(116, 23);
this.maskedTextBoxNumber.TabIndex = 3;
//
// ButtonRefreshCollection
//
this.ButtonRefreshCollection.Location = new System.Drawing.Point(16, 401);
this.ButtonRefreshCollection.Location = new System.Drawing.Point(19, 463);
this.ButtonRefreshCollection.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.ButtonRefreshCollection.Name = "ButtonRefreshCollection";
this.ButtonRefreshCollection.Size = new System.Drawing.Size(118, 37);
this.ButtonRefreshCollection.Size = new System.Drawing.Size(138, 43);
this.ButtonRefreshCollection.TabIndex = 2;
this.ButtonRefreshCollection.Text = "обновить коллекцию";
this.ButtonRefreshCollection.UseVisualStyleBackColor = true;
@ -112,9 +128,10 @@
//
// ButtonRemoveCar
//
this.ButtonRemoveCar.Location = new System.Drawing.Point(16, 356);
this.ButtonRemoveCar.Location = new System.Drawing.Point(19, 411);
this.ButtonRemoveCar.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.ButtonRemoveCar.Name = "ButtonRemoveCar";
this.ButtonRemoveCar.Size = new System.Drawing.Size(118, 39);
this.ButtonRemoveCar.Size = new System.Drawing.Size(138, 45);
this.ButtonRemoveCar.TabIndex = 1;
this.ButtonRemoveCar.Text = "удалить контейнеровоз";
this.ButtonRemoveCar.UseVisualStyleBackColor = true;
@ -122,34 +139,80 @@
//
// ButtonAddCar
//
this.ButtonAddCar.Location = new System.Drawing.Point(16, 286);
this.ButtonAddCar.Location = new System.Drawing.Point(19, 330);
this.ButtonAddCar.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.ButtonAddCar.Name = "ButtonAddCar";
this.ButtonAddCar.Size = new System.Drawing.Size(118, 38);
this.ButtonAddCar.Size = new System.Drawing.Size(138, 44);
this.ButtonAddCar.TabIndex = 0;
this.ButtonAddCar.Text = "добавить контейнеровоз";
this.ButtonAddCar.UseVisualStyleBackColor = true;
this.ButtonAddCar.Click += new System.EventHandler(this.ButtonAddCar_Click);
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.файлToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(183, 24);
this.menuStrip1.TabIndex = 6;
this.menuStrip1.Text = "menuStrip1";
//
// файлToolStripMenuItem
//
this.файлToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.LoadToolStripMenuItem,
this.SaveToolStripMenuItem});
this.файлToolStripMenuItem.Name = айлToolStripMenuItem";
this.файлToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
this.файлToolStripMenuItem.Text = "файл";
//
// LoadToolStripMenuItem
//
this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
this.LoadToolStripMenuItem.Size = new System.Drawing.Size(131, 22);
this.LoadToolStripMenuItem.Text = "загрузить";
this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click);
//
// SaveToolStripMenuItem
//
this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
this.SaveToolStripMenuItem.Size = new System.Drawing.Size(131, 22);
this.SaveToolStripMenuItem.Text = "сохранить";
this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click);
//
// pictureBoxCollection
//
this.pictureBoxCollection.Location = new System.Drawing.Point(0, 0);
this.pictureBoxCollection.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.pictureBoxCollection.Name = "pictureBoxCollection";
this.pictureBoxCollection.Size = new System.Drawing.Size(640, 449);
this.pictureBoxCollection.Size = new System.Drawing.Size(747, 518);
this.pictureBoxCollection.TabIndex = 0;
this.pictureBoxCollection.TabStop = false;
//
// openFileDialog
//
this.openFileDialog.Filter = "txt file | *.txt";
//
// saveFileDialog
//
this.saveFileDialog.Filter = "txt file | *.txt";
//
// FormShipCollection
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.ClientSize = new System.Drawing.Size(933, 519);
this.Controls.Add(this.panel1);
this.Controls.Add(this.pictureBoxCollection);
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.Name = "FormShipCollection";
this.Text = "FormShipCollection";
this.Load += new System.EventHandler(this.FormShipCollection_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
this.ResumeLayout(false);
@ -167,5 +230,11 @@
private System.Windows.Forms.Button ButtonAddObject;
private System.Windows.Forms.ListBox listBoxStorages;
private System.Windows.Forms.Button ButtonDelObject;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem файлToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem LoadToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem SaveToolStripMenuItem;
private System.Windows.Forms.OpenFileDialog openFileDialog;
private System.Windows.Forms.SaveFileDialog saveFileDialog;
}
}

View File

@ -162,5 +162,40 @@ namespace Lab1ContainersShip
ReloadObjects();
}
}
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))
{
ReloadObjects();
MessageBox.Show("Загрузка прошла успешно",
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Не загрузилось", "Результат",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
@ -117,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="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>175, 31</value>
</metadata>
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>290, 31</value>
</metadata>
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>430, 31</value>
</metadata>
</root>

View File

@ -79,9 +79,11 @@
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Location = new System.Drawing.Point(14, 14);
this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(466, 323);
this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.groupBox1.Size = new System.Drawing.Size(544, 373);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Параметры";
@ -89,9 +91,10 @@
// labelModifiedObject
//
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelModifiedObject.Location = new System.Drawing.Point(331, 229);
this.labelModifiedObject.Location = new System.Drawing.Point(386, 264);
this.labelModifiedObject.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelModifiedObject.Name = "labelModifiedObject";
this.labelModifiedObject.Size = new System.Drawing.Size(100, 32);
this.labelModifiedObject.Size = new System.Drawing.Size(116, 37);
this.labelModifiedObject.TabIndex = 10;
this.labelModifiedObject.Text = "Продвинутый";
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
@ -99,9 +102,10 @@
// labelSimpleObject
//
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelSimpleObject.Location = new System.Drawing.Point(206, 229);
this.labelSimpleObject.Location = new System.Drawing.Point(240, 264);
this.labelSimpleObject.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelSimpleObject.Name = "labelSimpleObject";
this.labelSimpleObject.Size = new System.Drawing.Size(100, 32);
this.labelSimpleObject.Size = new System.Drawing.Size(116, 37);
this.labelSimpleObject.TabIndex = 9;
this.labelSimpleObject.Text = "Простой";
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
@ -116,9 +120,11 @@
this.groupBox2.Controls.Add(this.panelYellow);
this.groupBox2.Controls.Add(this.panelOrange);
this.groupBox2.Controls.Add(this.panelRed);
this.groupBox2.Location = new System.Drawing.Point(196, 31);
this.groupBox2.Location = new System.Drawing.Point(229, 36);
this.groupBox2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(246, 158);
this.groupBox2.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.groupBox2.Size = new System.Drawing.Size(287, 182);
this.groupBox2.TabIndex = 8;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Цвета";
@ -126,98 +132,110 @@
// panelPink
//
this.panelPink.BackColor = System.Drawing.Color.Fuchsia;
this.panelPink.Location = new System.Drawing.Point(187, 75);
this.panelPink.Location = new System.Drawing.Point(218, 87);
this.panelPink.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.panelPink.Name = "panelPink";
this.panelPink.Size = new System.Drawing.Size(43, 41);
this.panelPink.Size = new System.Drawing.Size(50, 47);
this.panelPink.TabIndex = 0;
//
// panelPurple
//
this.panelPurple.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(0)))), ((int)(((byte)(64)))));
this.panelPurple.Location = new System.Drawing.Point(125, 75);
this.panelPurple.BackColor = System.Drawing.Color.Purple;
this.panelPurple.Location = new System.Drawing.Point(146, 87);
this.panelPurple.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.panelPurple.Name = "panelPurple";
this.panelPurple.Size = new System.Drawing.Size(43, 40);
this.panelPurple.Size = new System.Drawing.Size(50, 46);
this.panelPurple.TabIndex = 0;
//
// panelBlue
//
this.panelBlue.BackColor = System.Drawing.Color.Blue;
this.panelBlue.Location = new System.Drawing.Point(64, 75);
this.panelBlue.Location = new System.Drawing.Point(75, 87);
this.panelBlue.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.panelBlue.Name = "panelBlue";
this.panelBlue.Size = new System.Drawing.Size(43, 40);
this.panelBlue.Size = new System.Drawing.Size(50, 46);
this.panelBlue.TabIndex = 0;
//
// panelLightBlue
//
this.panelLightBlue.BackColor = System.Drawing.Color.Cyan;
this.panelLightBlue.Location = new System.Drawing.Point(6, 75);
this.panelLightBlue.Location = new System.Drawing.Point(7, 87);
this.panelLightBlue.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.panelLightBlue.Name = "panelLightBlue";
this.panelLightBlue.Size = new System.Drawing.Size(40, 40);
this.panelLightBlue.Size = new System.Drawing.Size(47, 46);
this.panelLightBlue.TabIndex = 13;
//
// panelGreen
//
this.panelGreen.BackColor = System.Drawing.Color.Lime;
this.panelGreen.Location = new System.Drawing.Point(187, 19);
this.panelGreen.Location = new System.Drawing.Point(218, 22);
this.panelGreen.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.panelGreen.Name = "panelGreen";
this.panelGreen.Size = new System.Drawing.Size(43, 41);
this.panelGreen.Size = new System.Drawing.Size(50, 47);
this.panelGreen.TabIndex = 12;
//
// panelYellow
//
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
this.panelYellow.Controls.Add(this.panel6);
this.panelYellow.Location = new System.Drawing.Point(125, 19);
this.panelYellow.Location = new System.Drawing.Point(146, 22);
this.panelYellow.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.panelYellow.Name = "panelYellow";
this.panelYellow.Size = new System.Drawing.Size(43, 38);
this.panelYellow.Size = new System.Drawing.Size(50, 44);
this.panelYellow.TabIndex = 11;
//
// panel6
//
this.panel6.Location = new System.Drawing.Point(0, 44);
this.panel6.Location = new System.Drawing.Point(0, 51);
this.panel6.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(43, 56);
this.panel6.Size = new System.Drawing.Size(50, 65);
this.panel6.TabIndex = 0;
//
// panelOrange
//
this.panelOrange.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
this.panelOrange.BackColor = System.Drawing.Color.OrangeRed;
this.panelOrange.Controls.Add(this.panel4);
this.panelOrange.Location = new System.Drawing.Point(64, 19);
this.panelOrange.Location = new System.Drawing.Point(75, 22);
this.panelOrange.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.panelOrange.Name = "panelOrange";
this.panelOrange.Size = new System.Drawing.Size(43, 38);
this.panelOrange.Size = new System.Drawing.Size(50, 44);
this.panelOrange.TabIndex = 10;
//
// panel4
//
this.panel4.Location = new System.Drawing.Point(0, 44);
this.panel4.Location = new System.Drawing.Point(0, 51);
this.panel4.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(43, 56);
this.panel4.Size = new System.Drawing.Size(50, 65);
this.panel4.TabIndex = 0;
//
// panelRed
//
this.panelRed.BackColor = System.Drawing.Color.Red;
this.panelRed.Controls.Add(this.panel2);
this.panelRed.Location = new System.Drawing.Point(6, 19);
this.panelRed.Location = new System.Drawing.Point(7, 22);
this.panelRed.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.panelRed.Name = "panelRed";
this.panelRed.Size = new System.Drawing.Size(40, 38);
this.panelRed.Size = new System.Drawing.Size(47, 44);
this.panelRed.TabIndex = 9;
this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panel2
//
this.panel2.Location = new System.Drawing.Point(157, 72);
this.panel2.Location = new System.Drawing.Point(183, 83);
this.panel2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(43, 28);
this.panel2.Size = new System.Drawing.Size(50, 32);
this.panel2.TabIndex = 0;
//
// checkBoxContainers
//
this.checkBoxContainers.AutoSize = true;
this.checkBoxContainers.Location = new System.Drawing.Point(9, 129);
this.checkBoxContainers.Location = new System.Drawing.Point(10, 149);
this.checkBoxContainers.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.checkBoxContainers.Name = "checkBoxContainers";
this.checkBoxContainers.Size = new System.Drawing.Size(88, 17);
this.checkBoxContainers.Size = new System.Drawing.Size(94, 19);
this.checkBoxContainers.TabIndex = 7;
this.checkBoxContainers.Text = "Контейнеры";
this.checkBoxContainers.UseVisualStyleBackColor = true;
@ -225,16 +243,18 @@
// checkBoxCrane
//
this.checkBoxCrane.AutoSize = true;
this.checkBoxCrane.Location = new System.Drawing.Point(9, 106);
this.checkBoxCrane.Location = new System.Drawing.Point(10, 122);
this.checkBoxCrane.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.checkBoxCrane.Name = "checkBoxCrane";
this.checkBoxCrane.Size = new System.Drawing.Size(51, 17);
this.checkBoxCrane.Size = new System.Drawing.Size(53, 19);
this.checkBoxCrane.TabIndex = 6;
this.checkBoxCrane.Text = "Кран";
this.checkBoxCrane.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
this.numericUpDownWeight.Location = new System.Drawing.Point(41, 65);
this.numericUpDownWeight.Location = new System.Drawing.Point(48, 75);
this.numericUpDownWeight.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.numericUpDownWeight.Maximum = new decimal(new int[] {
1000,
0,
@ -246,7 +266,7 @@
0,
0});
this.numericUpDownWeight.Name = "numericUpDownWeight";
this.numericUpDownWeight.Size = new System.Drawing.Size(120, 20);
this.numericUpDownWeight.Size = new System.Drawing.Size(140, 23);
this.numericUpDownWeight.TabIndex = 5;
this.numericUpDownWeight.Value = new decimal(new int[] {
100,
@ -256,7 +276,8 @@
//
// numericUpDownSpeed
//
this.numericUpDownSpeed.Location = new System.Drawing.Point(70, 29);
this.numericUpDownSpeed.Location = new System.Drawing.Point(82, 33);
this.numericUpDownSpeed.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.numericUpDownSpeed.Maximum = new decimal(new int[] {
1000,
0,
@ -268,7 +289,7 @@
0,
0});
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
this.numericUpDownSpeed.Size = new System.Drawing.Size(120, 20);
this.numericUpDownSpeed.Size = new System.Drawing.Size(140, 23);
this.numericUpDownSpeed.TabIndex = 4;
this.numericUpDownSpeed.Value = new decimal(new int[] {
100,
@ -279,26 +300,29 @@
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(17, 47);
this.label3.Location = new System.Drawing.Point(20, 54);
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(0, 13);
this.label3.Size = new System.Drawing.Size(0, 15);
this.label3.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(6, 67);
this.label2.Location = new System.Drawing.Point(7, 77);
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(29, 13);
this.label2.Size = new System.Drawing.Size(29, 15);
this.label2.TabIndex = 2;
this.label2.Text = "Вес:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 31);
this.label1.Location = new System.Drawing.Point(7, 36);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(58, 13);
this.label1.Size = new System.Drawing.Size(62, 15);
this.label1.TabIndex = 1;
this.label1.Text = "Скорость:";
//
@ -306,26 +330,29 @@
//
this.panel12.AllowDrop = true;
this.panel12.Controls.Add(this.pictureBoxObject);
this.panel12.Location = new System.Drawing.Point(484, 43);
this.panel12.Location = new System.Drawing.Point(565, 50);
this.panel12.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.panel12.Name = "panel12";
this.panel12.Size = new System.Drawing.Size(316, 235);
this.panel12.Size = new System.Drawing.Size(369, 271);
this.panel12.TabIndex = 1;
this.panel12.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
this.panel12.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
//
// pictureBoxObject
//
this.pictureBoxObject.Location = new System.Drawing.Point(3, 3);
this.pictureBoxObject.Location = new System.Drawing.Point(4, 3);
this.pictureBoxObject.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.pictureBoxObject.Name = "pictureBoxObject";
this.pictureBoxObject.Size = new System.Drawing.Size(310, 204);
this.pictureBoxObject.Size = new System.Drawing.Size(362, 235);
this.pictureBoxObject.TabIndex = 0;
this.pictureBoxObject.TabStop = false;
//
// buttonOk
//
this.buttonOk.Location = new System.Drawing.Point(526, 284);
this.buttonOk.Location = new System.Drawing.Point(614, 328);
this.buttonOk.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(89, 39);
this.buttonOk.Size = new System.Drawing.Size(104, 45);
this.buttonOk.TabIndex = 2;
this.buttonOk.Text = "Добавить";
this.buttonOk.UseVisualStyleBackColor = true;
@ -333,9 +360,10 @@
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(702, 284);
this.buttonCancel.Location = new System.Drawing.Point(819, 328);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(95, 39);
this.buttonCancel.Size = new System.Drawing.Size(111, 45);
this.buttonCancel.TabIndex = 3;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
@ -344,9 +372,10 @@
//
this.labelColor.AllowDrop = true;
this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelColor.Location = new System.Drawing.Point(494, 12);
this.labelColor.Location = new System.Drawing.Point(576, 14);
this.labelColor.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelColor.Name = "labelColor";
this.labelColor.Size = new System.Drawing.Size(100, 23);
this.labelColor.Size = new System.Drawing.Size(116, 26);
this.labelColor.TabIndex = 4;
this.labelColor.Text = "Цвет";
this.labelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
@ -356,9 +385,10 @@
//
this.labelAddColor.AllowDrop = true;
this.labelAddColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelAddColor.Location = new System.Drawing.Point(632, 13);
this.labelAddColor.Location = new System.Drawing.Point(737, 15);
this.labelAddColor.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelAddColor.Name = "labelAddColor";
this.labelAddColor.Size = new System.Drawing.Size(100, 23);
this.labelAddColor.Size = new System.Drawing.Size(116, 26);
this.labelAddColor.TabIndex = 5;
this.labelAddColor.Text = "Доп. цвет";
this.labelAddColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelAddColor_DragDrop);
@ -366,15 +396,16 @@
//
// FormShipConfig
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 347);
this.ClientSize = new System.Drawing.Size(933, 400);
this.Controls.Add(this.labelAddColor);
this.Controls.Add(this.labelColor);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOk);
this.Controls.Add(this.panel12);
this.Controls.Add(this.groupBox1);
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.Name = "FormShipConfig";
this.Text = "FormShipConfig";
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelAddColor_DragDrop);

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">

View File

@ -1,129 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{AFA56719-1551-4DFA-9EC2-1FD7AB801A5E}</ProjectGuid>
<TargetFramework>net7.0-windows</TargetFramework>
<OutputType>WinExe</OutputType>
<RootNamespace>Lab1ContainersShip</RootNamespace>
<AssemblyName>Lab1ContainersShip</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="AbstractStrategy.cs" />
<Compile Include="FormShipCollection.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormShipCollection.Designer.cs">
<DependentUpon>FormShipCollection.cs</DependentUpon>
</Compile>
<Compile Include="FormShipConfig.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormShipConfig.Designer.cs">
<DependentUpon>FormShipConfig.cs</DependentUpon>
</Compile>
<Compile Include="ShipGenericCollection.cs" />
<Compile Include="Direction.cs" />
<Compile Include="DrawingContainerShip.cs" />
<Compile Include="DrawingShip.cs" />
<Compile Include="DrawningObjectShip.cs" />
<Compile Include="EntityContainerShip.cs" />
<Compile Include="EntityShip.cs" />
<Compile Include="FormContainerShip.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormContainerShip.Designer.cs">
<DependentUpon>FormContainerShip.cs</DependentUpon>
</Compile>
<Compile Include="IMoveableObject.cs" />
<Compile Include="MoveToBorder.cs" />
<Compile Include="MoveToCenter.cs" />
<Compile Include="ObjectParameters.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SetGeneric.cs" />
<Compile Include="ShipGenericStorage.cs" />
<Compile Include="Status.cs" />
<EmbeddedResource Include="FormContainerShip.resx">
<DependentUpon>FormContainerShip.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormShipCollection.resx">
<DependentUpon>FormShipCollection.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormShipConfig.resx">
<DependentUpon>FormShipConfig.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Remove="ShipCollection.resx" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\photo.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\photo1.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\photo2.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\photo3.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанных со сборкой.
[assembly: AssemblyTitle("Lab1ContainersShip")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Lab1ContainersShip")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// COM, следует установить атрибут ComVisible в TRUE для этого типа.
[assembly: ComVisible(false)]
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("afa56719-1551-4dfa-9ec2-1fd7ab801a5e")]
// Сведения о версии сборки состоят из указанных ниже четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -13,6 +13,7 @@ namespace Lab1ContainersShip
where T : DrawingShip
where U : IMoveableObject
{
public IEnumerable<T> GetShips => _collection.GetShips();
/// <summary>
/// Ширина окна прорисовки
/// </summary>

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -14,6 +15,18 @@ namespace Lab1ContainersShip
{
readonly Dictionary<string, ShipGenericCollection<DrawingShip,
DrawningObjectShip>> _shipStorages;
/// <summary>
/// Разделитель для записи ключа и значения элемента словаря
/// </summary>
private static readonly char _separatorForKeyValue = '|';
/// <summary>
/// Разделитель для записей коллекции данных в файл
/// </summary>
private readonly char _separatorRecords = ';';
/// <summary>
/// Разделитель для записи информации по объекту в файл
/// </summary>
private static readonly char _separatorForObject = ':';
/// <summary>
/// Возвращение списка названий наборов
/// </summary>
@ -91,6 +104,99 @@ DrawningObjectShip>>();
}
}
}
/// <summary>
/// Сохранение информации по автомобилям в хранилище в файл
/// </summary>
/// <param name="filename">Путь и имя файла</param>
/// <returns>true - сохранение прошло успешно, false - ошибка при
//сохранении данных</returns>
public bool SaveData(string filename)
{
if (File.Exists(filename))
{
File.Delete(filename);
}
StringBuilder data = new StringBuilder();
foreach (KeyValuePair<string,
ShipGenericCollection<DrawingShip, DrawningObjectShip>> record in _shipStorages)
{
StringBuilder records = new StringBuilder();
foreach (DrawingShip elem in record.Value.GetShips)
{
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
}
data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}");
}
if (data.Length == 0)
{
return false;
}
using FileStream fs = new FileStream(filename, FileMode.Create);
byte[] info = new
UTF8Encoding(true).GetBytes($"ShipStorage{Environment.NewLine}{data}");
fs.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 fs = new FileStream(filename, FileMode.Open))
{
byte[] b = new byte[fs.Length];
UTF8Encoding temp = new UTF8Encoding(true);
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;
}
if (!strs[0].StartsWith("ShipStorage"))
{
//если нет такой записи, то это не те данные
return false;
}
_shipStorages.Clear();
foreach (string data in strs)
{
string[] record = data.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
if (record.Length != 2)
{
continue;
}
ShipGenericCollection<DrawingShip, DrawningObjectShip>collection = new ShipGenericCollection<DrawingShip, DrawningObjectShip>(_pictureWidth, _pictureHeight);
string[] set = record[1].Split(_separatorRecords,StringSplitOptions.RemoveEmptyEntries);
foreach (string elem in set)
{
DrawingShip ship =
elem?.CreateDrawingShip(_separatorForObject, _pictureWidth, _pictureHeight);
if (ship != null)
{
if (collection + ship == -1)
{
return false;
}
}
}
_shipStorages.Add(record[0], collection);
}
return true;
}
}
}