Update Reference Sources to .NET Framework 4.6.1
[mono.git] / mcs / class / referencesource / System.Workflow.ComponentModel / AuthoringOM / Design / Dialogs / WorkflowPageSetupDialog.cs
1 using System;
2 using System.IO;
3 using System.Drawing;
4 using System.Resources;
5 using System.Windows.Forms;
6 using System.Drawing.Printing;
7 using System.ComponentModel.Design;
8
9 namespace System.Workflow.ComponentModel.Design
10 {
11     /// <summary>
12     /// Summary description for Form1.
13     /// </summary>
14     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
15     public sealed class WorkflowPageSetupDialog : System.Windows.Forms.Form
16     {
17         #region [....] Desiger Generated Members
18         private System.ComponentModel.Container components = null;
19         private System.Windows.Forms.TabControl tabs;
20         private System.Windows.Forms.PictureBox landscapePicture;
21         private System.Windows.Forms.PictureBox portraitPicture;
22         private System.Windows.Forms.TabPage pageSettingsTab;
23         private System.Windows.Forms.GroupBox marginsGroup;
24         private NumericUpDown marginsBottomInput;
25         private NumericUpDown marginsRightInput;
26         private NumericUpDown marginsTopInput;
27         private System.Windows.Forms.Label marginsTopLabel;
28         private System.Windows.Forms.Label marginsLeftLabel;
29         private System.Windows.Forms.Label marginsBottomLabel;
30         private System.Windows.Forms.Label marginsRightLabel;
31         private NumericUpDown marginsLeftInput;
32         private System.Windows.Forms.GroupBox scalingGroup;
33         private NumericUpDown adjustToScaleInput;
34         private System.Windows.Forms.RadioButton adjustToRadioButton;
35         private System.Windows.Forms.RadioButton fitToRadioButton;
36         private NumericUpDown fitToPagesWideInput;
37         private NumericUpDown fitToPagesTallInput;
38         private System.Windows.Forms.Label fitToTallLabel;
39         private System.Windows.Forms.Label fitToWideLabel;
40         private System.Windows.Forms.GroupBox orientationGroup;
41         private System.Windows.Forms.RadioButton portraitRadioButton;
42         private System.Windows.Forms.RadioButton landscapeRadioButton;
43         private System.Windows.Forms.GroupBox paperSettingsGroup;
44         private System.Windows.Forms.ComboBox paperSizeComboBox;
45         private System.Windows.Forms.Label paperSizeLabel;
46         private System.Windows.Forms.Label paperSourceLabel;
47         private System.Windows.Forms.ComboBox paperSourceComboBox;
48         private System.Windows.Forms.TabPage headerFooterTab;
49         private System.Windows.Forms.GroupBox footerGroup;
50         private System.Windows.Forms.GroupBox headerGroup;
51         private System.Windows.Forms.ComboBox headerAlignmentComboBox;
52         private System.Windows.Forms.Label headerAlignmentLabel;
53         private System.Windows.Forms.ComboBox headerTextComboBox;
54         private System.Windows.Forms.Label headerTextLabel;
55         private System.Windows.Forms.Label headerMarginLabel;
56         private System.Windows.Forms.Button OKButton;
57         private System.Windows.Forms.Button cancelButton;
58         private System.Windows.Forms.Button printerButton;
59         private NumericUpDown headerMarginInput;
60         private NumericUpDown footerMarginInput;
61         private System.Windows.Forms.ComboBox footerAlignmentComboBox;
62         private System.Windows.Forms.Label footerAlignmentLabel;
63         private System.Windows.Forms.ComboBox footerTextComboBox;
64         private System.Windows.Forms.Label footerTextLabel;
65         private System.Windows.Forms.Label footerMarginLabel;
66         private System.Windows.Forms.Label scalingOfSizeLabel;
67         private System.Windows.Forms.Label footerMarginUnitsLabel;
68         private System.Windows.Forms.Label headerMarginUnitsLabel;
69         private System.Windows.Forms.TextBox customHeaderText;
70         private System.Windows.Forms.Label customHeaderLabel;
71         private System.Windows.Forms.Label customFooterLabel;
72         private System.Windows.Forms.TextBox customFooterText;
73         private System.Windows.Forms.GroupBox centerGroup;
74         private System.Windows.Forms.CheckBox CenterHorizontallyCheckBox;
75         private System.Windows.Forms.CheckBox CenterVerticallyCheckBox;
76         #endregion
77
78         #region Members and Constructor/Destructor
79         private IServiceProvider serviceProvider;
80         private WorkflowPrintDocument printDocument = null;
81         private string headerFooterNone = null;
82         private string headerFooterCustom = null;
83         private string[] headerFooterTemplates = null;
84         private bool headerCustom = false;
85         private TableLayoutPanel okCancelTableLayoutPanel;
86         private TableLayoutPanel paperTableLayoutPanel;
87         private TableLayoutPanel centerTableLayoutPanel;
88         private TableLayoutPanel marginsTableLayoutPanel;
89         private TableLayoutPanel orientationTableLayoutPanel;
90         private TableLayoutPanel scalingTableLayoutPanel;
91         private TableLayoutPanel headerTableLayoutPanel;
92         private TableLayoutPanel footerTableLayoutPanel;
93         private bool footerCustom = false;
94
95         public WorkflowPageSetupDialog(IServiceProvider serviceProvider)
96         {
97             if (serviceProvider == null)
98                 throw new ArgumentNullException("serviceProvider");
99
100             this.serviceProvider = serviceProvider;
101
102             WorkflowView workflowView = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView;
103             if (workflowView == null)
104                 throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(WorkflowView).FullName));
105
106             if (!(workflowView.PrintDocument is WorkflowPrintDocument))
107                 throw new InvalidOperationException(DR.GetString(DR.WorkflowPrintDocumentNotFound, typeof(WorkflowPrintDocument).Name));
108
109             try
110             {
111                 Cursor.Current = Cursors.WaitCursor;
112
113                 InitializeComponent();
114
115                 this.printDocument = workflowView.PrintDocument as WorkflowPrintDocument;
116                 //deserialize state of the dialog from the page setup data scaling:
117
118                 //set the values scaling controls
119                 this.adjustToScaleInput.Value = this.printDocument.PageSetupData.ScaleFactor;
120                 this.fitToPagesWideInput.Value = this.printDocument.PageSetupData.PagesWide;
121                 this.fitToPagesTallInput.Value = this.printDocument.PageSetupData.PagesTall;
122
123                 //select the right mode
124                 if (this.printDocument.PageSetupData.AdjustToScaleFactor)
125                     this.adjustToRadioButton.Checked = true;
126                 else
127                     this.fitToRadioButton.Checked = true;
128
129                 //set the orientation
130                 if (this.printDocument.PageSetupData.Landscape)
131                     this.landscapeRadioButton.Checked = true;
132                 else
133                     this.portraitRadioButton.Checked = true;
134
135                 //margins
136                 SetMarginsToUI(this.printDocument.PageSetupData.Margins);
137
138                 //centering
139                 this.CenterHorizontallyCheckBox.Checked = this.printDocument.PageSetupData.CenterHorizontally;
140                 this.CenterVerticallyCheckBox.Checked = this.printDocument.PageSetupData.CenterVertically;
141
142                 //Initialize the paper
143                 InitializePaperInformation();
144
145                 //read standard header/footer formats
146                 this.headerFooterNone = DR.GetString(DR.HeaderFooterStringNone); //"(none)"
147                 this.headerFooterCustom = DR.GetString(DR.HeaderFooterStringCustom); //"(none)"
148                 this.headerFooterTemplates = new string[] {
149                     DR.GetString(DR.HeaderFooterFormat1), //"Page %Page%",//
150                     DR.GetString(DR.HeaderFooterFormat2), //"Page %Page% of %Pages%",//
151                     DR.GetString(DR.HeaderFooterFormat3), //"%Path%%File, Page %Page% of %Pages%", //
152                     DR.GetString(DR.HeaderFooterFormat4), //"%Path%%File, Page %Page%",//
153                     DR.GetString(DR.HeaderFooterFormat5), //"%File, %Date% %Time%, Page %Page%",//
154                     DR.GetString(DR.HeaderFooterFormat6), //"%File, Page %Page% of %Pages%",//
155                     DR.GetString(DR.HeaderFooterFormat7), //"%File, Page %Page%",//
156                     DR.GetString(DR.HeaderFooterFormat8), //"Prepated by %User% %Date%",//
157                     DR.GetString(DR.HeaderFooterFormat9), //"%User%, Page %Page%, %Date%"//
158                 };
159
160                 //header inputs
161                 this.headerTextComboBox.Items.Add(this.headerFooterNone);
162                 this.headerTextComboBox.Items.AddRange(this.headerFooterTemplates);
163                 this.headerTextComboBox.Items.Add(this.headerFooterCustom);
164                 this.headerTextComboBox.SelectedIndex = 0;
165
166                 string userHeader = this.printDocument.PageSetupData.HeaderTemplate;
167                 this.headerCustom = this.printDocument.PageSetupData.HeaderCustom;
168                 if (userHeader.Length == 0)
169                 {
170                     this.headerTextComboBox.SelectedIndex = 0; //none
171                 }
172                 else
173                 {
174                     int userHeaderIndex = this.headerTextComboBox.Items.IndexOf(userHeader);
175
176                     if (-1 == userHeaderIndex || this.headerCustom)
177                     {
178                         //this is an unknown template, put it into custom field
179                         this.headerTextComboBox.SelectedIndex = this.headerTextComboBox.Items.IndexOf(this.headerFooterCustom);
180                         this.customHeaderText.Text = userHeader;
181                     }
182                     else
183                     {
184                         this.headerTextComboBox.SelectedIndex = userHeaderIndex;
185                     }
186                 }
187
188                 this.headerAlignmentComboBox.Items.AddRange(new object[] { HorizontalAlignment.Left, HorizontalAlignment.Center, HorizontalAlignment.Right });
189                 if (this.headerAlignmentComboBox.Items.IndexOf(this.printDocument.PageSetupData.HeaderAlignment) != -1)
190                     this.headerAlignmentComboBox.SelectedItem = this.printDocument.PageSetupData.HeaderAlignment;
191                 else
192                     this.headerAlignmentComboBox.SelectedItem = HorizontalAlignment.Center;
193
194                 this.headerMarginInput.Value = PrinterUnitToUIUnit(this.printDocument.PageSetupData.HeaderMargin);
195
196                 //footer inputs
197                 this.footerTextComboBox.Items.Add(this.headerFooterNone);
198                 this.footerTextComboBox.SelectedIndex = 0;
199                 this.footerTextComboBox.Items.AddRange(this.headerFooterTemplates);
200                 this.footerTextComboBox.Items.Add(this.headerFooterCustom);
201
202                 string userFooter = this.printDocument.PageSetupData.FooterTemplate;
203                 this.footerCustom = this.printDocument.PageSetupData.FooterCustom;
204                 if (userFooter.Length == 0)
205                 {
206                     this.footerTextComboBox.SelectedIndex = 0; //none
207                 }
208                 else
209                 {
210                     int userFooterIndex = this.footerTextComboBox.Items.IndexOf(userFooter);
211
212                     if (-1 == userFooterIndex || this.footerCustom)
213                     {
214                         //this is an unknown template, put it into custom field
215                         this.footerTextComboBox.SelectedIndex = this.footerTextComboBox.Items.IndexOf(this.headerFooterCustom);
216                         this.customFooterText.Text = userFooter;
217                     }
218                     else
219                     {
220                         this.footerTextComboBox.SelectedIndex = userFooterIndex;
221                     }
222                 }
223
224                 this.footerAlignmentComboBox.Items.AddRange(new object[] { HorizontalAlignment.Left, HorizontalAlignment.Center, HorizontalAlignment.Right });
225                 if (this.footerAlignmentComboBox.Items.IndexOf(this.printDocument.PageSetupData.FooterAlignment) != -1)
226                     this.footerAlignmentComboBox.SelectedItem = this.printDocument.PageSetupData.FooterAlignment;
227                 else
228                     this.footerAlignmentComboBox.SelectedItem = HorizontalAlignment.Center;
229
230                 this.footerMarginInput.Value = PrinterUnitToUIUnit(this.printDocument.PageSetupData.FooterMargin);
231             }
232             finally
233             {
234                 Cursor.Current = Cursors.Default;
235             }
236         }
237
238         protected override void Dispose(bool disposing)
239         {
240             if (disposing)
241             {
242                 if (components != null)
243                     components.Dispose();
244             }
245
246             base.Dispose(disposing);
247         }
248         #endregion
249
250         #region Windows Form Designer generated code
251         /// <summary>
252         /// Required method for Designer support - do not modify
253         /// the contents of this method with the code editor.
254         /// </summary>
255         private void InitializeComponent()
256         {
257             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WorkflowPageSetupDialog));
258             this.tabs = new System.Windows.Forms.TabControl();
259             this.pageSettingsTab = new System.Windows.Forms.TabPage();
260             this.centerGroup = new System.Windows.Forms.GroupBox();
261             this.centerTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
262             this.CenterVerticallyCheckBox = new System.Windows.Forms.CheckBox();
263             this.CenterHorizontallyCheckBox = new System.Windows.Forms.CheckBox();
264             this.marginsGroup = new System.Windows.Forms.GroupBox();
265             this.marginsTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
266             this.marginsRightInput = new System.Windows.Forms.NumericUpDown();
267             this.marginsBottomInput = new System.Windows.Forms.NumericUpDown();
268             this.marginsTopLabel = new System.Windows.Forms.Label();
269             this.marginsLeftLabel = new System.Windows.Forms.Label();
270             this.marginsRightLabel = new System.Windows.Forms.Label();
271             this.marginsBottomLabel = new System.Windows.Forms.Label();
272             this.marginsTopInput = new System.Windows.Forms.NumericUpDown();
273             this.marginsLeftInput = new System.Windows.Forms.NumericUpDown();
274             this.scalingGroup = new System.Windows.Forms.GroupBox();
275             this.scalingTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
276             this.fitToTallLabel = new System.Windows.Forms.Label();
277             this.scalingOfSizeLabel = new System.Windows.Forms.Label();
278             this.fitToWideLabel = new System.Windows.Forms.Label();
279             this.adjustToRadioButton = new System.Windows.Forms.RadioButton();
280             this.fitToPagesTallInput = new System.Windows.Forms.NumericUpDown();
281             this.fitToPagesWideInput = new System.Windows.Forms.NumericUpDown();
282             this.adjustToScaleInput = new System.Windows.Forms.NumericUpDown();
283             this.fitToRadioButton = new System.Windows.Forms.RadioButton();
284             this.orientationGroup = new System.Windows.Forms.GroupBox();
285             this.orientationTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
286             this.landscapeRadioButton = new System.Windows.Forms.RadioButton();
287             this.landscapePicture = new System.Windows.Forms.PictureBox();
288             this.portraitRadioButton = new System.Windows.Forms.RadioButton();
289             this.portraitPicture = new System.Windows.Forms.PictureBox();
290             this.paperSettingsGroup = new System.Windows.Forms.GroupBox();
291             this.paperTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
292             this.paperSourceComboBox = new System.Windows.Forms.ComboBox();
293             this.paperSizeComboBox = new System.Windows.Forms.ComboBox();
294             this.paperSizeLabel = new System.Windows.Forms.Label();
295             this.paperSourceLabel = new System.Windows.Forms.Label();
296             this.headerFooterTab = new System.Windows.Forms.TabPage();
297             this.footerGroup = new System.Windows.Forms.GroupBox();
298             this.footerTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
299             this.footerTextLabel = new System.Windows.Forms.Label();
300             this.footerAlignmentLabel = new System.Windows.Forms.Label();
301             this.footerMarginUnitsLabel = new System.Windows.Forms.Label();
302             this.footerMarginLabel = new System.Windows.Forms.Label();
303             this.footerMarginInput = new System.Windows.Forms.NumericUpDown();
304             this.footerTextComboBox = new System.Windows.Forms.ComboBox();
305             this.footerAlignmentComboBox = new System.Windows.Forms.ComboBox();
306             this.customFooterText = new System.Windows.Forms.TextBox();
307             this.customFooterLabel = new System.Windows.Forms.Label();
308             this.headerGroup = new System.Windows.Forms.GroupBox();
309             this.headerTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
310             this.headerTextLabel = new System.Windows.Forms.Label();
311             this.headerAlignmentLabel = new System.Windows.Forms.Label();
312             this.headerMarginUnitsLabel = new System.Windows.Forms.Label();
313             this.headerMarginLabel = new System.Windows.Forms.Label();
314             this.headerMarginInput = new System.Windows.Forms.NumericUpDown();
315             this.headerTextComboBox = new System.Windows.Forms.ComboBox();
316             this.headerAlignmentComboBox = new System.Windows.Forms.ComboBox();
317             this.customHeaderText = new System.Windows.Forms.TextBox();
318             this.customHeaderLabel = new System.Windows.Forms.Label();
319             this.OKButton = new System.Windows.Forms.Button();
320             this.cancelButton = new System.Windows.Forms.Button();
321             this.printerButton = new System.Windows.Forms.Button();
322             this.okCancelTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
323             this.tabs.SuspendLayout();
324             this.pageSettingsTab.SuspendLayout();
325             this.centerGroup.SuspendLayout();
326             this.centerTableLayoutPanel.SuspendLayout();
327             this.marginsGroup.SuspendLayout();
328             this.marginsTableLayoutPanel.SuspendLayout();
329             ((System.ComponentModel.ISupportInitialize)(this.marginsRightInput)).BeginInit();
330             ((System.ComponentModel.ISupportInitialize)(this.marginsBottomInput)).BeginInit();
331             ((System.ComponentModel.ISupportInitialize)(this.marginsTopInput)).BeginInit();
332             ((System.ComponentModel.ISupportInitialize)(this.marginsLeftInput)).BeginInit();
333             this.scalingGroup.SuspendLayout();
334             this.scalingTableLayoutPanel.SuspendLayout();
335             ((System.ComponentModel.ISupportInitialize)(this.fitToPagesTallInput)).BeginInit();
336             ((System.ComponentModel.ISupportInitialize)(this.fitToPagesWideInput)).BeginInit();
337             ((System.ComponentModel.ISupportInitialize)(this.adjustToScaleInput)).BeginInit();
338             this.orientationGroup.SuspendLayout();
339             this.orientationTableLayoutPanel.SuspendLayout();
340             ((System.ComponentModel.ISupportInitialize)(this.landscapePicture)).BeginInit();
341             ((System.ComponentModel.ISupportInitialize)(this.portraitPicture)).BeginInit();
342             this.paperSettingsGroup.SuspendLayout();
343             this.paperTableLayoutPanel.SuspendLayout();
344             this.headerFooterTab.SuspendLayout();
345             this.footerGroup.SuspendLayout();
346             this.footerTableLayoutPanel.SuspendLayout();
347             ((System.ComponentModel.ISupportInitialize)(this.footerMarginInput)).BeginInit();
348             this.headerGroup.SuspendLayout();
349             this.headerTableLayoutPanel.SuspendLayout();
350             ((System.ComponentModel.ISupportInitialize)(this.headerMarginInput)).BeginInit();
351             this.okCancelTableLayoutPanel.SuspendLayout();
352             this.SuspendLayout();
353             // 
354             // tabs
355             // 
356             resources.ApplyResources(this.tabs, "tabs");
357             this.tabs.Controls.Add(this.pageSettingsTab);
358             this.tabs.Controls.Add(this.headerFooterTab);
359             this.tabs.Name = "tabs";
360             this.tabs.SelectedIndex = 0;
361             // 
362             // pageSettingsTab
363             // 
364             this.pageSettingsTab.Controls.Add(this.centerGroup);
365             this.pageSettingsTab.Controls.Add(this.marginsGroup);
366             this.pageSettingsTab.Controls.Add(this.scalingGroup);
367             this.pageSettingsTab.Controls.Add(this.orientationGroup);
368             this.pageSettingsTab.Controls.Add(this.paperSettingsGroup);
369             resources.ApplyResources(this.pageSettingsTab, "pageSettingsTab");
370             this.pageSettingsTab.Name = "pageSettingsTab";
371             // 
372             // centerGroup
373             // 
374             resources.ApplyResources(this.centerGroup, "centerGroup");
375             this.centerGroup.Controls.Add(this.centerTableLayoutPanel);
376             this.centerGroup.Name = "centerGroup";
377             this.centerGroup.TabStop = false;
378             // 
379             // centerTableLayoutPanel
380             // 
381             resources.ApplyResources(this.centerTableLayoutPanel, "centerTableLayoutPanel");
382             this.centerTableLayoutPanel.Controls.Add(this.CenterVerticallyCheckBox, 1, 0);
383             this.centerTableLayoutPanel.Controls.Add(this.CenterHorizontallyCheckBox, 0, 0);
384             this.centerTableLayoutPanel.Name = "centerTableLayoutPanel";
385             // 
386             // CenterVerticallyCheckBox
387             // 
388             resources.ApplyResources(this.CenterVerticallyCheckBox, "CenterVerticallyCheckBox");
389             this.CenterVerticallyCheckBox.Name = "CenterVerticallyCheckBox";
390             // 
391             // CenterHorizontallyCheckBox
392             // 
393             resources.ApplyResources(this.CenterHorizontallyCheckBox, "CenterHorizontallyCheckBox");
394             this.CenterHorizontallyCheckBox.Name = "CenterHorizontallyCheckBox";
395             // 
396             // marginsGroup
397             // 
398             resources.ApplyResources(this.marginsGroup, "marginsGroup");
399             this.marginsGroup.Controls.Add(this.marginsTableLayoutPanel);
400             this.marginsGroup.Name = "marginsGroup";
401             this.marginsGroup.TabStop = false;
402             // 
403             // marginsTableLayoutPanel
404             // 
405             resources.ApplyResources(this.marginsTableLayoutPanel, "marginsTableLayoutPanel");
406             this.marginsTableLayoutPanel.Controls.Add(this.marginsRightInput, 3, 1);
407             this.marginsTableLayoutPanel.Controls.Add(this.marginsBottomInput, 3, 0);
408             this.marginsTableLayoutPanel.Controls.Add(this.marginsTopLabel, 0, 0);
409             this.marginsTableLayoutPanel.Controls.Add(this.marginsLeftLabel, 0, 1);
410             this.marginsTableLayoutPanel.Controls.Add(this.marginsRightLabel, 2, 1);
411             this.marginsTableLayoutPanel.Controls.Add(this.marginsBottomLabel, 2, 0);
412             this.marginsTableLayoutPanel.Controls.Add(this.marginsTopInput, 1, 0);
413             this.marginsTableLayoutPanel.Controls.Add(this.marginsLeftInput, 1, 1);
414             this.marginsTableLayoutPanel.Name = "marginsTableLayoutPanel";
415             // 
416             // marginsRightInput
417             // 
418             resources.ApplyResources(this.marginsRightInput, "marginsRightInput");
419             this.marginsRightInput.DecimalPlaces = 2;
420             this.marginsRightInput.Increment = new decimal(new int[] {
421             1,
422             0,
423             0,
424             131072});
425             this.marginsRightInput.Name = "marginsRightInput";
426             this.marginsRightInput.Value = new decimal(new int[] {
427             100,
428             0,
429             0,
430             131072});
431             this.marginsRightInput.Validating += new System.ComponentModel.CancelEventHandler(this.Margins_Validating);
432             // 
433             // marginsBottomInput
434             // 
435             resources.ApplyResources(this.marginsBottomInput, "marginsBottomInput");
436             this.marginsBottomInput.DecimalPlaces = 2;
437             this.marginsBottomInput.Increment = new decimal(new int[] {
438             1,
439             0,
440             0,
441             131072});
442             this.marginsBottomInput.Name = "marginsBottomInput";
443             this.marginsBottomInput.Value = new decimal(new int[] {
444             100,
445             0,
446             0,
447             131072});
448             this.marginsBottomInput.Validating += new System.ComponentModel.CancelEventHandler(this.Margins_Validating);
449             // 
450             // marginsTopLabel
451             // 
452             resources.ApplyResources(this.marginsTopLabel, "marginsTopLabel");
453             this.marginsTopLabel.Name = "marginsTopLabel";
454             // 
455             // marginsLeftLabel
456             // 
457             resources.ApplyResources(this.marginsLeftLabel, "marginsLeftLabel");
458             this.marginsLeftLabel.Name = "marginsLeftLabel";
459             // 
460             // marginsRightLabel
461             // 
462             resources.ApplyResources(this.marginsRightLabel, "marginsRightLabel");
463             this.marginsRightLabel.Name = "marginsRightLabel";
464             // 
465             // marginsBottomLabel
466             // 
467             resources.ApplyResources(this.marginsBottomLabel, "marginsBottomLabel");
468             this.marginsBottomLabel.Name = "marginsBottomLabel";
469             // 
470             // marginsTopInput
471             // 
472             resources.ApplyResources(this.marginsTopInput, "marginsTopInput");
473             this.marginsTopInput.DecimalPlaces = 2;
474             this.marginsTopInput.Increment = new decimal(new int[] {
475             1,
476             0,
477             0,
478             131072});
479             this.marginsTopInput.Name = "marginsTopInput";
480             this.marginsTopInput.Value = new decimal(new int[] {
481             100,
482             0,
483             0,
484             131072});
485             this.marginsTopInput.Validating += new System.ComponentModel.CancelEventHandler(this.Margins_Validating);
486             // 
487             // marginsLeftInput
488             // 
489             resources.ApplyResources(this.marginsLeftInput, "marginsLeftInput");
490             this.marginsLeftInput.DecimalPlaces = 2;
491             this.marginsLeftInput.Increment = new decimal(new int[] {
492             1,
493             0,
494             0,
495             131072});
496             this.marginsLeftInput.Name = "marginsLeftInput";
497             this.marginsLeftInput.Value = new decimal(new int[] {
498             100,
499             0,
500             0,
501             131072});
502             this.marginsLeftInput.Validating += new System.ComponentModel.CancelEventHandler(this.Margins_Validating);
503             // 
504             // scalingGroup
505             // 
506             resources.ApplyResources(this.scalingGroup, "scalingGroup");
507             this.scalingGroup.Controls.Add(this.scalingTableLayoutPanel);
508             this.scalingGroup.Name = "scalingGroup";
509             this.scalingGroup.TabStop = false;
510             // 
511             // scalingTableLayoutPanel
512             // 
513             resources.ApplyResources(this.scalingTableLayoutPanel, "scalingTableLayoutPanel");
514             this.scalingTableLayoutPanel.Controls.Add(this.fitToTallLabel, 2, 2);
515             this.scalingTableLayoutPanel.Controls.Add(this.scalingOfSizeLabel, 2, 0);
516             this.scalingTableLayoutPanel.Controls.Add(this.fitToWideLabel, 2, 1);
517             this.scalingTableLayoutPanel.Controls.Add(this.adjustToRadioButton, 0, 0);
518             this.scalingTableLayoutPanel.Controls.Add(this.fitToPagesTallInput, 1, 2);
519             this.scalingTableLayoutPanel.Controls.Add(this.fitToPagesWideInput, 1, 1);
520             this.scalingTableLayoutPanel.Controls.Add(this.adjustToScaleInput, 1, 0);
521             this.scalingTableLayoutPanel.Controls.Add(this.fitToRadioButton, 0, 1);
522             this.scalingTableLayoutPanel.Name = "scalingTableLayoutPanel";
523             // 
524             // fitToTallLabel
525             // 
526             resources.ApplyResources(this.fitToTallLabel, "fitToTallLabel");
527             this.fitToTallLabel.Name = "fitToTallLabel";
528             // 
529             // scalingOfSizeLabel
530             // 
531             resources.ApplyResources(this.scalingOfSizeLabel, "scalingOfSizeLabel");
532             this.scalingOfSizeLabel.Name = "scalingOfSizeLabel";
533             // 
534             // fitToWideLabel
535             // 
536             resources.ApplyResources(this.fitToWideLabel, "fitToWideLabel");
537             this.fitToWideLabel.Name = "fitToWideLabel";
538             // 
539             // adjustToRadioButton
540             // 
541             resources.ApplyResources(this.adjustToRadioButton, "adjustToRadioButton");
542             this.adjustToRadioButton.Name = "adjustToRadioButton";
543             // 
544             // fitToPagesTallInput
545             // 
546             resources.ApplyResources(this.fitToPagesTallInput, "fitToPagesTallInput");
547             this.fitToPagesTallInput.Maximum = new decimal(new int[] {
548             20,
549             0,
550             0,
551             0});
552             this.fitToPagesTallInput.Minimum = new decimal(new int[] {
553             1,
554             0,
555             0,
556             0});
557             this.fitToPagesTallInput.Name = "fitToPagesTallInput";
558             this.fitToPagesTallInput.Value = new decimal(new int[] {
559             1,
560             0,
561             0,
562             0});
563             this.fitToPagesTallInput.ValueChanged += new System.EventHandler(this.fitToInputs_ValueChanged);
564             // 
565             // fitToPagesWideInput
566             // 
567             resources.ApplyResources(this.fitToPagesWideInput, "fitToPagesWideInput");
568             this.fitToPagesWideInput.Maximum = new decimal(new int[] {
569             20,
570             0,
571             0,
572             0});
573             this.fitToPagesWideInput.Minimum = new decimal(new int[] {
574             1,
575             0,
576             0,
577             0});
578             this.fitToPagesWideInput.Name = "fitToPagesWideInput";
579             this.fitToPagesWideInput.Value = new decimal(new int[] {
580             1,
581             0,
582             0,
583             0});
584             this.fitToPagesWideInput.ValueChanged += new System.EventHandler(this.fitToInputs_ValueChanged);
585             // 
586             // adjustToScaleInput
587             // 
588             resources.ApplyResources(this.adjustToScaleInput, "adjustToScaleInput");
589             this.adjustToScaleInput.Maximum = new decimal(new int[] {
590             400,
591             0,
592             0,
593             0});
594             this.adjustToScaleInput.Minimum = new decimal(new int[] {
595             10,
596             0,
597             0,
598             0});
599             this.adjustToScaleInput.Name = "adjustToScaleInput";
600             this.adjustToScaleInput.Value = new decimal(new int[] {
601             100,
602             0,
603             0,
604             0});
605             this.adjustToScaleInput.ValueChanged += new System.EventHandler(this.adjustToInput_ValueChanged);
606             // 
607             // fitToRadioButton
608             // 
609             resources.ApplyResources(this.fitToRadioButton, "fitToRadioButton");
610             this.fitToRadioButton.Name = "fitToRadioButton";
611             // 
612             // orientationGroup
613             // 
614             resources.ApplyResources(this.orientationGroup, "orientationGroup");
615             this.orientationGroup.Controls.Add(this.orientationTableLayoutPanel);
616             this.orientationGroup.Name = "orientationGroup";
617             this.orientationGroup.TabStop = false;
618             // 
619             // orientationTableLayoutPanel
620             // 
621             resources.ApplyResources(this.orientationTableLayoutPanel, "orientationTableLayoutPanel");
622             this.orientationTableLayoutPanel.Controls.Add(this.landscapeRadioButton, 3, 0);
623             this.orientationTableLayoutPanel.Controls.Add(this.landscapePicture, 2, 0);
624             this.orientationTableLayoutPanel.Controls.Add(this.portraitRadioButton, 1, 0);
625             this.orientationTableLayoutPanel.Controls.Add(this.portraitPicture, 0, 0);
626             this.orientationTableLayoutPanel.Name = "orientationTableLayoutPanel";
627             // 
628             // landscapeRadioButton
629             // 
630             resources.ApplyResources(this.landscapeRadioButton, "landscapeRadioButton");
631             this.landscapeRadioButton.Name = "landscapeRadioButton";
632             this.landscapeRadioButton.CheckedChanged += new System.EventHandler(this.landscapeRadioButton_CheckedChanged);
633             // 
634             // landscapePicture
635             // 
636             resources.ApplyResources(this.landscapePicture, "landscapePicture");
637             this.landscapePicture.Name = "landscapePicture";
638             this.landscapePicture.TabStop = false;
639             // 
640             // portraitRadioButton
641             // 
642             resources.ApplyResources(this.portraitRadioButton, "portraitRadioButton");
643             this.portraitRadioButton.Name = "portraitRadioButton";
644             this.portraitRadioButton.CheckedChanged += new System.EventHandler(this.portraitRadioButton_CheckedChanged);
645             // 
646             // portraitPicture
647             // 
648             resources.ApplyResources(this.portraitPicture, "portraitPicture");
649             this.portraitPicture.Name = "portraitPicture";
650             this.portraitPicture.TabStop = false;
651             // 
652             // paperSettingsGroup
653             // 
654             resources.ApplyResources(this.paperSettingsGroup, "paperSettingsGroup");
655             this.paperSettingsGroup.Controls.Add(this.paperTableLayoutPanel);
656             this.paperSettingsGroup.Name = "paperSettingsGroup";
657             this.paperSettingsGroup.TabStop = false;
658             // 
659             // paperTableLayoutPanel
660             // 
661             resources.ApplyResources(this.paperTableLayoutPanel, "paperTableLayoutPanel");
662             this.paperTableLayoutPanel.Controls.Add(this.paperSourceComboBox, 1, 1);
663             this.paperTableLayoutPanel.Controls.Add(this.paperSizeComboBox, 1, 0);
664             this.paperTableLayoutPanel.Controls.Add(this.paperSizeLabel, 0, 0);
665             this.paperTableLayoutPanel.Controls.Add(this.paperSourceLabel, 0, 1);
666             this.paperTableLayoutPanel.Name = "paperTableLayoutPanel";
667             // 
668             // paperSourceComboBox
669             // 
670             resources.ApplyResources(this.paperSourceComboBox, "paperSourceComboBox");
671             this.paperSourceComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
672             this.paperSourceComboBox.FormattingEnabled = true;
673             this.paperSourceComboBox.Name = "paperSourceComboBox";
674             // 
675             // paperSizeComboBox
676             // 
677             resources.ApplyResources(this.paperSizeComboBox, "paperSizeComboBox");
678             this.paperSizeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
679             this.paperSizeComboBox.FormattingEnabled = true;
680             this.paperSizeComboBox.Name = "paperSizeComboBox";
681             this.paperSizeComboBox.SelectedIndexChanged += new System.EventHandler(this.paperSizeComboBox_SelectedIndexChanged);
682             // 
683             // paperSizeLabel
684             // 
685             resources.ApplyResources(this.paperSizeLabel, "paperSizeLabel");
686             this.paperSizeLabel.Name = "paperSizeLabel";
687             // 
688             // paperSourceLabel
689             // 
690             resources.ApplyResources(this.paperSourceLabel, "paperSourceLabel");
691             this.paperSourceLabel.Name = "paperSourceLabel";
692             // 
693             // headerFooterTab
694             // 
695             this.headerFooterTab.Controls.Add(this.footerGroup);
696             this.headerFooterTab.Controls.Add(this.headerGroup);
697             resources.ApplyResources(this.headerFooterTab, "headerFooterTab");
698             this.headerFooterTab.Name = "headerFooterTab";
699             // 
700             // footerGroup
701             // 
702             resources.ApplyResources(this.footerGroup, "footerGroup");
703             this.footerGroup.Controls.Add(this.footerTableLayoutPanel);
704             this.footerGroup.Controls.Add(this.customFooterText);
705             this.footerGroup.Controls.Add(this.customFooterLabel);
706             this.footerGroup.Name = "footerGroup";
707             this.footerGroup.TabStop = false;
708             // 
709             // footerTableLayoutPanel
710             // 
711             resources.ApplyResources(this.footerTableLayoutPanel, "footerTableLayoutPanel");
712             this.footerTableLayoutPanel.Controls.Add(this.footerTextLabel, 0, 0);
713             this.footerTableLayoutPanel.Controls.Add(this.footerAlignmentLabel, 0, 1);
714             this.footerTableLayoutPanel.Controls.Add(this.footerMarginUnitsLabel, 2, 2);
715             this.footerTableLayoutPanel.Controls.Add(this.footerMarginLabel, 0, 2);
716             this.footerTableLayoutPanel.Controls.Add(this.footerMarginInput, 1, 2);
717             this.footerTableLayoutPanel.Controls.Add(this.footerTextComboBox, 1, 0);
718             this.footerTableLayoutPanel.Controls.Add(this.footerAlignmentComboBox, 1, 1);
719             this.footerTableLayoutPanel.Name = "footerTableLayoutPanel";
720             // 
721             // footerTextLabel
722             // 
723             resources.ApplyResources(this.footerTextLabel, "footerTextLabel");
724             this.footerTextLabel.Name = "footerTextLabel";
725             // 
726             // footerAlignmentLabel
727             // 
728             resources.ApplyResources(this.footerAlignmentLabel, "footerAlignmentLabel");
729             this.footerAlignmentLabel.Name = "footerAlignmentLabel";
730             // 
731             // footerMarginUnitsLabel
732             // 
733             resources.ApplyResources(this.footerMarginUnitsLabel, "footerMarginUnitsLabel");
734             this.footerMarginUnitsLabel.Name = "footerMarginUnitsLabel";
735             // 
736             // footerMarginLabel
737             // 
738             resources.ApplyResources(this.footerMarginLabel, "footerMarginLabel");
739             this.footerMarginLabel.Name = "footerMarginLabel";
740             // 
741             // footerMarginInput
742             // 
743             resources.ApplyResources(this.footerMarginInput, "footerMarginInput");
744             this.footerMarginInput.DecimalPlaces = 2;
745             this.footerMarginInput.Increment = new decimal(new int[] {
746             1,
747             0,
748             0,
749             131072});
750             this.footerMarginInput.Name = "footerMarginInput";
751             this.footerMarginInput.Value = new decimal(new int[] {
752             1,
753             0,
754             0,
755             0});
756             this.footerMarginInput.Validating += new System.ComponentModel.CancelEventHandler(this.footerMarginInput_Validating);
757             // 
758             // footerTextComboBox
759             // 
760             resources.ApplyResources(this.footerTextComboBox, "footerTextComboBox");
761             this.footerTableLayoutPanel.SetColumnSpan(this.footerTextComboBox, 2);
762             this.footerTextComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
763             this.footerTextComboBox.FormattingEnabled = true;
764             this.footerTextComboBox.Name = "footerTextComboBox";
765             this.footerTextComboBox.SelectedIndexChanged += new System.EventHandler(this.footerTextComboBox_SelectedIndexChanged);
766             // 
767             // footerAlignmentComboBox
768             // 
769             resources.ApplyResources(this.footerAlignmentComboBox, "footerAlignmentComboBox");
770             this.footerTableLayoutPanel.SetColumnSpan(this.footerAlignmentComboBox, 2);
771             this.footerAlignmentComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
772             this.footerAlignmentComboBox.FormattingEnabled = true;
773             this.footerAlignmentComboBox.Name = "footerAlignmentComboBox";
774             // 
775             // customFooterText
776             // 
777             resources.ApplyResources(this.customFooterText, "customFooterText");
778             this.customFooterText.Name = "customFooterText";
779             // 
780             // customFooterLabel
781             // 
782             resources.ApplyResources(this.customFooterLabel, "customFooterLabel");
783             this.customFooterLabel.Name = "customFooterLabel";
784             // 
785             // headerGroup
786             // 
787             resources.ApplyResources(this.headerGroup, "headerGroup");
788             this.headerGroup.Controls.Add(this.headerTableLayoutPanel);
789             this.headerGroup.Controls.Add(this.customHeaderText);
790             this.headerGroup.Controls.Add(this.customHeaderLabel);
791             this.headerGroup.Name = "headerGroup";
792             this.headerGroup.TabStop = false;
793             // 
794             // headerTableLayoutPanel
795             // 
796             resources.ApplyResources(this.headerTableLayoutPanel, "headerTableLayoutPanel");
797             this.headerTableLayoutPanel.Controls.Add(this.headerTextLabel, 0, 0);
798             this.headerTableLayoutPanel.Controls.Add(this.headerAlignmentLabel, 0, 1);
799             this.headerTableLayoutPanel.Controls.Add(this.headerMarginUnitsLabel, 2, 2);
800             this.headerTableLayoutPanel.Controls.Add(this.headerMarginLabel, 0, 2);
801             this.headerTableLayoutPanel.Controls.Add(this.headerMarginInput, 1, 2);
802             this.headerTableLayoutPanel.Controls.Add(this.headerTextComboBox, 1, 0);
803             this.headerTableLayoutPanel.Controls.Add(this.headerAlignmentComboBox, 1, 1);
804             this.headerTableLayoutPanel.Name = "headerTableLayoutPanel";
805             // 
806             // headerTextLabel
807             // 
808             resources.ApplyResources(this.headerTextLabel, "headerTextLabel");
809             this.headerTextLabel.Name = "headerTextLabel";
810             // 
811             // headerAlignmentLabel
812             // 
813             resources.ApplyResources(this.headerAlignmentLabel, "headerAlignmentLabel");
814             this.headerAlignmentLabel.Cursor = System.Windows.Forms.Cursors.Arrow;
815             this.headerAlignmentLabel.Name = "headerAlignmentLabel";
816             // 
817             // headerMarginUnitsLabel
818             // 
819             resources.ApplyResources(this.headerMarginUnitsLabel, "headerMarginUnitsLabel");
820             this.headerMarginUnitsLabel.Name = "headerMarginUnitsLabel";
821             // 
822             // headerMarginLabel
823             // 
824             resources.ApplyResources(this.headerMarginLabel, "headerMarginLabel");
825             this.headerMarginLabel.Name = "headerMarginLabel";
826             // 
827             // headerMarginInput
828             // 
829             resources.ApplyResources(this.headerMarginInput, "headerMarginInput");
830             this.headerMarginInput.DecimalPlaces = 2;
831             this.headerMarginInput.Increment = new decimal(new int[] {
832             1,
833             0,
834             0,
835             131072});
836             this.headerMarginInput.Name = "headerMarginInput";
837             this.headerMarginInput.Value = new decimal(new int[] {
838             1,
839             0,
840             0,
841             0});
842             this.headerMarginInput.Validating += new System.ComponentModel.CancelEventHandler(this.headerMarginInput_Validating);
843             // 
844             // headerTextComboBox
845             // 
846             resources.ApplyResources(this.headerTextComboBox, "headerTextComboBox");
847             this.headerTableLayoutPanel.SetColumnSpan(this.headerTextComboBox, 2);
848             this.headerTextComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
849             this.headerTextComboBox.FormattingEnabled = true;
850             this.headerTextComboBox.Name = "headerTextComboBox";
851             this.headerTextComboBox.SelectedIndexChanged += new System.EventHandler(this.headerTextComboBox_SelectedIndexChanged);
852             // 
853             // headerAlignmentComboBox
854             // 
855             resources.ApplyResources(this.headerAlignmentComboBox, "headerAlignmentComboBox");
856             this.headerTableLayoutPanel.SetColumnSpan(this.headerAlignmentComboBox, 2);
857             this.headerAlignmentComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
858             this.headerAlignmentComboBox.FormattingEnabled = true;
859             this.headerAlignmentComboBox.Name = "headerAlignmentComboBox";
860             // 
861             // customHeaderText
862             // 
863             resources.ApplyResources(this.customHeaderText, "customHeaderText");
864             this.customHeaderText.Name = "customHeaderText";
865             // 
866             // customHeaderLabel
867             // 
868             resources.ApplyResources(this.customHeaderLabel, "customHeaderLabel");
869             this.customHeaderLabel.Name = "customHeaderLabel";
870             // 
871             // OKButton
872             // 
873             resources.ApplyResources(this.OKButton, "OKButton");
874             this.OKButton.DialogResult = System.Windows.Forms.DialogResult.OK;
875             this.OKButton.Name = "OKButton";
876             this.OKButton.Click += new System.EventHandler(this.OKButton_Click);
877             // 
878             // cancelButton
879             // 
880             resources.ApplyResources(this.cancelButton, "cancelButton");
881             this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
882             this.cancelButton.Name = "cancelButton";
883             // 
884             // printerButton
885             // 
886             resources.ApplyResources(this.printerButton, "printerButton");
887             this.printerButton.Name = "printerButton";
888             this.printerButton.Click += new System.EventHandler(this.printerButton_Click);
889             // 
890             // okCancelTableLayoutPanel
891             // 
892             resources.ApplyResources(this.okCancelTableLayoutPanel, "okCancelTableLayoutPanel");
893             this.okCancelTableLayoutPanel.Controls.Add(this.OKButton, 0, 0);
894             this.okCancelTableLayoutPanel.Controls.Add(this.cancelButton, 1, 0);
895             this.okCancelTableLayoutPanel.Controls.Add(this.printerButton, 2, 0);
896             this.okCancelTableLayoutPanel.Name = "okCancelTableLayoutPanel";
897             // 
898             // WorkflowPageSetupDialog
899             // 
900             this.AcceptButton = this.OKButton;
901             resources.ApplyResources(this, "$this");
902             this.CancelButton = this.cancelButton;
903             this.Controls.Add(this.okCancelTableLayoutPanel);
904             this.Controls.Add(this.tabs);
905             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
906             this.HelpButton = true;
907             this.MaximizeBox = false;
908             this.MinimizeBox = false;
909             this.Name = "WorkflowPageSetupDialog";
910             this.ShowInTaskbar = false;
911             this.HelpButtonClicked += new System.ComponentModel.CancelEventHandler(this.WorkflowPageSetupDialog_HelpButtonClicked);
912             this.tabs.ResumeLayout(false);
913             this.pageSettingsTab.ResumeLayout(false);
914             this.centerGroup.ResumeLayout(false);
915             this.centerTableLayoutPanel.ResumeLayout(false);
916             this.centerTableLayoutPanel.PerformLayout();
917             this.marginsGroup.ResumeLayout(false);
918             this.marginsTableLayoutPanel.ResumeLayout(false);
919             this.marginsTableLayoutPanel.PerformLayout();
920             ((System.ComponentModel.ISupportInitialize)(this.marginsRightInput)).EndInit();
921             ((System.ComponentModel.ISupportInitialize)(this.marginsBottomInput)).EndInit();
922             ((System.ComponentModel.ISupportInitialize)(this.marginsTopInput)).EndInit();
923             ((System.ComponentModel.ISupportInitialize)(this.marginsLeftInput)).EndInit();
924             this.scalingGroup.ResumeLayout(false);
925             this.scalingTableLayoutPanel.ResumeLayout(false);
926             this.scalingTableLayoutPanel.PerformLayout();
927             ((System.ComponentModel.ISupportInitialize)(this.fitToPagesTallInput)).EndInit();
928             ((System.ComponentModel.ISupportInitialize)(this.fitToPagesWideInput)).EndInit();
929             ((System.ComponentModel.ISupportInitialize)(this.adjustToScaleInput)).EndInit();
930             this.orientationGroup.ResumeLayout(false);
931             this.orientationTableLayoutPanel.ResumeLayout(false);
932             this.orientationTableLayoutPanel.PerformLayout();
933             ((System.ComponentModel.ISupportInitialize)(this.landscapePicture)).EndInit();
934             ((System.ComponentModel.ISupportInitialize)(this.portraitPicture)).EndInit();
935             this.paperSettingsGroup.ResumeLayout(false);
936             this.paperTableLayoutPanel.ResumeLayout(false);
937             this.paperTableLayoutPanel.PerformLayout();
938             this.headerFooterTab.ResumeLayout(false);
939             this.footerGroup.ResumeLayout(false);
940             this.footerGroup.PerformLayout();
941             this.footerTableLayoutPanel.ResumeLayout(false);
942             this.footerTableLayoutPanel.PerformLayout();
943             ((System.ComponentModel.ISupportInitialize)(this.footerMarginInput)).EndInit();
944             this.headerGroup.ResumeLayout(false);
945             this.headerGroup.PerformLayout();
946             this.headerTableLayoutPanel.ResumeLayout(false);
947             this.headerTableLayoutPanel.PerformLayout();
948             ((System.ComponentModel.ISupportInitialize)(this.headerMarginInput)).EndInit();
949             this.okCancelTableLayoutPanel.ResumeLayout(false);
950             this.okCancelTableLayoutPanel.PerformLayout();
951             this.ResumeLayout(false);
952             this.PerformLayout();
953
954         }
955         #endregion
956
957         #region Events
958         private void OKButton_Click(object sender, System.EventArgs e)
959         {
960             //serialize state of the dialog into the pageSetupData object
961             Margins margins = GetMarginsFromUI();
962
963             //scaling
964             this.printDocument.PageSetupData.AdjustToScaleFactor = this.adjustToRadioButton.Checked;
965
966             this.printDocument.PageSetupData.ScaleFactor = (int)this.adjustToScaleInput.Value;
967             this.printDocument.PageSetupData.PagesWide = (int)this.fitToPagesWideInput.Value;
968             this.printDocument.PageSetupData.PagesTall = (int)this.fitToPagesTallInput.Value;
969
970             //Set the orientation
971             this.printDocument.PageSetupData.Landscape = this.landscapeRadioButton.Checked;
972             this.printDocument.PageSetupData.Margins = margins;
973
974             //centering
975             this.printDocument.PageSetupData.CenterHorizontally = this.CenterHorizontallyCheckBox.Checked;
976             this.printDocument.PageSetupData.CenterVertically = this.CenterVerticallyCheckBox.Checked;
977
978             //header inputs
979             if (this.headerTextComboBox.SelectedIndex == 0)
980                 this.printDocument.PageSetupData.HeaderTemplate = string.Empty;
981             else
982                 if (!this.headerTextComboBox.Text.Equals(this.headerFooterCustom))
983                     this.printDocument.PageSetupData.HeaderTemplate = this.headerTextComboBox.Text;
984                 else
985                     this.printDocument.PageSetupData.HeaderTemplate = this.customHeaderText.Text;
986             this.printDocument.PageSetupData.HeaderCustom = this.headerCustom;
987             this.printDocument.PageSetupData.HeaderAlignment = (HorizontalAlignment)this.headerAlignmentComboBox.SelectedItem;
988             this.printDocument.PageSetupData.HeaderMargin = UIUnitToPrinterUnit(this.headerMarginInput.Value);
989
990             //footer inputs
991             if (this.footerTextComboBox.SelectedIndex == 0)
992                 this.printDocument.PageSetupData.FooterTemplate = string.Empty;
993             else
994                 if (!this.footerTextComboBox.Text.Equals(this.headerFooterCustom))
995                     this.printDocument.PageSetupData.FooterTemplate = this.footerTextComboBox.Text;
996                 else
997                     this.printDocument.PageSetupData.FooterTemplate = this.customFooterText.Text;
998             this.printDocument.PageSetupData.FooterCustom = this.footerCustom;
999             this.printDocument.PageSetupData.FooterAlignment = (HorizontalAlignment)this.footerAlignmentComboBox.SelectedItem;
1000             this.printDocument.PageSetupData.FooterMargin = UIUnitToPrinterUnit(this.footerMarginInput.Value);
1001
1002             // Set the paper size based upon the selection in the combo box.
1003             if (PrinterSettings.InstalledPrinters.Count > 0)
1004             {
1005                 if (this.paperSizeComboBox.SelectedItem != null)
1006                     this.printDocument.DefaultPageSettings.PaperSize = (PaperSize)this.paperSizeComboBox.SelectedItem;
1007
1008                 // Set the paper source based upon the selection in the combo box.
1009                 if (this.paperSourceComboBox.SelectedItem != null)
1010                     this.printDocument.DefaultPageSettings.PaperSource = (PaperSource)this.paperSourceComboBox.SelectedItem;
1011
1012                 this.printDocument.DefaultPageSettings.Landscape = this.printDocument.PageSetupData.Landscape;
1013                 this.printDocument.DefaultPageSettings.Margins = margins;
1014
1015                 //Make sure that printer setting are changed
1016                 this.printDocument.PrinterSettings.DefaultPageSettings.PaperSize = this.printDocument.DefaultPageSettings.PaperSize;
1017                 this.printDocument.PrinterSettings.DefaultPageSettings.PaperSource = this.printDocument.DefaultPageSettings.PaperSource;
1018                 this.printDocument.PrinterSettings.DefaultPageSettings.Landscape = this.printDocument.PageSetupData.Landscape;
1019                 this.printDocument.PrinterSettings.DefaultPageSettings.Margins = margins;
1020             }
1021
1022             this.printDocument.PageSetupData.StorePropertiesToRegistry();
1023             DialogResult = DialogResult.OK;
1024         }
1025
1026         private void printerButton_Click(object sender, System.EventArgs e)
1027         {
1028             PrintDialog printDialog = new System.Windows.Forms.PrintDialog();
1029
1030             printDialog.AllowPrintToFile = false;
1031             printDialog.Document = this.printDocument;
1032             try
1033             {
1034                 if (DialogResult.OK == printDialog.ShowDialog())
1035                 {
1036                     this.printDocument.PrinterSettings = printDialog.PrinterSettings;
1037                     this.printDocument.DefaultPageSettings = printDialog.Document.DefaultPageSettings;
1038
1039                     if (this.printDocument.DefaultPageSettings.Landscape)
1040                         this.landscapeRadioButton.Checked = true;
1041                     else
1042                         this.portraitRadioButton.Checked = true;
1043
1044                     InitializePaperInformation();
1045
1046                     this.printDocument.Print();
1047                 }
1048                 else
1049                 {
1050                     //todo: copy updated settings from the dialog to the print doc
1051                     //in the worst case it's a no-op, in case user clicked apply/cancel it's the only way to
1052                     //update the settings (see Winoe#3129 and VSWhidbey#403124 for more details)
1053                 }
1054             }
1055             catch (Exception exception)
1056             {
1057                 string errorString = DR.GetString(DR.SelectedPrinterIsInvalidErrorMessage);
1058                 errorString += "\n" + exception.Message;
1059                 DesignerHelpers.ShowError(this.serviceProvider, errorString);
1060             }
1061         }
1062
1063         private void Margins_Validating(object sender, System.ComponentModel.CancelEventArgs e)
1064         {
1065             Margins margins = GetMarginsFromUI();
1066
1067             //get the current paper size
1068             Size physicalPageSize;
1069             PaperSize paperSize = this.paperSizeComboBox.SelectedItem as PaperSize;
1070             if (null != paperSize)
1071                 physicalPageSize = new Size(paperSize.Width, paperSize.Height);
1072             else
1073                 physicalPageSize = this.printDocument.DefaultPageSettings.Bounds.Size;
1074
1075             //check the constrains
1076             int horizontalMarginsSum = margins.Left + margins.Right;
1077             int verticalMarginsSum = margins.Top + margins.Bottom;
1078
1079             if (horizontalMarginsSum < physicalPageSize.Width && verticalMarginsSum < physicalPageSize.Height)
1080                 return; //we are good
1081
1082             //cancelling the change - constrains are not satisfied
1083             string errorString = DR.GetString(DR.EnteredMarginsAreNotValidErrorMessage);
1084             DesignerHelpers.ShowError(this.serviceProvider, errorString);
1085             e.Cancel = true;
1086         }
1087
1088         private void headerTextComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
1089         {
1090             this.headerCustom = this.headerTextComboBox.Text.Equals(this.headerFooterCustom);
1091             this.customHeaderText.Enabled = this.headerCustom;
1092             if (!this.headerCustom)
1093                 this.customHeaderText.Text = this.headerTextComboBox.Text;
1094         }
1095         private void footerTextComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
1096         {
1097             this.footerCustom = this.footerTextComboBox.Text.Equals(this.headerFooterCustom);
1098             this.customFooterText.Enabled = this.footerCustom;
1099             if (!this.footerCustom)
1100                 this.customFooterText.Text = this.footerTextComboBox.Text;
1101         }
1102
1103         private void paperSizeComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
1104         {
1105             UpdateHeaderFooterMarginLimit();
1106         }
1107         private void landscapeRadioButton_CheckedChanged(object sender, System.EventArgs e)
1108         {
1109             UpdateHeaderFooterMarginLimit();
1110         }
1111         private void portraitRadioButton_CheckedChanged(object sender, System.EventArgs e)
1112         {
1113             UpdateHeaderFooterMarginLimit();
1114         }
1115
1116         private void UpdateHeaderFooterMarginLimit()
1117         {
1118             PaperSize paperSize = this.paperSizeComboBox.SelectedItem as PaperSize;
1119             if (paperSize != null)
1120                 this.footerMarginInput.Maximum = this.headerMarginInput.Maximum = PrinterUnitToUIUnit(this.landscapeRadioButton.Checked ? paperSize.Width : paperSize.Height);
1121         }
1122
1123
1124         private void headerMarginInput_Validating(object sender, System.ComponentModel.CancelEventArgs e)
1125         {
1126         }
1127         private void footerMarginInput_Validating(object sender, System.ComponentModel.CancelEventArgs e)
1128         {
1129         }
1130         private void adjustToInput_ValueChanged(object sender, System.EventArgs e)
1131         {
1132             this.adjustToRadioButton.Checked = true;
1133         }
1134         private void fitToInputs_ValueChanged(object sender, System.EventArgs e)
1135         {
1136             this.fitToRadioButton.Checked = true;
1137         }
1138         #endregion
1139
1140         #region Helpers
1141         private void InitializePaperInformation()
1142         {
1143             PrinterSettings.PaperSizeCollection paperSizeCollection = this.printDocument.PrinterSettings.PaperSizes;
1144             PrinterSettings.PaperSourceCollection paperSourceCollection = this.printDocument.PrinterSettings.PaperSources;
1145
1146             this.paperSizeComboBox.Items.Clear();
1147             this.paperSizeComboBox.DisplayMember = "PaperName";
1148             foreach (PaperSize paperSize in paperSizeCollection)
1149             {
1150                 if (paperSize.PaperName != null && paperSize.PaperName.Length > 0)
1151                 {
1152                     this.paperSizeComboBox.Items.Add(paperSize);
1153                     if (null == this.paperSizeComboBox.SelectedItem &&
1154                     this.printDocument.DefaultPageSettings.PaperSize.Kind == paperSize.Kind &&
1155                     this.printDocument.DefaultPageSettings.PaperSize.Width == paperSize.Width &&
1156                     this.printDocument.DefaultPageSettings.PaperSize.Height == paperSize.Height)
1157                     {
1158                         this.paperSizeComboBox.SelectedItem = paperSize;
1159                         this.printDocument.DefaultPageSettings.PaperSize = paperSize;
1160                     }
1161                 }
1162             }
1163
1164             if (null == this.paperSizeComboBox.SelectedItem)
1165             {
1166                 PaperKind paperKind = this.printDocument.DefaultPageSettings.PaperSize.Kind;
1167
1168                 this.printDocument.DefaultPageSettings = new PageSettings(this.printDocument.PrinterSettings);
1169                 foreach (PaperSize paperSize in this.paperSizeComboBox.Items)
1170                 {
1171                     if (null == this.paperSizeComboBox.SelectedItem &&
1172                     paperKind == paperSize.Kind &&
1173                     this.printDocument.DefaultPageSettings.PaperSize.Width == paperSize.Width &&
1174                     this.printDocument.DefaultPageSettings.PaperSize.Height == paperSize.Height)
1175                     {
1176                         this.paperSizeComboBox.SelectedItem = paperSize;
1177                         this.printDocument.DefaultPageSettings.PaperSize = paperSize;
1178                     }
1179                 }
1180
1181                 //We still did not find matching paper so not select first in the list
1182                 if (null == this.paperSizeComboBox.SelectedItem &&
1183                 this.paperSizeComboBox.Items.Count > 0)
1184                 {
1185                     this.paperSizeComboBox.SelectedItem = this.paperSizeComboBox.Items[0] as PaperSize;
1186                     this.printDocument.DefaultPageSettings.PaperSize = this.paperSizeComboBox.SelectedItem as PaperSize;
1187                 }
1188             }
1189
1190             ///////////////Select the appropriate paper source based on the pageSettings
1191             this.paperSourceComboBox.Items.Clear();
1192             this.paperSourceComboBox.DisplayMember = "SourceName";
1193             foreach (PaperSource paperSource in paperSourceCollection)
1194             {
1195                 this.paperSourceComboBox.Items.Add(paperSource);
1196                 if (null == this.paperSourceComboBox.SelectedItem &&
1197                 this.printDocument.DefaultPageSettings.PaperSource.Kind == paperSource.Kind &&
1198                 this.printDocument.DefaultPageSettings.PaperSource.SourceName == paperSource.SourceName)
1199                     this.paperSourceComboBox.SelectedItem = paperSource;
1200             }
1201
1202             if (null == this.paperSourceComboBox.SelectedItem &&
1203             this.paperSourceComboBox.Items.Count > 0)
1204             {
1205                 this.paperSourceComboBox.SelectedItem = this.paperSourceComboBox.Items[0] as PaperSource;
1206                 this.printDocument.DefaultPageSettings.PaperSource = this.paperSourceComboBox.SelectedItem as PaperSource;
1207             }
1208         }
1209
1210         //
1211
1212         private void SetMarginsToUI(Margins margins)
1213         {
1214             this.marginsLeftInput.Value = PrinterUnitToUIUnit(margins.Left);
1215             this.marginsRightInput.Value = PrinterUnitToUIUnit(margins.Right);
1216             this.marginsTopInput.Value = PrinterUnitToUIUnit(margins.Top);
1217             this.marginsBottomInput.Value = PrinterUnitToUIUnit(margins.Bottom);
1218         }
1219
1220         private Margins GetMarginsFromUI()
1221         {
1222             Margins margins = new Margins(
1223                 UIUnitToPrinterUnit(this.marginsLeftInput.Value),
1224                 UIUnitToPrinterUnit(this.marginsRightInput.Value),
1225                 UIUnitToPrinterUnit(this.marginsTopInput.Value),
1226                 UIUnitToPrinterUnit(this.marginsBottomInput.Value));
1227             return margins;
1228         }
1229
1230         private decimal PrinterUnitToUIUnit(int printerValue)
1231         {
1232             return Convert.ToDecimal((double)printerValue / 100.0d); //in 1/100 of inch
1233         }
1234
1235         private int UIUnitToPrinterUnit(decimal uiValue)
1236         {
1237             return Convert.ToInt32((double)uiValue * 100.0d); //in 1/100 of inch
1238         }
1239         #endregion
1240
1241         private void WorkflowPageSetupDialog_HelpButtonClicked(object sender, System.ComponentModel.CancelEventArgs e)
1242         {
1243             e.Cancel = true;
1244             GetHelp();
1245         }
1246
1247         protected override void OnHelpRequested(HelpEventArgs hlpevent)
1248         {
1249             hlpevent.Handled = true;
1250             GetHelp();
1251         }
1252
1253         private void GetHelp()
1254         {
1255             DesignerHelpers.ShowHelpFromKeyword(this.serviceProvider, typeof(WorkflowPageSetupDialog).FullName + ".UI");
1256         }
1257     }
1258 }