dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/System.Drawing/Printing PreviewPrintC


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/System.Drawing/Printing PreviewPrintController.cs, 1.1, 1.2 PrintController.cs, 1.1, 1.2 PrintDocument.cs, 1.2, 1.3 PrintPageEventArgs.cs, 1.1, 1.2 StandardPrintController.cs, 1.1, 1.2
Date: Thu, 17 Jul 2003 23:53:35 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/System.Drawing/Printing
In directory subversions:/tmp/cvs-serv31887/System.Drawing/Printing

Modified Files:
        PreviewPrintController.cs PrintController.cs PrintDocument.cs 
        PrintPageEventArgs.cs StandardPrintController.cs 
Log Message:


Implement the core loop for sending pages to the printer.


Index: PreviewPrintController.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/System.Drawing/Printing/PreviewPrintController.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** PreviewPrintController.cs   7 Jun 2003 22:40:58 -0000       1.1
--- PreviewPrintController.cs   18 Jul 2003 03:53:32 -0000      1.2
***************
*** 23,35 ****
  {
  
  public class PreviewPrintController : PrintController
  {
        // Internal state.
!       private bool useAntiAlias;
  
        // Constructor.
        public PreviewPrintController()
                        {
!                               this.useAntiAlias = false;
                        }
  
--- 23,38 ----
  {
  
+ using System.Drawing.Toolkit;
+ 
  public class PreviewPrintController : PrintController
  {
        // Internal state.
!       private IToolkitPrintSession session;
  
        // Constructor.
+       [TODO]
        public PreviewPrintController()
                        {
!                               this.session = null;    // TODO: create a 
preview session.
                        }
  
***************
*** 39,92 ****
                                get
                                {
!                                       return useAntiAlias;
                                }
                                set
                                {
!                                       useAntiAlias = value;
                                }
                        }
  
        // Get the page preview information for all pages.
-       [TODO]
        public PreviewPageInfo[] GetPreviewPageInfo()
                        {
!                               // TODO
!                               return null;
                        }
  
        // Event that is emitted at the end of a page.
-       [TODO]
        public override void OnEndPage
                                (PrintDocument document, PrintPageEventArgs e)
                        {
!                               // TODO
!                               base.OnEndPage(document, e);
                        }
  
        // Event that is emitted at the end of the print process.
-       [TODO]
        public override void OnEndPrint
                                (PrintDocument document, PrintEventArgs e)
                        {
!                               // TODO
!                               base.OnEndPrint(document, e);
                        }
  
        // Event that is emitted at the start of a page.
!       [TODO]
!       public override void OnStartPage
                                (PrintDocument document, PrintPageEventArgs e)
                        {
!                               // TODO
!                               base.OnStartPage(document, e);
                        }
  
        // Event that is emitted at the start of the print process.
-       [TODO]
        public override void OnStartPrint
                                (PrintDocument document, PrintEventArgs e)
                        {
!                               // TODO
!                               base.OnStartPrint(document, e);
                        }
  
--- 42,86 ----
                                get
                                {
!                                       return session.UseAntiAlias;
                                }
                                set
                                {
!                                       session.UseAntiAlias = value;
                                }
                        }
  
        // Get the page preview information for all pages.
        public PreviewPageInfo[] GetPreviewPageInfo()
                        {
!                               return session.GetPreviewPageInfo();
                        }
  
        // Event that is emitted at the end of a page.
        public override void OnEndPage
                                (PrintDocument document, PrintPageEventArgs e)
                        {
!                               session.EndPage(e);
                        }
  
        // Event that is emitted at the end of the print process.
        public override void OnEndPrint
                                (PrintDocument document, PrintEventArgs e)
                        {
!                               session.EndPrint(e);
                        }
  
        // Event that is emitted at the start of a page.
!       public override Graphics OnStartPage
                                (PrintDocument document, PrintPageEventArgs e)
                        {
!                               return session.StartPage(e);
                        }
  
        // Event that is emitted at the start of the print process.
        public override void OnStartPrint
                                (PrintDocument document, PrintEventArgs e)
                        {
!                               session.Document = document;
!                               session.StartPrint(e);
                        }
  

Index: PrintController.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/System.Drawing/Printing/PrintController.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** PrintController.cs  7 Jun 2003 22:40:58 -0000       1.1
--- PrintController.cs  18 Jul 2003 03:53:32 -0000      1.2
***************
*** 43,50 ****
  
        // Event that is emitted at the start of a page.
!       public virtual void OnStartPage
                                (PrintDocument document, PrintPageEventArgs e)
                        {
                                // Nothing to do here.
                        }
  
--- 43,51 ----
  
        // Event that is emitted at the start of a page.
!       public virtual Graphics OnStartPage
                                (PrintDocument document, PrintPageEventArgs e)
                        {
                                // Nothing to do here.
+                               return null;
                        }
  

Index: PrintDocument.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/System.Drawing/Printing/PrintDocument.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** PrintDocument.cs    9 Jun 2003 22:15:09 -0000       1.2
--- PrintDocument.cs    18 Jul 2003 03:53:32 -0000      1.3
***************
*** 24,27 ****
--- 24,28 ----
  
  using System.ComponentModel;
+ using System.Drawing.Toolkit;
  
  public class PrintDocument
***************
*** 36,39 ****
--- 37,41 ----
        private PrintController printController;
        private PrinterSettings printerSettings;
+       internal IToolkitPrintSession session;
  
        // Constructor.
***************
*** 81,85 ****
                                }
                        }
-       [TODO]
        public PrintController PrintController
                        {
--- 83,86 ----
***************
*** 90,95 ****
                                                // Create a standard print 
controller.
                                                printController = new 
StandardPrintController();
- 
-                                               // TODO: wrap the controller 
with a status dialog.
                                        }
                                        return printController;
--- 91,94 ----
***************
*** 113,120 ****
  
        // Print the document.
-       [TODO]
        public void Print()
                        {
!                               // TODO
                        }
  
--- 112,183 ----
  
        // Print the document.
        public void Print()
                        {
!                               PrintController controller = PrintController;
!                               PrintEventArgs printArgs;
!                               QueryPageSettingsEventArgs queryArgs;
!                               PrintPageEventArgs pageArgs;
!                               Graphics graphics;
! 
!                               // Begin the printing process.
!                               printArgs = new PrintEventArgs();
!                               OnBeginPrint(printArgs);
!                       #if CONFIG_COMPONENT_MODEL
!                               if(printArgs.Cancel)
!                               {
!                                       return;
!                               }
!                       #endif
!                               controller.OnStartPrint(this, printArgs);
! 
!                               // Wrap the rest in a "try" block so that the 
controller
!                               // will be properly shut down if an exception 
occurs.
!                               try
!                               {
!                                       queryArgs = new 
QueryPageSettingsEventArgs
!                                               
((PageSettings)(DefaultPageSettings.Clone()));
!                                       do
!                                       {
!                                               // Query the page settings for 
the next page.
!                                               OnQueryPageSettings(queryArgs);
!                                       #if CONFIG_COMPONENT_MODEL
!                                               if(queryArgs.Cancel)
!                                               {
!                                                       break;
!                                               }
!                                       #endif
! 
!                                               // Create the page argument 
structure.
!                                               pageArgs = new 
PrintPageEventArgs
!                                                       
(queryArgs.PageSettings);
! 
!                                               // Get the graphics object to 
use to draw the page.
!                                               graphics = 
controller.OnStartPage(this, pageArgs);
!                                               pageArgs.graphics = graphics;
! 
!                                               // Print the page.
!                                               try
!                                               {
!                                                       OnPrintPage(pageArgs);
!                                                       
controller.OnEndPage(this, pageArgs);
!                                               }
!                                               finally
!                                               {
!                                                       graphics.Dispose();
!                                               }
!                                       }
!                                       while(!(pageArgs.Cancel) && 
pageArgs.HasMorePages);
!                               }
!                               finally
!                               {
!                                       try
!                                       {
!                                               OnEndPrint(printArgs);
!                                       }
!                                       finally
!                                       {
!                                               controller.OnEndPrint(this, 
printArgs);
!                                       }
!                               }
                        }
  

Index: PrintPageEventArgs.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/System.Drawing/Printing/PrintPageEventArgs.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** PrintPageEventArgs.cs       7 Jun 2003 22:40:58 -0000       1.1
--- PrintPageEventArgs.cs       18 Jul 2003 03:53:32 -0000      1.2
***************
*** 28,32 ****
        private bool cancel;
        private bool hasMorePages;
!       private Graphics graphics;
        private Rectangle marginBounds;
        private Rectangle pageBounds;
--- 28,32 ----
        private bool cancel;
        private bool hasMorePages;
!       internal Graphics graphics;
        private Rectangle marginBounds;
        private Rectangle pageBounds;
***************
*** 44,47 ****
--- 44,60 ----
                                this.marginBounds = marginBounds;
                                this.pageBounds = pageBounds;
+                               this.pageSettings = pageSettings;
+                       }
+       internal PrintPageEventArgs(PageSettings pageSettings)
+                       {
+                               this.cancel = false;
+                               this.hasMorePages = false;
+                               this.graphics = null;
+                               this.pageBounds = pageSettings.Bounds;
+                               Margins margins = pageSettings.Margins;
+                               this.marginBounds = new Rectangle
+                                       (margins.Left, margins.Top,
+                                        pageBounds.Width - margins.Left - 
margins.Right,
+                                        pageBounds.Height - margins.Top - 
margins.Bottom);
                                this.pageSettings = pageSettings;
                        }

Index: StandardPrintController.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/System.Drawing/Printing/StandardPrintController.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** StandardPrintController.cs  7 Jun 2003 22:40:58 -0000       1.1
--- StandardPrintController.cs  18 Jul 2003 03:53:32 -0000      1.2
***************
*** 23,26 ****
--- 23,28 ----
  {
  
+ using System.Drawing.Toolkit;
+ 
  public class StandardPrintController : PrintController
  {
***************
*** 28,65 ****
        public StandardPrintController() {}
  
        // Event that is emitted at the end of a page.
-       [TODO]
        public override void OnEndPage
                                (PrintDocument document, PrintPageEventArgs e)
                        {
!                               // TODO
!                               base.OnEndPage(document, e);
                        }
  
        // Event that is emitted at the end of the print process.
-       [TODO]
        public override void OnEndPrint
                                (PrintDocument document, PrintEventArgs e)
                        {
!                               // TODO
!                               base.OnEndPrint(document, e);
                        }
  
        // Event that is emitted at the start of a page.
!       [TODO]
!       public override void OnStartPage
                                (PrintDocument document, PrintPageEventArgs e)
                        {
!                               // TODO
!                               base.OnStartPage(document, e);
                        }
  
        // Event that is emitted at the start of the print process.
-       [TODO]
        public override void OnStartPrint
                                (PrintDocument document, PrintEventArgs e)
                        {
!                               // TODO
!                               base.OnStartPrint(document, e);
                        }
  
--- 30,81 ----
        public StandardPrintController() {}
  
+       // Get the printer session for a document.
+       private static IToolkitPrintSession GetSession(PrintDocument document)
+                       {
+                               if(document.session == null)
+                               {
+                                       document.session =
+                                               
document.PrinterSettings.ToolkitPrinter
+                                                       .GetSession(document);
+                                       document.session.Document = document;
+                               }
+                               return document.session;
+                       }
+ 
        // Event that is emitted at the end of a page.
        public override void OnEndPage
                                (PrintDocument document, PrintPageEventArgs e)
                        {
!                               GetSession(document).EndPage(e);
                        }
  
        // Event that is emitted at the end of the print process.
        public override void OnEndPrint
                                (PrintDocument document, PrintEventArgs e)
                        {
!                               IToolkitPrintSession session = 
GetSession(document);
!                               try
!                               {
!                                       session.EndPrint(e);
!                               }
!                               finally
!                               {
!                                       document.session = null;
!                               }
                        }
  
        // Event that is emitted at the start of a page.
!       public override Graphics OnStartPage
                                (PrintDocument document, PrintPageEventArgs e)
                        {
!                               return GetSession(document).StartPage(e);
                        }
  
        // Event that is emitted at the start of the print process.
        public override void OnStartPrint
                                (PrintDocument document, PrintEventArgs e)
                        {
!                               IToolkitPrintSession session = 
GetSession(document);
!                               session.StartPrint(e);
                        }
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]