Esempio n. 1
0
        public void SetupForItems(BitPickerConfig config, List <BitPickerItem> items, string pattern)
        {
            hasWorkLeft = true;

            this.config  = config;
            this.items   = items;
            this.pattern = pattern;

            var workerCount = workers.Length;

            step = (items.Count + workerCount - 1) / workerCount;

            foreach (var state in this.workers)
            {
                state.Setup();
            }
        }
Esempio n. 2
0
        public static void HighlightMatches(BitPickerConfig config, string text, Slice <int> matches, StringBuilder stringBuilder)
        {
            var markupLength =
                config.stylingConfig.beforeMatchMarkup.Length +
                config.stylingConfig.afterMatchMarkup.Length;

            var offset = stringBuilder.Length;

            stringBuilder.Append(text);

            var matchGroupCount = 0;

            for (var i = matches.startIndex; i < matches.endIndex;)
            {
                var match = matches.array[i];

                var startIndex = i;
                i++;
                for ( ; i < matches.endIndex && matches.array[i] == matches.array[i - 1] + 1; i++)
                {
                    continue;
                }

                stringBuilder.Insert(
                    offset + match + matchGroupCount * markupLength + (i - startIndex),
                    config.stylingConfig.afterMatchMarkup
                    );

                stringBuilder.Insert(
                    offset + match + matchGroupCount * markupLength,
                    config.stylingConfig.beforeMatchMarkup
                    );

                matchGroupCount++;
            }
        }
Esempio n. 3
0
 public static void PrepareToGetMatches(BitPickerConfig config, List <BitPickerItem> providedItems, string pattern)
 {
     workerGroup.SetupForItems(config, providedItems, pattern);
 }