private void SearchWait(ViewState.View origView, string search) { Thread.Sleep(500); lock (this.searchThreadLock) { if (!object.ReferenceEquals(Thread.CurrentThread, this.searchThread)) { // A search thread was created more recently, stop this thread return; } if (!this.IsDisposed) { this.Invoke((MethodInvoker)delegate { this.PerformSearch(origView, search); }); } } }
private void View_ViewChanged(ViewState.View view, ViewState.MainTab tab, object data) { this.ButtonFindNew.Checked = false; this.ButtonFavourites.Checked = false; this.ButtonSubscriptions.Checked = false; this.ButtonDownloads.Checked = false; switch (tab) { case ViewState.MainTab.FindProgramme: this.ButtonFindNew.Checked = true; break; case ViewState.MainTab.Favourites: this.ButtonFavourites.Checked = true; break; case ViewState.MainTab.Subscriptions: this.ButtonSubscriptions.Checked = true; break; case ViewState.MainTab.Downloads: this.ButtonDownloads.Checked = true; break; } this.SetViewDefaults(); // Set the focus to a control which does not show it, to prevent the toolbar momentarily showing focus this.LabelSidebarTitle.Focus(); this.ListProviders.Visible = false; this.PanelPluginSpace.Visible = false; this.ListEpisodes.Visible = false; this.ListFavourites.Visible = false; this.ListSubscribed.Visible = false; this.ListDownloads.Visible = false; this.TextSearch.Visible = false; switch (view) { case ViewState.View.FindNewChooseProvider: this.ListProviders.Visible = true; this.ListProviders.Focus(); if (this.ListProviders.SelectedItems.Count > 0) { this.ShowProviderInfo(new Guid(this.ListProviders.SelectedItems[0].Name)); } break; case ViewState.View.FindNewProviderForm: FindNewViewData findViewData = (FindNewViewData)data; if (this.PanelPluginSpace.Controls.Count > 0) { this.PanelPluginSpace.Controls[0].Dispose(); this.PanelPluginSpace.Controls.Clear(); } this.PanelPluginSpace.Visible = true; this.PanelPluginSpace.Controls.Add(FindNew.GetFindNewPanel(findViewData.ProviderID, findViewData.View)); this.PanelPluginSpace.Controls[0].Dock = DockStyle.Fill; this.PanelPluginSpace.Controls[0].Focus(); break; case ViewState.View.ProgEpisodes: this.ListEpisodes.Visible = true; FindNew.CancelEpisodeListing(); this.ListEpisodes.Items.Clear(); // Clear before DoEvents so that old items don't flash up on screen Application.DoEvents(); // Give any queued Invoke calls a chance to be processed this.ListEpisodes.Items.Clear(); FindNew.InitEpisodeList((int)data); break; case ViewState.View.Favourites: this.ListFavourites.Visible = true; this.ListFavourites.Focus(); if (this.ListFavourites.SelectedItems.Count > 0) { this.ShowFavouriteInfo(Convert.ToInt32(this.ListFavourites.SelectedItems[0].Name, CultureInfo.InvariantCulture)); } break; case ViewState.View.Subscriptions: this.ListSubscribed.Visible = true; this.ListSubscribed.Focus(); if (this.ListSubscribed.SelectedItems.Count > 0) { this.ShowSubscriptionInfo(Convert.ToInt32(this.ListSubscribed.SelectedItems[0].Name, CultureInfo.InvariantCulture)); } break; case ViewState.View.Downloads: if (data == null) { this.TextSearch.Text = string.Empty; } else { this.TextSearch.Text = (string)data; this.PerformSearch(view, this.TextSearch.Text); } this.TextSearch.Visible = true; this.ListDownloads.Visible = true; this.ListDownloads.Focus(); if (this.ListDownloads.SelectedItems.Count > 0) { this.ShowDownloadInfo(Convert.ToInt32(this.ListDownloads.SelectedItems[0].Name, CultureInfo.InvariantCulture)); } break; } }
private void PerformSearch(ViewState.View origView, string search) { if (this.view.CurrentView == origView) { if (string.IsNullOrEmpty(search)) { if (this.view.CurrentViewData != null) { this.view.StoreView(null); } } else { if (this.view.CurrentViewData == null) { this.view.StoreView(search); } else { this.view.CurrentViewData = search; } } this.dataSearch.DownloadQuery = search; this.InitDownloadList(); this.SetViewDefaults(); } }