|
|
@ -14,12 +14,12 @@ using STranslate.Util;
|
|
|
|
|
|
|
|
|
|
|
|
namespace STranslate.ViewModel
|
|
|
|
namespace STranslate.ViewModel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class MainVM : BaseVM
|
|
|
|
public class MainVM : BaseVM, IDisposable
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public MainVM()
|
|
|
|
public MainVM()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!InitialConfig())
|
|
|
|
if (!ReadConfig())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Task.Delay(3000);
|
|
|
|
Task.Delay(3000);
|
|
|
|
Environment.Exit(-1);
|
|
|
|
Environment.Exit(-1);
|
|
|
@ -75,7 +75,7 @@ namespace STranslate.ViewModel
|
|
|
|
/// 初始化配置文件
|
|
|
|
/// 初始化配置文件
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
private bool InitialConfig()
|
|
|
|
private bool ReadConfig()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -98,8 +98,8 @@ namespace STranslate.ViewModel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//从配置读取source target
|
|
|
|
//从配置读取source target
|
|
|
|
InputComboSelected = GlobalConfig.SourceLanguage.GetDescription();
|
|
|
|
InputComboSelected = GlobalConfig.SourceLanguage;
|
|
|
|
OutputComboSelected = GlobalConfig.TargetLanguage.GetDescription();
|
|
|
|
OutputComboSelected = GlobalConfig.TargetLanguage;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -109,6 +109,25 @@ namespace STranslate.ViewModel
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void WriteConfig()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ConfigHelper.Instance.WriteConfig(new ConfigModel
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
IsBright = true,
|
|
|
|
|
|
|
|
SourceLanguage = InputComboSelected,
|
|
|
|
|
|
|
|
TargetLanguage = OutputComboSelected,
|
|
|
|
|
|
|
|
SelectServer = TranslationInterface.FindIndex(x => x == SelectedTranslationInterface),
|
|
|
|
|
|
|
|
Servers = GlobalConfig.Servers,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MessageBox.Show(ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 自动识别语种
|
|
|
|
/// 自动识别语种
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -206,6 +225,11 @@ namespace STranslate.ViewModel
|
|
|
|
OutputTxt = ex.Message;
|
|
|
|
OutputTxt = ex.Message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
WriteConfig();
|
|
|
|
|
|
|
|
}
|
|
|
|
#endregion handle
|
|
|
|
#endregion handle
|
|
|
|
|
|
|
|
|
|
|
|
#region Params
|
|
|
|
#region Params
|
|
|
|