private void lstSteppingCommands_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index != -1) { SteppingCommandsItem item = lstSteppingCommands.Items[e.Index] as SteppingCommandsItem; if (item != null) { if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { e = new DrawItemEventArgs(e.Graphics, e.Font, e.Bounds, e.Index, e.State ^ DrawItemState.Selected, e.ForeColor, item.Color); e.DrawBackground(); e.Graphics.DrawString(item.Text, e.Font, Brushes.White, e.Bounds); } else { e.DrawBackground(); e.Graphics.DrawString(item.Text, e.Font, new SolidBrush(item.Color), e.Bounds); } e.DrawFocusRectangle(); } } }
public void uiBtnPause_Click(object sender, EventArgs e) { if (InvokeRequired) { var d = new uiBtnPause_ClickDelegate(uiBtnPause_Click); Invoke(d, new object[] { sender, e }); } else { if (uiBtnPause.DisplayText == "Pause") { SteppingCommandsItem commandsItem = new SteppingCommandsItem { Text = "[User Requested Pause]", Color = Color.Red }; lstSteppingCommands.Items.Add(commandsItem); uiBtnPause.Image = Resources.engine_resume; uiBtnPause.DisplayText = "Resume"; EngineInstance.PauseScript(); } else if (uiBtnPause.DisplayText == "Resume") { SteppingCommandsItem commandsItem = new SteppingCommandsItem { Text = "[User Requested Resume]", Color = Color.Green }; lstSteppingCommands.Items.Add(commandsItem); uiBtnPause.Image = Resources.engine_pause; uiBtnPause.DisplayText = "Pause"; uiBtnStepOver.Visible = false; uiBtnStepInto.Visible = false; if (EngineContext.ScriptBuilder != null) { EngineContext.ScriptBuilder.IsScriptSteppedOver = false; EngineContext.ScriptBuilder.IsScriptSteppedInto = false; } if (IsNewTaskSteppedInto || !IsHiddenTaskEngine) { IsNewTaskResumed = true; } EngineInstance.ResumeScript(); } lstSteppingCommands.SelectedIndex = lstSteppingCommands.Items.Count - 1; } }
public void uiBtnCancel_Click(object sender, EventArgs e) { if (InvokeRequired) { var d = new uiBtnCancel_ClickDelegate(uiBtnCancel_Click); Invoke(d, new object[] { sender, e }); } else { if (uiBtnCancel.DisplayText == "Close") { UpdateLineNumber(0); ClosingAllEngines = true; Close(); Dispose(); return; } if (IsNewTaskSteppedInto || IsHiddenTaskEngine) { IsNewTaskResumed = false; IsNewTaskCancelled = true; } uiBtnPause.Visible = false; uiBtnCancel.Visible = false; uiBtnStepInto.Visible = false; uiBtnStepOver.Visible = false; lblKillProcNote.Text = "Cancelling..."; EngineInstance.ResumeScript(); SteppingCommandsItem commandsItem = new SteppingCommandsItem { Text = "[User Requested Cancellation]", Color = Color.Black }; lstSteppingCommands.Items.Add(commandsItem); lstSteppingCommands.SelectedIndex = lstSteppingCommands.Items.Count - 1; lblMainLogo.Text = "debug info (cancelling)"; EngineInstance.CancelScript(); } }
/// <summary> /// Adds a status to the listbox for debugging and display purposes /// </summary> /// <param name="text"></param> public void AddStatus(string text, Color?statusColor = null) { if (InvokeRequired) { var d = new AddStatusDelegate(AddStatus); Invoke(d, new object[] { text, statusColor }); } else { if (text == "Pausing Before Execution" && !uiBtnStepOver.Visible) { uiBtnPause_Click(null, null); uiBtnStepOver.Visible = true; uiBtnStepInto.Visible = true; if (IsHiddenTaskEngine) { //toggle running flag to allow for tab selection EngineContext.ScriptBuilder.IsScriptRunning = false; ((frmScriptBuilder)EngineContext.ScriptBuilder).OpenOpenBotsFile(EngineContext.FilePath, true); EngineContext.ScriptBuilder.IsScriptRunning = true; EngineContext.ScriptBuilder.CurrentEngine = this; IsNewTaskSteppedInto = true; IsHiddenTaskEngine = false; EngineContext.ScriptBuilder.IsScriptPaused = false; } EngineContext.ScriptBuilder.IsScriptPaused = false; UpdateLineNumber(DebugLineNumber); } else if (text == "Pausing Before Exception") { uiBtnPause_Click(null, null); uiBtnStepOver.Visible = true; uiBtnStepInto.Visible = true; if (IsHiddenTaskEngine) { EngineContext.ScriptBuilder.CurrentEngine = this; //toggle running flag to allow for tab selection EngineContext.ScriptBuilder.IsScriptRunning = false; ((frmScriptBuilder)EngineContext.ScriptBuilder).OpenOpenBotsFile(EngineContext.FilePath, true); EngineContext.ScriptBuilder.IsScriptRunning = true; IsNewTaskSteppedInto = true; IsHiddenTaskEngine = false; } EngineContext.ScriptBuilder.IsScriptPaused = false; UpdateLineNumber(DebugLineNumber); } else { //update status lblAction.Text = text + ".."; SteppingCommandsItem commandsItem = new SteppingCommandsItem { Text = DateTime.Now.ToString("MM/dd/yy hh:mm:ss.fff") + " | " + text, Color = statusColor ?? SystemColors.Highlight }; lstSteppingCommands.Items.Add(commandsItem); lstSteppingCommands.SelectedIndex = lstSteppingCommands.Items.Count - 1; } } }