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];
            }
        }
        private protected virtual bool GetFocusedStateAndChildren(FocusFocusList newFocusChain, IFocusNodeState state, out IFocusNodeStateView mainStateView, out List <IFocusNodeStateView> stateViewList, out List <IFocusFocus> sameStateFocusableList)
        {
            mainStateView = (IFocusNodeStateView)StateViewTable[state];

            stateViewList          = new List <IFocusNodeStateView>();
            sameStateFocusableList = new List <IFocusFocus>();
            GetChildrenStateView(mainStateView, stateViewList);

            // Find all focusable cells belonging to these states.
            foreach (IFocusFocus NewFocus in newFocusChain)
            {
                IFocusFocusableCellView CellView = NewFocus.CellView;

                foreach (IFocusNodeStateView StateView in stateViewList)
                {
                    if (CellView.StateView == StateView && !sameStateFocusableList.Contains(NewFocus))
                    {
                        sameStateFocusableList.Add(NewFocus);
                        break;
                    }
                }
            }

            if (sameStateFocusableList.Count > 0)
            {
                return(true);
            }

            // If it doesn't work, try the parent state, down to the root (in case of a removal or unassign).
            return(false);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FocusFocus"/> class.
 /// </summary>
 public FocusFocus(IFocusFocusableCellView cellView)
 {
     CellView = cellView;
 }