System.Drawing.Point GetExecutionCursor(bool start)
        {
            System.Drawing.Point cursor  = new System.Drawing.Point();
            IExecutionSession    session = Solution.Current.ExecutionSession;

            if (null != session)
            {
                CodeRange codeRange = new CodeRange();
                if (session.GetExecutionCursor(ref codeRange))
                {
                    if (false != start)
                    {
                        cursor.X = codeRange.StartInclusive.CharNo - 1;
                        cursor.Y = codeRange.StartInclusive.LineNo - 1;
                    }
                    else
                    {
                        cursor.X = codeRange.EndExclusive.CharNo - 1;
                        cursor.Y = codeRange.EndExclusive.LineNo - 1;
                    }
                }
            }

            return(cursor);
        }
        internal void HandleScriptActivation()
        {
            //Check if its in playback mode, as it should be treated differently due to blocking
            if (player == null)
            {
                if (textCore.ChangeScript(ScriptTabControl.CurrentTab))
                {
                    CheckTabControlVisibility(false);
                }
                else
                {
                    return;
                }
            }
            else
            {
                CheckTabControlVisibility(false);
                TextEditorCommand command = new TextEditorCommand(TextEditorCommand.Method.ChangeScript);
                command.AppendArgument(ScriptTabControl.CurrentTab);
                textCore.PlaybackCommand(command);
            }

            // Resize canvas to fit the next script.
            //if (numSlider != null)
            //    numSlider.Visibility = Visibility.Collapsed;
            UpdateCanvasDimension();

            IExecutionSession session = Solution.Current.ExecutionSession;

            UpdateScriptDisplay(Solution.Current.ActiveScript);
            UpdateCaretPosition(false);
            textCanvas.BreakpointsUpdated();

            if (null != session)
            {
                CodeRange executionCursor = new CodeRange();
                if (session.GetExecutionCursor(ref executionCursor))
                {
                    textCanvas.SetExecutionCursor(executionCursor);
                }
            }

            if (null != textEditorControl.textCore.CurrentTextBuffer)
            {
                textCanvas.ScrollOwner.ScrollToVerticalOffset(
                    textEditorControl.textCore.VerticalScrollPosition);
            }
        }