void SimulationHandler_StateChanged(object sender, MySimulationHandler.StateEventArgs e) { MySimulationHandler simulationHandler = sender as MySimulationHandler; runToolButton.Enabled = simulationHandler.CanStart; stepInButton.Enabled = simulationHandler.CanStepInto; stepOutButton.Enabled = simulationHandler.CanStepOut; stepOverButton.Enabled = simulationHandler.CanStepOver; pauseToolButton.Enabled = simulationHandler.CanPause; UpdateDebugListView(); if (e.NewState == MySimulationHandler.SimulationState.PAUSED) { if (simulationHandler.Simulation.InDebugMode) { noDebugLabel.Visible = false; MyExecutionBlock currentBlock = simulationHandler.Simulation.CurrentDebuggedBlock; m_selectedNodeView = null; if (currentBlock != null && currentBlock.CurrentChild != null) { m_selectedNodeView = debugTreeView.AllNodes.FirstOrDefault(node => (node.Tag is MyDebugNode && (node.Tag as MyDebugNode).Executable == currentBlock.CurrentChild)); } ; } debugTreeView.Invalidate(); //debugTreeView.Invoke((MethodInvoker)(() => debugTreeView.SelectedNode = m_selectedNodeView)); } else if (e.NewState == MySimulationHandler.SimulationState.STOPPED) { m_executionPlan = null; debugTreeView.Model = null; noDebugLabel.Visible = true; if (this.IsFloat) { this.Hide(); } } breakpointCheckBox.EditEnabled = simulationHandler.Simulation.InDebugMode; }
private void UpdateDebugListView() { if (IsHidden) { return; } // Clean up the event handlers. foreach (var node in debugTreeView.AllNodes) { var debugNode = node.Tag as MyDebugNode; debugNode.BreakpointStateChanged -= OnBreakpointStateChanged; } m_executionPlan = m_mainForm.SimulationHandler.Simulation.ExecutionPlan; if (m_executionPlan != null) { var treeModel = new TreeModel(); if (m_executionPlan.InitStepPlan != null) { treeModel.Nodes.Add(CreateDebugNode(m_executionPlan.InitStepPlan)); } treeModel.Nodes.Add(CreateDebugNode(m_executionPlan.StandardStepPlan)); debugTreeView.Model = treeModel; debugTreeView.ExpandAll(); } foreach (var node in debugTreeView.AllNodes) { var debugNode = node.Tag as MyDebugNode; debugNode.Breakpoint = m_mainForm.Breakpoints.Contains(debugNode.Executable); } }