public void SetControlStateTo(ItemSearchState state, string stateMessage) { switch (state) { case ItemSearchState.Pending: this.btnSearchCancel.Text = SR.RssSearchDialogButtonSearchCaption; SetControlEnabled(true); break; case ItemSearchState.Searching: this.btnSearchCancel.Text = SR.RssSearchDialogButtonCancelCaption; this.panelRssSearchCommands.SetBounds(0, 0, 0, 80, BoundsSpecified.Height); SetControlEnabled(false); break; case ItemSearchState.Finished: SetControlStateTo(ItemSearchState.Pending, stateMessage); return; case ItemSearchState.Canceled: this.btnSearchCancel.Text = SR.RssSearchDialogButtonSearchCaption; SetControlEnabled(true); break; case ItemSearchState.Failure: this.btnSearchCancel.Text = SR.RssSearchDialogButtonSearchCaption; SetControlEnabled(true); break; default: break; } this.labelRssSearchState.Text = stateMessage; _rssSearchState = state; }
private void OnSearchCancelClick(object sender, EventArgs e) { switch (_rssSearchState) { case ItemSearchState.Pending: SetControlStateTo(ItemSearchState.Searching, SR.RssSearchStateMessage); string searchID = Guid.NewGuid().ToString(); string newName = textFinderCaption.Text.Trim(); SearchCriteriaCollection criteria = this.SearchDialogGetSearchCriterias(); //Test scope: // ArrayList cs = new ArrayList(1); // cs.Add("Weblogs"); // ArrayList fs = new ArrayList(1); // fs.Add("http://www.rendelmann.info/blog/GetRss.asmx"); // fs.Add("http://www.25hoursaday.com/webblog/GetRss.asmx"); // activate for scope tests: // resultContainer.Finder = new RssFinder(resultContainer, this.SearchDialogGetSearchCriterias(), // cs, fs, new RssFinder.SearchScopeResolveCallback(this.ScopeResolve) , true); ArrayList catScope = null; ArrayList feedScope = null; // if we have scope nodes, and not all selected: if (this.treeRssSearchScope.Nodes.Count > 0 && !this.treeRssSearchScope.Nodes[0].Checked) { ArrayList cs = new ArrayList(), fs = new ArrayList(); TreeHelper.GetCheckedNodes(this.treeRssSearchScope.Nodes[0], cs, fs); if (cs.Count > 0) { catScope = new ArrayList(cs.Count); } if (fs.Count > 0) { feedScope = new ArrayList(fs.Count); } foreach (TreeNode n in cs) { catScope.Add(TreeHelper.BuildCategoryStoreName(n)); } foreach (TreeNode n in fs) { feedScope.Add((string)n.Tag); } } FinderNode resultContainer; try { resultContainer = this.OnBeforeSearch(searchID, newName, criteria, catScope, feedScope); } catch (Exception validationException) { SetControlStateTo(ItemSearchState.Failure, validationException.Message); break; } this.Refresh(); if (resultContainer != null) { try { OnSearch(resultContainer); } catch (Exception validationException) { SetControlStateTo(ItemSearchState.Failure, validationException.Message); break; } } break; case ItemSearchState.Searching: _rssSearchState = ItemSearchState.Canceled; //this.SetSearchStatusText(SR.RssSearchCancelledStateMessage); btnSearchCancel.Enabled = false; break; case ItemSearchState.Canceled: Debug.Assert(false); // should not be able to press Search button while it is canceling break; } }