private static HeadingTreeNodeWrapper FindNextMatch(ObservableCollection <HeadingTreeNodeWrapper> nodes) { HeadingTreeNodeWrapper htnwResult = null; int iStarting = -1; for (int i = 0; i < nodes.Count; i++) { if ((nodes[i].HasMatches || nodes[i].SearchMatch) && iStarting == -1) { iStarting = i; } if (!nodes[i].IsSelected && !nodes[i].ChildSelected) { continue; } iStarting = i; break; } if (iStarting < 0) { return(null); } if (nodes[iStarting].IsSelected) { if (nodes[iStarting].HasChildren && nodes[iStarting].HasMatches) { htnwResult = nodes[iStarting].GetChildMatch(); } } else if (nodes[iStarting].ChildSelected) { htnwResult = FindNextMatch(nodes[iStarting].Children); } else if (nodes[iStarting].SearchMatch) { htnwResult = nodes[iStarting]; } else { htnwResult = nodes[iStarting].GetChildMatch(); } if (htnwResult == null) { for (int i = iStarting + 1; i < nodes.Count; i++) { if (nodes[i].SearchMatch) { htnwResult = nodes[i]; break; } if (!nodes[i].HasMatches) { continue; } htnwResult = nodes[i].GetChildMatch(); break; } } return(htnwResult); }
public HeadingTreeNodeWrapper(HeadingsNavigator navigator, TreeNode node, TreeNode.Section section, HeadingTreeNodeWrapper parent) { m_parent = parent; m_navigator = navigator; m_isExpanded = false; m_TreeNodeHeading = null; m_TreeNodeLevel = null; m_Section = section; if ((node == null && m_Section == null) || m_navigator == null) { return; } CommandExpandAll = m_navigator.ViewModel.CommandExpandAll; CommandCollapseAll = m_navigator.ViewModel.CommandCollapseAll; Tuple <TreeNode, TreeNode> nodes = ComputeLevelNodes(node, m_Section); m_TreeNodeLevel = nodes.Item1; m_TreeNodeHeading = nodes.Item2; }
public HeadingTreeNodeWrapper FindPrevious(bool select) { ExpandAll(); HeadingTreeNodeWrapper prevMatch = FindPrevMatch(m_roots); if (prevMatch != null) { if (select) { //prevMatch.IsSelected = true; ViewModel.View.SelectTreeNodeWrapper(prevMatch, true); } else { var treeViewItem = VisualLogicalTreeWalkHelper.FindObjectInVisualTreeWithMatchingType <TreeViewItem>( ViewModel.View.TreeView, child => { object dc = child.GetValue(FrameworkElement.DataContextProperty); return(dc != null && dc == prevMatch); }); if (treeViewItem != null) { treeViewItem.BringIntoView(); } } } else { AudioCues.PlayBeep(); } return(prevMatch); }
//public UIElement ViewControl //{ // get { return this; } //} //public UIElement ViewFocusStart //{ // get // { // if (m_SelectedTreeViewItem != null) // { // return m_SelectedTreeViewItem; // } // return TreeView; // } //} private void handleTreeViewCurrentSelection() { HeadingTreeNodeWrapper node = TreeView.SelectedItem as HeadingTreeNodeWrapper; if (node == null) { return; } //TreeNode nested; TreeNode treeNode = null; if (node.WrappedTreeNode_LevelHeading != null) { treeNode = node.WrappedTreeNode_LevelHeading; } else { treeNode = node.WrappedTreeNode_Level.GetFirstDescendantWithText(); if (treeNode != null && treeNode.GetXmlProperty() == null) { //treeNode = TreeNode.GetNextTreeNodeWithNoSignificantTextOnlySiblings(false, treeNode, out nested); treeNode = TreeNode.NavigatePreviousNextSignificantText(false, treeNode); } } if (treeNode == null) { treeNode = node.WrappedTreeNode_Level; } if (treeNode == null) { #if DEBUG Debugger.Break(); #endif return; } //if (m_ignoreHeadingSelected) //{ // m_ignoreHeadingSelected = false; // return; //} m_SelectedTreeViewItem = TreeView.SelectItem(node, true); //m_Logger.Log("-- PublishEvent [TreeNodeSelectedEvent] HeadingPaneView.handleTreeViewCurrentSelection", Category.Debug, Priority.Medium); if (!m_UrakawaSession.isAudioRecording) { m_ignoreTreeNodeSelectedEvent = true; m_UrakawaSession.PerformTreeNodeSelection(treeNode); } }
public void SelectTreeNode(TreeNode node, bool focus) { if (m_ignoreTreeNodeSelectedEvent) { m_ignoreTreeNodeSelectedEvent = false; return; } HeadingTreeNodeWrapper nodeTOC = m_ViewModel.HeadingsNavigator.GetAncestorContainer(node); SelectTreeNodeWrapper(nodeTOC, focus); }
private static void ExpandAll(HeadingTreeNodeWrapper node) { node.IsExpanded = true; if (!node.HasChildren) { return; } foreach (HeadingTreeNodeWrapper child in node.Children) { ExpandAll(child); } }
public static void CollapseAll(HeadingTreeNodeWrapper node) { Collapse(node); if (!node.HasChildren) { return; } foreach (HeadingTreeNodeWrapper child in node.Children) { CollapseAll(child); } }
public void SelectTreeNodeWrapper(HeadingTreeNodeWrapper nodeTOC, bool focus) { if (nodeTOC == null || TreeView.SelectedItem == nodeTOC) { return; } //m_ignoreHeadingSelected = true; m_SelectedTreeViewItem = TreeView.SelectItem(nodeTOC, false); if (m_SelectedTreeViewItem != null && focus) { FocusHelper.FocusBeginInvoke(m_SelectedTreeViewItem); } }
internal void FlagSearchMatches() { ExpandAll(); bool atLeastOneFound = FlagSearchMatches(m_roots); if (atLeastOneFound) { HeadingTreeNodeWrapper nw = FindNext(false); if (nw == null) { nw = FindPrevious(false); } } }
private void checkNodeTitleChanged(HeadingTreeNodeWrapper parent, TreeNode treeNode) { if (parent.WrappedTreeNode_LevelHeading != null && (treeNode == parent.WrappedTreeNode_LevelHeading || treeNode.IsDescendantOf(parent.WrappedTreeNode_LevelHeading)) ) { parent.InvalidateTitle(); } foreach (var child in parent.Children) { checkNodeTitleChanged(child, treeNode); } }
private HeadingTreeNodeWrapper findTreeNodeWrapper(TreeNode node) { foreach (HeadingTreeNodeWrapper root in Roots) { if (root.WrappedTreeNode_Level == node || root.WrappedTreeNode_LevelHeading == node) { return(root); } HeadingTreeNodeWrapper wrapperChild = root.FindTreeNodeWrapper(node); if (wrapperChild != null) { return(wrapperChild); } } return(null); }
public HeadingTreeNodeWrapper FindTreeNodeWrapper(TreeNode node) { if (WrappedTreeNode_Level == node || WrappedTreeNode_LevelHeading == node) { return(this); } IsExpanded = true; foreach (HeadingTreeNodeWrapper child in Children) { HeadingTreeNodeWrapper wrapperChild = child.FindTreeNodeWrapper(node); if (wrapperChild != null) { return(wrapperChild); } } return(null); }
internal HeadingTreeNodeWrapper GetPreviousChildMatch() { HeadingTreeNodeWrapper htnwResult = null; if (m_children == null) { LoadChildren(); } for (int i = m_children.Count - 1; i >= 0; i--) { if (m_children[i].HasMatches) { htnwResult = m_children[i].GetPreviousChildMatch(); break; } if (!m_children[i].SearchMatch) { continue; } htnwResult = m_children[i]; break; } return(htnwResult); }
internal HeadingTreeNodeWrapper GetChildMatch() { HeadingTreeNodeWrapper htnwResult = null; if (m_children == null) { LoadChildren(); } foreach (HeadingTreeNodeWrapper child in m_children) { if (child.SearchMatch) { htnwResult = child; break; } if (!child.HasMatches) { continue; } htnwResult = child.GetChildMatch(); break; } return(htnwResult); }
public static void Expand(HeadingTreeNodeWrapper node) { node.IsExpanded = true; }
public static void Collapse(HeadingTreeNodeWrapper node) { node.IsExpanded = false; }