private void DictArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (_dict != null) { if (e.ClickCount == 2) { //双击事件 TextBlock textBlock = sender as TextBlock; string ret = _dict.SearchInDict(textBlock.Text); if (ret != null) { if (ret == string.Empty) { Growl.ErrorGlobal(Application.Current.Resources["TranslateWin_DictError_Hint"] + _dict.GetLastError()); } else { dtimer.Stop(); DictResWindow _dictResWindow = new DictResWindow(textBlock.Text, (string)textBlock.Tag, _textSpeechHelper); _dictResWindow.ShowDialog(); dtimer.Start(); } } else { Growl.ErrorGlobal(Application.Current.Resources["TranslateWin_DictError_Hint"] + _dict.GetLastError()); } } } }
/// <summary> /// Errors the specified message. /// </summary> /// <param name="message">The message.</param> public void Error(string message) { Application.Current.Dispatcher.Invoke(() => { Growl.ErrorGlobal(message); }); }
/// <summary> /// 键盘鼠标钩子初始化 /// </summary> private void MouseKeyboardHook_Init() { if (Common.UsingHotKey.IsMouse) { //初始化钩子对象 if (hook == null) { hook = new GlobalHook(); hook.OnMouseActivity += Hook_OnMouseActivity; } } else { //初始化钩子对象 if (hook == null) { hook = new GlobalHook(); hook.KeyDown += Hook_OnKeyBoardActivity; } } bool r = hook.Start(); if (!r) { Growl.ErrorGlobal(Application.Current.Resources["Hook_Error_Hint"].ToString()); } }
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); } }
private async void btnGetHashWeb_Click(object sender, RoutedEventArgs e) { try { if (!string.IsNullOrEmpty(txtUrl.Text) && txtUrl.Text.IsUrl()) { prgStatus.IsIndeterminate = false; btnGetHashWeb.IsEnabled = false; btnGetHashLocal.IsEnabled = false; txtHash.IsEnabled = false; try { var downloader = new DownloadService(); downloader.DownloadProgressChanged += OnDownloadProgressChanged; downloader.DownloadFileCompleted += OnDownloadFileCompleted; await downloader.DownloadFileTaskAsync(txtUrl.Text, new DirectoryInfo(Consts.TempSetupPath)); } catch (Exception ex) { prgStatus.IsIndeterminate = true; prgStatus.ShowError = true; Growl.ErrorGlobal(ex.Message); } } else { Growl.ErrorGlobal("Url field is Empty or Invalid"); } } catch (Exception ex) { Growl.ErrorGlobal(ex.Message); } }
private void btnAddInstaller_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(txtUrl.Text) || !string.IsNullOrEmpty(txtHash.Text)) { var arch = (cmbArchitecture.SelectedItem as ComboBoxItem).Content.ToString(); var item = new Installer { Architecture = arch, InstallerUrl = txtUrl.Text, InstallerSha256 = txtHash.Text }; if (!Installers.Contains(item, new GenericCompare <Installer>(x => x.Architecture))) { Installers.Add(item); } else { Growl.ErrorGlobal($"{arch} Architecture already exist."); } } else { Growl.ErrorGlobal("Installer Url and Installer Sha256 must be filled"); } }
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); } }
/// <summary> /// 键盘鼠标钩子初始化 /// </summary> private void MouseKeyboardHook_Init() { if (hook == null) { hook = new KeyboardMouseHook(); bool r = false; if (Common.UsingHotKey.IsMouse) { hook.OnMouseActivity += Hook_OnMouseActivity; if (Common.UsingHotKey.MouseButton == System.Windows.Forms.MouseButtons.Left) { r = hook.Start(true, 1); } else if (Common.UsingHotKey.MouseButton == System.Windows.Forms.MouseButtons.Right) { r = hook.Start(true, 2); } } else { hook.onKeyboardActivity += Hook_OnKeyBoardActivity; int keycode = (int)Common.UsingHotKey.KeyCode; r = hook.Start(false, keycode); } if (!r) { Growl.ErrorGlobal(Application.Current.Resources["Hook_Error_Hint"].ToString()); } } }
public void GenerateScript(GenerateScriptMode mode) { try { if (!string.IsNullOrEmpty(txtAppName.Text) && !string.IsNullOrEmpty(txtPublisher.Text) && !string.IsNullOrEmpty(txtId.Text) && !string.IsNullOrEmpty(txtVersion.Text) && !string.IsNullOrEmpty(txtLicense.Text) && !string.IsNullOrEmpty(txtUrl.Text) && txtUrl.Text.IsUrl()) { var builder = new YamlPackageModel { PackageIdentifier = txtId.Text, PackageVersion = txtVersion.Text, PackageName = txtAppName.Text, Publisher = txtPublisher.Text, License = txtLicense.Text, LicenseUrl = txtLicenseUrl.Text, ShortDescription = txtDescription.Text, PackageUrl = txtHomePage.Text, ManifestType = "singleton", ManifestVersion = "1.0.0", PackageLocale = "en-US", Installers = Installers.ToList() }; var serializer = new SerializerBuilder().Build(); var yaml = serializer.Serialize(builder); switch (mode) { case GenerateScriptMode.CopyToClipboard: Clipboard.SetText(yaml); Growl.SuccessGlobal("Script Copied to clipboard."); ClearInputs(); break; case GenerateScriptMode.SaveToFile: var dialog = new SaveFileDialog(); dialog.Title = "Save Package"; dialog.FileName = $"{txtId.Text}.yaml"; dialog.DefaultExt = "yaml"; dialog.Filter = "Yaml File (*.yaml)|*.yaml"; if (dialog.ShowDialog() == true) { File.WriteAllText(dialog.FileName, yaml); ClearInputs(); } break; } } else { Growl.ErrorGlobal("Required fields must be filled"); } } catch (Exception ex) { Growl.ErrorGlobal(ex.Message); } }
void MainWindow_SourceInitialized(object sender, EventArgs e) { hwnd = new WindowInteropHelper(this).Handle; HwndSource.FromHwnd(hwnd).AddHook(new HwndSourceHook(WndProc)); //注册热键 Common.GlobalOCRHotKey = new GlobalHotKey(); if (Common.GlobalOCRHotKey.RegistHotKeyByStr(Common.appSettings.GlobalOCRHotkey, hwnd, CallBack) == false) { Growl.ErrorGlobal("全局OCR热键注册失败!"); } }
private void MainWindow_SourceInitialized(object sender, EventArgs e) { hwnd = new WindowInteropHelper(this).Handle; HwndSource.FromHwnd(hwnd)?.AddHook(WndProc); //注册热键 Common.GlobalOCRHotKey = new GlobalHotKey(); if (Common.GlobalOCRHotKey.RegisterHotKeyByStr(Common.appSettings.GlobalOCRHotkey, hwnd, CallBack) == false) { Growl.ErrorGlobal(Application.Current.Resources["MainWindow_GlobalOCRError_Hint"].ToString()); } }
private void btnCopy_Click(object sender, RoutedEventArgs e) { if (Installers.Count > 1) { Growl.ErrorGlobal("You have Multiple installer We do not support this scenario yet."); } else { GenerateScript(GenerateScriptMode.CopyToClipboard); } }
public static bool IsOsSupported() { if (OSVersionHelper.IsWindows10_1709_OrGreater) { return(true); } else { Growl.ErrorGlobal("Your Windows Is Not Supported, Winget-cli requires Windows 10 version 1709 (build 16299) Please Update to Windows 10 1709 (build 16299) or later"); return(false); } }
private void AutoStart_BtnClick(object sender, RoutedEventArgs e) { var res = GetGameListHasProcessGame_PID_ID(); if (res == -1) { Growl.ErrorGlobal(Application.Current.Resources["MainWindow_AutoStartError_Hint"].ToString()); } else { StartTranslateByGid(res); } }
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> /// 显示界面提示信息 /// </summary> /// <param name="msg"></param> public void ShowTipMsg(string msg) { Growl.ErrorGlobal(new GrowlInfo { Message = msg, WaitTime = 5 }); // Snackbar?.MessageQueue?.Enqueue(msg, //null, //null, //null, //false, //true, //TimeSpan.FromSeconds(3)); }
private void btnRemoveInstaller_Click(object sender, RoutedEventArgs e) { var item = lstInstaller.SelectedItem as Installer; if (item != null) { Installers.Remove(item); } else { Growl.ErrorGlobal("Please Select Installer from list"); } }
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 }); } }
private void DictArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (_dict != null) { if (e.ClickCount == 2) { //双击事件 TextBlock textBlock = sender as TextBlock; string ret = _dict.SearchInDict(textBlock.Text); if (ret != null) { if (ret == string.Empty) { Growl.ErrorGlobal(Application.Current.Resources["TranslateWin_DictError_Hint"] + _dict.GetLastError()); } else { ret = XxgJpzhDict.RemoveHTML(ret); var textbox = new HandyControl.Controls.TextBox { Text = ret, FontSize = 15, TextWrapping = TextWrapping.Wrap, TextAlignment = TextAlignment.Left, HorizontalScrollBarVisibility = ScrollBarVisibility.Visible }; var window = new PopupWindow { PopupElement = textbox, WindowStartupLocation = WindowStartupLocation.CenterScreen, BorderThickness = new Thickness(0, 0, 0, 0), MaxWidth = 600, MaxHeight = 300, MinWidth = 600, MinHeight = 300, Title = Application.Current.Resources["TranslateWin_Dict_Title"].ToString() }; window.Show(); } } else { Growl.ErrorGlobal(Application.Current.Resources["TranslateWin_DictError_Hint"] + _dict.GetLastError()); } } } }
public static void StartProcess(string path) { try { var ps = new ProcessStartInfo(path) { UseShellExecute = true, Verb = "open" }; Process.Start(ps); } catch (Win32Exception ex) { if (!ex.Message.Contains("The system cannot find the file specified.")) { Growl.ErrorGlobal(ex.Message); } } }
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 static void DownloadWithIDM(string link) { var command = $"/C /d \"{link}\""; var IDManX64Location = @"C:\Program Files (x86)\Internet Download Manager\IDMan.exe"; var IDManX86Location = @"C:\Program Files\Internet Download Manager\IDMan.exe"; if (File.Exists(IDManX64Location)) { Process.Start(IDManX64Location, command); } else if (File.Exists(IDManX86Location)) { Process.Start(IDManX86Location, command); } else { Growl.ErrorGlobal( "Internet Download Manager (IDM) is not installed on your system, please download and install it first"); } }
public void GenerateScript() { try { if (!string.IsNullOrEmpty(txtAppName.Text) && !string.IsNullOrEmpty(txtPublisher.Text) && !string.IsNullOrEmpty(txtId.Text) && !string.IsNullOrEmpty(txtVersion.Text) && !string.IsNullOrEmpty(txtLicense.Text) && !string.IsNullOrEmpty(txtUrl.Text) && txtUrl.Text.IsUrl()) { var versionBuilder = new ExportVersionModel { PackageIdentifier = txtId.Text, PackageVersion = txtVersion.Text, PackageName = txtAppName.Text, Publisher = txtPublisher.Text, License = txtLicense.Text, LicenseUrl = txtLicenseUrl.Text, ShortDescription = txtDescription.Text, PackageUrl = txtHomePage.Text, ManifestType = "version", ManifestVersion = "1.0.0", DefaultLocale = "en-US" }; var installerBuilder = new ExportInstallerModel { PackageIdentifier = txtId.Text, PackageVersion = txtVersion.Text, ManifestType = "installer", ManifestVersion = "1.0.0", Installers = Installers.ToList() }; var versionSerializer = new SerializerBuilder().Build(); var installerSerializer = new SerializerBuilder().Build(); var versionYaml = versionSerializer.Serialize(versionBuilder); var installerYaml = installerSerializer.Serialize(installerBuilder); var dialog = new SaveFileDialog(); dialog.Title = "Save Package"; dialog.FileName = $"{txtId.Text}.yaml"; dialog.DefaultExt = "yaml"; dialog.Filter = "Yaml File (*.yaml)|*.yaml"; if (dialog.ShowDialog() == true) { var path = Path.GetDirectoryName(dialog.FileName) + @"\" + txtVersion.Text; Directory.CreateDirectory(path); File.WriteAllText(path + @"\" + txtId.Text + ".yaml", versionYaml); File.WriteAllText(path + @"\" + txtId.Text + ".installer.yaml", installerYaml); ClearInputs(); } } else { Growl.ErrorGlobal("Required fields must be filled"); } } catch (Exception ex) { Growl.ErrorGlobal(ex.Message); } }
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 (transRes1 == null) { Growl.ErrorGlobal(_translator1.GetType().Name + ": " + _translator1.GetLastError()); } } if (_translator2 != null) { transRes2 = _translator2.Translate(beforeString, Common.UsingDstLang, Common.UsingSrcLang); if (transRes2 == null) { Growl.ErrorGlobal(_translator2.GetType().Name + ": " + _translator2.GetLastError()); } } //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> /// Hook模式下调用的事件 /// </summary> public void DataRecvEventHandler(object sender, SolvedDataRecvEventArgs e) { Application.Current.Dispatcher.BeginInvoke((Action)(() => { //1.得到原句 string source = e.Data.Data; if (source == null && e.Data.HookFunc == "Clipboard") { return; } //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 (transRes1 == null) { Growl.ErrorGlobal(_translator1.GetType().Name + ": " + _translator1.GetLastError()); } } if (_translator2 != null) { transRes2 = _translator2.Translate(beforeString, Common.UsingDstLang, Common.UsingSrcLang); if (transRes2 == null) { Growl.ErrorGlobal(_translator2.GetType().Name + ": " + _translator2.GetLastError()); } } //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); } } } })); }