/// <summary> /// Use Fast Filter /// </summary> private void UseFastFilterRecipes() { if (FastFilterList.Count == 0) { FastFilter = TextMatchFilter.Contains(olvRecipes, ""); } else { string[] filterArray = FastFilterList.ToArray(); FastFilter = TextMatchFilter.Prefix(olvRecipes, filterArray); } if (cbFastFilterCol.SelectedIndex == 0) { FastFilter.Columns = new OLVColumn[] { recName, recCategory, recExcluded } } ; else if (cbFastFilterCol.SelectedIndex == 1) { FastFilter.Columns = new OLVColumn[] { recName } } ; else if (cbFastFilterCol.SelectedIndex == 2) { FastFilter.Columns = new OLVColumn[] { recCategory } } ; else if (cbFastFilterCol.SelectedIndex == 3) { FastFilter.Columns = new OLVColumn[] { recExcluded } } ; }
/// <summary> /// Use Standard Filter /// </summary> private void UseStandardFilterRecipes() { StandardFilter = TextMatchFilter.Contains(olvRecipes, txtFilter.Text); if (cbFilterCol.SelectedIndex == 0) { StandardFilter.Columns = new OLVColumn[] { recName, recCategory, recKeywords, recExcluded } } ; else if (cbFilterCol.SelectedIndex == 1) { StandardFilter.Columns = new OLVColumn[] { recName } } ; else if (cbFilterCol.SelectedIndex == 2) { StandardFilter.Columns = new OLVColumn[] { recCategory } } ; else if (cbFilterCol.SelectedIndex == 3) { StandardFilter.Columns = new OLVColumn[] { recKeywords } } ; else if (cbFilterCol.SelectedIndex == 4) { StandardFilter.Columns = new OLVColumn[] { recExcluded } } ; }
public void TimedFilter(ObjectListView olv, string txt, int matchKind) { TextMatchFilter filter = null; if (!String.IsNullOrEmpty(txt)) { switch (matchKind) { case 0: default: filter = TextMatchFilter.Contains(olv, txt); break; case 1: filter = TextMatchFilter.Prefix(olv, txt); break; case 2: filter = TextMatchFilter.Regex(olv, txt); break; } } olv.AdditionalFilter = filter; }
/// <summary> /// Called when you type something inside the text box above the main module list view. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void textBoxFilterSimple_TextChanged(object sender, EventArgs e) { // Use a timer to have a single update for more than one "text changed" event, better UX _moduleFilter.Restart(false, (object s, ElapsedEventArgs e1) => { BeginInvoke(new MethodInvoker(() => { TextMatchFilter filter = null; Debug.WriteLineIf(DEBUG, "Text Changed!"); if (rb_RegexFilter.Checked) { filter = TextMatchFilter.Regex(olv_ModuleView, textBoxFilterSimple.Text); } else { filter = TextMatchFilter.Contains(olv_ModuleView, textBoxFilterSimple.Text); } olv_ModuleView.AdditionalFilter = filter; if (!_UIUpdateInProgress) { AddSumRow(olv_ModuleView.FilteredObjects); PopulateSymbolLV(FilterSymbols(olv_ModuleView.FilteredObjects.Cast <Module>().ToList())); olv_ModuleView.Invalidate(); } })); }); }
private void TimedFilter(ObjectListView olv, string txt, int matchKind) { TextMatchFilter filter = null; if (!string.IsNullOrEmpty(txt)) { switch (matchKind) { default: filter = TextMatchFilter.Contains(olv, txt); break; case 1: filter = TextMatchFilter.Prefix(olv, txt); break; case 2: filter = TextMatchFilter.Regex(olv, txt); break; } } // Setup a default renderer to draw the filter matches olv.DefaultRenderer = filter == null ? null : new HighlightTextRenderer(filter); // Some lists have renderers already installed if (olv.GetColumn(0).Renderer is HighlightTextRenderer highlightingRenderer) { highlightingRenderer.Filter = filter; } olv.ModelFilter = filter; SetItemCount(); }
/// <summary> /// Use Fast Filter /// </summary> private void UseFastFilterLending() { if (FastFilterList.Count == 0) { FastFilter = TextMatchFilter.Contains(olvLending, ""); } else { string[] filterArray = FastFilterList.ToArray(); FastFilter = TextMatchFilter.Prefix(olvLending, filterArray); } if (cbFastFilterCol.SelectedIndex == 0) { FastFilter.Columns = new OLVColumn[] { ldItemType, ldItemName, ldPerson } } ; else if (cbFastFilterCol.SelectedIndex == 1) { FastFilter.Columns = new OLVColumn[] { ldItemType } } ; else if (cbFastFilterCol.SelectedIndex == 2) { FastFilter.Columns = new OLVColumn[] { ldItemName } } ; else if (cbFastFilterCol.SelectedIndex == 3) { FastFilter.Columns = new OLVColumn[] { ldPerson } } ; }
// Search by text, expanding any parent nodes to reveal child match. internal void AddStringFilter(String text) { // If string filter is not null, try and remove it from active filter list if (StringFilter != null) { if (this.Filters.Contains(StringFilter)) { this.Filters.Remove(StringFilter); } StringFilter = null; } // Only search if string is not empty, and ensure all matched children are showing by expanding parents. if (!String.IsNullOrEmpty(text)) { StringFilter = TextMatchFilter.Contains(this.ListView, text); StringFilter.Columns = new OLVColumn[] { ListView.NlmColumns.NameColumn }; ExpandParentsOfMatchedChildren(text); this.Filters.Add(StringFilter); } // Set the filter to correspone to the text being searched. If text is "", nothing is filtered. HighlightTextRenderer highLightingRenderer = ListView.NlmColumns.NameColumn.Renderer as HighlightTextRenderer; if (highLightingRenderer != null) { highLightingRenderer.Filter = StringFilter; } }
/// <summary> /// Called when you type something inside the text box above the main module list view. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void textBoxFilterSimple_TextChanged(object sender, EventArgs e) { TextMatchFilter filter = null; if (rb_RegexFilter.Checked) { filter = TextMatchFilter.Regex(olv_ModuleView, textBoxFilterSimple.Text); } else { filter = TextMatchFilter.Contains(olv_ModuleView, textBoxFilterSimple.Text); } olv_ModuleView.AdditionalFilter = filter; AddSumRow(olv_ModuleView.FilteredObjects); foreach (var x in olv_ModuleView.FilteredObjects) { Debug.WriteLineIf(DEBUG, "Selected:" + ((Module)x).ModuleName); } // Use a timer to have a single update for more than one "text changed" event, better UX _timer.Stop(); // Stop an existing timer _timer.AutoReset = false; // one shot _timer.Enabled = true; _timer.Elapsed += (object s, ElapsedEventArgs e1) => { if (!_UIUpdateInProgress) { PopulateSymbolLV(FilterSymbols(olv_ModuleView.FilteredObjects.Cast <Module>().ToList())); olv_ModuleView.Invalidate(); } }; _timer.Start(); }
private void OnFilterReceive(Observer MsgName, Msg Msg) { string Type = Msg.Sender == null ? string.Empty : Msg.Sender.ToString(); string filter = Msg.Message == null ? string.Empty : Msg.Message.ToString(); //沒有聯動 if (string.IsNullOrEmpty(filter)) { olvError.DefaultRenderer = null; olvError.ModelFilter = null; } else { TextMatchFilter filter1 = TextMatchFilter.Contains(olvError, filter); filter1.Columns = new OLVColumn[] { olvcOrderID }; if (Type == "Filter") //過濾 { olvError.ModelFilter = new CompositeAllFilter(new List <IModelFilter> { filter1 }); olvError.DefaultRenderer = null; } else if (Type == "Renderer") //聯動 { olvError.ModelFilter = null; olvError.DefaultRenderer = new HighlightTextRenderer(filter1); } } olvError.Refresh(); }
void TimedFilter(ObjectListView olv, string txt, int matchKind) { TextMatchFilter filter = null; if (!String.IsNullOrEmpty(txt)) { switch (matchKind) { case 0: default: filter = TextMatchFilter.Contains(olv, txt); break; case 1: filter = TextMatchFilter.Prefix(olv, txt); break; case 2: filter = TextMatchFilter.Regex(olv, txt); break; } } if (filter == null) { olv.DefaultRenderer = null; } else { olv.DefaultRenderer = new HighlightTextRenderer(filter); } HighlightTextRenderer highlightingRenderer = olv.GetColumn(0).Renderer as HighlightTextRenderer; if (highlightingRenderer != null) { highlightingRenderer.Filter = 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); } }
private void txtBx_SymFilter_TextChanged(object sender, EventArgs e) { TextMatchFilter filter = null; if (rb_RegexFilter2.Checked) { filter = TextMatchFilter.Regex(olv_SymbolView, txtBx_SymFilter.Text); } else { filter = TextMatchFilter.Contains(olv_SymbolView, txtBx_SymFilter.Text); } olv_SymbolView.AdditionalFilter = filter; // Use a timer to have a single update for more than "text changed" event, better UX _timer.Stop(); // Stop an existing timer _timer.AutoReset = false; // one shot _timer.Enabled = true; _timer.Elapsed += (object s, ElapsedEventArgs e1) => { if (!_UIUpdateInProgress) { AddSumRow(olv_SymbolView.FilteredObjects.Cast <Symbol>().ToList()); olv_SymbolView.Invalidate(); } }; _timer.Start(); }
public void DisplaySearchResults() { chatTable.SetObjects(SearchResults); chatTable.Invalidate(); var filters = new List <IModelFilter>(); TextMatchFilter highlightingFilter = null; if (!String.IsNullOrEmpty(searchBox.Text)) { char[] sep = { ',', '\"', ':' }; var words = searchBox.Text.Trim().Split(sep); highlightingFilter = TextMatchFilter.Contains(chatTable, words); foreach (var word in words) { var filter = TextMatchFilter.Contains(chatTable, word); filters.Add(filter); //filters.Add(tagFilter); } } var compositeFilter = new CompositeAllFilter(filters); chatTable.ModelFilter = highlightingFilter; chatTable.AdditionalFilter = compositeFilter; highlightTextRenderer1.Filter = highlightingFilter; }
private void UpdateTreeListView() { if (Chunk == null) { treeView.Roots = null; return; } var root = showOnlySerialized ? Chunk.GetEditableVariables().Where(_ => _.IsSerialized) : Chunk.GetEditableVariables(); treeView.Roots = root; // filter this.treeView.ModelFilter = !string.IsNullOrEmpty(toolStripSearchBox.Text.ToUpper()) ? TextMatchFilter.Contains(treeView, toolStripSearchBox.Text.ToUpper()) : null; foreach (var treeViewObject in treeView.Objects) { treeView.Expand(treeViewObject); treeView.RefreshObject(treeViewObject); } }
private void toolFilterBox_TextChanged(object sender, EventArgs e) { if (itemListViewExt.Columns.Count < 4) { return; } TextMatchFilter filter = null; filter = TextMatchFilter.Contains(itemListViewExt, toolFilterBox.Text); if (filter == null) { itemListViewExt.DefaultRenderer = null; } else { itemListViewExt.DefaultRenderer = new HighlightTextRenderer(filter); } // Some lists have renderers already installed HighlightTextRenderer highlightingRenderer = itemListViewExt.GetColumn(3).Renderer as HighlightTextRenderer; if (highlightingRenderer != null) { highlightingRenderer.Filter = filter; } //Stopwatch stopWatch = new Stopwatch(); //stopWatch.Start(); itemListViewExt.AdditionalFilter = filter; //olv.Invalidate(); //stopWatch.Stop(); }
/// <summary> /// 收到聯動設定 /// </summary> /// <param name="n"></param> private void OnFilterReceive(Notification n) { string Type = n.Sender == null ? string.Empty : n.Sender.ToString(); string filter = n.Message == null ? string.Empty : n.Message.ToString(); //沒有聯動 if (string.IsNullOrEmpty(filter)) { olvCancel.DefaultRenderer = null; olvCancel.ModelFilter = null; } else { TextMatchFilter filter1 = TextMatchFilter.Contains(olvCancel, filter); filter1.Columns = new OLVColumn[] { this.olvcOrdNo }; if (Type == "Filter") //過濾 { olvCancel.ModelFilter = new CompositeAllFilter(new List <IModelFilter> { filter1 }); olvCancel.DefaultRenderer = null; } else if (Type == "Renderer") //聯動 { olvCancel.DefaultRenderer = new HighlightTextRenderer(filter1); olvCancel.ModelFilter = null; } olvCancel.Refresh(); } }
/// <summary> /// Use Standard Filter /// </summary> private void UseStandardFilterBooks() { StandardFilter = TextMatchFilter.Contains(olvBooks, txtFilter.Text); if (cbFilterCol.SelectedIndex == 0) { StandardFilter.Columns = new OLVColumn[] { bkAuthor, bkGenre, bkInvNum, bkKeywords, bkLocation, bkName, bkSeries, bkSubgenre, bkType, bkYear } } ; else if (cbFilterCol.SelectedIndex == 1) { StandardFilter.Columns = new OLVColumn[] { bkName } } ; else if (cbFilterCol.SelectedIndex == 2) { StandardFilter.Columns = new OLVColumn[] { bkAuthor } } ; else if (cbFilterCol.SelectedIndex == 3) { StandardFilter.Columns = new OLVColumn[] { bkType } } ; else if (cbFilterCol.SelectedIndex == 4) { StandardFilter.Columns = new OLVColumn[] { bkYear } } ; else if (cbFilterCol.SelectedIndex == 5) { StandardFilter.Columns = new OLVColumn[] { bkGenre } } ; else if (cbFilterCol.SelectedIndex == 6) { StandardFilter.Columns = new OLVColumn[] { bkSubgenre } } ; else if (cbFilterCol.SelectedIndex == 7) { StandardFilter.Columns = new OLVColumn[] { bkInvNum } } ; else if (cbFilterCol.SelectedIndex == 8) { StandardFilter.Columns = new OLVColumn[] { bkLocation } } ; else if (cbFilterCol.SelectedIndex == 9) { StandardFilter.Columns = new OLVColumn[] { bkKeywords } } ; else if (cbFilterCol.SelectedIndex == 10) { StandardFilter.Columns = new OLVColumn[] { bkSeries } } ; }
public virtual void Test_TextFilter_FindAll_Text_NoMatch_Multiple() { TextMatchFilter filter = TextMatchFilter.Contains(this.olv, "xyz", "jpp"); List <CharacterRange> ranges = new List <CharacterRange>(filter.FindAllMatchedRanges("x-abcd-ABCD")); Assert.AreEqual(0, ranges.Count); }
private void filterMods_TextChanged(object sender, EventArgs e) { TextMatchFilter filter = null; int matchKind = 0; string txt = ((TextBox)sender).Text; if (!String.IsNullOrEmpty(txt)) { switch (matchKind) { case 0: default: filter = TextMatchFilter.Contains(modlist_ListObjectListView, txt); break; case 1: filter = TextMatchFilter.Prefix(modlist_ListObjectListView, txt); break; case 2: filter = TextMatchFilter.Regex(modlist_ListObjectListView, txt); break; } } // Text highlighting requires at least a default renderer if (modlist_ListObjectListView.DefaultRenderer == null) { modlist_ListObjectListView.DefaultRenderer = new HighlightTextRenderer(filter); } modlist_ListObjectListView.AdditionalFilter = filter; }
void Filter(FastObjectListView olv, string txt, int matchKind) { olv.OwnerDraw = true; TextMatchFilter filter = null; if (!String.IsNullOrEmpty(txt)) { switch (matchKind) { case 0: default: filter = TextMatchFilter.Contains(olv, txt); break; case 1: filter = TextMatchFilter.Prefix(olv, txt); break; case 2: filter = TextMatchFilter.Regex(olv, txt); break; } } // Setup a default renderer to draw the filter matches if (filter == null) { olv.DefaultRenderer = null; olv.ModelFilter = null; } else { olv.DefaultRenderer = new HighlightTextRenderer(filter); olv.ModelFilter = filter; // Uncomment this line to see how the GDI+ rendering looks //olv.DefaultRenderer = new HighlightTextRenderer { Filter = filter, UseGdiTextRendering = false }; } // Some lists have renderers already installed HighlightTextRenderer highlightingRenderer = olv.GetColumn(0).Renderer as HighlightTextRenderer; if (highlightingRenderer != null) { highlightingRenderer.Filter = filter; } IList objects = olv.Objects as IList; if ((objects == null) || (objects.Count == olv.Items.Count)) { this.toolStripStatusLabel1.Text = string.Empty; } else { this.toolStripStatusLabel1.Text = String.Format("Filtered {0} items down to {1} items", objects.Count, olv.Items.Count); } }
private void mSearchBox_TextChanged(object sender, EventArgs e) { TextMatchFilter nFilter = null; nFilter = TextMatchFilter.Contains(this.objectListView1, this.mSearchBox.Text); nFilter.RegexOptions = System.Text.RegularExpressions.RegexOptions.IgnoreCase; this.objectListView1.ModelFilter = nFilter; }
private void SearchTextChanged(object sender, EventArgs e) { filter = TextMatchFilter.Contains(modListView, textBoxSearch.Text); hfilter = new HighlightTextRenderer(filter); modListView.ModelFilter = filter; modListView.DefaultRenderer = hfilter; hfilter.UseRoundedRectangle = false; }
private void SearchBox_TextChanged(object sender, EventArgs e) { var text = (sender as TextBox).Text; ListView.AdditionalFilter = !string.IsNullOrEmpty(text) ? TextMatchFilter.Contains(ListView, text) : null; }
public static void InitFastObjectListView(FastObjectListView lv, System.Windows.Forms.TextBox filterBox) { lv.UseFiltering = true; lv.UseAlternatingBackColors = true; lv.AlternateRowBackColor = alternateRowBackColor; lv.Font = objectListViewFont; lv.FullRowSelect = true; filterBox.TextChanged += delegate { lv.ModelFilter = TextMatchFilter.Contains(lv, filterBox.Text); }; }
private void TextBox_Search_TextChanged(object sender, EventArgs e) { filter = TextMatchFilter.Contains(olvLootList, textBoxSearch.Text); hfilter = new HighlightTextRenderer(filter); olvLootList.ModelFilter = filter; olvLootList.DefaultRenderer = hfilter; hfilter.UseRoundedRectangle = false; Olv_ParseEntries(); }
/// <summary> /// Use Fast Filter /// </summary> private void UseFastFilterObjects() { if (FastFilterList.Count == 0) { FastFilter = TextMatchFilter.Contains(olvObjects, ""); } else { string[] filterArray = FastFilterList.ToArray(); FastFilter = TextMatchFilter.Prefix(olvObjects, filterArray); } if (cbFastFilterCol.SelectedIndex == 0) { FastFilter.Columns = new OLVColumn[] { objName, objType, objCategory, objNumber, objParent, objCustomer, objDevelopment, objActive } } ; else if (cbFastFilterCol.SelectedIndex == 1) { FastFilter.Columns = new OLVColumn[] { objName } } ; else if (cbFastFilterCol.SelectedIndex == 2) { FastFilter.Columns = new OLVColumn[] { objType } } ; else if (cbFastFilterCol.SelectedIndex == 3) { FastFilter.Columns = new OLVColumn[] { objCategory } } ; else if (cbFastFilterCol.SelectedIndex == 4) { FastFilter.Columns = new OLVColumn[] { objNumber } } ; else if (cbFastFilterCol.SelectedIndex == 5) { FastFilter.Columns = new OLVColumn[] { objParent } } ; else if (cbFastFilterCol.SelectedIndex == 6) { FastFilter.Columns = new OLVColumn[] { objCustomer } } ; else if (cbFastFilterCol.SelectedIndex == 7) { FastFilter.Columns = new OLVColumn[] { objDevelopment } } ; else if (cbFastFilterCol.SelectedIndex == 8) { FastFilter.Columns = new OLVColumn[] { objActive } } ; }
/// <summary> /// Use Fast Filter /// </summary> private void UseFastFilterCopies() { if (FastFilterList.Count == 0) { FastFilter = TextMatchFilter.Contains(olvCopies, ""); } else { string[] filterArray = FastFilterList.ToArray(); FastFilter = TextMatchFilter.Prefix(olvCopies, filterArray); } if (cbFastFilterCol.SelectedIndex == 0) { FastFilter.Columns = new OLVColumn[] { cpName, cpType, cpInvNum, cpBarcode, cpCondition, cpLocation, cpExcluded, cpStatus } } ; else if (cbFastFilterCol.SelectedIndex == 1) { FastFilter.Columns = new OLVColumn[] { cpName } } ; else if (cbFastFilterCol.SelectedIndex == 2) { FastFilter.Columns = new OLVColumn[] { cpType } } ; else if (cbFastFilterCol.SelectedIndex == 3) { FastFilter.Columns = new OLVColumn[] { cpInvNum } } ; else if (cbFastFilterCol.SelectedIndex == 4) { FastFilter.Columns = new OLVColumn[] { cpBarcode } } ; else if (cbFastFilterCol.SelectedIndex == 5) { FastFilter.Columns = new OLVColumn[] { cpCondition } } ; else if (cbFastFilterCol.SelectedIndex == 6) { FastFilter.Columns = new OLVColumn[] { cpLocation } } ; else if (cbFastFilterCol.SelectedIndex == 7) { FastFilter.Columns = new OLVColumn[] { cpExcluded } } ; else if (cbFastFilterCol.SelectedIndex == 8) { FastFilter.Columns = new OLVColumn[] { cpStatus } } ; }
// ----- DESCRIPTION FILTER ----- private void txtFilter_TextChanged(object sender, EventArgs e) { filterDesc = TextMatchFilter.Contains(olvLog, txtFilter.Text); filterDesc.Columns = new OLVColumn[] { olvLogDesc }; olvLog.UseFiltering = true; olvLog.ModelFilter = new CompositeAllFilter(new List <IModelFilter> { filterDesc, filterLevel, filterDevice, filterHistory }); }
private void filterToolStripTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { var filter = TextMatchFilter.Contains(this.fastObjectListViewRows, filterToolStripTextBox.Text); _highlighter.Filter = filter; fastObjectListViewRows.ModelFilter = filter; fastObjectListViewRows.Refresh(); } }
private void filterToolStripTextBox_TextChanged(object sender, EventArgs e) { if (filterToolStripTextBox.TextLength == 0) { var filter = TextMatchFilter.Contains(this.fastObjectListViewRows, string.Empty); _highlighter.Filter = filter; fastObjectListViewRows.ModelFilter = filter; fastObjectListViewRows.Refresh(); } }
public virtual void Test_TextFilter_Columns_NoMatch() { this.olv.SetObjects(PersonDb.All); this.olv.UseFiltering = true; TextMatchFilter filter = TextMatchFilter.Contains(this.olv, "occup"); filter.Columns = new OLVColumn[] { this.olv.GetColumn(0), this.olv.GetColumn(2) }; this.olv.ModelFilter = filter; Assert.AreEqual(0, this.olv.GetItemCount()); }