first commit

This commit is contained in:
2026-01-07 11:33:05 +08:00
commit fc54ffd43b
215 changed files with 31856 additions and 0 deletions

185
QuickTools/Form1.Designer.cs generated Normal file
View File

@@ -0,0 +1,185 @@
namespace QuickTools
{
partial class Form1
{
/// <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()
{
btnEncode = new Button();
tableLayoutPanel1 = new TableLayoutPanel();
panel1 = new Panel();
label1 = new Label();
btnDecode = new Button();
txtProtoId = new TextBox();
groupBox1 = new GroupBox();
groupBox2 = new GroupBox();
txtProto = new TextBox();
this.txtJson = new ICSharpCode.TextEditor.TextEditorControlEx();
tableLayoutPanel1.SuspendLayout();
panel1.SuspendLayout();
groupBox1.SuspendLayout();
groupBox2.SuspendLayout();
SuspendLayout();
//
// btnEncode
//
btnEncode.Location = new Point(3, 49);
btnEncode.Name = "btnEncode";
btnEncode.Size = new Size(75, 23);
btnEncode.TabIndex = 0;
btnEncode.Text = "→";
btnEncode.UseVisualStyleBackColor = true;
btnEncode.Click += btnEncode_Click;
//
// tableLayoutPanel1
//
tableLayoutPanel1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
tableLayoutPanel1.ColumnCount = 3;
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 89F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutPanel1.Controls.Add(panel1, 1, 0);
tableLayoutPanel1.Controls.Add(groupBox1, 0, 0);
tableLayoutPanel1.Controls.Add(groupBox2, 2, 0);
tableLayoutPanel1.Location = new Point(12, 12);
tableLayoutPanel1.Name = "tableLayoutPanel1";
tableLayoutPanel1.RowCount = 1;
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
tableLayoutPanel1.Size = new Size(815, 444);
tableLayoutPanel1.TabIndex = 2;
//
// panel1
//
panel1.Controls.Add(label1);
panel1.Controls.Add(btnDecode);
panel1.Controls.Add(btnEncode);
panel1.Controls.Add(txtProtoId);
panel1.Dock = DockStyle.Fill;
panel1.Location = new Point(366, 3);
panel1.Name = "panel1";
panel1.Size = new Size(83, 438);
panel1.TabIndex = 0;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(3, 0);
label1.Name = "label1";
label1.Size = new Size(74, 17);
label1.TabIndex = 1;
label1.Text = "Protocol ID";
label1.TextAlign = ContentAlignment.MiddleCenter;
//
// btnDecode
//
btnDecode.Location = new Point(3, 78);
btnDecode.Name = "btnDecode";
btnDecode.Size = new Size(75, 23);
btnDecode.TabIndex = 0;
btnDecode.Text = "←";
btnDecode.UseVisualStyleBackColor = true;
btnDecode.Click += btnDecode_Click;
//
// txtProtoId
//
txtProtoId.Location = new Point(3, 20);
txtProtoId.Name = "txtProtoId";
txtProtoId.Size = new Size(74, 23);
txtProtoId.TabIndex = 0;
//
// groupBox1
//
groupBox1.Controls.Add(this.txtJson);
groupBox1.Dock = DockStyle.Fill;
groupBox1.Location = new Point(3, 3);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(357, 438);
groupBox1.TabIndex = 1;
groupBox1.TabStop = false;
groupBox1.Text = "JSON";
//
// groupBox2
//
groupBox2.Controls.Add(txtProto);
groupBox2.Dock = DockStyle.Fill;
groupBox2.Location = new Point(455, 3);
groupBox2.Name = "groupBox2";
groupBox2.Size = new Size(357, 438);
groupBox2.TabIndex = 1;
groupBox2.TabStop = false;
groupBox2.Text = "Protobuf(Base64)";
//
// txtProto
//
txtProto.Dock = DockStyle.Fill;
txtProto.Location = new Point(3, 19);
txtProto.Multiline = true;
txtProto.Name = "txtProto";
txtProto.ScrollBars = ScrollBars.Both;
txtProto.Size = new Size(351, 416);
txtProto.TabIndex = 1;
//
// txtJson
//
this.txtJson.Font = new Font("Courier New", 10F, FontStyle.Regular, GraphicsUnit.Point);
this.txtJson.Location = new Point(6, 19);
this.txtJson.Name = "txtJson";
this.txtJson.Size = new Size(351, 416);
this.txtJson.SyntaxHighlighting = "JSON";
this.txtJson.FoldingStrategy = "JSON";
this.txtJson.TabIndex = 0;
//
// Form1
//
AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(832, 460);
Controls.Add(tableLayoutPanel1);
Name = "Form1";
Text = "Form1";
tableLayoutPanel1.ResumeLayout(false);
panel1.ResumeLayout(false);
panel1.PerformLayout();
groupBox1.ResumeLayout(false);
groupBox2.ResumeLayout(false);
groupBox2.PerformLayout();
ResumeLayout(false);
}
#endregion
private Button btnEncode;
private TableLayoutPanel tableLayoutPanel1;
private Panel panel1;
private Label label1;
private Button btnDecode;
private TextBox txtProtoId;
private GroupBox groupBox1;
private GroupBox groupBox2;
private TextBox txtProto;
private ICSharpCode.TextEditor.TextEditorControlEx txtJson;
}
}

139
QuickTools/Form1.cs Normal file
View File

@@ -0,0 +1,139 @@
using Flurl.Http;
using Newtonsoft.Json.Linq;
using System.Diagnostics;
namespace QuickTools
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private async void btnEncode_Click(object sender, EventArgs e)
{
if (txtProtoId.Text.Trim() == string.Empty)
{
MessageBox.Show("ProtocolID <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>", "<22><><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
int protocolId;
try
{
protocolId = Convert.ToInt32(txtProtoId.Text.Trim());
}
catch
{
MessageBox.Show("ProtocolID ֻ<><D6BB>Ϊ<EFBFBD><CEAA><EFBFBD>֣<EFBFBD>", "<22><><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
var url = "http://localhost:9999/api/v1/emoney/converter/request/encode";
try
{
string r = await url.PostJsonAsync(new
{
protocolId,
protocolBody = txtJson.Text,
}).Result.Content.ReadAsStringAsync();
if (r != null)
{
JObject jo = JObject.Parse(r);
if (jo["code"].Value<int>() == 0)
{
txtProto.Text = jo["result"].Value<string>();
}
else
{
MessageBox.Show(jo["msg"].Value<string>(), "<22><><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.StackTrace);
MessageBox.Show($"ת<><D7AA> JSON Ϊ Protobuf <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD>{ex.Message}", "<22><><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
private async void btnDecode_Click(object sender, EventArgs e)
{
if (txtProtoId.Text.Trim() == string.Empty)
{
MessageBox.Show("ProtocolID <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>", "<22><><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
int protocolId;
try
{
protocolId = Convert.ToInt32(txtProtoId.Text.Trim());
}
catch
{
MessageBox.Show("ProtocolID ֻ<><D6BB>Ϊ<EFBFBD><CEAA><EFBFBD>֣<EFBFBD>", "<22><><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
var url = "http://localhost:9999/api/v1/emoney/converter/request/decode";
try
{
string r = await url.PostJsonAsync(new
{
protocolId,
protocolBody = txtProto.Text,
}).Result.Content.ReadAsStringAsync();
if (r != null)
{
JObject jo = JObject.Parse(r);
if (jo["code"].Value<int>() == 0)
{
txtJson.Text = ClearSizeInfo(jo["result"]).ToString();
}
else
{
MessageBox.Show(jo["msg"].Value<string>(), "<22><><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.StackTrace);
MessageBox.Show($"ת<><D7AA> Protobuf Ϊ JSON <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD>{ex.Message}", "<22><><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
public static JToken ClearSizeInfo(JToken j)
{
if (j == null) return null;
if (j is JArray ja)
{
for (int i = 0; i < ja.Count; i++)
{
ja[i] = ClearSizeInfo(ja[i]);
}
return ja;
}
if (j is JObject jo)
{
if (jo.ContainsKey("cachedSize"))
{
jo.Remove("cachedSize");
}
if (jo.ContainsKey("serializedSize"))
{
jo.Remove("serializedSize");
}
foreach (var p in jo)
{
string key = p.Key;
JToken val = p.Value;
jo[key] = ClearSizeInfo(val);
}
return jo;
}
return j;
}
}
}

60
QuickTools/Form1.resx Normal file
View File

@@ -0,0 +1,60 @@
<root>
<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>
</root>

17
QuickTools/Program.cs Normal file
View File

@@ -0,0 +1,17 @@
namespace QuickTools
{
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 Form1());
}
}
}

View File

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Flurl.Http" Version="2.4.1" />
</ItemGroup>
</Project>