DesignerOptionsForm.cs 5.1 KB

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