public EditRecording(ConcurrentQueue<string> actionQueue ) { tempList = actionQueue.ToList(); InitializeComponent(); bool firstMove = true; int count = 0; string moveAction = string.Empty; ps = new PointScreen(); int testFirstXCoord, testFirstYCoord, testSecondXCoord, testSecondYCoord; testFirstXCoord = testFirstYCoord = testSecondXCoord = testSecondYCoord = 0; foreach(string action in tempList) { if (action.StartsWith("[") && action.EndsWith("];")) { double seconds = Convert.ToInt64(action.Replace("];", "").Replace("[", "")); seconds = TimeSpan.FromMilliseconds(seconds).TotalSeconds; //ActionList.Items.Add(string.Format("Wait for {0} seconds", seconds)); } else if (action.StartsWith("{") && action.EndsWith("};")) { if (firstMove) { string tempAction = action.Replace("{", "").Replace("};", ""); testFirstXCoord = Convert.ToInt32(tempAction.Substring(0, tempAction.IndexOf(","))); testFirstYCoord = Convert.ToInt32(tempAction.Substring(tempAction.IndexOf(",") + 2)); moveAction += string.Format("Move from X: {0} Y: {1} to ", tempAction.Substring(0, tempAction.IndexOf(",")), tempAction.Substring(tempAction.IndexOf(",") + 2)); firstMove = false; } } else if (mouseActions.Contains(action.Replace(";", ""))) { string lastMove = string.Empty; if (tempList[count - 1].Contains("{")) { lastMove = tempList[count - 1]; } else if (tempList[count - 2].Contains("{")) { lastMove = tempList[count - 2]; } if (!string.IsNullOrEmpty(lastMove)) { string tempAction = lastMove.Replace("{", "").Replace("};", ""); testSecondXCoord = Convert.ToInt32(tempAction.Substring(0, tempAction.IndexOf(","))); testSecondYCoord = Convert.ToInt32(tempAction.Substring(tempAction.IndexOf(",") + 2)); moveAction += string.Format("X: {0} Y: {1}", tempAction.Substring(0, tempAction.IndexOf(",")), tempAction.Substring(tempAction.IndexOf(",") + 2)); if (testFirstXCoord != testSecondXCoord && testFirstYCoord != testSecondYCoord) { ActionList.Items.Add(moveAction); } testFirstXCoord = testSecondXCoord = testFirstYCoord = testSecondYCoord = 0; moveAction = string.Empty; firstMove = true; } if (action.Replace(";", "") == "LCU") { ActionList.Items.Add("Left Click"); } else if (action.Replace(";", "") == "RCU") { ActionList.Items.Add("Right Click"); } } else if (action.StartsWith("(") && action.EndsWith(");")) { ActionList.Items.Add(string.Format("Press the {0} key.", ((VirtualKeyCode) Convert.ToInt32(action.Replace("(", "").Replace(");", ""))))); } count++; } }
public EditRecording(ConcurrentQueue <string> actionQueue) { tempList = actionQueue.ToList(); InitializeComponent(); bool firstMove = true; int count = 0; string moveAction = string.Empty; ps = new PointScreen(); int testFirstXCoord, testFirstYCoord, testSecondXCoord, testSecondYCoord; testFirstXCoord = testFirstYCoord = testSecondXCoord = testSecondYCoord = 0; foreach (string action in tempList) { if (action.StartsWith("[") && action.EndsWith("];")) { double seconds = Convert.ToInt64(action.Replace("];", "").Replace("[", "")); seconds = TimeSpan.FromMilliseconds(seconds).TotalSeconds; //ActionList.Items.Add(string.Format("Wait for {0} seconds", seconds)); } else if (action.StartsWith("{") && action.EndsWith("};")) { if (firstMove) { string tempAction = action.Replace("{", "").Replace("};", ""); testFirstXCoord = Convert.ToInt32(tempAction.Substring(0, tempAction.IndexOf(","))); testFirstYCoord = Convert.ToInt32(tempAction.Substring(tempAction.IndexOf(",") + 2)); moveAction += string.Format("Move from X: {0} Y: {1} to ", tempAction.Substring(0, tempAction.IndexOf(",")), tempAction.Substring(tempAction.IndexOf(",") + 2)); firstMove = false; } } else if (mouseActions.Contains(action.Replace(";", ""))) { string lastMove = string.Empty; if (tempList[count - 1].Contains("{")) { lastMove = tempList[count - 1]; } else if (tempList[count - 2].Contains("{")) { lastMove = tempList[count - 2]; } if (!string.IsNullOrEmpty(lastMove)) { string tempAction = lastMove.Replace("{", "").Replace("};", ""); testSecondXCoord = Convert.ToInt32(tempAction.Substring(0, tempAction.IndexOf(","))); testSecondYCoord = Convert.ToInt32(tempAction.Substring(tempAction.IndexOf(",") + 2)); moveAction += string.Format("X: {0} Y: {1}", tempAction.Substring(0, tempAction.IndexOf(",")), tempAction.Substring(tempAction.IndexOf(",") + 2)); if (testFirstXCoord != testSecondXCoord && testFirstYCoord != testSecondYCoord) { ActionList.Items.Add(moveAction); } testFirstXCoord = testSecondXCoord = testFirstYCoord = testSecondYCoord = 0; moveAction = string.Empty; firstMove = true; } if (action.Replace(";", "") == "LCU") { ActionList.Items.Add("Left Click"); } else if (action.Replace(";", "") == "RCU") { ActionList.Items.Add("Right Click"); } } else if (action.StartsWith("(") && action.EndsWith(");")) { ActionList.Items.Add(string.Format("Press the {0} key.", ((VirtualKeyCode)Convert.ToInt32(action.Replace("(", "").Replace(");", ""))))); } count++; } }