Add Test page

This commit is contained in:
2022-12-15 20:32:01 +08:00
parent 5d208d1220
commit d56c73e2a3
5 changed files with 254 additions and 0 deletions

View File

@ -101,6 +101,7 @@ namespace GrasscutterTools.Forms
TPQuest.Controls.Add(CreatePage<PageQuest>());
TPScene.Controls.Add(CreatePage<PageScene>());
TPAbout.Controls.Add(CreatePage<PageAbout>());
//TPAbout.Controls.Add(CreatePage<PageTools>());
TCMain.ResumeLayout();
Logger.I(TAG, "InitPages completed");
}

View File

@ -244,6 +244,12 @@
<Compile Include="Pages\PageTasks.Designer.cs">
<DependentUpon>PageTasks.cs</DependentUpon>
</Compile>
<Compile Include="Pages\PageTools.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Pages\PageTools.Designer.cs">
<DependentUpon>PageTools.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.zh-TW.Designer.cs">
@ -514,6 +520,9 @@
<EmbeddedResource Include="Pages\PageTasks.zh-TW.resx">
<DependentUpon>PageTasks.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Pages\PageTools.resx">
<DependentUpon>PageTools.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.zh-TW.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.zh-TW.Designer.cs</LastGenOutput>

View File

@ -0,0 +1,58 @@
namespace GrasscutterTools.Pages
{
partial class PageTools
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.BtnUpdateResources = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// BtnUpdateResources
//
this.BtnUpdateResources.Location = new System.Drawing.Point(3, 3);
this.BtnUpdateResources.Name = "BtnUpdateResources";
this.BtnUpdateResources.Size = new System.Drawing.Size(100, 30);
this.BtnUpdateResources.TabIndex = 0;
this.BtnUpdateResources.Text = "Update res";
this.BtnUpdateResources.UseVisualStyleBackColor = true;
this.BtnUpdateResources.Click += new System.EventHandler(this.BtnUpdateResources_Click);
//
// PageTools
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.BtnUpdateResources);
this.Name = "PageTools";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button BtnUpdateResources;
}
}

View File

@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
namespace GrasscutterTools.Pages
{
internal partial class PageTools : BasePage
{
public PageTools()
{
InitializeComponent();
}
private void BtnUpdateResources_Click(object sender, EventArgs e)
{
var src = new OpenFileDialog
{
Title = "请选择当前原文件",
Multiselect = false,
};
var dest = new OpenFileDialog
{
Title = "请选择包含新ID的文件",
Multiselect = false,
};
if (src.ShowDialog() == DialogResult.OK && dest.ShowDialog() == DialogResult.OK)
{
var srcLines = File.ReadAllLines(src.FileName);
var srcDic = new Dictionary<string, string>(srcLines.Length);
foreach (var line in srcLines)
{
var sp = line.IndexOf(':');
if (sp > 0)
{
var value = line.Substring(sp + 1).Trim();
if (!value.StartsWith("[N/A]"))
srcDic[line.Substring(0, sp).Trim()] = line.Substring(sp + 1).Trim();
}
}
var destLines = File.ReadAllLines(dest.FileName);
using (var outStream = File.Create(dest.FileName))
using (var outTxtStream = new StreamWriter(outStream))
{
foreach (var line in destLines)
{
var sp = line.IndexOf(':');
if (sp == -1)
{
outTxtStream.WriteLine(line);
}
else
{
var key = line.Substring(0, sp).Trim();
if (!srcDic.TryGetValue(key, out var value))
value = line.Substring(sp + 1).Trim();
outTxtStream.WriteLine($"{key}:{value}");
}
}
}
}
}
}
}

View File

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