8 changed files with 236 additions and 5 deletions
@ -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> |
@ -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(); |
||||
} |
||||
} |
||||
} |
@ -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…
Reference in new issue