private void filter_opt_Click(object sender, EventArgs e) { FilterDlg dlg = new FilterDlg(); DialogResult dr = dlg.ShowDialog(); if (dr == DialogResult.OK) { // User changed the filter // Restart capture using new filter if we are capturing now if (worker != null) { object[] ctrls = new object[2]; ctrls[0] = frames; ctrls[1] = clear_cap; frames.Items.Clear(); if (!IsOffline) { worker.StopCapture(); PacketSniffer.ResetDetailsDumper(); worker.StartOfflineCapture(null, ctrls); int deviceIndex = device_opt.SelectedIndex; worker.StartCapture(deviceIndex, ctrls); } else { PacketSniffer.ResetDetailsDumper(); worker.StartOfflineCapture(OfflineDumpFile, ctrls); } } } }
private void open_file_Click(object sender, EventArgs e) { // Update tool strip status start_cap.Enabled = false; stop_cap.Enabled = false; filter_opt.Enabled = false; open_file.Enabled = false; IsOffline = true; DialogResult rs = open_dlg.ShowDialog(this); OfflineDumpFile = null; if (rs == DialogResult.OK) { string path = open_dlg.FileName; OfflineDumpFile = path; if (worker == null) { worker = new CaptureWorker(); } frames.Items.Clear(); f_details.Items.Clear(); h_details.ResetText(); object[] ctrls = new object[2]; ctrls[0] = frames; ctrls[1] = clear_cap; this.Cursor = Cursors.WaitCursor; try { PacketSniffer.ResetDetailsDumper(); } catch (Exception) { } bool status = worker.StartOfflineCapture(path, ctrls); if (!status) { MessageBox.Show(this, "Bad dump file format", "Sniffer.NET", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Cursor = Cursors.Arrow; } // Update tool strip status if (device_opt.Items.Count != 0) { start_cap.Enabled = true; } filter_opt.Enabled = true; open_file.Enabled = true; }
private void clear_cap_Click(object sender, EventArgs e) { frames.Items.Clear(); f_details.Items.Clear(); h_details.Clear(); if (worker != null) { worker.FrameId = 1; } PacketSniffer.ResetDetailsDumper(); clear_cap.Enabled = false; }