private void FilterContextMenuStrip_Opening(object sender, CancelEventArgs e) { BrowsingFilters filters = BrowsingFilter.Filters; filterNoneButton.Checked = filters == BrowsingFilters.None; filterAllButton.Checked = filters == BrowsingFilters.All; filterRecentSearchButton.Checked = filters.HasFlag(BrowsingFilters.RecentSearch); filterQuerySearchButton.Checked = filters.HasFlag(BrowsingFilters.QuerySearch); filterTaggedSearchButton.Checked = filters.HasFlag(BrowsingFilters.TaggedSearch); filterNoneButton.Enabled = filters != BrowsingFilters.None; filterAllButton.Enabled = filters != BrowsingFilters.All; }
public static BrowsingFilters ToggleFlag(this BrowsingFilters flags, BrowsingFilters flag) { if (flags.HasFlag(flag)) { flags &= ~flag; } else { flags |= flag; } return(flags); }
private bool ShouldFilterType(KeyValuePair <string, BrowsingItem> value) { bool none = filters == BrowsingFilters.None; bool all = filters == BrowsingFilters.All; if (none) { return(false); } else if (all) { return(true); } else { bool recent = filters.HasFlag(BrowsingFilters.RecentSearch); bool query = filters.HasFlag(BrowsingFilters.QuerySearch); bool tagged = filters.HasFlag(BrowsingFilters.TaggedSearch); return((recent && value.Key.StartsWith("recent:", StringComparison.OrdinalIgnoreCase)) || (query && value.Key.StartsWith("query:", StringComparison.OrdinalIgnoreCase)) || (tagged && value.Key.StartsWith("tagged:", StringComparison.OrdinalIgnoreCase))); } }