Ejemplo n.º 1
0
        /// <summary>
        ///     Helper function called by Editable ComboBox to search through items.
        /// </summary>
        internal static MatchedTextInfo FindMatchingPrefix(ItemsControl itemsControl, string prefix)
        {
            MatchedTextInfo matchedTextInfo;
            bool            wasNewCharUsed = false;

            int matchedItemIndex = FindMatchingPrefix(itemsControl, GetPrimaryTextPath(itemsControl), prefix, String.Empty, 0, false, ref wasNewCharUsed);

            // There could be compressions or expansions in either matched text or inputted text which means
            // length of the prefix in the matched text and length of the inputted text could be different
            // for example: "Grosses" would match for the input text "Groß" where the prefix length in matched text is 5
            // whereas the length of the inputted text is 4. Same matching rule applies for the other way as well with
            // "Groß" in matched text for the inputted text "Gross"
            if (matchedItemIndex >= 0)
            {
                int         matchedPrefixLength;
                int         textExcludingPrefixLength;
                CultureInfo cultureInfo = GetCulture(itemsControl);
                bool        ignoreCase  = itemsControl.IsTextSearchCaseSensitive;
                string      matchedText = GetPrimaryTextFromItem(itemsControl, itemsControl.Items[matchedItemIndex]);

                GetMatchingPrefixAndRemainingTextLength(matchedText, prefix, cultureInfo, !ignoreCase, out matchedPrefixLength, out textExcludingPrefixLength);
                matchedTextInfo = new MatchedTextInfo(matchedItemIndex, matchedText, matchedPrefixLength, textExcludingPrefixLength);
            }
            else
            {
                matchedTextInfo = MatchedTextInfo.NoMatch;
            }

            return(matchedTextInfo);
        }
        // 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);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// For no match case
 /// </summary>
 static MatchedTextInfo()
 {
     s_NoMatch = new MatchedTextInfo(-1, null, 0, 0);
 }