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

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

            ChangeTextOperation = ChangeTextOperation.ToInverseChange();

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

            System.Action <IWriteableOperation> HandlerRedo = (IWriteableOperation operation) => RedoChangeText(operation);
            System.Action <IWriteableOperation> HandlerUndo = (IWriteableOperation operation) => UndoChangeText(operation);
            IWriteableNodeState          State     = (IWriteableNodeState)StateTable[NodeIndex];
            WriteableChangeTextOperation Operation = CreateChangeTextOperation(State.Node, propertyName, Text, HandlerRedo, HandlerUndo, isNested: false);

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

            IWriteableNodeState State = (IWriteableNodeState)GetState(ParentNode);

            Debug.Assert(State != null);
            Debug.Assert(State.ValuePropertyTypeTable.ContainsKey(PropertyName));
            Debug.Assert(State.ValuePropertyTypeTable[PropertyName] == Constants.ValuePropertyType.String);

            string OldText = NodeTreeHelper.GetString(State.Node, PropertyName);

            Debug.Assert(OldText != null);

            NodeTreeHelper.SetString(State.Node, PropertyName, NewText);

            operation.Update(State, OldText);

            NotifyTextChanged(operation);
        }
Пример #5
0
 private protected virtual void NotifyTextChanged(WriteableChangeTextOperation operation)
 {
     TextChangedHandler?.Invoke(operation);
 }
Пример #6
0
        private protected virtual void RedoChangeText(IWriteableOperation operation)
        {
            WriteableChangeTextOperation ChangeTextOperation = (WriteableChangeTextOperation)operation;

            ExecuteChangeText(ChangeTextOperation);
        }