Сданная 6 лаба
This commit is contained in:
parent
e55dbeb7a1
commit
6f3123432f
@ -31,5 +31,7 @@ namespace Airbus
|
||||
{
|
||||
_plane.DrawTransport(g);
|
||||
}
|
||||
public string GetInfo() => _plane?.GetDataForSave();
|
||||
public static IDrawningObject Create(string data) => new DrawningObjectPlane(data.CreateDrawningPlane());
|
||||
}
|
||||
}
|
||||
|
50
Airbus/Airbus/ExtentionPlane.cs
Normal file
50
Airbus/Airbus/ExtentionPlane.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Airbus
|
||||
{
|
||||
internal static class ExtentionPlane
|
||||
{
|
||||
/// <summary>
|
||||
/// Разделитель для записи информации по объекту в файл
|
||||
/// </summary>
|
||||
private static readonly char _separatorForObject = ':';
|
||||
/// <summary>
|
||||
/// Создание объекта из строки
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
/// <returns></returns>
|
||||
public static DrawningPlane CreateDrawningPlane(this string info)
|
||||
{
|
||||
string[] strs = info.Split(_separatorForObject);
|
||||
if (strs.Length == 3)
|
||||
{
|
||||
return new DrawningPlane(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]));
|
||||
}
|
||||
if (strs.Length == 7)
|
||||
{
|
||||
return new DrawningAirbus(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]), Color.FromName(strs[3]), Convert.ToBoolean(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение данных для сохранения в файл
|
||||
/// </summary>
|
||||
/// <param name="drawningPlane"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetDataForSave(this DrawningPlane drawningPlane)
|
||||
{
|
||||
var plane = drawningPlane.Plane;
|
||||
var str = $"{plane.Speed}{_separatorForObject}{plane.Weight}{_separatorForObject}{plane.BodyColor. Name}";
|
||||
if (plane is not EntityAirbus airbus)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
return
|
||||
$"{str}{_separatorForObject}{airbus.DopColor.Name}{_separatorForObject}{airbus.BodyKit}{_separatorForObject}{airbus.Wing}{_separatorForObject}{airbus.SportLine}";
|
||||
}
|
||||
}
|
||||
}
|
69
Airbus/Airbus/FormMapWithSetPlanes.Designer.cs
generated
69
Airbus/Airbus/FormMapWithSetPlanes.Designer.cs
generated
@ -45,9 +45,16 @@
|
||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||
this.buttonAddPlane = new System.Windows.Forms.Button();
|
||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.menuStrip1 = 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.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBoxMaps.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
@ -63,9 +70,9 @@
|
||||
this.groupBox1.Controls.Add(this.maskedTextBoxPosition);
|
||||
this.groupBox1.Controls.Add(this.buttonAddPlane);
|
||||
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.groupBox1.Location = new System.Drawing.Point(657, 0);
|
||||
this.groupBox1.Location = new System.Drawing.Point(657, 24);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(200, 614);
|
||||
this.groupBox1.Size = new System.Drawing.Size(200, 616);
|
||||
this.groupBox1.TabIndex = 0;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Инструменты";
|
||||
@ -227,19 +234,62 @@
|
||||
// pictureBox
|
||||
//
|
||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBox.Location = new System.Drawing.Point(0, 24);
|
||||
this.pictureBox.Name = "pictureBox";
|
||||
this.pictureBox.Size = new System.Drawing.Size(657, 614);
|
||||
this.pictureBox.Size = new System.Drawing.Size(657, 616);
|
||||
this.pictureBox.TabIndex = 0;
|
||||
this.pictureBox.TabStop = false;
|
||||
//
|
||||
// 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(857, 24);
|
||||
this.menuStrip1.TabIndex = 1;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// файл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.Filter = "«txt file | *.txt";
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
this.saveFileDialog.Filter = "«txt file | *.txt";
|
||||
//
|
||||
// FormMapWithSetPlanes
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(857, 614);
|
||||
this.ClientSize = new System.Drawing.Size(857, 640);
|
||||
this.Controls.Add(this.pictureBox);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Name = "FormMapWithSetPlanes";
|
||||
this.Text = "Карта с набором объектов";
|
||||
this.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
@ -248,7 +298,10 @@
|
||||
this.groupBoxMaps.ResumeLayout(false);
|
||||
this.groupBoxMaps.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
@ -271,5 +324,11 @@
|
||||
private ListBox listBoxMaps;
|
||||
private Button buttonAddMap;
|
||||
private TextBox textBoxNewMapName;
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem файлToolStripMenuItem;
|
||||
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
}
|
||||
}
|
@ -225,5 +225,39 @@ namespace Airbus
|
||||
_mapsCollection[listBoxMaps.SelectedItem?.ToString() ??
|
||||
string.Empty].MoveObject(dir);
|
||||
}
|
||||
|
||||
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_mapsCollection.SaveData(saveFileDialog.FileName))
|
||||
{
|
||||
MessageBox.Show("Сохранение прошло успешно", "Результат",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не сохранилось", "Результат",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// TODO продумать логику
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_mapsCollection.LoadData(openFileDialog.FileName))
|
||||
{
|
||||
ReloadMaps();
|
||||
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
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="menuStrip1.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>132, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>272, 17</value>
|
||||
</metadata>
|
||||
</root>
|
126
Airbus/Airbus/FormPlaneConfig.Designer.cs
generated
126
Airbus/Airbus/FormPlaneConfig.Designer.cs
generated
@ -73,11 +73,9 @@
|
||||
this.groupBoxConfig.Controls.Add(this.labelWeight);
|
||||
this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed);
|
||||
this.groupBoxConfig.Controls.Add(this.labelSpeed);
|
||||
this.groupBoxConfig.Location = new System.Drawing.Point(14, 16);
|
||||
this.groupBoxConfig.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.groupBoxConfig.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBoxConfig.Name = "groupBoxConfig";
|
||||
this.groupBoxConfig.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.groupBoxConfig.Size = new System.Drawing.Size(569, 233);
|
||||
this.groupBoxConfig.Size = new System.Drawing.Size(498, 175);
|
||||
this.groupBoxConfig.TabIndex = 0;
|
||||
this.groupBoxConfig.TabStop = false;
|
||||
this.groupBoxConfig.Text = "Параметры";
|
||||
@ -85,9 +83,9 @@
|
||||
// labelModifiedObject
|
||||
//
|
||||
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelModifiedObject.Location = new System.Drawing.Point(453, 173);
|
||||
this.labelModifiedObject.Location = new System.Drawing.Point(396, 130);
|
||||
this.labelModifiedObject.Name = "labelModifiedObject";
|
||||
this.labelModifiedObject.Size = new System.Drawing.Size(109, 46);
|
||||
this.labelModifiedObject.Size = new System.Drawing.Size(96, 35);
|
||||
this.labelModifiedObject.TabIndex = 7;
|
||||
this.labelModifiedObject.Text = "Продвинутый";
|
||||
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
@ -96,9 +94,9 @@
|
||||
// labelSimpleObject
|
||||
//
|
||||
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelSimpleObject.Location = new System.Drawing.Point(341, 173);
|
||||
this.labelSimpleObject.Location = new System.Drawing.Point(298, 130);
|
||||
this.labelSimpleObject.Name = "labelSimpleObject";
|
||||
this.labelSimpleObject.Size = new System.Drawing.Size(105, 46);
|
||||
this.labelSimpleObject.Size = new System.Drawing.Size(92, 35);
|
||||
this.labelSimpleObject.TabIndex = 1;
|
||||
this.labelSimpleObject.Text = "Простой";
|
||||
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
@ -114,11 +112,9 @@
|
||||
this.groupBoxColor.Controls.Add(this.panelYellow);
|
||||
this.groupBoxColor.Controls.Add(this.panelGreen);
|
||||
this.groupBoxColor.Controls.Add(this.panelRed);
|
||||
this.groupBoxColor.Location = new System.Drawing.Point(341, 20);
|
||||
this.groupBoxColor.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.groupBoxColor.Location = new System.Drawing.Point(298, 15);
|
||||
this.groupBoxColor.Name = "groupBoxColor";
|
||||
this.groupBoxColor.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.groupBoxColor.Size = new System.Drawing.Size(222, 149);
|
||||
this.groupBoxColor.Size = new System.Drawing.Size(194, 112);
|
||||
this.groupBoxColor.TabIndex = 1;
|
||||
this.groupBoxColor.TabStop = false;
|
||||
this.groupBoxColor.Text = "Цвета";
|
||||
@ -126,90 +122,81 @@
|
||||
// panelBlack
|
||||
//
|
||||
this.panelBlack.BackColor = System.Drawing.Color.Black;
|
||||
this.panelBlack.Location = new System.Drawing.Point(165, 91);
|
||||
this.panelBlack.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.panelBlack.Location = new System.Drawing.Point(144, 68);
|
||||
this.panelBlack.Name = "panelBlack";
|
||||
this.panelBlack.Size = new System.Drawing.Size(46, 53);
|
||||
this.panelBlack.Size = new System.Drawing.Size(40, 40);
|
||||
this.panelBlack.TabIndex = 1;
|
||||
this.panelBlack.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelPink
|
||||
//
|
||||
this.panelPink.BackColor = System.Drawing.Color.Fuchsia;
|
||||
this.panelPink.Location = new System.Drawing.Point(112, 91);
|
||||
this.panelPink.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.panelPink.Location = new System.Drawing.Point(98, 68);
|
||||
this.panelPink.Name = "panelPink";
|
||||
this.panelPink.Size = new System.Drawing.Size(46, 53);
|
||||
this.panelPink.Size = new System.Drawing.Size(40, 40);
|
||||
this.panelPink.TabIndex = 1;
|
||||
this.panelPink.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelGol
|
||||
//
|
||||
this.panelGol.BackColor = System.Drawing.Color.Cyan;
|
||||
this.panelGol.Location = new System.Drawing.Point(59, 91);
|
||||
this.panelGol.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.panelGol.Location = new System.Drawing.Point(52, 68);
|
||||
this.panelGol.Name = "panelGol";
|
||||
this.panelGol.Size = new System.Drawing.Size(46, 53);
|
||||
this.panelGol.Size = new System.Drawing.Size(40, 40);
|
||||
this.panelGol.TabIndex = 1;
|
||||
this.panelGol.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
this.panelBlue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
|
||||
this.panelBlue.Location = new System.Drawing.Point(7, 91);
|
||||
this.panelBlue.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.panelBlue.Location = new System.Drawing.Point(6, 68);
|
||||
this.panelBlue.Name = "panelBlue";
|
||||
this.panelBlue.Size = new System.Drawing.Size(46, 53);
|
||||
this.panelBlue.Size = new System.Drawing.Size(40, 40);
|
||||
this.panelBlue.TabIndex = 2;
|
||||
this.panelBlue.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelOrange
|
||||
//
|
||||
this.panelOrange.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
|
||||
this.panelOrange.Location = new System.Drawing.Point(165, 29);
|
||||
this.panelOrange.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.panelOrange.Location = new System.Drawing.Point(144, 22);
|
||||
this.panelOrange.Name = "panelOrange";
|
||||
this.panelOrange.Size = new System.Drawing.Size(46, 53);
|
||||
this.panelOrange.Size = new System.Drawing.Size(40, 40);
|
||||
this.panelOrange.TabIndex = 1;
|
||||
this.panelOrange.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
|
||||
this.panelYellow.Location = new System.Drawing.Point(112, 29);
|
||||
this.panelYellow.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.panelYellow.Location = new System.Drawing.Point(98, 22);
|
||||
this.panelYellow.Name = "panelYellow";
|
||||
this.panelYellow.Size = new System.Drawing.Size(46, 53);
|
||||
this.panelYellow.Size = new System.Drawing.Size(40, 40);
|
||||
this.panelYellow.TabIndex = 1;
|
||||
this.panelYellow.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
this.panelGreen.BackColor = System.Drawing.Color.Lime;
|
||||
this.panelGreen.Location = new System.Drawing.Point(59, 29);
|
||||
this.panelGreen.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.panelGreen.Location = new System.Drawing.Point(52, 22);
|
||||
this.panelGreen.Name = "panelGreen";
|
||||
this.panelGreen.Size = new System.Drawing.Size(46, 53);
|
||||
this.panelGreen.Size = new System.Drawing.Size(40, 40);
|
||||
this.panelGreen.TabIndex = 1;
|
||||
this.panelGreen.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
this.panelRed.BackColor = System.Drawing.Color.Red;
|
||||
this.panelRed.Location = new System.Drawing.Point(7, 29);
|
||||
this.panelRed.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.panelRed.Location = new System.Drawing.Point(6, 22);
|
||||
this.panelRed.Name = "panelRed";
|
||||
this.panelRed.Size = new System.Drawing.Size(46, 53);
|
||||
this.panelRed.Size = new System.Drawing.Size(40, 40);
|
||||
this.panelRed.TabIndex = 0;
|
||||
this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// checkBoxSportLine
|
||||
//
|
||||
this.checkBoxSportLine.AutoSize = true;
|
||||
this.checkBoxSportLine.Location = new System.Drawing.Point(19, 195);
|
||||
this.checkBoxSportLine.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.checkBoxSportLine.Location = new System.Drawing.Point(17, 146);
|
||||
this.checkBoxSportLine.Name = "checkBoxSportLine";
|
||||
this.checkBoxSportLine.Size = new System.Drawing.Size(320, 24);
|
||||
this.checkBoxSportLine.Size = new System.Drawing.Size(254, 19);
|
||||
this.checkBoxSportLine.TabIndex = 6;
|
||||
this.checkBoxSportLine.Text = "Признак наличия отсека для пассажиров";
|
||||
this.checkBoxSportLine.UseVisualStyleBackColor = true;
|
||||
@ -217,10 +204,9 @@
|
||||
// checkBoxWing
|
||||
//
|
||||
this.checkBoxWing.AutoSize = true;
|
||||
this.checkBoxWing.Location = new System.Drawing.Point(19, 161);
|
||||
this.checkBoxWing.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.checkBoxWing.Location = new System.Drawing.Point(17, 121);
|
||||
this.checkBoxWing.Name = "checkBoxWing";
|
||||
this.checkBoxWing.Size = new System.Drawing.Size(233, 24);
|
||||
this.checkBoxWing.Size = new System.Drawing.Size(186, 19);
|
||||
this.checkBoxWing.TabIndex = 5;
|
||||
this.checkBoxWing.Text = "Признак наличия антикрыла";
|
||||
this.checkBoxWing.UseVisualStyleBackColor = true;
|
||||
@ -228,54 +214,50 @@
|
||||
// checkBoxBodyKit
|
||||
//
|
||||
this.checkBoxBodyKit.AutoSize = true;
|
||||
this.checkBoxBodyKit.Location = new System.Drawing.Point(19, 128);
|
||||
this.checkBoxBodyKit.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.checkBoxBodyKit.Location = new System.Drawing.Point(17, 96);
|
||||
this.checkBoxBodyKit.Name = "checkBoxBodyKit";
|
||||
this.checkBoxBodyKit.Size = new System.Drawing.Size(265, 24);
|
||||
this.checkBoxBodyKit.Size = new System.Drawing.Size(210, 19);
|
||||
this.checkBoxBodyKit.TabIndex = 4;
|
||||
this.checkBoxBodyKit.Text = "Признак наличия доп.двигателей";
|
||||
this.checkBoxBodyKit.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
this.numericUpDownWeight.Location = new System.Drawing.Point(94, 89);
|
||||
this.numericUpDownWeight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.numericUpDownWeight.Location = new System.Drawing.Point(82, 67);
|
||||
this.numericUpDownWeight.Name = "numericUpDownWeight";
|
||||
this.numericUpDownWeight.Size = new System.Drawing.Size(111, 27);
|
||||
this.numericUpDownWeight.Size = new System.Drawing.Size(97, 23);
|
||||
this.numericUpDownWeight.TabIndex = 3;
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
this.labelWeight.AutoSize = true;
|
||||
this.labelWeight.Location = new System.Drawing.Point(19, 92);
|
||||
this.labelWeight.Location = new System.Drawing.Point(17, 69);
|
||||
this.labelWeight.Name = "labelWeight";
|
||||
this.labelWeight.Size = new System.Drawing.Size(36, 20);
|
||||
this.labelWeight.Size = new System.Drawing.Size(29, 15);
|
||||
this.labelWeight.TabIndex = 2;
|
||||
this.labelWeight.Text = "Вес:";
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
this.numericUpDownSpeed.Location = new System.Drawing.Point(94, 37);
|
||||
this.numericUpDownSpeed.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.numericUpDownSpeed.Location = new System.Drawing.Point(82, 28);
|
||||
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||
this.numericUpDownSpeed.Size = new System.Drawing.Size(111, 27);
|
||||
this.numericUpDownSpeed.Size = new System.Drawing.Size(97, 23);
|
||||
this.numericUpDownSpeed.TabIndex = 1;
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
this.labelSpeed.AutoSize = true;
|
||||
this.labelSpeed.Location = new System.Drawing.Point(19, 40);
|
||||
this.labelSpeed.Location = new System.Drawing.Point(17, 30);
|
||||
this.labelSpeed.Name = "labelSpeed";
|
||||
this.labelSpeed.Size = new System.Drawing.Size(76, 20);
|
||||
this.labelSpeed.Size = new System.Drawing.Size(62, 15);
|
||||
this.labelSpeed.TabIndex = 0;
|
||||
this.labelSpeed.Text = "Скорость:";
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
this.pictureBoxObject.Location = new System.Drawing.Point(18, 69);
|
||||
this.pictureBoxObject.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.pictureBoxObject.Location = new System.Drawing.Point(16, 52);
|
||||
this.pictureBoxObject.Name = "pictureBoxObject";
|
||||
this.pictureBoxObject.Size = new System.Drawing.Size(250, 117);
|
||||
this.pictureBoxObject.Size = new System.Drawing.Size(219, 88);
|
||||
this.pictureBoxObject.TabIndex = 0;
|
||||
this.pictureBoxObject.TabStop = false;
|
||||
//
|
||||
@ -285,10 +267,9 @@
|
||||
this.panelObject.Controls.Add(this.labelBaseColor);
|
||||
this.panelObject.Controls.Add(this.labelDopColor);
|
||||
this.panelObject.Controls.Add(this.pictureBoxObject);
|
||||
this.panelObject.Location = new System.Drawing.Point(597, 16);
|
||||
this.panelObject.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.panelObject.Location = new System.Drawing.Point(522, 12);
|
||||
this.panelObject.Name = "panelObject";
|
||||
this.panelObject.Size = new System.Drawing.Size(287, 200);
|
||||
this.panelObject.Size = new System.Drawing.Size(251, 150);
|
||||
this.panelObject.TabIndex = 1;
|
||||
this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
|
||||
this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
|
||||
@ -297,9 +278,9 @@
|
||||
//
|
||||
this.labelBaseColor.AllowDrop = true;
|
||||
this.labelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelBaseColor.Location = new System.Drawing.Point(18, 13);
|
||||
this.labelBaseColor.Location = new System.Drawing.Point(16, 10);
|
||||
this.labelBaseColor.Name = "labelBaseColor";
|
||||
this.labelBaseColor.Size = new System.Drawing.Size(109, 46);
|
||||
this.labelBaseColor.Size = new System.Drawing.Size(96, 35);
|
||||
this.labelBaseColor.TabIndex = 9;
|
||||
this.labelBaseColor.Text = "Цвет";
|
||||
this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
@ -310,9 +291,9 @@
|
||||
//
|
||||
this.labelDopColor.AllowDrop = true;
|
||||
this.labelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelDopColor.Location = new System.Drawing.Point(159, 13);
|
||||
this.labelDopColor.Location = new System.Drawing.Point(139, 10);
|
||||
this.labelDopColor.Name = "labelDopColor";
|
||||
this.labelDopColor.Size = new System.Drawing.Size(109, 46);
|
||||
this.labelDopColor.Size = new System.Drawing.Size(96, 35);
|
||||
this.labelDopColor.TabIndex = 8;
|
||||
this.labelDopColor.Text = "Доп. цвет";
|
||||
this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
@ -321,10 +302,9 @@
|
||||
//
|
||||
// buttonOk
|
||||
//
|
||||
this.buttonOk.Location = new System.Drawing.Point(597, 224);
|
||||
this.buttonOk.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonOk.Location = new System.Drawing.Point(522, 168);
|
||||
this.buttonOk.Name = "buttonOk";
|
||||
this.buttonOk.Size = new System.Drawing.Size(114, 31);
|
||||
this.buttonOk.Size = new System.Drawing.Size(100, 23);
|
||||
this.buttonOk.TabIndex = 2;
|
||||
this.buttonOk.Text = "Добавить";
|
||||
this.buttonOk.UseVisualStyleBackColor = true;
|
||||
@ -332,24 +312,22 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(774, 224);
|
||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonCancel.Location = new System.Drawing.Point(677, 168);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(110, 31);
|
||||
this.buttonCancel.Size = new System.Drawing.Size(96, 23);
|
||||
this.buttonCancel.TabIndex = 3;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormPlaneConfig
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(897, 257);
|
||||
this.ClientSize = new System.Drawing.Size(785, 193);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonOk);
|
||||
this.Controls.Add(this.panelObject);
|
||||
this.Controls.Add(this.groupBoxConfig);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormPlaneConfig";
|
||||
this.Text = "Создание объекта";
|
||||
this.groupBoxConfig.ResumeLayout(false);
|
||||
|
@ -36,5 +36,7 @@ namespace Airbus
|
||||
/// <returns></returns>
|
||||
(float Left, float Top, float Right, float Bottom)
|
||||
GetCurrentPosition();
|
||||
|
||||
string GetInfo();
|
||||
}
|
||||
}
|
||||
|
@ -189,6 +189,31 @@ namespace Airbus
|
||||
i++;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение данных в виде строки
|
||||
/// </summary>
|
||||
/// <param name="sep"></param>
|
||||
/// <returns></returns>
|
||||
public string GetData(char separatorType, char separatorData)
|
||||
{
|
||||
string data = $"{_map.GetType().Name}{separatorType}";
|
||||
foreach (var plane in _setPlanes.GetPlanes())
|
||||
{
|
||||
data += $"{plane.GetInfo()}{separatorData}";
|
||||
}
|
||||
return data;
|
||||
}
|
||||
/// <summary>
|
||||
/// Загрузка списка из массива строк
|
||||
/// </summary>
|
||||
/// <param name="records"></param>
|
||||
public void LoadData(string[] records)
|
||||
{
|
||||
foreach (var rec in records)
|
||||
{
|
||||
_setPlanes.Insert(DrawningObjectPlane.Create(rec) as T);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ namespace Airbus
|
||||
/// <summary>
|
||||
/// Словарь (хранилище) с картами
|
||||
/// </summary>
|
||||
readonly Dictionary<string, MapWithSetPlanesGeneric<DrawningObjectPlane,AbstractMap>> _mapStorages;
|
||||
readonly Dictionary<string, MapWithSetPlanesGeneric<IDrawningObject, AbstractMap>> _mapStorages;
|
||||
/// <summary>
|
||||
/// Возвращение списка названий карт
|
||||
/// </summary>
|
||||
@ -29,9 +29,11 @@ namespace Airbus
|
||||
/// </summary>
|
||||
/// <param name="pictureWidth"></param>
|
||||
/// <param name="pictureHeight"></param>
|
||||
private readonly char separatorDict = '|';
|
||||
private readonly char separatorData = ';';
|
||||
public MapsCollection(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_mapStorages = new Dictionary<string, MapWithSetPlanesGeneric<DrawningObjectPlane, AbstractMap>>();
|
||||
_mapStorages = new Dictionary<string, MapWithSetPlanesGeneric<IDrawningObject, AbstractMap>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
@ -47,7 +49,7 @@ namespace Airbus
|
||||
{
|
||||
return;
|
||||
}
|
||||
_mapStorages.Add(name, new MapWithSetPlanesGeneric<DrawningObjectPlane, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||
_mapStorages.Add(name, new MapWithSetPlanesGeneric<IDrawningObject, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление карты
|
||||
@ -63,7 +65,7 @@ namespace Airbus
|
||||
/// </summary>
|
||||
/// <param name="ind"></param>
|
||||
/// <returns></returns>
|
||||
public MapWithSetPlanesGeneric<DrawningObjectPlane, AbstractMap> this[string ind]
|
||||
public MapWithSetPlanesGeneric<IDrawningObject, AbstractMap> this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -74,6 +76,75 @@ namespace Airbus
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод записи информации в файл
|
||||
/// </summary>
|
||||
/// <param name="text">Строка, которую следует записать</param>
|
||||
/// <param name="stream">Поток для записи</param>
|
||||
private static void WriteToFile(string text, FileStream stream)
|
||||
{
|
||||
byte[] info = new UTF8Encoding(true).GetBytes(text);
|
||||
stream.Write(info, 0, info.Length);
|
||||
}
|
||||
/// <summary>
|
||||
/// Сохранение информации по самолетам в хранилище в файл
|
||||
/// </summary>
|
||||
/// <param name="filename">Путь и имя файла</param>
|
||||
/// <returns></returns>
|
||||
public bool SaveData(string filename)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
File.Delete(filename);
|
||||
}
|
||||
using (StreamWriter sw = new(filename))
|
||||
{
|
||||
sw.Write($"MapsCollection{Environment.NewLine}");
|
||||
foreach (var storage in _mapStorages)
|
||||
{
|
||||
sw.Write($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, separatorData)}{Environment.NewLine}");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Загрузка нформации по автомобилям на парковках из файла
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <returns></returns>
|
||||
public bool LoadData(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
using (StreamReader sr = new(filename))
|
||||
{
|
||||
string str = "";
|
||||
if ((str = sr.ReadLine()) == null || !str.Contains("MapsCollection"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_mapStorages.Clear();
|
||||
while ((str = sr.ReadLine()) != null)
|
||||
{
|
||||
var tempElem = str.Split(separatorDict);
|
||||
AbstractMap map = null;
|
||||
switch (tempElem[1])
|
||||
{
|
||||
case "SimpleMap":
|
||||
map = new SimpleMap();
|
||||
break;
|
||||
case "MyMap":
|
||||
map = new MyMap();
|
||||
break;
|
||||
}
|
||||
_mapStorages.Add(tempElem[0], new MapWithSetPlanesGeneric<IDrawningObject, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||
_mapStorages[tempElem[0]].LoadData(tempElem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user