Beispiel #1
0
        private void PerformSearchActions(string enteredText)
        {
            enteredText = ApplyDisableWhitespaceTrim(enteredText);

            if (enteredText.Equals(_lastTextValue))
            {
                return;
            }

            if (string.IsNullOrEmpty(enteredText))
            {
                ClearSelectedItem();
            }
            else
            {
                bool doSearchNow = !IsSearchInProgress && enteredText.Length >= MinimumPrefixLength;
                if (doSearchNow)
                {
                    SearchTimer = new DispatcherTimer(
                        TimeSpan.FromMilliseconds(MinimumSearchDelay),
                        DispatcherPriority.Background,
                        new EventHandler(OnSearchTimerTick),
                        this.Dispatcher);

                    _lastTextValue = enteredText;
                    OnSearchBeginning(_lastTextValue, MaxResults, Tag);
                    SearchProvider.BeginSearchAsync(_lastTextValue, DateTime.Now.ToUniversalTime(), MaxResults, Tag, ProcessSearchResults);
                    SearchTimer.Start();
                }
            }
        }
Beispiel #2
0
        private void OnSearchTimerTick(object sender, EventArgs e)
        {
            if (IsSearchInProgress)
            {
                var last    = ApplyDisableWhitespaceTrim(_lastTextValue);
                var current = ApplyDisableWhitespaceTrim(PART_EDITFIELD.Text);

                if (!last.Equals(current))
                {
                    _lastTextValue = current;
                    OnSearchBeginning(current, MaxResults, Tag);
                    SearchProvider.BeginSearchAsync(_lastTextValue, DateTime.Now.ToUniversalTime(), MaxResults, Tag, ProcessSearchResults);
                }
            }
        }