示例#1
0
        private void btnStopAll_Click(object sender, EventArgs e)
        {
            try
            {
                var errors = new StringBuilder();
                foreach (TabPage tabPage in this.tabControl1.TabPages)
                {
                    TrafficStatisticsPanel body = (TrafficStatisticsPanel)tabPage.Controls[0];
                    try
                    {
                        body.Stop();
                    }
                    catch (Exception ex)
                    {
                        errors.AppendLine($"{tabPage.Text} 出错: {ex.Message}");
                    }
                }

                if (errors.Length > 0)
                {
                    MessageBox.Show(errors.ToString());
                }
                else
                {
                    this.tabControl1.TabPages.Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
        private void btnStartAll_Click(object sender, EventArgs e)
        {
            try
            {
                var errors = new StringBuilder();
                foreach (ListViewItem lvitem in this.listView1.Items)
                {
                    ItemInfo info = (ItemInfo)lvitem.Tag;
                    try
                    {
                        var tabPage = new TabPage($"{info.Protocol}:{info.LocalAddress}");
                        var body    = new TrafficStatisticsPanel();
                        body.ItemInfo  = info;
                        body.AutoStart = true;
                        body.Dock      = DockStyle.Fill;
                        tabPage.Controls.Add(body);
                        tabControl1.TabPages.Add(tabPage);
                    }
                    catch (Exception ex)
                    {
                        errors.AppendLine($"{info.Protocol}:{info.LocalAddress} 出错: {ex.Message}");
                    }
                }

                if (errors.Length > 0)
                {
                    MessageBox.Show(errors.ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#3
0
 private void MyTabControl1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (myTabControl1.SelectedIndex == myTabControl1.TabCount - 1)
     {
         var tabpage = new TabPage($"[{(++_id)}]");
         var panel   = new TrafficStatisticsPanel();
         panel.Dock = DockStyle.Fill;
         tabpage.Controls.Add(panel);
         myTabControl1.TabPages.Insert(myTabControl1.TabCount - 1, tabpage);
         myTabControl1.SelectedIndex = myTabControl1.TabCount - 2;
     }
 }
示例#4
0
        private void HighlightTab(ItemInfo info)
        {
            if (info == null)
            {
                return;
            }

            // highlight tab
            foreach (TabPage tabPage in this.tabControl1.TabPages)
            {
                TrafficStatisticsPanel body = (TrafficStatisticsPanel)tabPage.Controls[0];
                if (body.ItemInfo == info)
                {
                    this.tabControl1.SelectedTab = tabPage;
                    break;
                }
            }
        }
        private void ListView1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                if (_SelectedItem == null || _SelectedItem.Tag == null || !(_SelectedItem.Tag is ItemInfo))
                {
                    return;
                }
                var info = _SelectedItem.Tag as ItemInfo;

                var tabPage = new TabPage($"{info.Protocol}:{info.LocalAddress}");
                var body    = new TrafficStatisticsPanel();
                body.ItemInfo = info;
                body.Dock     = DockStyle.Fill;
                tabPage.Controls.Add(body);
                tabControl1.TabPages.Add(tabPage);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#6
0
 public ConsoleWriter(TrafficStatisticsPanel control)
 {
     _control = new WeakReference <TrafficStatisticsPanel>(control);
 }