/// <summary> /// Выделение ячейки двойным кликом мыши с заходом в дополнительное окно /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void cell_MouseDoubleClick(object sender, MouseEventArgs e) { if (typeAction != TypeAction.none && typeAction == TypeAction.game) { GetOrdinate(sender, out currentCell.X, out currentCell.Y); cells[currentCell.X, currentCell.Y].SelectCell(); if (cells[currentCell.X, currentCell.Y].CellType != CellType.closed) { SmartInfoForm smartInfoForm = new SmartInfoForm(cells[currentCell.X, currentCell.Y]); smartInfoForm.ShowDialog(); } } }
/// <summary> /// Отлов нажатия кнопок на форме /// </summary> /// <param name="keyData"></param> /// <returns></returns> protected override bool ProcessDialogKey(Keys keyData) { if (typeAction != TypeAction.none && buttonPause.Text == "Пауза") { if (keyData == Keys.Enter && typeAction == TypeAction.game) { if (cells[currentCell.X, currentCell.Y].CellType != CellType.closed) { SmartInfoForm smartInfoForm = new SmartInfoForm(cells[currentCell.X, currentCell.Y]); smartInfoForm.ShowDialog(); } else { MessageBox.Show("Значение в данной клетке изменять нельзя", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(true); } else if (keyData == Keys.Right) { if (currentCell.Y + 1 < 9) { currentCell.Y++; } else { currentCell.Y = 0; } cells[currentCell.X, currentCell.Y].SelectCell(); return(true); } else if (keyData == Keys.Left) { if (currentCell.Y - 1 > -1) { currentCell.Y--; } else { currentCell.Y = 8; } cells[currentCell.X, currentCell.Y].SelectCell(); return(true); } else if (keyData == Keys.Down) { if (currentCell.X + 1 < 9) { currentCell.X++; } else { currentCell.X = 0; } cells[currentCell.X, currentCell.Y].SelectCell(); return(true); } else if (keyData == Keys.Up) { if (currentCell.X - 1 > -1) { currentCell.X--; } else { currentCell.X = 8; } cells[currentCell.X, currentCell.Y].SelectCell(); return(true); } else if (keyData == Keys.Space || keyData == Keys.D0 || keyData == Keys.NumPad0 || keyData == Keys.Delete || keyData == Keys.Back) { SetNewValue(0); return(true); } else if (keyData == Keys.D1 || keyData == Keys.D2 || keyData == Keys.D3 || keyData == Keys.D4 || keyData == Keys.D5 || keyData == Keys.D6 || keyData == Keys.D7 || keyData == Keys.D8 || keyData == Keys.D9) { int val = Convert.ToInt32(keyData.ToString("D")) - 48; SetNewValue(val); return(true); } else if (keyData == Keys.NumPad1 || keyData == Keys.NumPad2 || keyData == Keys.NumPad3 || keyData == Keys.NumPad4 || keyData == Keys.NumPad5 || keyData == Keys.NumPad6 || keyData == Keys.NumPad7 || keyData == Keys.NumPad8 || keyData == Keys.NumPad9) { int val = Convert.ToInt32(keyData.ToString("D")) - 96; SetNewValue(val); return(true); } } return(base.ProcessDialogKey(keyData)); }