public bool CheckPoseKeyExist(PoseCombination poseCombination) { if (poseCombination.CheckPose() && poseCombination.CheckKey()) return true; else return false; }
public void ProcessKeyPictureBoxPaint(Graphics graphics, PoseCombination poseCombination) { SolidBrush redBrush = new SolidBrush(Color.FromArgb(100, 255, 0, 0)); SolidBrush greenBrush = new SolidBrush(Color.FromArgb(100, 0, 255, 0)); SolidBrush blueBrush = new SolidBrush(Color.FromArgb(100, 0, 0, 255)); for (int i = 0; i < poseCombination.GetKeyLength(); i++) { Key key = poseCombination.GetKey(i); switch (key.State) { //design by http://stackoverflow.com/questions/2444033/get-dictionary-key-by-value case KeyStates.Press: graphics.FillRectangle(redBrush, _keyBoard.FirstOrDefault(x => x.Value.Code == key.Code).Key); break; case KeyStates.Hold: graphics.FillRectangle(greenBrush, _keyBoard.FirstOrDefault(x => x.Value.Code == key.Code).Key); break; case KeyStates.Release: graphics.FillRectangle(blueBrush, _keyBoard.FirstOrDefault(x => x.Value.Code == key.Code).Key); break; } } }
public void ProcessClickKeyPictureBox(int locationX, int locationY, PoseCombination poseCombination) { foreach (Rectangle keyRect in _keyBoard.Keys) { if (keyRect.Contains(locationX, locationY)) OpenForm(new Key(_keyBoard[keyRect].Code, _keyBoard[keyRect].State), poseCombination); } }
public void ProcessClickKeyPictureBox(int locationX, int locationY, PoseCombination poseCombination) { foreach (Rectangle keyRect in _keyBoard.Keys) { if (keyRect.Contains(locationX, locationY)) { OpenForm(new Key(_keyBoard[keyRect].Code, _keyBoard[keyRect].State), poseCombination); } } }
public PoseCombination GetPoseCombination(int index) { PoseCombination response = null; if (index < _poseCollection.Count) { response = _poseCollection[index]; } return(response); }
public bool CheckPosesIsContinue(PoseCombination poseCombination) { if (poseCombination.IsContinue) return true; else { if (poseCombination.IsContinue) poseCombination.IsContinue = false; return false; } }
public bool IsExistPoseCombination(PoseCombination poseCombination) { foreach (PoseCombination poses in _poseCollection) { if (poses.GetPoseList().SequenceEqual(poseCombination.GetPoseList())) { return(true); } } return(false); }
public bool CheckPoseKeyExist(PoseCombination poseCombination) { if (poseCombination.CheckPose() && poseCombination.CheckKey()) { return(true); } else { return(false); } }
public void ProcessInitailizePoseCombination(PoseCombination poseCombination, PoseCombination editPoseCombination) { for (int i = 0; i < editPoseCombination.GetPoseLength(); i++) { poseCombination.AddPose(editPoseCombination.GetPose(i)); } for (int i = 0; i < editPoseCombination.GetKeyLength(); i++) { poseCombination.AddKey(editPoseCombination.GetKey(i)); } poseCombination.IsContinue = editPoseCombination.IsContinue; }
public void ProcessPosePictureBoxPaint(Graphics graphics, PoseCombination poseCombination) { if (poseCombination.GetPoseLength() != 0) { graphics.DrawImage(GetImage(poseCombination.GetPose(0), 75, 75), 30, 260); } for (int i = 1; i < poseCombination.GetPoseLength(); i++) { graphics.DrawString("+", new Font("微軟正黑體", 30), Brushes.SkyBlue, 110 * i - 10, 265); graphics.DrawImage(GetImage(poseCombination.GetPose(i), 75, 75), 30 + 110 * i, 260); } }
public void ChangeMouseInPictureBox(PoseCombination poseCombination, int mouseLocationX, int mouseLocationXY) { foreach (Rectangle section in _poseBoard.Keys) { if (section.Contains(mouseLocationX, mouseLocationXY)) Cursor.Current = Cursors.Hand; } for (int i = 0; i < poseCombination.GetPoseLength(); i++) { Rectangle select = new Rectangle(30 + 110 * i, 260, 75, 75); if (select.Contains(mouseLocationX, mouseLocationXY)) Cursor.Current = Cursors.Hand; } }
public bool CheckPosesIsContinue(PoseCombination poseCombination) { if (poseCombination.IsContinue) { return(true); } else { if (poseCombination.IsContinue) { poseCombination.IsContinue = false; } return(false); } }
public bool IsExistPoseCombinationEdit(PoseCombination poseCombination, int editIndex) { PoseCombination editPoseCombination = _poseCollection[editIndex]; _poseCollection.RemoveAt(editIndex); foreach (PoseCombination poses in _poseCollection) { if (poses.GetPoseList().SequenceEqual(poseCombination.GetPoseList())) { _poseCollection.Insert(editIndex, editPoseCombination); return(true); } } _poseCollection.Insert(editIndex, editPoseCombination); return(false); }
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); }
private void OpenForm(Key key, PoseCombination poseCombination) { if (poseCombination.IsKeyExist(key)) { poseCombination.ToggleKey(key); } else { KeyState keyState = new KeyState(); DialogResult result = keyState.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { key.State = keyState.GetKeyState(); poseCombination.ToggleKey(key); } } }
public Bitmap GetPoseCombinationImage(PoseCombination poseCombination, int keyBoardWidth, int keyBoardHeight) { Bitmap canvas = new Bitmap(300, 50); Graphics graphics = Graphics.FromImage(canvas); graphics.Clear(SystemColors.Control); if (poseCombination.GetPoseLength() != 0) graphics.DrawImage(GetImage(poseCombination.GetPose(0), 50, 50), 0, 0); for (int i = 1; i < poseCombination.GetPoseLength(); i++) graphics.DrawImage(GetImage(poseCombination.GetPose(i), 50, 50), 52 * i, 0); graphics.DrawString("➜", new Font("Arial", 27), Brushes.Black, poseCombination.GetPoseLength() * 50, 5); for (int i = 0; i < poseCombination.GetKeyLength(); i++) { Rectangle section = _keyBoard.FirstOrDefault(x => x.Value.Code == poseCombination.GetKey(i).Code).Key; Bitmap cutImage = cutImageMethod.CutImage(GetImage("keyboard", keyBoardWidth, keyBoardHeight), section); graphics.DrawImage(cutImage, (poseCombination.GetPoseLength() + i + 1) * 50, 7); } return canvas; }
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 ProcessClickPosePictureBox(int locationX, int locationY, PoseCombination poseCombination) { foreach (Rectangle poseRect in _poseBoard.Keys) { if (poseRect.Contains(locationX, locationY)) { poseCombination.TogglePose(_poseBoard[poseRect]); } } for (int i = 0; i < poseCombination.GetPoseLength(); i++) { Rectangle select = new Rectangle(30 + 110 * i, 260, 75, 75); if (select.Contains(locationX, locationY)) { poseCombination.RemovePose(i); } } }
public void ChangeMouseInPictureBox(PoseCombination poseCombination, int mouseLocationX, int mouseLocationXY) { foreach (Rectangle section in _poseBoard.Keys) { if (section.Contains(mouseLocationX, mouseLocationXY)) { Cursor.Current = Cursors.Hand; } } for (int i = 0; i < poseCombination.GetPoseLength(); i++) { Rectangle select = new Rectangle(30 + 110 * i, 260, 75, 75); if (select.Contains(mouseLocationX, mouseLocationXY)) { Cursor.Current = Cursors.Hand; } } }
public Bitmap GetPoseCombinationImage(PoseCombination poseCombination, int keyBoardWidth, int keyBoardHeight) { Bitmap canvas = new Bitmap(300, 50); Graphics graphics = Graphics.FromImage(canvas); graphics.Clear(SystemColors.Control); if (poseCombination.GetPoseLength() != 0) { graphics.DrawImage(GetImage(poseCombination.GetPose(0), 50, 50), 0, 0); } for (int i = 1; i < poseCombination.GetPoseLength(); i++) { graphics.DrawImage(GetImage(poseCombination.GetPose(i), 50, 50), 52 * i, 0); } graphics.DrawString("➜", new Font("Arial", 27), Brushes.Black, poseCombination.GetPoseLength() * 50, 5); for (int i = 0; i < poseCombination.GetKeyLength(); i++) { Rectangle section = _keyBoard.FirstOrDefault(x => x.Value.Code == poseCombination.GetKey(i).Code).Key; Bitmap cutImage = cutImageMethod.CutImage(GetImage("keyboard", keyBoardWidth, keyBoardHeight), section); graphics.DrawImage(cutImage, (poseCombination.GetPoseLength() + i + 1) * 50, 7); } return(canvas); }
public void InsertPoseCombination(int index, PoseCombination poseCombination) { _poseCollection.Insert(index, poseCombination); }
public void AddPoseCombination(PoseCombination poseCombination) { _poseCollection.Add(poseCombination); }
//讀檔處理 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); } } }
public void RemovePoseCombination(PoseCombination poseCombination) { _poseCollection.Remove(poseCombination); }
public void ProcessPosePictureBoxPaint(Graphics graphics, PoseCombination poseCombination) { if (poseCombination.GetPoseLength() != 0) graphics.DrawImage(GetImage(poseCombination.GetPose(0), 75, 75), 30, 260); for (int i = 1; i < poseCombination.GetPoseLength(); i++) { graphics.DrawString("+", new Font("微軟正黑體", 30), Brushes.SkyBlue, 110 * i - 10, 265); graphics.DrawImage(GetImage(poseCombination.GetPose(i), 75, 75), 30 + 110 * i, 260); } }
public void ProcessClickPosePictureBox(int locationX, int locationY, PoseCombination poseCombination) { foreach (Rectangle poseRect in _poseBoard.Keys) { if (poseRect.Contains(locationX, locationY)) { poseCombination.TogglePose(_poseBoard[poseRect]); } } for (int i = 0; i < poseCombination.GetPoseLength(); i++) { Rectangle select = new Rectangle(30 + 110 * i, 260, 75, 75); if (select.Contains(locationX, locationY)) poseCombination.RemovePose(i); } }
//初始化PoseCombination public void InitailizePoseCombination(PoseCombination poseCombination) { _presentationModel.ProcessInitailizePoseCombination(_poseCombination, poseCombination); }
//讀檔處理 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); } } }
public bool IsExistPoseCombination(PoseCombination poseCombination) { foreach (PoseCombination poses in _poseCollection) { if (poses.GetPoseList().SequenceEqual(poseCombination.GetPoseList())) return true; } return false; }
public bool IsExistPoseCombinationEdit(PoseCombination poseCombination, int editIndex) { PoseCombination editPoseCombination = _poseCollection[editIndex]; _poseCollection.RemoveAt(editIndex); foreach (PoseCombination poses in _poseCollection) { if (poses.GetPoseList().SequenceEqual(poseCombination.GetPoseList())) { _poseCollection.Insert(editIndex, editPoseCombination); return true; } } _poseCollection.Insert(editIndex, editPoseCombination); return false; }