public Netstat() { InitializeComponent(); int Pid = 0; MainWindow Main = new MainWindow(); Pid = MainWindow.PPID; ProcInfo.ProcessID = Pid; t = new Thread(new ThreadStart(list)); t.SetApartmentState(ApartmentState.STA); t.IsBackground = true; t.Start(); for (int i = 0; i < SendLine.Count; i++) { SendLine.RemoveAt(i); } ReadLine.Clear(); }
private void CanvasAdd2() { Line Reav = new Line(); Line ReavSYG; Line Send = new Line(); Line SendSYG; if (ReadLine.Count == 0) { Reav.X1 = 0; Reav.Y1 = 10; if (R == 0) { Reav.X2 = 5; Reav.Y2 = 15; } else { Reav.X2 = Reav.X1 + (R / 10); Reav.Y2 = -(Reav.X2 + 10); } } else { ReavSYG = (Line)ReadLine[ReadLine.Count - 1]; Reav.X1 = ReavSYG.X2; Reav.Y1 = ReavSYG.Y2; if (R == 0) { Reav.X2 = ReavSYG.X1 + 5; Reav.Y2 = Reav.X2 + 10; } else { Reav.X2 = Reav.X1 + (R / 10); Reav.Y2 = -(Reav.X2 + 10); } //调整线条位置 if (Reav.X2 > 200) { for (int i = 0; i < ReadLine.Count; i++) { Line u = ReadLine[i]; Canvas1.Children.Remove(u); } ReadLine.Clear(); return; } } if (SendLine.Count == 0) { Send.X1 = 0; Send.Y1 = 10; if (S == 0) { Send.X2 = 5; //长度 Send.Y2 = 15; //下降 } else { Send.X2 = Send.X1 + (S / 4); //长度 Send.Y2 = -(Send.X2 + 10); //上升 } } else { SendSYG = (Line)SendLine[SendLine.Count - 1]; Send.X1 = SendSYG.X2; Send.Y1 = SendSYG.Y2; if (S == 0) { Send.X2 = SendSYG.X1 + 5; //长度 Send.Y2 = Send.X2 + 10; //下降 } else { Send.X2 = Send.X1 + (S / 4); //长度 Send.Y2 = -(Send.X2 + 10); //上升 } //调整线条位置 if (Send.X2 > 200) { for (int i = 0; i < SendLine.Count; i++) { Line u = SendLine[i]; Canvas1.Children.Remove(u); } SendLine.Clear(); return; } } BrushConverter ie = new BrushConverter(); Brush brush = (Brush)ie.ConvertFromString("#DC143C"); Send.Stroke = brush; Send.StrokeThickness = 3; Canvas.SetTop(Send, 200); SendLine.Add(Send); brush = (Brush)ie.ConvertFromString("#4682B4"); Reav.Stroke = brush; Reav.StrokeThickness = 3; Canvas.SetTop(Reav, 180); ReadLine.Add(Reav); Debug.WriteLine(ProcInfo.CpuTime); Canvas1.Children.Add(Reav); Canvas1.Children.Add(Send); //this.stakpanal1.Children.Add(element); }