/// <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)); }
private protected virtual void UndoChangeComment(IWriteableOperation operation) { WriteableChangeCommentOperation ChangeCommentOperation = (WriteableChangeCommentOperation)operation; ChangeCommentOperation = ChangeCommentOperation.ToInverseChange(); ExecuteChangeComment(ChangeCommentOperation); }
/// <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(); }
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); }
private protected virtual void NotifyCommentChanged(WriteableChangeCommentOperation operation) { CommentChangedHandler?.Invoke(operation); }
private protected virtual void RedoChangeComment(IWriteableOperation operation) { WriteableChangeCommentOperation ChangeCommentOperation = (WriteableChangeCommentOperation)operation; ExecuteChangeComment(ChangeCommentOperation); }