PIbd-22. Stroev V.M. Lab Work 06 #8
@ -18,7 +18,7 @@ namespace Monorail.DrawningObjects
|
||||
return new DrawningMonorail(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]),
|
||||
Color.FromName(strs[2]), width, height);
|
||||
}
|
||||
if (strs.Length == 6)
|
||||
if (strs.Length == 7)
|
||||
{
|
||||
return new DrawningSecondMonorail(Convert.ToInt32(strs[0]),
|
||||
Convert.ToInt32(strs[1]),
|
||||
|
@ -198,6 +198,7 @@ EventArgs e)
|
||||
MessageBox.Show("Не загрузилось", "Результат",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
ReloadObjects();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
118
Monorail/Monorail/FormMonorailConfig.Designer.cs
generated
118
Monorail/Monorail/FormMonorailConfig.Designer.cs
generated
@ -29,6 +29,10 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
groupBox1 = new GroupBox();
|
||||
ButtonOk = new Button();
|
||||
ButtonCancel = new Button();
|
||||
label_body_color = new Label();
|
||||
label_additional_color = new Label();
|
||||
labelModifiedObject = new Label();
|
||||
labelSimpleObject = new Label();
|
||||
GroupColor = new GroupBox();
|
||||
@ -48,11 +52,7 @@
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
pictureBoxObject = new PictureBox();
|
||||
label4 = new Label();
|
||||
ButtonOk = new Button();
|
||||
ButtonCancel = new Button();
|
||||
PanelObject = new Panel();
|
||||
label_body_color = new Label();
|
||||
label_additional_color = new Label();
|
||||
groupBox1.SuspendLayout();
|
||||
GroupColor.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
@ -84,6 +84,59 @@
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Параметры";
|
||||
//
|
||||
// ButtonOk
|
||||
//
|
||||
ButtonOk.BackColor = SystemColors.Info;
|
||||
ButtonOk.ForeColor = SystemColors.ControlText;
|
||||
ButtonOk.Location = new Point(313, 480);
|
||||
ButtonOk.Name = "ButtonOk";
|
||||
ButtonOk.Size = new Size(101, 46);
|
||||
ButtonOk.TabIndex = 12;
|
||||
ButtonOk.Text = "Добавить";
|
||||
ButtonOk.UseVisualStyleBackColor = false;
|
||||
ButtonOk.Click += ButtonOk_Click;
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
ButtonCancel.BackColor = SystemColors.Info;
|
||||
ButtonCancel.ForeColor = SystemColors.ControlText;
|
||||
ButtonCancel.Location = new Point(6, 480);
|
||||
ButtonCancel.Name = "ButtonCancel";
|
||||
ButtonCancel.Size = new Size(106, 46);
|
||||
ButtonCancel.TabIndex = 13;
|
||||
ButtonCancel.Text = "Отмена";
|
||||
ButtonCancel.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// label_body_color
|
||||
//
|
||||
label_body_color.AllowDrop = true;
|
||||
label_body_color.BackColor = SystemColors.Info;
|
||||
label_body_color.BorderStyle = BorderStyle.FixedSingle;
|
||||
label_body_color.ForeColor = SystemColors.ControlText;
|
||||
label_body_color.Location = new Point(6, 382);
|
||||
label_body_color.Name = "label_body_color";
|
||||
label_body_color.Size = new Size(106, 56);
|
||||
label_body_color.TabIndex = 10;
|
||||
label_body_color.Text = "Осн. цвет";
|
||||
label_body_color.TextAlign = ContentAlignment.MiddleCenter;
|
||||
label_body_color.DragDrop += PanelColor_DragDrop;
|
||||
label_body_color.DragEnter += PanelColor_DragEnter;
|
||||
//
|
||||
// label_additional_color
|
||||
//
|
||||
label_additional_color.AllowDrop = true;
|
||||
label_additional_color.BackColor = SystemColors.Info;
|
||||
label_additional_color.BorderStyle = BorderStyle.FixedSingle;
|
||||
label_additional_color.ForeColor = SystemColors.ControlText;
|
||||
label_additional_color.Location = new Point(250, 382);
|
||||
label_additional_color.Name = "label_additional_color";
|
||||
label_additional_color.Size = new Size(101, 56);
|
||||
label_additional_color.TabIndex = 10;
|
||||
label_additional_color.Text = "Доп. цвет";
|
||||
label_additional_color.TextAlign = ContentAlignment.MiddleCenter;
|
||||
label_additional_color.DragDrop += PanelColor_DragDrop;
|
||||
label_additional_color.DragEnter += PanelColor_DragEnter;
|
||||
//
|
||||
// labelModifiedObject
|
||||
//
|
||||
labelModifiedObject.AllowDrop = true;
|
||||
@ -159,7 +212,7 @@
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
panelBlue.BackColor = Color.FromArgb(0, 0, 192);
|
||||
panelBlue.BackColor = Color.Blue;
|
||||
panelBlue.Location = new Point(174, 32);
|
||||
panelBlue.Name = "panelBlue";
|
||||
panelBlue.Size = new Size(78, 55);
|
||||
@ -195,7 +248,7 @@
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
panelRed.BackColor = Color.FromArgb(192, 0, 0);
|
||||
panelRed.BackColor = Color.Red;
|
||||
panelRed.Location = new Point(6, 32);
|
||||
panelRed.Name = "panelRed";
|
||||
panelRed.Size = new Size(78, 55);
|
||||
@ -282,29 +335,6 @@
|
||||
label4.Size = new Size(0, 20);
|
||||
label4.TabIndex = 2;
|
||||
//
|
||||
// ButtonOk
|
||||
//
|
||||
ButtonOk.BackColor = SystemColors.Info;
|
||||
ButtonOk.ForeColor = SystemColors.ControlText;
|
||||
ButtonOk.Location = new Point(313, 480);
|
||||
ButtonOk.Name = "ButtonOk";
|
||||
ButtonOk.Size = new Size(101, 46);
|
||||
ButtonOk.TabIndex = 12;
|
||||
ButtonOk.Text = "Добавить";
|
||||
ButtonOk.UseVisualStyleBackColor = false;
|
||||
ButtonOk.Click += ButtonOk_Click;
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
ButtonCancel.BackColor = SystemColors.Info;
|
||||
ButtonCancel.ForeColor = SystemColors.ControlText;
|
||||
ButtonCancel.Location = new Point(6, 480);
|
||||
ButtonCancel.Name = "ButtonCancel";
|
||||
ButtonCancel.Size = new Size(106, 46);
|
||||
ButtonCancel.TabIndex = 13;
|
||||
ButtonCancel.Text = "Отмена";
|
||||
ButtonCancel.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// PanelObject
|
||||
//
|
||||
PanelObject.AllowDrop = true;
|
||||
@ -316,36 +346,6 @@
|
||||
PanelObject.DragDrop += PanelObject_DragDrop;
|
||||
PanelObject.DragEnter += PanelObject_DragEnter;
|
||||
//
|
||||
// label_body_color
|
||||
//
|
||||
label_body_color.AllowDrop = true;
|
||||
label_body_color.BackColor = SystemColors.Info;
|
||||
label_body_color.BorderStyle = BorderStyle.FixedSingle;
|
||||
label_body_color.ForeColor = SystemColors.ControlText;
|
||||
label_body_color.Location = new Point(6, 382);
|
||||
label_body_color.Name = "label_body_color";
|
||||
label_body_color.Size = new Size(106, 56);
|
||||
label_body_color.TabIndex = 10;
|
||||
label_body_color.Text = "Осн. цвет";
|
||||
label_body_color.TextAlign = ContentAlignment.MiddleCenter;
|
||||
label_body_color.DragDrop += PanelColor_DragDrop;
|
||||
label_body_color.DragEnter += PanelColor_DragEnter;
|
||||
//
|
||||
// label_additional_color
|
||||
//
|
||||
label_additional_color.AllowDrop = true;
|
||||
label_additional_color.BackColor = SystemColors.Info;
|
||||
label_additional_color.BorderStyle = BorderStyle.FixedSingle;
|
||||
label_additional_color.ForeColor = SystemColors.ControlText;
|
||||
label_additional_color.Location = new Point(250, 382);
|
||||
label_additional_color.Name = "label_additional_color";
|
||||
label_additional_color.Size = new Size(101, 56);
|
||||
label_additional_color.TabIndex = 10;
|
||||
label_additional_color.Text = "Доп. цвет";
|
||||
label_additional_color.TextAlign = ContentAlignment.MiddleCenter;
|
||||
label_additional_color.DragDrop += PanelColor_DragDrop;
|
||||
label_additional_color.DragEnter += PanelColor_DragEnter;
|
||||
//
|
||||
// FormMonorailConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
|
@ -59,6 +59,7 @@ namespace Monorail.Generics
|
||||
File.Delete(filename);
|
||||
}
|
||||
StringBuilder data = new();
|
||||
|
||||
foreach (KeyValuePair<string,MonorailsGenericCollection<DrawningMonorail, DrawningObjectMonorail>>
|
||||
record in _monorailsStorages)
|
||||
{
|
||||
@ -73,10 +74,8 @@ namespace Monorail.Generics
|
||||
{
|
||||
return false;
|
||||
}
|
||||
using FileStream fs = new(filename, FileMode.Create);
|
||||
byte[] info = new
|
||||
UTF8Encoding(true).GetBytes($"MonorailStorage{Environment.NewLine}{data}");
|
||||
fs.Write(info, 0, info.Length);
|
||||
using StreamWriter sw = new(filename);
|
||||
sw.Write($"MonorailStorage{Environment.NewLine}{data}");
|
||||
return true;
|
||||
}
|
||||
public bool LoadData(string filename)
|
||||
@ -85,47 +84,43 @@ namespace Monorail.Generics
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string bufferTextFromFile = "";
|
||||
using (FileStream fs = new(filename, FileMode.Open))
|
||||
using (StreamReader sr = File.OpenText(filename))
|
||||
{
|
||||
byte[] b = new byte[fs.Length];
|
||||
UTF8Encoding temp = new(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)
|
||||
string str = sr.ReadLine();
|
||||
if (str == null || str.Length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!strs[0].StartsWith("MonorailStorage"))
|
||||
if (!str.StartsWith("MonorailStorage"))
|
||||
{
|
||||
//если нет такой записи, то это не те данные
|
||||
return false;
|
||||
}
|
||||
|
||||
_monorailsStorages.Clear();
|
||||
foreach (string data in strs)
|
||||
string strs = "";
|
||||
|
||||
while ((strs = sr.ReadLine()) != null)
|
||||
{
|
||||
string[] record = data.Split(_separatorForKeyValue,
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
if (strs == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (record.Length != 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
MonorailsGenericCollection<DrawningMonorail, DrawningObjectMonorail>
|
||||
collection = new(_pictureWidth, _pictureHeight);
|
||||
string[] set = record[1].Split(_separatorRecords,
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
MonorailsGenericCollection<DrawningMonorail, DrawningObjectMonorail> collection =
|
||||
new(_pictureWidth, _pictureHeight);
|
||||
string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string elem in set)
|
||||
{
|
||||
DrawningMonorail? monorail =
|
||||
elem?.CreateDrawningMonorail(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||
DrawningMonorail? monorail = elem?.CreateDrawningMonorail(_separatorForObject,
|
||||
_pictureWidth, _pictureHeight);
|
||||
if (monorail != null)
|
||||
{
|
||||
if ((collection + monorail)==-1)
|
||||
if ((collection + monorail) == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -135,6 +130,7 @@ namespace Monorail.Generics
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user