예제 #1
0
 public BoundActiveElement(InsertionContext context, SnippetReplaceableTextElement targetSnippetElement, SnippetBoundElement boundElement, AnchorSegment segment)
 {
     _context = context;
     _targetSnippetElement = targetSnippetElement;
     _boundElement         = boundElement;
     _segment = segment;
 }
예제 #2
0
        /// <summary>
        /// Adds existing segments as snippet elements.
        /// </summary>
        public void Link(ISegment mainElement, ISegment[] boundElements)
        {
            var main = new SnippetReplaceableTextElement {
                Text = Document.GetText(mainElement)
            };

            RegisterActiveElement(main, new ReplaceableActiveElement(this, mainElement.Offset, mainElement.EndOffset));
            foreach (var boundElement in boundElements)
            {
                var bound = new SnippetBoundElement {
                    TargetElement = main
                };
                var start = Document.CreateAnchor(boundElement.Offset);
                start.MovementType    = AnchorMovementType.BeforeInsertion;
                start.SurviveDeletion = true;
                var end = Document.CreateAnchor(boundElement.EndOffset);
                end.MovementType    = AnchorMovementType.BeforeInsertion;
                end.SurviveDeletion = true;

                RegisterActiveElement(bound, new BoundActiveElement(this, main, bound, new AnchorSegment(start, end)));
            }
        }