/// <summary> /// Updates the focus chain with cells in the tree. /// </summary> /// <param name="focusChain">The list of focusable cell views found in the tree.</param> /// <param name="focusedNode">The currently focused node.</param> /// <param name="focusedFrame">The currently focused frame in the template associated to <paramref name="focusedNode"/>.</param> /// <param name="matchingFocus">The focus in <paramref name="focusChain"/> that match <paramref name="focusedNode"/> and <paramref name="focusedFrame"/> upon return.</param> public virtual void UpdateFocusChain(FocusFocusList focusChain, Node focusedNode, IFocusFrame focusedFrame, ref IFocusFocus matchingFocus) { foreach (IFocusCellView Item in CellViewList) { Item.UpdateFocusChain(focusChain, focusedNode, focusedFrame, ref matchingFocus); } }
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); }
/// <summary> /// Updates the focus chain with cells in the tree. /// </summary> /// <param name="focusChain">The list of focusable cell views found in the tree.</param> /// <param name="focusedNode">The currently focused node.</param> /// <param name="focusedFrame">The currently focused frame in the template associated to <paramref name="focusedNode"/>.</param> /// <param name="matchingFocus">The focus in <paramref name="focusChain"/> that match <paramref name="focusedNode"/> and <paramref name="focusedFrame"/> upon return.</param> public virtual void UpdateFocusChain(FocusFocusList focusChain, Node focusedNode, IFocusFrame focusedFrame, ref IFocusFocus matchingFocus) { IFocusFocus NewFocus = CreateFocus(); focusChain.Add(NewFocus); if (focusedFrame == Frame) { IFocusOptionalNodeState AsOptionalNodeState = StateView.State as IFocusOptionalNodeState; Debug.Assert(AsOptionalNodeState == null || AsOptionalNodeState.ParentInner.IsAssigned); if (focusedNode == StateView.State.Node) { Debug.Assert(matchingFocus == null); matchingFocus = NewFocus; } } }
private protected virtual void RecoverFocus(IFocusNodeState state, FocusFocusList newFocusChain) { IFocusNodeState CurrentState = state; List <IFocusNodeStateView> StateViewList = new List <IFocusNodeStateView>(); IFocusNodeStateView MainStateView = null; List <IFocusFocus> SameStateFocusableList = new List <IFocusFocus>(); // Get the state that should have the focus and all its children. while (CurrentState != null && !GetFocusedStateAndChildren(newFocusChain, CurrentState, out MainStateView, out StateViewList, out SameStateFocusableList)) { CurrentState = CurrentState.ParentState; } Debug.Assert(SameStateFocusableList.Count > 0); // Now that we have found candidates, try to select the original frame. bool IsFrameChanged = true; IFocusFrame Frame = Focus.CellView.Frame; foreach (IFocusFocus CellFocus in SameStateFocusableList) { if (CellFocus.CellView.Frame == Frame) { IsFrameChanged = false; Focus = CellFocus; break; } } // If the frame has changed, use a preferred frame. if (IsFrameChanged) { FindPreferredFrame(MainStateView, SameStateFocusableList); } ResetCaretPosition(0, true); }
private protected virtual void UpdateFocusChain(IFocusNodeState state, Node focusedNode, IFocusFrame focusedFrame) { FocusFocusList NewFocusChain = CreateFocusChain(); IFocusNodeState RootState = Controller.RootState; IFocusNodeStateView RootStateView = (IFocusNodeStateView)StateViewTable[RootState]; IFocusFocus MatchingFocus = null; RootStateView.UpdateFocusChain(NewFocusChain, focusedNode, focusedFrame, ref MatchingFocus); // Ensured by all templates having at least one preferred (hence focusable) frame. Debug.Assert(NewFocusChain.Count > 0); // First run, initialize the focus to the first focusable cell. if (Focus == null) { Debug.Assert(FocusChain == null); Focus = NewFocusChain[0]; ResetCaretPosition(0, true); } else if (MatchingFocus != null) { Focus = MatchingFocus; UpdateMaxCaretPosition(); // The focus didn't change, but the content may have. } else { RecoverFocus(state, NewFocusChain); // The focus has forcibly changed. } FocusChain = NewFocusChain; DebugObjects.AddReference(NewFocusChain); Debug.Assert(Focus != null); Debug.Assert(FocusChain.Contains(Focus)); SelectionAnchor = Focus.CellView.StateView; SelectionExtension = 0; }
/// <summary> /// Updates the focus chain with cells in the tree. /// </summary> /// <param name="focusChain">The list of focusable cell views found in the tree.</param> /// <param name="focusedNode">The currently focused node.</param> /// <param name="focusedFrame">The currently focused frame in the template associated to <paramref name="focusedNode"/>.</param> /// <param name="matchingFocus">The focus in <paramref name="focusChain"/> that match <paramref name="focusedNode"/> and <paramref name="focusedFrame"/> upon return.</param> public abstract void UpdateFocusChain(FocusFocusList focusChain, Node focusedNode, IFocusFrame focusedFrame, ref IFocusFocus matchingFocus);
/// <summary> /// Updates the focus chain with cells in the tree. /// </summary> /// <param name="focusChain">The list of focusable cell views found in the tree.</param> /// <param name="focusedNode">The currently focused node.</param> /// <param name="focusedFrame">The currently focused frame in the template associated to <paramref name="focusedNode"/>.</param> /// <param name="matchingFocus">The focus in <paramref name="focusChain"/> that match <paramref name="focusedNode"/> and <paramref name="focusedFrame"/> upon return.</param> public virtual void UpdateFocusChain(FocusFocusList focusChain, Node focusedNode, IFocusFrame focusedFrame, ref IFocusFocus matchingFocus) { Debug.Assert(RootCellView != null); RootCellView.UpdateFocusChain(focusChain, focusedNode, focusedFrame, ref matchingFocus); }
/// <inheritdoc/> public FocusFocusReadOnlyList(FocusFocusList list) : base(list) { }
/// <summary> /// Updates the focus chain with cells in the tree. /// </summary> /// <param name="focusChain">The list of focusable cell views found in the tree.</param> /// <param name="focusedNode">The currently focused node.</param> /// <param name="focusedFrame">The currently focused frame in the template associated to <paramref name="focusedNode"/>.</param> /// <param name="matchingFocus">The focus in <paramref name="focusChain"/> that match <paramref name="focusedNode"/> and <paramref name="focusedFrame"/> upon return.</param> public virtual void UpdateFocusChain(FocusFocusList focusChain, Node focusedNode, IFocusFrame focusedFrame, ref IFocusFocus matchingFocus) { ChildStateView.UpdateFocusChain(focusChain, focusedNode, focusedFrame, ref matchingFocus); }
/// <summary> /// Updates the focus chain with cells in the tree. /// </summary> /// <param name="focusChain">The list of focusable cell views found in the tree.</param> /// <param name="focusedNode">The currently focused node.</param> /// <param name="focusedFrame">The currently focused frame in the template associated to <paramref name="focusedNode"/>.</param> /// <param name="matchingFocus">The focus in <paramref name="focusChain"/> that match <paramref name="focusedNode"/> and <paramref name="focusedFrame"/> upon return.</param> public virtual void UpdateFocusChain(FocusFocusList focusChain, Node focusedNode, IFocusFrame focusedFrame, ref IFocusFocus matchingFocus) { }