Exemplo n.º 1
0
            /*
             *          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);
                    _textArea.TextView.Services.RemoveService(typeof(FoldingManager));
                    _margin    = null;
                    _generator = null;
                    _textArea  = null;
                }
            }
Exemplo n.º 2
0
 public FoldingManagerInstallation(TextArea textArea) : base(textArea.Document)
 {
     _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;
 }