Beispiel #1
0
        /// <summary>
        /// Handler called every time a state is removed in the controller.
        /// </summary>
        /// <param name="state">The state removed.</param>
        public virtual void OnNodeStateRemoved(IReadOnlyNodeState state)
        {
            Debug.Assert(state != null);
            Debug.Assert(StateViewTable.ContainsKey(state));

            StateViewTable.Remove(state);
        }
Beispiel #2
0
        /// <summary>
        /// Handler called every time a state is initialized in the controller.
        /// </summary>
        /// <param name="state">The state initialized.</param>
        public virtual void OnNodeStateInitialized(IReadOnlyNodeState state)
        {
            Contract.RequireNotNull(state, out IReadOnlyNodeState State);
            Debug.Assert(StateViewTable.ContainsKey(State));

            IReadOnlyNodeStateView StateView = StateViewTable[State];
        }
Beispiel #3
0
        /// <summary>
        /// Handler called every time a state is removed in the controller.
        /// </summary>
        /// <param name="state">The state removed.</param>
        public virtual void OnNodeStateRemoved(IReadOnlyNodeState state)
        {
            Contract.RequireNotNull(state, out IReadOnlyNodeState State);
            Debug.Assert(StateViewTable.ContainsKey(State));

            StateViewTable.Remove(State);
        }
Beispiel #4
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));
        }
        /// <summary>
        /// Handler called every time a comment is changed in the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected override void OnCommentChanged(WriteableChangeCommentOperation operation)
        {
            bool IsSameFocus           = IsSameChangeCommentOperationFocus((FocusChangeCommentOperation)operation);
            int  NewCaretPosition      = ((IFocusChangeCaretOperation)operation).NewCaretPosition;
            bool ChangeCaretBeforeText = ((IFocusChangeCaretOperation)operation).ChangeCaretBeforeText;

            if (IsSameFocus && NewCaretPosition >= 0 && ChangeCaretBeforeText)
            {
                CaretPosition = NewCaretPosition;
            }

            base.OnCommentChanged(operation);

            if (IsSameFocus && NewCaretPosition >= 0 && !ChangeCaretBeforeText)
            {
                CaretPosition = NewCaretPosition;
            }

            IFocusNodeState State = ((FocusChangeCommentOperation)operation).State;

            Debug.Assert(State != null);
            Debug.Assert(StateViewTable.ContainsKey(State));

            ResetSelection();
            CheckCaretInvariant();
        }
Beispiel #6
0
        /// <summary>
        /// Handler called every time a state is removed from the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected virtual void OnStateRemoved(WriteableRemoveNodeOperation operation)
        {
            IWriteablePlaceholderNodeState RemovedState = operation.RemovedState;

            Debug.Assert(RemovedState != null);
            Debug.Assert(!StateViewTable.ContainsKey(RemovedState));
        }
Beispiel #7
0
        /// <summary>
        /// Handler called every time a state is created in the controller.
        /// </summary>
        /// <param name="state">The state created.</param>
        public virtual void OnNodeStateCreated(IReadOnlyNodeState state)
        {
            Debug.Assert(state != null);
            Debug.Assert(!StateViewTable.ContainsKey(state));

            IReadOnlyNodeStateView StateView = null;

            switch (state)
            {
            case IReadOnlyPatternState AsPatternState:
                StateView = CreatePatternStateView(AsPatternState);
                break;

            case IReadOnlySourceState AsSourceState:
                StateView = CreateSourceStateView(AsSourceState);
                break;

            case IReadOnlyPlaceholderNodeState AsPlaceholderState:
                StateView = CreatePlaceholderNodeStateView(AsPlaceholderState);
                break;

            case IReadOnlyOptionalNodeState AsOptionalState:
                StateView = CreateOptionalNodeStateView(AsOptionalState);
                break;
            }

            Debug.Assert(StateView != null);

            StateViewTable.Add(state, StateView);
        }
Beispiel #8
0
        /// <summary>
        /// Handler called every time a state is unassigned in the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected virtual void OnStateUnassigned(WriteableAssignmentOperation operation)
        {
            IWriteableOptionalNodeState State = operation.State;

            Debug.Assert(State != null);
            Debug.Assert(StateViewTable.ContainsKey(State));
        }
        /// <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(IWriteableChangeTextOperation operation)
        {
            Debug.Assert(operation != null);

            IWriteableNodeState State = operation.State;

            Debug.Assert(State != null);
            Debug.Assert(StateViewTable.ContainsKey(State));
        }
Beispiel #10
0
        /// <summary>
        /// Handler called to refresh views.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected virtual void OnGenericRefresh(WriteableGenericRefreshOperation operation)
        {
            Debug.Assert(!operation.IsNested);

            IWriteableNodeState RefreshState = operation.RefreshState;

            Debug.Assert(RefreshState != null);
            Debug.Assert(StateViewTable.ContainsKey(RefreshState));
        }
        /// <summary>
        /// Handler called every time a state is moved in the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected override void OnStateMoved(WriteableMoveNodeOperation operation)
        {
            base.OnStateMoved(operation);

            IFocusPlaceholderNodeState State = ((FocusMoveNodeOperation)operation).State;

            Debug.Assert(State != null);
            Debug.Assert(StateViewTable.ContainsKey(State));
        }
        /// <summary>
        /// Handler called every time a discrete value is changed in the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected override void OnDiscreteValueChanged(WriteableChangeDiscreteValueOperation operation)
        {
            base.OnDiscreteValueChanged(operation);

            IFocusNodeState State = ((FocusChangeDiscreteValueOperation)operation).State;

            Debug.Assert(State != null);
            Debug.Assert(StateViewTable.ContainsKey(State));
        }
        /// <summary>
        /// Handler called every time a state is unassigned in the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected override void OnStateUnassigned(WriteableAssignmentOperation operation)
        {
            base.OnStateUnassigned(operation);

            IFocusOptionalNodeState State = ((FocusAssignmentOperation)operation).State;

            Debug.Assert(State != null);
            Debug.Assert(StateViewTable.ContainsKey(State));
        }
Beispiel #14
0
        /// <summary>
        /// Handler called every time a state is initialized in the controller.
        /// </summary>
        /// <param name="state">The state initialized.</param>
        public virtual void OnNodeStateInitialized(IReadOnlyNodeState state)
        {
            Debug.Assert(state != null);
            Debug.Assert(StateViewTable.ContainsKey(state));

            IReadOnlyNodeStateView StateView = StateViewTable[state];

            Debug.Assert(StateView.ToString() != null); // For code coverage.
        }
        /// <summary>
        /// Handler called every time a comment is changed in the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected override void OnCommentChanged(WriteableChangeCommentOperation operation)
        {
            base.OnCommentChanged(operation);

            ILayoutNodeState State = ((LayoutChangeCommentOperation)operation).State;

            Debug.Assert(State != null);
            Debug.Assert(StateViewTable.ContainsKey(State));
        }
        /// <summary>
        /// Handler called every time a state is removed from the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected override void OnStateRemoved(WriteableRemoveNodeOperation operation)
        {
            base.OnStateRemoved(operation);

            ILayoutPlaceholderNodeState RemovedState = ((LayoutRemoveNodeOperation)operation).RemovedState;

            Debug.Assert(RemovedState != null);
            Debug.Assert(!StateViewTable.ContainsKey(RemovedState));
        }
Beispiel #17
0
        /// <summary>
        /// Handler called every time a state is moved in the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected virtual void OnStateMoved(WriteableMoveNodeOperation operation)
        {
            Debug.Assert(!operation.IsNested);

            IWriteablePlaceholderNodeState State = operation.State;

            Debug.Assert(State != null);
            Debug.Assert(StateViewTable.ContainsKey(State));
        }
        /// <summary>
        /// Handler called to refresh views.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected override void OnGenericRefresh(WriteableGenericRefreshOperation operation)
        {
            base.OnGenericRefresh(operation);

            IFocusNodeState RefreshState = ((FocusGenericRefreshOperation)operation).RefreshState;

            Debug.Assert(RefreshState != null);
            Debug.Assert(StateViewTable.ContainsKey(RefreshState));
        }
Beispiel #19
0
        private protected virtual bool IsLastFocusableCellView(IFocusNodeState state, IFocusContentFocusableCellView cellView)
        {
            Debug.Assert(StateViewTable.ContainsKey(state));

            IFocusNodeStateView StateView = (IFocusNodeStateView)StateViewTable[state];

            StateView.RootCellView.EnumerateVisibleCellViews(GetLastFocusable, out IFrameVisibleCellView FirstCellView, reversed: true);
            return(FirstCellView == cellView);
        }
Beispiel #20
0
        /// <summary>
        /// Handler called every time a state is inserted in the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected virtual void OnStateInserted(WriteableInsertNodeOperation operation)
        {
            IWriteableNodeState ChildState = operation.ChildState;

            Debug.Assert(ChildState != null);
            Debug.Assert(StateViewTable.ContainsKey(ChildState));

            IWriteableBrowsingCollectionNodeIndex BrowsingIndex = operation.BrowsingIndex;

            Debug.Assert(ChildState.ParentIndex == BrowsingIndex);
        }
        /// <summary>
        /// Handler called every time a state is inserted in the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected override void OnStateInserted(WriteableInsertNodeOperation operation)
        {
            base.OnStateInserted(operation);

            ILayoutNodeState ChildState = ((LayoutInsertNodeOperation)operation).ChildState;

            Debug.Assert(ChildState != null);
            Debug.Assert(StateViewTable.ContainsKey(ChildState));

            ILayoutBrowsingCollectionNodeIndex BrowsingIndex = ((LayoutInsertNodeOperation)operation).BrowsingIndex;

            Debug.Assert(ChildState.ParentIndex == BrowsingIndex);
        }
Beispiel #22
0
        /// <summary>
        /// Handler called every time a block view must be removed from the controller view.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected virtual void OnBlockViewRemoved(WriteableRemoveBlockViewOperation operation)
        {
            IWriteableBlockState BlockState = operation.BlockState;

            Debug.Assert(BlockState != null);
            Debug.Assert(!BlockStateViewTable.ContainsKey(BlockState));

            Debug.Assert(!StateViewTable.ContainsKey(BlockState.PatternState));
            Debug.Assert(!StateViewTable.ContainsKey(BlockState.SourceState));

            foreach (IWriteableNodeState State in BlockState.StateList)
            {
                Debug.Assert(!StateViewTable.ContainsKey(State));
            }
        }
Beispiel #23
0
        /// <summary>
        /// Handler called every time a block state is removed from the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected virtual void OnBlockStateRemoved(IWriteableRemoveBlockOperation operation)
        {
            IWriteableBlockState BlockState = operation.BlockState;

            Debug.Assert(BlockState != null);
            Debug.Assert(!BlockStateViewTable.ContainsKey(BlockState));

            Debug.Assert(!StateViewTable.ContainsKey(BlockState.PatternState));
            Debug.Assert(!StateViewTable.ContainsKey(BlockState.SourceState));

            IWriteableNodeState RemovedState = operation.RemovedState;

            Debug.Assert(!StateViewTable.ContainsKey(RemovedState));

            Debug.Assert(BlockState.StateList.Count == 0);
        }
Beispiel #24
0
        /// <summary>
        /// Handler called every time a state is replaced in the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected virtual void OnStateReplaced(IWriteableReplaceOperation operation)
        {
            IWriteableNodeState NewChildState = operation.NewChildState;

            Debug.Assert(NewChildState != null);
            Debug.Assert(StateViewTable.ContainsKey(NewChildState));

            IWriteableBrowsingChildIndex OldBrowsingIndex = operation.OldBrowsingIndex;

            Debug.Assert(OldBrowsingIndex != null);
            Debug.Assert(NewChildState.ParentIndex != OldBrowsingIndex);

            IWriteableBrowsingChildIndex NewBrowsingIndex = operation.NewBrowsingIndex;

            Debug.Assert(NewBrowsingIndex != null);
            Debug.Assert(NewChildState.ParentIndex == NewBrowsingIndex);
        }
        /// <summary>
        /// Handler called every time a block view must be removed from the controller view.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected override void OnBlockViewRemoved(WriteableRemoveBlockViewOperation operation)
        {
            base.OnBlockViewRemoved(operation);

            IFocusBlockState BlockState = ((FocusRemoveBlockViewOperation)operation).BlockState;

            Debug.Assert(BlockState != null);
            Debug.Assert(!BlockStateViewTable.ContainsKey(BlockState));

            Debug.Assert(!StateViewTable.ContainsKey(BlockState.PatternState));
            Debug.Assert(!StateViewTable.ContainsKey(BlockState.SourceState));

            foreach (IFocusNodeState State in BlockState.StateList)
            {
                Debug.Assert(!StateViewTable.ContainsKey(State));
            }
        }
        /// <summary>
        /// Handler called every time a block state is removed from the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected override void OnBlockStateRemoved(IWriteableRemoveBlockOperation operation)
        {
            base.OnBlockStateRemoved(operation);

            IFocusBlockState BlockState = ((IFocusRemoveBlockOperation)operation).BlockState;

            Debug.Assert(BlockState != null);
            Debug.Assert(!BlockStateViewTable.ContainsKey(BlockState));

            Debug.Assert(!StateViewTable.ContainsKey(BlockState.PatternState));
            Debug.Assert(!StateViewTable.ContainsKey(BlockState.SourceState));

            IFocusNodeState RemovedState = ((IFocusRemoveBlockOperation)operation).RemovedState;

            Debug.Assert(!StateViewTable.ContainsKey(RemovedState));

            Debug.Assert(BlockState.StateList.Count == 0);
        }
Beispiel #27
0
        /// <summary>
        /// Handler called every time a block state is inserted in the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected virtual void OnBlockStateInserted(IWriteableInsertBlockOperation operation)
        {
            IWriteableBlockState BlockState = operation.BlockState;

            Debug.Assert(BlockState != null);
            Debug.Assert(BlockStateViewTable.ContainsKey(BlockState));

            Debug.Assert(StateViewTable.ContainsKey(BlockState.PatternState));
            Debug.Assert(StateViewTable.ContainsKey(BlockState.SourceState));

            Debug.Assert(BlockState.StateList.Count == 1);

            IWriteablePlaceholderNodeState ChildState = operation.ChildState;

            Debug.Assert(ChildState == BlockState.StateList[0]);
            Debug.Assert(ChildState.ParentIndex == operation.BrowsingIndex);
            Debug.Assert(StateViewTable.ContainsKey(ChildState));
        }
        /// <summary>
        /// Handler called every time a state is inserted in the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected override void OnStateReplaced(IWriteableReplaceOperation operation)
        {
            base.OnStateReplaced(operation);

            IFocusNodeState NewChildState = ((IFocusReplaceOperation)operation).NewChildState;

            Debug.Assert(NewChildState != null);
            Debug.Assert(StateViewTable.ContainsKey(NewChildState));

            IFocusBrowsingChildIndex OldBrowsingIndex = ((IFocusReplaceOperation)operation).OldBrowsingIndex;

            Debug.Assert(OldBrowsingIndex != null);
            Debug.Assert(NewChildState.ParentIndex != OldBrowsingIndex);

            IFocusBrowsingChildIndex NewBrowsingIndex = ((IFocusReplaceOperation)operation).NewBrowsingIndex;

            Debug.Assert(NewBrowsingIndex != null);
            Debug.Assert(NewChildState.ParentIndex == NewBrowsingIndex);
        }
        /// <summary>
        /// Handler called every time a block state is inserted in the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected override void OnBlockStateInserted(IWriteableInsertBlockOperation operation)
        {
            base.OnBlockStateInserted(operation);

            IFocusBlockState BlockState = ((IFocusInsertBlockOperation)operation).BlockState;

            Debug.Assert(BlockState != null);
            Debug.Assert(BlockStateViewTable.ContainsKey(BlockState));

            Debug.Assert(StateViewTable.ContainsKey(BlockState.PatternState));
            Debug.Assert(StateViewTable.ContainsKey(BlockState.SourceState));

            Debug.Assert(BlockState.StateList.Count == 1);

            IFocusPlaceholderNodeState ChildState = ((IFocusInsertBlockOperation)operation).ChildState;

            Debug.Assert(ChildState == BlockState.StateList[0]);
            Debug.Assert(ChildState.ParentIndex == ((IFocusInsertBlockOperation)operation).BrowsingIndex);
            Debug.Assert(StateViewTable.ContainsKey(ChildState));
        }
        private protected virtual void GetChildrenStateView(IFocusNodeStateView stateView, List <IFocusNodeStateView> stateViewList)
        {
            stateViewList.Add(stateView);

            foreach (string Key in stateView.State.InnerTable.Keys)
            {
                IFocusInner Value = (IFocusInner)stateView.State.InnerTable[Key];

                bool           IsHandled = false;
                IFocusTemplate Template;
                FocusAssignableCellViewReadOnlyDictionary <string> CellViewTable;
                IFocusCellViewCollection EmbeddingCellView;

                if (Value is IFocusPlaceholderInner <IFocusBrowsingPlaceholderNodeIndex> AsPlaceholderInner)
                {
                    Debug.Assert(StateViewTable.ContainsKey(AsPlaceholderInner.ChildState));
                    IFocusNodeStateView ChildStateView = (IFocusNodeStateView)StateViewTable[AsPlaceholderInner.ChildState];
                    Debug.Assert(ChildStateView != null);

                    GetChildrenStateView(ChildStateView, stateViewList);

                    Template      = ChildStateView.Template;
                    CellViewTable = ChildStateView.CellViewTable;

                    IsHandled = true;
                }
                else if (Value is IFocusOptionalInner <IFocusBrowsingOptionalNodeIndex> AsOptionalInner)
                {
                    if (AsOptionalInner.IsAssigned)
                    {
                        Debug.Assert(StateViewTable.ContainsKey(AsOptionalInner.ChildState));
                        IFocusOptionalNodeStateView ChildStateView = StateViewTable[AsOptionalInner.ChildState] as IFocusOptionalNodeStateView;
                        Debug.Assert(ChildStateView != null);

                        GetChildrenStateView(ChildStateView, stateViewList);

                        Template      = ChildStateView.Template;
                        CellViewTable = ChildStateView.CellViewTable;
                    }

                    IsHandled = true;
                }
                else if (Value is IFocusListInner <IFocusBrowsingListNodeIndex> AsListInner)
                {
                    foreach (IFocusNodeState ChildState in AsListInner.StateList)
                    {
                        IFocusNodeStateView ChildStateView = (IFocusNodeStateView)StateViewTable[ChildState];
                        GetChildrenStateView(ChildStateView, stateViewList);

                        Template      = ChildStateView.Template;
                        CellViewTable = ChildStateView.CellViewTable;
                    }

                    IsHandled = true;
                }
                else if (Value is IFocusBlockListInner <IFocusBrowsingBlockNodeIndex> AsBlockListInner)
                {
                    foreach (IFocusBlockState BlockState in AsBlockListInner.BlockStateList)
                    {
                        IFocusNodeStateView PatternStateView = (IFocusNodeStateView)StateViewTable[BlockState.PatternState];
                        GetChildrenStateView(PatternStateView, stateViewList);
                        Template      = PatternStateView.Template;
                        CellViewTable = PatternStateView.CellViewTable;

                        IFocusNodeStateView SourceStateView = (IFocusNodeStateView)StateViewTable[BlockState.SourceState];
                        GetChildrenStateView(SourceStateView, stateViewList);
                        Template      = SourceStateView.Template;
                        CellViewTable = SourceStateView.CellViewTable;

                        FocusBlockStateView BlockStateView = (FocusBlockStateView)BlockStateViewTable[BlockState];
                        Template          = BlockStateView.Template;
                        EmbeddingCellView = BlockStateView.EmbeddingCellView;

                        foreach (IFocusNodeState ChildState in BlockState.StateList)
                        {
                            IFocusNodeStateView ChildStateView = (IFocusNodeStateView)StateViewTable[ChildState];
                            GetChildrenStateView(ChildStateView, stateViewList);

                            Template      = ChildStateView.Template;
                            CellViewTable = ChildStateView.CellViewTable;
                        }
                    }

                    IsHandled = true;
                }

                Debug.Assert(IsHandled);
            }
        }