private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         UpdateHelper.GithubReleaseModel ver = UpdateHelper.CheckForUpdateGithubRelease("ghost1372", "SubtitleDownloader");
         lblCreatedAt.Text               = ver.CreatedAt.ToString();
         lblPublishedAt.Text             = ver.PublishedAt.ToString();
         lblDownloadUrl.CommandParameter = lblDownloadUrl.Content = ver.Asset[0].browser_download_url;
         lblCurrentVersion.Text          = Assembly.GetExecutingAssembly().GetName().Version.ToString();
         lblVersion.Text   = ver.TagName.Replace("v", "");
         txtChangelog.Text = ver.Changelog;
         if (ver.IsExistNewVersion)
         {
             Growl.InfoGlobal(Properties.Langs.Lang.NewVersion);
         }
         else
         {
             Growl.ErrorGlobal(Properties.Langs.Lang.LatestVersion);
         }
     }
     catch (System.Exception)
     {
         Growl.ErrorGlobal(Properties.Langs.Lang.ReleaseNotFound);
     }
 }
Beispiel #2
0
        private async void CheckUpdate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                btnCheck.IsEnabled = false;
                var ver = await UpdateHelper.CheckUpdateAsync("HandyOrg", "HandyWinGet");

                if (ver.IsExistNewVersion)
                {
                    Growl.AskGlobal("we found a new Version, do you want to download?", b =>
                    {
                        if (!b)
                        {
                            return(true);
                        }
                        StartProcess(ver.Assets[0].Url);
                        return(true);
                    });
                }
                else
                {
                    Growl.InfoGlobal("you are using Latest Version.");
                }

                btnCheck.IsEnabled = true;
            }
            catch (Exception ex)
            {
                Growl.ErrorGlobal(ex.Message);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Informations the specified message.
 /// </summary>
 /// <param name="message">The message.</param>
 public void Info(string message)
 {
     Application.Current.Dispatcher.Invoke(() =>
     {
         Growl.InfoGlobal(message);
     });
 }
Beispiel #4
0
        public TranslateWindow()
        {
            InitializeComponent();

            _isShowSource = true;
            _isLocked     = false;

            _gameTextHistory = new Queue <string>();

            this.Topmost = true;
            UI_Init();
            IsOCRingFlag = false;


            _wordSpliter = WordSpliterAuto(Common.appSettings.WordSpliter);

            _textSpeechHelper = new TextSpeechHelper();
            if (Common.appSettings.ttsVoice == "")
            {
                Growl.InfoGlobal(Application.Current.Resources["TranslateWin_NoTTS_Hint"].ToString());
            }
            else
            {
                _textSpeechHelper.SetTTSVoice(Common.appSettings.ttsVoice);
                _textSpeechHelper.SetVolume(Common.appSettings.ttsVolume);
                _textSpeechHelper.SetRate(Common.appSettings.ttsRate);
            }

            if (Common.appSettings.xxgPath != string.Empty)
            {
                _dict = new XxgJpzhDict();
                _dict.DictInit(Common.appSettings.xxgPath, string.Empty);
            }

            IsPauseFlag  = true;
            _translator1 = TranslatorAuto(Common.appSettings.FirstTranslator);
            _translator2 = TranslatorAuto(Common.appSettings.SecondTranslator);

            _beforeTransHandle = new BeforeTransHandle(Convert.ToString(Common.GameID), Common.UsingSrcLang, Common.UsingDstLang);
            _afterTransHandle  = new AfterTransHandle(_beforeTransHandle);

            _artificialTransHelper = new ArtificialTransHelper(Convert.ToString(Common.GameID));

            if (Common.transMode == 1)
            {
                Common.textHooker.Sevent += DataRecvEventHandler;
            }
            else if (Common.transMode == 2)
            {
                MouseKeyboardHook_Init();
            }

            toggleRec.ToolTip = Common.appSettings.ATon ? REC_OFF: REC_ON;
            updateToggleRecDisplay(false);
        }
Beispiel #5
0
 private void RenewOCR_Item_Click(object sender, RoutedEventArgs e)
 {
     if (Common.transMode == 2)
     {
         OCR();
     }
     else
     {
         Growl.InfoGlobal("非OCR模式下无法刷新!");
     }
 }
Beispiel #6
0
 private static void ShowNotificationInDesktop(string message, ENotificationType type)
 {
     Action action = type switch
     {
         ENotificationType.Success => () => Growl.SuccessGlobal(message),
         ENotificationType.Info => () => Growl.InfoGlobal(message),
         ENotificationType.Warning => () => Growl.WarningGlobal(message),
         ENotificationType.Error => () => Growl.ErrorGlobal(message),
         ENotificationType.Fatal => () => Growl.FatalGlobal(message),
         _ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
     };
     Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, action);
 }
 /// <summary>
 /// 允许关闭全局通知。实际做法是新建了一个无关联的panel,那些通知本质上还是会生成。
 /// </summary>
 void GrowlDisableSwitch()
 {
     if (!Common.appSettings.GrowlEnabled)
     {
         Growl.InfoGlobal("将不会显示全局通知。"); // 必须先显示一句否则GrowlWindow是null
         var gw    = typeof(Growl).GetField("GrowlWindow", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).GetValue(null);
         var panel = gw.GetType().GetProperty("GrowlPanel", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
         var sp    = new StackPanel();
         sp.Children.Add(new UIElement());                                           // 必须添加一个成员否则HC检测到成员为空时就把GrowlWindow设为null了
         panel.SetValue(gw, sp);
         this.Closing += (o, e) => gw.GetType().GetMethod("Close").Invoke(gw, null); // 关闭主窗口时关闭GrowlWindow否则程序无法退出
     }
 }
Beispiel #8
0
 private void ChangeSize_Item_Click(object sender, RoutedEventArgs e)
 {
     if (BackWinChrome.Opacity != 1)
     {
         BackWinChrome.Opacity       = 1;
         ChangeSizeButton.Foreground = Brushes.Gray;
         Growl.InfoGlobal(Application.Current.Resources["TranslateWin_DragBox_Hint"].ToString());
     }
     else
     {
         BackWinChrome.Opacity       = Common.appSettings.TF_Opacity / 100;
         ChangeSizeButton.Foreground = Brushes.PapayaWhip;
     }
 }
 private void ChangeSize_Item_Click(object sender, RoutedEventArgs e)
 {
     if (BackWinChrome.Opacity != 1)
     {
         BackWinChrome.Opacity = 1;
         DragBorder.Opacity    = 1;
     }
     else
     {
         BackWinChrome.Opacity = double.Parse(Common.appSettings.TF_Opacity) / 100;
         DragBorder.Opacity    = 0.01;
         Growl.InfoGlobal("鼠标指向拖拽栏可显示!");
     }
 }
Beispiel #10
0
 private void ChangeSize_Item_Click(object sender, RoutedEventArgs e)
 {
     if (BackWinChrome.Opacity != 1)
     {
         BackWinChrome.Opacity = 1;
         DragBorder.Opacity    = 1;
     }
     else
     {
         BackWinChrome.Opacity = double.Parse(Common.appSettings.TF_Opacity) / 100;
         DragBorder.Opacity    = 0.01;
         Growl.InfoGlobal(Application.Current.Resources["TranslateWin_DragBox_Hint"].ToString());
     }
 }
Beispiel #11
0
    public static async void CheckForUpdate(bool onlyShowIfUpdateAvailable = false)
    {
        if (ApplicationHelper.IsConnectedToInternet())
        {
            var ver = await UpdateHelper.CheckUpdateAsync("DineshSolanki", "FoliCon");

            if (ver.IsExistNewVersion)
            {
                var info = new GrowlInfo
                {
                    Message = LangProvider.GetLang("NewVersionFound").Format(ver.TagName,
                                                                             ver.Changelog.Replace("\\n", Environment.NewLine)),
                    ConfirmStr        = LangProvider.GetLang("UpdateNow"),
                    CancelStr         = LangProvider.GetLang("Ignore"),
                    ShowDateTime      = false,
                    ActionBeforeClose = isConfirmed =>
                    {
                        if (isConfirmed)
                        {
                            StartProcess(ver.ReleaseUrl);
                        }
                        return(true);
                    }
                };
                Growl.AskGlobal(info);
            }
            else
            {
                if (onlyShowIfUpdateAvailable is not false)
                {
                    return;
                }
                var info = new GrowlInfo
                {
                    Message      = LangProvider.GetLang("ThisIsLatestVersion"),
                    ShowDateTime = false,
                    StaysOpen    = false
                };
                Growl.InfoGlobal(info);
            }
        }
        else
        {
            Growl.ErrorGlobal(new GrowlInfo
            {
                Message = LangProvider.GetLang("NetworkNotAvailable"), ShowDateTime = false
            });
        }
    }
Beispiel #12
0
        public async void Info(string msg)
        {
            await WaitForTokenLoaded();

            App.Current.Dispatcher.Invoke(() =>
            {
                if (Program.CliOptions.GlobalNotification)
                {
                    Growl.InfoGlobal(msg);
                }
                else
                {
                    Growl.Info(msg, Token);
                }
            });
        }
Beispiel #13
0
 public static void CheckForUpdate()
 {
     if (IsNetworkAvailable())
     {
         var ver = UpdateHelper.CheckForUpdate(
             "https://raw.githubusercontent.com/DineshSolanki/FoliCon/master/FoliCon/Updater.xml");
         if (ver.IsExistNewVersion)
         {
             var info = new GrowlInfo
             {
                 Message           = $"New Version Found!\n Changelog:{ver.Changelog}",
                 ConfirmStr        = "Update Now",
                 CancelStr         = "Ignore",
                 ShowDateTime      = false,
                 ActionBeforeClose = isConfirmed =>
                 {
                     if (isConfirmed)
                     {
                         StartProcess(ver.Url);
                     }
                     return(true);
                 }
             };
             Growl.AskGlobal(info);
         }
         else
         {
             var info = new GrowlInfo
             {
                 Message      = "Great! you are using the latest version",
                 ShowDateTime = false,
                 StaysOpen    = false
             };
             Growl.InfoGlobal(info);
         }
     }
     else
     {
         Growl.ErrorGlobal(new GrowlInfo {
             Message = "Network not available!", ShowDateTime = false
         });
     }
 }
        public DictResWindow(string word, string kana = "----", TextSpeechHelper tsh = null)
        {
            sourceWord = word;
            InitializeComponent();
            if (tsh == null)
            {
                _textSpeechHelper = new TextSpeechHelper();
            }
            else
            {
                _textSpeechHelper = tsh;
            }


            if (Common.appSettings.ttsVoice == "")
            {
                Growl.InfoGlobal(Application.Current.Resources["TranslateWin_NoTTS_Hint"].ToString());
            }
            else
            {
                _textSpeechHelper.SetTTSVoice(Common.appSettings.ttsVoice);
                _textSpeechHelper.SetVolume(Common.appSettings.ttsVolume);
                _textSpeechHelper.SetRate(Common.appSettings.ttsRate);
            }

            if (Common.appSettings.xxgPath != string.Empty)
            {
                _dict = new XxgJpzhDict();
                _dict.DictInit(Common.appSettings.xxgPath, string.Empty);
            }

            string ret = _dict.SearchInDict(sourceWord);

            SourceWord.Text = sourceWord;

            Kana.Text = kana;

            this.Topmost    = true;
            DicResText.Text = XxgJpzhDict.RemoveHTML(ret);
        }
Beispiel #15
0
        /// <summary>
        /// Hook模式下调用的事件
        /// </summary>
        public void DataRecvEventHandler(object sender, SolvedDataRecvEventArgs e)
        {
            Application.Current.Dispatcher.BeginInvoke((Action)(() =>
            {
                //1.得到原句
                string source = e.Data.Data;

                //2.进行去重
                string repairedText = TextRepair.RepairFun_Auto(Common.UsingRepairFunc, source);

                if (Convert.ToBoolean(Common.appSettings.EachRowTrans) == false)
                {
                    //不需要分行翻译
                    repairedText = repairedText.Replace("<br>", "").Replace("</br>", "").Replace("\n", "").Replace("\t", "").Replace("\r", "");
                }
                //去乱码
                repairedText = repairedText.Replace("_", "").Replace("-", "").Replace("+", "").Replace("&", "");

                //补充:如果去重之后的文本长度超过指定值(默认100),直接不翻译、不显示
                //补充2:如果去重后文本长度为0,则不翻译不显示
                if (repairedText.Length != 0 && repairedText.Length <= Common.appSettings.TransLimitNums)
                {
                    //2.5 清除面板
                    SourceTextPanel.Children.Clear();

                    _currentsrcText = repairedText;

                    if (_isShowSource)
                    {
                        //3.分词
                        var mwi = _mecabHelper.SentenceHandle(repairedText);
                        //分词后结果显示
                        for (int i = 0; i < mwi.Count; i++)
                        {
                            StackPanel stackPanel = new StackPanel();
                            stackPanel.Orientation = Orientation.Vertical;
                            stackPanel.Margin = new Thickness(10, 0, 0, 10);

                            TextBlock textBlock = new TextBlock();
                            if (!string.IsNullOrEmpty(SourceTextFont))
                            {
                                FontFamily fontFamily = new FontFamily(SourceTextFont);
                                textBlock.FontFamily = fontFamily;
                            }
                            textBlock.Text = mwi[i].Word;
                            textBlock.Tag = mwi[i].Kana;
                            textBlock.Margin = new Thickness(0, 0, 0, 0);
                            textBlock.FontSize = SourceTextFontSize;
                            textBlock.Background = Brushes.Transparent;
                            textBlock.MouseLeftButtonDown += DictArea_MouseLeftButtonDown;
                            //根据不同词性跟字体上色
                            switch (mwi[i].PartOfSpeech)
                            {
                            case "名詞":
                                textBlock.Foreground = Brushes.AliceBlue;
                                break;

                            case "助詞":
                                textBlock.Foreground = Brushes.LightGreen;
                                break;

                            case "動詞":
                                textBlock.Foreground = Brushes.Red;
                                break;

                            case "連体詞":
                                textBlock.Foreground = Brushes.Orange;
                                break;

                            default:
                                textBlock.Foreground = Brushes.White;
                                break;
                            }


                            TextBlock superScript = new TextBlock();//假名或注释等的上标标签
                            if (!string.IsNullOrEmpty(SourceTextFont))
                            {
                                FontFamily fontFamily = new FontFamily(SourceTextFont);
                                superScript.FontFamily = fontFamily;
                            }
                            superScript.Text = mwi[i].Kana;
                            superScript.Margin = new Thickness(0, 0, 0, 2);
                            superScript.HorizontalAlignment = HorizontalAlignment.Center;
                            if ((double)SourceTextFontSize - 6.5 > 0)
                            {
                                superScript.FontSize = (double)SourceTextFontSize - 6.5;
                            }
                            else
                            {
                                superScript.FontSize = 1;
                            }
                            superScript.Background = Brushes.Transparent;
                            superScript.Foreground = Brushes.White;
                            stackPanel.Children.Add(superScript);


                            //是否打开假名标注
                            if (Common.appSettings.TF_isKanaShow)
                            {
                                stackPanel.Children.Add(textBlock);
                                SourceTextPanel.Children.Add(stackPanel);
                            }
                            else
                            {
                                textBlock.Margin = new Thickness(10, 0, 0, 10);
                                SourceTextPanel.Children.Add(textBlock);
                            }
                        }
                    }


                    //4.翻译前预处理
                    string beforeString = _beforeTransHandle.AutoHandle(repairedText);

                    //5.提交翻译
                    string transRes1 = string.Empty;
                    string transRes2 = string.Empty;
                    if (_translator1 != null)
                    {
                        transRes1 = _translator1.Translate(beforeString, Common.UsingDstLang, Common.UsingSrcLang);
                    }
                    if (_translator2 != null)
                    {
                        transRes2 = _translator2.Translate(beforeString, Common.UsingDstLang, Common.UsingSrcLang);
                    }

                    //6.翻译后处理
                    string afterString1 = _afterTransHandle.AutoHandle(transRes1);
                    string afterString2 = _afterTransHandle.AutoHandle(transRes2);

                    //7.翻译结果显示到窗口上
                    FirstTransText.Text = afterString1;
                    SecondTransText.Text = afterString2;

                    //8.翻译结果记录到队列
                    if (_gameTextHistory.Count > 5)
                    {
                        _gameTextHistory.Dequeue();
                    }
                    _gameTextHistory.Enqueue(repairedText + "\n" + afterString1 + "\n" + afterString2);

                    //9.翻译原句和结果记录到数据库
                    if (Common.appSettings.ATon)
                    {
                        bool addRes = _artificialTransHelper.AddTrans(repairedText, afterString1);
                        if (addRes == false)
                        {
                            HandyControl.Data.GrowlInfo growlInfo = new HandyControl.Data.GrowlInfo();
                            growlInfo.Message = Application.Current.Resources["ArtificialTransAdd_Error_Hint"].ToString();
                            growlInfo.WaitTime = 2;
                            Growl.InfoGlobal(growlInfo);
                        }
                    }
                }
            }));
        }
Beispiel #16
0
        private void OCR()
        {
            if (IsPauseFlag)
            {
                if (IsOCRingFlag == false)
                {
                    IsOCRingFlag = true;

                    int j = 0;

                    for (; j < 3; j++)
                    {
                        Thread.Sleep(Common.UsingOCRDelay);

                        string srcText = Common.ocr.OCRProcess();
                        GC.Collect();

                        if (!string.IsNullOrEmpty(srcText))
                        {
                            Application.Current.Dispatcher.BeginInvoke((Action)(() =>
                            {
                                //0.清除面板
                                SourceTextPanel.Children.Clear();

                                //1.得到原句
                                string source = srcText;

                                _currentsrcText = source;

                                if (_isShowSource)
                                {
                                    //3.分词
                                    List <MecabWordInfo> mwi = _mecabHelper.SentenceHandle(source);
                                    //分词后结果显示
                                    for (int i = 0; i < mwi.Count; i++)
                                    {
                                        StackPanel stackPanel = new StackPanel();
                                        stackPanel.Orientation = Orientation.Vertical;
                                        stackPanel.Margin = new Thickness(10, 0, 0, 10);

                                        TextBlock textBlock = new TextBlock();
                                        if (!string.IsNullOrEmpty(SourceTextFont))
                                        {
                                            FontFamily fontFamily = new FontFamily(SourceTextFont);
                                            textBlock.FontFamily = fontFamily;
                                        }
                                        textBlock.Text = mwi[i].Word;
                                        textBlock.Tag = mwi[i].Kana;
                                        textBlock.Margin = new Thickness(0, 0, 0, 0);
                                        textBlock.FontSize = SourceTextFontSize;
                                        textBlock.Background = Brushes.Transparent;
                                        textBlock.MouseLeftButtonDown += DictArea_MouseLeftButtonDown;
                                        //根据不同词性跟字体上色
                                        switch (mwi[i].PartOfSpeech)
                                        {
                                        case "名詞":
                                            textBlock.Foreground = Brushes.AliceBlue;
                                            break;

                                        case "助詞":
                                            textBlock.Foreground = Brushes.LightGreen;
                                            break;

                                        case "動詞":
                                            textBlock.Foreground = Brushes.Red;
                                            break;

                                        case "連体詞":
                                            textBlock.Foreground = Brushes.Orange;
                                            break;

                                        default:
                                            textBlock.Foreground = Brushes.White;
                                            break;
                                        }


                                        TextBlock superScript = new TextBlock();//假名或注释等的上标标签
                                        if (!string.IsNullOrEmpty(SourceTextFont))
                                        {
                                            FontFamily fontFamily = new FontFamily(SourceTextFont);
                                            superScript.FontFamily = fontFamily;
                                        }
                                        superScript.Text = mwi[i].Kana;
                                        superScript.Margin = new Thickness(0, 0, 0, 2);
                                        superScript.HorizontalAlignment = HorizontalAlignment.Center;
                                        if ((double)SourceTextFontSize - 6.5 > 0)
                                        {
                                            superScript.FontSize = (double)SourceTextFontSize - 6.5;
                                        }
                                        else
                                        {
                                            superScript.FontSize = 1;
                                        }
                                        superScript.Background = Brushes.Transparent;
                                        superScript.Foreground = Brushes.White;
                                        stackPanel.Children.Add(superScript);


                                        //是否打开假名标注
                                        if (Common.appSettings.TF_isKanaShow)
                                        {
                                            stackPanel.Children.Add(textBlock);
                                            SourceTextPanel.Children.Add(stackPanel);
                                        }
                                        else
                                        {
                                            textBlock.Margin = new Thickness(10, 0, 0, 10);
                                            SourceTextPanel.Children.Add(textBlock);
                                        }
                                    }
                                }

                                if (Convert.ToBoolean(Common.appSettings.EachRowTrans) == false)
                                {
                                    //不需要分行翻译
                                    source = source.Replace("<br>", "").Replace("</br>", "").Replace("\n", "").Replace("\t", "").Replace("\r", "");
                                }
                                //去乱码
                                source = source.Replace("_", "").Replace("-", "").Replace("+", "").Replace("&", "");

                                //4.翻译前预处理
                                string beforeString = _beforeTransHandle.AutoHandle(source);

                                //5.提交翻译
                                string transRes1 = string.Empty;
                                string transRes2 = string.Empty;
                                if (_translator1 != null)
                                {
                                    transRes1 = _translator1.Translate(beforeString, Common.UsingDstLang, Common.UsingSrcLang);
                                }
                                if (_translator2 != null)
                                {
                                    transRes2 = _translator2.Translate(beforeString, Common.UsingDstLang, Common.UsingSrcLang);
                                }

                                //6.翻译后处理
                                string afterString1 = _afterTransHandle.AutoHandle(transRes1);
                                string afterString2 = _afterTransHandle.AutoHandle(transRes2);

                                //7.翻译结果显示到窗口上
                                FirstTransText.Text = afterString1;
                                SecondTransText.Text = afterString2;

                                //8.翻译结果记录到队列
                                if (_gameTextHistory.Count > 5)
                                {
                                    _gameTextHistory.Dequeue();
                                }
                                _gameTextHistory.Enqueue(source + "\n" + afterString1 + "\n" + afterString2);

                                //9.翻译原句和结果记录到数据库
                                if (Common.appSettings.ATon)
                                {
                                    bool addRes = _artificialTransHelper.AddTrans(source, afterString1);
                                    if (addRes == false)
                                    {
                                        HandyControl.Data.GrowlInfo growlInfo = new HandyControl.Data.GrowlInfo();
                                        growlInfo.Message = Application.Current.Resources["ArtificialTransAdd_Error_Hint"].ToString();
                                        growlInfo.WaitTime = 2;
                                        Growl.InfoGlobal(growlInfo);
                                    }
                                }
                            }));

                            IsOCRingFlag = false;
                            break;
                        }
                    }

                    if (j == 3)
                    {
                        Application.Current.Dispatcher.BeginInvoke((Action)(() =>
                        {
                            FirstTransText.Text = "[OCR]自动识别三次均为空,请自行刷新!";
                        }));

                        IsOCRingFlag = false;
                    }
                }
            }
        }
        /// <summary>
        /// 提交原文到翻译器,获取翻译结果并显示
        /// </summary>
        /// <param name="repairedText">原文</param>
        /// <param name="tranResultIndex">翻译框序号</param>
        /// <param name="isRenew">是否是重新获取翻译</param>
        private async Task TranslateApiSubmitASync(string repairedText, int tranResultIndex, bool isRenew = false)
        {
            //4.翻译前预处理
            string beforeString = _beforeTransHandle.AutoHandle(repairedText);

            //5.提交翻译
            string transRes = string.Empty;

            if (tranResultIndex == 1)
            {
                if (_translator1 != null)
                {
                    transRes = await _translator1.TranslateAsync(beforeString, Common.UsingDstLang, Common.UsingSrcLang);

                    if (transRes == null)
                    {
                        Application.Current.Dispatcher.Invoke(() =>
                        {
                            Growl.WarningGlobal(_translator1.GetType().Name + ": " + _translator1.GetLastError());
                        });
                        return;
                    }
                }
            }
            else if (tranResultIndex == 2)
            {
                if (_translator2 != null)
                {
                    transRes = await _translator2.TranslateAsync(beforeString, Common.UsingDstLang, Common.UsingSrcLang);

                    if (transRes == null)
                    {
                        Application.Current.Dispatcher.Invoke(() =>
                        {
                            Growl.WarningGlobal(_translator2.GetType().Name + ": " + _translator2.GetLastError());
                        });
                        return;
                    }
                }
            }

            //6.翻译后处理
            string afterString = _afterTransHandle.AutoHandle(transRes);

            //7.翻译结果显示到窗口上
            switch (tranResultIndex)
            {
            case 1:
                Application.Current.Dispatcher.Invoke(() =>
                {
                    FirstTransText.Text = afterString;
                });
                break;

            case 2:
                Application.Current.Dispatcher.Invoke(() =>
                {
                    SecondTransText.Text = afterString;
                });
                break;
            }

            if (!isRenew)
            {
                lock (_saveTransResultLock)
                {
                    //8.翻译结果记录到队列
                    // todo: 这是比较粗暴地添加历史记录,可以优化(时间排序等)
                    if (_gameTextHistory.Count > 10)
                    {
                        _gameTextHistory.Dequeue();
                    }
                    _gameTextHistory.Enqueue(repairedText + "\n" + afterString);

                    //9.翻译原句和结果记录到数据库
                    if (Common.appSettings.ATon)
                    {
                        bool addRes = _artificialTransHelper.AddTrans(repairedText, afterString);
                        if (addRes == false)
                        {
                            Application.Current.Dispatcher.Invoke(() =>
                            {
                                HandyControl.Data.GrowlInfo growlInfo = new HandyControl.Data.GrowlInfo();
                                growlInfo.Message  = Application.Current.Resources["ArtificialTransAdd_Error_Hint"].ToString();
                                growlInfo.WaitTime = 2;
                                Growl.InfoGlobal(growlInfo);
                            });
                        }
                    }
                }
            }
        }