private void SetExecutionState(ExecutionStateChangedEventArgs.States state)
        {
            ExecutionStateChangedEventArgs.States oldState = this.executionState;
            this.executionState = state;

            if (null != ExecutionStateChanged)
            {
                ExecutionStateChangedEventArgs args = null;
                args = new ExecutionStateChangedEventArgs(oldState, state);
                ExecutionStateChanged(this, args);
            }
        }
Example #2
0
        private void OnExecutionStateChanged(object sender, ExecutionStateChangedEventArgs e)
        {
            if (e.CurrentState == ExecutionStateChangedEventArgs.States.Debugging)
            {
                // If this is the first time user hits "Run (Debug)", register all breakpoints.
                if (e.PreviousState == ExecutionStateChangedEventArgs.States.None)
                {
                    Solution.Current.FlushBreakpointsToVm();
                }
            }
            else if (e.CurrentState == ExecutionStateChangedEventArgs.States.Paused)
            {
                // The debugger has just gotten to a breakpoint.
                hostApplication.PostStepTearDown();
                TextEditorCore.Instance.UpdateExecutionCursor();
            }
            else if (e.CurrentState == ExecutionStateChangedEventArgs.States.Stopped)
            {
                // The debugging has come to an end.
                hostApplication.PostStepTearDown();
                TextEditorCore.Instance.UpdateExecutionCursor();
            }
            else if (e.CurrentState == ExecutionStateChangedEventArgs.States.None)
            {
                // "Run" to "None" means running without debugger has just ended.
                if (e.PreviousState == ExecutionStateChangedEventArgs.States.Running)
                {
                    hostApplication.PostStepTearDown();
                    hostApplication.PostExecutionTearDown();
                    TextEditorCore.Instance.UpdateExecutionCursor();
                }
                else if (e.PreviousState == ExecutionStateChangedEventArgs.States.Debugging)
                {
                    //
                }
            }

            if (null != TextEditorCore.Instance.UiExecutionStateChangeHandler)
            {
                TextEditorCore.Instance.UiExecutionStateChangeHandler(this, e);
            }
        }
Example #3
0
        private void OnExecutionStateChanged(object sender, ExecutionStateChangedEventArgs e)
        {
            if (e.CurrentState == ExecutionStateChangedEventArgs.States.Debugging)
            {
                // If this is the first time user hits "Run (Debug)", register all breakpoints.
                if (e.PreviousState == ExecutionStateChangedEventArgs.States.None)
                    Solution.Current.FlushBreakpointsToVm();
            }
            else if (e.CurrentState == ExecutionStateChangedEventArgs.States.Paused)
            {
                // The debugger has just gotten to a breakpoint.
                hostApplication.PostStepTearDown();
                TextEditorCore.Instance.UpdateExecutionCursor();
            }
            else if (e.CurrentState == ExecutionStateChangedEventArgs.States.Stopped)
            {
                // The debugging has come to an end.
                hostApplication.PostStepTearDown();
                TextEditorCore.Instance.UpdateExecutionCursor();
            }
            else if (e.CurrentState == ExecutionStateChangedEventArgs.States.None)
            {
                // "Run" to "None" means running without debugger has just ended.
                if (e.PreviousState == ExecutionStateChangedEventArgs.States.Running)
                {
                    hostApplication.PostStepTearDown();
                    hostApplication.PostExecutionTearDown();
                    TextEditorCore.Instance.UpdateExecutionCursor();
                }
                else if (e.PreviousState == ExecutionStateChangedEventArgs.States.Debugging)
                {
                    //
                }
            }

            if (null != TextEditorCore.Instance.UiExecutionStateChangeHandler)
                TextEditorCore.Instance.UiExecutionStateChangeHandler(this, e);
        }
        private void SetExecutionState(ExecutionStateChangedEventArgs.States state)
        {
            ExecutionStateChangedEventArgs.States oldState = this.executionState;
            this.executionState = state;

            if (null != ExecutionStateChanged)
            {
                ExecutionStateChangedEventArgs args = null;
                args = new ExecutionStateChangedEventArgs(oldState, state);
                ExecutionStateChanged(this, args);
            }
        }
        private void OnExecutionStateChanged(object sender, ExecutionStateChangedEventArgs e)
        {
            bool executionInProgress = false;
            bool refreshOutputPanes = false;
            bool refreshInspectionPane = false;
            bool refreshOnScreenBreakpoints = false;
            bool refreshExecutionCursor = false;
            Color textCanvasBackground = Colors.White;
            Color scrollViewerBackground = Colors.White;

            switch (e.CurrentState)
            {
                case ExecutionStateChangedEventArgs.States.None:
                    refreshOutputPanes = true;
                    refreshInspectionPane = true;
                    refreshOnScreenBreakpoints = true;

                    textCore.ReadOnlyState = false;
                    textCanvasBackground = Colors.White;
                    scrollViewerBackground = Colors.White;
                    break;

                case ExecutionStateChangedEventArgs.States.Running:
                    executionInProgress = true;
                    textCore.ReadOnlyState = true;
                    textCanvasBackground = UIColors.TextCanvasBackground;
                    scrollViewerBackground = UIColors.ScrollViewerBackground;
                    break;

                case ExecutionStateChangedEventArgs.States.Debugging:
                    executionInProgress = true;
                    textCore.ReadOnlyState = true;
                    textCanvasBackground = UIColors.TextCanvasBackground;
                    scrollViewerBackground = UIColors.ScrollViewerBackground;
                    break;

                case ExecutionStateChangedEventArgs.States.Paused:
                    refreshOutputPanes = true;
                    refreshInspectionPane = true;
                    refreshOnScreenBreakpoints = true;
                    refreshExecutionCursor = true;

                    textCore.ReadOnlyState = true;
                    textCanvasBackground = UIColors.TextCanvasBackground;
                    scrollViewerBackground = UIColors.ScrollViewerBackground;
                    break;

                case ExecutionStateChangedEventArgs.States.Stopped:
                    refreshOutputPanes = true;
                    refreshInspectionPane = true;
                    refreshOnScreenBreakpoints = true;

                    textCore.ReadOnlyState = true;
                    textCanvasBackground = UIColors.TextCanvasBackground;
                    scrollViewerBackground = UIColors.ScrollViewerBackground;
                    break;
            }

            // Display/hide execution status bar depending on the state.
            ShowStatusProgressBar(executionInProgress);

            if (false != refreshExecutionCursor)
            {
                CodeRange executionCursor = new CodeRange();
                IExecutionSession session = Solution.Current.ExecutionSession;
                if (session.GetExecutionCursor(ref executionCursor))
                {
                    if (null != executionCursor.StartInclusive.SourceLocation)
                    {
                        CodePoint codePoint = executionCursor.StartInclusive;
                        ActivateScriptByPath(codePoint.SourceLocation.FilePath);
                    }

                    UpdateCaretPosition();
                    textCanvas.SetExecutionCursor(executionCursor);
                }
                else
                    textCanvas.ClearExecutionCursor(); // Busy?
            }
            else
            {
                // Either busy executing or not execution at all,
                // we don't show the execution cursor for both cases.
                textCanvas.ClearExecutionCursor();
            }

            if (false != refreshOutputPanes)
            {
                IOutputStream outputStream = Solution.Current.GetMessage(false);
                List<ProtoCore.OutputMessage> outputMessages = outputStream.GetMessages();
                Solution.Current.AddInlineMessages(outputMessages);
                OutputWindow.Instance.SetOutputMessage(outputMessages);
                ErrorWindow.Instance.SetErrorMessage(outputMessages);
            }

            if (false != refreshInspectionPane)
            {
                // Inspection window cannot be updated while the vm is running
                // in the background (i.e. being in 'Debugging' or 'Running'
                // state). Other than that we'll refresh the inspection view,
                // even when it is 'None', in which case the inspection view is
                // refreshed with 'null' values.
                InspectionViewControl.Instance.RefreshInspectionView();
            }

            if (false != refreshOnScreenBreakpoints)
                textCanvas.BreakpointsUpdated();

            #if DEBUG
            if (e.CurrentState == ExecutionStateChangedEventArgs.States.Debugging)
            {
                if (e.PreviousState == ExecutionStateChangedEventArgs.States.None)
                {
                    List<DisassemblyEntry> instructions = new List<DisassemblyEntry>();
                    Solution.Current.ExecutionSession.PopulateInstructions(instructions);
                    Disassembly.Instance.BindNewInstructionList(instructions);
                }
            }
            #endif

            textCanvas.Background = new SolidColorBrush(textCanvasBackground);
            scrollViewer.Background = new SolidColorBrush(scrollViewerBackground);
            CommandManager.InvalidateRequerySuggested(); // Refresh button states.
        }
Example #6
0
 private void OnExecutionStateChanged(object sender, ExecutionStateChangedEventArgs e)
 {
 }