AuthForm.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. using System;
  2. using FastReport.Controls;
  3. using FastReport.Design;
  4. using FastReport.Forms;
  5. using FastReport.Utils;
  6. using System.Collections.Generic;
  7. using System.Diagnostics;
  8. using System.Drawing;
  9. using System.Windows.Forms;
  10. namespace FastReport.Auth
  11. {
  12. public partial class AuthForm : BaseDialogForm
  13. {
  14. private readonly List<DesignerOptionsPage> optionsPages;
  15. private PageControl pageControl1;
  16. private void AddPages(DesignerOptionsPage page)
  17. {
  18. if (page != null)
  19. {
  20. foreach (TabPage tab in page.tc1.TabPages)
  21. {
  22. PageControlPage panel = new PageControlPage();
  23. panel.Text = tab.Text;
  24. panel.Dock = DockStyle.Fill;
  25. panel.BackColor = SystemColors.Window;
  26. while (tab.Controls.Count > 0)
  27. {
  28. var control = tab.Controls[0];
  29. control.Parent = panel;
  30. }
  31. pageControl1.Controls.Add(panel);
  32. }
  33. optionsPages.Add(page);
  34. page.Init();
  35. }
  36. }
  37. public AuthForm()
  38. {
  39. optionsPages = new List<DesignerOptionsPage>();
  40. InitializeComponent();
  41. Localize();
  42. // add default pages
  43. AddPages(new AuthFormOptions());
  44. // Load active options tab.
  45. int activePageIndex;
  46. XmlItem options = Config.Root.FindItem("Designer").FindItem("OptionsWindow");
  47. int.TryParse(options.GetProp("ActiveTab"), out activePageIndex);
  48. pageControl1.ActivePageIndex = activePageIndex;
  49. UIUtils.CheckRTL(this);
  50. UpdateDpiDependencies();
  51. }
  52. private void DesignerOptions_FormClosing(object sender, FormClosingEventArgs e)
  53. {
  54. foreach (DesignerOptionsPage page in optionsPages)
  55. {
  56. page.Done(DialogResult);
  57. }
  58. // Save active options tab.
  59. XmlItem options = Config.Root.FindItem("Designer").FindItem("OptionsWindow");
  60. options.SetProp("ActiveTab", pageControl1.ActivePageIndex.ToString());
  61. }
  62. public override void Localize()
  63. {
  64. base.Localize();
  65. Text = Res.Get("Designer,Menu,Help,Account");
  66. }
  67. private void InitializeComponent()
  68. {
  69. this.pageControl1 = new FastReport.Controls.PageControl();
  70. this.SuspendLayout();
  71. //
  72. // btnOk
  73. //
  74. this.btnOk.Location = new System.Drawing.Point(364, 276);
  75. //
  76. // btnCancel
  77. //
  78. this.btnCancel.Location = new System.Drawing.Point(444, 276);
  79. //
  80. // pageControl1
  81. //
  82. this.pageControl1.Location = new System.Drawing.Point(12, 12);
  83. this.pageControl1.Name = "pageControl1";
  84. this.pageControl1.SelectorWidth = 139;
  85. this.pageControl1.Size = new System.Drawing.Size(508, 252);
  86. this.pageControl1.TabIndex = 1;
  87. this.pageControl1.Text = "pageControl1";
  88. //
  89. // AuthForm
  90. //
  91. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  92. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
  93. this.ClientSize = new System.Drawing.Size(531, 310);
  94. this.Controls.Add(this.pageControl1);
  95. this.Name = "AuthForm";
  96. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DesignerOptions_FormClosing);
  97. this.Controls.SetChildIndex(this.btnOk, 0);
  98. this.Controls.SetChildIndex(this.btnCancel, 0);
  99. this.Controls.SetChildIndex(this.pageControl1, 0);
  100. this.ResumeLayout(false);
  101. }
  102. public override void UpdateDpiDependencies()
  103. {
  104. base.UpdateDpiDependencies();
  105. foreach (DesignerOptionsPage page in optionsPages)
  106. {
  107. page.UpdateDpiDependencies();
  108. AuthFormOptions temp = page as AuthFormOptions;
  109. if (temp != null)
  110. temp.UpdateCaptionFont(NewDpi);
  111. }
  112. }
  113. }
  114. }