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()); } } } }
private void DictArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (dict != null) { if (e.ClickCount == 2) { //双击事件 TextBlock tb = sender as TextBlock; string ret = dict.SearchInDict(tb.Text); if (ret != null) { if (ret == "") { HandyControl.Controls.Growl.ErrorGlobal("或未查询到结果!" + dict.GetLastError()); } else { ret = XxgJpzhDict.RemoveHTML(ret); var textbox = new HandyControl.Controls.TextBox(); textbox.Text = ret; textbox.FontSize = 15; textbox.TextWrapping = TextWrapping.Wrap; textbox.TextAlignment = TextAlignment.Left; textbox.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible; var window = new HandyControl.Controls.PopupWindow { PopupElement = textbox, WindowStartupLocation = WindowStartupLocation.CenterScreen, BorderThickness = new Thickness(0, 0, 0, 0), MaxWidth = 600, MaxHeight = 300, MinWidth = 600, MinHeight = 300, Title = "字典结果" }; window.Show(); } } else { HandyControl.Controls.Growl.ErrorGlobal("查询错误!" + dict.GetLastError()); } } } }
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); }
private void TestBtn_Click(object sender, RoutedEventArgs e) { IDict dict = new XxgJpzhDict(); dict.DictInit(Common.appSettings.xxgPath, ""); string ret = dict.SearchInDict(TestSrcText.Text); if (ret != null) { ret = XxgJpzhDict.RemoveHTML(ret); var textbox = new HandyControl.Controls.TextBox(); textbox.Text = ret; textbox.FontSize = 15; textbox.TextWrapping = TextWrapping.Wrap; textbox.TextAlignment = TextAlignment.Left; textbox.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible; var window = new HandyControl.Controls.PopupWindow { PopupElement = textbox, WindowStartupLocation = WindowStartupLocation.CenterScreen, BorderThickness = new Thickness(0, 0, 0, 0), MaxWidth = 600, MaxHeight = 300, MinWidth = 600, MinHeight = 300, Title = "字典结果" }; window.Show(); } else { HandyControl.Controls.Growl.Error("查询错误!" + dict.GetLastError()); } }