51 lines
1.2 KiB
C#
51 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Xml;
|
|
using ReactiveUI;
|
|
using TransTool;
|
|
|
|
namespace AvaloniaApplication2.ViewModels;
|
|
|
|
public class MainWindowViewModel : ViewModelBase
|
|
{
|
|
private List<TKey> _Keys;
|
|
|
|
public ObservableCollection<TKey> Keys
|
|
{
|
|
get { return new ObservableCollection<TKey>(_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; }
|
|
}
|
|
} |