Inheritance: CsDebugScript.UI.CodeWindow.CsTextEditor
Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InteractiveWindow"/> class.
        /// </summary>
        public InteractiveWindow()
        {
            // Set window look
            Background    = ExecutingBackground;
            ShowInTaskbar = false;
            Title         = "C# Interactive Window";

            // Add dock panel and status bar
            DockPanel dockPanel = new DockPanel();
            StatusBar statusBar = new StatusBar();

            statusBarStatusText         = new StatusBarItem();
            statusBarStatusText.Content = InitializingStatusText;
            statusBar.Items.Add(statusBarStatusText);
            DockPanel.SetDock(statusBar, Dock.Bottom);
            dockPanel.Children.Add(statusBar);
            Content = dockPanel;

            // Add results panel
            ScrollViewer scrollViewer = new ScrollViewer();

            scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            scrollViewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            scrollViewer.Margin = new Thickness(5);
            dockPanel.Children.Add(scrollViewer);
            resultsPanel                       = new StackPanel();
            resultsPanel.Orientation           = Orientation.Vertical;
            resultsPanel.CanVerticallyScroll   = true;
            resultsPanel.CanHorizontallyScroll = true;
            scrollViewer.Content               = resultsPanel;

            // Add prompt for text editor
            var panel = new DockPanel();

            resultsPanel.Children.Add(panel);

            promptBlock            = new TextBlock();
            promptBlock.FontFamily = new FontFamily("Consolas");
            promptBlock.FontSize   = 14;
            promptBlock.Text       = ExecutingPrompt;
            DockPanel.SetDock(promptBlock, Dock.Left);
            panel.Children.Add(promptBlock);

            // Add text editor
            textEditor                  = new InteractiveCodeEditor();
            textEditor.Background       = Brushes.Transparent;
            textEditor.CommandExecuted += TextEditor_CommandExecuted;
            textEditor.CommandFailed   += TextEditor_CommandFailed;
            textEditor.Executing       += TextEditor_Executing;
            textEditor.CloseRequested  += TextEditor_CloseRequested;
            textEditor.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
            textEditor.VerticalScrollBarVisibility   = ScrollBarVisibility.Hidden;
            textEditor.TextArea.PreviewKeyDown      += TextEditor_PreviewKeyDown;
            panel.Children.Add(textEditor);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InteractiveWindowContent"/> class.
        /// </summary>
        /// <param name="interactiveExecutionInitialization">Interactive execution initialization.</param>
        /// <param name="fontFamily">The font family.</param>
        /// <param name="fontSize">Size of the font.</param>
        /// <param name="indentationSize">Size of the indentation.</param>
        /// <param name="highlightingColors">The highlighting colors.</param>
        public InteractiveWindowContent(InteractiveExecutionInitialization interactiveExecutionInitialization, string fontFamily, double fontSize, int indentationSize, params ICSharpCode.AvalonEdit.Highlighting.HighlightingColor[] highlightingColors)
        {
            this.fontFamily         = fontFamily;
            this.fontSize           = fontSize;
            this.indentationSize    = indentationSize;
            this.highlightingColors = highlightingColors;

            // Add results panel
            scrollViewer = new ScrollViewer();
            scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            scrollViewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            scrollViewer.Margin                = new Thickness(0);
            scrollViewer.Padding               = new Thickness(5);
            resultsPanel                       = new StackPanel();
            resultsPanel.Orientation           = Orientation.Vertical;
            resultsPanel.CanVerticallyScroll   = true;
            resultsPanel.CanHorizontallyScroll = true;
            scrollViewer.Content               = resultsPanel;
            interactiveExecutionInitialization.InteractiveExecutionBehavior.ClearDone += () => clearAfterExecution = true;

            // Add prompt for text editor
            var panel = new Grid();

            resultsPanel.Children.Add(panel);

            promptBlock = new TextBlock();
            promptBlock.HorizontalAlignment = HorizontalAlignment.Left;
            promptBlock.VerticalAlignment   = VerticalAlignment.Top;
            promptBlock.FontFamily          = new FontFamily(fontFamily);
            promptBlock.FontSize            = fontSize;
            promptBlock.Text         = interactiveExecutionInitialization.InteractiveExecutionBehavior.GetReplExecutingPrompt();
            promptBlock.SizeChanged += PromptBlock_SizeChanged;
            panel.Children.Add(promptBlock);

            // Add text editor
            TextEditor = new InteractiveCodeEditor(new InteractiveResultVisualizer(this), interactiveExecutionInitialization.InteractiveExecutionCache, fontFamily, fontSize, indentationSize, highlightingColors);
            TextEditor.HorizontalAlignment           = HorizontalAlignment.Stretch;
            TextEditor.Background                    = Brushes.Transparent;
            TextEditor.CommandExecuted              += TextEditor_CommandExecuted;
            TextEditor.CommandFailed                += TextEditor_CommandFailed;
            TextEditor.Executing                    += TextEditor_Executing;
            TextEditor.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
            TextEditor.VerticalScrollBarVisibility   = ScrollBarVisibility.Hidden;
            TextEditor.TextArea.PreviewKeyDown      += TextEditor_PreviewKeyDown;
            TextEditor.TextArea.SizeChanged         += TextArea_SizeChanged;
            panel.Children.Add(TextEditor);

            Content = scrollViewer;

            // Enable drag and drop
            AllowDrop  = true;
            DragEnter += (s, e) => e.Effects = GetFilename(e) != null ? DragDropEffects.Link : DragDropEffects.None;
            Drop      += (s, e) => FileDropped(GetFilename(e));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="InteractiveWindow"/> class.
        /// </summary>
        public InteractiveWindow()
        {
            // Set window look
            Background = ExecutingBackground;
            ShowInTaskbar = false;
            Title = "C# Interactive Window";

            // Add dock panel and status bar
            DockPanel dockPanel = new DockPanel();
            StatusBar statusBar = new StatusBar();
            statusBarStatusText = new StatusBarItem();
            statusBarStatusText.Content = InitializingStatusText;
            statusBar.Items.Add(statusBarStatusText);
            DockPanel.SetDock(statusBar, Dock.Bottom);
            dockPanel.Children.Add(statusBar);
            Content = dockPanel;

            // Add results panel
            ScrollViewer scrollViewer = new ScrollViewer();
            scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            scrollViewer.Margin = new Thickness(5);
            dockPanel.Children.Add(scrollViewer);
            resultsPanel = new StackPanel();
            resultsPanel.Orientation = Orientation.Vertical;
            resultsPanel.CanVerticallyScroll = true;
            resultsPanel.CanHorizontallyScroll = true;
            scrollViewer.Content = resultsPanel;

            // Add prompt for text editor
            var panel = new DockPanel();
            resultsPanel.Children.Add(panel);

            promptBlock = new TextBlock();
            promptBlock.FontFamily = new FontFamily("Consolas");
            promptBlock.FontSize = 14;
            promptBlock.Text = ExecutingPrompt;
            DockPanel.SetDock(promptBlock, Dock.Left);
            panel.Children.Add(promptBlock);

            // Add text editor
            textEditor = new InteractiveCodeEditor();
            textEditor.Background = Brushes.Transparent;
            textEditor.CommandExecuted += TextEditor_CommandExecuted;
            textEditor.CommandFailed += TextEditor_CommandFailed;
            textEditor.Executing += TextEditor_Executing;
            textEditor.CloseRequested += TextEditor_CloseRequested;
            textEditor.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
            textEditor.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
            textEditor.TextArea.PreviewKeyDown += TextEditor_PreviewKeyDown;
            panel.Children.Add(textEditor);
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InteractiveWindowContent"/> class.
        /// </summary>
        /// <param name="fontFamily">The font family.</param>
        /// <param name="fontSize">Size of the font.</param>
        /// <param name="indentationSize">Size of the indentation.</param>
        /// <param name="highlightingColors">The highlighting colors.</param>
        public InteractiveWindowContent(string fontFamily, double fontSize, int indentationSize, params ICSharpCode.AvalonEdit.Highlighting.HighlightingColor[] highlightingColors)
        {
            this.fontFamily         = fontFamily;
            this.fontSize           = fontSize;
            this.indentationSize    = indentationSize;
            this.highlightingColors = highlightingColors;

            // Add results panel
            scrollViewer = new ScrollViewer();
            scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            scrollViewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            scrollViewer.Margin                = new Thickness(0);
            scrollViewer.Padding               = new Thickness(5);
            resultsPanel                       = new StackPanel();
            resultsPanel.Orientation           = Orientation.Vertical;
            resultsPanel.CanVerticallyScroll   = true;
            resultsPanel.CanHorizontallyScroll = true;
            scrollViewer.Content               = resultsPanel;

            // Add prompt for text editor
            var panel = new Grid();

            resultsPanel.Children.Add(panel);

            promptBlock = new TextBlock();
            promptBlock.HorizontalAlignment = HorizontalAlignment.Left;
            promptBlock.VerticalAlignment   = VerticalAlignment.Top;
            promptBlock.FontFamily          = new FontFamily(fontFamily);
            promptBlock.FontSize            = fontSize;
            promptBlock.Text         = ExecutingPrompt;
            promptBlock.SizeChanged += PromptBlock_SizeChanged;
            panel.Children.Add(promptBlock);

            // Add text editor
            textEditor = new InteractiveCodeEditor(new InteractiveResultVisualizer(this), fontFamily, fontSize, indentationSize, highlightingColors);
            textEditor.HorizontalAlignment           = HorizontalAlignment.Stretch;
            textEditor.Background                    = Brushes.Transparent;
            textEditor.CommandExecuted              += TextEditor_CommandExecuted;
            textEditor.CommandFailed                += TextEditor_CommandFailed;
            textEditor.Executing                    += TextEditor_Executing;
            textEditor.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
            textEditor.VerticalScrollBarVisibility   = ScrollBarVisibility.Hidden;
            textEditor.TextArea.PreviewKeyDown      += TextEditor_PreviewKeyDown;
            textEditor.TextArea.SizeChanged         += TextArea_SizeChanged;
            panel.Children.Add(textEditor);

            Content = scrollViewer;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="VSInteractiveWindowControl"/> class.
        /// </summary>
        public VSInteractiveWindowControl()
        {
            this.InitializeComponent();

            // Set window look
            Background = ExecutingBackground;

            // Add dock panel and status bar
            DockPanel dockPanel = new DockPanel();
            StatusBar statusBar = new StatusBar();
            statusBarStatusText = new StatusBarItem();
            statusBarStatusText.Content = InitializingStatusText;
            statusBar.Items.Add(statusBarStatusText);
            DockPanel.SetDock(statusBar, Dock.Bottom);
            dockPanel.Children.Add(statusBar);
            Content = dockPanel;

            // Add results panel
            ScrollViewer scrollViewer = new ScrollViewer();
            scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            scrollViewer.Margin = new Thickness(5);
            dockPanel.Children.Add(scrollViewer);
            resultsPanel = new StackPanel();
            resultsPanel.Orientation = Orientation.Vertical;
            resultsPanel.CanVerticallyScroll = true;
            resultsPanel.CanHorizontallyScroll = true;
            scrollViewer.Content = resultsPanel;

            // Add prompt for text editor
            var panel = new DockPanel();
            resultsPanel.Children.Add(panel);

            promptBlock = new TextBlock();
            promptBlock.FontFamily = new FontFamily("Consolas");
            promptBlock.FontSize = 14;
            promptBlock.Text = ExecutingPrompt;
            DockPanel.SetDock(promptBlock, Dock.Left);
            panel.Children.Add(promptBlock);

            // Add text editor
            textEditor = new InteractiveCodeEditor();
            textEditor.Background = Brushes.Transparent;
            textEditor.CommandExecuted += TextEditor_CommandExecuted;
            textEditor.CommandFailed += TextEditor_CommandFailed;
            textEditor.Executing += TextEditor_Executing;
            textEditor.CloseRequested += TextEditor_CloseRequested;
            textEditor.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
            textEditor.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
            textEditor.TextArea.PreviewKeyDown += TextEditor_PreviewKeyDown;
            panel.Children.Add(textEditor);

            MakeEnabled(VSContext.CurrentDebugMode == EnvDTE.dbgDebugMode.dbgBreakMode);
            VSContext.DebuggerEnteredBreakMode += () => MakeEnabled(true);
            VSContext.DebuggerEnteredDesignMode += () => MakeEnabled(false);
            VSContext.DebuggerEnteredRunMode += () => MakeEnabled(false);
        }