public WindowShowLineInfo(Line l, PeerMapShow _uc) { InitializeComponent(); uc = _uc; line = l; timer = new DispatcherTimer(); timer.Interval = new System.TimeSpan(0, 0, 1); timer.Tick += new EventHandler(timer_Tick); timer.Start(); srcIP = ((PeerMapShow.LineSrcDst)line.Tag)._srcip; dstIP = ((PeerMapShow.LineSrcDst)line.Tag)._dstip; tbSrcIP.Text = srcIP.ToString(); tbDstIP.Text = dstIP.ToString(); //srcPeerInfo = uc.ipAndPeerInfos[srcIP]; //dstPeerInfo = uc.ipAndPeerInfos[dstIP]; p2pS2D = uc.ipAndPeerInfos[srcIP].peerToPeers[dstIP]; p2pD2S = uc.ipAndPeerInfos[dstIP].peerToPeers[srcIP]; tbIP.Text = srcIP.ToString() + " - " + dstIP.ToString(); sentPacketsNum = p2pS2D.totalSendPkNum; oldSentBytesNum = sentBytesNum = p2pS2D.totalSendPkSize; sentPercentNum = (double)p2pS2D.totalSendPkSize * 100 / (double)uc.totalPkSize; rcvPacketsNum = p2pD2S.totalSendPkNum; oldRcvBytesNum = rcvBytesNum = p2pD2S.totalSendPkSize; rcvPercentNum = (double)p2pD2S.totalSendPkSize * 100 / (double)uc.totalPkSize; sentPackets.Text = sentPacketsNum.ToString(); sentBytes.Text = sentBytesNum.ToString(); sentSpeed.Text = ""; sentPercent.Text = sentPercentNum.ToString("0.000"); rcvPackets.Text = rcvPacketsNum.ToString(); rcvBytes.Text = rcvBytesNum.ToString(); rcvSpeed.Text = ""; rcvPercent.Text = rcvPercentNum.ToString("0.000"); sumPackets.Text = (sentPacketsNum + rcvPacketsNum).ToString(); sumBytes.Text = (sentBytesNum + rcvBytesNum).ToString(); sumSpeed.Text = ""; sumPercent.Text = (sentPercentNum + rcvPercentNum).ToString("0.000"); protocols.Text = CountProtocols(p2pS2D, p2pD2S); }
private void BtnPeerMapWPF_Click(object sender, RoutedEventArgs e) { int index = 0; if (radioBtns.Count == 0) { MessageBox.Show("没有合适的网卡", "错误", MessageBoxButton.OK); return; } foreach (RadioButton R in radioBtns) { if ((bool)R.IsChecked) { break; } index++; } if (index == radioBtns.Count) { MessageBox.Show("请选择需要捕获的网卡", "提示", MessageBoxButton.OK); return; } dev = devices[index]; if (dev.Started) { MessageBox.Show("此网卡已经在抓包"); return; } //传递dev参数,打开PeerMap显示页面。匿名函数 Thread threadPeerMapPage = new Thread(delegate() { PeerMapShow peerMapShow = new PeerMapShow(dev); peerMapShow.WindowStartupLocation = WindowStartupLocation.CenterScreen; peerMapShow.ShowDialog(); }); threadPeerMapPage.SetApartmentState(ApartmentState.STA); threadPeerMapPage.Start(); }
public WindowShowEllipseInfo(Ellipse e, PeerMapShow _uc) { InitializeComponent(); //this.ShowInTaskbar = false; uc = _uc; el = e; timer = new DispatcherTimer(); timer.Interval = new System.TimeSpan(0, 0, 1); timer.Tick += new EventHandler(timer_Tick); timer.Start(); elInfo = (EllipseInfo)el.Tag; ip = elInfo.ip; peerInfo = uc.ipAndPeerInfos[ip]; tbIP.Text = ip.ToString(); sentPackets.Text = peerInfo.allSendPkNum.ToString(); sentBytes.Text = peerInfo.allSendPkSize.ToString(); sentPercent.Text = ((double)peerInfo.allSendPkSize * 100 / (double)uc.totalPkSize).ToString("0.000"); rcvPackets.Text = peerInfo.allrcvPkNum.ToString(); rcvBytes.Text = peerInfo.allrcvPkSize.ToString(); rcvPercent.Text = ((double)peerInfo.allrcvPkSize * 100 / (double)uc.totalPkSize).ToString("0.000"); peers.Text = peerInfo.peerToPeers.Count.ToString(); protocols.Text = CountProtocols(peerInfo).ToString(); }