/// <summary> /// Load Stations and pass the result to the <see cref="AutoCompleteLoaded"/> Event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AutocompleteTimer_Tick(object sender, EventArgs e) { Console.WriteLine("Autocomplete Started"); AutocompleteTimer.Stop(); AutoCompleteLoaded(this, new AutocompleteEventArgs { Stations = Transport.GetStations(LastStationText) }); Console.WriteLine("Autocomplete Finished"); }
/// <summary> /// Wait some time before loading the Stations, because otherwise it will load too many times and show old search results. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmbStationSearch_TextChanged(object sender, EventArgs e) { var box = (ComboBox)sender; foreach (var item in box.Items) { if (item.ToString() == box.Text) { return; } } LastStationBox = box; LastStationText = LastStationBox.Text; AutocompleteTimer.Stop(); AutocompleteTimer.Start(); }