From e0a63d2ef6b39849123ca80275c473ac5eb74903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=B5=D1=80=D1=88=D0=BC=D0=B0=D0=BD=20=D0=90=D0=BD?= =?UTF-8?q?=D1=82=D0=BE=D0=BD=20=D0=9B=D0=B5=D0=B9=D0=B1=D0=BE=D0=B2=D0=B8?= =?UTF-8?q?=D1=87?= Date: Mon, 3 Aug 2026 13:59:50 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=20=D0=BA?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=BD=D0=B8=D0=BA=D0=B0=D0=BB=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D1=80=D0=B0=20=D0=BF=D0=BE=D0=B4=20WinGUI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JsonCanonicalizer.UI.csproj | 15 ++ .../OneFileTaskForm.Designer.cs | 145 ++++++++++++++++++ JsonCanonicalizer.UI/OneFileTaskForm.cs | 61 ++++++++ JsonCanonicalizer.UI/OneFileTaskForm.resx | 126 +++++++++++++++ JsonCanonicalizer.UI/Program.cs | 17 ++ JsonCanonicalizer.sln | 6 + 6 files changed, 370 insertions(+) create mode 100644 JsonCanonicalizer.UI/JsonCanonicalizer.UI.csproj create mode 100644 JsonCanonicalizer.UI/OneFileTaskForm.Designer.cs create mode 100644 JsonCanonicalizer.UI/OneFileTaskForm.cs create mode 100644 JsonCanonicalizer.UI/OneFileTaskForm.resx create mode 100644 JsonCanonicalizer.UI/Program.cs diff --git a/JsonCanonicalizer.UI/JsonCanonicalizer.UI.csproj b/JsonCanonicalizer.UI/JsonCanonicalizer.UI.csproj new file mode 100644 index 0000000..1dac222 --- /dev/null +++ b/JsonCanonicalizer.UI/JsonCanonicalizer.UI.csproj @@ -0,0 +1,15 @@ + + + + WinExe + net8.0-windows + enable + true + enable + + + + + + + \ No newline at end of file diff --git a/JsonCanonicalizer.UI/OneFileTaskForm.Designer.cs b/JsonCanonicalizer.UI/OneFileTaskForm.Designer.cs new file mode 100644 index 0000000..78463b4 --- /dev/null +++ b/JsonCanonicalizer.UI/OneFileTaskForm.Designer.cs @@ -0,0 +1,145 @@ +namespace JsonCanonicalizer.UI +{ + partial class OneFileTaskForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + lblSrcFile = new Label(); + txtSrcFile = new TextBox(); + btnSrcFile = new Button(); + txtDstFile = new TextBox(); + lblDstFile = new Label(); + btnDstFile = new Button(); + btnDoIt = new Button(); + dlgSrcFile = new OpenFileDialog(); + dlgDstFile = new SaveFileDialog(); + SuspendLayout(); + // + // lblSrcFile + // + lblSrcFile.AutoSize = true; + lblSrcFile.Location = new Point(12, 15); + lblSrcFile.Name = "lblSrcFile"; + lblSrcFile.Size = new Size(99, 15); + lblSrcFile.TabIndex = 0; + lblSrcFile.Text = "Исходный файл:"; + // + // txtSrcFile + // + txtSrcFile.Location = new Point(117, 12); + txtSrcFile.Name = "txtSrcFile"; + txtSrcFile.Size = new Size(377, 23); + txtSrcFile.TabIndex = 1; + // + // btnSrcFile + // + btnSrcFile.Location = new Point(500, 12); + btnSrcFile.Name = "btnSrcFile"; + btnSrcFile.Size = new Size(79, 23); + btnSrcFile.TabIndex = 2; + btnSrcFile.Text = ". . ."; + btnSrcFile.UseVisualStyleBackColor = true; + btnSrcFile.Click += btnSrcFile_Click; + // + // txtDstFile + // + txtDstFile.Location = new Point(117, 41); + txtDstFile.Name = "txtDstFile"; + txtDstFile.Size = new Size(377, 23); + txtDstFile.TabIndex = 3; + // + // lblDstFile + // + lblDstFile.AutoSize = true; + lblDstFile.Location = new Point(12, 44); + lblDstFile.Name = "lblDstFile"; + lblDstFile.Size = new Size(63, 15); + lblDstFile.TabIndex = 4; + lblDstFile.Text = "Результат:"; + // + // btnDstFile + // + btnDstFile.Location = new Point(500, 41); + btnDstFile.Name = "btnDstFile"; + btnDstFile.Size = new Size(79, 23); + btnDstFile.TabIndex = 5; + btnDstFile.Text = ". . ."; + btnDstFile.UseVisualStyleBackColor = true; + btnDstFile.Click += btnDstFile_Click; + // + // btnDoIt + // + btnDoIt.Location = new Point(500, 77); + btnDoIt.Name = "btnDoIt"; + btnDoIt.Size = new Size(79, 46); + btnDoIt.TabIndex = 6; + btnDoIt.Text = "DO IT"; + btnDoIt.UseVisualStyleBackColor = true; + btnDoIt.Click += this.btnDoIt_Click; + // + // dlgSrcFile + // + dlgSrcFile.Filter = "Файлы JSON|*.json|Все файлы|*"; + dlgSrcFile.Title = "Файл для каноникализации"; + // + // dlgDstFile + // + dlgDstFile.Filter = "Файлы JSON|*.json|Все файлы|*"; + dlgDstFile.Title = "Каноникализированный файл"; + // + // OneFileTaskForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(591, 135); + Controls.Add(btnDoIt); + Controls.Add(btnDstFile); + Controls.Add(lblDstFile); + Controls.Add(txtDstFile); + Controls.Add(btnSrcFile); + Controls.Add(txtSrcFile); + Controls.Add(lblSrcFile); + FormBorderStyle = FormBorderStyle.FixedDialog; + Name = "OneFileTaskForm"; + Text = "Каноникализатор JSON"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label lblSrcFile; + private TextBox txtSrcFile; + private Button btnSrcFile; + private TextBox txtDstFile; + private Label lblDstFile; + private Button btnDstFile; + private Button btnDoIt; + private OpenFileDialog dlgSrcFile; + private SaveFileDialog dlgDstFile; + } +} diff --git a/JsonCanonicalizer.UI/OneFileTaskForm.cs b/JsonCanonicalizer.UI/OneFileTaskForm.cs new file mode 100644 index 0000000..2f8998c --- /dev/null +++ b/JsonCanonicalizer.UI/OneFileTaskForm.cs @@ -0,0 +1,61 @@ +namespace JsonCanonicalizer.UI; + +public partial class OneFileTaskForm : Form +{ + public OneFileTaskForm() + { + InitializeComponent(); + } + + private void btnSrcFile_Click(object sender, EventArgs e) + { + dlgSrcFile.FileName = txtSrcFile.Text; + if (dlgSrcFile.ShowDialog() == DialogResult.OK) + { + txtSrcFile.Text = dlgSrcFile.FileName; + } + } + + private void btnDstFile_Click(object sender, EventArgs e) + { + dlgDstFile.FileName = txtDstFile.Text; + if (dlgDstFile.ShowDialog() == DialogResult.OK) + { + txtDstFile.Text = dlgDstFile.FileName; + } + } + + private void btnDoIt_Click(object sender, EventArgs e) + { + if (String.IsNullOrWhiteSpace(txtSrcFile.Text)) + { + MessageBox.Show(" ", Text, MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + if (String.IsNullOrWhiteSpace(txtDstFile.Text)) + { + MessageBox.Show(" ", Text, MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + if (!File.Exists(txtSrcFile.Text)) + { + MessageBox.Show(" ", Text, MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + try + { + using Stream src = new FileStream(txtSrcFile.Text, FileMode.Open); + using Stream dst = new FileStream(txtDstFile.Text, FileMode.Create); + BL.Canonicalizer.Canonicalize(src, dst); + + MessageBox.Show("", Text, MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } +} diff --git a/JsonCanonicalizer.UI/OneFileTaskForm.resx b/JsonCanonicalizer.UI/OneFileTaskForm.resx new file mode 100644 index 0000000..067fc94 --- /dev/null +++ b/JsonCanonicalizer.UI/OneFileTaskForm.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 156, 17 + + \ No newline at end of file diff --git a/JsonCanonicalizer.UI/Program.cs b/JsonCanonicalizer.UI/Program.cs new file mode 100644 index 0000000..f308cdb --- /dev/null +++ b/JsonCanonicalizer.UI/Program.cs @@ -0,0 +1,17 @@ +namespace JsonCanonicalizer.UI +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new OneFileTaskForm()); + } + } +} \ No newline at end of file diff --git a/JsonCanonicalizer.sln b/JsonCanonicalizer.sln index 0f9e7b4..6b5ce38 100644 --- a/JsonCanonicalizer.sln +++ b/JsonCanonicalizer.sln @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonCanonicalizer.BL", "Jso EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonCanonicalizer.Test", "JsonCanicalizer.Test\JsonCanonicalizer.Test.csproj", "{E43C66DF-FE35-4752-8201-A08E807122DB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonCanonicalizer.UI", "JsonCanonicalizer.UI\JsonCanonicalizer.UI.csproj", "{4F6E83B8-D21F-412A-83C9-71BB82A82C92}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,6 +29,10 @@ Global {E43C66DF-FE35-4752-8201-A08E807122DB}.Debug|Any CPU.Build.0 = Debug|Any CPU {E43C66DF-FE35-4752-8201-A08E807122DB}.Release|Any CPU.ActiveCfg = Release|Any CPU {E43C66DF-FE35-4752-8201-A08E807122DB}.Release|Any CPU.Build.0 = Release|Any CPU + {4F6E83B8-D21F-412A-83C9-71BB82A82C92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F6E83B8-D21F-412A-83C9-71BB82A82C92}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F6E83B8-D21F-412A-83C9-71BB82A82C92}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F6E83B8-D21F-412A-83C9-71BB82A82C92}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE