コード例 #1
0
        public void AddDescribableTreeNode(TreeNode node)
        {
            RemoveDescribableTreeNode(node); // ensure no duplicate

            var describedTreeNode = new DescribableTreeNode(node);

            bool inserted = false;

            foreach (DescribableTreeNode describableTreeNode in DescribableTreeNodes)
            {
                if (node.IsBefore(describableTreeNode.TreeNode))
                {
                    var i = DescribableTreeNodes.IndexOf(describableTreeNode);

                    if (!m_BackupTreeNodes.Contains(describedTreeNode))
                    {
                        m_BackupTreeNodes.Insert(i, describedTreeNode);
                    }

                    DescribableTreeNodes.Insert(i, describedTreeNode);

                    inserted = true;
                    break;
                }
            }
            if (!inserted)
            {
                if (!m_BackupTreeNodes.Contains(describedTreeNode))
                {
                    m_BackupTreeNodes.Add(describedTreeNode);
                }

                DescribableTreeNodes.Add(describedTreeNode);
            }
        }
コード例 #2
0
        public DescribableTreeNode FindPrevious(bool select)
        {
            DescribableTreeNode previousMatch = FindPrevDescription(m_DescribableTreeNodes);

            if (previousMatch != null)
            {
                var listItem = VisualLogicalTreeWalkHelper.FindObjectInVisualTreeWithMatchingType <ListViewItem>(
                    m_view.ListView,
                    child =>
                {
                    object dc = child.GetValue(FrameworkElement.DataContextProperty);
                    return(dc != null && dc == previousMatch);
                });
                if (select)
                {
                    previousMatch.IsSelected = true;
                    if (listItem != null)
                    {
                        FocusHelper.FocusBeginInvoke(listItem); //m_view.m_LastListItemSelected
                    }
                }
                else
                {
                    if (listItem != null)
                    {
                        listItem.BringIntoView();
                    }
                }
            }
            else
            {
                AudioCues.PlayBeep();
            }
            return(previousMatch);
        }
コード例 #3
0
        private void FlagSearchMatches()
        {
            if (string.IsNullOrEmpty(SearchTerm))
            {
                foreach (DescribableTreeNode mnode in DescribableTreeNodes)
                {
                    mnode.SearchMatch = false;
                }
                return;
            }
            bool atLeastOneFound = false;

            foreach (DescribableTreeNode mnode in DescribableTreeNodes)
            {
                bool found = !string.IsNullOrEmpty(mnode.Description) &&
                             mnode.Description.IndexOf(SearchTerm, StringComparison.OrdinalIgnoreCase) >= 0;
                mnode.SearchMatch = found;
                if (found)
                {
                    atLeastOneFound = true;
                }
            }

            if (atLeastOneFound)
            {
                DescribableTreeNode sw = FindNext(false);
                if (sw == null)
                {
                    sw = FindPrevious(false);
                }
            }
        }
コード例 #4
0
        public void UpdateTreeNodeSelectionFromListItem()
        {
            if (ListView.SelectedIndex >= 0)
            {
                DescribableTreeNode mnode = ListView.SelectedItem as DescribableTreeNode;
                if (mnode == null)
                {
                    return;
                }
                TreeNode treeNode = mnode.TreeNode;

                if (treeNode == null)
                {
                    return;
                }

                if (!m_UrakawaSession.isAudioRecording)
                {
                    _ignoreTreeNodeSelectedEvent = true;
                    m_UrakawaSession.PerformTreeNodeSelection(treeNode, false, null);
                }
                //m_EventAggregator.GetEvent<TreeNodeSelectedEvent>().Publish(treeNode);
            }

            //m_DescriptionsView.Popup();
        }
コード例 #5
0
        private static DescribableTreeNode FindPrevDescription(ObservableCollection <DescribableTreeNode> pages)
        {
            DescribableTreeNode pResult = null;
            int iStarting = -1;

            for (int i = pages.Count - 1; i >= 0; i--)
            {
                if (pages[i].SearchMatch && iStarting == -1)
                {
                    iStarting = i;
                }
                if (!pages[i].IsSelected)
                {
                    continue;
                }
                iStarting = i;
                break;
            }
            if (iStarting < 0)
            {
                return(null);
            }
            if (!pages[iStarting].IsSelected && pages[iStarting].SearchMatch)
            {
                pResult = pages[iStarting];
            }
            if (pResult == null)
            {
                for (int i = iStarting - 1; i >= 0; i--)
                {
                    if (!pages[i].SearchMatch)
                    {
                        continue;
                    }
                    pResult = pages[i];
                    break;
                }
            }
            return(pResult);
        }
コード例 #6
0
        public void RemoveDescribableTreeNode(TreeNode node)
        {
            DescribableTreeNode toRemove = null;

            foreach (DescribableTreeNode describableTreeNode in DescribableTreeNodes)
            {
                if (describableTreeNode.TreeNode == node)
                {
                    toRemove = describableTreeNode;
                    break;
                }
            }
            if (toRemove != null)
            {
                if (m_BackupTreeNodes.Contains(toRemove))
                {
                    m_BackupTreeNodes.Remove(toRemove);
                }

                DescribableTreeNodes.Remove(toRemove);
            }
        }