예제 #1
0
        public bool Search(string nextChar)
        {
            int  startIndex     = isActive ? lastMatchIndex : Math.Max(0, treeView.SelectedIndex);
            bool lookBackwards  = inputStack.Count > 0 && string.Compare(inputStack.Peek(), nextChar, StringComparison.OrdinalIgnoreCase) == 0;
            int  nextMatchIndex = IndexOfMatch(matchPrefix + nextChar, startIndex, lookBackwards, out bool wasNewCharUsed);

            if (nextMatchIndex != -1)
            {
                if (!isActive || nextMatchIndex != startIndex)
                {
                    treeView.SelectedItem = treeView.Items[nextMatchIndex];
                    treeView.FocusNode((SharpTreeNode)treeView.SelectedItem);
                    lastMatchIndex = nextMatchIndex;
                }
                if (wasNewCharUsed)
                {
                    matchPrefix += nextChar;
                    inputStack.Push(nextChar);
                }
                isActive = true;
            }
            if (isActive)
            {
                ResetTimeout();
            }
            return(nextMatchIndex != -1);
        }