PageRenderTime 12ms CodeModel.GetById 8ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/AvalonEdit/Documentation/Folding.aml

http://github.com/icsharpcode/ILSpy
Unknown | 58 lines | 58 code | 0 blank | 0 comment | 0 complexity | 3c7446d4e339e1b7422137e6e7d680b4 MD5 | raw file
 1<?xml version="1.0" encoding="utf-8"?>
 2<topic id="440df648-413e-4f42-a28b-6b2b0e9b1084" revisionNumber="1">
 3  <developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
 4    <!--<introduction>
 5      <para>
 6			Introduction for 'Folding'.
 7		</para>
 8    </introduction>-->
 9    <section>
10      <title>How to use Folding in your application</title>
11      <content>
12        <para>
13        Folding (code collapsing) is implemented as an extension to the editor.
14        It could have been implemented in a separate assembly without having to
15        modify the AvalonEdit code. 
16        A <codeEntityReference>T:ICSharpCode.AvalonEdit.Rendering.VisualLineElementGenerator</codeEntityReference>
17        takes care of the collapsed sections in the text document; and a custom
18        margin draws the plus and minus buttons.
19		</para>
20		<para>You could use the relevant classes separately;
21		but, to make it a bit easier to use, the static
22		<codeEntityReference qualifyHint="true">M:ICSharpCode.AvalonEdit.Folding.FoldingManager.Install(ICSharpCode.AvalonEdit.Editing.TextArea)</codeEntityReference>
23		method will create and register the necessary parts automatically.</para>
24		<para>All that's left for you is to regularly call
25		<codeEntityReference qualifyHint="true">M:ICSharpCode.AvalonEdit.Folding.FoldingManager.UpdateFoldings(System.Collections.Generic.IEnumerable{ICSharpCode.AvalonEdit.Folding.NewFolding},System.Int32)</codeEntityReference>
26		with the list of foldings you want to provide.
27		You could calculate that list yourself, or you could use a built-in
28		folding strategy to do it for you.</para>
29		<para>Here is the full code required to enable folding: 
30<code language="cs">foldingManager = FoldingManager.Install(textEditor.TextArea);
31foldingStrategy = new XmlFoldingStrategy();
32foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document);</code>
33		If you want the folding markers to update when the text is changed,
34		you have to repeat the <codeInline>foldingStrategy.UpdateFoldings</codeInline> call regularly.
35		</para>
36      </content>
37    </section>
38    <section>
39      <title>How the FoldingManager works</title>
40      <content>
41        <para>
42	The FoldingManager maintains a list of foldings. The FoldMargin displays those foldings and provides
43	the UI for collapsing/expanding.</para><para>
44	Folded foldings cause the FoldingElementGenerator to produce a line element that spans the whole folded
45	text section, causing the text generation for the visual line that contains the folding start to
46	continue after the folding end in another line.</para><para>
47	To ensure scrolling works correctly in the presence of foldings, lines inside folded regions must not
48	be used as start lines for the visual line generation. This is done by setting the line height of all
49	such lines to 0. To efficiently set the height on a large number of lines and support reverting to the
50	old height when the folding is uncollapsed, a CollapsedLineSection is used.
51			</para>
52      </content>
53    </section>
54    <relatedTopics>
55      <codeEntityReference>T:ICSharpCode.AvalonEdit.Folding.FoldingManager</codeEntityReference>
56    </relatedTopics>
57  </developerConceptualDocument>
58</topic>