Exemple #1
0
        /// <summary>
        /// Start a capture task.
        /// </summary>
        /// <param name="des"></param>
        /// <param name="option"></param>
        public void StartNewCaptureTask(DeviceDes des, DumpOptions options = null)
        {
            Microsoft.Win32.SaveFileDialog dlg = null;
            if (options == null)
            {
                dlg            = new Microsoft.Win32.SaveFileDialog();
                dlg.FileName   = "new_capture";
                dlg.DefaultExt = ".pcap";
                dlg.Filter     = "Libpcap capture file (.pcap)|*.pcap";

                Nullable <bool> res = dlg.ShowDialog();

                if (res != true)
                {
                    return;
                }
            }

            var op = options ?? new DumpOptions()
            {
                Path    = dlg.FileName,
                Count   = int.MaxValue,
                Durance = TimeSpan.MaxValue,
                Filter  = null
            };

            CaptureControlBlock cm = new CaptureControlBlock()
            {
                Device  = des,
                Options = op
            };

            RaiseCaptureCreated(cm);
            cm.StartCapture();
            RaiseCaptureStarted(cm);

            ActivateDocument.Execute(pages.OfType <TaskListPage>().FirstOrDefault(), this);

            cm.CaptureTask.ContinueWith(
                (res) =>
            {
                if (res.Exception != null)
                {
                    MessageBox.Show(res.Exception.Message);
                }
                else if (res.IsCanceled)
                {
                    string str = string.Format("{0} 上的捕获任务已停止!", cm.Device.FriendlyName);
                    MessageBox.Show(str);
                }
                else
                {
                    string str = string.Format("{0} 上的捕获任务完成!", cm.Device.FriendlyName);
                    MessageBox.Show(str);
                }
            });
        }
        private void UnSetupDevice(DeviceDes des)
        {
            RemoveDeviceFromChart(des);

            if (Ssource.MonitoringList.Count == 0)
            {
                refreshTimer.Stop();
                DeviceStatisticsHelper.startTime = -1;
            }
        }
        private void SetupDevice(DeviceDes des)
        {
            if (!refreshTimer.IsEnabled)
            {
                refreshTimer.Start();
                ResetLineChart(BpsChart);
                ResetLineChart(PpsChart);
            }

            AddDeviceToChart(des);
        }
        public StartNewCaptureDetial(DeviceDes des)
        {
            this.des = des;
            Options  = new DumpOptions();

            InitializeComponent();

            filterBinding.ValidationRules.Add(new BerkeleyPacketFilterValidationRule()
            {
                DeviceDescription = des
            });
        }
        protected void AddDeviceToChart(DeviceDes des)
        {
            // Pie Chart
            FrameworkElement chart = CreatePieCharts(helpers[des.Name]);

            chart.Tag = des.Name;

            CentralGraph.Children.Add(chart);

            // Line Chart
            Color c = ColorGen.GetColor();

            BpsChart.AddLineGraph(helpers[des.Name].Bps, c, 2, des.FriendlyName);
            PpsChart.AddLineGraph(helpers[des.Name].Pps, c, 2, des.FriendlyName);
            BpsChart.FitToView();
            PpsChart.FitToView();
        }
        public DeviceStatisticsHelper(ChartPlotter bps, ChartPlotter pps, DeviceDes des)
        {
            Device           = des;
            Shown            = false;
            CaptureThis      = false;
            Pps              = new RemovableDataSource <Tuple <double, double> >();
            Bps              = new RemovableDataSource <Tuple <double, double> >();
            NetworkLayer     = new ObservableCollection <NotifyKeyValuePairSL>();
            TransportLayer   = new ObservableCollection <NotifyKeyValuePairSL>();
            ApplicationLayer = new ObservableCollection <NotifyKeyValuePairSL>();
            BpsPlotter       = bps;
            PpsPlotter       = pps;
            MaxPoints        = 50;

            //var axis = BpsPlotter.MainHorizontalAxis as HorizontalTimeSpanAxis;
            //Bps.SetXYMapping(tp => new Point(axis.ConvertToDouble(tp.Item1), tp.Item2));
            Bps.SetXYMapping(tp => new Point(tp.Item1, tp.Item2));
            //axis = PpsPlotter.MainHorizontalAxis as HorizontalTimeSpanAxis
            Pps.SetXYMapping(tp => new Point(tp.Item1, tp.Item2));
        }
        protected void RemoveDeviceFromChart(DeviceDes des)
        {
            // Pie Chart
            for (int i = 0; i != CentralGraph.Children.Count; i++)
            {
                FrameworkElement chart = CentralGraph.Children[i] as FrameworkElement;
                if (chart != null && chart.Tag.Equals(des.Name))
                {
                    CentralGraph.Children.RemoveAt(i);
                    break;
                }
            }

            // Line Chart
            var bpsline = BpsChart.Children.OfType <LineGraph>()
                          .Where(x => x.Description.Brief.Equals(des.FriendlyName)).Single();

            BpsChart.Children.Remove(bpsline);
            var ppsline = PpsChart.Children.OfType <LineGraph>()
                          .Where(x => x.Description.Brief.Equals(des.FriendlyName)).Single();

            PpsChart.Children.Remove(ppsline);
        }
Exemple #8
0
        private void BindingCommands()
        {
            CommandBindings.Add(new CommandBinding(CloseDocument,
                                                   (o, e) => pages.Remove((ITabPage)Tabs.ItemContainerGenerator.ItemFromContainer((TabItem)e.Parameter)),
                                                   (o, e) =>
            {
                ITabPage page = (ITabPage)Tabs.ItemContainerGenerator.ItemFromContainer((TabItem)e.Parameter);
                e.CanExecute  = !NoClosePage.Contains(page.TypeIdentity);
            }
                                                   ));

            CommandBindings.Add(new CommandBinding(ActivateDocument,
                                                   (o, e) =>
            {
                if (e.Parameter != null)
                {
                    Tabs.SelectedItem = e.Parameter;
                    UI.OverflowTabHeaderObserver.EnsureActiveTabVisible(Tabs);
                }
            }));

            CommandBindings.Add(new CommandBinding(NewFluxAnalyze,
                                                   (o, e) =>
            {
                OpenNewFluxAnalyze();
            }));

            CommandBindings.Add(new CommandBinding(MainWindow.ReassembleTCP,
                                                   (o, e) =>
            {
                if (Tabs.SelectedContent is FileAnalyzePage)
                {
                    FileAnalyzePage page = Tabs.SelectedContent as FileAnalyzePage;
                    page.ReassembleTCP();
                }
            },
                                                   (o, e) => e.CanExecute = Tabs.SelectedContent is FileAnalyzePage));

            CommandBindings.Add(new CommandBinding(MainWindow.ReconstructHTTP,
                                                   (o, e) =>
            {
                if (Tabs.SelectedContent is FileAnalyzePage)
                {
                    FileAnalyzePage page = Tabs.SelectedContent as FileAnalyzePage;
                    page.ReconstructHTTP();
                }
            },
                                                   (o, e) => e.CanExecute = Tabs.SelectedContent is FileAnalyzePage));

            CommandBindings.Add(new CommandBinding(MainWindow.ReconstructKeywordHttp,
                                                   (o, e) =>
            {
                if (Tabs.SelectedContent is FileAnalyzePage)
                {
                    FileAnalyzePage page = Tabs.SelectedContent as FileAnalyzePage;
                    page.ReconstructKeywordHTTP();
                }
            },
                                                   (o, e) => e.CanExecute = Tabs.SelectedContent is FileAnalyzePage));

            CommandBindings.Add(new CommandBinding(MainWindow.CreateNewCapture,
                                                   (o, e) =>
            {
                DeviceDes des = DeviceCombo.SelectedItem as DeviceDes;
                if ((bool)e.Parameter)
                {
                    StartNewCaptureDetial dlg = new StartNewCaptureDetial(des);
                    dlg.Owner = this;
                    bool res  = dlg.ShowDialog() ?? false;
                    if (res)
                    {
                        StartNewCaptureTask(des, dlg.Options);
                    }
                }
                else
                {
                    StartNewCaptureTask(des);
                }
            },
                                                   (o, e) => e.CanExecute = DeviceCombo.SelectedItem != null));
        }
Exemple #9
0
 private void CaptureThis_Unchecked(object sender, RoutedEventArgs e)
 {
     DeviceDes des = DeviceList.SelectedValue as DeviceDes;
 }
Exemple #10
0
        private void ShowInMonitor_Unchecked(object sender, RoutedEventArgs e)
        {
            DeviceDes des = DeviceList.SelectedValue as DeviceDes;

            Ssource.StopStatistic(des);
        }
Exemple #11
0
        private void DeviceList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DeviceDes des = DeviceList.SelectedValue as DeviceDes;

            ShowInMonitor.IsChecked = Ssource.MonitoringList.Contains(des);
        }