SimpleGaugeEditorForm.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using FastReport.Gauge.Simple.Progress;
  5. using FastReport.Utils;
  6. namespace FastReport.Gauge.Simple
  7. {
  8. internal partial class SimpleGaugeEditorForm : GaugeEditorForm
  9. {
  10. #region Fields
  11. private GroupBox gpBoxFirstSubScale;
  12. private GroupBox gpBoxSecondSubScale;
  13. private TabPage tpSubscales;
  14. private ComboBox cbEnabled1;
  15. private Label lbEnabled1;
  16. private Label lbShowCaption1;
  17. private ComboBox cbShowCaption1;
  18. private ComboBox cbEnabled2;
  19. private Label lbEnabled2;
  20. private Label lbShowCaption2;
  21. private ComboBox cbShowCaption2;
  22. #endregion Fields // Fields
  23. #region Constructors
  24. public SimpleGaugeEditorForm(GaugeObject gauge, bool intermediate = false) : base(gauge)
  25. {
  26. if (!intermediate)
  27. {
  28. InitializeComponent();
  29. Localize();
  30. UIUtils.CheckRTL(this);
  31. UpdateDpiDependencies();
  32. }
  33. }
  34. #endregion Constructors // Constructors
  35. #region ProtectedMethods
  36. protected override void Init()
  37. {
  38. DeleteLabel = Gauge is SimpleProgressGauge ? false : true;
  39. base.Init();
  40. #region ControlsDesign
  41. gpBoxFirstSubScale = new GroupBox();
  42. gpBoxSecondSubScale = new GroupBox();
  43. lbEnabled1 = new Label();
  44. cbEnabled1 = new ComboBox();
  45. lbShowCaption1 = new Label();
  46. cbShowCaption1 = new ComboBox();
  47. lbEnabled2 = new Label();
  48. cbEnabled2 = new ComboBox();
  49. lbShowCaption2 = new Label();
  50. cbShowCaption2 = new ComboBox();
  51. int margin = 5;
  52. //first subscale
  53. gpBoxFirstSubScale.Location = new System.Drawing.Point(8, 9);
  54. gpBoxFirstSubScale.Name = "gpBoxFirstSubScale";
  55. gpBoxFirstSubScale.Margin = new Padding(10);
  56. gpBoxFirstSubScale.AutoSize = false;
  57. gpBoxFirstSubScale.Size = new Size(269, 83);
  58. gpBoxFirstSubScale.TabStop = false;
  59. gpBoxFirstSubScale.Text = "First Subscale";
  60. lbEnabled1.AutoSize = true;
  61. lbEnabled1.Margin = new Padding(margin);
  62. lbEnabled1.Location = new Point(11, 23);
  63. lbEnabled1.Name = "lbEnabled";
  64. lbEnabled1.Text = "Enabled :";
  65. cbEnabled1.DropDownStyle = ComboBoxStyle.DropDownList;
  66. cbEnabled1.Margin = new Padding(margin);
  67. cbEnabled1.Location = new Point(133, 21);
  68. cbEnabled1.Size = new Size(124, 21);
  69. cbEnabled1.Items.Add("true");
  70. cbEnabled1.Items.Add("false");
  71. cbEnabled1.SelectedItem = "false";
  72. cbEnabled1.Name = "cbEnabled";
  73. lbShowCaption1.AutoSize = true;
  74. lbShowCaption1.Margin = new Padding(margin);
  75. lbShowCaption1.Location = new Point(11, 49);
  76. lbShowCaption1.Name = "lbShowCaption";
  77. lbShowCaption1.Text = "Show Caption:";
  78. cbShowCaption1.DropDownStyle = ComboBoxStyle.DropDownList;
  79. cbShowCaption1.Margin = new Padding(margin);
  80. cbShowCaption1.Location = new Point(133, 46);
  81. cbShowCaption1.Size = new Size(124, 21);
  82. cbShowCaption1.Items.Add("true");
  83. cbShowCaption1.Items.Add("false");
  84. cbShowCaption1.SelectedItem = "false";
  85. cbShowCaption1.Name = "cbInverted";
  86. gpBoxFirstSubScale.Controls.AddRange(new Control[] { lbEnabled1, cbEnabled1, lbShowCaption1, cbShowCaption1 });
  87. //second subscale
  88. gpBoxSecondSubScale.Location = new Point(gpBoxFirstSubScale.Location.X, gpBoxFirstSubScale.Location.Y + gpBoxFirstSubScale.Size.Height + 4);
  89. gpBoxSecondSubScale.Name = "gpBoxSecondSubScale";
  90. gpBoxSecondSubScale.Margin = new Padding(10);
  91. gpBoxSecondSubScale.Size = new Size(269, 83);
  92. gpBoxSecondSubScale.TabStop = false;
  93. gpBoxSecondSubScale.Text = "Second Subscale";
  94. lbEnabled2.AutoSize = true;
  95. lbEnabled2.Margin = new Padding(margin);
  96. lbEnabled2.Location = new Point(11, 23);
  97. lbEnabled2.Name = "lbEnabled";
  98. lbEnabled2.Text = "Enabled :";
  99. cbEnabled2.DropDownStyle = ComboBoxStyle.DropDownList;
  100. cbEnabled2.Margin = new Padding(margin);
  101. cbEnabled2.Location = new Point(133, 21);
  102. cbEnabled2.Size = new Size(124, 21);
  103. cbEnabled2.Items.Add("true");
  104. cbEnabled2.Items.Add("false");
  105. cbEnabled2.SelectedItem = "false";
  106. cbEnabled2.Name = "cbEnabled";
  107. lbShowCaption2 = new Label();
  108. lbShowCaption2.AutoSize = true;
  109. lbShowCaption2.Margin = new Padding(margin);
  110. lbShowCaption2.Location = new Point(11, 49);
  111. lbShowCaption2.Name = "lbShowCaption";
  112. lbShowCaption2.Text = "Show Caption:";
  113. cbShowCaption2.DropDownStyle = ComboBoxStyle.DropDownList;
  114. cbShowCaption2.Margin = new Padding(margin);
  115. cbShowCaption2.Location = new Point(133, 46);
  116. cbShowCaption2.Size = new Size(124, 21);
  117. cbShowCaption2.Items.Add("true");
  118. cbShowCaption2.Items.Add("false");
  119. cbShowCaption2.SelectedItem = "false";
  120. cbShowCaption2.Name = "cbInverted";
  121. gpBoxSecondSubScale.Controls.AddRange(new Control[] { lbEnabled2, cbEnabled2, lbShowCaption2, cbShowCaption2 });
  122. //tab page
  123. tpSubscales = new TabPage();
  124. tpSubscales.Name = "tabPageSubscales";
  125. tpSubscales.Size = new System.Drawing.Size(418, 525);
  126. tpSubscales.Text = "Subscales";
  127. tpSubscales.UseVisualStyleBackColor = true;
  128. tpSubscales.Controls.AddRange(new Control[] { gpBoxFirstSubScale, gpBoxSecondSubScale });
  129. tabControl3.TabPages.Add(tpSubscales);
  130. //tpSubscales.Scale(new SizeF(this.DpiMultiplier(), this.DpiMultiplier()));
  131. #endregion // ControlsDesign
  132. if (Gauge != null)
  133. {
  134. try
  135. {
  136. cbEnabled1.SelectedItem = ((Gauge as SimpleGauge).Scale as SimpleScale).FirstSubScale.Enabled ? "true" : "false";
  137. cbShowCaption1.SelectedItem = ((Gauge as SimpleGauge).Scale as SimpleScale).FirstSubScale.ShowCaption ? "true" : "false";
  138. cbEnabled2.SelectedItem = ((Gauge as SimpleGauge).Scale as SimpleScale).SecondSubScale.Enabled ? "true" : "false";
  139. cbShowCaption2.SelectedItem = ((Gauge as SimpleGauge).Scale as SimpleScale).SecondSubScale.ShowCaption ? "true" : "false";
  140. }
  141. catch (Exception ex)
  142. {
  143. if (!Config.WebMode)
  144. {
  145. FRMessageBox.Error(ex.Message);
  146. }
  147. }
  148. }
  149. }
  150. protected override void GaugeEditorForm_FormClosing(object sender, FormClosingEventArgs e)
  151. {
  152. if (this.DialogResult == DialogResult.OK)
  153. {
  154. base.GaugeEditorForm_FormClosing(sender, e);
  155. try
  156. {
  157. ((Gauge as SimpleGauge).Scale as SimpleScale).FirstSubScale.Enabled = cbEnabled1.SelectedItem.ToString() == "false" ? false : true;
  158. ((Gauge as SimpleGauge).Scale as SimpleScale).FirstSubScale.ShowCaption = cbShowCaption1.SelectedItem.ToString() == "false" ? false : true;
  159. ((Gauge as SimpleGauge).Scale as SimpleScale).SecondSubScale.Enabled = cbEnabled2.SelectedItem.ToString() == "false" ? false : true;
  160. ((Gauge as SimpleGauge).Scale as SimpleScale).SecondSubScale.ShowCaption = cbShowCaption2.SelectedItem.ToString() == "false" ? false : true;
  161. }
  162. catch (Exception ex)
  163. {
  164. if (!Config.WebMode)
  165. {
  166. FRMessageBox.Error(ex.Message);
  167. }
  168. }
  169. }
  170. }
  171. #endregion //Protected Methods
  172. public override void Localize()
  173. {
  174. base.Localize();
  175. MyRes res = new MyRes("Objects,Gauge,GaugeForms,SimpleGauge");
  176. Text = res.Get("");
  177. res = new MyRes("Objects,Gauge,GaugeForms,PageScale,Subscales");
  178. tabControl3.TabPages[2].Text = res.Get("");
  179. gpBoxFirstSubScale.Text = res.Get("FirstSubscale");
  180. lbEnabled1.Text = res.Get("FirstSubscale,Enabled");
  181. lbShowCaption1.Text = res.Get("FirstSubscale,ShowCaption");
  182. gpBoxSecondSubScale.Text = res.Get("SecondSubscale");
  183. lbEnabled2.Text = res.Get("SecondSubscale,Enabled");
  184. lbShowCaption2.Text = res.Get("SecondSubscale,ShowCaption");
  185. }
  186. }
  187. }