Example #1
0
        private async void ButtonBase_SearchTags_OnClick(object sender, RoutedEventArgs e)
        {
            string tagToSearchFor = TextBox_Search_Tags.Text;
            Properties.Settings.Default.resentSearch = tagToSearchFor;

            Jokes foundJokes = await Task.Run(() =>
            {
                Jokes derpJokes = new Jokes();

                foreach (Joke joke in JokesList)
                {
                    if (joke.ContainsTopic(tagToSearchFor))
                    {
                        derpJokes.Add(joke);
                    }
                }

                Thread.Sleep(3000);

                return derpJokes;
            });

            if (_searchResultsWindow != null) _searchResultsWindow.Focus();
            else
            {
                _searchResultsWindow = new SearchResults(foundJokes);
                _searchResultsWindow.Owner = this;
                _searchResultsWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;

                _searchResultsWindow.CloseEvent += SearchResultsClosed;

                _searchResultsWindow.Show();
            }
        }
Example #2
0
 private void SearchResultsClosed(object sender, EventArgs e)
 {
     _searchResultsWindow = null;
     Focus();
 }