public void SearchDialogSetSearchCriterias(FinderNode node) { if (node == null) { return; } SearchCriteriaCollection criterias = node.Finder.SearchCriterias; string searchName = node.Finder.FullPath; ResetControlState(); Queue itemAgeCriterias = new Queue(2); foreach (ISearchCriteria criteria in criterias) { SearchCriteriaString str = criteria as SearchCriteriaString; if (str != null) { SearchStringElement where = str.Where; if ((where & SearchStringElement.Title) == SearchStringElement.Title) { checkBoxRssSearchInTitle.Checked = true; } else { checkBoxRssSearchInTitle.Checked = false; } if ((where & SearchStringElement.Content) == SearchStringElement.Content) { checkBoxRssSearchInDesc.Checked = true; } else { checkBoxRssSearchInDesc.Checked = false; } if ((where & SearchStringElement.Subject) == SearchStringElement.Subject) { checkBoxRssSearchInCategory.Checked = true; } else { checkBoxRssSearchInCategory.Checked = false; } if ((where & SearchStringElement.Link) == SearchStringElement.Link) { checkBoxRssSearchInLink.Checked = true; } else { checkBoxRssSearchInLink.Checked = false; } SearchFieldsGroupExpanded = true; // if (str.WhatKind == StringExpressionKind.Text) // radioRssSearchSimpleText.Checked = true; // else if (str.WhatKind == StringExpressionKind.RegularExpression) // radioRssSearchRegEx.Checked = true; // else if (str.WhatKind == StringExpressionKind.XPathExpression) // radioRssSearchExprXPath.Checked = true; // // if (!radioRssSearchSimpleText.Checked) // this.collapsiblePanelRssSearchExprKindEx.Collapsed = false; textSearchExpression.Text = str.What; } SearchCriteriaProperty prop = criteria as SearchCriteriaProperty; if (prop != null) { if (prop.WhatKind == PropertyExpressionKind.Unread) { if (!prop.BeenRead) { checkBoxRssSearchUnreadItems.Checked = true; } else { checkBoxRssSearchUnreadItems.Checked = false; } } IsAdvancedOptionReadStatusActive = true; AdvancedOptionsGroupExpanded = true; } SearchCriteriaAge age = criteria as SearchCriteriaAge; if (age != null) { if (age.WhatRelativeToToday.CompareTo(TimeSpan.Zero) != 0) { // relative item age specified IsAdvancedOptionItemAgeActive = true; if (age.WhatKind == DateExpressionKind.NewerThan) { this.optionSetItemAge.CheckedIndex = 0; } else { this.optionSetItemAge.CheckedIndex = 1; } this.comboRssSearchItemAge.SelectedIndex = Utils.RssSearchItemAgeToIndex(age.WhatRelativeToToday); } else { // absolute item age or range specified, queue for later handling itemAgeCriterias.Enqueue(age); } if (!AdvancedOptionsGroupExpanded) { AdvancedOptionsGroupExpanded = true; } } } if (itemAgeCriterias.Count > 0) { // absolute date specified IsAdvancedOptionItemPostedActive = true; SearchCriteriaAge ageAbs = (SearchCriteriaAge)itemAgeCriterias.Dequeue(); if (ageAbs.WhatKind == DateExpressionKind.Equal) { this.comboBoxRssSearchItemPostedOperator.SelectedIndex = 0; } else if (ageAbs.WhatKind == DateExpressionKind.OlderThan) { this.comboBoxRssSearchItemPostedOperator.SelectedIndex = 1; } else if (ageAbs.WhatKind == DateExpressionKind.NewerThan) { this.comboBoxRssSearchItemPostedOperator.SelectedIndex = 2; } else // between (range): { this.comboBoxRssSearchItemPostedOperator.SelectedIndex = 3; } this.dateTimeRssSearchItemPost.Value = ageAbs.What; if (itemAgeCriterias.Count > 1) { // range specified SearchCriteriaAge ageFrom = (SearchCriteriaAge)itemAgeCriterias.Dequeue(); SearchCriteriaAge ageTo = (SearchCriteriaAge)itemAgeCriterias.Dequeue(); this.dateTimeRssSearchItemPost.Value = ageFrom.What; this.dateTimeRssSearchPostBefore.Value = ageTo.What; } } itemAgeCriterias.Clear(); if (!node.IsTempFinderNode) { textFinderCaption.Text = searchName; } if (textFinderCaption.Text.Length > 0) { SaveSearchGroupExpanded = true; } PopulateTreeRssSearchScope(); // init, all checked. Common case if (this.treeRssSearchScope.Nodes.Count == 0 || (node.Finder.CategoryPathScope == null || node.Finder.CategoryPathScope.Count == 0) && (node.Finder.FeedUrlScope == null || node.Finder.FeedUrlScope.Count == 0)) { return; } this.treeRssSearchScope.Nodes[0].Checked = false; // uncheck all. TreeHelper.CheckChildNodes(this.treeRssSearchScope.Nodes[0], false); TreeHelper.SetCheckedNodes(this.treeRssSearchScope.Nodes[0], node.Finder.CategoryPathScope, node.Finder.FeedUrlScope); }
public SearchCriteriaString(string what, SearchStringElement where, StringExpressionKind kind) { this.What = what; this.Where = where; this.WhatKind = kind; }
private SearchCriteriaCollection SearchDialogGetSearchCriterias() { SearchCriteriaCollection sc = new SearchCriteriaCollection(); SearchStringElement where = SearchStringElement.Undefined; if (textSearchExpression.Text.Length > 0) { if (checkBoxRssSearchInTitle.Checked) { where |= SearchStringElement.Title; } if (checkBoxRssSearchInDesc.Checked) { where |= SearchStringElement.Content; } if (checkBoxRssSearchInCategory.Checked) { where |= SearchStringElement.Subject; } if (checkBoxRssSearchInLink.Checked) { where |= SearchStringElement.Link; } } StringExpressionKind kind = StringExpressionKind.LuceneExpression; // if (radioRssSearchSimpleText.Checked) // kind = StringExpressionKind.Text; // else if (radioRssSearchRegEx.Checked) // kind = StringExpressionKind.RegularExpression; // else if (radioRssSearchExprXPath.Checked) // kind = StringExpressionKind.XPathExpression; SearchCriteriaString scs = new SearchCriteriaString(textSearchExpression.Text, where, kind); sc.Add(scs); if (this.IsAdvancedOptionReadStatusActive) { SearchCriteriaProperty scp = new SearchCriteriaProperty(); scp.BeenRead = !checkBoxRssSearchUnreadItems.Checked; scp.WhatKind = PropertyExpressionKind.Unread; sc.Add(scp); } if (this.IsAdvancedOptionItemAgeActive) { SearchCriteriaAge sca = new SearchCriteriaAge(); if (this.optionSetItemAge.CheckedIndex == 0) { sca.WhatKind = DateExpressionKind.NewerThan; } else { sca.WhatKind = DateExpressionKind.OlderThan; } sca.WhatRelativeToToday = Utils.RssSearchItemAgeToTimeSpan(this.comboRssSearchItemAge.SelectedIndex); sc.Add(sca); } if (this.IsAdvancedOptionItemPostedActive) { if (comboBoxRssSearchItemPostedOperator.SelectedIndex == 0) { sc.Add(new SearchCriteriaAge(dateTimeRssSearchItemPost.Value, DateExpressionKind.Equal)); } else if (comboBoxRssSearchItemPostedOperator.SelectedIndex == 1) { sc.Add(new SearchCriteriaAge(dateTimeRssSearchItemPost.Value, DateExpressionKind.OlderThan)); } else if (comboBoxRssSearchItemPostedOperator.SelectedIndex == 2) { sc.Add(new SearchCriteriaAge(dateTimeRssSearchItemPost.Value, DateExpressionKind.NewerThan)); } else { // handle case: either one date is greater than the other or equal if (dateTimeRssSearchItemPost.Value > dateTimeRssSearchPostBefore.Value) { sc.Add(new SearchCriteriaDateRange(dateTimeRssSearchPostBefore.Value, dateTimeRssSearchItemPost.Value)); } else if (dateTimeRssSearchItemPost.Value < dateTimeRssSearchPostBefore.Value) { sc.Add(new SearchCriteriaDateRange(dateTimeRssSearchItemPost.Value, dateTimeRssSearchPostBefore.Value)); } else { sc.Add(new SearchCriteriaAge(dateTimeRssSearchPostBefore.Value, DateExpressionKind.Equal)); } } } return(sc); }
public SearchRssDocument(INewsItem item, SearchStringElement where) { this.item = item; this.Where = where; }