/// <summary> /// συνάρτηση διαχείρισης των επιλογών που έγιναν στο TrayIcon /// </summary> private void Button_OnPushed(object sender) { String msg = sender as string; if (msg.Equals("SETTINGS")) { loadPreferences(); this.Visibility = Visibility.Visible; } else if (msg.Equals("TRANSLATOR")) { translatorUI = new TranslatorUI(); translatorUI.OnClose += translatorUI_OnClose; translatorUI.Show(); this.Visibility = Visibility.Collapsed; } else if (msg.Equals("START/STOP")) { startStopTranslate(); } else if (msg.Equals("EXIT")) Application.Current.Shutdown(); }
/// <summary> /// συνάρτηση που χρησιμοποιείται για την μετάφραση του επιλεγμένου κειμένου /// </summary> private void translate() { string source = hotKeyToTranslate.GetTextFromFocusedControl(new WindowInteropHelper(this).Handle); string result = Translate.translate(source); if (result.Equals("TranslatorException")) { Translate.init(); result = Translate.translate(source); } Console.WriteLine("TRANSLATE source :" + source + " , result : " + result); notifyTray.ShowBalloonTip("Translator", "Trying to translate message..."); if (translatorUI == null) { translatorUI = new TranslatorUI(); translatorUI.OnClose += translatorUI_OnClose; translatorUI.setSourceText(source); translatorUI.setResultText(result); translatorUI.Show(); } else { translatorUI.setSourceText(source); translatorUI.setResultText(result); if (translatorUI.WindowState == WindowState.Minimized) translatorUI.WindowState = WindowState.Normal; translatorUI.Focus(); } }