public FormSessionSearch(ref FilterOptions filterOptions)
 {
     InitializeComponent();
     filterOptions.SearchText = "Foo Bar";
     FilterOpts = filterOptions;
     this.checkBoxSearchSelected.Enabled = filterOptions.HasSelection;
 }
示例#2
0
        private void findSessions_Click(object sender, EventArgs e)
        {
            FilterOptions opts = new FilterOptions((listViewSessions.SelectedIndices.Count > 0));
            FormSessionSearch search = new FormSessionSearch(ref opts);
            search.ShowDialog();

            if (!String.IsNullOrEmpty(opts.SearchText))
            {
                Thread sThread = new Thread(delegate()
                {
                    SearchSessions(opts);
                });
                sThread.Name = "Search";
                sThread.Start();
            }
        }
示例#3
0
        private void SearchSessions(FilterOptions opts)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new MethodInvoker(() => SearchSessions(opts)));
            }
            else
            {
                int resultCount = 0;
                progressBar1.Step = 1;// m_SessionViewItems.Count / 100 / 100;
                progressBar1.Maximum = m_SessionViewItems.Count;
                progressBar1.Value = 0;
                panelActionProgress.Visible = true;

                lock (m_SessionViewItems)
                {
                    for (int i = 0; i < m_SessionViewItems.Count; i++)
                    {
                        Session session = m_SessionViewItems[i];

                        if (opts.UnMarkPrevious)
                            session.BackColor = Color.White;

                        if (opts.SearchSelected && !session.Selected)
                            continue;

                        if (
                        (opts.MatchCase
                        && (session.Name.Contains(opts.SearchText)
                        || session.ToPrettyString(session.Direction).Contains(opts.SearchText))
                        ) // no case matching
                        || ((session.Name.ToLower().Contains(opts.SearchText.ToLower())
                        || session.ToPrettyString(session.Direction).ToLower().Contains(opts.SearchText.ToLower())
                            ))
                        )
                        {
                            if (opts.MarkMatches)
                                session.BackColor = opts.HighlightMatchColor;

                            if (opts.SelectResults)
                                session.Selected = true;
                            else
                                session.Selected = false;

                            resultCount++;
                        }
                        progressBar1.PerformStep();
                    }
                }
                ClearCache();
                listViewSessions.Invalidate();
                panelActionProgress.Visible = false;
                toolStripLowerStatusLabel.Text = String.Format("Searched {0} session{2} and found {1} matche{2}", m_SessionViewItems.Count, resultCount,
                    (resultCount != 1) ? "s" : "");
            }
        }
        private void SearchSessions(FilterOptions opts)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new MethodInvoker(() => SearchSessions(opts)));
            }
            else
            {
                int resultCount = 0;

                foreach (ListViewItem item in listViewSessions.Items)
                {
                    if (opts.UnMarkPrevious)
                        item.BackColor = Color.White;

                    if (opts.SearchSelected && !item.Selected)
                    {
                        continue;
                    }

                    if (
                        (opts.MatchCase
                        && (item.SubItems[3].Text.Contains(opts.SearchText)
                        /*|| TagToString(item.Tag, item.SubItems[2].Text).Contains(opts.SearchText)*/)
                        ) // no case matching
                        || ((item.SubItems[3].Text.ToLower().Contains(opts.SearchText.ToLower())
                        /*|| TagToString(item.Tag, item.SubItems[2].Text).ToLower().Contains(opts.SearchText.ToLower())*/
                            ))
                        )
                    {
                        resultCount++;

                        if (opts.MarkMatches)
                            item.BackColor = opts.HighlightMatchColor;

                        if (opts.SelectResults)
                            item.Selected = true;
                        else
                            item.Selected = false;
                    }
                }

                //toolStripMainLabel.Text = String.Format("Search found {0} Matches", resultCount);
            }
        }