private void grid_PO_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (!view.IsRunning) { Grid_Mem.EndEdit(); if (Grid_Mem.CurrentCell.ColumnIndex > 0) { using (theSubView = new MemSubmit(Grid_Mem.Rows[Grid_Mem.CurrentCell.RowIndex].Cells[2].Value.ToString(), Grid_Mem.Rows[Grid_Mem.CurrentCell.RowIndex].Cells[3].Value.ToString())) { Point startPosition = Cursor.Position; startPosition.Y -= theSubView.Height / 2; if (startPosition.Y < 0) { startPosition.Y = 0; } startPosition.X -= theSubView.Width / 2; theSubView.Location = startPosition; var result = theSubView.ShowDialog(); if (result == DialogResult.OK) { Grid_Mem.Rows[Grid_Mem.CurrentCell.RowIndex].Cells[1].Value = theSubView.binaryData; Grid_Mem.Rows[Grid_Mem.CurrentCell.RowIndex].Cells[2].Value = theSubView.hexData; Grid_Mem.Rows[Grid_Mem.CurrentCell.RowIndex].Cells[3].Value = theSubView.dataType; AUpdateForm(Grid_Mem.CurrentCell.RowIndex, theSubView.binaryData, theSubView.hexData, theSubView.dataType); } } } Grid_PO_SelectionChanged(sender, e); } }
private void Grid_PO_KeyDown(object sender, KeyEventArgs e) { if (!view.IsRunning) { if (e.KeyCode == Keys.Enter) { Grid_Mem.ReadOnly = true; Grid_Mem.EndEdit(); e.Handled = true; } if (!e.Control) { if (e.KeyCode == Keys.Delete) { button_Clear_Row_Click(sender, e); } else if (char.IsLetterOrDigit((char)e.KeyCode) || e.KeyCode == Keys.OemMinus) { Grid_Mem.ReadOnly = false; int nonVirtualKey = MapVirtualKey((uint)e.KeyCode, 2); char mappedChar = Convert.ToChar(nonVirtualKey); if ((mappedChar >= 'a' && mappedChar <= 'f') || (mappedChar >= 'A' && mappedChar <= 'F') || (mappedChar >= '0' && mappedChar <= '9')) { Grid_Mem.CurrentCell.Value = mappedChar; } else if (e.KeyCode == Keys.OemMinus) { Grid_Mem.CurrentCell.Value = (char)45; } else { Grid_Mem.CurrentCell.Value = ""; } Grid_Mem.BeginEdit(false); } } else if (e.KeyCode == Keys.C) { copyRow[0] = Grid_Mem.Rows[Grid_Mem.CurrentCell.RowIndex].Cells[1].Value.ToString(); copyRow[1] = Grid_Mem.Rows[Grid_Mem.CurrentCell.RowIndex].Cells[2].Value.ToString(); copyRow[2] = Grid_Mem.Rows[Grid_Mem.CurrentCell.RowIndex].Cells[3].Value.ToString(); } else if (e.KeyCode == Keys.V) { Grid_Mem.Rows[Grid_Mem.CurrentCell.RowIndex].Cells[1].Value = copyRow[0]; Grid_Mem.Rows[Grid_Mem.CurrentCell.RowIndex].Cells[2].Value = copyRow[1]; Grid_Mem.Rows[Grid_Mem.CurrentCell.RowIndex].Cells[3].Value = copyRow[2]; AUpdateForm(Grid_Mem.CurrentCell.RowIndex, copyRow[0], copyRow[1], Convert.ToInt16(copyRow[2])); } } }
private void button_Edit_Click(object sender, EventArgs e) { if (!view.IsRunning) { Grid_Mem.EndEdit(); if (Grid_Mem.CurrentCell.ColumnIndex > 0) { using (theSubView = new MemSubmit(Grid_Mem.Rows[Grid_Mem.CurrentCell.RowIndex].Cells[2].Value.ToString(), Grid_Mem.Rows[Grid_Mem.CurrentCell.RowIndex].Cells[3].Value.ToString())) { theSubView.Location = Cursor.Position; var result = theSubView.ShowDialog(); if (result == DialogResult.OK) { Grid_Mem.Rows[Grid_Mem.CurrentCell.RowIndex].Cells[1].Value = theSubView.binaryData; Grid_Mem.Rows[Grid_Mem.CurrentCell.RowIndex].Cells[2].Value = theSubView.hexData; Grid_Mem.Rows[Grid_Mem.CurrentCell.RowIndex].Cells[3].Value = theSubView.dataType; AUpdateForm(Grid_Mem.CurrentCell.RowIndex, theSubView.binaryData, theSubView.hexData, theSubView.dataType); } } } Grid_PO_SelectionChanged(sender, e); } }