Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Rendering/CollapsedLineSection.cs @ 17246

Last change on this file since 17246 was 11700, checked in by jkarder, 10 years ago

#2077: created branch and added first version

File size: 3.4 KB
Line 
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
19using System;
20using System.ComponentModel;
21using ICSharpCode.AvalonEdit.Document;
22
23namespace ICSharpCode.AvalonEdit.Rendering
24{
25  /// <summary>
26  /// Represents a collapsed line section.
27  /// Use the Uncollapse() method to uncollapse the section.
28  /// </summary>
29  public sealed class CollapsedLineSection
30  {
31    DocumentLine start, end;
32    HeightTree heightTree;
33   
34    #if DEBUG
35    internal string ID;
36    static int nextId;
37    #else
38    const string ID = "";
39    #endif
40   
41    internal CollapsedLineSection(HeightTree heightTree, DocumentLine start, DocumentLine end)
42    {
43      this.heightTree = heightTree;
44      this.start = start;
45      this.end = end;
46      #if DEBUG
47      unchecked {
48        this.ID = " #" + (nextId++);
49      }
50      #endif
51    }
52   
53    /// <summary>
54    /// Gets if the document line is collapsed.
55    /// This property initially is true and turns to false when uncollapsing the section.
56    /// </summary>
57    public bool IsCollapsed {
58      get { return start != null; }
59    }
60   
61    /// <summary>
62    /// Gets the start line of the section.
63    /// When the section is uncollapsed or the text containing it is deleted,
64    /// this property returns null.
65    /// </summary>
66    public DocumentLine Start {
67      get { return start; }
68      internal set { start = value; }
69    }
70   
71    /// <summary>
72    /// Gets the end line of the section.
73    /// When the section is uncollapsed or the text containing it is deleted,
74    /// this property returns null.
75    /// </summary>
76    public DocumentLine End {
77      get { return end; }
78      internal set { end = value; }
79    }
80   
81    /// <summary>
82    /// Uncollapses the section.
83    /// This causes the Start and End properties to be set to null!
84    /// Does nothing if the section is already uncollapsed.
85    /// </summary>
86    public void Uncollapse()
87    {
88      if (start == null)
89        return;
90     
91      heightTree.Uncollapse(this);
92      #if DEBUG
93      heightTree.CheckProperties();
94      #endif
95     
96      start = null;
97      end = null;
98    }
99   
100    /// <summary>
101    /// Gets a string representation of the collapsed section.
102    /// </summary>
103    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.Int32.ToString")]
104    public override string ToString()
105    {
106      return "[CollapsedSection" + ID + " Start=" + (start != null ? start.LineNumber.ToString() : "null")
107        + " End=" + (end != null ? end.LineNumber.ToString() : "null") + "]";
108    }
109  }
110}
Note: See TracBrowser for help on using the repository browser.