добавли сохранение глобальных параметров
This commit is contained in:
parent
aeae2c1dfc
commit
599f82140a
|
|
@ -1,4 +1,5 @@
|
||||||
using Reseter2.History;
|
using Reseter2.History;
|
||||||
|
using Reseter2.Setting;
|
||||||
using Reseter2.Words;
|
using Reseter2.Words;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -24,31 +25,30 @@ namespace Reseter2
|
||||||
public Form1()
|
public Form1()
|
||||||
{
|
{
|
||||||
|
|
||||||
BinaryFormatter binaryFormatter = new BinaryFormatter();
|
//BinaryFormatter binaryFormatter = new BinaryFormatter();
|
||||||
FileStream file = new FileStream("res.dat", FileMode.OpenOrCreate);
|
//FileStream file = new FileStream("res.dat", FileMode.OpenOrCreate);
|
||||||
try
|
//try
|
||||||
{
|
//{
|
||||||
|
|
||||||
HistoryList.Hitem = (List<HistoryItem>)binaryFormatter.Deserialize(file);
|
//HistoryList.Hitem = (List<HistoryItem>)binaryFormatter.Deserialize(file);
|
||||||
file.Close();
|
//file.Close();
|
||||||
file.Dispose();
|
//file.Dispose();
|
||||||
binaryFormatter = new BinaryFormatter();
|
|
||||||
file = new FileStream("base.dat", FileMode.OpenOrCreate);
|
|
||||||
WordsList.MainCategory = (WordsCategory)binaryFormatter.Deserialize(file);
|
|
||||||
file.Close();
|
|
||||||
file.Dispose();
|
|
||||||
|
|
||||||
}
|
//}
|
||||||
catch
|
//catch
|
||||||
{
|
//{
|
||||||
|
|
||||||
file.Close();
|
// file.Close();
|
||||||
file.Dispose();
|
// file.Dispose();
|
||||||
MessageBox.Show("Ошибка чтения конфигурационных файлов.\n Перезапустите программу.", "Критическая ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
// MessageBox.Show("Ошибка чтения конфигурационных файлов.\n Перезапустите программу.", "Критическая ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
this.Close();
|
// this.Close();
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
SGlobalSetting.LoadSetting();
|
||||||
|
WordsList.MainCategory = SGlobalSetting.LoadWords();
|
||||||
|
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
checkControl1.updateCheck += CheckControl1_updateCheck;
|
checkControl1.updateCheck += CheckControl1_updateCheck;
|
||||||
flowLayoutPanel1.AutoScrollMinSize = new Size(0, 683) ;
|
flowLayoutPanel1.AutoScrollMinSize = new Size(0, 683) ;
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@
|
||||||
<Compile Include="reseter.cs" />
|
<Compile Include="reseter.cs" />
|
||||||
<Compile Include="ReseteTask.cs" />
|
<Compile Include="ReseteTask.cs" />
|
||||||
<Compile Include="Setting\SettingWords.cs" />
|
<Compile Include="Setting\SettingWords.cs" />
|
||||||
|
<Compile Include="Setting\SSetting.cs" />
|
||||||
<Compile Include="Shutdown.cs" />
|
<Compile Include="Shutdown.cs" />
|
||||||
<Compile Include="StatusCanceled.cs" />
|
<Compile Include="StatusCanceled.cs" />
|
||||||
<Compile Include="StatusReboot.cs" />
|
<Compile Include="StatusReboot.cs" />
|
||||||
|
|
@ -102,11 +103,6 @@
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Words\IWordsContol.cs" />
|
<Compile Include="Words\IWordsContol.cs" />
|
||||||
<Compile Include="Words\IWordsItem.cs" />
|
<Compile Include="Words\IWordsItem.cs" />
|
||||||
<Compile Include="Words\Resource1.Designer.cs">
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<DependentUpon>Resource1.resx</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Words\WordsCategory.cs" />
|
<Compile Include="Words\WordsCategory.cs" />
|
||||||
<Compile Include="Words\WordsCategoryControl.cs">
|
<Compile Include="Words\WordsCategoryControl.cs">
|
||||||
<SubType>UserControl</SubType>
|
<SubType>UserControl</SubType>
|
||||||
|
|
@ -157,7 +153,6 @@
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Words\Resource1.resx">
|
<EmbeddedResource Include="Words\Resource1.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resource1.Designer.cs</LastGenOutput>
|
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Words\WordsCategoryControl.resx">
|
<EmbeddedResource Include="Words\WordsCategoryControl.resx">
|
||||||
|
|
|
||||||
|
|
@ -13,31 +13,55 @@ using System.Windows.Forms;
|
||||||
namespace Reseter2.Setting
|
namespace Reseter2.Setting
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
internal static class SGlobalSetting
|
internal static class SGlobalSetting
|
||||||
{
|
{
|
||||||
// public static SettingHistory settingHistory
|
|
||||||
public static SettingWords settingWords = new SettingWords();
|
public static SettingWords settingWords = new SettingWords();
|
||||||
|
|
||||||
|
//public static void LoadSetting()
|
||||||
|
// {
|
||||||
|
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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();
|
BinaryFormatter binaryFormatter = new BinaryFormatter();
|
||||||
FileStream file = null;
|
FileStream file = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
file = new FileStream(path, FileMode.Open);
|
file = new FileStream(path, FileMode.Open);
|
||||||
WordsList.MainCategory = (WordsCategory)binaryFormatter.Deserialize(file);
|
obj = binaryFormatter.Deserialize(file);
|
||||||
file.Close();
|
file.Close();
|
||||||
file.Dispose();
|
file.Dispose();
|
||||||
return true;
|
return obj;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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<HistoryItem> historyItems;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,73 +0,0 @@
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// Этот код создан программой.
|
|
||||||
// Исполняемая версия:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
|
||||||
// повторной генерации кода.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace Reseter2.Words {
|
|
||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
|
||||||
/// </summary>
|
|
||||||
// Этот класс создан автоматически классом 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() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
|
||||||
/// </summary>
|
|
||||||
[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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
|
||||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
|
||||||
get {
|
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap comp1 {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("comp1", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -119,6 +119,6 @@
|
||||||
</resheader>
|
</resheader>
|
||||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
<data name="comp1" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="comp1" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\comp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Loading…
Reference in New Issue