protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e) { base.OnBackKeyPress(e); if (AppBar.IsOpen) { AppBar.Close(); e.Cancel = true; } if (_textManipulationListener != null && _textManipulationListener.IsAttached) { ClearTextSelection(); e.Cancel = true; } if (TranslationControl.IsOpen) { TranslationControl.Hide(); e.Cancel = true; } if (_oldOffset != null) { ViewModel.TokenOffset = _oldOffset.Value; _oldOffset = null; CreateController(); e.Cancel = true; } }
private async void Translate(string text) { try { using (await BusyOverlay.Create()) { var translatedText = await _translateController.Translate(text, AppSettings.Default.CurrentTranslateLanguage.TwoLetterISOLanguageName); ClearTextSelection(); TranslationControl.Show(translatedText); } } catch (TranslationException) { MessageBox.Show(UIStrings.TranslateError_Body, UIStrings.TranslateError_Title, MessageBoxButton.OK); } }