public void AddPoseCombination(Window window, PoseCombination poseCombination, bool isEdit, int editIndex, Form form) { if (isEdit && !window.IsExistPoseCombinationEdit(poseCombination, editIndex)) { window.RemovePoseCombinationByIndex(editIndex); window.InsertPoseCombination(editIndex, poseCombination); form.Close(); } else if (!isEdit && !window.IsExistPoseCombination(poseCombination)) { window.AddPoseCombination(poseCombination); form.Close(); } else MessageBox.Show("此手勢組合已選擇過!!!", "警告", MessageBoxButtons.OK); }
public void AddPoseCombination(Window window, PoseCombination poseCombination, bool isEdit, int editIndex, Form form) { if (isEdit && !window.IsExistPoseCombinationEdit(poseCombination, editIndex)) { window.RemovePoseCombinationByIndex(editIndex); window.InsertPoseCombination(editIndex, poseCombination); form.Close(); } else if (!isEdit && !window.IsExistPoseCombination(poseCombination)) { window.AddPoseCombination(poseCombination); form.Close(); } else { MessageBox.Show("此手勢組合已選擇過!!!", "警告", MessageBoxButtons.OK); } }
//讀檔處理 public void easyControlLoad(string file) { if (!File.Exists(file)) { return; } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(file); XmlNodeList windowNodeLists = xmlDoc.SelectNodes("easy-control/window"); foreach (XmlNode windowNode in windowNodeLists) { string windowName = windowNode.Attributes["windowName"].Value; string imagePath = windowNode.Attributes["imagePath"].Value; string winIsEnable = windowNode.Attributes["isEnable"].Value; Window window = _model.AddWindow(windowName); window.SetImage(imagePath); if (winIsEnable == "True") { window.IsEnable = true; } else { window.IsEnable = false; } XmlNodeList poseCombinationNodeLists = windowNode.ChildNodes; foreach (XmlNode poseCombinationNode in poseCombinationNodeLists) { PoseCombination poseCombination = new PoseCombination(); string poseCombinationIsContinue = poseCombinationNode.Attributes["isContinue"].Value; string poseCombinationIsEnable = poseCombinationNode.Attributes["isEnable"].Value; XmlNodeList poseKeyLists = poseCombinationNode.ChildNodes; XmlNode poseNode = poseKeyLists.Item(0); string poses = poseNode.InnerText; XmlNode keyNode = poseKeyLists.Item(1); string keys = keyNode.InnerText; XmlNode keyStateNode = poseKeyLists.Item(2); string keyStates = keyStateNode.InnerText; if (poseCombinationIsContinue == "True") { poseCombination.IsContinue = true; } else { poseCombination.IsContinue = false; } if (poseCombinationIsEnable == "True") { poseCombination.IsEnable = true; } else { poseCombination.IsEnable = false; } string[] pose = poses.Split('+'); for (int i = 0; i < pose.Count(); i++) { poseCombination.AddPose(pose[i]); } string[] key = keys.Split('+'); string[] keyState = keyStates.Split('+'); for (int i = 0; i < key.Count(); i++) { switch (keyState[i]) { case "Press": poseCombination.AddKey(_keyMap[key[i]], KeyStates.Press); break; case "Hold": poseCombination.AddKey(_keyMap[key[i]], KeyStates.Hold); break; case "Release": poseCombination.AddKey(_keyMap[key[i]], KeyStates.Release); break; default: break; } } poseCombination.GetImage = GetPoseCombinationImage(poseCombination, 644, 172); window.AddPoseCombination(poseCombination); } } }