commit 5c6aab9fe28e6544a2bab0e43dfff07399f594ac
Author: MADxingjin <25790044+MADxingjin@users.noreply.github.com>
Date: Thu Jan 4 17:26:29 2024 +0800
First version that actully working.
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d846f4d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+*/bin
+.vs
+.idea
+*/obj
\ No newline at end of file
diff --git a/AvaloniaApplication2/App.axaml b/AvaloniaApplication2/App.axaml
new file mode 100644
index 0000000..d6ab0d8
--- /dev/null
+++ b/AvaloniaApplication2/App.axaml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AvaloniaApplication2/App.axaml.cs b/AvaloniaApplication2/App.axaml.cs
new file mode 100644
index 0000000..d82a0f0
--- /dev/null
+++ b/AvaloniaApplication2/App.axaml.cs
@@ -0,0 +1,25 @@
+using Avalonia;
+using Avalonia.Controls.ApplicationLifetimes;
+using Avalonia.Markup.Xaml;
+using AvaloniaApplication2.ViewModels;
+using AvaloniaApplication2.Views;
+
+namespace AvaloniaApplication2;
+
+public partial class App : Application
+{
+ public override void Initialize()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+
+ public override void OnFrameworkInitializationCompleted()
+ {
+ if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
+ {
+ desktop.MainWindow = new MainWindow();
+ }
+
+ base.OnFrameworkInitializationCompleted();
+ }
+}
\ No newline at end of file
diff --git a/AvaloniaApplication2/Assets/avalonia-logo.ico b/AvaloniaApplication2/Assets/avalonia-logo.ico
new file mode 100644
index 0000000..da8d49f
Binary files /dev/null and b/AvaloniaApplication2/Assets/avalonia-logo.ico differ
diff --git a/AvaloniaApplication2/AvaloniaApplication2.csproj b/AvaloniaApplication2/AvaloniaApplication2.csproj
new file mode 100644
index 0000000..a0c15d8
--- /dev/null
+++ b/AvaloniaApplication2/AvaloniaApplication2.csproj
@@ -0,0 +1,47 @@
+
+
+ WinExe
+ net6.0
+ enable
+ true
+ app.manifest
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ MainWindow.axaml
+ Code
+
+
+
+
+
+
+
+
+
+ Always
+
+
+
diff --git a/AvaloniaApplication2/Program.cs b/AvaloniaApplication2/Program.cs
new file mode 100644
index 0000000..d306580
--- /dev/null
+++ b/AvaloniaApplication2/Program.cs
@@ -0,0 +1,22 @@
+using Avalonia;
+using Avalonia.ReactiveUI;
+using System;
+
+namespace AvaloniaApplication2;
+
+class Program
+{
+ // Initialization code. Don't use any Avalonia, third-party APIs or any
+ // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
+ // yet and stuff might break.
+ [STAThread]
+ public static void Main(string[] args) => BuildAvaloniaApp()
+ .StartWithClassicDesktopLifetime(args);
+
+ // Avalonia configuration, don't remove; also used by visual designer.
+ public static AppBuilder BuildAvaloniaApp()
+ => AppBuilder.Configure()
+ .UsePlatformDetect()
+ .LogToTrace()
+ .UseReactiveUI();
+}
\ No newline at end of file
diff --git a/AvaloniaApplication2/ViewModels/MainWindowViewModel.cs b/AvaloniaApplication2/ViewModels/MainWindowViewModel.cs
new file mode 100644
index 0000000..59770ac
--- /dev/null
+++ b/AvaloniaApplication2/ViewModels/MainWindowViewModel.cs
@@ -0,0 +1,51 @@
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Xml;
+using ReactiveUI;
+using TransTool;
+
+namespace AvaloniaApplication2.ViewModels;
+
+public class MainWindowViewModel : ViewModelBase
+{
+ private List _Keys;
+
+ public ObservableCollection Keys
+ {
+ get { return new ObservableCollection(_Keys); }
+ }
+
+ public MainWindowViewModel()
+ {
+ _Keys = new();
+ var testxmlpath = @".\\test.xml";
+ XmlDocument doc = new();
+ doc.Load(testxmlpath);
+ _Greeting += "\n XML Loaded";
+ var xer = doc.DocumentElement;
+ var xnlist = xer.ChildNodes;
+ var orig = string.Empty;
+ var target = string.Empty;
+ foreach (XmlNode node in xnlist)
+ {
+ if (node.NodeType is XmlNodeType.Comment)
+ {
+ orig = node.Value;
+ }
+ else
+ {
+ target = node.InnerText;
+ _Keys.Add(new TKey(orig, target,node.Name));
+ orig = target = string.Empty;
+ }
+ }
+
+ _Greeting += "\n DATA LOADED";
+ }
+
+ private string _Greeting = "Avalonia Testing";
+ public string Greeting
+ {
+ get { return _Greeting; }
+ }
+}
\ No newline at end of file
diff --git a/AvaloniaApplication2/ViewModels/ViewModelBase.cs b/AvaloniaApplication2/ViewModels/ViewModelBase.cs
new file mode 100644
index 0000000..27e5c75
--- /dev/null
+++ b/AvaloniaApplication2/ViewModels/ViewModelBase.cs
@@ -0,0 +1,7 @@
+using ReactiveUI;
+
+namespace AvaloniaApplication2.ViewModels;
+
+public class ViewModelBase : ReactiveObject
+{
+}
\ No newline at end of file
diff --git a/AvaloniaApplication2/Views/MainWindow.axaml b/AvaloniaApplication2/Views/MainWindow.axaml
new file mode 100644
index 0000000..2795df2
--- /dev/null
+++ b/AvaloniaApplication2/Views/MainWindow.axaml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AvaloniaApplication2/Views/MainWindow.axaml.cs b/AvaloniaApplication2/Views/MainWindow.axaml.cs
new file mode 100644
index 0000000..001a4da
--- /dev/null
+++ b/AvaloniaApplication2/Views/MainWindow.axaml.cs
@@ -0,0 +1,14 @@
+using Avalonia.Controls;
+using AvaloniaApplication2.ViewModels;
+
+namespace AvaloniaApplication2.Views;
+
+public partial class MainWindow : Window
+{
+ public MainWindow()
+ {
+ InitializeComponent();
+ var viewModel = new MainWindowViewModel();
+ DataContext = viewModel;
+ }
+ }
\ No newline at end of file
diff --git a/AvaloniaApplication2/app.manifest b/AvaloniaApplication2/app.manifest
new file mode 100644
index 0000000..e0ce8d0
--- /dev/null
+++ b/AvaloniaApplication2/app.manifest
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AvaloniaApplication2/test.xml b/AvaloniaApplication2/test.xml
new file mode 100644
index 0000000..413c0e5
--- /dev/null
+++ b/AvaloniaApplication2/test.xml
@@ -0,0 +1,195 @@
+
+
+
+
+ 突击步枪子弹
+
+
+ 自动手枪子弹
+
+
+ 栓动步枪子弹
+
+
+ EMP弹
+
+
+ 重型冲锋枪子弹
+
+
+ 燃烧弹
+
+
+ 轻机枪子弹
+
+
+ 冲锋手枪子弹
+
+
+ 速射机枪子弹
+
+
+ 左轮手枪子弹
+
+
+ 霰弹枪子弹
+
+
+ 烟雾弹
+
+
+ 狙击步枪子弹
+
+
+ 突击步枪
+
+ 古老的制式军用武器,用于野外或城市作战。拥有良好的射程、火力和精度。
+
+ 枪托
+
+ 枪管
+
+ 突击步枪
+
+
+ 自动手枪
+
+ 古老构造的自动手枪。缺乏火力和射程,但开火迅速。
+
+ 握把
+
+ 枪管
+
+ 自动手枪
+
+
+ 栓动步枪
+
+ 古老的栓动式步枪。拥有良好的射程但射速低。
+
+ 枪托
+
+ 枪管
+
+ 栓动步枪
+
+
+ 链式霰弹枪
+
+ 古老的弹匣供弹全自动霰弹枪。射程短,精度低,但由于火力强大而极具威胁性。
+
+ 枪托
+
+ 枪管
+
+ 链式霰弹枪
+
+
+ EMP发射器
+
+ 一种宽口径EMP炮弹发射器。炮弹在撞击时会释放出一股电磁能量、瘫痪机械目标(机械体、炮塔、迫击炮)以及耗尽范围内护盾的能量。
+
+ 枪托
+
+ 枪管
+
+ EMP发射器
+
+
+ 重型冲锋枪
+
+ 古老的通用口径的紧凑型枪械。射程短,但着弹点集中、操控性好。
+
+ 握把
+
+ 枪管
+
+ 重型冲锋枪
+
+
+ 燃烧弹发射器
+
+ 古老的大口径燃烧弹发射器。能够点燃目标区域,可以用来放火。
+
+ 枪托
+
+ 枪管
+
+ 燃烧弹发射器
+
+
+ 轻机枪
+
+ 古老的轻机枪。较强的压制火力弥补了其他方面的不足。
+
+ 枪托
+
+ 枪管
+
+ 轻机枪
+
+
+ 冲锋手枪
+
+ 古老的微型冲锋枪。射程短,威力低,但射速很高。瞄准和开火都非常迅速敏捷。
+
+ 握把
+
+ 枪管
+
+ 冲锋手枪
+
+
+ 速射机枪
+
+ 古老的多管机枪,拥有极高的射速。虽然笨重但火力强大。在大多数自动武器使用火药提供动力的情况下,这种武器使用一种电动机使子弹能够快速替换。
+
+ 枪管
+
+ 速射机枪
+
+
+ 泵动霰弹枪
+
+ 古老的霰弹枪,拥有致命的火力,但射程较短。
+
+ 枪托
+
+ 枪管
+
+ 泵动霰弹枪
+
+
+ 左轮手枪
+
+ 古老构造的复动式左轮手枪。威力和射程一般,但射击迅速。
+
+ 握把
+
+ 枪管
+
+ 左轮手枪
+
+
+ 烟雾弹发射器
+
+ 一种大口径烟雾弹发射器。炮弹在撞击时会释放出一团烟雾,遮蔽瞄准的视线,也能够防止炮塔锁定。
+
+ 枪托
+
+ 枪管
+
+ 烟雾弹发射器
+
+
+ 狙击步枪
+
+ 样式古老的军用狙击步枪。栓动式。拥有极高的射程,很高的精度和良好的威力。但由于十分笨重,近距离的性能远不及其他武器。
+
+ 枪托
+
+ 枪管
+
+ 狙击步枪
+
+
\ No newline at end of file
diff --git a/TransTool/TFile.cs b/TransTool/TFile.cs
new file mode 100644
index 0000000..2b836a0
--- /dev/null
+++ b/TransTool/TFile.cs
@@ -0,0 +1,40 @@
+// ${File.SolutionName} / ${File.ProjectName} / ${File.FileName}
+// CREATED AT ${File.CreatedYear} / ${File.CreatedMonth} / ${File.CreatedDay}
+
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+
+namespace TransTool;
+
+public class TFile: INotifyPropertyChanged
+{
+ private string FileName;
+ private string FileNameShort;
+ private DateTime LastModified;
+ private DateTime Created;
+
+ public ObservableCollection Keys;
+
+ public TFile(string fileName, string fileNameShort)
+ {
+ FileName = fileName;
+ FileNameShort = fileNameShort;
+ Keys = new();
+ }
+
+ public event PropertyChangedEventHandler? PropertyChanged;
+
+ protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+
+ protected bool SetField(ref T field, T value, [CallerMemberName] string? propertyName = null)
+ {
+ if (EqualityComparer.Default.Equals(field, value)) return false;
+ field = value;
+ OnPropertyChanged(propertyName);
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/TransTool/TKey.cs b/TransTool/TKey.cs
new file mode 100644
index 0000000..5a2b807
--- /dev/null
+++ b/TransTool/TKey.cs
@@ -0,0 +1,16 @@
+// ${File.SolutionName} / ${File.ProjectName} / ${File.FileName}
+// CREATED AT ${File.CreatedYear} / ${File.CreatedMonth} / ${File.CreatedDay}
+namespace TransTool;
+public class TKey
+{
+ public string orig { get; set; }
+ public string target { get; set; }
+ public string ident { get; set; }
+
+ public TKey(string Orig,string Target,string Ident)
+ {
+ orig = Orig;
+ target = Target;
+ ident = Ident;
+ }
+}
\ No newline at end of file
diff --git a/TransTool/TransTool.csproj b/TransTool/TransTool.csproj
new file mode 100644
index 0000000..b3ba306
--- /dev/null
+++ b/TransTool/TransTool.csproj
@@ -0,0 +1,9 @@
+
+
+
+ enable
+ enable
+ net6.0
+
+
+
diff --git a/XMLTransTool/Program.cs b/XMLTransTool/Program.cs
new file mode 100644
index 0000000..405a857
--- /dev/null
+++ b/XMLTransTool/Program.cs
@@ -0,0 +1,47 @@
+// See https://aka.ms/new-console-template for more information
+
+using System.Text;
+using System.Xml;
+using XMLTransTool;
+
+Console.WriteLine("Hello, World!");
+string testxmlpath = @".\\test.xml";
+if (!File.Exists(testxmlpath))
+ return -1;
+XmlDocument doc = new();
+doc.Load(testxmlpath);
+XmlElement xer = doc.DocumentElement;
+XmlNodeList xnlist = xer.ChildNodes;
+PrintNodeInfo(xnlist);
+TransData td= AnalysisFile(xnlist);
+td.PrintContent();
+return 0;
+
+void PrintNodeInfo(XmlNodeList nodeList)
+{
+ foreach (XmlNode node in nodeList)
+ {
+
+ Console.WriteLine("Node {0}, Type == {1}, Content == {2}",node.Name,node.NodeType,node.NodeType is XmlNodeType.Element? node.InnerText : node.Value);
+ //if(node.HasChildNodes)
+ //PrintNodeInfo(node.ChildNodes);
+ }
+}
+TransData AnalysisFile(XmlNodeList nodeList)
+{
+ TransData td = new("Not a real name");
+ string orig = String.Empty;
+ string target = String.Empty;
+ foreach (XmlNode node in nodeList)
+ {
+ if (node.NodeType is XmlNodeType.Comment)
+ orig = node.Value;
+ else
+ {
+ target = node.InnerText;
+ td.AddText(node.Name,orig,target);
+ orig = target = String.Empty;
+ }
+ }
+ return td;
+}
\ No newline at end of file
diff --git a/XMLTransTool/TransData.cs b/XMLTransTool/TransData.cs
new file mode 100644
index 0000000..7a3ad3d
--- /dev/null
+++ b/XMLTransTool/TransData.cs
@@ -0,0 +1,72 @@
+// XMLTransTool / XMLTransTool / TransData.cs
+// CREATED AT 2023 / 12 / 25
+
+namespace XMLTransTool;
+
+///
+/// Obviously a primitive solution, improvements will be needed.
+/// Todo: Directly Create Content From iterating FileSystem.
+///
+public class TransData
+{
+ ///
+ /// Todo: Implement Short FileName.
+ ///
+ public string FileName;
+ public string FileNameFull;
+ ///
+ /// Key,Original,Target
+ ///
+ private Dictionary> Content;
+
+
+ public TransData(string fileNameFull)
+ {
+ FileNameFull = fileNameFull;
+ FileName = "!!!Not Implemented Short Name!!!";
+ Content = new();
+ }
+ public void AddText(string key,string eng, string target)
+ {
+ if (Content.ContainsKey(key))
+ {
+ throw new ArgumentException("Given Key has been defined Multiple times.",eng);
+ }
+
+ if (!Content.TryAdd(key,new KeyValuePair(eng,target)))
+ throw new ArgumentException("Failed to add given Key to internal Content Dict");
+ }
+
+ public void PrintContent()
+ {
+ Console.WriteLine("Now Printing Content of File [{0}]",FileNameFull);
+ foreach (KeyValuePair> pair in Content)
+ {
+ Console.WriteLine("{0} == {1}",pair.Key,pair.Value);
+ }
+ }
+
+ public List AllKeys()
+ {
+ return Content.Keys.ToList();
+ }
+
+ public List AllSrcs()
+ {
+ List r = new List();
+ foreach (KeyValuePair> pair in Content)
+ {
+ r.Add(pair.Value.Key);
+ }
+ return r;
+ }
+ public List AllTargets()
+ {
+ List r = new List();
+ foreach (KeyValuePair> pair in Content)
+ {
+ r.Add(pair.Value.Value);
+ }
+ return r;
+ }
+}
\ No newline at end of file
diff --git a/XMLTransTool/XMLTransTool.csproj b/XMLTransTool/XMLTransTool.csproj
new file mode 100644
index 0000000..2f4fc77
--- /dev/null
+++ b/XMLTransTool/XMLTransTool.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+