CodePageOptions.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. using System.Windows.Forms;
  2. using FastReport.Utils;
  3. using FastReport.Design.PageDesigners.Code;
  4. using FastReport.Controls;
  5. namespace FastReport.Forms
  6. {
  7. internal class CodePageOptions : DesignerOptionsPage
  8. {
  9. private CodePageDesigner editor;
  10. private CheckBox cbEnableCodeCompletion;
  11. private CheckBox cbEnableVirtualSpace;
  12. private CheckBox cbAllowOutlining;
  13. private NumericUpDown udTabSize;
  14. private Label lblTabSize;
  15. private CheckBox cbLineNumbers;
  16. private GroupBox gbScriptLanguage;
  17. private RadioButton rbVBNet;
  18. private RadioButton rbCSharp;
  19. private CheckBox cbUseSpaces;
  20. private void InitializeComponent()
  21. {
  22. this.cbEnableCodeCompletion = new CheckBox();
  23. this.cbEnableVirtualSpace = new CheckBox();
  24. this.cbUseSpaces = new CheckBox();
  25. this.cbAllowOutlining = new CheckBox();
  26. this.udTabSize = new NumericUpDown();
  27. this.lblTabSize = new Label();
  28. this.cbLineNumbers = new CheckBox();
  29. this.gbScriptLanguage = new GroupBox();
  30. this.rbVBNet = new RadioButton();
  31. this.rbCSharp = new RadioButton();
  32. this.tc1.SuspendLayout();
  33. this.tab1.SuspendLayout();
  34. ((System.ComponentModel.ISupportInitialize)(this.udTabSize)).BeginInit();
  35. this.gbScriptLanguage.SuspendLayout();
  36. this.SuspendLayout();
  37. //
  38. // tab1
  39. //
  40. this.tab1.Controls.Add(this.gbScriptLanguage);
  41. this.tab1.Controls.Add(this.cbLineNumbers);
  42. this.tab1.Controls.Add(this.udTabSize);
  43. this.tab1.Controls.Add(this.lblTabSize);
  44. this.tab1.Controls.Add(this.cbEnableCodeCompletion);
  45. this.tab1.Controls.Add(this.cbEnableVirtualSpace);
  46. this.tab1.Controls.Add(this.cbUseSpaces);
  47. this.tab1.Controls.Add(this.cbAllowOutlining);
  48. //
  49. // cbEnableCodeCompletion
  50. //
  51. this.cbEnableCodeCompletion.AutoSize = true;
  52. this.cbEnableCodeCompletion.Location = new System.Drawing.Point(16, 16);
  53. this.cbEnableCodeCompletion.Name = "cbEnableCodeCompletion";
  54. this.cbEnableCodeCompletion.Size = new System.Drawing.Size(138, 17);
  55. this.cbEnableCodeCompletion.TabIndex = 7;
  56. this.cbEnableCodeCompletion.Text = "Enable code completion";
  57. this.cbEnableCodeCompletion.UseVisualStyleBackColor = true;
  58. //
  59. // cbEnableVirtualSpace
  60. //
  61. this.cbEnableVirtualSpace.AutoSize = true;
  62. this.cbEnableVirtualSpace.Location = new System.Drawing.Point(16, 40);
  63. this.cbEnableVirtualSpace.Name = "cbEnableVirtualSpace";
  64. this.cbEnableVirtualSpace.Size = new System.Drawing.Size(122, 17);
  65. this.cbEnableVirtualSpace.TabIndex = 0;
  66. this.cbEnableVirtualSpace.Text = "Enable virtual space";
  67. this.cbEnableVirtualSpace.UseVisualStyleBackColor = true;
  68. //
  69. // cbUseSpaces
  70. //
  71. this.cbUseSpaces.AutoSize = true;
  72. this.cbUseSpaces.Location = new System.Drawing.Point(16, 64);
  73. this.cbUseSpaces.Name = "cbUseSpaces";
  74. this.cbUseSpaces.Size = new System.Drawing.Size(130, 17);
  75. this.cbUseSpaces.TabIndex = 1;
  76. this.cbUseSpaces.Text = "Use spaces to fill tabs";
  77. this.cbUseSpaces.UseVisualStyleBackColor = true;
  78. //
  79. // cbAllowOutlining
  80. //
  81. this.cbAllowOutlining.AutoSize = true;
  82. this.cbAllowOutlining.Location = new System.Drawing.Point(16, 88);
  83. this.cbAllowOutlining.Name = "cbAllowOutlining";
  84. this.cbAllowOutlining.Size = new System.Drawing.Size(94, 17);
  85. this.cbAllowOutlining.TabIndex = 2;
  86. this.cbAllowOutlining.Text = "Allow outlining";
  87. this.cbAllowOutlining.UseVisualStyleBackColor = true;
  88. //
  89. // udTabSize
  90. //
  91. this.udTabSize.Location = new System.Drawing.Point(199, 138);
  92. this.udTabSize.Maximum = new decimal(new int[] {
  93. 16,
  94. 0,
  95. 0,
  96. 0});
  97. this.udTabSize.Minimum = new decimal(new int[] {
  98. 1,
  99. 0,
  100. 0,
  101. 0});
  102. this.udTabSize.Name = "udTabSize";
  103. this.udTabSize.Size = new System.Drawing.Size(76, 21);
  104. this.udTabSize.TabIndex = 5;
  105. this.udTabSize.Value = new decimal(new int[] {
  106. 1,
  107. 0,
  108. 0,
  109. 0});
  110. //
  111. // lblTabSize
  112. //
  113. this.lblTabSize.AutoSize = true;
  114. this.lblTabSize.Location = new System.Drawing.Point(16, 140);
  115. this.lblTabSize.Name = "lblTabSize";
  116. this.lblTabSize.Size = new System.Drawing.Size(50, 13);
  117. this.lblTabSize.TabIndex = 4;
  118. this.lblTabSize.Text = "Tab size:";
  119. //
  120. // cbLineNumbers
  121. //
  122. this.cbLineNumbers.AutoSize = true;
  123. this.cbLineNumbers.Location = new System.Drawing.Point(16, 112);
  124. this.cbLineNumbers.Name = "cbLineNumbers";
  125. this.cbLineNumbers.Size = new System.Drawing.Size(89, 17);
  126. this.cbLineNumbers.TabIndex = 6;
  127. this.cbLineNumbers.Text = "Line numbers";
  128. this.cbLineNumbers.UseVisualStyleBackColor = true;
  129. //
  130. // gbScriptLanguage
  131. //
  132. this.gbScriptLanguage.Controls.Add(this.rbVBNet);
  133. this.gbScriptLanguage.Controls.Add(this.rbCSharp);
  134. this.gbScriptLanguage.Location = new System.Drawing.Point(16, 165);
  135. this.gbScriptLanguage.Name = "gbScriptLanguage";
  136. this.gbScriptLanguage.Size = new System.Drawing.Size(335, 68);
  137. this.gbScriptLanguage.TabIndex = 10;
  138. this.gbScriptLanguage.TabStop = false;
  139. this.gbScriptLanguage.Text = "Default script language:";
  140. //
  141. // rbVBNet
  142. //
  143. this.rbVBNet.AutoSize = true;
  144. this.rbVBNet.Location = new System.Drawing.Point(154, 29);
  145. this.rbVBNet.Name = "rbVBNet";
  146. this.rbVBNet.Size = new System.Drawing.Size(105, 17);
  147. this.rbVBNet.TabIndex = 1;
  148. this.rbVBNet.Text = "Visual Basic .NET";
  149. this.rbVBNet.UseVisualStyleBackColor = true;
  150. //
  151. // rbCSharp
  152. //
  153. this.rbCSharp.AutoSize = true;
  154. this.rbCSharp.Checked = true;
  155. this.rbCSharp.Location = new System.Drawing.Point(10, 29);
  156. this.rbCSharp.Name = "rbCSharp";
  157. this.rbCSharp.Size = new System.Drawing.Size(40, 17);
  158. this.rbCSharp.TabIndex = 0;
  159. this.rbCSharp.TabStop = true;
  160. this.rbCSharp.Text = "C#";
  161. this.rbCSharp.UseVisualStyleBackColor = true;
  162. //
  163. // CodePageOptions
  164. //
  165. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  166. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
  167. this.ClientSize = new System.Drawing.Size(389, 313);
  168. this.Name = "CodePageOptions";
  169. this.tc1.ResumeLayout(false);
  170. this.tab1.ResumeLayout(false);
  171. this.tab1.PerformLayout();
  172. ((System.ComponentModel.ISupportInitialize)(this.udTabSize)).EndInit();
  173. this.gbScriptLanguage.ResumeLayout(false);
  174. this.gbScriptLanguage.PerformLayout();
  175. this.ResumeLayout(false);
  176. this.PerformLayout();
  177. }
  178. public void Localize()
  179. {
  180. MyRes res = new MyRes("Forms,CodePageOptions");
  181. tab1.Text = res.Get("");
  182. cbEnableCodeCompletion.Text = res.Get("EnableCodeCompletion");
  183. cbEnableVirtualSpace.Text = res.Get("EnableVirtualSpace");
  184. cbUseSpaces.Text = res.Get("UseSpaces");
  185. cbAllowOutlining.Text = res.Get("AllowOutlining");
  186. cbLineNumbers.Text = res.Get("LineNumbers");
  187. lblTabSize.Text = res.Get("TabSize");
  188. gbScriptLanguage.Text = res.Get("DefaultScriptLanguage");
  189. rbCSharp.Text = res.Get("CSharp");
  190. rbVBNet.Text = res.Get("VBNet");
  191. }
  192. public override void Init()
  193. {
  194. cbEnableCodeCompletion.Checked = CodePageSettings.EnableCodeCompletion;
  195. cbEnableVirtualSpace.Checked = CodePageSettings.EnableVirtualSpace;
  196. cbUseSpaces.Checked = CodePageSettings.UseSpaces;
  197. cbAllowOutlining.Checked = CodePageSettings.AllowOutlining;
  198. cbLineNumbers.Checked = CodePageSettings.LineNumbers;
  199. udTabSize.Value = CodePageSettings.TabSize;
  200. if (CodePageSettings.DefaultScriptLanguage == Language.CSharp)
  201. {
  202. rbCSharp.Checked = true;
  203. rbVBNet.Checked = false;
  204. }
  205. else
  206. {
  207. rbCSharp.Checked = false;
  208. rbVBNet.Checked = true;
  209. }
  210. }
  211. public override void Done(DialogResult result)
  212. {
  213. if (result == DialogResult.OK)
  214. {
  215. CodePageSettings.EnableCodeCompletion = cbEnableCodeCompletion.Checked;
  216. CodePageSettings.EnableVirtualSpace = cbEnableVirtualSpace.Checked;
  217. CodePageSettings.UseSpaces = cbUseSpaces.Checked;
  218. CodePageSettings.AllowOutlining = cbAllowOutlining.Checked;
  219. CodePageSettings.LineNumbers = cbLineNumbers.Checked;
  220. CodePageSettings.TabSize = (int)udTabSize.Value;
  221. CodePageSettings.DefaultScriptLanguage = rbCSharp.Checked ? Language.CSharp : Language.Vb;
  222. editor.UpdateOptions();
  223. }
  224. }
  225. public CodePageOptions(CodePageDesigner editor) : base()
  226. {
  227. this.editor = editor;
  228. InitializeComponent();
  229. Localize();
  230. }
  231. }
  232. }