1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2006 Novell, Inc.
23 // Jonathan Chambers (jonathan.chambers@ansys.com)
27 using System.Drawing;
\r
28 using System.Drawing.Printing;
\r
30 namespace System.Windows.Forms
\r
33 public class PrintControllerWithStatusDialog : PrintController {
34 #region Local variables
35 PrintController underlyingController;
37 PrintingDialog dialog;
39 #endregion // Local variables
41 #region Public Constructors
\r
43 [MonoTODO("Localize Dialog Title")]
\r
44 public PrintControllerWithStatusDialog(PrintController underlyingController) {
\r
45 this.underlyingController = underlyingController;
\r
46 dialog = new PrintingDialog();
\r
47 dialog.Text = "Printing";
\r
50 public PrintControllerWithStatusDialog(PrintController underlyingController, string dialogTitle) : this(underlyingController) {
51 dialog.Text = dialogTitle;
53 #endregion // Public Constructors
\r
55 #region Protected Instance Methods
\r
56 public override void OnEndPage(PrintDocument document, PrintPageEventArgs e) {
\r
57 if (dialog.DialogResult == DialogResult.Cancel) {
\r
61 base.OnEndPage (document, e);
\r
64 public override void OnEndPrint(PrintDocument document, PrintEventArgs e) {
\r
67 base.OnEndPrint (document, e);
\r
70 public override Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e) {
\r
71 if (dialog.DialogResult == DialogResult.Cancel) {
\r
75 dialog.LabelText = string.Format("Page {0} of document", ++currentPage);
\r
76 return base.OnStartPage (document, e);
\r
79 public override void OnStartPrint(PrintDocument document, PrintEventArgs e) {
\r
82 base.OnStartPrint (document, e);
\r
85 #endregion // Protected Instance Methods
\r
87 #region Internal Class
\r
88 class PrintingDialog : Form {
\r
89 private Button buttonCancel;
\r
90 private Label label;
\r
92 public PrintingDialog() {
\r
93 buttonCancel = new System.Windows.Forms.Button();
\r
94 label = new System.Windows.Forms.Label();
\r
97 buttonCancel.Location = new System.Drawing.Point(88, 88);
\r
98 buttonCancel.Name = "buttonCancel";
\r
99 buttonCancel.TabIndex = 0;
\r
100 buttonCancel.Text = "Cancel";
\r
102 label.Location = new System.Drawing.Point(0, 40);
\r
103 label.Name = "label";
\r
104 label.Size = new System.Drawing.Size(257, 23);
\r
105 label.TabIndex = 1;
\r
106 label.Text = "Page 1 of document";
\r
107 label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
\r
109 AutoScaleBaseSize = new System.Drawing.Size(5, 13);
\r
110 CancelButton = buttonCancel;
\r
111 ClientSize = new System.Drawing.Size(258, 124);
\r
112 ControlBox = false;
\r
113 Controls.Add(label);
\r
114 Controls.Add(buttonCancel);
\r
115 FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
\r
116 Name = "PrintingDialog";
\r
117 ShowInTaskbar = false;
\r
119 ResumeLayout(false);
\r
122 public string LabelText {
\r
123 get { return label.Text; }
\r
124 set { label.Text = value; }
\r
127 #endregion Internal Class
\r