// Token: 0x060057F7 RID: 22519 RVA: 0x00185E84 File Offset: 0x00184084
        internal static MatchedTextInfo FindMatchingPrefix(ItemsControl itemsControl, string prefix)
        {
            bool            flag = false;
            int             num  = TextSearch.FindMatchingPrefix(itemsControl, TextSearch.GetPrimaryTextPath(itemsControl), prefix, string.Empty, 0, false, ref flag);
            MatchedTextInfo result;

            if (num >= 0)
            {
                CultureInfo culture = TextSearch.GetCulture(itemsControl);
                bool        isTextSearchCaseSensitive = itemsControl.IsTextSearchCaseSensitive;
                string      primaryTextFromItem       = TextSearch.GetPrimaryTextFromItem(itemsControl, itemsControl.Items[num]);
                int         matchedPrefixLength;
                int         textExcludingPrefixLength;
                TextSearch.GetMatchingPrefixAndRemainingTextLength(primaryTextFromItem, prefix, culture, !isTextSearchCaseSensitive, out matchedPrefixLength, out textExcludingPrefixLength);
                result = new MatchedTextInfo(num, primaryTextFromItem, matchedPrefixLength, textExcludingPrefixLength);
            }
            else
            {
                result = MatchedTextInfo.NoMatch;
            }
            return(result);
        }
        // Token: 0x060057F3 RID: 22515 RVA: 0x00185B20 File Offset: 0x00183D20
        internal bool DoSearch(string nextChar)
        {
            bool           lookForFallbackMatchToo = false;
            int            num   = 0;
            ItemCollection items = this._attachedTo.Items;

            if (this.IsActive)
            {
                num = this.MatchedItemIndex;
            }
            if (this._charsEntered.Count > 0 && string.Compare(this._charsEntered[this._charsEntered.Count - 1], nextChar, true, TextSearch.GetCulture(this._attachedTo)) == 0)
            {
                lookForFallbackMatchToo = true;
            }
            string primaryTextPath = TextSearch.GetPrimaryTextPath(this._attachedTo);
            bool   flag            = false;
            int    num2            = TextSearch.FindMatchingPrefix(this._attachedTo, primaryTextPath, this.Prefix, nextChar, num, lookForFallbackMatchToo, ref flag);

            if (num2 != -1)
            {
                if (!this.IsActive || num2 != num)
                {
                    object item = items[num2];
                    this._attachedTo.NavigateToItem(item, num2, new ItemsControl.ItemNavigateArgs(Keyboard.PrimaryDevice, ModifierKeys.None));
                    this.MatchedItemIndex = num2;
                }
                if (flag)
                {
                    this.AddCharToPrefix(nextChar);
                }
                if (!this.IsActive)
                {
                    this.IsActive = true;
                }
            }
            if (this.IsActive)
            {
                this.ResetTimeout();
            }
            return(num2 != -1);
        }
        // Token: 0x060057F6 RID: 22518 RVA: 0x00185D48 File Offset: 0x00183F48
        private static int FindMatchingPrefix(ItemsControl itemsControl, string primaryTextPath, string prefix, string newChar, int startItemIndex, bool lookForFallbackMatchToo, ref bool wasNewCharUsed)
        {
            ItemCollection items = itemsControl.Items;
            int            num   = -1;
            int            num2  = -1;
            int            count = items.Count;

            if (count == 0)
            {
                return(-1);
            }
            string value = prefix + newChar;

            if (string.IsNullOrEmpty(value))
            {
                return(-1);
            }
            BindingExpression bindingExpression = null;
            object            item = itemsControl.Items[0];

            if (SystemXmlHelper.IsXmlNode(item) || !string.IsNullOrEmpty(primaryTextPath))
            {
                bindingExpression = TextSearch.CreateBindingExpression(itemsControl, item, primaryTextPath);
                TextSearch.TextValueBindingExpression.SetValue(itemsControl, bindingExpression);
            }
            bool flag = true;

            wasNewCharUsed = false;
            CultureInfo culture = TextSearch.GetCulture(itemsControl);
            int         i       = startItemIndex;

            while (i < count)
            {
                object obj = items[i];
                if (obj != null)
                {
                    string primaryText = TextSearch.GetPrimaryText(obj, bindingExpression, itemsControl);
                    bool   isTextSearchCaseSensitive = itemsControl.IsTextSearchCaseSensitive;
                    if (primaryText != null && primaryText.StartsWith(value, !isTextSearchCaseSensitive, culture))
                    {
                        wasNewCharUsed = true;
                        num            = i;
                        break;
                    }
                    if (lookForFallbackMatchToo)
                    {
                        if (!flag && prefix != string.Empty)
                        {
                            if (primaryText != null && num2 == -1 && primaryText.StartsWith(prefix, !isTextSearchCaseSensitive, culture))
                            {
                                num2 = i;
                            }
                        }
                        else
                        {
                            flag = false;
                        }
                    }
                }
                i++;
                if (i >= count)
                {
                    i = 0;
                }
                if (i == startItemIndex)
                {
                    break;
                }
            }
            if (bindingExpression != null)
            {
                TextSearch.TextValueBindingExpression.ClearValue(itemsControl);
            }
            if (num == -1 && num2 != -1)
            {
                num = num2;
            }
            return(num);
        }