private void Button_Remove(object sender, RoutedEventArgs e) { KeyChangeItem changeItem = ItemList.SelectedItem as KeyChangeItem; if (changeItem == null) { return; } KeyChangeManager.Instance.RemoveChange(changeItem); }
public KeyChangeItem NewChange() { KeyChangeItem changeItem = new KeyChangeItem(); changeItem.FromStores.Add(new KeyStoreInfo()); changeItem.ToStores.Add(new KeyStoreInfo()); KeyChangeItemCollection.Add(changeItem); return(changeItem); }
public static void WriteItem(KeyChangeItem keyItem, ref XmlDocument xmlDoc, ref XmlNode xmlNode) { XmlElement xmlGroup = xmlDoc.CreateElement(KEY_GROUP); XmlElement xmlFrom = xmlDoc.CreateElement(KEY_CHANGE_FROM); WriteStore(keyItem.FromStores, ref xmlDoc, ref xmlFrom); xmlGroup.AppendChild(xmlFrom); XmlElement xmlTo = xmlDoc.CreateElement(KEY_CHANGE_TO); WriteStore(keyItem.ToStores, ref xmlDoc, ref xmlTo); xmlGroup.AppendChild(xmlTo); xmlNode.AppendChild(xmlGroup); }
private bool SendKeyItem(KeyChangeItem keyItem) { //没有按下,发送按下 if (!keyItem.IsDown) { foreach (KeyStoreInfo keyStore in keyItem.ToStores) { //先只支持键盘 try { if (!keyStore.IsJoystick()) { byte keyCode = (byte)keyStore._Keyboard; user32.keybd_event(keyCode, ScanCode(keyCode), 0, 0); } } catch (Exception e) { } } keyItem.IsDown = true; return(true); } //已经按下,发送弹起 else { foreach (KeyStoreInfo keyStore in keyItem.ToStores) { //先只支持键盘 try { if (!keyStore.IsJoystick()) { byte keyCode = (byte)keyStore._Keyboard; user32.keybd_event(keyCode, ScanCode(keyCode), user32.KEYEVENTF_KEYUP, 0); //user32.keybd_event(keyCode, ScanCode(keyCode), 0, 0); //byte keyCode2 = (byte)Keys.NumPad0; //user32.keybd_event(keyCode2, ScanCode(keyCode2), 0, 0); //user32.keybd_event(keyCode2, ScanCode(keyCode2), user32.KEYEVENTF_KEYUP, 0); } } catch (Exception e) { } } keyItem.IsDown = false; return(false); } }
public static void ReadGroup(XmlElement xmlElement) { KeyChangeItem newItem = KeyChangeManager.Instance.NewChange(); foreach (XmlElement childElement in xmlElement.ChildNodes.OfType <XmlElement>()) { if (childElement.Name == KEY_CHANGE_FROM) { newItem.FromStores = ReadStore(childElement); } else if (childElement.Name == KEY_CHANGE_TO) { newItem.ToStores = ReadStore(childElement); } } }
private int CompareKeyPrior(KeyChangeItem keyItem1, KeyChangeItem keyItem2) { foreach (KeyStoreInfo keyInfo in keyItem1.FromStores) { if (_KeyMatchPrior.ContainsKey(keyInfo.BtnName)) { if (_KeyMatchPrior[keyInfo.BtnName].Contains(keyItem2)) { if (_KeyMatchPrior[keyInfo.BtnName].IndexOf(keyItem1) > _KeyMatchPrior[keyInfo.BtnName].IndexOf(keyItem2)) { return(1); } else { return(-1); } } } } return(0); }
public KeyChangeItem NewChange() { KeyChangeItem changeItem = new KeyChangeItem(); changeItem.FromStores.Add(new KeyStoreInfo()); changeItem.ToStores.Add(new KeyStoreInfo()); KeyChangeItemCollection.Add(changeItem); return changeItem; }
private int CompareKeyPrior(KeyChangeItem keyItem1, KeyChangeItem keyItem2) { foreach (KeyStoreInfo keyInfo in keyItem1.FromStores) { if (_KeyMatchPrior.ContainsKey(keyInfo.BtnName)) { if (_KeyMatchPrior[keyInfo.BtnName].Contains(keyItem2)) { if (_KeyMatchPrior[keyInfo.BtnName].IndexOf(keyItem1) > _KeyMatchPrior[keyInfo.BtnName].IndexOf(keyItem2)) return 1; else return -1; } } } return 0; }
public void RemoveChange(KeyChangeItem changeItem) { KeyChangeItemCollection.Remove(changeItem); }
private bool SendKeyItem(KeyChangeItem keyItem) { //没有按下,发送按下 if (!keyItem.IsDown) { foreach (KeyStoreInfo keyStore in keyItem.ToStores) { //先只支持键盘 try { if (!keyStore.IsJoystick()) { byte keyCode = (byte)keyStore._Keyboard; user32.keybd_event(keyCode, ScanCode(keyCode), 0, 0); } } catch (Exception e) { } } keyItem.IsDown = true; return true; } //已经按下,发送弹起 else { foreach (KeyStoreInfo keyStore in keyItem.ToStores) { //先只支持键盘 try { if (!keyStore.IsJoystick()) { byte keyCode = (byte)keyStore._Keyboard; user32.keybd_event(keyCode, ScanCode(keyCode), user32.KEYEVENTF_KEYUP, 0); //user32.keybd_event(keyCode, ScanCode(keyCode), 0, 0); //byte keyCode2 = (byte)Keys.NumPad0; //user32.keybd_event(keyCode2, ScanCode(keyCode2), 0, 0); //user32.keybd_event(keyCode2, ScanCode(keyCode2), user32.KEYEVENTF_KEYUP, 0); } } catch (Exception e) { } } keyItem.IsDown = false; return false; } }