private protected virtual void FindPreferredFrame(IFocusNodeStateView mainStateView, List <IFocusFocus> sameStateFocusableList)
        {
            bool IsFrameSet             = false;
            IFocusNodeTemplate Template = mainStateView.Template as IFocusNodeTemplate;

            Debug.Assert(Template != null);

            Template.GetPreferredFrame(out IFocusNodeFrame FirstPreferredFrame, out IFocusNodeFrame LastPreferredFrame);
            Debug.Assert(FirstPreferredFrame != null);
            Debug.Assert(LastPreferredFrame != null);

            foreach (IFocusFocus CellFocus in sameStateFocusableList)
            {
                IFocusFocusableCellView CellView = CellFocus.CellView;
                if (CellView.Frame == FirstPreferredFrame || CellView.Frame == LastPreferredFrame)
                {
                    IsFrameSet = true;
                    Focus      = CellFocus;
                    break;
                }
            }

            // If none of the preferred frames are visible, use the first focusable cell.
            if (!IsFrameSet)
            {
                Focus = sameStateFocusableList[0];
            }
        }
コード例 #2
0
        /// <summary></summary>
        protected virtual bool UpdateSelectorStackNodeState(List <FocusFrameSelectorList> selectorStack, ref IFocusNodeStateView currentStateView)
        {
            IFocusInner     ParentInner = currentStateView.State.ParentInner;
            IFocusNodeState ParentState = currentStateView.State.ParentState;

            if (ParentInner == null)
            {
                Debug.Assert(ParentState == null);
                return(false);
            }

            Debug.Assert(ParentState != null);

            currentStateView = (IFocusNodeStateView)ControllerView.StateViewTable[ParentState];
            IFocusNodeTemplate Template = currentStateView.Template as IFocusNodeTemplate;

            Debug.Assert(Template != null);

            if (Template.FrameSelectorForProperty(ParentInner.PropertyName, out IFocusFrameWithSelector Frame))
            {
                if (Frame != null)
                {
                    if (Frame.Selectors.Count > 0)
                    {
                        selectorStack.Insert(0, Frame.Selectors);
                    }
                }
            }

            return(true);
        }
コード例 #3
0
        /// <summary>
        /// Checks if the template associated to the <paramref name="propertyName"/> property of the <paramref name="stateView"/> state is complex.
        /// </summary>
        /// <param name="stateView">The state view for the node with property <paramref name="propertyName"/>.</param>
        /// <param name="propertyName">Name of the property pointing to the template to check.</param>
        public virtual bool IsTemplateComplex(IFocusNodeStateView stateView, string propertyName)
        {
            IFocusNodeState State = stateView.State;

            Debug.Assert(State.InnerTable.ContainsKey(propertyName));

            IFocusPlaceholderInner ParentInner = State.InnerTable[propertyName] as IFocusPlaceholderInner;

            Debug.Assert(ParentInner != null);

            NodeTreeHelperChild.GetChildNode(stateView.State.Node, propertyName, out Node ChildNode);
            Debug.Assert(ChildNode != null);

            Type NodeType = Type.FromGetType(ChildNode);

            //Type InterfaceType = NodeTreeHelper.NodeTypeToInterfaceType(NodeType);
            //Debug.Assert(TemplateSet.NodeTemplateTable.ContainsKey(InterfaceType));
            Debug.Assert(TemplateSet.NodeTemplateTable.ContainsKey(NodeType));

            IFocusNodeTemplate ParentTemplate = TemplateSet.NodeTemplateTable[NodeType] as IFocusNodeTemplate;

            Debug.Assert(ParentTemplate != null);

            return(ParentTemplate.IsComplex);
        }
コード例 #4
0
        /// <summary>
        /// Gets the frame that creates cells associated to a comment in a state.
        /// This overload uses selectors to choose the correct frame.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <param name="selectorStack">A list of selectors to choose the correct frame.</param>
        public virtual IFocusCommentFrame GetCommentFrame(IFocusNodeState state, IList <IFocusFrameSelectorList> selectorStack)
        {
            Type OwnerType              = state.Node.GetType();
            Type InterfaceType          = NodeTreeHelper.NodeTypeToInterfaceType(OwnerType);
            IFocusNodeTemplate Template = (IFocusNodeTemplate)NodeTypeToTemplate(InterfaceType);
            IFocusCommentFrame Frame    = Template.GetCommentFrame(selectorStack);

            return(Frame);
        }
コード例 #5
0
        /// <summary>
        /// Gets the frame that creates cells associated to a property in a state.
        /// This overload uses selectors to choose the correct frame.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <param name="propertyName">The property name.</param>
        /// <param name="selectorStack">A list of selectors to choose the correct frame.</param>
        public virtual IFocusFrame PropertyToFrame(IFocusNodeState state, string propertyName, IList <IFocusFrameSelectorList> selectorStack)
        {
            Type OwnerType              = state.Node.GetType();
            Type InterfaceType          = NodeTreeHelper.NodeTypeToInterfaceType(OwnerType);
            IFocusNodeTemplate Template = (IFocusNodeTemplate)NodeTypeToTemplate(InterfaceType);
            IFocusFrame        Frame    = Template.PropertyToFrame(propertyName, selectorStack);

            return(Frame);
        }
コード例 #6
0
        /// <summary>
        /// Checks that a frame selector is correctly constructed.
        /// </summary>
        /// <param name="nodeType">Type of the node this frame selector can describe.</param>
        /// <param name="nodeTemplateTable">Table of templates with all frames.</param>
        /// <param name="propertyName">The property for which frames can be selected.</param>
        public virtual bool IsValid(Type nodeType, IFocusTemplateReadOnlyDictionary nodeTemplateTable, string propertyName)
        {
            bool IsValid = true;

            IsValid &= SelectorType != null;
            IsValid &= !string.IsNullOrEmpty(SelectorName);

            Type ChildInterfaceType, ChildNodeType;

            IsValid &= NodeTreeHelperChild.IsChildNodeProperty(nodeType, propertyName, out ChildInterfaceType) ||
                       NodeTreeHelperOptional.IsOptionalChildNodeProperty(nodeType, propertyName, out ChildInterfaceType) ||
                       NodeTreeHelperList.IsNodeListProperty(nodeType, propertyName, out ChildInterfaceType) ||
                       NodeTreeHelperBlockList.IsBlockListProperty(nodeType, propertyName, out ChildInterfaceType, out ChildNodeType) ||
                       (NodeTreeHelper.IsBlockType(nodeType) && propertyName == nameof(BaseNode.IBlock.NodeList));

            IsValid &= nodeTemplateTable.ContainsKey(SelectorType);

            IFocusNodeTemplate Template = nodeTemplateTable[SelectorType] as IFocusNodeTemplate;

            Debug.Assert(Template != null);

            IFocusSelectionFrame AsSelectionFrame = Template.Root as IFocusSelectionFrame;

            IsValid &= AsSelectionFrame != null;

            if (IsValid)
            {
                IFocusSelectableFrame SelectedItem = null;
                foreach (IFocusSelectableFrame Item in AsSelectionFrame.Items)
                {
                    if (Item.Name == SelectorName)
                    {
                        SelectedItem = Item;
                        break;
                    }
                }

                IsValid &= SelectedItem != null;
            }

            Debug.Assert(IsValid);
            return(IsValid);
        }
コード例 #7
0
        /// <summary>
        /// Gets the frame that creates cells associated to states in the inner.
        /// This overload uses selectors to choose the correct frame.
        /// </summary>
        /// <param name="inner">The inner.</param>
        /// <param name="selectorStack">A list of selectors to choose the correct frame.</param>
        public virtual IFocusFrame InnerToFrame(IFocusInner <IFocusBrowsingChildIndex> inner, IList <IFocusFrameSelectorList> selectorStack)
        {
            IFocusNodeState    Owner         = inner.Owner;
            Type               OwnerType     = Owner.Node.GetType();
            Type               InterfaceType = NodeTreeHelper.NodeTypeToInterfaceType(OwnerType);
            IFocusNodeTemplate Template      = (IFocusNodeTemplate)NodeTypeToTemplate(InterfaceType);
            IFocusFrame        Frame         = Template.PropertyToFrame(inner.PropertyName, selectorStack);

            if (Frame is IFocusBlockListFrame AsBlockListFrame)
            {
                IFocusBlockListInner <IFocusBrowsingBlockNodeIndex> BlockListInner = inner as IFocusBlockListInner <IFocusBrowsingBlockNodeIndex>;
                Debug.Assert(BlockListInner != null);

                Type BlockType = NodeTreeHelperBlockList.BlockListBlockType(Owner.Node, BlockListInner.PropertyName);
                IFocusBlockTemplate BlockTemplate = (IFocusBlockTemplate)BlockTypeToTemplate(BlockType);

                Frame = (IFocusFrame)BlockTemplate.GetPlaceholderFrame();
            }

            return(Frame);
        }