From 527aae7b40186cdffc9555f99f03a0c76e0e9ac1 Mon Sep 17 00:00:00 2001 From: Lev Rusanov <30170278+JDM170@users.noreply.github.com> Date: Thu, 20 Feb 2025 20:09:17 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BD?= =?UTF-8?q?=D0=B0=20=D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D0=B0=20=D0=B2?= =?UTF-8?q?=D0=B7=D0=B0=D0=B8=D0=BC=D0=BE=D0=B4=D0=B5=D0=B9=D1=81=D1=82?= =?UTF-8?q?=D0=B2=D0=B8=D1=8F=20=D1=81=D0=BE=20=D1=81=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com> --- .gitignore | 5 ++ App.config | 6 ++ MainForm.Designer.cs | 40 +++++++++++ MainForm.cs | 20 ++++++ Program.cs | 22 ++++++ Properties/AssemblyInfo.cs | 33 +++++++++ Properties/Resources.Designer.cs | 71 +++++++++++++++++++ Properties/Resources.resx | 117 +++++++++++++++++++++++++++++++ Properties/Settings.Designer.cs | 30 ++++++++ Properties/Settings.settings | 7 ++ RegexHandler.cs | 94 +++++++++++++++++++++++++ SaveWizard_rewritten.csproj | 82 ++++++++++++++++++++++ SaveWizard_rewritten.sln | 25 +++++++ Utils.cs | 27 +++++++ 14 files changed, 579 insertions(+) create mode 100644 .gitignore create mode 100644 App.config create mode 100644 MainForm.Designer.cs create mode 100644 MainForm.cs create mode 100644 Program.cs create mode 100644 Properties/AssemblyInfo.cs create mode 100644 Properties/Resources.Designer.cs create mode 100644 Properties/Resources.resx create mode 100644 Properties/Settings.Designer.cs create mode 100644 Properties/Settings.settings create mode 100644 RegexHandler.cs create mode 100644 SaveWizard_rewritten.csproj create mode 100644 SaveWizard_rewritten.sln create mode 100644 Utils.cs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..93621e5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.vs +bin/ +obj/ +packages/ +*.csproj.user diff --git a/App.config b/App.config new file mode 100644 index 0000000..193aecc --- /dev/null +++ b/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs new file mode 100644 index 0000000..5217edf --- /dev/null +++ b/MainForm.Designer.cs @@ -0,0 +1,40 @@ +namespace SaveWizard_rewritten +{ + partial class MainForm + { + /// + /// Обязательная переменная конструктора. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором форм Windows + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "Form1"; + } + + #endregion + } +} + diff --git a/MainForm.cs b/MainForm.cs new file mode 100644 index 0000000..ddb1566 --- /dev/null +++ b/MainForm.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SaveWizard_rewritten +{ + public partial class MainForm: Form + { + public MainForm() + { + InitializeComponent(); + } + } +} diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..90f545a --- /dev/null +++ b/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SaveWizard_rewritten +{ + static class Program + { + /// + /// Главная точка входа для приложения. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ee6a2c2 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов для изменения сведений, +// связанных со сборкой. +[assembly: AssemblyTitle("SaveWizard_rewritten")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SaveWizard_rewritten")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// COM, следует установить атрибут ComVisible в TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("a08c24b5-43a9-4e0b-8c5c-0ab019cbafe8")] + +// Сведения о версии сборки состоят из указанных ниже четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs new file mode 100644 index 0000000..9e952cf --- /dev/null +++ b/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программным средством. +// Версия среды выполнения: 4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если +// код создан повторно. +// +//------------------------------------------------------------------------------ + +namespace SaveWizard_rewritten.Properties +{ + + + /// + /// Класс ресурсов со строгим типом для поиска локализованных строк и пр. + /// + // Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder + // класс с помощью таких средств, как ResGen или Visual Studio. + // Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen + // с параметром /str или заново постройте свой VS-проект. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Возврат кэшированного экземпляра ResourceManager, используемого этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SaveWizard_rewritten.Properties.Resources", typeof(Resources).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; + } + } + } +} diff --git a/Properties/Resources.resx b/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs new file mode 100644 index 0000000..d1e3287 --- /dev/null +++ b/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SaveWizard_rewritten.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Properties/Settings.settings b/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/RegexHandler.cs b/RegexHandler.cs new file mode 100644 index 0000000..793d200 --- /dev/null +++ b/RegexHandler.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace SaveWizard_rewritten +{ + static class RegexHandler + { + private static List lines; + + public static void FillLines(List _lines) + { + lines = _lines; + } + + public static string GetLine(int index) + { + return lines[index]; + } + + public static List GetAllLines() + { + return lines; + } + + public static int SearchLine(string term, int start = 0, string cancel = "this_string_must_not_exist") + { + if (lines[start].Contains(term)) + return start; + start += 1; + while (start <= (lines.Count-1)) { + if (lines[start].Contains(term)) + return start; + if (lines[start].Contains(cancel)) + return 0; + start += 1; + } + return 0; + } + + public static int SearchLineInUnit(string term, string unit) + { + return SearchLine(term, start: SearchLine(" : " + unit + " {"), cancel: "}"); + } + + public static List SearchAllLines(string term) + { + List matches = new List(); + int line = 0; + while (SearchLine(term, start: line + 1) != 0) + { + line = SearchLine(term, start: line + 1); + matches.Add(line); + } + if (matches.Count == 0) + return null; + return matches; + } + + public static string GetValue(int line) + { + return Regex.Match(": (.+)$", lines[line]).Value; + } + + public static void SetValue(int line, string value) + { + string name = Regex.Match("(.+):", lines[line]).Value; + lines[line] = $"{name}: {value}"; + } + + public static int GetArrayLength(int line) + { + return Convert.ToInt32(Regex.Match(": ([0-9]+)$", lines[line]).Value); + } + + public static List GetArrayItems(int line) + { + List items = new List(); + for (int i = 0; i < GetArrayLength(line); i++) + items.Add(Regex.Match(": (.+)$", lines[line + i + 1]).Value); + if (items.Count == 0) + return null; + return items; + } + + public static void AddArrayValue(int line, string value) + { + string name = Regex.Match("(.+):", lines[line]).Value; + int length = GetArrayLength(line); + lines[line] = $"{name}: {length + 1}"; + lines.Insert(line + length + 1, $"{name}[{length}]: {value}"); + } + } +} diff --git a/SaveWizard_rewritten.csproj b/SaveWizard_rewritten.csproj new file mode 100644 index 0000000..4ecc674 --- /dev/null +++ b/SaveWizard_rewritten.csproj @@ -0,0 +1,82 @@ + + + + + Debug + AnyCPU + {A08C24B5-43A9-4E0B-8C5C-0AB019CBAFE8} + WinExe + SaveWizard_rewritten + SaveWizard_rewritten + v4.8 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + Form + + + MainForm.cs + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/SaveWizard_rewritten.sln b/SaveWizard_rewritten.sln new file mode 100644 index 0000000..391bb6c --- /dev/null +++ b/SaveWizard_rewritten.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.13.35806.99 d17.13 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SaveWizard_rewritten", "SaveWizard_rewritten.csproj", "{A08C24B5-43A9-4E0B-8C5C-0AB019CBAFE8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A08C24B5-43A9-4E0B-8C5C-0AB019CBAFE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A08C24B5-43A9-4E0B-8C5C-0AB019CBAFE8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A08C24B5-43A9-4E0B-8C5C-0AB019CBAFE8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A08C24B5-43A9-4E0B-8C5C-0AB019CBAFE8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4346FDD4-4C80-4F6E-AEFA-7F23A9C15B50} + EndGlobalSection +EndGlobal diff --git a/Utils.cs b/Utils.cs new file mode 100644 index 0000000..51ae95c --- /dev/null +++ b/Utils.cs @@ -0,0 +1,27 @@ +using System.IO; +using System.Security.Cryptography; +using System.Text; + +namespace SaveWizard_rewritten +{ + static class Utils + { + public static string GenerateMD5(string filename) + { + if (!File.Exists(filename)) + return null; + using (var md5 = MD5.Create()) + { + using (FileStream stream = File.OpenRead(filename)) + md5.ComputeHash(stream); + + StringBuilder sb = new StringBuilder(); + byte[] hash = md5.Hash; + for (int i = 0; i < hash.Length; i++) + sb.Append(hash[i].ToString("x2")); + + return sb.ToString(); + } + } + } +}