From 3a18cfc72a4b785b7669cb532573ad392a668e00 Mon Sep 17 00:00:00 2001 From: Pavel_Sorokin Date: Mon, 7 Nov 2022 20:18:18 +0400 Subject: [PATCH 1/7] =?UTF-8?q?commit=2006=20full.(=D0=9D=D0=B5=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=B5=D0=BD=D0=BD=D0=B0=D1=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Liner/Liner/DrawingObjectShip.cs | 2 + Liner/Liner/ExtentionShip.cs | 38 +++++++++++ Liner/Liner/FormMapWithSetShips.Designer.cs | 71 ++++++++++++++++--- Liner/Liner/FormMapWithSetShips.cs | 31 +++++++++ Liner/Liner/FormMapWithSetShips.resx | 9 +++ Liner/Liner/IDrawingObject.cs | 1 + Liner/Liner/MapWithSetShipsGeneric.cs | 16 +++++ Liner/Liner/MapsCollection.cs | 75 +++++++++++++++++++-- 8 files changed, 231 insertions(+), 12 deletions(-) create mode 100644 Liner/Liner/ExtentionShip.cs diff --git a/Liner/Liner/DrawingObjectShip.cs b/Liner/Liner/DrawingObjectShip.cs index 3686c49..8a66da9 100644 --- a/Liner/Liner/DrawingObjectShip.cs +++ b/Liner/Liner/DrawingObjectShip.cs @@ -30,5 +30,7 @@ namespace Liner { _ship.DrawTransport(g); } + public string GetInfo() => _ship?.GetDataForSave(); + public static IDrawingObject Create(string data) => new DrawingObjectShip(data.CreateDrawingShip()); } } diff --git a/Liner/Liner/ExtentionShip.cs b/Liner/Liner/ExtentionShip.cs new file mode 100644 index 0000000..15f108b --- /dev/null +++ b/Liner/Liner/ExtentionShip.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Liner +{ + internal static class ExtentionShip + { + public static readonly char _separatorForObject = ':'; + public static DrawingShip CreateDrawingShip(this string info) + { + string[] strs=info.Split(_separatorForObject); + if (strs.Length == 3) + { + return new DrawingShip(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]),Color.FromName(strs[2])); + } + if (strs.Length == 6) + { + return new DrawningLiner(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]), Color.FromName(strs[3]), Convert.ToBoolean(strs[4]), Convert.ToBoolean(strs[5])); + } + return null; + + } + public static string GetDataForSave(this DrawingShip drawingShip) + { + var ship = drawingShip.Ship; + var str = $"{ship.Speed}{_separatorForObject}{ship.Weight}{_separatorForObject}{ship.BodyColor.Name}"; + if (ship is not EntityLiner liner) + { + return str; + } + return $"{str}{_separatorForObject}{liner.DopColor.Name}{_separatorForObject}{liner.DopDeck}{_separatorForObject}{liner.Pool}"; + + } + } +} diff --git a/Liner/Liner/FormMapWithSetShips.Designer.cs b/Liner/Liner/FormMapWithSetShips.Designer.cs index 064deb1..876869b 100644 --- a/Liner/Liner/FormMapWithSetShips.Designer.cs +++ b/Liner/Liner/FormMapWithSetShips.Designer.cs @@ -45,9 +45,16 @@ this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox(); this.ButtonAddShip = new System.Windows.Forms.Button(); this.pictureBox = new System.Windows.Forms.PictureBox(); + 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(); + this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); + this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); this.groupBox.SuspendLayout(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); + this.menuStrip.SuspendLayout(); this.SuspendLayout(); // // groupBox @@ -63,9 +70,9 @@ this.groupBox.Controls.Add(this.maskedTextBoxPosition); this.groupBox.Controls.Add(this.ButtonAddShip); this.groupBox.Dock = System.Windows.Forms.DockStyle.Right; - this.groupBox.Location = new System.Drawing.Point(696, 0); + this.groupBox.Location = new System.Drawing.Point(696, 28); this.groupBox.Name = "groupBox"; - this.groupBox.Size = new System.Drawing.Size(279, 668); + this.groupBox.Size = new System.Drawing.Size(279, 640); this.groupBox.TabIndex = 0; this.groupBox.TabStop = false; this.groupBox.Text = "Инструменты"; @@ -139,7 +146,7 @@ this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonRight.BackgroundImage = global::Liner.Properties.Resources._3; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonRight.Location = new System.Drawing.Point(233, 626); + this.buttonRight.Location = new System.Drawing.Point(233, 598); this.buttonRight.Name = "buttonRight"; this.buttonRight.Size = new System.Drawing.Size(30, 30); this.buttonRight.TabIndex = 17; @@ -151,7 +158,7 @@ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonDown.BackgroundImage = global::Liner.Properties.Resources._2; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonDown.Location = new System.Drawing.Point(197, 626); + this.buttonDown.Location = new System.Drawing.Point(197, 598); this.buttonDown.Name = "buttonDown"; this.buttonDown.Size = new System.Drawing.Size(30, 30); this.buttonDown.TabIndex = 16; @@ -163,7 +170,7 @@ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonUp.BackgroundImage = global::Liner.Properties.Resources._4; this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonUp.Location = new System.Drawing.Point(197, 590); + this.buttonUp.Location = new System.Drawing.Point(197, 562); this.buttonUp.Name = "buttonUp"; this.buttonUp.Size = new System.Drawing.Size(30, 30); this.buttonUp.TabIndex = 15; @@ -175,7 +182,7 @@ this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonLeft.BackgroundImage = global::Liner.Properties.Resources._1; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonLeft.Location = new System.Drawing.Point(161, 626); + this.buttonLeft.Location = new System.Drawing.Point(161, 598); this.buttonLeft.Name = "buttonLeft"; this.buttonLeft.Size = new System.Drawing.Size(30, 30); this.buttonLeft.TabIndex = 14; @@ -233,12 +240,49 @@ // 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, 28); this.pictureBox.Name = "pictureBox"; - this.pictureBox.Size = new System.Drawing.Size(696, 668); + this.pictureBox.Size = new System.Drawing.Size(696, 640); this.pictureBox.TabIndex = 1; this.pictureBox.TabStop = false; // + // menuStrip + // + this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20); + 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(975, 28); + this.menuStrip.TabIndex = 2; + // + // 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(59, 24); + this.FileToolStripMenuItem.Text = "Файл"; + // + // SaveToolStripMenuItem + // + this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem"; + this.SaveToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + this.SaveToolStripMenuItem.Text = "Сохранение"; + this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click); + // + // LoadToolStripMenuItem + // + this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem"; + this.LoadToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + this.LoadToolStripMenuItem.Text = "Загрузка"; + this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click); + // + // saveFileDialog + // + this.saveFileDialog.Filter = "txt file | *.txt"; + // // FormMapWithSetShips // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); @@ -246,6 +290,8 @@ this.ClientSize = new System.Drawing.Size(975, 668); this.Controls.Add(this.pictureBox); this.Controls.Add(this.groupBox); + this.Controls.Add(this.menuStrip); + this.MainMenuStrip = this.menuStrip; this.Name = "FormMapWithSetShips"; this.Text = "FormMapWithSetShips"; this.groupBox.ResumeLayout(false); @@ -253,7 +299,10 @@ this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); + this.menuStrip.ResumeLayout(false); + this.menuStrip.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -276,5 +325,11 @@ private ListBox ListBoxMaps; private Button ButtonAddMap; private TextBox textBoxNewMapName; + private MenuStrip menuStrip; + private ToolStripMenuItem FileToolStripMenuItem; + private ToolStripMenuItem SaveToolStripMenuItem; + private ToolStripMenuItem LoadToolStripMenuItem; + private OpenFileDialog openFileDialog; + private SaveFileDialog saveFileDialog; } } \ No newline at end of file diff --git a/Liner/Liner/FormMapWithSetShips.cs b/Liner/Liner/FormMapWithSetShips.cs index bce36f8..e02a7e0 100644 --- a/Liner/Liner/FormMapWithSetShips.cs +++ b/Liner/Liner/FormMapWithSetShips.cs @@ -169,5 +169,36 @@ namespace Liner ReloadMaps(); } } + + 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) + { + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + if (_mapsCollection.LoadData(openFileDialog.FileName)) + { + ReloadMaps(); + MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + else + { + MessageBox.Show("Не загрузилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } } } diff --git a/Liner/Liner/FormMapWithSetShips.resx b/Liner/Liner/FormMapWithSetShips.resx index f298a7b..985a3e4 100644 --- a/Liner/Liner/FormMapWithSetShips.resx +++ b/Liner/Liner/FormMapWithSetShips.resx @@ -57,4 +57,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 144, 17 + + + 311, 17 + \ No newline at end of file diff --git a/Liner/Liner/IDrawingObject.cs b/Liner/Liner/IDrawingObject.cs index aad8465..7422b43 100644 --- a/Liner/Liner/IDrawingObject.cs +++ b/Liner/Liner/IDrawingObject.cs @@ -14,5 +14,6 @@ namespace Liner void DrawningObject(Graphics g); (float Left, float Right, float Top, float Bottom) GetCurrentPosition(); + string GetInfo(); } } diff --git a/Liner/Liner/MapWithSetShipsGeneric.cs b/Liner/Liner/MapWithSetShipsGeneric.cs index 5d9931f..a17ce92 100644 --- a/Liner/Liner/MapWithSetShipsGeneric.cs +++ b/Liner/Liner/MapWithSetShipsGeneric.cs @@ -58,6 +58,22 @@ namespace Liner } return new(_pictureWidth, _pictureHeight); } + public string GetData(char separatorType, char separatorData) + { + string data = $"{_map.GetType().Name}{separatorType}"; + foreach (var ship in _setShips.GetShips()) + { + data += $"{ship.GetInfo()}{separatorData}"; + } + return data; + } + public void LoadData(string[] records) + { + foreach (var rec in records) + { + _setShips.Insert(DrawingObjectShip.Create(rec) as T); + } + } private void Shaking() { int j = _setShips.Count - 1; diff --git a/Liner/Liner/MapsCollection.cs b/Liner/Liner/MapsCollection.cs index 5dd14d7..09d4a38 100644 --- a/Liner/Liner/MapsCollection.cs +++ b/Liner/Liner/MapsCollection.cs @@ -8,13 +8,15 @@ namespace Liner { internal class MapsCollection { - readonly Dictionary> _mapStorages; + readonly Dictionary> _mapStorages; public List Keys => _mapStorages.Keys.ToList(); private readonly int _pictureWidth; private readonly int _pictureHeight; + private readonly char separatorDict = '|'; + private readonly char separatorData = ';'; public MapsCollection(int pictureWidth, int pictureHeight) { - _mapStorages = new Dictionary>(); + _mapStorages = new Dictionary>(); _pictureWidth = pictureWidth; _pictureHeight = pictureHeight; } @@ -22,14 +24,14 @@ namespace Liner { if (!_mapStorages.ContainsKey(name)) { - _mapStorages.Add(name, new MapWithSetShipsGeneric(_pictureWidth, _pictureHeight, map)); + _mapStorages.Add(name, new MapWithSetShipsGeneric(_pictureWidth, _pictureHeight, map)); } } public void DelMap(string name) { if (_mapStorages.ContainsKey(name)) _mapStorages.Remove(name); } - public MapWithSetShipsGeneric this[string ind] + public MapWithSetShipsGeneric this[string ind] { get { @@ -40,5 +42,70 @@ namespace Liner return null; } } + private static void WriteToFile(string text, FileStream stream) + { + byte[] info = new UTF8Encoding(true).GetBytes(text); + stream.Write(info, 0, info.Length); + } + public bool SaveData(string filename) + { + if (File.Exists(filename)) + { + File.Delete(filename); + } + using (FileStream fs = new(filename, FileMode.Create)) + { + WriteToFile($"MapsCollection{Environment.NewLine}", fs); + foreach (var storage in _mapStorages) + { + WriteToFile($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, separatorData)}{Environment.NewLine}", fs); + } + } + return true; + } + public bool LoadData(string filename) + { + if (!File.Exists(filename)) + { + return false; + } + string bufferTextFromFile = ""; + using (FileStream fs = new(filename, FileMode.Open)) + { + 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[0].Contains("MapsCollection")) + { + return false; + } + _mapStorages.Clear(); + for (int i = 1; i < strs.Length; ++i) + { + var elem = strs[i].Split(separatorDict); + AbstractMap map = null; + switch (elem[1]) + { + case "SimpleMap": + map = new SimpleMap(); + break; + case "SeaMap": + map=new SeaMap(); + break; + case "SwampMap": + map = new SwampMap(); + break; + } + _mapStorages.Add(elem[0], new MapWithSetShipsGeneric(_pictureWidth, _pictureHeight, map)); + _mapStorages[elem[0]].LoadData(elem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries)); + } + return true; + } + } } -- 2.25.1 From dd9105c2e4dec44fd9b71fb993e2a60513c13ddd Mon Sep 17 00:00:00 2001 From: Pavel_Sorokin Date: Mon, 7 Nov 2022 20:33:06 +0400 Subject: [PATCH 2/7] StreamWriter and StreamReader. --- Liner/Liner/MapsCollection.cs | 76 +++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/Liner/Liner/MapsCollection.cs b/Liner/Liner/MapsCollection.cs index 09d4a38..2eed3e7 100644 --- a/Liner/Liner/MapsCollection.cs +++ b/Liner/Liner/MapsCollection.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; +using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; @@ -53,12 +55,12 @@ namespace Liner { File.Delete(filename); } - using (FileStream fs = new(filename, FileMode.Create)) + using (StreamWriter sw = new(filename)) { - WriteToFile($"MapsCollection{Environment.NewLine}", fs); + sw.Write($"MapsCollection{Environment.NewLine}"); foreach (var storage in _mapStorages) { - WriteToFile($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, separatorData)}{Environment.NewLine}", fs); + sw.Write($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, separatorData)}{Environment.NewLine}"); } } return true; @@ -70,39 +72,45 @@ namespace Liner return false; } string bufferTextFromFile = ""; - using (FileStream fs = new(filename, FileMode.Open)) + using (StreamReader sr = new(filename)) { - byte[] b = new byte[fs.Length]; - UTF8Encoding temp = new(true); - while (fs.Read(b, 0, b.Length) > 0) + bool isFirst = true; + string str; + while ((str = sr.ReadLine()) != null) { - bufferTextFromFile += temp.GetString(b); - } - } - var strs = bufferTextFromFile.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); - if (!strs[0].Contains("MapsCollection")) - { - return false; - } - _mapStorages.Clear(); - for (int i = 1; i < strs.Length; ++i) - { - var elem = strs[i].Split(separatorDict); - AbstractMap map = null; - switch (elem[1]) - { - case "SimpleMap": - map = new SimpleMap(); - break; - case "SeaMap": - map=new SeaMap(); - break; - case "SwampMap": - map = new SwampMap(); - break; - } - _mapStorages.Add(elem[0], new MapWithSetShipsGeneric(_pictureWidth, _pictureHeight, map)); - _mapStorages[elem[0]].LoadData(elem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries)); + if (isFirst) + { + if (!str.Contains("MapsCollection")) + { + return false; + } + else + { + _mapStorages.Clear(); + } + isFirst = false; + } + else + { + var tempElem = str.Split(separatorDict); + AbstractMap map = null; + switch (tempElem[1]) + { + case "SimpleMap": + map = new SimpleMap(); + break; + case "SeaMap": + map = new SeaMap(); + break; + case "SwampMap": + map = new SwampMap(); + break; + + } + _mapStorages.Add(tempElem[0], new MapWithSetShipsGeneric(_pictureWidth, _pictureHeight, map)); + _mapStorages[tempElem[0]].LoadData(tempElem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries)); + } + } } return true; } -- 2.25.1 From 401fa5cbd7159a187ac2ac5fda5f278ccd88719c Mon Sep 17 00:00:00 2001 From: Pavel_Sorokin Date: Mon, 7 Nov 2022 22:37:13 +0400 Subject: [PATCH 3/7] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Liner/Liner/MapsCollection.cs | 53 ++++++++++++++--------------------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/Liner/Liner/MapsCollection.cs b/Liner/Liner/MapsCollection.cs index 2eed3e7..4b4a13e 100644 --- a/Liner/Liner/MapsCollection.cs +++ b/Liner/Liner/MapsCollection.cs @@ -74,43 +74,32 @@ namespace Liner string bufferTextFromFile = ""; using (StreamReader sr = new(filename)) { - bool isFirst = true; - string str; + string str = sr.ReadLine(); + if (!str.Contains("MapsCollection")) + { + return false; + } + _mapStorages.Clear(); while ((str = sr.ReadLine()) != null) { - if (isFirst) + var tempElem = str.Split(separatorDict); + AbstractMap map = null; + switch (tempElem[1]) { - if (!str.Contains("MapsCollection")) - { - return false; - } - else - { - _mapStorages.Clear(); - } - isFirst = false; - } - else - { - var tempElem = str.Split(separatorDict); - AbstractMap map = null; - switch (tempElem[1]) - { - case "SimpleMap": - map = new SimpleMap(); - break; - case "SeaMap": - map = new SeaMap(); - break; - case "SwampMap": - map = new SwampMap(); - break; + case "SimpleMap": + map = new SimpleMap(); + break; + case "SeaMap": + map = new SeaMap(); + break; + case "SwampMap": + map = new SwampMap(); + break; - } - _mapStorages.Add(tempElem[0], new MapWithSetShipsGeneric(_pictureWidth, _pictureHeight, map)); - _mapStorages[tempElem[0]].LoadData(tempElem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries)); } - } + _mapStorages.Add(tempElem[0], new MapWithSetShipsGeneric(_pictureWidth, _pictureHeight, map)); + _mapStorages[tempElem[0]].LoadData(tempElem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries)); + } } return true; } -- 2.25.1 From e1a39a5ee53e2f17ec88874aaea1a394266f51b2 Mon Sep 17 00:00:00 2001 From: Pavel_Sorokin Date: Tue, 8 Nov 2022 08:39:36 +0400 Subject: [PATCH 4/7] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D1=89?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BE=D1=87?= =?UTF-8?q?=D0=B5=D0=BA=20=D0=B1=D0=BE=D0=BB=D0=B5=D0=B5=20=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=BD=D0=BE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Liner/Liner/FormMapWithSetShips.Designer.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Liner/Liner/FormMapWithSetShips.Designer.cs b/Liner/Liner/FormMapWithSetShips.Designer.cs index 876869b..12a5ba7 100644 --- a/Liner/Liner/FormMapWithSetShips.Designer.cs +++ b/Liner/Liner/FormMapWithSetShips.Designer.cs @@ -191,7 +191,7 @@ // // ButtonShowOnMap // - this.ButtonShowOnMap.Location = new System.Drawing.Point(16, 558); + this.ButtonShowOnMap.Location = new System.Drawing.Point(16, 527); this.ButtonShowOnMap.Name = "ButtonShowOnMap"; this.ButtonShowOnMap.Size = new System.Drawing.Size(222, 29); this.ButtonShowOnMap.TabIndex = 13; @@ -201,7 +201,7 @@ // // ButtonShowStorage // - this.ButtonShowStorage.Location = new System.Drawing.Point(16, 505); + this.ButtonShowStorage.Location = new System.Drawing.Point(16, 472); this.ButtonShowStorage.Name = "ButtonShowStorage"; this.ButtonShowStorage.Size = new System.Drawing.Size(222, 29); this.ButtonShowStorage.TabIndex = 12; @@ -211,7 +211,7 @@ // // ButtonRemoveShip // - this.ButtonRemoveShip.Location = new System.Drawing.Point(16, 452); + this.ButtonRemoveShip.Location = new System.Drawing.Point(16, 437); this.ButtonRemoveShip.Name = "ButtonRemoveShip"; this.ButtonRemoveShip.Size = new System.Drawing.Size(222, 29); this.ButtonRemoveShip.TabIndex = 11; @@ -221,7 +221,7 @@ // // maskedTextBoxPosition // - this.maskedTextBoxPosition.Location = new System.Drawing.Point(16, 419); + this.maskedTextBoxPosition.Location = new System.Drawing.Point(16, 404); this.maskedTextBoxPosition.Mask = "00"; this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; this.maskedTextBoxPosition.Size = new System.Drawing.Size(222, 27); @@ -229,7 +229,7 @@ // // ButtonAddShip // - this.ButtonAddShip.Location = new System.Drawing.Point(16, 368); + this.ButtonAddShip.Location = new System.Drawing.Point(16, 356); this.ButtonAddShip.Name = "ButtonAddShip"; this.ButtonAddShip.Size = new System.Drawing.Size(222, 29); this.ButtonAddShip.TabIndex = 2; @@ -268,14 +268,14 @@ // SaveToolStripMenuItem // this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem"; - this.SaveToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + this.SaveToolStripMenuItem.Size = new System.Drawing.Size(177, 26); this.SaveToolStripMenuItem.Text = "Сохранение"; this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click); // // LoadToolStripMenuItem // this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem"; - this.LoadToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + this.LoadToolStripMenuItem.Size = new System.Drawing.Size(177, 26); this.LoadToolStripMenuItem.Text = "Загрузка"; this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click); // -- 2.25.1 From 15f17de6aaa94a2e87ac286492dd568796cf776b Mon Sep 17 00:00:00 2001 From: Pavel_Sorokin Date: Thu, 10 Nov 2022 18:20:44 +0400 Subject: [PATCH 5/7] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=20?= =?UTF-8?q?=D0=BB=D0=B8=D1=88=D0=BD=D0=B8=D0=B9=20=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=B4=20WriteToFile(=D1=82.=D0=BA.=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D1=88=D0=BB=D0=B8=20=D0=BD=D0=B0=20StreamWriter=20=D0=B8=20Str?= =?UTF-8?q?eamReader)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Liner/Liner/MapsCollection.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Liner/Liner/MapsCollection.cs b/Liner/Liner/MapsCollection.cs index 4b4a13e..59166aa 100644 --- a/Liner/Liner/MapsCollection.cs +++ b/Liner/Liner/MapsCollection.cs @@ -44,11 +44,6 @@ namespace Liner return null; } } - private static void WriteToFile(string text, FileStream stream) - { - byte[] info = new UTF8Encoding(true).GetBytes(text); - stream.Write(info, 0, info.Length); - } public bool SaveData(string filename) { if (File.Exists(filename)) -- 2.25.1 From 3972db5683fac2b8aa9e16db785199dcbb01d91e Mon Sep 17 00:00:00 2001 From: Pavel_Sorokin Date: Thu, 10 Nov 2022 18:36:49 +0400 Subject: [PATCH 6/7] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BB=D0=B8=D1=88=D0=BD=D1=8F=D1=8F=20=D1=81=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D1=87=D0=BA=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Liner/Liner/MapsCollection.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Liner/Liner/MapsCollection.cs b/Liner/Liner/MapsCollection.cs index 59166aa..c3157f7 100644 --- a/Liner/Liner/MapsCollection.cs +++ b/Liner/Liner/MapsCollection.cs @@ -66,7 +66,6 @@ namespace Liner { return false; } - string bufferTextFromFile = ""; using (StreamReader sr = new(filename)) { string str = sr.ReadLine(); -- 2.25.1 From 3a7188b36eac88036a365aa2938da9be07b4bb15 Mon Sep 17 00:00:00 2001 From: Pavel_Sorokin Date: Thu, 10 Nov 2022 22:14:56 +0400 Subject: [PATCH 7/7] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D0=BF=D1=83=D1=81=D1=82=D0=BE=D0=B9=20=D1=84?= =?UTF-8?q?=D0=B0=D0=B9=D0=BB=D0=B8=D0=BA.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Liner/Liner/MapsCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Liner/Liner/MapsCollection.cs b/Liner/Liner/MapsCollection.cs index c3157f7..80106d5 100644 --- a/Liner/Liner/MapsCollection.cs +++ b/Liner/Liner/MapsCollection.cs @@ -68,8 +68,8 @@ namespace Liner } using (StreamReader sr = new(filename)) { - string str = sr.ReadLine(); - if (!str.Contains("MapsCollection")) + string str = ""; + if ((str = sr.ReadLine()) == null || !str.Contains("MapsCollection")) { return false; } -- 2.25.1