Browse Source

WatchPad + Console control

pull/2/head
Eusebiu 15 years ago committed by Daniel Grunwald
parent
commit
a351d20664
  1. 11
      src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj
  2. 41
      src/AddIns/Debugger/Debugger.AddIn/Pads/WatchInputBox.xaml
  3. 100
      src/AddIns/Debugger/Debugger.AddIn/Pads/WatchInputBox.xaml.cs
  4. 2
      src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs
  5. 15
      src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPadCommands.cs
  6. 11
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs
  7. 1
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  8. 60
      src/Main/Base/Project/Src/Gui/Pads/BaseWatchBox.cs

11
src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj

@ -79,12 +79,22 @@ @@ -79,12 +79,22 @@
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsFormsIntegration">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsFormsIntegration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Pads\CallStackPad.xaml.cs">
<DependentUpon>CallStackPad.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Pads\WatchInputBox.xaml.cs">
<DependentUpon>WatchInputBox.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="BreakpointChangeMenuBuilder.cs" />
<Compile Include="DisableBreakpointMenuCommand.cs" />
@ -326,6 +336,7 @@ @@ -326,6 +336,7 @@
</ItemGroup>
<ItemGroup>
<Page Include="Pads\CallStackPad.xaml" />
<Page Include="Pads\WatchInputBox.xaml" />
<Page Include="Service\EditBreakpointScriptWindow.xaml" />
<Page Include="Visualizers\Graph\Drawing\NodeControlResources.xaml" />
<Page Include="Visualizers\Graph\Drawing\PositionedGraphNodeControl.xaml" />

41
src/AddIns/Debugger/Debugger.AddIn/Pads/WatchInputBox.xaml

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<src:BaseWatchBox
x:Class="Debugger.AddIn.Pads.WatchInputBox" xmlns:src="clr-namespace:ICSharpCode.SharpDevelop.Gui.Pads;assembly=ICSharpCode.SharpDevelop" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
ShowInTaskbar="False"
WindowStartupLocation="CenterScreen"
WindowState="Normal"
WindowStyle="ToolWindow"
Height="75"
Width="271"
ResizeMode="NoResize"
Background="LightGray">
<Grid
Height="50"
VerticalAlignment="Top">
<Grid.RowDefinitions>
<RowDefinition
Height="23" />
<RowDefinition
Height="24" />
</Grid.RowDefinitions>
<DockPanel
VerticalAlignment="Top"
Name="ConsolePanel" />
<DockPanel
VerticalAlignment="Bottom"
Grid.Row="1"
HorizontalAlignment="Center">
<Button
Name="AcceptButton"
Width="100"
Content="Accept"
Click="AcceptButton_Click"
IsDefault="True" />
<Button
Name="CancelButton"
Width="100"
Content="Cancel"
Click="CancelButton_Click" />
</DockPanel>
</Grid>
</src:BaseWatchBox>

100
src/AddIns/Debugger/Debugger.AddIn/Pads/WatchInputBox.xaml.cs

@ -0,0 +1,100 @@ @@ -0,0 +1,100 @@
using System;
using System.Windows;
using System.Windows.Input;
using ICSharpCode.AvalonEdit;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.SharpDevelop.Gui.Pads;
using ICSharpCode.SharpDevelop.Services;
namespace Debugger.AddIn.Pads
{
/// <summary>
/// Interaction logic for WatchBox.xaml
/// </summary>
public partial class WatchInputBox : BaseWatchBox
{
private NRefactoryResolver resolver;
public WatchInputBox(string text, string caption) : base()
{
InitializeComponent();
// UI
text = StringParser.Parse(text);
this.Title = StringParser.Parse(caption);
AcceptButton.Content = StringParser.Parse("${res:Global.OKButtonText}");
CancelButton.Content = StringParser.Parse("${res:Global.CancelButtonText}");
this.ConsolePanel.Children.Add(console);
// FIXME: for testing only
var language = LanguageProperties.CSharp;
resolver = new NRefactoryResolver(language);
console.SetHighlighting("C#");
// get process
WindowsDebugger debugger = (WindowsDebugger)DebuggerService.CurrentDebugger;
debugger.ProcessSelected += delegate(object sender, ProcessEventArgs e) {
this.Process = e.Process;
};
this.Process = debugger.DebuggedProcess;
}
private Process Process { get; set; }
protected override void AbstractConsolePadTextEntered(object sender, TextCompositionEventArgs e)
{
if (this.Process == null || this.Process.IsRunning)
return;
if (this.Process.SelectedStackFrame == null || this.Process.SelectedStackFrame.NextStatement == null)
return;
foreach (char ch in e.Text) {
if (ch == '.') {
ShowDotCompletion(console.CommandText);
}
}
}
private void ShowDotCompletion(string currentText)
{
var seg = Process.SelectedStackFrame.NextStatement;
var expressionFinder = ParserService.GetExpressionFinder(seg.Filename);
var info = ParserService.GetParseInformation(seg.Filename);
string text = ParserService.GetParseableFileContent(seg.Filename).Text;
int currentOffset = TextEditor.Caret.Offset - console.CommandOffset - 1;
var expr = expressionFinder.FindExpression(currentText, currentOffset);
expr.Region = new DomRegion(seg.StartLine, seg.StartColumn, seg.EndLine, seg.EndColumn);
var rr = resolver.Resolve(expr, info, text);
if (rr != null) {
TextEditor.ShowCompletionWindow(new DotCodeCompletionItemProvider().GenerateCompletionListForResolveResult(rr, expr.Context));
}
}
private void AcceptButton_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
this.Close();
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
DialogResult = false;
this.Close();
}
}
}

2
src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs

@ -3,7 +3,9 @@ @@ -3,7 +3,9 @@
using System;
using System.Collections.Generic;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
using Aga.Controls.Tree;
using Aga.Controls.Tree.NodeControls;

15
src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPadCommands.cs

@ -6,12 +6,13 @@ using System.Collections.Generic; @@ -6,12 +6,13 @@ using System.Collections.Generic;
using System.Windows.Forms;
using Aga.Controls.Tree;
using Debugger.AddIn.Pads;
using Debugger.AddIn.TreeModel;
using ICSharpCode.SharpDevelop;
using ICSharpCode.Core;
using ICSharpCode.Core.Presentation;
using ICSharpCode.Core.WinForms;
using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui.Pads;
namespace Debugger.AddIn
@ -24,9 +25,15 @@ namespace Debugger.AddIn @@ -24,9 +25,15 @@ namespace Debugger.AddIn
WatchPad pad = (WatchPad)this.Owner;
TreeViewAdv ctrl = (TreeViewAdv)pad.Control;
string input = MessageService.ShowInputBox(StringParser.Parse("${res:MainWindow.Windows.Debug.Watch.AddWatch}"),
StringParser.Parse("${res:MainWindow.Windows.Debug.Watch.EnterExpression}"),
"");
var inputWindow = new WatchInputBox(StringParser.Parse("${res:MainWindow.Windows.Debug.Watch.AddWatch}"),
StringParser.Parse("${res:MainWindow.Windows.Debug.Watch.EnterExpression}"));
var result = inputWindow.ShowDialog();
if (!result.HasValue || !result.Value)
return;
string input = inputWindow.CommandText;
if (!string.IsNullOrEmpty(input)) {
ctrl.BeginUpdate();
TextNode text = new TextNode(input, SupportedLanguage.CSharp);

11
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs

@ -1051,5 +1051,14 @@ namespace ICSharpCode.AvalonEdit @@ -1051,5 +1051,14 @@ namespace ICSharpCode.AvalonEdit
}
}
}
/// <summary>
/// Hides the scroll viewer.
/// </summary>
public void HideScrollBar()
{
scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
}
}
}
}

1
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -256,6 +256,7 @@ @@ -256,6 +256,7 @@
</Compile>
<Compile Include="Src\Gui\IImage.cs" />
<Compile Include="Src\Gui\Pads\AbstractConsolePad.cs" />
<Compile Include="Src\Gui\Pads\BaseWatchBox.cs" />
<Compile Include="Src\Gui\Pads\OutlinePad.cs" />
<Compile Include="Src\Gui\Pads\ProjectBrowser\TreeNodes\DirectoryNodeFactory.cs" />
<Compile Include="Src\Gui\Pads\TaskList\TaskListPadCommands.cs" />

60
src/Main/Base/Project/Src/Gui/Pads/BaseWatchBox.cs

@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.AvalonEdit;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.SharpDevelop.Gui.Pads
{
/// <summary>
/// Interaction logic for AbstractWatchBox.xaml
/// </summary>
public class BaseWatchBox : Window
{
protected ConsoleControl console;
public BaseWatchBox()
{
console = new ConsoleControl();
this.console.editor.TextArea.TextEntered += new TextCompositionEventHandler(AbstractConsolePadTextEntered);
this.console.editor.TextArea.PreviewKeyDown += (sender, e) => {
e.Handled = e.Key == Key.Return;
if (e.Handled) {
DialogResult = true;
this.Close();
}
};
// hide scroll bar
this.console.editor.ApplyTemplate();
this.console.editor.HideScrollBar();
this.console.editor.TextArea.Focus();
}
protected virtual void AbstractConsolePadTextEntered(object sender, TextCompositionEventArgs e)
{
}
protected ITextEditor TextEditor {
get {
return console.TextEditor;
}
}
/// <summary>
/// Gets/sets the command text displayed at the command prompt.
/// </summary>
public string CommandText {
get { return TextEditor.Document.Text; }
}
}
}
Loading…
Cancel
Save