/AvalonEdit/ICSharpCode.AvalonEdit/Folding/NewFolding.cs

http://github.com/icsharpcode/ILSpy · C# · 87 lines · 35 code · 10 blank · 42 comment · 1 complexity · dda27c537b0ae3b48b265edf851a263d MD5 · raw file

  1. // Copyright (c) 2014 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;
  19. #if NREFACTORY
  20. using ICSharpCode.NRefactory.Editor;
  21. #else
  22. using ICSharpCode.AvalonEdit.Document;
  23. #endif
  24. namespace ICSharpCode.AvalonEdit.Folding
  25. {
  26. /// <summary>
  27. /// Helper class used for <see cref="FoldingManager.UpdateFoldings"/>.
  28. /// </summary>
  29. public class NewFolding : ISegment
  30. {
  31. /// <summary>
  32. /// Gets/Sets the start offset.
  33. /// </summary>
  34. public int StartOffset { get; set; }
  35. /// <summary>
  36. /// Gets/Sets the end offset.
  37. /// </summary>
  38. public int EndOffset { get; set; }
  39. /// <summary>
  40. /// Gets/Sets the name displayed for the folding.
  41. /// </summary>
  42. public string Name { get; set; }
  43. /// <summary>
  44. /// Gets/Sets whether the folding is closed by default.
  45. /// </summary>
  46. public bool DefaultClosed { get; set; }
  47. /// <summary>
  48. /// Gets/Sets whether the folding is considered to be a definition.
  49. /// This has an effect on the 'Show Definitions only' command.
  50. /// </summary>
  51. public bool IsDefinition { get; set; }
  52. /// <summary>
  53. /// Creates a new NewFolding instance.
  54. /// </summary>
  55. public NewFolding()
  56. {
  57. }
  58. /// <summary>
  59. /// Creates a new NewFolding instance.
  60. /// </summary>
  61. public NewFolding(int start, int end)
  62. {
  63. if (!(start <= end))
  64. throw new ArgumentException("'start' must be less than 'end'");
  65. this.StartOffset = start;
  66. this.EndOffset = end;
  67. this.Name = null;
  68. this.DefaultClosed = false;
  69. }
  70. int ISegment.Offset {
  71. get { return this.StartOffset; }
  72. }
  73. int ISegment.Length {
  74. get { return this.EndOffset - this.StartOffset; }
  75. }
  76. }
  77. }