* XplatUIX11.cs: Removed unused hwnd var in SetBorderStyle.
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / PageSetupDialog.cs
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:
8 // 
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 // 
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.
19 //
20 // Copyright (c) 2006 Novell, Inc.
21 //
22 // Authors:
23 //      Jonathan Chambers (jonathan.chambers@ansys.com)
24 //
25
26 using System;
27 using System.ComponentModel;
28 using System.ComponentModel.Design;
29 using System.ComponentModel.Design.Serialization;
30 using System.Collections;
31 using System.Diagnostics;
32 using System.Drawing;
33 using System.Drawing.Printing;
34 using System.Globalization;
35 using System.Reflection;
36
37 namespace System.Windows.Forms {
38
39         [DefaultProperty("Document")]
40         public sealed class PageSetupDialog : CommonDialog {
41                 //const int yard_pound_default = 100;
42                 //static readonly int meter_default = (int) Math.Round (10 * 3.937 * 100);
43
44                 #region Local variables
45                 private PrintDocument document;
46                 private PageSettings page_settings;
47                 private PrinterSettings printer_settings;
48                 private Margins min_margins;
49                 private bool allow_margins;
50                 private bool allow_orientation;
51                 private bool allow_paper;
52                 private bool allow_printer;
53                 private bool show_help;
54                 private bool show_network;
55
56                 private GroupBox groupbox_paper;
57                 private Label label_source;
58                 private Label label_size;
59                 private GroupBox groupbox_orientation;
60                 private RadioButton radio_landscape;
61                 private RadioButton radio_portrait;
62                 private GroupBox groupbox_margin;
63                 private Label label_left;
64                 private Button button_help;
65                 private Button button_ok;
66                 private Button button_cancel;
67                 private Button button_printer;
68                 private Label label_top;
69                 private Label label_right;
70                 private Label label_bottom;
71                 private NumericTextBox textbox_left;
72                 private NumericTextBox textbox_top;
73                 private NumericTextBox textbox_right;
74                 private NumericTextBox textbox_bottom;
75                 private ComboBox combobox_source;
76                 private ComboBox combobox_size;
77                 private PrinterForm printer_helper_form;
78                 #endregion // Local variables
79
80                 #region Public Constructors
81                 public PageSetupDialog () 
82                 {
83                         InitializeComponent();
84                         Reset ();
85                 }
86                 #endregion // Public Constructors
87
88
89                 #region Public Instance Methods
90                 public override void Reset () 
91                 {
92                         AllowMargins = true;
93                         AllowOrientation = true;
94                         AllowPaper = true;
95                         AllowPrinter = true;
96                         ShowHelp = false;
97                         ShowNetwork = true;
98                         MinMargins = new Margins (0, 0, 0, 0);
99                         PrinterSettings = null;
100                         PageSettings = null;
101                         Document = null;
102                 }
103                 #endregion // Public Instance Methods
104
105                 #region Public Instance Properties
106                 [DefaultValue(true)]
107                 public bool AllowMargins {
108                         get { return allow_margins; }
109                         set { allow_margins = value; }
110                 }
111
112                 [DefaultValue(true)]
113                 public bool AllowOrientation {
114                         get { return allow_orientation; }
115                         set { allow_orientation = value; }
116                 }
117
118                 [DefaultValue(true)]
119                 public bool AllowPaper {
120                         get { return allow_paper; }
121                         set { allow_paper = value; }
122                 }
123
124                 [DefaultValue(true)]
125                 public bool AllowPrinter {
126                         get { return allow_printer; }
127                         set { allow_printer = value; }
128                 }
129
130                 [DefaultValue(null)]
131                 public PrintDocument Document {
132                         get { return document; }
133                         set { 
134                                 document = value;
135                                 if (document != null) {
136                                         printer_settings = document.PrinterSettings;
137                                         page_settings = document.DefaultPageSettings;
138                                 }
139                         }
140                 }
141
142                 public Margins MinMargins {
143                         get { return min_margins; }
144                         set { min_margins = value; }
145                 }
146
147                 [Browsable(false)]
148                 [DefaultValue(null)]
149                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
150                 public PageSettings PageSettings {
151                         get { return page_settings; }
152                         set { 
153                                 page_settings = value;
154                                 document = null;
155                         }
156                 }
157
158                 [Browsable(false)]
159                 [DefaultValue(null)]
160                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
161                 public PrinterSettings PrinterSettings {
162                         get { return printer_settings; }
163                         set { 
164                                 printer_settings = value;
165                                 document = null;
166                         }
167                 }
168
169                 [DefaultValue(false)]
170                 public bool ShowHelp {
171                         get { return show_help; }
172                         set { 
173                                 if (value != show_help) {
174                                         show_help = value;
175                                         ShowHelpButton ();
176                                 }
177                         }
178                 }
179
180                 [DefaultValue(true)]
181                 public bool ShowNetwork {
182                         get { return show_network; }
183                         set { show_network = value; }
184                 }
185
186                 #endregion // Public Instance Properties
187
188                 #region Protected Instance Methods
189                 protected override bool RunDialog (IntPtr hwnd) 
190                 {
191                         try {
192                                 SetPrinterDetails ();
193                                 return true;
194                         }
195                         catch (Exception e) {
196                                 MessageBox.Show (e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
197                                 return false;
198                         }
199                 }
200                 #endregion // Protected Instance Methods
201
202                 #region Private Helper
203                 private void InitializeComponent()
204                 {
205                         this.groupbox_paper = new System.Windows.Forms.GroupBox();
206                         this.combobox_source = new System.Windows.Forms.ComboBox();
207                         this.combobox_size = new System.Windows.Forms.ComboBox();
208                         this.label_source = new System.Windows.Forms.Label();
209                         this.label_size = new System.Windows.Forms.Label();
210                         this.groupbox_orientation = new System.Windows.Forms.GroupBox();
211                         this.radio_landscape = new System.Windows.Forms.RadioButton();
212                         this.radio_portrait = new System.Windows.Forms.RadioButton();
213                         this.groupbox_margin = new System.Windows.Forms.GroupBox();
214                         this.label_left = new System.Windows.Forms.Label();
215                         this.button_ok = new System.Windows.Forms.Button();
216                         this.button_cancel = new System.Windows.Forms.Button();
217                         this.button_printer = new System.Windows.Forms.Button();
218                         this.label_top = new System.Windows.Forms.Label();
219                         this.label_right = new System.Windows.Forms.Label();
220                         this.label_bottom = new System.Windows.Forms.Label();
221                         this.textbox_left = new System.Windows.Forms.NumericTextBox();
222                         this.textbox_top = new System.Windows.Forms.NumericTextBox();
223                         this.textbox_right = new System.Windows.Forms.NumericTextBox();
224                         this.textbox_bottom = new System.Windows.Forms.NumericTextBox();
225                         this.groupbox_paper.SuspendLayout();
226                         this.groupbox_orientation.SuspendLayout();
227                         this.groupbox_margin.SuspendLayout();
228                         form.SuspendLayout();
229                         // 
230                         // groupbox_paper
231                         // 
232                         this.groupbox_paper.Controls.Add(this.combobox_source);
233                         this.groupbox_paper.Controls.Add(this.combobox_size);
234                         this.groupbox_paper.Controls.Add(this.label_source);
235                         this.groupbox_paper.Controls.Add(this.label_size);
236                         this.groupbox_paper.Location = new System.Drawing.Point(12, 157);
237                         this.groupbox_paper.Name = "groupbox_paper";
238                         this.groupbox_paper.Size = new System.Drawing.Size(336, 90);
239                         this.groupbox_paper.TabIndex = 0;
240                         this.groupbox_paper.TabStop = false;
241                         this.groupbox_paper.Text = "Paper";
242                         // 
243                         // combobox_source
244                         // 
245                         this.combobox_source.Location = new System.Drawing.Point(84, 54);
246                         this.combobox_source.Name = "combobox_source";
247                         this.combobox_source.Size = new System.Drawing.Size(240, 21);
248                         this.combobox_source.TabIndex = 3;
249                         // 
250                         // combobox_size
251                         // 
252                         this.combobox_size.ItemHeight = 13;
253                         this.combobox_size.Location = new System.Drawing.Point(84, 22);
254                         this.combobox_size.Name = "combobox_size";
255                         this.combobox_size.Size = new System.Drawing.Size(240, 21);
256                         this.combobox_size.TabIndex = 2;
257                         // 
258                         // label_source
259                         // 
260                         this.label_source.Location = new System.Drawing.Point(13, 58);
261                         this.label_source.Name = "label_source";
262                         this.label_source.Size = new System.Drawing.Size(48, 16);
263                         this.label_source.TabIndex = 1;
264                         this.label_source.Text = "&Source:";
265                         // 
266                         // label_size
267                         // 
268                         this.label_size.Location = new System.Drawing.Point(13, 25);
269                         this.label_size.Name = "label_size";
270                         this.label_size.Size = new System.Drawing.Size(52, 16);
271                         this.label_size.TabIndex = 0;
272                         this.label_size.Text = "Si&ze:";
273                         // 
274                         // groupbox_orientation
275                         // 
276                         this.groupbox_orientation.Controls.Add(this.radio_landscape);
277                         this.groupbox_orientation.Controls.Add(this.radio_portrait);
278                         this.groupbox_orientation.Location = new System.Drawing.Point(12, 255);
279                         this.groupbox_orientation.Name = "groupbox_orientation";
280                         this.groupbox_orientation.Size = new System.Drawing.Size(96, 90);
281                         this.groupbox_orientation.TabIndex = 1;
282                         this.groupbox_orientation.TabStop = false;
283                         this.groupbox_orientation.Text = "Orientation";
284                         // 
285                         // radio_landscape
286                         // 
287                         this.radio_landscape.Location = new System.Drawing.Point(13, 52);
288                         this.radio_landscape.Name = "radio_landscape";
289                         this.radio_landscape.Size = new System.Drawing.Size(80, 24);
290                         this.radio_landscape.TabIndex = 7;
291                         this.radio_landscape.Text = "L&andscape";
292                         // 
293                         // radio_portrait
294                         // 
295                         this.radio_portrait.Location = new System.Drawing.Point(13, 19);
296                         this.radio_portrait.Name = "radio_portrait";
297                         this.radio_portrait.Size = new System.Drawing.Size(72, 24);
298                         this.radio_portrait.TabIndex = 6;
299                         this.radio_portrait.Text = "P&ortrait";
300                         // 
301                         // groupbox_margin
302                         // 
303                         this.groupbox_margin.Controls.Add(this.textbox_bottom);
304                         this.groupbox_margin.Controls.Add(this.textbox_right);
305                         this.groupbox_margin.Controls.Add(this.textbox_top);
306                         this.groupbox_margin.Controls.Add(this.textbox_left);
307                         this.groupbox_margin.Controls.Add(this.label_bottom);
308                         this.groupbox_margin.Controls.Add(this.label_right);
309                         this.groupbox_margin.Controls.Add(this.label_top);
310                         this.groupbox_margin.Controls.Add(this.label_left);
311                         this.groupbox_margin.Location = new System.Drawing.Point(120, 255);
312                         this.groupbox_margin.Name = "groupbox_margin";
313                         this.groupbox_margin.Size = new System.Drawing.Size(228, 90);
314                         this.groupbox_margin.TabIndex = 2;
315                         this.groupbox_margin.TabStop = false;
316                         this.groupbox_margin.Text = LocalizedLengthUnit ();
317                         // 
318                         // label_left
319                         // 
320                         this.label_left.Location = new System.Drawing.Point(11, 25);
321                         this.label_left.Name = "label_left";
322                         this.label_left.Size = new System.Drawing.Size(40, 23);
323                         this.label_left.TabIndex = 0;
324                         this.label_left.Text = "&Left:";
325                         // 
326                         // button_ok
327                         // 
328                         this.button_ok.Location = new System.Drawing.Point(120, 358);
329                         this.button_ok.Name = "button_ok";
330                         this.button_ok.Size = new System.Drawing.Size(72, 23);
331                         this.button_ok.TabIndex = 3;
332                         this.button_ok.Text = "OK";
333                         this.button_ok.Click += new EventHandler (OnClickOkButton);
334                         // 
335                         // button_cancel
336                         // 
337                         this.button_cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
338                         this.button_cancel.Location = new System.Drawing.Point(198, 358);
339                         this.button_cancel.Name = "button_cancel";
340                         this.button_cancel.Size = new System.Drawing.Size(72, 23);
341                         this.button_cancel.TabIndex = 4;
342                         this.button_cancel.Text = "Cancel";
343                         // 
344                         // button_printer
345                         // 
346                         this.button_printer.Location = new System.Drawing.Point(276, 358);
347                         this.button_printer.Name = "button_printer";
348                         this.button_printer.Size = new System.Drawing.Size(72, 23);
349                         this.button_printer.TabIndex = 5;
350                         this.button_printer.Text = "&Printer...";
351                         this.button_printer.Click += new EventHandler (OnClickPrinterButton);
352                         // 
353                         // label_top
354                         // 
355                         this.label_top.Location = new System.Drawing.Point(11, 57);
356                         this.label_top.Name = "label_top";
357                         this.label_top.Size = new System.Drawing.Size(40, 23);
358                         this.label_top.TabIndex = 1;
359                         this.label_top.Text = "&Top:";
360                         // 
361                         // label_right
362                         // 
363                         this.label_right.Location = new System.Drawing.Point(124, 25);
364                         this.label_right.Name = "label_right";
365                         this.label_right.Size = new System.Drawing.Size(40, 23);
366                         this.label_right.TabIndex = 2;
367                         this.label_right.Text = "&Right:";
368                         // 
369                         // label_bottom
370                         // 
371                         this.label_bottom.Location = new System.Drawing.Point(124, 57);
372                         this.label_bottom.Name = "label_bottom";
373                         this.label_bottom.Size = new System.Drawing.Size(40, 23);
374                         this.label_bottom.TabIndex = 3;
375                         this.label_bottom.Text = "&Bottom:";
376                         // 
377                         // textbox_left
378                         // 
379                         this.textbox_left.Location = new System.Drawing.Point(57, 21);
380                         this.textbox_left.Name = "textbox_left";
381                         this.textbox_left.Size = new System.Drawing.Size(48, 20);
382                         this.textbox_left.TabIndex = 4;
383                         // 
384                         // textbox_top
385                         //
386                         this.textbox_top.Location = new System.Drawing.Point(57, 54);
387                         this.textbox_top.Name = "textbox_top";
388                         this.textbox_top.Size = new System.Drawing.Size(48, 20);
389                         this.textbox_top.TabIndex = 5;
390                         // 
391                         // textbox_right
392                         // 
393                         this.textbox_right.Location = new System.Drawing.Point(171, 21);
394                         this.textbox_right.Name = "textbox_right";
395                         this.textbox_right.Size = new System.Drawing.Size(48, 20);
396                         this.textbox_right.TabIndex = 6;
397                         // 
398                         // textbox_bottom
399                         // 
400                         this.textbox_bottom.Location = new System.Drawing.Point(171, 54);
401                         this.textbox_bottom.Name = "textbox_bottom";
402                         this.textbox_bottom.Size = new System.Drawing.Size(48, 20);
403                         this.textbox_bottom.TabIndex = 7;
404                         // 
405                         // Form3
406                         // 
407                         form.AcceptButton = this.button_ok;
408                         form.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
409                         form.CancelButton = this.button_cancel;
410                         form.ClientSize = new System.Drawing.Size(360, 390);
411                         form.Controls.Add(this.button_printer);
412                         form.Controls.Add(this.button_cancel);
413                         form.Controls.Add(this.button_ok);
414                         form.Controls.Add(this.groupbox_margin);
415                         form.Controls.Add(this.groupbox_orientation);
416                         form.Controls.Add(this.groupbox_paper);
417                         form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
418                         form.HelpButton = true;
419                         form.MaximizeBox = false;
420                         form.MinimizeBox = false;
421                         form.Name = "Form3";
422                         form.ShowInTaskbar = false;
423                         form.Text = "Page Setup";
424                         this.groupbox_paper.ResumeLayout(false);
425                         this.groupbox_orientation.ResumeLayout(false);
426                         this.groupbox_margin.ResumeLayout(false);
427                         form.ResumeLayout(false);
428
429                 }
430
431                 static bool UseYardPound {
432                         get { return !RegionInfo.CurrentRegion.IsMetric; }                      }
433
434                 // .Net uses PrinterSettings property if it is not null.
435                 // Otherwise, it uses PageSettings.PrinterSettings to set values.
436                 // We use this property internally to automatically select the available one.
437                 PrinterSettings InternalPrinterSettings {
438                         get {
439                                 return (printer_settings == null ? page_settings.PrinterSettings :
440                                                 printer_settings);
441                         }
442                 }
443
444                 private double ToLocalizedLength (int marginsUnit)
445                 {
446                         return UseYardPound ?
447                                 marginsUnit / 100.0 :
448                                 marginsUnit / 10.0;
449                 }
450
451                 private int FromLocalizedLength (double marginsUnit)
452                 {
453                         return UseYardPound ?
454                                 (int) (marginsUnit * 100.0) :
455                                 (int) (marginsUnit * 3.937);
456                 }
457
458                 private string LocalizedLengthUnit ()
459                 {
460                         return UseYardPound ? "Margins (inches)" : "Margins (millimeters)";
461                 }
462                 
463                 private void SetPrinterDetails ()
464                 {
465                         if (PageSettings == null)
466                                 throw new ArgumentException ("PageSettings");
467
468                         combobox_size.Items.Clear ();
469                         foreach (PaperSize paper_size in InternalPrinterSettings.PaperSizes)
470                                 combobox_size.Items.Add (paper_size.PaperName);
471                         combobox_size.SelectedItem = page_settings.PaperSize.PaperName;
472                         
473                         combobox_source.Items.Clear ();
474                         foreach (PaperSource paper_source in InternalPrinterSettings.PaperSources)
475                                 combobox_source.Items.Add (paper_source.SourceName);
476                         combobox_source.SelectedItem = page_settings.PaperSource.SourceName;
477                         
478                         if (PageSettings.Landscape)
479                                 radio_landscape.Checked = true;
480                         else
481                                 radio_portrait.Checked = true;
482
483                         if (ShowHelp)
484                                 ShowHelpButton ();
485
486                         Margins page_margins = PageSettings.Margins;
487                         Margins min_margins = MinMargins;
488
489                         // Update margin data
490                         textbox_top.Text = ToLocalizedLength (page_margins.Top).ToString ();
491                         textbox_bottom.Text = ToLocalizedLength (page_margins.Bottom).ToString ();
492                         textbox_left.Text = ToLocalizedLength (page_margins.Left).ToString ();
493                         textbox_right.Text = ToLocalizedLength (page_margins.Right).ToString ();
494                         textbox_top.Min = ToLocalizedLength (min_margins.Top);
495                         textbox_bottom.Min = ToLocalizedLength (min_margins.Bottom);
496                         textbox_left.Min = ToLocalizedLength (min_margins.Left);
497                         textbox_right.Min = ToLocalizedLength (min_margins.Right);
498
499                         button_printer.Enabled = AllowPrinter && PrinterSettings != null;
500                         groupbox_orientation.Enabled = AllowOrientation;
501                         groupbox_paper.Enabled = AllowPaper;
502                         groupbox_margin.Enabled = AllowMargins;
503                 }
504
505                 private void OnClickOkButton (object sender, EventArgs e)
506                 {                       
507                         if (combobox_size.SelectedItem != null) {
508                                 foreach (PaperSize paper_size in InternalPrinterSettings.PaperSizes) {
509                                         if (paper_size.PaperName == (string) combobox_size.SelectedItem) {
510                                                 PageSettings.PaperSize = paper_size;
511                                                 break;
512                                         }
513                                 }
514                         }
515                         
516                         if (combobox_source.SelectedItem != null) {
517                                 foreach (PaperSource paper_source in InternalPrinterSettings.PaperSources) {
518                                         if (paper_source.SourceName == (string) combobox_source.SelectedItem) {
519                                                 PageSettings.PaperSource = paper_source;
520                                                 break;
521                                         }
522                                 }
523                         }
524
525                         Margins margins = new Margins ();
526                         margins.Top = FromLocalizedLength (textbox_top.Value);
527                         margins.Bottom = FromLocalizedLength (textbox_bottom.Value);
528                         margins.Left = FromLocalizedLength (textbox_left.Value);
529                         margins.Right = FromLocalizedLength (textbox_right.Value);
530                         PageSettings.Margins = margins;
531
532                         PageSettings.Landscape = radio_landscape.Checked;
533                         form.DialogResult = DialogResult.OK;
534                 }
535
536                 void ShowHelpButton ()
537                 {
538                         if (button_help == null) {
539                                 button_help = new Button ();
540                                 button_help.Location = new System.Drawing.Point (12, 358);
541                                 button_help.Name = "button_help";
542                                 button_help.Size = new System.Drawing.Size (72, 23);
543                                 button_help.Text = "&Help";
544                                 form.Controls.Add (button_help);
545                         }
546
547                         button_help.Visible = show_help;
548                 }
549
550                 void OnClickPrinterButton (object sender, EventArgs args)
551                 {
552                         if (printer_helper_form == null)
553                                 printer_helper_form = new PrinterForm (this);
554
555                         printer_helper_form.UpdateValues ();
556
557                         // Here update values for PrinterSettings
558                         if (printer_helper_form.ShowDialog () == DialogResult.OK)
559                                 if (printer_helper_form.SelectedPrinter != PrinterSettings.PrinterName)
560                                         PrinterSettings.PrinterName = printer_helper_form.SelectedPrinter;
561
562                         button_ok.Select ();
563                 }
564                 #endregion // Private Helper
565
566                 class PrinterForm : Form
567                 {
568                         private System.Windows.Forms.GroupBox groupbox_printer;
569                         private System.Windows.Forms.ComboBox combobox_printers;
570                         private System.Windows.Forms.Label label_name;
571                         private System.Windows.Forms.Label label_status;
572                         private System.Windows.Forms.Button button_properties;
573                         private System.Windows.Forms.Button button_network;
574                         private System.Windows.Forms.Button button_cancel;
575                         private System.Windows.Forms.Button button_ok;
576                         private System.Windows.Forms.Label label_status_text;
577                         private System.Windows.Forms.Label label_type;
578                         private System.Windows.Forms.Label label_where;
579                         private System.Windows.Forms.Label label_where_text;
580                         private System.Windows.Forms.Label label_type_text;
581                         private System.Windows.Forms.Label label_comment;
582                         private System.Windows.Forms.Label label_comment_text;
583                         PageSetupDialog page_setup_dialog;
584
585                         public PrinterForm (PageSetupDialog page_setup_dialog)
586                         {
587                                 InitializeComponent();
588                                 this.page_setup_dialog = page_setup_dialog;
589                         }
590
591                         public string SelectedPrinter {
592                                 get {
593                                         return (string) combobox_printers.SelectedItem;
594                                 }
595                                 set {
596                                         combobox_printers.SelectedItem = value;
597                                         label_type_text.Text = value;
598                                 }
599                         }
600
601                         public void UpdateValues ()
602                         {
603                                 combobox_printers.Items.Clear ();
604                                 foreach (string printer_name in PrinterSettings.InstalledPrinters)
605                                         combobox_printers.Items.Add (printer_name);
606
607                                 // Select the printer indicated by PageSetupDialog.PrinterSettings
608                                 SelectedPrinter = page_setup_dialog.PrinterSettings.PrinterName;
609
610                                 button_network.Enabled = page_setup_dialog.ShowNetwork;
611                         }
612
613 #region Windows Form Designer generated code
614                         private void InitializeComponent()
615                         {
616                                 this.groupbox_printer = new System.Windows.Forms.GroupBox();
617                                 this.combobox_printers = new System.Windows.Forms.ComboBox();
618                                 this.button_network = new System.Windows.Forms.Button();
619                                 this.button_cancel = new System.Windows.Forms.Button();
620                                 this.button_ok = new System.Windows.Forms.Button();
621                                 this.label_name = new System.Windows.Forms.Label();
622                                 this.label_status = new System.Windows.Forms.Label();
623                                 this.label_status_text = new System.Windows.Forms.Label();
624                                 this.label_type = new System.Windows.Forms.Label();
625                                 this.label_type_text = new System.Windows.Forms.Label();
626                                 this.label_where = new System.Windows.Forms.Label();
627                                 this.label_comment = new System.Windows.Forms.Label();
628                                 this.label_where_text = new System.Windows.Forms.Label();
629                                 this.label_comment_text = new System.Windows.Forms.Label();
630                                 this.button_properties = new System.Windows.Forms.Button();
631                                 this.groupbox_printer.SuspendLayout();
632                                 this.SuspendLayout();
633                                 // 
634                                 // groupbox_printer
635                                 // 
636                                 this.groupbox_printer.Controls.AddRange(new System.Windows.Forms.Control[] {
637                                                 this.button_properties,
638                                                 this.label_comment_text,
639                                                 this.label_where_text,
640                                                 this.label_comment,
641                                                 this.label_where,
642                                                 this.label_type_text,
643                                                 this.label_type,
644                                                 this.label_status_text,
645                                                 this.label_status,
646                                                 this.label_name,
647                                                 this.combobox_printers});
648                                 this.groupbox_printer.Location = new System.Drawing.Point(12, 8);
649                                 this.groupbox_printer.Name = "groupbox_printer";
650                                 this.groupbox_printer.Size = new System.Drawing.Size(438, 136);
651                                 this.groupbox_printer.Text = "Printer";
652                                 // 
653                                 // combobox_printers
654                                 // 
655                                 this.combobox_printers.Location = new System.Drawing.Point(64, 24);
656                                 this.combobox_printers.Name = "combobox_printers";
657                                 this.combobox_printers.SelectedValueChanged += new EventHandler (OnSelectedValueChangedPrinters);
658                                 this.combobox_printers.Size = new System.Drawing.Size(232, 21);
659                                 this.combobox_printers.TabIndex = 1;
660                                 // 
661                                 // button_network
662                                 // 
663                                 this.button_network.Location = new System.Drawing.Point(16, 160);
664                                 this.button_network.Name = "button_network";
665                                 this.button_network.Size = new System.Drawing.Size(68, 22);
666                                 this.button_network.TabIndex = 5;
667                                 this.button_network.Text = "Network...";
668                                 // 
669                                 // button_cancel
670                                 // 
671                                 this.button_cancel.DialogResult = DialogResult.Cancel;
672                                 this.button_cancel.Location = new System.Drawing.Point(376, 160);
673                                 this.button_cancel.Name = "button_cancel";
674                                 this.button_cancel.Size = new System.Drawing.Size(68, 22);
675                                 this.button_cancel.TabIndex = 4;
676                                 this.button_cancel.Text = "Cancel";
677                                 // 
678                                 // button_ok
679                                 // 
680                                 this.button_ok.DialogResult = DialogResult.OK;
681                                 this.button_ok.Location = new System.Drawing.Point(300, 160);
682                                 this.button_ok.Name = "button_ok";
683                                 this.button_ok.Size = new System.Drawing.Size(68, 22);
684                                 this.button_ok.TabIndex = 3;
685                                 this.button_ok.Text = "OK";
686                                 // 
687                                 // label_name
688                                 // 
689                                 this.label_name.Location = new System.Drawing.Point(12, 28);
690                                 this.label_name.Name = "label_name";
691                                 this.label_name.Size = new System.Drawing.Size(48, 20);
692                                 this.label_name.Text = "Name:";
693                                 // 
694                                 // label_status
695                                 // 
696                                 this.label_status.Location = new System.Drawing.Point(6, 52);
697                                 this.label_status.Name = "label_status";
698                                 this.label_status.Size = new System.Drawing.Size(58, 14);
699                                 this.label_status.Text = "Status:";
700                                 // 
701                                 // label_status_text
702                                 // 
703                                 this.label_status_text.Location = new System.Drawing.Point(64, 52);
704                                 this.label_status_text.Name = "label_status_text";
705                                 this.label_status_text.Size = new System.Drawing.Size(64, 14);
706                                 this.label_status_text.Text = String.Empty;
707                                 // 
708                                 // label_type
709                                 // 
710                                 this.label_type.Location = new System.Drawing.Point(6, 72);
711                                 this.label_type.Name = "label_type";
712                                 this.label_type.Size = new System.Drawing.Size(58, 14);
713                                 this.label_type.Text = "Type:";
714                                 // 
715                                 // label_type_text
716                                 // 
717                                 this.label_type_text.Location = new System.Drawing.Point(64, 72);
718                                 this.label_type_text.Name = "label_type_text";
719                                 this.label_type_text.Size = new System.Drawing.Size(232, 14);
720                                 this.label_type_text.TabIndex = 5;
721                                 this.label_type_text.Text = String.Empty;
722                                 // 
723                                 // label_where
724                                 // 
725                                 this.label_where.Location = new System.Drawing.Point(6, 92);
726                                 this.label_where.Name = "label_where";
727                                 this.label_where.Size = new System.Drawing.Size(58, 16);
728                                 this.label_where.TabIndex = 6;
729                                 this.label_where.Text = "Where:";
730                                 // 
731                                 // label_comment
732                                 // 
733                                 this.label_comment.Location = new System.Drawing.Point(6, 112);
734                                 this.label_comment.Name = "label_comment";
735                                 this.label_comment.Size = new System.Drawing.Size(56, 16);
736                                 this.label_comment.Text = "Comment:";
737                                 // 
738                                 // label_where_text
739                                 // 
740                                 this.label_where_text.Location = new System.Drawing.Point(64, 92);
741                                 this.label_where_text.Name = "label_where_text";
742                                 this.label_where_text.Size = new System.Drawing.Size(232, 16);
743                                 this.label_where_text.Text = String.Empty;
744                                 // 
745                                 // label_comment_text
746                                 // 
747                                 this.label_comment_text.Location = new System.Drawing.Point(64, 112);
748                                 this.label_comment_text.Name = "label_comment_text";
749                                 this.label_comment_text.Size = new System.Drawing.Size(232, 16);
750                                 this.label_comment_text.Text = String.Empty;
751                                 // 
752                                 // button_properties
753                                 // 
754                                 this.button_properties.Location = new System.Drawing.Point(308, 22);
755                                 this.button_properties.Name = "button_properties";
756                                 this.button_properties.Size = new System.Drawing.Size(92, 22);
757                                 this.button_properties.TabIndex = 2;
758                                 this.button_properties.Text = "Properties...";
759                                 // 
760                                 // PrinterForm
761                                 // 
762                                 this.AllowDrop = true;
763                                 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
764                                 this.AcceptButton = button_ok;
765                                 this.CancelButton = button_cancel;
766                                 this.ClientSize = new System.Drawing.Size(456, 194);
767                                 this.Controls.AddRange(new System.Windows.Forms.Control[] {
768                                                 this.button_ok,
769                                                 this.button_cancel,
770                                                 this.button_network,
771                                                 this.groupbox_printer});
772                                 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
773                                 this.HelpButton = true;
774                                 this.MaximizeBox = false;
775                                 this.MinimizeBox = false;
776                                 this.Name = "PrinterForm";
777                                 this.ShowInTaskbar = false;
778                                 this.Text = "Configure page";
779                                 this.groupbox_printer.ResumeLayout(false);
780                                 this.ResumeLayout(false);
781                         }
782 #endregion
783                         void OnSelectedValueChangedPrinters (object sender, EventArgs args)
784                         {
785                                 SelectedPrinter = (string) combobox_printers.SelectedItem;
786                         }
787                 }
788
789         }
790 }