Beispiel #1
0
        public void RaiseInsertionCompleted(EventArgs e)
        {
            if (currentStatus != Status.Insertion)
            {
                throw new InvalidOperationException();
            }
            if (e == null)
            {
                e = EventArgs.Empty;
            }

            currentStatus = Status.RaisingInsertionCompleted;
            int endPosition = this.InsertionPosition;

            this.wholeSnippetAnchor = new AnchorSegment(Document, startPosition, endPosition - startPosition);
            TextDocumentWeakEventManager.UpdateFinished.AddListener(Document, this);
            deactivateIfSnippetEmpty = (endPosition != startPosition);

            foreach (IActiveElement element in registeredElements)
            {
                element.OnInsertionCompleted();
            }
            if (InsertionCompleted != null)
            {
                InsertionCompleted(this, e);
            }
            currentStatus = Status.Interactive;
            if (registeredElements.Count == 0)
            {
                // deactivate immediately if there are no interactive elements
                Deactivate(new SnippetEventArgs(DeactivateReason.NoActiveElements));
            }
            else
            {
                myInputHandler = new SnippetInputHandler(this);
                // disable existing snippet input handlers - there can be only 1 active snippet
                foreach (TextAreaStackedInputHandler h in TextArea.StackedInputHandlers)
                {
                    if (h is SnippetInputHandler)
                    {
                        TextArea.PopStackedInputHandler(h);
                    }
                }
                TextArea.PushStackedInputHandler(myInputHandler);
            }
        }
Beispiel #2
0
		public void RaiseInsertionCompleted(EventArgs e)
		{
			if (currentStatus != Status.Insertion)
				throw new InvalidOperationException();
			if (e == null)
				e = EventArgs.Empty;
			
			currentStatus = Status.RaisingInsertionCompleted;
			int endPosition = this.InsertionPosition;
			this.wholeSnippetAnchor = new AnchorSegment(Document, startPosition, endPosition - startPosition);
			TextDocumentWeakEventManager.UpdateFinished.AddListener(Document, this);
			deactivateIfSnippetEmpty = (endPosition != startPosition);
			
			foreach (IActiveElement element in registeredElements) {
				element.OnInsertionCompleted();
			}
			if (InsertionCompleted != null)
				InsertionCompleted(this, e);
			currentStatus = Status.Interactive;
			if (registeredElements.Count == 0) {
				// deactivate immediately if there are no interactive elements
				Deactivate(new SnippetEventArgs(DeactivateReason.NoActiveElements));
			} else {
				myInputHandler = new SnippetInputHandler(this);
				// disable existing snippet input handlers - there can be only 1 active snippet
				foreach (TextAreaStackedInputHandler h in TextArea.StackedInputHandlers) {
					if (h is SnippetInputHandler)
						TextArea.PopStackedInputHandler(h);
				}
				TextArea.PushStackedInputHandler(myInputHandler);
			}
		}