Пример #1
0
        /// <summary>
        /// Handler called every time a comment is changed in the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected virtual void OnCommentChanged(WriteableChangeCommentOperation operation)
        {
            IWriteableNodeState State = operation.State;

            Debug.Assert(State != null);
            Debug.Assert(StateViewTable.ContainsKey(State));
        }
Пример #2
0
        private protected virtual void UndoChangeComment(IWriteableOperation operation)
        {
            WriteableChangeCommentOperation ChangeCommentOperation = (WriteableChangeCommentOperation)operation;

            ChangeCommentOperation = ChangeCommentOperation.ToInverseChange();

            ExecuteChangeComment(ChangeCommentOperation);
        }
Пример #3
0
        /// <summary>
        /// Changes the value of a text.
        /// </summary>
        /// <param name="nodeIndex">Index of the state with the comment to change.</param>
        /// <param name="text">The new comment.</param>
        public virtual void ChangeComment(IWriteableIndex nodeIndex, string text)
        {
            Contract.RequireNotNull(nodeIndex, out IWriteableIndex NodeIndex);
            Debug.Assert(StateTable.ContainsKey(NodeIndex));
            Contract.RequireNotNull(text, out string Text);

            System.Action <IWriteableOperation> HandlerRedo = (IWriteableOperation operation) => RedoChangeComment(operation);
            System.Action <IWriteableOperation> HandlerUndo = (IWriteableOperation operation) => UndoChangeComment(operation);
            IWriteableNodeState             State           = (IWriteableNodeState)StateTable[NodeIndex];
            WriteableChangeCommentOperation Operation       = CreateChangeCommentOperation(State.Node, Text, HandlerRedo, HandlerUndo, isNested: false);

            Operation.Redo();
            SetLastOperation(Operation);
            CheckInvariant();
        }
Пример #4
0
        private protected virtual void ExecuteChangeComment(WriteableChangeCommentOperation operation)
        {
            Node   ParentNode = operation.ParentNode;
            string NewText    = operation.NewText;

            IWriteableNodeState State = (IWriteableNodeState)GetState(ParentNode);

            Debug.Assert(State != null);

            string OldText = NodeTreeHelper.GetCommentText(State.Node);

            Debug.Assert(OldText != null);

            CommentHelper.Set(State.Node.Documentation, NewText);

            operation.Update(State, OldText);

            NotifyCommentChanged(operation);
        }
Пример #5
0
 private protected virtual void NotifyCommentChanged(WriteableChangeCommentOperation operation)
 {
     CommentChangedHandler?.Invoke(operation);
 }
Пример #6
0
        private protected virtual void RedoChangeComment(IWriteableOperation operation)
        {
            WriteableChangeCommentOperation ChangeCommentOperation = (WriteableChangeCommentOperation)operation;

            ExecuteChangeComment(ChangeCommentOperation);
        }