private void dataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { CellDetails cellDetails = new CellDetails(); try { if (dataGridView.CurrentCell.ColumnIndex == 1) { Common.ShowDetail(dataGridView.CurrentCell.RowIndex); return; } cellDetails.MainMenuStrip.Enabled = false; cellDetails.richTextBox.Text = dataGridView.CurrentCell.Value.ToString(); } catch (Exception) { //空引用异常,不处理 } cellDetails.Show(); }/// <summary>
/// <summary> /// 双击协议名称单元格时新建窗口并显示数据包详细信息 /// </summary> /// <param name="index"></param> public static void ShowDetail(int index) { RawCapture rawCapture = null; try { rawCapture = queue[index]; } catch (Exception) { MessageBox.Show("Error while displying details"); return; } Packet packet = Packet.ParsePacket(rawCapture.LinkLayerType, rawCapture.Data); PacketDetials pd = new PacketDetials(packet); CellDetails cellDetails = new CellDetails(); cellDetails.rawCapture = rawCapture; if (pd.ethernetPacket != null) { cellDetails.richTextBox.Text = pd.ethernetPacket.ToString(StringOutputType.VerboseColored) + Environment.NewLine + pd.ethernetPacket.PrintHex(); } cellDetails.Show(); }