/ILSpy/Options/DisplaySettings.cs

http://github.com/icsharpcode/ILSpy · C# · 269 lines · 211 code · 38 blank · 20 comment · 32 complexity · 77a845ab066b0b213143faebf2255ac4 MD5 · raw file

  1. // Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
  2. //
  3. // Permission is hereby granted, free of charge, to any person obtaining a copy of this
  4. // software and associated documentation files (the "Software"), to deal in the Software
  5. // without restriction, including without limitation the rights to use, copy, modify, merge,
  6. // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
  7. // to whom the Software is furnished to do so, subject to the following conditions:
  8. //
  9. // The above copyright notice and this permission notice shall be included in all copies or
  10. // substantial portions of the Software.
  11. //
  12. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  13. // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  14. // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
  15. // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  16. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  17. // DEALINGS IN THE SOFTWARE.
  18. using System.ComponentModel;
  19. using System.Runtime.CompilerServices;
  20. using System.Windows.Media;
  21. namespace ICSharpCode.ILSpy.Options
  22. {
  23. /// <summary>
  24. /// Description of DisplaySettings.
  25. /// </summary>
  26. public class DisplaySettings : INotifyPropertyChanged
  27. {
  28. public DisplaySettings()
  29. {
  30. this.selectedFont = new FontFamily("Consolas");
  31. this.selectedFontSize = 10.0 * 4 / 3;
  32. this.sortResults = true;
  33. this.indentationUseTabs = true;
  34. this.indentationSize = 4;
  35. this.indentationTabSize = 4;
  36. this.highlightMatchingBraces = true;
  37. }
  38. #region INotifyPropertyChanged implementation
  39. public event PropertyChangedEventHandler PropertyChanged;
  40. protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
  41. {
  42. PropertyChanged?.Invoke(this, e);
  43. }
  44. protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
  45. {
  46. OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
  47. }
  48. #endregion
  49. FontFamily selectedFont;
  50. public FontFamily SelectedFont {
  51. get { return selectedFont; }
  52. set {
  53. if (selectedFont != value) {
  54. selectedFont = value;
  55. OnPropertyChanged();
  56. }
  57. }
  58. }
  59. double selectedFontSize;
  60. public double SelectedFontSize {
  61. get { return selectedFontSize; }
  62. set {
  63. if (selectedFontSize != value) {
  64. selectedFontSize = value;
  65. OnPropertyChanged();
  66. }
  67. }
  68. }
  69. bool showLineNumbers;
  70. public bool ShowLineNumbers {
  71. get { return showLineNumbers; }
  72. set {
  73. if (showLineNumbers != value) {
  74. showLineNumbers = value;
  75. OnPropertyChanged();
  76. }
  77. }
  78. }
  79. bool showMetadataTokens;
  80. public bool ShowMetadataTokens {
  81. get { return showMetadataTokens; }
  82. set {
  83. if (showMetadataTokens != value) {
  84. showMetadataTokens = value;
  85. OnPropertyChanged();
  86. }
  87. }
  88. }
  89. bool showMetadataTokensInBase10;
  90. public bool ShowMetadataTokensInBase10 {
  91. get { return showMetadataTokensInBase10; }
  92. set {
  93. if (showMetadataTokensInBase10 != value) {
  94. showMetadataTokensInBase10 = value;
  95. OnPropertyChanged();
  96. }
  97. }
  98. }
  99. bool enableWordWrap;
  100. public bool EnableWordWrap
  101. {
  102. get { return enableWordWrap; }
  103. set
  104. {
  105. if (enableWordWrap != value) {
  106. enableWordWrap = value;
  107. OnPropertyChanged();
  108. }
  109. }
  110. }
  111. bool sortResults = true;
  112. public bool SortResults {
  113. get { return sortResults; }
  114. set {
  115. if (sortResults != value) {
  116. sortResults = value;
  117. OnPropertyChanged();
  118. }
  119. }
  120. }
  121. bool foldBraces = false;
  122. public bool FoldBraces {
  123. get { return foldBraces; }
  124. set {
  125. if (foldBraces != value) {
  126. foldBraces = value;
  127. OnPropertyChanged();
  128. }
  129. }
  130. }
  131. bool expandMemberDefinitions = false;
  132. public bool ExpandMemberDefinitions {
  133. get { return expandMemberDefinitions; }
  134. set {
  135. if (expandMemberDefinitions != value) {
  136. expandMemberDefinitions = value;
  137. OnPropertyChanged();
  138. }
  139. }
  140. }
  141. bool expandUsingDeclarations = false;
  142. public bool ExpandUsingDeclarations {
  143. get { return expandUsingDeclarations; }
  144. set {
  145. if (expandUsingDeclarations != value) {
  146. expandUsingDeclarations = value;
  147. OnPropertyChanged();
  148. }
  149. }
  150. }
  151. bool showDebugInfo;
  152. public bool ShowDebugInfo {
  153. get { return showDebugInfo; }
  154. set {
  155. if (showDebugInfo != value) {
  156. showDebugInfo = value;
  157. OnPropertyChanged();
  158. }
  159. }
  160. }
  161. bool indentationUseTabs = true;
  162. public bool IndentationUseTabs {
  163. get { return indentationUseTabs; }
  164. set {
  165. if (indentationUseTabs != value) {
  166. indentationUseTabs = value;
  167. OnPropertyChanged();
  168. }
  169. }
  170. }
  171. int indentationTabSize = 4;
  172. public int IndentationTabSize {
  173. get { return indentationTabSize; }
  174. set {
  175. if (indentationTabSize != value) {
  176. indentationTabSize = value;
  177. OnPropertyChanged();
  178. }
  179. }
  180. }
  181. int indentationSize = 4;
  182. public int IndentationSize {
  183. get { return indentationSize; }
  184. set {
  185. if (indentationSize != value) {
  186. indentationSize = value;
  187. OnPropertyChanged();
  188. }
  189. }
  190. }
  191. bool highlightMatchingBraces = true;
  192. public bool HighlightMatchingBraces {
  193. get { return highlightMatchingBraces; }
  194. set {
  195. if (highlightMatchingBraces != value) {
  196. highlightMatchingBraces = value;
  197. OnPropertyChanged();
  198. }
  199. }
  200. }
  201. bool hideEmptyMetadataTables = true;
  202. public bool HideEmptyMetadataTables {
  203. get { return hideEmptyMetadataTables; }
  204. set {
  205. if (hideEmptyMetadataTables != value) {
  206. hideEmptyMetadataTables = value;
  207. OnPropertyChanged();
  208. }
  209. }
  210. }
  211. public void CopyValues(DisplaySettings s)
  212. {
  213. this.SelectedFont = s.selectedFont;
  214. this.SelectedFontSize = s.selectedFontSize;
  215. this.ShowLineNumbers = s.showLineNumbers;
  216. this.ShowMetadataTokens = s.showMetadataTokens;
  217. this.ShowMetadataTokensInBase10 = s.showMetadataTokensInBase10;
  218. this.ShowDebugInfo = s.showDebugInfo;
  219. this.EnableWordWrap = s.enableWordWrap;
  220. this.SortResults = s.sortResults;
  221. this.FoldBraces = s.foldBraces;
  222. this.ExpandMemberDefinitions = s.expandMemberDefinitions;
  223. this.ExpandUsingDeclarations = s.expandUsingDeclarations;
  224. this.IndentationUseTabs = s.indentationUseTabs;
  225. this.IndentationTabSize = s.indentationTabSize;
  226. this.IndentationSize = s.indentationSize;
  227. this.HighlightMatchingBraces = s.highlightMatchingBraces;
  228. this.HideEmptyMetadataTables = s.HideEmptyMetadataTables;
  229. }
  230. }
  231. }