Beispiel #1
0
			private void SuggestionsProvidedEventHandler(object sender, SuggestionsProvidedEventArgs e)
			{
				var childLookup = _lookupHandlers[(ISuggestionProvider)sender];

				// update the cached list of suggested items for the child lookup handler
				var items = _owner.SuggestedItemsCache[childLookup];
				items.Clear();
				items.AddRange(new TypeSafeEnumerableWrapper<object>(e.Items));

				// provide aggregate list of items
				var aggregate = CollectionUtils.Concat(new List<List<object>>(_owner.SuggestedItemsCache.Values));

				// sort the aggregate list according to the formatting of each item
				aggregate.Sort((x, y) => _owner.FormatItem(x).CompareTo(_owner.FormatItem(y)));
				EventsHelper.Fire(_suggestionsProvided, this, new SuggestionsProvidedEventArgs(aggregate));
			}
Beispiel #2
0
        private void ItemsProvidedEventHandler(object sender, SuggestionsProvidedEventArgs e)
        {
            // Remember the current text and selection start,
            // as they exists prior to modifying the items collection
            var curText        = this.Text;
            var cursorPosition = this.SelectionStart;

            if (e.Items.Count == 0)
            {
                try
                {
                    this.DroppedDown = false;
                    // there are no suggestions, so clear the items list
                    this.Items.Clear();
                    // reset text back to original text
                    // and return the cursor to the original position
                    this.Text           = curText;
                    this.SelectionStart = cursorPosition;
                }
                catch (ArgumentOutOfRangeException)
                {
                    // just in case...it throws the exception while clearing the list
                }
            }
            else
            {
                // at least 1 suggestion exists

                // open the dropdown menu
                this.DroppedDown = true;

                // update list
                UpdateListItems(e.Items);

                // set cursor to the end
                this.Text            = curText;
                this.SelectionStart  = curText.Length;
                this.SelectionLength = 0;
            }
        }
Beispiel #3
0
        private void ItemsProvidedEventHandler(object sender, SuggestionsProvidedEventArgs e)
        {
            // Remember the current text and selection start,
            // as they exists prior to modifying the items collection
            var curText = this.Text;
            var cursorPosition = this.SelectionStart;

            if (e.Items.Count == 0)
            {
				try
				{
					this.DroppedDown = false;
					// there are no suggestions, so clear the items list
					this.Items.Clear();
					// reset text back to original text
					// and return the cursor to the original position
					this.Text = curText;
					this.SelectionStart = cursorPosition;
				}
				catch (ArgumentOutOfRangeException)
				{
					// just in case...it throws the exception while clearing the list
				}
            }
            else
            {
                // at least 1 suggestion exists

                // open the dropdown menu
                this.DroppedDown = true;

                // update list
                UpdateListItems(e.Items);

                // set cursor to the end
                this.Text = curText;
                this.SelectionStart = curText.Length;
                this.SelectionLength = 0;
            }
        }