From 599f82140a4aa3c3fb0a6e2c2278ed7441a4ea30 Mon Sep 17 00:00:00 2001 From: klavirshik Date: Fri, 16 Aug 2024 19:01:46 +0200 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B8=20?= =?UTF-8?q?=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=B3=D0=BB=D0=BE=D0=B1=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D1=85=20?= =?UTF-8?q?=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Reseter2/Form1.cs | 44 ++++++++--------- Reseter2/Reseter2.csproj | 7 +-- Reseter2/Setting/SGlobalSetting.cs | 36 +++++++++++--- Reseter2/Setting/SSetting.cs | 16 ++++++ Reseter2/Words/Resource1.Designer.cs | 73 ---------------------------- Reseter2/Words/Resource1.resx | 2 +- 6 files changed, 70 insertions(+), 108 deletions(-) create mode 100644 Reseter2/Setting/SSetting.cs delete mode 100644 Reseter2/Words/Resource1.Designer.cs diff --git a/Reseter2/Form1.cs b/Reseter2/Form1.cs index bb2faf6..4354134 100644 --- a/Reseter2/Form1.cs +++ b/Reseter2/Form1.cs @@ -1,4 +1,5 @@ using Reseter2.History; +using Reseter2.Setting; using Reseter2.Words; using System; using System.Collections.Generic; @@ -24,31 +25,30 @@ namespace Reseter2 public Form1() { - BinaryFormatter binaryFormatter = new BinaryFormatter(); - FileStream file = new FileStream("res.dat", FileMode.OpenOrCreate); - try - { + //BinaryFormatter binaryFormatter = new BinaryFormatter(); + //FileStream file = new FileStream("res.dat", FileMode.OpenOrCreate); + //try + //{ - HistoryList.Hitem = (List)binaryFormatter.Deserialize(file); - file.Close(); - file.Dispose(); - binaryFormatter = new BinaryFormatter(); - file = new FileStream("base.dat", FileMode.OpenOrCreate); - WordsList.MainCategory = (WordsCategory)binaryFormatter.Deserialize(file); - file.Close(); - file.Dispose(); + //HistoryList.Hitem = (List)binaryFormatter.Deserialize(file); + //file.Close(); + //file.Dispose(); - } - catch - { + //} + //catch + //{ - file.Close(); - file.Dispose(); - MessageBox.Show("Ошибка чтения конфигурационных файлов.\n Перезапустите программу.", "Критическая ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - this.Close(); - } - - + // file.Close(); + // file.Dispose(); + // MessageBox.Show("Ошибка чтения конфигурационных файлов.\n Перезапустите программу.", "Критическая ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + // this.Close(); + //} + + + SGlobalSetting.LoadSetting(); + WordsList.MainCategory = SGlobalSetting.LoadWords(); + + InitializeComponent(); checkControl1.updateCheck += CheckControl1_updateCheck; flowLayoutPanel1.AutoScrollMinSize = new Size(0, 683) ; diff --git a/Reseter2/Reseter2.csproj b/Reseter2/Reseter2.csproj index 365b6da..bf0ba62 100644 --- a/Reseter2/Reseter2.csproj +++ b/Reseter2/Reseter2.csproj @@ -76,6 +76,7 @@ + @@ -102,11 +103,6 @@ - - True - True - Resource1.resx - UserControl @@ -157,7 +153,6 @@ ResXFileCodeGenerator - Resource1.Designer.cs Designer diff --git a/Reseter2/Setting/SGlobalSetting.cs b/Reseter2/Setting/SGlobalSetting.cs index 762c67c..c4aa898 100644 --- a/Reseter2/Setting/SGlobalSetting.cs +++ b/Reseter2/Setting/SGlobalSetting.cs @@ -13,31 +13,55 @@ using System.Windows.Forms; namespace Reseter2.Setting { [Serializable] - internal static class SGlobalSetting + internal static class SGlobalSetting { - // public static SettingHistory settingHistory + public static SettingWords settingWords = new SettingWords(); + //public static void LoadSetting() + // { + + + // } + + + public static void LoadSetting() { + object output = Load("res.dat"); + if (!(output is SSetting)) return; + SSetting setting = (SSetting)output; + settingWords = setting .settingWords; + HistoryList.Hitem = setting.historyItems; + // return output; } - public static bool Load(string path) + public static WordsCategory LoadWords() { + WordsCategory output = (WordsCategory)Load(settingWords.PathBase); + if (output == null) + { + output = new WordsCategory("Main"); + } + return output; + } + private static object Load(string path) + { + object obj = null; BinaryFormatter binaryFormatter = new BinaryFormatter(); FileStream file = null; try { file = new FileStream(path, FileMode.Open); - WordsList.MainCategory = (WordsCategory)binaryFormatter.Deserialize(file); + obj = binaryFormatter.Deserialize(file); file.Close(); file.Dispose(); - return true; + return obj; } catch { - return false; + return null; } } diff --git a/Reseter2/Setting/SSetting.cs b/Reseter2/Setting/SSetting.cs new file mode 100644 index 0000000..5dbcc25 --- /dev/null +++ b/Reseter2/Setting/SSetting.cs @@ -0,0 +1,16 @@ +using Reseter2.History; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Reseter2.Setting +{ + internal struct SSetting + { + public SettingWords settingWords; + public List historyItems; + + } +} diff --git a/Reseter2/Words/Resource1.Designer.cs b/Reseter2/Words/Resource1.Designer.cs deleted file mode 100644 index 4eea888..0000000 --- a/Reseter2/Words/Resource1.Designer.cs +++ /dev/null @@ -1,73 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Этот код создан программой. -// Исполняемая версия:4.0.30319.42000 -// -// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае -// повторной генерации кода. -// -//------------------------------------------------------------------------------ - -namespace Reseter2.Words { - using System; - - - /// - /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. - /// - // Этот класс создан автоматически классом StronglyTypedResourceBuilder - // с помощью такого средства, как ResGen или Visual Studio. - // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen - // с параметром /str или перестройте свой проект VS. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resource1 { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resource1() { - } - - /// - /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Reseter2.Words.Resource1", typeof(Resource1).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Перезаписывает свойство CurrentUICulture текущего потока для всех - /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Поиск локализованного ресурса типа System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap comp1 { - get { - object obj = ResourceManager.GetObject("comp1", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - } -} diff --git a/Reseter2/Words/Resource1.resx b/Reseter2/Words/Resource1.resx index 03148d2..2814f4f 100644 --- a/Reseter2/Words/Resource1.resx +++ b/Reseter2/Words/Resource1.resx @@ -119,6 +119,6 @@ - ..\Resources\comp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file