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_MouseMove(object sender, MouseEventArgs e) { if ((e.Button & MouseButtons.Left) == MouseButtons.Left) { if (dragBoxFromMouseDown != Rectangle.Empty && !dragBoxFromMouseDown.Contains(e.X, e.Y)) { DragDropEffects dropEffect = Grid_Mem.DoDragDrop(valueFromMouseDown, DragDropEffects.Copy); } } }
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 Grid_PO_DragDrop(object sender, DragEventArgs e) { if (!view.IsRunning) { Point clientPoint = Grid_Mem.PointToClient(new Point(e.X, e.Y)); if (e.Effect == DragDropEffects.Copy) { var hitTestInfo = Grid_Mem.HitTest(clientPoint.X, clientPoint.Y); if (hitTestInfo.ColumnIndex > 0 && hitTestInfo.RowIndex != -1) { Grid_Mem.Rows[hitTestInfo.RowIndex].Cells[1].Value = Grid_Mem.Rows[idxDragRow].Cells[1].Value; Grid_Mem.Rows[hitTestInfo.RowIndex].Cells[2].Value = Grid_Mem.Rows[idxDragRow].Cells[2].Value; Grid_Mem.Rows[hitTestInfo.RowIndex].Cells[3].Value = Grid_Mem.Rows[idxDragRow].Cells[3].Value; AUpdateForm(hitTestInfo.RowIndex, Grid_Mem.Rows[idxDragRow].Cells[1].Value.ToString(), Grid_Mem.Rows[idxDragRow].Cells[2].Value.ToString(), Convert.ToInt16(Grid_Mem.Rows[idxDragRow].Cells[3].Value)); } } } }
private void Grid_PO_MouseDown(object sender, MouseEventArgs e) { var hitTestInfo = Grid_Mem.HitTest(e.X, e.Y); if (hitTestInfo.RowIndex != -1 && hitTestInfo.ColumnIndex > 0) { valueFromMouseDown = Grid_Mem.Rows[hitTestInfo.RowIndex].Cells[hitTestInfo.ColumnIndex].Value; idxDragRow = hitTestInfo.RowIndex; if (valueFromMouseDown != null) { Size dragSize = SystemInformation.DragSize; dragBoxFromMouseDown = new Rectangle(new Point(e.X - (dragSize.Width / 2), e.Y - (dragSize.Height / 2)), dragSize); } } else { dragBoxFromMouseDown = Rectangle.Empty; } }
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); } }