|
|
@ -17,9 +17,12 @@ namespace STranslate.ViewModel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class MainVM : BaseVM, IDisposable
|
|
|
|
public class MainVM : BaseVM, IDisposable
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
private MainWindow mainwin;
|
|
|
|
public MainVM()
|
|
|
|
public MainVM(Window win)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
mainwin = (MainWindow)win;
|
|
|
|
|
|
|
|
OpenMainWin();
|
|
|
|
|
|
|
|
|
|
|
|
if (!ReadConfig())
|
|
|
|
if (!ReadConfig())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Task.Delay(3000);
|
|
|
|
Task.Delay(3000);
|
|
|
@ -35,20 +38,14 @@ namespace STranslate.ViewModel
|
|
|
|
//输入翻译
|
|
|
|
//输入翻译
|
|
|
|
InputTranslateCmd = new RelayCommand((_) => true, (_) =>
|
|
|
|
InputTranslateCmd = new RelayCommand((_) => true, (_) =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
InputTxt = string.Empty;
|
|
|
|
ClearAll();
|
|
|
|
OutputTxt = string.Empty;
|
|
|
|
OpenMainWin();
|
|
|
|
SnakeRet = string.Empty;
|
|
|
|
|
|
|
|
SmallHumpRet = string.Empty;
|
|
|
|
|
|
|
|
LargeHumpRet = string.Empty;
|
|
|
|
|
|
|
|
IdentifyLanguage = string.Empty;
|
|
|
|
|
|
|
|
//view操作
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//显示主界面
|
|
|
|
//显示主界面
|
|
|
|
ShowMainWinCmd = new RelayCommand((_) => true, (_) =>
|
|
|
|
ShowMainWinCmd = new RelayCommand((_) => true, (_) =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//view操作
|
|
|
|
OpenMainWin();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
//开机自启
|
|
|
|
//开机自启
|
|
|
|
StartupCmd = new RelayCommand((_) => true, (_) =>
|
|
|
|
StartupCmd = new RelayCommand((_) => true, (_) =>
|
|
|
@ -68,6 +65,7 @@ namespace STranslate.ViewModel
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Common
|
|
|
|
//source speak
|
|
|
|
//source speak
|
|
|
|
SourceSpeakCmd = new RelayCommand((_) => true, (_) =>
|
|
|
|
SourceSpeakCmd = new RelayCommand((_) => true, (_) =>
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -120,9 +118,32 @@ namespace STranslate.ViewModel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await Translate();
|
|
|
|
await Translate();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region handle
|
|
|
|
#region handle
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 清空所有
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
private void ClearAll()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
InputTxt = string.Empty;
|
|
|
|
|
|
|
|
OutputTxt = string.Empty;
|
|
|
|
|
|
|
|
SnakeRet = string.Empty;
|
|
|
|
|
|
|
|
SmallHumpRet = string.Empty;
|
|
|
|
|
|
|
|
LargeHumpRet = string.Empty;
|
|
|
|
|
|
|
|
IdentifyLanguage = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 打开主窗口
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
private void OpenMainWin()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mainwin.Show();
|
|
|
|
|
|
|
|
mainwin.Activate();
|
|
|
|
|
|
|
|
//TODO: add textbox focus
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 初始化配置文件
|
|
|
|
/// 初始化配置文件
|
|
|
|