CodePageSettings.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. namespace FastReport.Design.PageDesigners.Code
  10. {
  11. internal class CodePageSettings
  12. {
  13. #region Fields
  14. private static bool FEnableCodeCompletion;
  15. private static bool FEnableVirtualSpace;
  16. private static bool FUseSpaces;
  17. private static bool FAllowOutlining;
  18. private static int FTabSize;
  19. private static bool FLineNumbers;
  20. private static Language FDefaultScriptLanguage;
  21. #endregion
  22. #region Properties
  23. public static bool EnableCodeCompletion
  24. {
  25. get { return FEnableCodeCompletion; }
  26. set { FEnableCodeCompletion = value; }
  27. }
  28. public static bool EnableVirtualSpace
  29. {
  30. get { return FEnableVirtualSpace; }
  31. set { FEnableVirtualSpace = value; }
  32. }
  33. public static bool UseSpaces
  34. {
  35. get { return FUseSpaces; }
  36. set { FUseSpaces = value; }
  37. }
  38. public static bool AllowOutlining
  39. {
  40. get { return FAllowOutlining; }
  41. set { FAllowOutlining = value; }
  42. }
  43. public static int TabSize
  44. {
  45. get { return FTabSize; }
  46. set { FTabSize = value; }
  47. }
  48. public static bool LineNumbers
  49. {
  50. get { return FLineNumbers; }
  51. set { FLineNumbers = value; }
  52. }
  53. public static Language DefaultScriptLanguage
  54. {
  55. get { return FDefaultScriptLanguage; }
  56. set
  57. {
  58. FDefaultScriptLanguage = value;
  59. Config.ReportSettings.DefaultLanguage = FDefaultScriptLanguage;
  60. }
  61. }
  62. #endregion
  63. #region Public Methods
  64. public static void SaveState()
  65. {
  66. XmlItem xi = Config.Root.FindItem("Designer").FindItem("Code");
  67. xi.SetProp("EnableCodeCompletion", EnableCodeCompletion ? "1" : "0");
  68. xi.SetProp("EnableVirtualSpace", EnableVirtualSpace ? "1" : "0");
  69. xi.SetProp("UseSpaces", UseSpaces ? "1" : "0");
  70. xi.SetProp("AllowOutlining", AllowOutlining ? "1" : "0");
  71. xi.SetProp("TabSize", TabSize.ToString());
  72. xi.SetProp("LineNumbers", LineNumbers ? "1" : "0");
  73. xi.SetProp("DefaultScriptLanguage", DefaultScriptLanguage.ToString());
  74. }
  75. static CodePageSettings()
  76. {
  77. XmlItem xi = Config.Root.FindItem("Designer").FindItem("Code");
  78. EnableCodeCompletion = xi.GetProp("EnableCodeCompletion") != "0";
  79. EnableVirtualSpace = xi.GetProp("EnableVirtualSpace") != "0";
  80. UseSpaces = xi.GetProp("UseSpaces") != "0";
  81. AllowOutlining = xi.GetProp("AllowOutlining") != "0";
  82. string tabSize = xi.GetProp("TabSize");
  83. if (String.IsNullOrEmpty(tabSize))
  84. tabSize = "2";
  85. TabSize = int.Parse(tabSize);
  86. LineNumbers = xi.GetProp("LineNumbers") != "0";
  87. DefaultScriptLanguage = xi.GetProp("DefaultScriptLanguage") == Language.Vb.ToString() ? Language.Vb : Language.CSharp;
  88. }
  89. #endregion
  90. }
  91. }