Клиент каноникализатора под WinGUI

This commit is contained in:
Гершман Антон Лейбович 2026-08-03 13:59:50 +03:00
parent d58147a9b2
commit e0a63d2ef6
6 changed files with 370 additions and 0 deletions

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\JsonCanonicalizer.BL\JsonCanonicalizer.BL.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,145 @@
namespace JsonCanonicalizer.UI
{
partial class OneFileTaskForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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);
}
}
}

View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="dlgSrcFile.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="dlgDstFile.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>156, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,17 @@
namespace JsonCanonicalizer.UI
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[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());
}
}
}

View File

@ -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