public static void TimedFilter(ObjectListView olv, string txt, TextMatchFilter.MatchKind matchKind = TextMatchFilter.MatchKind.Text) { TextMatchFilter filter = null; if (!String.IsNullOrEmpty(txt)) filter = new TextMatchFilter(olv, txt, matchKind); // Setup a default renderer to draw the filter matches olv.DefaultRenderer = filter == null ? null : new HighlightTextRenderer(filter); // Some lists have renderers already installed var highlightingRenderer = olv.GetColumn(0).Renderer as HighlightTextRenderer; if (highlightingRenderer != null) highlightingRenderer.Filter = filter; olv.ModelFilter = filter; }
/// <summary> /// Creates a regex strategy /// </summary> /// <param name="filter"></param> /// <param name="text"></param> public TextRegexMatchingStrategy(TextMatchFilter filter, string text) { this.TextFilter = filter; this.Text = text; }
/// <summary> /// Create a text contains strategy /// </summary> /// <param name="filter"></param> /// <param name="text"></param> public TextContainsMatchingStrategy(TextMatchFilter filter, string text) { this.TextFilter = filter; this.Text = text; }
/// <summary> /// Create a HighlightTextRenderer /// </summary> /// <param name="filter"></param> public HighlightTextRenderer(TextMatchFilter filter) : this() { this.Filter = filter; }
/// <summary> /// Create a text filter that includes rows where any cell contains any of the given strings. /// </summary> /// <param name="olv"></param> /// <param name="texts"></param> /// <returns></returns> public static TextMatchFilter Contains(ObjectListView olv, params string[] texts) { TextMatchFilter filter = new TextMatchFilter(olv); filter.ContainsStrings = texts; return filter; }
/// <summary> /// Create a text filter that includes rows where any cell begins with one of the given strings /// </summary> /// <param name="olv"></param> /// <param name="texts"></param> /// <returns></returns> public static TextMatchFilter Prefix(ObjectListView olv, params string[] texts) { TextMatchFilter filter = new TextMatchFilter(olv); filter.PrefixStrings = texts; return filter; }
// // Filter Problem List // private void searchBox1_SearchTextChanged(object sender, EventArgs e) { problemListView.SelectedObjects.Clear(); if (deepSearchCheckBox.Checked) { return; } if (searchBox1.SearchText.Length == 0) { ClearSearch(); } else { problemListView.ShowGroups = false; TextMatchFilter filter = new TextMatchFilter(problemListView, searchBox1.SearchText, StringComparison.OrdinalIgnoreCase); problemListView.DefaultRenderer = new HighlightTextRenderer(filter); problemListView.AdditionalFilter = filter; } }
// // Filter Category list // private void searchBox2_SearchTextChanged(object sender, EventArgs e) { categoryListView.SelectedObjects.Clear(); if (filterBox1.SearchText.Length == 0) { categoryListView.DefaultRenderer = null; categoryListView.AdditionalFilter = null; categoryListView.CollapseAll(); foreach (var b in categoryListView.Roots) { categoryListView.Expand(b); } categoryListView.EnsureVisible(0); } else { TextMatchFilter filter = new TextMatchFilter(categoryListView, filterBox1.SearchText, StringComparison.OrdinalIgnoreCase); categoryListView.ExpandAll(); categoryListView.DefaultRenderer = new HighlightTextRenderer(filter); categoryListView.AdditionalFilter = filter; } }
private void textBox1_TextChanged(object sender, EventArgs e) { var Text = textBox1.Text; if (Text.Length > 0) { TextMatchFilter filter = new TextMatchFilter(objectListView1, Text); objectListView1.UseFiltering = true; objectListView1.ModelFilter = filter; //objectListView1.DefaultRenderer = new HighlightTextRenderer(filter); } else { objectListView1.UseFiltering = false; objectListView1.ModelFilter = null; //objectListView1.DefaultRenderer = new BaseRenderer(); } }
/// <summary> /// Filter list by text /// </summary> /// <param name="olv"></param> /// <param name="txt"></param> void ResultTextFilter(ObjectListView olv, string txt) { TextMatchFilter filter = null; if (!String.IsNullOrEmpty(txt)) filter = new TextMatchFilter(olv, txt); // Setup a default renderer to draw the filter matches if (filter == null) olv.DefaultRenderer = null; else olv.DefaultRenderer = new HighlightTextRenderer(txt); // Some lists have renderers already installed HighlightTextRenderer highlightingRenderer = olv.GetColumn(0).Renderer as HighlightTextRenderer; if (highlightingRenderer != null) highlightingRenderer.TextToHighlight = txt; olv.ModelFilter = filter; /* Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); olv.ModelFilter = filter; stopWatch.Stop(); IList objects = olv.Objects as IList; if (objects == null) this.toolStripStatusLabel1.Text = String.Format("Filtered in {0}ms", stopWatch.ElapsedMilliseconds); else this.toolStripStatusLabel1.Text = String.Format("Filtered {0} items down to {1} items in {2}ms", objects.Count, olv.Items.Count, stopWatch.ElapsedMilliseconds); */ //GC.Collect();//Melek }
/// <summary> /// Create a text filter that will include rows where any cell matches /// any of the given regex expressions. /// </summary> /// <param name="olv"></param> /// <param name="texts"></param> /// <returns></returns> /// <remarks>Any string that is not a valid regex expression will be ignored.</remarks> public static TextMatchFilter Regex(ObjectListView olv, params string[] texts) { var filter = new TextMatchFilter(olv); filter.RegexStrings = texts; return filter; }
/// <summary> /// Create a text begins strategy /// </summary> /// <param name="filter"></param> /// <param name="text"></param> public TextBeginsMatchingStrategy(TextMatchFilter filter, string text) { TextFilter = filter; Text = text; }
private void textBox1_TextChanged(object sender, EventArgs e) { var Text = FilterTextBox.Text; if (Text.Length > 0) { TextMatchFilter filter = new TextMatchFilter(GameListView, Text); GameListView.UseFiltering = true; GameListView.ModelFilter = filter; //objectListView1.DefaultRenderer = new HighlightTextRenderer(filter); } else { GameListView.UseFiltering = false; GameListView.ModelFilter = null; //objectListView1.DefaultRenderer = new BaseRenderer(); } GameListView.FullRowSelect = true; GameListView.SelectedIndex = MathUtils.Clamp(GameListView.SelectedIndex, 0, GameListView.Items.Count - 1); }