diff --git a/Common/YamlHelper.cs b/Common/YamlHelper.cs
index 61269a5ce1f73db0689be8641ffbce2ea515eb26..67e4435fe0bd0f39e354146c4fec6e2f515aa940 100644
--- a/Common/YamlHelper.cs
+++ b/Common/YamlHelper.cs
@@ -18,28 +18,55 @@ public static class YamlHelper
_jsonserializer = new SerializerBuilder().JsonCompatible().Build();
}
+ ///
+ /// 从文件中反序列化
+ ///
+ ///
+ ///
+ ///
public static T DeserializeFromFile(string filePath)
{
var yaml = File.ReadAllText(filePath, Encoding.UTF8);
return Deserizlize(yaml);
}
+ ///
+ /// 反序列化
+ ///
+ ///
+ ///
+ ///
public static T Deserizlize(string yaml)
{
return _deserializer.Deserialize(yaml);
}
+ ///
+ /// 序列化
+ ///
+ ///
+ ///
public static string Serialize(object target)
{
return _serializer.Serialize(target);
}
+ ///
+ /// 序列化到文件
+ ///
+ ///
+ ///
public static void SerizlizerToFile(object target, string filePath)
{
var content = Serialize(target);
File.WriteAllText(filePath, content, Encoding.UTF8);
}
+ ///
+ /// 写入Yaml文件
+ ///
+ ///
+ ///
public static void WriteYaml(object target, string filePath)
{
StreamWriter yamlWriter = File.CreateText(filePath);
@@ -61,6 +88,11 @@ public static class YamlHelper
File.WriteAllLines(filePath, _list.ToArray(), encoding: Encoding.UTF8);
}
+ ///
+ /// yaml转json
+ ///
+ ///
+ ///
public static string YamlToJson(string yaml)
{
var yamlObject = _jsondeserializer.Deserialize(yaml);
diff --git a/ViewModels/LexiconViewModel.cs b/ViewModels/LexiconViewModel.cs
index 37900a060e438ec52d8dc90976c253b743ed9690..fbc8f632b39a20c4e18c4c5ee1c52d6616e62b92 100644
--- a/ViewModels/LexiconViewModel.cs
+++ b/ViewModels/LexiconViewModel.cs
@@ -27,10 +27,35 @@ public partial class LexiconViewModel : ObservableObject
CikuAllList = new List();
WeakReferenceMessenger.Default.Register(this, "ReLoadCikuData", ReLoadCikuData);
+ LoadCiKus();
LoadCikuData();
InitPageControl();
}
+ ///
+ /// 加载词库下载选项
+ ///
+ public void LoadCiKus()
+ {
+ // 默认词库路径
+ var default_ciku_path = GlobalValues.UserPath + @"\wubi.dict.yaml";
+ // 扩展词库路径
+ var extend_ciku_path = GlobalValues.UserPath + @"\wubi.extended.dict.yaml";
+
+
+ if (!File.Exists(extend_ciku_path))
+ {
+ this.ShowMessage($"找不到【wubi.extended.dict.yaml】扩展词库文件", DialogType.Error);
+ return;
+ }
+
+ // # 读取词库名称列表
+ var cikuNames = new List<(string, string)>();
+ cikuNames.Add(("默认词库", default_ciku_path));
+ cikuNames.Add(("扩展词库", extend_ciku_path));
+ cikuNames.Add(("", ""));
+ }
+
private void InitPageControl()
{
try
diff --git a/Views/LexiconView.xaml b/Views/LexiconView.xaml
index 60fcae417223af1d146b87a054ffeb437a8c7f05..ed533b312bd3ffb22ede517002f53c5c2192d402 100644
--- a/Views/LexiconView.xaml
+++ b/Views/LexiconView.xaml
@@ -14,68 +14,38 @@
mc:Ignorable="d"
DataContext="{Binding Source={StaticResource Locator}, Path=LexiconViewModel}">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+