public static void FocusMaybe(this RichEditBox textBox, FocusState focusState) { if (UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse) { textBox.Focus(focusState); } }
private void RichEditBox_SetFocus(PivotItem pi) { RichEditBox reb = pi.Content as RichEditBox; reb.Focus(FocusState.Keyboard); journalEntry = new JournalEntry(reb); }
private void MainCanvas_Tapped(object sender, TappedRoutedEventArgs e) { if (e.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Pen) { return; } var position = e.GetPosition(Root); List <UIElement> elements = new List <UIElement>(VisualTreeHelper.FindElementsInHostCoordinates(position, MainCanvas)); if (elements.Count > 0) { return; } RichEditBox box = new RichEditBox(); box.Width = Root.Width > 500 ? Math.Min(Root.ActualWidth / 2, 500) : Root.Width; box.LostFocus += Box_LostFocus; box.SizeChanged += Box_SizeChanged; box.Style = App.Current.Resources["InfiniteRichEditBoxStyle"] as Style; Canvas.SetLeft(box, position.X); Canvas.SetTop(box, position.Y); MainCanvas.Children.Add(box); box.Focus(FocusState.Keyboard); AdjustCanvasSize(); }
private void RichEditBox_SetFocus(PivotItem pi) { RichEditBox reb = pi.Content as RichEditBox; reb.Focus(FocusState.Keyboard); currentJournalEntries.GetSelectedEntry(pi.Header.ToString()); }
private void PivotItem_Loaded(System.Object sender, RoutedEventArgs e) { PivotItem pi = sender as PivotItem; RichEditBox reb = pi.Content as RichEditBox; reb.Focus(FocusState.Keyboard); }
private void RichEditBox_SetFocus(PivotItem pi) { RichEditBox reb = pi.Content as RichEditBox; reb.Focus(FocusState.Keyboard); currentRichEditBox = reb; }
private void SuggestionList_GotFocus(object sender, RoutedEventArgs e) { if (_richEditBox != null) { _richEditBox.Focus(FocusState.Programmatic); } }
private void rootPivot_GotFocus(object sender, RoutedEventArgs e) { Pivot p = sender as Pivot; PivotItem pi = p.SelectedItem as PivotItem; RichEditBox reb = pi.Content as RichEditBox; reb.Focus(FocusState.Keyboard); }
public void LoadRichEditBox(RichEditBox box) { box.Document.SetText(TextSetOptions.FormatRtf, CurrentSentence.ActiveSysSentence.Text); LoadAnnotationsEditBox(box); //Sprjecava selekciju anotacije kod prijelaska na drugu recenicu box.Focus(FocusState.Keyboard); box.Document.Selection.SetRange(box.Document.Selection.EndPosition, box.Document.Selection.EndPosition); }
public static void Focus(this RichEditBox richEditBox) { if (richEditBox is null) { throw new ArgumentNullException(nameof(richEditBox)); } richEditBox.Focus(Windows.UI.Xaml.FocusState.Keyboard); }
public MainWindow() { InitializeComponent(); Viewer = InitializeDocumentViewer(); RichEditBox = InitializeRichEdit(); wordProcessor = InitializeWordProcessor(); DataContext = wordProcessor; Loaded += (s, e) => { RichEditBox.Focus(); }; }
private async void OnLoaded(object sender, RoutedEventArgs e) { SetupFocusMode(Settings.FocusMode); await SetOverlayMode(Settings.CurrentMode); if (ViewModel.File == null) { await ViewModel.InitNewDocument(); } Mvvm.ViewModels.ViewModel.Dispatch(() => Bindings.Update()); if (Settings.DefaultMode == "Compact Overlay") { if (await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay)) { //set the current mode to be the launch mode Settings.CurrentMode = Settings.DefaultMode; } } if (Settings.DefaultMode == "LaunchFocusMode") { //set return mode in case the user wants to leave focus mode Settings.ReturnToMode = nameof(DisplayModes.LaunchClassicMode); //set the current mode to be the launch mode Settings.CurrentMode = Settings.DefaultMode; } Settings.NotDeferred = true; Settings.Status("Ready", TimeSpan.FromSeconds(10), Verbosity.Release); if (ViewModel.CurrentFileType == ".rtf") { RichEditBox.Focus(FocusState.Programmatic); } else { TextBox.Focus(FocusState.Programmatic); } TextBox.SelectionFlyout.Opening += Menu_Opening; TextBox.ContextFlyout.Opening += Menu_Opening; RichEditBox.SelectionFlyout.Opening += RMenu_Opening; RichEditBox.ContextFlyout.Opening += RMenu_Opening; }
private async void OnLoaded(object sender, RoutedEventArgs e) { SetupFocusMode(Settings.FocusMode); await SetOverlayMode(Settings.CurrentMode); if (ViewModel.File == null) { await ViewModel.InitNewDocument(); } Mvvm.ViewModels.ViewModel.Dispatch(() => Bindings.Update()); if (Settings.DefaultMode == "Compact Overlay") { if (await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay)) { Settings.CurrentMode = "Compact Overlay"; } } Settings.NotDeferred = true; Settings.Status("Ready", TimeSpan.FromSeconds(10), Verbosity.Release); if (ViewModel.CurrentFileType == ".rtf") { RichEditBox.Focus(FocusState.Programmatic); } else { TextBox.Focus(FocusState.Programmatic); } TextBox.SelectionFlyout.Opening += Menu_Opening; TextBox.ContextFlyout.Opening += Menu_Opening; RichEditBox.SelectionFlyout.Opening += RMenu_Opening; RichEditBox.ContextFlyout.Opening += RMenu_Opening; }
private async void MoreOptionsList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (MoreOptionsList.SelectedIndex == 0) { mp.ChangeLoading(true); Windows.Storage.Pickers.FileSavePicker picker = new Windows.Storage.Pickers.FileSavePicker(); picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary; picker.FileTypeChoices.Add(mp.resourceLoader.GetString("FileRTF"), new List <string>() { ".rtf" }); picker.FileTypeChoices.Add(mp.resourceLoader.GetString("FilePDF"), new List <string>() { ".pdf" }); picker.FileTypeChoices.Add(mp.resourceLoader.GetString("FileHTML"), new List <string>() { ".html" }); picker.FileTypeChoices.Add(mp.resourceLoader.GetString("FileDocx"), new List <string>() { ".docx" }); picker.FileTypeChoices.Add(mp.resourceLoader.GetString("FileDoc"), new List <string>() { ".doc" }); picker.FileTypeChoices.Add(mp.resourceLoader.GetString("FileEpub"), new List <string>() { ".epub" }); picker.FileTypeChoices.Add(mp.resourceLoader.GetString("FileTXT"), new List <string>() { ".txt" }); picker.FileTypeChoices.Add(mp.resourceLoader.GetString("FileJPG"), new List <string>() { ".jpg" }); picker.FileTypeChoices.Add(mp.resourceLoader.GetString("FilePNG"), new List <string>() { ".png" }); picker.FileTypeChoices.Add(mp.resourceLoader.GetString("FileBMP"), new List <string>() { ".bmp" }); picker.FileTypeChoices.Add(mp.resourceLoader.GetString("FileGIF"), new List <string>() { ".gif" }); picker.FileTypeChoices.Add(mp.resourceLoader.GetString("FileTIFF"), new List <string>() { ".tiff" }); picker.CommitButtonText = mp.resourceLoader.GetString("CommitExportText"); picker.SuggestedFileName = Settings.Default.DefaultExportName; StorageFile saveFile = await picker.PickSaveFileAsync(); if (saveFile != null) { if (saveFile.FileType == ".rtf") { me.RequestedTheme = ElementTheme.Light; await mp.file.CopyAndReplaceAsync(saveFile); if (Settings.Default.ThemeDefault == true) { me.RequestedTheme = ElementTheme.Default; } if (Settings.Default.ThemeDark == true) { me.RequestedTheme = ElementTheme.Dark; } if (Settings.Default.ThemeLight == true) { me.RequestedTheme = ElementTheme.Light; } } if (saveFile.FileType == ".html") { await FileIO.WriteTextAsync(saveFile, ConvertToHtml(me, mp.EncodingList)); } if (saveFile.FileType == ".docx") { mp.SfSave(saveFile, FormatType.Docx); } if (saveFile.FileType == ".doc") { mp.SfSave(saveFile, FormatType.Doc); } if (saveFile.FileType == ".epub") { mp.SfSave(saveFile, FormatType.EPub); } if (saveFile.FileType == ".txt") { me.Document.GetText(TextGetOptions.None, out string txtstring); await FileIO.WriteTextAsync(saveFile, txtstring); } if (saveFile.FileType == ".jpg") { me.RequestedTheme = ElementTheme.Light; me.Focus(FocusState.Programmatic); Debug.WriteLine("Focus set"); await mp.renderTargetBitmap.RenderAsync(me); Debug.WriteLine("Rendered"); using (var stream = await saveFile.OpenStreamForWriteAsync()) { var logicalDpi = DisplayInformation.GetForCurrentView().LogicalDpi; var pixelBuffer = await mp.renderTargetBitmap.GetPixelsAsync(); var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, stream.AsRandomAccessStream()); encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Straight, (uint)mp.renderTargetBitmap.PixelWidth, (uint)mp.renderTargetBitmap.PixelHeight, logicalDpi, logicalDpi, pixelBuffer.ToArray()); await encoder.FlushAsync(); } if (Settings.Default.ThemeDefault == true) { me.RequestedTheme = ElementTheme.Default; } if (Settings.Default.ThemeDark == true) { me.RequestedTheme = ElementTheme.Dark; } if (Settings.Default.ThemeLight == true) { me.RequestedTheme = ElementTheme.Light; } } if (saveFile.FileType == ".png") { me.RequestedTheme = ElementTheme.Light; me.Focus(FocusState.Programmatic); Debug.WriteLine("Focus set"); await mp.renderTargetBitmap.RenderAsync(me); Debug.WriteLine("Rendered"); using (var stream = await saveFile.OpenStreamForWriteAsync()) { var logicalDpi = DisplayInformation.GetForCurrentView().LogicalDpi; var pixelBuffer = await mp.renderTargetBitmap.GetPixelsAsync(); var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, stream.AsRandomAccessStream()); encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Straight, (uint)mp.renderTargetBitmap.PixelWidth, (uint)mp.renderTargetBitmap.PixelHeight, logicalDpi, logicalDpi, pixelBuffer.ToArray()); await encoder.FlushAsync(); } if (Settings.Default.ThemeDefault == true) { me.RequestedTheme = ElementTheme.Default; } if (Settings.Default.ThemeDark == true) { me.RequestedTheme = ElementTheme.Dark; } if (Settings.Default.ThemeLight == true) { me.RequestedTheme = ElementTheme.Light; } } if (saveFile.FileType == ".bmp") { me.RequestedTheme = ElementTheme.Light; me.Focus(FocusState.Programmatic); Debug.WriteLine("Focus set"); await mp.renderTargetBitmap.RenderAsync(me); Debug.WriteLine("Rendered"); using (var stream = await saveFile.OpenStreamForWriteAsync()) { var logicalDpi = DisplayInformation.GetForCurrentView().LogicalDpi; var pixelBuffer = await mp.renderTargetBitmap.GetPixelsAsync(); var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.BmpEncoderId, stream.AsRandomAccessStream()); encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Straight, (uint)mp.renderTargetBitmap.PixelWidth, (uint)mp.renderTargetBitmap.PixelHeight, logicalDpi, logicalDpi, pixelBuffer.ToArray()); await encoder.FlushAsync(); } if (Settings.Default.ThemeDefault == true) { me.RequestedTheme = ElementTheme.Default; } if (Settings.Default.ThemeDark == true) { me.RequestedTheme = ElementTheme.Dark; } if (Settings.Default.ThemeLight == true) { me.RequestedTheme = ElementTheme.Light; } } if (saveFile.FileType == ".gif") { me.RequestedTheme = ElementTheme.Light; me.Focus(FocusState.Programmatic); Debug.WriteLine("Focus set"); await mp.renderTargetBitmap.RenderAsync(me); Debug.WriteLine("Rendered"); using (var stream = await saveFile.OpenStreamForWriteAsync()) { var logicalDpi = DisplayInformation.GetForCurrentView().LogicalDpi; var pixelBuffer = await mp.renderTargetBitmap.GetPixelsAsync(); var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.GifEncoderId, stream.AsRandomAccessStream()); encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Straight, (uint)mp.renderTargetBitmap.PixelWidth, (uint)mp.renderTargetBitmap.PixelHeight, logicalDpi, logicalDpi, pixelBuffer.ToArray()); await encoder.FlushAsync(); } if (Settings.Default.ThemeDefault == true) { me.RequestedTheme = ElementTheme.Default; } if (Settings.Default.ThemeDark == true) { me.RequestedTheme = ElementTheme.Dark; } if (Settings.Default.ThemeLight == true) { me.RequestedTheme = ElementTheme.Light; } } if (saveFile.FileType == ".tiff") { me.RequestedTheme = ElementTheme.Light; me.Focus(FocusState.Programmatic); Debug.WriteLine("Focus set"); await mp.renderTargetBitmap.RenderAsync(me); Debug.WriteLine("Rendered"); using (var stream = await saveFile.OpenStreamForWriteAsync()) { var logicalDpi = DisplayInformation.GetForCurrentView().LogicalDpi; var pixelBuffer = await mp.renderTargetBitmap.GetPixelsAsync(); var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.TiffEncoderId, stream.AsRandomAccessStream()); encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Straight, (uint)mp.renderTargetBitmap.PixelWidth, (uint)mp.renderTargetBitmap.PixelHeight, logicalDpi, logicalDpi, pixelBuffer.ToArray()); await encoder.FlushAsync(); } if (Settings.Default.ThemeDefault == true) { me.RequestedTheme = ElementTheme.Default; } if (Settings.Default.ThemeDark == true) { me.RequestedTheme = ElementTheme.Dark; } if (Settings.Default.ThemeLight == true) { me.RequestedTheme = ElementTheme.Light; } } if (saveFile.FileType == ".pdf") { await mp.SfPdfSave(saveFile); } } else { MessageDialog md = new MessageDialog(mp.resourceLoader.GetString("Dialog_FileNotSaved"), mp.resourceLoader.GetString("Dialog_OperationCancelled")); await md.ShowAsync(); } mp.ChangeLoading(false); } if (MoreOptionsList.SelectedIndex == 1) { me.Document.GetText(TextGetOptions.None, out string value); if (string.IsNullOrEmpty(value) || string.IsNullOrWhiteSpace(value)) { mp.Import(2); } else { mp.Import(Settings.Default.ImportOption); } } if (MoreOptionsList.SelectedIndex == 2) { mp.ChangeLoading(true); StorageFolder folder = await ApplicationData.Current.LocalCacheFolder.CreateFolderAsync("share", CreationCollisionOption.ReplaceExisting); if (Settings.Default.ShareFileType == 0) { StorageFile sharefile = await mp.file.CopyAsync(folder, Settings.Default.DefaultShareName + ".rtf", NameCollisionOption.ReplaceExisting); } if (Settings.Default.ShareFileType == 1) { StorageFile sharefile = await folder.CreateFileAsync(Settings.Default.DefaultShareName + ".pdf", CreationCollisionOption.ReplaceExisting); await mp.SfPdfSave(sharefile); } if (Settings.Default.ShareFileType == 2) { StorageFile shareFile = await folder.CreateFileAsync(Settings.Default.DefaultShareName + ".html", CreationCollisionOption.ReplaceExisting); await FileIO.WriteTextAsync(shareFile, ConvertToHtml(me, mp.EncodingList)); } if (Settings.Default.ShareFileType == 3) { StorageFile shareFile = await folder.CreateFileAsync(Settings.Default.DefaultShareName + ".docx", CreationCollisionOption.ReplaceExisting); mp.SfSave(shareFile, FormatType.Docx); } if (Settings.Default.ShareFileType == 4) { StorageFile shareFile = await folder.CreateFileAsync(Settings.Default.DefaultShareName + ".doc", CreationCollisionOption.ReplaceExisting); mp.SfSave(shareFile, FormatType.Doc); } if (Settings.Default.ShareFileType == 5) { StorageFile shareFile = await folder.CreateFileAsync(Settings.Default.DefaultShareName + ".epub", CreationCollisionOption.ReplaceExisting); mp.SfSave(shareFile, FormatType.EPub); } if (Settings.Default.ShareFileType == 6) { StorageFile shareFile = await folder.CreateFileAsync(Settings.Default.DefaultShareName + ".txt", CreationCollisionOption.ReplaceExisting); me.Document.GetText(TextGetOptions.None, out string txtstring); await FileIO.WriteTextAsync(shareFile, txtstring); } if (Settings.Default.ShareFileType >= 7) { string ext = ".jpg"; if (Settings.Default.ShareFileType == 8) { ext = ".png"; } if (Settings.Default.ShareFileType == 9) { ext = ".bmp"; } if (Settings.Default.ShareFileType == 10) { ext = ".gif"; } if (Settings.Default.ShareFileType == 11) { ext = ".tiff"; } StorageFile shareFile = await folder.CreateFileAsync(Settings.Default.DefaultShareName + ext, CreationCollisionOption.ReplaceExisting); me.RequestedTheme = ElementTheme.Light; me.Focus(FocusState.Programmatic); Debug.WriteLine("Focus set"); await mp.renderTargetBitmap.RenderAsync(me); Debug.WriteLine("Rendered"); using (var stream = await shareFile.OpenStreamForWriteAsync()) { var logicalDpi = DisplayInformation.GetForCurrentView().LogicalDpi; var pixelBuffer = await mp.renderTargetBitmap.GetPixelsAsync(); if (Settings.Default.ShareFileType == 7) { BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, stream.AsRandomAccessStream());; encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Straight, (uint)mp.renderTargetBitmap.PixelWidth, (uint)mp.renderTargetBitmap.PixelHeight, logicalDpi, logicalDpi, pixelBuffer.ToArray()); await encoder.FlushAsync(); } if (Settings.Default.ShareFileType == 8) { BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, stream.AsRandomAccessStream());; encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Straight, (uint)mp.renderTargetBitmap.PixelWidth, (uint)mp.renderTargetBitmap.PixelHeight, logicalDpi, logicalDpi, pixelBuffer.ToArray()); await encoder.FlushAsync(); } if (Settings.Default.ShareFileType == 9) { BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.BmpEncoderId, stream.AsRandomAccessStream());; encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Straight, (uint)mp.renderTargetBitmap.PixelWidth, (uint)mp.renderTargetBitmap.PixelHeight, logicalDpi, logicalDpi, pixelBuffer.ToArray()); await encoder.FlushAsync(); } if (Settings.Default.ShareFileType == 10) { BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.GifEncoderId, stream.AsRandomAccessStream());; encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Straight, (uint)mp.renderTargetBitmap.PixelWidth, (uint)mp.renderTargetBitmap.PixelHeight, logicalDpi, logicalDpi, pixelBuffer.ToArray()); await encoder.FlushAsync(); } if (Settings.Default.ShareFileType == 11) { BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.TiffEncoderId, stream.AsRandomAccessStream());; encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Straight, (uint)mp.renderTargetBitmap.PixelWidth, (uint)mp.renderTargetBitmap.PixelHeight, logicalDpi, logicalDpi, pixelBuffer.ToArray()); await encoder.FlushAsync(); } stream.Dispose(); } if (Settings.Default.ThemeDefault == true) { me.RequestedTheme = ElementTheme.Default; } if (Settings.Default.ThemeDark == true) { me.RequestedTheme = ElementTheme.Dark; } if (Settings.Default.ThemeLight == true) { me.RequestedTheme = ElementTheme.Light; } } IReadOnlyList <StorageFile> pickedFiles = await folder.GetFilesAsync(); if (pickedFiles.Count > 0) { storageItems = pickedFiles; // Display the file names in the UI. string selectedFiles = string.Empty; for (int index = 0; index < pickedFiles.Count; index++) { selectedFiles += pickedFiles[index].Name; if (index != (pickedFiles.Count - 1)) { selectedFiles += ", "; } } } DataTransferManager.GetForCurrentView().DataRequested += ShareFile_DataRequested; DataTransferManager.ShowShareUI(); mp.ChangeLoading(false); } if (MoreOptionsList.SelectedIndex == 3) { mp.ChangeLoading(true); if (me.Document.Selection.Length == 0) { DataTransferManager.GetForCurrentView().DataRequested += ShareTextAll_DataRequested; DataTransferManager.ShowShareUI(); } else { DataTransferManager.GetForCurrentView().DataRequested += ShareText_DataRequested; DataTransferManager.ShowShareUI(); } mp.ChangeLoading(false); } if (MoreOptionsList.SelectedIndex == 4) { mp.ChangeLoading(true); me.Document.SetText(TextSetOptions.None, ""); mp.ChangeLoading(false); } if (MoreOptionsList.SelectedIndex == 5) { Application.Current.Exit(); } MoreOptionsList.SelectedItem = null; }
private void focus(ref RichEditBox display) { display.Focus(FocusState.Keyboard); }
//tracks selection private void selected(ref RichEditBox document) { document.Focus(Windows.UI.Xaml.FocusState.Keyboard); }