private void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.Control && e.KeyCode.Equals(Keys.Enter)) { // 終了 Application.Exit(); } else if (e.KeyCode.Equals(Keys.Enter)) { // 非表示 if (lbString.SelectedIndex >= 0) { Clipboard.SetText(lbString.SelectedItem.ToString()); } this.Visible = false; } if (e.KeyCode.Equals(Keys.Down)) { if (ActiveControl.Equals(lbString) && !lbString.SelectedIndex.Equals(lbString.Items.Count - 1)) { return; } // フォーカス移動 SelectNextControl(ActiveControl, true, true, true, true); } else if (e.KeyCode.Equals(Keys.Up)) { if (ActiveControl.Equals(lbString) && !lbString.SelectedIndex.Equals(0)) { return; } // フォーカス移動 SelectNextControl(ActiveControl, false, true, true, true); } }
private void OnCommonKeyDown(object sender, KeyEventArgs eventArgs) { switch (eventArgs.Key) { case Keys.GK_F1: if (ActiveControl is ListBox) { ListBox box = (ListBox)ActiveControl; int idx = box.SelIndex; if (idx >= 0 && idx < box.Items.Count) { Item item = (Item)box.Items.GetItem(idx).Data; GlobalVars.nwrWin.ShowKnowledge(item.Entry.Name); } } break; case Keys.GK_TAB: if (ActiveControl.Equals(fEquipList)) { ActiveControl = fPackList; } else if (ActiveControl.Equals(fPackList)) { ActiveControl = fOutList; } else if (ActiveControl.Equals(fOutList)) { ActiveControl = fEquipList; } break; case Keys.GK_RETURN: if (ActiveControl.Equals(fEquipList) && fEquipList.SelIndex >= 0) { Equip_ItemSelect(fEquipList, MouseButton.mbRight, fEquipList.Items.GetItem(fEquipList.SelIndex)); } else if (ActiveControl.Equals(fPackList) && fPackList.SelIndex >= 0) { Pack_ItemSelect(fPackList, MouseButton.mbRight, fPackList.Items.GetItem(fPackList.SelIndex)); } else if (ActiveControl.Equals(fOutList) && fOutList.SelIndex >= 0) { Out_ItemSelect(fOutList, MouseButton.mbRight, fOutList.Items.GetItem(fOutList.SelIndex)); } break; case Keys.GK_UP: if ((eventArgs.Shift.Contains(ShiftStates.SsCtrl))) { if (ActiveControl.Equals(fPackList)) { PackToEquip(); } else { if (ActiveControl.Equals(fOutList)) { OutToPack(); } } } break; case Keys.GK_DOWN: if ((eventArgs.Shift.Contains(ShiftStates.SsCtrl))) { if (ActiveControl.Equals(fEquipList)) { EquipToPack(); } else { if (ActiveControl.Equals(fPackList)) { PackToOut(); } } } break; case Keys.GK_RIGHT: case Keys.GK_LEFT: break; } }