public FoldingManagerInstallation(TextArea textArea) : base(textArea.Document) { this.textArea = textArea; margin = new FoldingMargin() { FoldingManager = this }; generator = new FoldingElementGenerator() { FoldingManager = this }; textArea.LeftMargins.Add(margin); textArea.TextView.Services.AddService(typeof(FoldingManager), this); // HACK: folding only works correctly when it has highest priority textArea.TextView.ElementGenerators.Insert(0, generator); textArea.Caret.PositionChanged += textArea_Caret_PositionChanged; }
/* * void DemoMode() * { * foldingGenerator = new FoldingElementGenerator() { FoldingManager = fm }; * foldingMargin = new FoldingMargin { FoldingManager = fm }; * foldingMarginBorder = new Border { * Child = foldingMargin, * Background = new LinearGradientBrush(Colors.White, Colors.Transparent, 0) * }; * foldingMarginBorder.SizeChanged += UpdateTextViewClip; * textEditor.TextArea.TextView.ElementGenerators.Add(foldingGenerator); * textEditor.TextArea.LeftMargins.Add(foldingMarginBorder); * } * * void UpdateTextViewClip(object sender, SizeChangedEventArgs e) * { * textEditor.TextArea.TextView.Clip = new RectangleGeometry( * new Rect(-foldingMarginBorder.ActualWidth, * 0, * textEditor.TextArea.TextView.ActualWidth + foldingMarginBorder.ActualWidth, * textEditor.TextArea.TextView.ActualHeight)); * } */ public void Uninstall() { Clear(); if (textArea != null) { textArea.Caret.PositionChanged -= textArea_Caret_PositionChanged; textArea.LeftMargins.Remove(margin); textArea.TextView.ElementGenerators.Remove(generator); margin = null; generator = null; textArea = null; } }
public FoldingManagerInstallation(TextArea textArea) : base(textArea.TextView, textArea.Document) { this.textArea = textArea; margin = new FoldingMargin() { FoldingManager = this }; generator = new FoldingElementGenerator() { FoldingManager = this }; textArea.LeftMargins.Add(margin); textArea.TextView.ElementGenerators.Add(generator); textArea.Caret.PositionChanged += textArea_Caret_PositionChanged; }