Example #1
0
        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;
        }
Example #2
0
 public virtual void Test_TextFilter_Prefix_NoMatch()
 {
     this.olv.SetObjects(PersonDb.All);
     this.olv.UseFiltering = true;
     this.olv.ModelFilter  = TextMatchFilter.Prefix(this.olv, PersonDb.LastAlphabeticalName.ToLowerInvariant().Substring(1, 4));
     Assert.AreEqual(0, this.olv.GetItemCount());
 }
Example #3
0
        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;
                }
            }

            // Text highlighting requires at least a default renderer
            if (olv.DefaultRenderer == null)
            {
                olv.DefaultRenderer = new HighlightTextRenderer(filter);
            }

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            olv.AdditionalFilter = filter;
            stopWatch.Stop();
        }
        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);
            }
        }
Example #5
0
        public virtual void Test_TextFilter_FindAll_StringStart_NoMatch()
        {
            TextMatchFilter       filter = TextMatchFilter.Prefix(this.olv, "abc");
            List <CharacterRange> ranges = new List <CharacterRange>(filter.FindAllMatchedRanges("x-abcd-ABCD"));

            Assert.AreEqual(0, ranges.Count);
        }
Example #6
0
 /// <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 }
     }
     ;
 }
Example #7
0
        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;
        }
Example #8
0
 /// <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 }
     }
     ;
 }
Example #9
0
        private void Find()
        {
            string[]        txt    = txtSearch.Text.Split('|').Select(x => x.Trim()).ToArray();
            TextMatchFilter filter = null;

            switch (comboBoxFilterType.SelectedIndex)
            {
            case 0:
            default:
                filter = TextMatchFilter.Contains(listView, txt);
                break;

            case 1:
                filter = TextMatchFilter.Prefix(listView, txt);
                break;

            case 2:
                filter = TextMatchFilter.Regex(listView, txt);
                break;
            }
            listView.DefaultRenderer  = new HighlightTextRenderer(filter);
            listView.AdditionalFilter = filter;

            IList objects = listView.Objects as IList;
        }
Example #10
0
        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();
        }
Example #11
0
        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);
            }
        }
Example #12
0
 /// <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 }
     }
     ;
 }
Example #13
0
 /// <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 }
     }
     ;
 }
Example #14
0
        public virtual void Test_TextFilter_FindAll_StringStart_Multiple()
        {
            TextMatchFilter       filter = TextMatchFilter.Prefix(this.olv, "xyz", "abc");
            List <CharacterRange> ranges = new List <CharacterRange>(filter.FindAllMatchedRanges("abcd-ABCD"));

            Assert.AreEqual(1, ranges.Count);
            Assert.AreEqual(0, ranges[0].First);
            Assert.AreEqual(3, ranges[0].Length);
        }
Example #15
0
        public virtual void Test_TextFilter_Prefix_CaseSensitive()
        {
            this.olv.SetObjects(PersonDb.All);
            this.olv.UseFiltering = true;
            TextMatchFilter filter = TextMatchFilter.Prefix(this.olv, PersonDb.LastAlphabeticalName.ToLowerInvariant().Substring(0, 4));

            filter.StringComparison = StringComparison.InvariantCulture;
            this.olv.ModelFilter    = filter;
            Assert.AreEqual(1, this.olv.GetItemCount());
        }
Example #16
0
        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;
                }
            }
            // Setup a default renderer to draw the filter matches
            olv.DefaultRenderer = filter == null ? null : new HighlightTextRenderer(filter);
            // Some lists have renderers already installed
            HighlightTextRenderer highlightingRenderer = olv.GetColumn(0).Renderer as HighlightTextRenderer;

            if (highlightingRenderer != null)
            {
                highlightingRenderer.Filter = filter;
            }

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            olv.AdditionalFilter = filter;
            //olv.Invalidate();
            stopWatch.Stop();

            IList objects = olv.Objects as IList;

            if (objects == null)
            {
                toolStripStatusLabel1.Text =
                    String.Format("Filtered in {0}ms", stopWatch.ElapsedMilliseconds);
            }
            else
            {
                toolStripStatusLabel1.Text =
                    String.Format("在 {0} 条数据中过滤出符合条件的 {1} 数据,耗时{2}ms",
                                  objects.Count,
                                  olv.Items.Count,
                                  stopWatch.ElapsedMilliseconds);
            }
        }
Example #17
0
 /// <summary>
 /// Use Fast Filter
 /// </summary>
 private void UseFastFilterBooks()
 {
     if (FastFilterList.Count == 0)
     {
         FastFilter = TextMatchFilter.Contains(olvBooks, "");
     }
     else
     {
         string[] filterArray = FastFilterList.ToArray();
         FastFilter = TextMatchFilter.Prefix(olvBooks, filterArray);
     }
     if (cbFastFilterCol.SelectedIndex == 0)
     {
         FastFilter.Columns = new OLVColumn[] { bkAuthor, bkGenre, bkInvNum, bkKeywords, bkLocation, bkName, bkSeries, bkSubgenre, bkType, bkYear }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 1)
     {
         FastFilter.Columns = new OLVColumn[] { bkName }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 2)
     {
         FastFilter.Columns = new OLVColumn[] { bkAuthor }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 3)
     {
         FastFilter.Columns = new OLVColumn[] { bkType }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 4)
     {
         FastFilter.Columns = new OLVColumn[] { bkGenre }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 5)
     {
         FastFilter.Columns = new OLVColumn[] { bkSubgenre }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 6)
     {
         FastFilter.Columns = new OLVColumn[] { bkLocation }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 7)
     {
         FastFilter.Columns = new OLVColumn[] { bkSeries }
     }
     ;
 }
Example #18
0
        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;
                }
            }

            // Text highlighting requires at least a default renderer
            if (olv.DefaultRenderer == null)
            {
                olv.DefaultRenderer = new HighlightTextRenderer(filter);
            }

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            olv.AdditionalFilter = filter;
            //olv.Invalidate();
            stopWatch.Stop();

            IList objects = olv.Objects as IList;

            if (objects == null)
            {
                this.ToolStripStatus1 = prefixForNextSelectionMessage =
                    String.Format("Filtered in {0}ms", stopWatch.ElapsedMilliseconds);
            }
            else
            {
                this.ToolStripStatus1 = prefixForNextSelectionMessage =
                    String.Format("Filtered {0} items down to {1} items in {2}ms",
                                  objects.Count,
                                  olv.Items.Count,
                                  stopWatch.ElapsedMilliseconds);
            }
        }
Example #19
0
 /// <summary>
 /// Use Fast Filter
 /// </summary>
 private void UseFastFilterContacts()
 {
     if (FastFilterList.Count == 0)
     {
         FastFilter = TextMatchFilter.Contains(olvContacts, "");
     }
     else
     {
         string[] filterArray = FastFilterList.ToArray();
         FastFilter = TextMatchFilter.Prefix(olvContacts, filterArray);
     }
     if (cbFastFilterCol.SelectedIndex == 0)
     {
         FastFilter.Columns = new OLVColumn[] { conName, conSurname, conNick, conPhone, conEmail, conAddress, conCompany }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 1)
     {
         FastFilter.Columns = new OLVColumn[] { conName }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 2)
     {
         FastFilter.Columns = new OLVColumn[] { conSurname }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 3)
     {
         FastFilter.Columns = new OLVColumn[] { conNick }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 4)
     {
         FastFilter.Columns = new OLVColumn[] { conPhone }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 5)
     {
         FastFilter.Columns = new OLVColumn[] { conEmail }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 6)
     {
         FastFilter.Columns = new OLVColumn[] { conAddress }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 7)
     {
         FastFilter.Columns = new OLVColumn[] { conCompany }
     }
     ;
 }
Example #20
0
        private static TextMatchFilter createTextMatchFilter(ObjectListView olv, string[] filterTexts, int matchKind)
        {
            switch (matchKind)
            {
            case 0:
            default:
                return(TextMatchFilter.Contains(olv, filterTexts));

            case 1:
                return(TextMatchFilter.Prefix(olv, filterTexts));

            case 2:
                return(TextMatchFilter.Regex(olv, filterTexts));
            }
        }
Example #21
0
        public static void OLVFilter(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;
                }
            }
            // Setup a default renderer to draw the filter matches

            if (filter == null)
            {
                olv.DefaultRenderer = null;
            }
            else
            {
                olv.DefaultRenderer = new HighlightTextRenderer(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;
            }


            olv.AdditionalFilter = filter;
            //olv.Invalidate();
        }
Example #22
0
 /// <summary>
 /// Use Fast Filter
 /// </summary>
 private void UseFastFilterItems()
 {
     if (FastFilterList.Count == 0)
     {
         FastFilter = TextMatchFilter.Contains(olvItem, "");
     }
     else
     {
         string[] filterArray = FastFilterList.ToArray();
         FastFilter = TextMatchFilter.Prefix(olvItem, filterArray);
     }
     if (cbFastFilterCol.SelectedIndex == 0)
     {
         FastFilter.Columns = new OLVColumn[] { itName, itCategory, itSubcategory, itInvNum, itLocation, itExcluded }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 1)
     {
         FastFilter.Columns = new OLVColumn[] { itName }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 2)
     {
         FastFilter.Columns = new OLVColumn[] { itCategory }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 3)
     {
         FastFilter.Columns = new OLVColumn[] { itSubcategory }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 4)
     {
         FastFilter.Columns = new OLVColumn[] { itInvNum }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 5)
     {
         FastFilter.Columns = new OLVColumn[] { itLocation }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 6)
     {
         FastFilter.Columns = new OLVColumn[] { itExcluded }
     }
     ;
 }
Example #23
0
        private void TimedFilter(ObjectListView folv, string txt, int matchKind)
        {
            TextMatchFilter filter = null;

            if (!String.IsNullOrEmpty(txt))
            {
                switch (matchKind)
                {
                case 0:
                default:
                    filter = TextMatchFilter.Prefix(folv, txt);
                    break;

                case 1:
                    filter = TextMatchFilter.Contains(folv, txt);
                    break;

                case 2:
                    filter = TextMatchFilter.Regex(folv, txt);
                    break;
                }
            }
            // Setup a default renderer to draw the filter matches
            if (filter == null)
            {
                folv.DefaultRenderer = null;
            }
            else
            {
                folv.DefaultRenderer = new HighlightTextRenderer(filter);
            }

            // Some lists have renderers already installed
            HighlightTextRenderer highlightingRenderer = folv.GetColumn(0).Renderer as HighlightTextRenderer;

            if (highlightingRenderer != null)
            {
                highlightingRenderer.Filter = filter;
            }

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            folv.ModelFilter = filter;
            stopWatch.Stop();
        }
Example #24
0
        // ----- LEVEL FILTER -----

        private void chError_CheckedChanged(object sender, EventArgs e)
        {
            List <string> filterList = new List <string>();

            if (chError.Checked)
            {
                filterList.Add("E");
            }
            if (chbWarning.Checked)
            {
                filterList.Add("W");
            }
            if (chbInfo.Checked)
            {
                filterList.Add("I");
            }
            if (chbDebug.Checked)
            {
                filterList.Add("D");
            }
            if (chbExtended.Checked)
            {
                filterList.Add("X");
            }
            if (chbUnknown.Checked)
            {
                filterList.Add("U");
            }
            if (filterList.Count == 0)
            {
                filterLevel = TextMatchFilter.Contains(olvLog, " ");
            }
            else
            {
                string[] filterArray = filterList.ToArray();
                filterLevel = TextMatchFilter.Prefix(olvLog, filterArray);
            }
            filterLevel.Columns = new OLVColumn[] { olvLogLevel };

            olvLog.UseFiltering = true;
            olvLog.ModelFilter  = new CompositeAllFilter(new List <IModelFilter> {
                filterDesc, filterLevel, filterDevice, filterHistory
            });
        }
Example #25
0
 /// <summary>
 /// Use Fast Filter
 /// </summary>
 private void UseFastFilterBoard()
 {
     if (FastFilterList.Count == 0)
     {
         FastFilter = TextMatchFilter.Contains(olvBoard, "");
     }
     else
     {
         string[] filterArray = FastFilterList.ToArray();
         FastFilter = TextMatchFilter.Prefix(olvBoard, filterArray);
     }
     if (cbFastFilterCol.SelectedIndex == 0)
     {
         FastFilter.Columns = new OLVColumn[] { bgName, bgCategory, bgInvNum, bgLocation, bgExcluded }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 1)
     {
         FastFilter.Columns = new OLVColumn[] { bgName }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 2)
     {
         FastFilter.Columns = new OLVColumn[] { bgCategory }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 3)
     {
         FastFilter.Columns = new OLVColumn[] { bgInvNum }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 4)
     {
         FastFilter.Columns = new OLVColumn[] { bgLocation }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 5)
     {
         FastFilter.Columns = new OLVColumn[] { bgExcluded }
     }
     ;
 }
Example #26
0
        public void TimeFilter(String aFilterStr, FilterType aType)
        {
            TextMatchFilter nFilter = null;

            if (!String.IsNullOrEmpty(aFilterStr))
            {
                switch (aType)
                {
                default:
                case FilterType.CONTAINS:
                    nFilter = TextMatchFilter.Contains(this, aFilterStr);
                    break;

                case FilterType.PREFIX:
                    nFilter = TextMatchFilter.Prefix(this, aFilterStr);
                    break;

                case FilterType.REGEX:
                    nFilter = TextMatchFilter.Regex(this, aFilterStr);
                    break;
                }
            }

            if (nFilter == null)
            {
                this.DefaultRenderer = null;
            }
            else
            {
                this.DefaultRenderer = new HighlightTextRenderer(nFilter);
            }

            // Some lists have renderers already installed
            HighlightTextRenderer highlightingRenderer = this.GetColumn(0).Renderer as HighlightTextRenderer;

            if (highlightingRenderer != null)
            {
                highlightingRenderer.Filter = nFilter;
            }

            this.AdditionalFilter = nFilter;
        }
        private 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);

                olv.DefaultRenderer = new HighlightTextRenderer {
                    Filter = filter, UseGdiTextRendering = true
                };
            }

            System.Diagnostics.Stopwatch stopWatch = new Stopwatch();
            stopWatch.Start();
            olv.ModelFilter = filter;
            stopWatch.Stop();
        }
Example #28
0
 /// <summary>
 /// Use Fast Filter
 /// </summary>
 private void UseFastFilterGames()
 {
     if (FastFilterList.Count == 0)
     {
         FastFilter = TextMatchFilter.Contains(olvGames, "");
     }
     else
     {
         string[] filterArray = FastFilterList.ToArray();
         FastFilter = TextMatchFilter.Prefix(olvGames, filterArray);
     }
     if (cbFastFilterCol.SelectedIndex == 0)
     {
         FastFilter.Columns = new OLVColumn[] { gmName, gmCategory, gmKeywords, gmEnviroment, gmExcluded }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 1)
     {
         FastFilter.Columns = new OLVColumn[] { gmName }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 2)
     {
         FastFilter.Columns = new OLVColumn[] { gmCategory }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 3)
     {
         FastFilter.Columns = new OLVColumn[] { gmEnviroment }
     }
     ;
     else if (cbFastFilterCol.SelectedIndex == 4)
     {
         FastFilter.Columns = new OLVColumn[] { gmExcluded }
     }
     ;
 }
Example #29
0
        private void materialSingleLineTextField3_TextChanged(object sender, EventArgs e)
        {
            string txt = materialSingleLineTextField3.Text;
            //Debug.WriteLine("过滤: " + txt);
            int             matchKind = comboBox4.SelectedIndex;
            TextMatchFilter filter    = null;

            if (!String.IsNullOrEmpty(txt))
            {
                switch (matchKind)
                {
                case 0:
                default:
                    filter = TextMatchFilter.Contains(fastObjectListView1, txt);
                    break;

                case 1:
                    filter = TextMatchFilter.Prefix(fastObjectListView1, txt);
                    break;

                case 2:
                    filter = TextMatchFilter.Regex(fastObjectListView1, txt);
                    break;
                }
            }

            if (filter == null)
            {
                fastObjectListView1.DefaultRenderer = null;
            }
            else
            {
                fastObjectListView1.DefaultRenderer = new HighlightTextRenderer(filter);

                // 可以选择GDI渲染高亮
                //fastObjectListView1.DefaultRenderer = new HighlightTextRenderer { Filter = filter, UseGdiTextRendering = false };
            }

            // 如果使用了其他过滤器
            HighlightTextRenderer highlightingRenderer = fastObjectListView1.GetColumn(0).Renderer as HighlightTextRenderer;

            if (highlightingRenderer != null)
            {
                highlightingRenderer.Filter = filter;
            }

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            fastObjectListView1.AdditionalFilter = filter;
            stopWatch.Stop();

            IList objects = fastObjectListView1.Objects as IList;

            if (objects == null)
            {
                SetTips(String.Format("过滤完成, 消耗 {0} 毫秒", stopWatch.ElapsedMilliseconds));
            }
            else
            {
                SetTips(String.Format("过滤完成, 总元素数量 {0} , 过滤后元素数量 {1} ,消耗 {2} 毫秒",
                                      objects.Count,
                                      fastObjectListView1.Items.Count,
                                      stopWatch.ElapsedMilliseconds));
            }

            fastObjectListView1.Invalidate();

            //Debug.WriteLine("过滤: " + txt + " 完毕.");
        }
        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;
                }
            }
            // Setup a default renderer to draw the filter matches
            if (filter == null)
            {
                olv.DefaultRenderer = null;
            }
            else
            {
                olv.DefaultRenderer = new HighlightTextRenderer(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;
            }
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            olv.AdditionalFilter = filter;
            olv.Invalidate();
            stopWatch.Stop();

            IList objects = olv.Objects as IList;

            if (objects == null)
            {
                string msg = String.Format("Filtered in {0}ms", stopWatch.ElapsedMilliseconds);
                this.toolTip1.SetToolTip(this.textBoxFilterTree, msg);
            }
            else
            {
                string msg = String.Format("Filtered {0} items down to {1} items in {2}ms",
                                           objects.Count,
                                           olv.Items.Count,
                                           stopWatch.ElapsedMilliseconds);
                this.toolTip1.SetToolTip(this.textBoxFilterTree, msg);
            }
        }