/// <summary> /// CreateIDocumentScrollInfo instantiates our IDocumentScrollInfo control /// and sets/resets default properties. /// </summary> private void CreateIDocumentScrollInfo() { if (_documentScrollInfo == null) { // Construct IDocumentScrollInfo (DocumentGrid). _documentScrollInfo = new DocumentGrid(); _documentScrollInfo.DocumentViewerOwner = this; //If IDocumentScrollInfo is a FrameworkElement we can give it a //Name for automation. FrameworkElement fe = _documentScrollInfo as FrameworkElement; if (fe != null) { fe.Name = "DocumentGrid"; fe.Focusable = false; //We don't allow Tabbing to the IDocumentScrollInfo -- //The ScrollViewer parent is what is tabbed to. fe.SetValue(KeyboardNavigation.IsTabStopProperty, false); TextEditorRenderScope = fe; } } //Assign our content to the IDSI. AttachContent(); //Give the IDocumentScrollInfo object default values for important properties. _documentScrollInfo.VerticalPageSpacing = VerticalPageSpacing; _documentScrollInfo.HorizontalPageSpacing = HorizontalPageSpacing; }
//Helper to set properties on the menu items based on the command private void SetMenuProperties(MenuItem menuItem, DocumentGrid dg, RoutedUICommand command) { SetMenuProperties(menuItem, dg, command, null, null); }
private void SetMenuProperties(MenuItem menuItem, DocumentGrid dg, RoutedUICommand command, string header, string inputGestureText) { menuItem.Command = command; menuItem.CommandTarget = dg.DocumentViewerOwner; // the text editor expects the commands to come from the DocumentViewer if (header == null) { menuItem.Header = command.Text; // use default menu text for this command } else { menuItem.Header = header; } if (inputGestureText != null) { menuItem.InputGestureText = inputGestureText; } menuItem.Name = "ViewerContextMenu_" + command.Name; // does not require localization this.Items.Add(menuItem); }
internal void AddMenuItems(DocumentGrid dg, bool userInitiated) { // create a special menu item for paste which only works for user initiated copy // within the confines of partial trust this cannot be done programmatically if (userInitiated == false) { SecurityHelper.DemandAllClipboardPermission(); } this.Name = "ViewerContextMenu"; SetMenuProperties(new EditorMenuItem(), dg, ApplicationCommands.Copy); // Copy will be marked as user initiated // build menu for XPSViewer SetMenuProperties(new MenuItem(), dg, ApplicationCommands.SelectAll); AddSeparator(); SetMenuProperties( new MenuItem(), dg, NavigationCommands.PreviousPage, SR.Get(SRID.DocumentApplicationContextMenuPreviousPageHeader), SR.Get(SRID.DocumentApplicationContextMenuPreviousPageInputGesture)); SetMenuProperties( new MenuItem(), dg, NavigationCommands.NextPage, SR.Get(SRID.DocumentApplicationContextMenuNextPageHeader), SR.Get(SRID.DocumentApplicationContextMenuNextPageInputGesture)); SetMenuProperties( new MenuItem(), dg, NavigationCommands.FirstPage, null, //menu header SR.Get(SRID.DocumentApplicationContextMenuFirstPageInputGesture)); SetMenuProperties( new MenuItem(), dg, NavigationCommands.LastPage, null, //menu header SR.Get(SRID.DocumentApplicationContextMenuLastPageInputGesture)); AddSeparator(); SetMenuProperties(new MenuItem(), dg, ApplicationCommands.Print); }