Initial commit: Better-Seewo EN5 plugin v1.0.1
This commit is contained in:
45
Better-EN5/UIItemManagerExtensions.cs
Normal file
45
Better-EN5/UIItemManagerExtensions.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using Cvte.EasiNote;
|
||||
using Cvte.Windows.Localization;
|
||||
|
||||
namespace BetterEN5
|
||||
{
|
||||
static class UIItemManagerExtensions
|
||||
{
|
||||
public static void AppendWithLang(this IUIItemManager manager, UIItem item,
|
||||
UIItemAttribute attribute, IList<UIItemLangInfo> langInfoList)
|
||||
{
|
||||
manager.Append(c => item, attribute);
|
||||
|
||||
string menuName;
|
||||
if (attribute.Purposes[0] == UIItemPurposes.BoardEditMenu)
|
||||
{
|
||||
menuName = "BoardEditContextMenu";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
var itemLangKey = item.GetType().Name.Replace("MenuItem", "");
|
||||
var langKey = $"Lang.{menuName}.{itemLangKey}";
|
||||
|
||||
Application.Current.Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
foreach (var langInfo in langInfoList)
|
||||
{
|
||||
Lang.Sources.Add(new DictionaryLanguageSource
|
||||
{
|
||||
[langInfo.CultureInfo] = new Dictionary<string, string>()
|
||||
{
|
||||
{ langKey, langInfo.LangText },
|
||||
},
|
||||
});
|
||||
}
|
||||
}, DispatcherPriority.Send);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user