コード例 #1
0
        //----------------------------------------------
        //
        // Internal Methods
        //
        //----------------------------------------------
        #region Internal Methods

        /// <summary>
        ///     Creates the RBW object and sets the Style property on it
        ///     to the correct value
        /// </summary>
        internal static RootBrowserWindow CreateAndInitialize()
        {
            RootBrowserWindow rbw = new RootBrowserWindow();

            rbw.InitializeRBWStyle();
            return(rbw);
        }
コード例 #2
0
 private object _CreateRootBrowserWindowCallback(object unused)
 {
     EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordPerf | EventTrace.Keyword.KeywordHosting, EventTrace.Event.WpfHost_RootBrowserWindowSetupStart);
     this.RootBrowserWindow = RootBrowserWindow.CreateAndInitialize();
     EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordPerf | EventTrace.Keyword.KeywordHosting, EventTrace.Event.WpfHost_RootBrowserWindowSetupEnd);
     return(null);
 }
コード例 #3
0
        // Token: 0x06007A0E RID: 31246 RVA: 0x00229348 File Offset: 0x00227548
        private static void OnQueryEnabledCommandPrint(object sender, CanExecuteRoutedEventArgs e)
        {
            RootBrowserWindow rootBrowserWindow = sender as RootBrowserWindow;

            Invariant.Assert(rootBrowserWindow != null);
            if (!e.Handled && !rootBrowserWindow._isPrintingFromRBW)
            {
                e.CanExecute = (rootBrowserWindow.Content != null);
            }
        }
コード例 #4
0
        private static void OnQueryEnabledCommandPrint(object sender, CanExecuteRoutedEventArgs e)
        {
            RootBrowserWindow rbw = sender as RootBrowserWindow;

            Invariant.Assert(rbw != null);

            if ((!e.Handled) && (!rbw._isPrintingFromRBW))
            {
                // While we could print null it doesn't really make sense to do so
                e.CanExecute = rbw.Content != null;
            }
        }
コード例 #5
0
        // Token: 0x06007A0D RID: 31245 RVA: 0x002291F0 File Offset: 0x002273F0
        private static void OnCommandPrint(object sender, ExecutedRoutedEventArgs e)
        {
            RootBrowserWindow rootBrowserWindow = sender as RootBrowserWindow;

            Invariant.Assert(rootBrowserWindow != null);
            if (!rootBrowserWindow._isPrintingFromRBW)
            {
                Visual visual = rootBrowserWindow.Content as Visual;
                if (visual == null)
                {
                    IInputElement inputElement = rootBrowserWindow.Content as IInputElement;
                    if (inputElement != null)
                    {
                        rootBrowserWindow._isPrintingFromRBW = true;
                        try
                        {
                            if (ApplicationCommands.Print.CanExecute(null, inputElement))
                            {
                                ApplicationCommands.Print.Execute(null, inputElement);
                                return;
                            }
                        }
                        finally
                        {
                            rootBrowserWindow._isPrintingFromRBW = false;
                        }
                    }
                }
                PrintDialog printDialog = new PrintDialog();
                if (printDialog.ShowDialog() == true)
                {
                    string printJobDescription = RootBrowserWindow.GetPrintJobDescription(RootBrowserWindow.App.MainWindow);
                    if (visual == null)
                    {
                        INavigatorImpl navigatorImpl = rootBrowserWindow;
                        Invariant.Assert(navigatorImpl != null);
                        visual = navigatorImpl.FindRootViewer();
                        Invariant.Assert(visual != null);
                    }
                    Rect        imageableRect = RootBrowserWindow.GetImageableRect(printDialog);
                    VisualBrush visualBrush   = new VisualBrush(visual);
                    visualBrush.Stretch = Stretch.None;
                    DrawingVisual  drawingVisual  = new DrawingVisual();
                    DrawingContext drawingContext = drawingVisual.RenderOpen();
                    drawingContext.DrawRectangle(visualBrush, null, new Rect(imageableRect.X, imageableRect.Y, visual.VisualDescendantBounds.Width, visual.VisualDescendantBounds.Height));
                    drawingContext.Close();
                    printDialog.PrintVisual(drawingVisual, printJobDescription);
                }
            }
        }
コード例 #6
0
 ///
 public RootBrowserWindowAutomationPeer(RootBrowserWindow owner): base(owner) 
 {}
コード例 #7
0
 internal static RootBrowserWindow CreateAndInitialize() 
 {
     RootBrowserWindow rbw = new RootBrowserWindow(); 
     rbw.InitializeRBWStyle();
     return rbw;
 }
コード例 #8
0
        ///<summary>
        /// Prints the content of the App's MainWindow.  The logic is that if the content is not visual but IInputElement
        /// we will try to let it handle the command first. If it does not handle the print command we will get the corresponding
        /// visual in the visual tree and use that to print.
        ///</summary>
        private static void OnCommandPrint(object sender, ExecutedRoutedEventArgs e)
        {
#if !DONOTREFPRINTINGASMMETA
            RootBrowserWindow rbw = sender as RootBrowserWindow;
            Invariant.Assert(rbw != null);

            if (!rbw._isPrintingFromRBW)
            {
                Visual vis = rbw.Content as Visual;

                if (vis == null)
                {
                    // If the content is not Visual but IInputElement, try to let it handle the command first.
                    // This is for the document scenario. Printing a document is different from printing a visual.
                    // Printing a visual is to print how it is rendered on screen. Printing a doc prints the full
                    // doc inculding the part that is not visible. There might be other functionalities that are
                    // specific for document. FlowDocument's viewer knows how to print the doc.
                    IInputElement target = rbw.Content as IInputElement;

                    if (target != null)
                    {
                        // CanExecute will bubble up. If nobody between the content and rbw can handle it,
                        // It would call back on RBW again. Use _isPrintingFromRBW to prevent the loop.
                        rbw._isPrintingFromRBW = true;
                        try
                        {
                            if (ApplicationCommands.Print.CanExecute(null, target))
                            {
                                ApplicationCommands.Print.Execute(null, target);
                                return;
                            }
                        }
                        finally
                        {
                            rbw._isPrintingFromRBW = false;
                        }
                    }
                }

                // Let the user choose a printer and set print options.
                PrintDialog printDlg = new PrintDialog();

                // If the user pressed the OK button on the print dialog, we proceed
                if (printDlg.ShowDialog() == true)
                {
                    string printJobDescription = GetPrintJobDescription(App.MainWindow);

                    // If the root is not visual and does not know how to print itself, we find the
                    // corresponding visual and use that to print.
                    if (vis == null)
                    {
                        INavigatorImpl navigator = rbw as INavigatorImpl;
                        Invariant.Assert(navigator != null);

                        vis = navigator.FindRootViewer();
                        Invariant.Assert(vis != null);
                    }

                    // Area we can print to for the chosen printer
                    Rect imageableRect = GetImageableRect(printDlg);

                    // We print Visuals aligned with the top/left corner of the printable area.
                    // We do not attempt to print very large Visuals across multiple pages.
                    // Any portion that doesn't fit on a single page will get cropped by the
                    // print system.

                    // Used to draw our visual into another visual for printing purposes
                    VisualBrush visualBrush = new VisualBrush(vis);
                    visualBrush.Stretch = Stretch.None;

                    // Visual we will print - containing a rectangle the size of our
                    // original Visual but offset into the printable area
                    DrawingVisual  drawingVisual = new DrawingVisual();
                    DrawingContext context       = drawingVisual.RenderOpen();
                    context.DrawRectangle(visualBrush,
                                          null,
                                          new Rect(imageableRect.X,
                                                   imageableRect.Y,
                                                   vis.VisualDescendantBounds.Width,
                                                   vis.VisualDescendantBounds.Height));
                    context.Close();

                    printDlg.PrintVisual(drawingVisual, printJobDescription);
                }
            }
#endif // DONOTREFPRINTINGASMMETA
        }
コード例 #9
0
 // Token: 0x06007A15 RID: 31253 RVA: 0x0022957F File Offset: 0x0022777F
 internal RootBrowserWindowProxy(RootBrowserWindow rbw)
 {
     this._rbw = rbw;
 }
コード例 #10
0
 internal RootBrowserWindowProxy(RootBrowserWindow rbw)
 {
     _rbw = rbw;
 }