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 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 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 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); }