/// <summary>
 /// Occurs when a subtitle search found a new link.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 private void SubtitleSearchEngineNewLink(object sender, EventArgs <Subtitle> e)
 {
     Dispatcher.Invoke((Action)(() =>
     {
         lock (SubtitlesListViewItemCollection)
         {
             SubtitlesListViewItemCollection.Add(new SubtitleItem(e.Data));
         }
     }));
 }
        /// <summary>
        /// Handles the Click event of the searchButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void SearchButtonClick(object sender = null, RoutedEventArgs e = null)
        {
            if (string.IsNullOrWhiteSpace(textBox.Text))
            {
                return;
            }

            if (_searching)
            {
                ActiveSearch.CancelAsync();
                SubtitleSearchDone();
                return;
            }

            SubtitlesListViewItemCollection.Clear();

            textBox.IsEnabled    = false;
            searchButton.Content = "Cancel";

            ActiveSearch = new SubtitleSearch(ActiveSearchEngines, ActiveLangs, filterResults.IsChecked);

            ActiveSearch.SubtitleSearchDone          += SubtitleSearchDone;
            ActiveSearch.SubtitleSearchEngineNewLink += SubtitleSearchEngineNewLink;
            ActiveSearch.SubtitleSearchEngineDone    += SubtitleSearchEngineDone;
            ActiveSearch.SubtitleSearchEngineError   += SubtitleSearchEngineError;

            SetStatus("Searching for subtitles on " + (string.Join(", ", ActiveSearch.SearchEngines.Select(engine => engine.Name).ToArray())) + "...", true);

            _searching = true;

            ActiveSearch.SearchAsync(textBox.Text);

            _dbep = FileNames.Parser.ParseFile(textBox.Text, null, false).DbEpisode;

            Utils.Win7Taskbar(0, TaskbarProgressBarState.Normal);
        }