4 using System.Resources;
5 using System.Windows.Forms;
6 using System.Drawing.Printing;
7 using System.ComponentModel.Design;
9 namespace System.Workflow.ComponentModel.Design
12 /// Summary description for Form1.
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
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;
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;
95 public WorkflowPageSetupDialog(IServiceProvider serviceProvider)
97 if (serviceProvider == null)
98 throw new ArgumentNullException("serviceProvider");
100 this.serviceProvider = serviceProvider;
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));
106 if (!(workflowView.PrintDocument is WorkflowPrintDocument))
107 throw new InvalidOperationException(DR.GetString(DR.WorkflowPrintDocumentNotFound, typeof(WorkflowPrintDocument).Name));
111 Cursor.Current = Cursors.WaitCursor;
113 InitializeComponent();
115 this.printDocument = workflowView.PrintDocument as WorkflowPrintDocument;
116 //deserialize state of the dialog from the page setup data scaling:
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;
123 //select the right mode
124 if (this.printDocument.PageSetupData.AdjustToScaleFactor)
125 this.adjustToRadioButton.Checked = true;
127 this.fitToRadioButton.Checked = true;
129 //set the orientation
130 if (this.printDocument.PageSetupData.Landscape)
131 this.landscapeRadioButton.Checked = true;
133 this.portraitRadioButton.Checked = true;
136 SetMarginsToUI(this.printDocument.PageSetupData.Margins);
139 this.CenterHorizontallyCheckBox.Checked = this.printDocument.PageSetupData.CenterHorizontally;
140 this.CenterVerticallyCheckBox.Checked = this.printDocument.PageSetupData.CenterVertically;
142 //Initialize the paper
143 InitializePaperInformation();
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%"//
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;
166 string userHeader = this.printDocument.PageSetupData.HeaderTemplate;
167 this.headerCustom = this.printDocument.PageSetupData.HeaderCustom;
168 if (userHeader.Length == 0)
170 this.headerTextComboBox.SelectedIndex = 0; //none
174 int userHeaderIndex = this.headerTextComboBox.Items.IndexOf(userHeader);
176 if (-1 == userHeaderIndex || this.headerCustom)
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;
184 this.headerTextComboBox.SelectedIndex = userHeaderIndex;
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;
192 this.headerAlignmentComboBox.SelectedItem = HorizontalAlignment.Center;
194 this.headerMarginInput.Value = PrinterUnitToUIUnit(this.printDocument.PageSetupData.HeaderMargin);
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);
202 string userFooter = this.printDocument.PageSetupData.FooterTemplate;
203 this.footerCustom = this.printDocument.PageSetupData.FooterCustom;
204 if (userFooter.Length == 0)
206 this.footerTextComboBox.SelectedIndex = 0; //none
210 int userFooterIndex = this.footerTextComboBox.Items.IndexOf(userFooter);
212 if (-1 == userFooterIndex || this.footerCustom)
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;
220 this.footerTextComboBox.SelectedIndex = userFooterIndex;
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;
228 this.footerAlignmentComboBox.SelectedItem = HorizontalAlignment.Center;
230 this.footerMarginInput.Value = PrinterUnitToUIUnit(this.printDocument.PageSetupData.FooterMargin);
234 Cursor.Current = Cursors.Default;
238 protected override void Dispose(bool disposing)
242 if (components != null)
243 components.Dispose();
246 base.Dispose(disposing);
250 #region Windows Form Designer generated code
252 /// Required method for Designer support - do not modify
253 /// the contents of this method with the code editor.
255 private void InitializeComponent()
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();
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;
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";
374 resources.ApplyResources(this.centerGroup, "centerGroup");
375 this.centerGroup.Controls.Add(this.centerTableLayoutPanel);
376 this.centerGroup.Name = "centerGroup";
377 this.centerGroup.TabStop = false;
379 // centerTableLayoutPanel
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";
386 // CenterVerticallyCheckBox
388 resources.ApplyResources(this.CenterVerticallyCheckBox, "CenterVerticallyCheckBox");
389 this.CenterVerticallyCheckBox.Name = "CenterVerticallyCheckBox";
391 // CenterHorizontallyCheckBox
393 resources.ApplyResources(this.CenterHorizontallyCheckBox, "CenterHorizontallyCheckBox");
394 this.CenterHorizontallyCheckBox.Name = "CenterHorizontallyCheckBox";
398 resources.ApplyResources(this.marginsGroup, "marginsGroup");
399 this.marginsGroup.Controls.Add(this.marginsTableLayoutPanel);
400 this.marginsGroup.Name = "marginsGroup";
401 this.marginsGroup.TabStop = false;
403 // marginsTableLayoutPanel
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";
418 resources.ApplyResources(this.marginsRightInput, "marginsRightInput");
419 this.marginsRightInput.DecimalPlaces = 2;
420 this.marginsRightInput.Increment = new decimal(new int[] {
425 this.marginsRightInput.Name = "marginsRightInput";
426 this.marginsRightInput.Value = new decimal(new int[] {
431 this.marginsRightInput.Validating += new System.ComponentModel.CancelEventHandler(this.Margins_Validating);
433 // marginsBottomInput
435 resources.ApplyResources(this.marginsBottomInput, "marginsBottomInput");
436 this.marginsBottomInput.DecimalPlaces = 2;
437 this.marginsBottomInput.Increment = new decimal(new int[] {
442 this.marginsBottomInput.Name = "marginsBottomInput";
443 this.marginsBottomInput.Value = new decimal(new int[] {
448 this.marginsBottomInput.Validating += new System.ComponentModel.CancelEventHandler(this.Margins_Validating);
452 resources.ApplyResources(this.marginsTopLabel, "marginsTopLabel");
453 this.marginsTopLabel.Name = "marginsTopLabel";
457 resources.ApplyResources(this.marginsLeftLabel, "marginsLeftLabel");
458 this.marginsLeftLabel.Name = "marginsLeftLabel";
462 resources.ApplyResources(this.marginsRightLabel, "marginsRightLabel");
463 this.marginsRightLabel.Name = "marginsRightLabel";
465 // marginsBottomLabel
467 resources.ApplyResources(this.marginsBottomLabel, "marginsBottomLabel");
468 this.marginsBottomLabel.Name = "marginsBottomLabel";
472 resources.ApplyResources(this.marginsTopInput, "marginsTopInput");
473 this.marginsTopInput.DecimalPlaces = 2;
474 this.marginsTopInput.Increment = new decimal(new int[] {
479 this.marginsTopInput.Name = "marginsTopInput";
480 this.marginsTopInput.Value = new decimal(new int[] {
485 this.marginsTopInput.Validating += new System.ComponentModel.CancelEventHandler(this.Margins_Validating);
489 resources.ApplyResources(this.marginsLeftInput, "marginsLeftInput");
490 this.marginsLeftInput.DecimalPlaces = 2;
491 this.marginsLeftInput.Increment = new decimal(new int[] {
496 this.marginsLeftInput.Name = "marginsLeftInput";
497 this.marginsLeftInput.Value = new decimal(new int[] {
502 this.marginsLeftInput.Validating += new System.ComponentModel.CancelEventHandler(this.Margins_Validating);
506 resources.ApplyResources(this.scalingGroup, "scalingGroup");
507 this.scalingGroup.Controls.Add(this.scalingTableLayoutPanel);
508 this.scalingGroup.Name = "scalingGroup";
509 this.scalingGroup.TabStop = false;
511 // scalingTableLayoutPanel
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";
526 resources.ApplyResources(this.fitToTallLabel, "fitToTallLabel");
527 this.fitToTallLabel.Name = "fitToTallLabel";
529 // scalingOfSizeLabel
531 resources.ApplyResources(this.scalingOfSizeLabel, "scalingOfSizeLabel");
532 this.scalingOfSizeLabel.Name = "scalingOfSizeLabel";
536 resources.ApplyResources(this.fitToWideLabel, "fitToWideLabel");
537 this.fitToWideLabel.Name = "fitToWideLabel";
539 // adjustToRadioButton
541 resources.ApplyResources(this.adjustToRadioButton, "adjustToRadioButton");
542 this.adjustToRadioButton.Name = "adjustToRadioButton";
544 // fitToPagesTallInput
546 resources.ApplyResources(this.fitToPagesTallInput, "fitToPagesTallInput");
547 this.fitToPagesTallInput.Maximum = new decimal(new int[] {
552 this.fitToPagesTallInput.Minimum = new decimal(new int[] {
557 this.fitToPagesTallInput.Name = "fitToPagesTallInput";
558 this.fitToPagesTallInput.Value = new decimal(new int[] {
563 this.fitToPagesTallInput.ValueChanged += new System.EventHandler(this.fitToInputs_ValueChanged);
565 // fitToPagesWideInput
567 resources.ApplyResources(this.fitToPagesWideInput, "fitToPagesWideInput");
568 this.fitToPagesWideInput.Maximum = new decimal(new int[] {
573 this.fitToPagesWideInput.Minimum = new decimal(new int[] {
578 this.fitToPagesWideInput.Name = "fitToPagesWideInput";
579 this.fitToPagesWideInput.Value = new decimal(new int[] {
584 this.fitToPagesWideInput.ValueChanged += new System.EventHandler(this.fitToInputs_ValueChanged);
586 // adjustToScaleInput
588 resources.ApplyResources(this.adjustToScaleInput, "adjustToScaleInput");
589 this.adjustToScaleInput.Maximum = new decimal(new int[] {
594 this.adjustToScaleInput.Minimum = new decimal(new int[] {
599 this.adjustToScaleInput.Name = "adjustToScaleInput";
600 this.adjustToScaleInput.Value = new decimal(new int[] {
605 this.adjustToScaleInput.ValueChanged += new System.EventHandler(this.adjustToInput_ValueChanged);
609 resources.ApplyResources(this.fitToRadioButton, "fitToRadioButton");
610 this.fitToRadioButton.Name = "fitToRadioButton";
614 resources.ApplyResources(this.orientationGroup, "orientationGroup");
615 this.orientationGroup.Controls.Add(this.orientationTableLayoutPanel);
616 this.orientationGroup.Name = "orientationGroup";
617 this.orientationGroup.TabStop = false;
619 // orientationTableLayoutPanel
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";
628 // landscapeRadioButton
630 resources.ApplyResources(this.landscapeRadioButton, "landscapeRadioButton");
631 this.landscapeRadioButton.Name = "landscapeRadioButton";
632 this.landscapeRadioButton.CheckedChanged += new System.EventHandler(this.landscapeRadioButton_CheckedChanged);
636 resources.ApplyResources(this.landscapePicture, "landscapePicture");
637 this.landscapePicture.Name = "landscapePicture";
638 this.landscapePicture.TabStop = false;
640 // portraitRadioButton
642 resources.ApplyResources(this.portraitRadioButton, "portraitRadioButton");
643 this.portraitRadioButton.Name = "portraitRadioButton";
644 this.portraitRadioButton.CheckedChanged += new System.EventHandler(this.portraitRadioButton_CheckedChanged);
648 resources.ApplyResources(this.portraitPicture, "portraitPicture");
649 this.portraitPicture.Name = "portraitPicture";
650 this.portraitPicture.TabStop = false;
652 // paperSettingsGroup
654 resources.ApplyResources(this.paperSettingsGroup, "paperSettingsGroup");
655 this.paperSettingsGroup.Controls.Add(this.paperTableLayoutPanel);
656 this.paperSettingsGroup.Name = "paperSettingsGroup";
657 this.paperSettingsGroup.TabStop = false;
659 // paperTableLayoutPanel
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";
668 // paperSourceComboBox
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";
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);
685 resources.ApplyResources(this.paperSizeLabel, "paperSizeLabel");
686 this.paperSizeLabel.Name = "paperSizeLabel";
690 resources.ApplyResources(this.paperSourceLabel, "paperSourceLabel");
691 this.paperSourceLabel.Name = "paperSourceLabel";
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";
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;
709 // footerTableLayoutPanel
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";
723 resources.ApplyResources(this.footerTextLabel, "footerTextLabel");
724 this.footerTextLabel.Name = "footerTextLabel";
726 // footerAlignmentLabel
728 resources.ApplyResources(this.footerAlignmentLabel, "footerAlignmentLabel");
729 this.footerAlignmentLabel.Name = "footerAlignmentLabel";
731 // footerMarginUnitsLabel
733 resources.ApplyResources(this.footerMarginUnitsLabel, "footerMarginUnitsLabel");
734 this.footerMarginUnitsLabel.Name = "footerMarginUnitsLabel";
738 resources.ApplyResources(this.footerMarginLabel, "footerMarginLabel");
739 this.footerMarginLabel.Name = "footerMarginLabel";
743 resources.ApplyResources(this.footerMarginInput, "footerMarginInput");
744 this.footerMarginInput.DecimalPlaces = 2;
745 this.footerMarginInput.Increment = new decimal(new int[] {
750 this.footerMarginInput.Name = "footerMarginInput";
751 this.footerMarginInput.Value = new decimal(new int[] {
756 this.footerMarginInput.Validating += new System.ComponentModel.CancelEventHandler(this.footerMarginInput_Validating);
758 // footerTextComboBox
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);
767 // footerAlignmentComboBox
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";
777 resources.ApplyResources(this.customFooterText, "customFooterText");
778 this.customFooterText.Name = "customFooterText";
782 resources.ApplyResources(this.customFooterLabel, "customFooterLabel");
783 this.customFooterLabel.Name = "customFooterLabel";
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;
794 // headerTableLayoutPanel
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";
808 resources.ApplyResources(this.headerTextLabel, "headerTextLabel");
809 this.headerTextLabel.Name = "headerTextLabel";
811 // headerAlignmentLabel
813 resources.ApplyResources(this.headerAlignmentLabel, "headerAlignmentLabel");
814 this.headerAlignmentLabel.Cursor = System.Windows.Forms.Cursors.Arrow;
815 this.headerAlignmentLabel.Name = "headerAlignmentLabel";
817 // headerMarginUnitsLabel
819 resources.ApplyResources(this.headerMarginUnitsLabel, "headerMarginUnitsLabel");
820 this.headerMarginUnitsLabel.Name = "headerMarginUnitsLabel";
824 resources.ApplyResources(this.headerMarginLabel, "headerMarginLabel");
825 this.headerMarginLabel.Name = "headerMarginLabel";
829 resources.ApplyResources(this.headerMarginInput, "headerMarginInput");
830 this.headerMarginInput.DecimalPlaces = 2;
831 this.headerMarginInput.Increment = new decimal(new int[] {
836 this.headerMarginInput.Name = "headerMarginInput";
837 this.headerMarginInput.Value = new decimal(new int[] {
842 this.headerMarginInput.Validating += new System.ComponentModel.CancelEventHandler(this.headerMarginInput_Validating);
844 // headerTextComboBox
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);
853 // headerAlignmentComboBox
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";
863 resources.ApplyResources(this.customHeaderText, "customHeaderText");
864 this.customHeaderText.Name = "customHeaderText";
868 resources.ApplyResources(this.customHeaderLabel, "customHeaderLabel");
869 this.customHeaderLabel.Name = "customHeaderLabel";
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);
880 resources.ApplyResources(this.cancelButton, "cancelButton");
881 this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
882 this.cancelButton.Name = "cancelButton";
886 resources.ApplyResources(this.printerButton, "printerButton");
887 this.printerButton.Name = "printerButton";
888 this.printerButton.Click += new System.EventHandler(this.printerButton_Click);
890 // okCancelTableLayoutPanel
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";
898 // WorkflowPageSetupDialog
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();
958 private void OKButton_Click(object sender, System.EventArgs e)
960 //serialize state of the dialog into the pageSetupData object
961 Margins margins = GetMarginsFromUI();
964 this.printDocument.PageSetupData.AdjustToScaleFactor = this.adjustToRadioButton.Checked;
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;
970 //Set the orientation
971 this.printDocument.PageSetupData.Landscape = this.landscapeRadioButton.Checked;
972 this.printDocument.PageSetupData.Margins = margins;
975 this.printDocument.PageSetupData.CenterHorizontally = this.CenterHorizontallyCheckBox.Checked;
976 this.printDocument.PageSetupData.CenterVertically = this.CenterVerticallyCheckBox.Checked;
979 if (this.headerTextComboBox.SelectedIndex == 0)
980 this.printDocument.PageSetupData.HeaderTemplate = string.Empty;
982 if (!this.headerTextComboBox.Text.Equals(this.headerFooterCustom))
983 this.printDocument.PageSetupData.HeaderTemplate = this.headerTextComboBox.Text;
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);
991 if (this.footerTextComboBox.SelectedIndex == 0)
992 this.printDocument.PageSetupData.FooterTemplate = string.Empty;
994 if (!this.footerTextComboBox.Text.Equals(this.headerFooterCustom))
995 this.printDocument.PageSetupData.FooterTemplate = this.footerTextComboBox.Text;
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);
1002 // Set the paper size based upon the selection in the combo box.
1003 if (PrinterSettings.InstalledPrinters.Count > 0)
1005 if (this.paperSizeComboBox.SelectedItem != null)
1006 this.printDocument.DefaultPageSettings.PaperSize = (PaperSize)this.paperSizeComboBox.SelectedItem;
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;
1012 this.printDocument.DefaultPageSettings.Landscape = this.printDocument.PageSetupData.Landscape;
1013 this.printDocument.DefaultPageSettings.Margins = margins;
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;
1022 this.printDocument.PageSetupData.StorePropertiesToRegistry();
1023 DialogResult = DialogResult.OK;
1026 private void printerButton_Click(object sender, System.EventArgs e)
1028 PrintDialog printDialog = new System.Windows.Forms.PrintDialog();
1030 printDialog.AllowPrintToFile = false;
1031 printDialog.Document = this.printDocument;
1034 if (DialogResult.OK == printDialog.ShowDialog())
1036 this.printDocument.PrinterSettings = printDialog.PrinterSettings;
1037 this.printDocument.DefaultPageSettings = printDialog.Document.DefaultPageSettings;
1039 if (this.printDocument.DefaultPageSettings.Landscape)
1040 this.landscapeRadioButton.Checked = true;
1042 this.portraitRadioButton.Checked = true;
1044 InitializePaperInformation();
1046 this.printDocument.Print();
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)
1055 catch (Exception exception)
1057 string errorString = DR.GetString(DR.SelectedPrinterIsInvalidErrorMessage);
1058 errorString += "\n" + exception.Message;
1059 DesignerHelpers.ShowError(this.serviceProvider, errorString);
1063 private void Margins_Validating(object sender, System.ComponentModel.CancelEventArgs e)
1065 Margins margins = GetMarginsFromUI();
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);
1073 physicalPageSize = this.printDocument.DefaultPageSettings.Bounds.Size;
1075 //check the constrains
1076 int horizontalMarginsSum = margins.Left + margins.Right;
1077 int verticalMarginsSum = margins.Top + margins.Bottom;
1079 if (horizontalMarginsSum < physicalPageSize.Width && verticalMarginsSum < physicalPageSize.Height)
1080 return; //we are good
1082 //cancelling the change - constrains are not satisfied
1083 string errorString = DR.GetString(DR.EnteredMarginsAreNotValidErrorMessage);
1084 DesignerHelpers.ShowError(this.serviceProvider, errorString);
1088 private void headerTextComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
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;
1095 private void footerTextComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
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;
1103 private void paperSizeComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
1105 UpdateHeaderFooterMarginLimit();
1107 private void landscapeRadioButton_CheckedChanged(object sender, System.EventArgs e)
1109 UpdateHeaderFooterMarginLimit();
1111 private void portraitRadioButton_CheckedChanged(object sender, System.EventArgs e)
1113 UpdateHeaderFooterMarginLimit();
1116 private void UpdateHeaderFooterMarginLimit()
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);
1124 private void headerMarginInput_Validating(object sender, System.ComponentModel.CancelEventArgs e)
1127 private void footerMarginInput_Validating(object sender, System.ComponentModel.CancelEventArgs e)
1130 private void adjustToInput_ValueChanged(object sender, System.EventArgs e)
1132 this.adjustToRadioButton.Checked = true;
1134 private void fitToInputs_ValueChanged(object sender, System.EventArgs e)
1136 this.fitToRadioButton.Checked = true;
1141 private void InitializePaperInformation()
1143 PrinterSettings.PaperSizeCollection paperSizeCollection = this.printDocument.PrinterSettings.PaperSizes;
1144 PrinterSettings.PaperSourceCollection paperSourceCollection = this.printDocument.PrinterSettings.PaperSources;
1146 this.paperSizeComboBox.Items.Clear();
1147 this.paperSizeComboBox.DisplayMember = "PaperName";
1148 foreach (PaperSize paperSize in paperSizeCollection)
1150 if (paperSize.PaperName != null && paperSize.PaperName.Length > 0)
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)
1158 this.paperSizeComboBox.SelectedItem = paperSize;
1159 this.printDocument.DefaultPageSettings.PaperSize = paperSize;
1164 if (null == this.paperSizeComboBox.SelectedItem)
1166 PaperKind paperKind = this.printDocument.DefaultPageSettings.PaperSize.Kind;
1168 this.printDocument.DefaultPageSettings = new PageSettings(this.printDocument.PrinterSettings);
1169 foreach (PaperSize paperSize in this.paperSizeComboBox.Items)
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)
1176 this.paperSizeComboBox.SelectedItem = paperSize;
1177 this.printDocument.DefaultPageSettings.PaperSize = paperSize;
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)
1185 this.paperSizeComboBox.SelectedItem = this.paperSizeComboBox.Items[0] as PaperSize;
1186 this.printDocument.DefaultPageSettings.PaperSize = this.paperSizeComboBox.SelectedItem as PaperSize;
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)
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;
1202 if (null == this.paperSourceComboBox.SelectedItem &&
1203 this.paperSourceComboBox.Items.Count > 0)
1205 this.paperSourceComboBox.SelectedItem = this.paperSourceComboBox.Items[0] as PaperSource;
1206 this.printDocument.DefaultPageSettings.PaperSource = this.paperSourceComboBox.SelectedItem as PaperSource;
1212 private void SetMarginsToUI(Margins margins)
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);
1220 private Margins GetMarginsFromUI()
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));
1230 private decimal PrinterUnitToUIUnit(int printerValue)
1232 return Convert.ToDecimal((double)printerValue / 100.0d); //in 1/100 of inch
1235 private int UIUnitToPrinterUnit(decimal uiValue)
1237 return Convert.ToInt32((double)uiValue * 100.0d); //in 1/100 of inch
1241 private void WorkflowPageSetupDialog_HelpButtonClicked(object sender, System.ComponentModel.CancelEventArgs e)
1247 protected override void OnHelpRequested(HelpEventArgs hlpevent)
1249 hlpevent.Handled = true;
1253 private void GetHelp()
1255 DesignerHelpers.ShowHelpFromKeyword(this.serviceProvider, typeof(WorkflowPageSetupDialog).FullName + ".UI");