Browse Source

Edit Pin control v0.1

pull/11/head
eusebiu 15 years ago
parent
commit
af9798ef45
  1. 3
      data/resources/StringResources.resx
  2. 2
      data/resources/image/BitmapResources/BitmapResources.res
  3. BIN
      data/resources/image/BitmapResources/Bookmarks/Pin.png
  4. 4
      src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPadModel.cs
  5. 76
      src/AddIns/Debugger/Debugger.AddIn/TreeModel/ExpressionNode.cs
  6. 13
      src/AddIns/Debugger/Debugger.AddIn/TreeModel/TreeNode.cs
  7. 6
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs
  8. 6
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  9. 31
      src/Main/Base/Project/Src/Bookmarks/BookmarkConverter.cs
  10. 6
      src/Main/Base/Project/Src/Editor/ITooltip.cs
  11. 8
      src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerPopup.cs
  12. 72
      src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerTooltipControl.xaml
  13. 209
      src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerTooltipControl.xaml.cs
  14. 4
      src/Main/Base/Project/Src/Services/Debugger/Tooltips/ITreeNode.cs
  15. 57
      src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinBookmark.cs
  16. 29
      src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinCloseControl.xaml
  17. 89
      src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinCloseControl.xaml.cs
  18. 151
      src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinControlsDictionary.xaml
  19. BIN
      src/Main/StartUp/Project/Resources/BitmapResources.resources

3
data/resources/StringResources.resx

@ -4500,6 +4500,9 @@ has been changed externally do you want to reload it?</value> @@ -4500,6 +4500,9 @@ has been changed externally do you want to reload it?</value>
<data name="ICSharpCode.SharpDevelop.ExceptionBox.Title" xml:space="preserve">
<value>Unhandled exception has occured</value>
</data>
<data name="ICSharpCode.SharpDevelop.Debugging.SavedString" xml:space="preserve">
<value>Saved</value>
</data>
<data name="ICSharpCode.SharpDevelop.FormDesigner.CantDeserializeFormError" xml:space="preserve">
<value>Can't deserialize form. Possible reason: Initialize component method was changed manually.</value>
</data>

2
data/resources/image/BitmapResources/BitmapResources.res

@ -343,6 +343,8 @@ Bookmarks.UnhealthyBreakpoint = Bookmarks\UnhealthyBreakpoin @@ -343,6 +343,8 @@ Bookmarks.UnhealthyBreakpoint = Bookmarks\UnhealthyBreakpoin
Bookmarks.UnhealthyBreakpointConditional = Bookmarks\UnhealthyBreakpointConditional.png
Bookmarks.CurrentLine = Bookmarks\CurrentLine.png
Bookmarks.Pin = Bookmarks\Pin.png
#backend icons
C#.ProjectIcon = backendicons\CSharp\SmallProject.png
C#.FileIcon = backendicons\CSharp\SmallFile.png

BIN
data/resources/image/BitmapResources/Bookmarks/Pin.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

4
src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPadModel.cs

@ -19,13 +19,13 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -19,13 +19,13 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
this.Language = language;
}
public bool CanSetText {
public new bool CanSetText {
get {
return true;
}
}
public bool SetText(string text)
public new bool SetText(string text)
{
this.Text = text;
return true;

76
src/AddIns/Debugger/Debugger.AddIn/TreeModel/ExpressionNode.cs

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.Reflection;
@ -26,7 +27,7 @@ namespace Debugger.AddIn.TreeModel @@ -26,7 +27,7 @@ namespace Debugger.AddIn.TreeModel
/// Node in the tree which can be defined by a debugger expression.
/// The expression will be lazily evaluated when needed.
/// </summary>
public class ExpressionNode: TreeNode, ISetText, IContextMenu
public class ExpressionNode: TreeNode, ISetText, INotifyPropertyChanged
{
bool evaluated;
@ -36,11 +37,16 @@ namespace Debugger.AddIn.TreeModel @@ -36,11 +37,16 @@ namespace Debugger.AddIn.TreeModel
string fullText;
public bool Evaluated {
get { return evaluated; }
set { evaluated = value; }
}
public Expression Expression {
get { return expression; }
}
public bool CanSetText {
public override bool CanSetText {
get {
if (!evaluated) EvaluateExpression();
return canSetText;
@ -54,11 +60,21 @@ namespace Debugger.AddIn.TreeModel @@ -54,11 +60,21 @@ namespace Debugger.AddIn.TreeModel
}
}
public string FullText {
get { return fullText; }
}
public override string Text {
get {
if (!evaluated) EvaluateExpression();
return base.Text;
}
set {
if (value != base.Text) {
base.Text = value;
NotifyPropertyChanged("Text");
}
}
}
public override string Type {
@ -80,7 +96,7 @@ namespace Debugger.AddIn.TreeModel @@ -80,7 +96,7 @@ namespace Debugger.AddIn.TreeModel
if (!evaluated) EvaluateExpression();
return base.HasChildNodes;
}
}
}
/// <summary> Used to determine available VisualizerCommands </summary>
private DebugType expressionType;
@ -269,7 +285,7 @@ namespace Debugger.AddIn.TreeModel @@ -269,7 +285,7 @@ namespace Debugger.AddIn.TreeModel
return size >= 7 && runs <= (size + 7) / 8;
}
public bool SetText(string newText)
public override bool SetText(string newText)
{
Value val = null;
try {
@ -343,19 +359,19 @@ namespace Debugger.AddIn.TreeModel @@ -343,19 +359,19 @@ namespace Debugger.AddIn.TreeModel
return DebuggerResourceService.GetImage("Icons.16x16." + name);
}
public ContextMenuStrip GetContextMenu()
{
if (this.Error != null) return GetErrorContextMenu();
ContextMenuStrip menu = new ContextMenuStrip();
ToolStripMenuItem copyItem;
copyItem = new ToolStripMenuItem();
copyItem.Text = ResourceService.GetString("MainWindow.Windows.Debug.LocalVariables.CopyToClipboard");
copyItem.Checked = false;
copyItem.Click += delegate {
ClipboardWrapper.SetText(fullText);
};
// public ContextMenuStrip GetContextMenu()
// {
// if (this.Error != null) return GetErrorContextMenu();
//
// ContextMenuStrip menu = new ContextMenuStrip();
//
// ToolStripMenuItem copyItem;
// copyItem = new ToolStripMenuItem();
// copyItem.Text = ResourceService.GetString("MainWindow.Windows.Debug.LocalVariables.CopyToClipboard");
// copyItem.Checked = false;
// copyItem.Click += delegate {
// ClipboardWrapper.SetText(fullText);
// };
// ToolStripMenuItem hexView;
// hexView = new ToolStripMenuItem();
@ -371,13 +387,13 @@ namespace Debugger.AddIn.TreeModel @@ -371,13 +387,13 @@ namespace Debugger.AddIn.TreeModel
// WatchPad.Instance.RefreshPad();
// };
menu.Items.AddRange(new ToolStripItem[] {
copyItem,
//hexView
});
return menu;
}
// menu.Items.AddRange(new ToolStripItem[] {
// copyItem,
// //hexView
// });
//
// return menu;
// }
public ContextMenuStrip GetErrorContextMenu()
{
@ -403,5 +419,15 @@ namespace Debugger.AddIn.TreeModel @@ -403,5 +419,15 @@ namespace Debugger.AddIn.TreeModel
return (WindowsDebugger)DebuggerService.CurrentDebugger;
}
}
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(info));
}
}
}
}
}

13
src/AddIns/Debugger/Debugger.AddIn/TreeModel/TreeNode.cs

@ -3,9 +3,10 @@ @@ -3,9 +3,10 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Media;
using System.Linq;
using System.Windows.Media;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Debugging;
@ -58,7 +59,7 @@ namespace Debugger.AddIn.TreeModel @@ -58,7 +59,7 @@ namespace Debugger.AddIn.TreeModel
public virtual string Text
{
get { return text; }
protected set { text = value; }
set { text = value; }
}
public virtual string Type {
@ -79,6 +80,10 @@ namespace Debugger.AddIn.TreeModel @@ -79,6 +80,10 @@ namespace Debugger.AddIn.TreeModel
get { return childNodes != null; }
}
public virtual bool CanSetText {
get { return false; }
}
public virtual IEnumerable<IVisualizerCommand> VisualizerCommands {
get {
return null;
@ -108,5 +113,9 @@ namespace Debugger.AddIn.TreeModel @@ -108,5 +113,9 @@ namespace Debugger.AddIn.TreeModel
{
return this.Name.CompareTo(other.Name);
}
public virtual bool SetText(string newValue) {
return false;
}
}
}

6
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs

@ -13,6 +13,8 @@ using System.Windows.Controls; @@ -13,6 +13,8 @@ using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.AvalonEdit.AddIn.Options;
using ICSharpCode.AvalonEdit.AddIn.Snippets;
using ICSharpCode.AvalonEdit.Editing;
@ -234,6 +236,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -234,6 +236,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (!(args.ContentToShow is UIElement)) {
throw new NotSupportedException("Content to show in Popup must be UIElement: " + args.ContentToShow);
}
contentToShowITooltip.LogicalPosition = args.LogicalPosition;
if (popup == null) {
popup = CreatePopup();
}
@ -321,6 +324,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -321,6 +324,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
{
popup = new Popup();
popup.Closed += PopupClosed;
popup.AllowsTransparency = true;
popup.PlacementTarget = this; // required for property inheritance
popup.Placement = PlacementMode.Absolute;
popup.StaysOpen = true;
@ -499,4 +503,4 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -499,4 +503,4 @@ namespace ICSharpCode.AvalonEdit.AddIn
}
}
}
}
}

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

@ -317,6 +317,10 @@ @@ -317,6 +317,10 @@
<Compile Include="Src\Services\Debugger\Tooltips\ITreeNode.cs" />
<Compile Include="Src\Services\Debugger\Tooltips\IVisualizerCommand.cs" />
<Compile Include="Src\Services\Debugger\Tooltips\LazyItemsControl.cs" />
<Compile Include="Src\Services\Debugger\Tooltips\PinBookmark.cs" />
<Compile Include="Src\Services\Debugger\Tooltips\PinCloseControl.xaml.cs">
<DependentUpon>PinCloseControl.xaml</DependentUpon>
</Compile>
<Compile Include="Src\Services\Debugger\Tooltips\VirtualizingIEnumerable.cs" />
<Compile Include="Src\Services\Debugger\Tooltips\VisualizerPicker.cs" />
<Compile Include="Src\Services\DisplayBinding\ExternalProcessDisplayBinding.cs" />
@ -817,6 +821,8 @@ @@ -817,6 +821,8 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Page Include="Src\Services\Debugger\Tooltips\PinCloseControl.xaml" />
<Page Include="Src\Services\Debugger\Tooltips\PinControlsDictionary.xaml" />
<Page Include="Src\Services\RefactoringService\ContextActions\ContextActionsBulbControl.xaml" />
<Page Include="Src\Services\RefactoringService\ContextActions\ContextActionsControl.xaml" />
<Page Include="Src\Services\RefactoringService\ContextActions\ContextActionsHeaderedControl.xaml" />

31
src/Main/Base/Project/Src/Bookmarks/BookmarkConverter.cs

@ -1,12 +1,14 @@ @@ -1,12 +1,14 @@
// 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 ICSharpCode.NRefactory;
using System;
using System.ComponentModel;
using System.Globalization;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.NRefactory;
using Services.Debugger.Tooltips;
namespace ICSharpCode.SharpDevelop.Bookmarks
{
@ -25,8 +27,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -25,8 +27,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
{
if (value is string) {
string[] v = ((string)value).Split('|');
if (v.Length != 8)
return null;
FileName fileName = FileName.Create(v[1]);
int lineNumber = int.Parse(v[2], culture);
int columnNumber = int.Parse(v[3], culture);
@ -49,6 +50,14 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -49,6 +50,14 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
bbm.IsEnabled = bool.Parse(v[4]);
bookmark = bbm;
break;
case "PinBookmark":
var pin = new PinBookmark(fileName, new Location(columnNumber, lineNumber));
for (int i = 4; i < v.Length; i+=2) {
pin.SavedNodes.Add(new Tuple<string, string>(v[i], v[i+1]));
}
bookmark = pin;
break;
default:
bookmark = new SDBookmark(fileName, new Location(columnNumber, lineNumber));
break;
@ -67,7 +76,10 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -67,7 +76,10 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
if (bookmark is Debugging.BreakpointBookmark) {
b.Append("Breakpoint");
} else {
b.Append("Bookmark");
if (bookmark is PinBookmark)
b.Append("PinBookmark");
else
b.Append("Bookmark");
}
b.Append('|');
b.Append(bookmark.FileName);
@ -75,6 +87,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -75,6 +87,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
b.Append(bookmark.LineNumber);
b.Append('|');
b.Append(bookmark.ColumnNumber);
if (bookmark is Debugging.BreakpointBookmark) {
Debugging.BreakpointBookmark bbm = (Debugging.BreakpointBookmark)bookmark;
b.Append('|');
@ -86,6 +99,16 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -86,6 +99,16 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
b.Append('|');
b.Append(bbm.Condition);
}
if (bookmark is PinBookmark) {
var pin = (PinBookmark)bookmark;
b.Append(pin.Comment);
foreach(var node in pin.Nodes) {
b.Append(node.Name);
b.Append('|');
b.Append(node.Text);
}
}
return b.ToString();
} else {
return base.ConvertTo(context, culture, value, destinationType);

6
src/Main/Base/Project/Src/Editor/ITooltip.cs

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using System;
using System.Windows;
using ICSharpCode.NRefactory;
namespace ICSharpCode.SharpDevelop.Editor
{
@ -12,6 +13,11 @@ namespace ICSharpCode.SharpDevelop.Editor @@ -12,6 +13,11 @@ namespace ICSharpCode.SharpDevelop.Editor
/// </summary>
public interface ITooltip
{
/// <summary>
/// Gets or sets the logical location within the document.
/// </summary>
Location LogicalPosition { get; set; }
/// <summary>
/// If true, this ITooltip will be displayed in a WPF Popup.
/// Otherwise it will be displayed in a WPF Tooltip.

8
src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerPopup.cs

@ -17,11 +17,11 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -17,11 +17,11 @@ namespace ICSharpCode.SharpDevelop.Debugging
/// </summary>
public class DebuggerPopup : Popup
{
private DebuggerTooltipControl contentControl;
internal DebuggerTooltipControl contentControl;
public DebuggerPopup(DebuggerTooltipControl parentControl)
public DebuggerPopup(DebuggerTooltipControl parentControl, bool showPinControl)
{
this.contentControl = new DebuggerTooltipControl(parentControl);
this.contentControl = new DebuggerTooltipControl(parentControl, showPinControl);
this.contentControl.containingPopup = this;
this.Child = this.contentControl;
this.IsLeaf = false;
@ -30,7 +30,7 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -30,7 +30,7 @@ namespace ICSharpCode.SharpDevelop.Debugging
//this.contentControl.Focusable = true;
//Keyboard.Focus(this.contentControl);
//this.AllowsTransparency = true;
this.AllowsTransparency = true;
//this.PopupAnimation = PopupAnimation.Slide;
}

72
src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerTooltipControl.xaml

@ -3,13 +3,17 @@ @@ -3,13 +3,17 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:aero="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
xmlns:debugging="clr-namespace:ICSharpCode.SharpDevelop.Debugging"
xmlns:core="http://icsharpcode.net/sharpdevelop/core"
xmlns:localControls="clr-namespace:Services.Debugger.Tooltips"
Background="Transparent"
>
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="VisualizerPicker.xaml" />
<ResourceDictionary Source="PinControlsDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
<!-- TODO move styles to ResourceDictionary -->
<Style x:Key="ExpandCollapseToggleStyle"
TargetType="{x:Type ToggleButton}">
@ -95,8 +99,36 @@ @@ -95,8 +99,36 @@
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type TextBox}" x:Key="TextStyle">
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBoxBase}">
<Border
Name="Border"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="0">
<ScrollViewer Margin="0" Name="PART_ContentHost" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</UserControl.Resources>
<Grid Background="Transparent" Name="ParentGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical">
<RepeatButton Name="btnUp" Focusable="False" Style="{StaticResource upButtonStyle}" Content="^" Click="BtnUp_Click"></RepeatButton>
<DataGrid VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Disabled"
@ -194,12 +226,48 @@ @@ -194,12 +226,48 @@
<DataGridTemplateColumn MinWidth="20" Header="Text"> <!-- Text (value) -->
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Margin="4 0" Text="{Binding Path=Text, Mode=OneWay}" VerticalAlignment="Top"></TextBlock>
<TextBox
Style="{StaticResource TextStyle}"
IsEnabled="{Binding CanSetText}"
KeyUp="TextBox_KeyUp"
LostFocus="TextBox_LostFocus"
Margin="4 0"
Text="{Binding Path=Text, Mode=OneWay}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn> <!-- Pin -->
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ToggleButton
DataContext="{Binding}"
Visibility="Collapsed"
Name="PinButton"
VerticalAlignment="Center"
Checked="PinButton_Checked"
Unchecked="PinButton_Unchecked"
Template="{StaticResource PinTooltipButtonTemplate}"/>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGridRow}}" Value="True">
<Setter TargetName="PinButton" Property="Visibility" Value="Visible"/>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<RepeatButton Name="btnDown" Focusable="False" Style="{StaticResource downButtonStyle}" Content="v" Click="BtnDown_Click"></RepeatButton>
<!-- commentTextbox -->
<Border Name="BorderComment" Background="White" BorderThickness="1,0,1,1" BorderBrush="Black" Height="0" MaxHeight="50">
<TextBox Name="CommentTextBox" Margin="3" Height="34"/>
</Border>
</StackPanel>
<Canvas MinWidth="25" Background="Transparent" Grid.Column="1" Name="PinControlCanvas" Visibility="Collapsed">
<!-- Pin close control -->
</Canvas>
</Grid>
</UserControl>

209
src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerTooltipControl.xaml.cs

@ -3,15 +3,22 @@ @@ -3,15 +3,22 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ICSharpCode.Core;
using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
using Services.Debugger.Tooltips;
namespace ICSharpCode.SharpDevelop.Debugging
{
@ -24,10 +31,28 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -24,10 +31,28 @@ namespace ICSharpCode.SharpDevelop.Debugging
private readonly double ChildPopupOpenYOffet = 15;
private readonly int InitialItemsCount = 12;
private readonly int VisibleItemsCount = 11;
bool showPinControl;
PinCloseControl pinCloseControl;
public DebuggerTooltipControl()
public DebuggerTooltipControl(bool showPinControl = false)
{
InitializeComponent();
this.showPinControl = showPinControl;
// show pin close control
if (this.showPinControl) {
dataGrid.Columns[5].Visibility = Visibility.Collapsed;
pinCloseControl = new PinCloseControl(this);
pinCloseControl.Visibility = Visibility.Visible;
PinControlCanvas.Visibility = Visibility.Visible;
PinControlCanvas.Children.Add(pinCloseControl);
}
else {
PinControlCanvas.Visibility = Visibility.Collapsed;
}
}
public DebuggerTooltipControl(ITreeNode node)
@ -41,8 +66,8 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -41,8 +66,8 @@ namespace ICSharpCode.SharpDevelop.Debugging
this.ItemsSource = nodes;
}
public DebuggerTooltipControl(DebuggerTooltipControl parentControl)
: this()
public DebuggerTooltipControl(DebuggerTooltipControl parentControl, bool showPinControl = false)
: this(showPinControl)
{
this.parentControl = parentControl;
}
@ -74,7 +99,6 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -74,7 +99,6 @@ namespace ICSharpCode.SharpDevelop.Debugging
this.lazyGrid.ItemsSourceTotalCount.Value <= VisibleItemsCount ? Visibility.Collapsed : Visibility.Visible;
}
}
}
/// <inheritdoc/>
@ -85,7 +109,17 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -85,7 +109,17 @@ namespace ICSharpCode.SharpDevelop.Debugging
return true;
}
}
public string Comment {
get { return CommentTextBox.Text; }
set { CommentTextBox.Text = value; }
}
/// <summary>
/// Position within the document
/// </summary>
public Location LogicalPosition { get; set; }
/// <inheritdoc/>
public bool Close(bool mouseClick)
{
@ -161,7 +195,7 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -161,7 +195,7 @@ namespace ICSharpCode.SharpDevelop.Debugging
// open child Popup
if (this.childPopup == null) {
this.childPopup = new DebuggerPopup(this);
this.childPopup = new DebuggerPopup(this, showPinControl);
this.childPopup.Placement = PlacementMode.Absolute;
}
if (this.containingPopup != null) {
@ -192,5 +226,164 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -192,5 +226,164 @@ namespace ICSharpCode.SharpDevelop.Debugging
{
this.lazyGrid.ScrollViewer.ScrollDown(1);
}
void TextBox_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape) {
dataGrid.Focus();
return;
}
if (e.Key == Key.Enter) {
dataGrid.Focus();
// set new value
var textBox = (TextBox)sender;
var newValue = textBox.Text;
var node = ((FrameworkElement)sender).DataContext as ITreeNode;
SaveNewValue(node, textBox.Text);
}
}
void TextBox_LostFocus(object sender, RoutedEventArgs e)
{
// set new value
var textBox = (TextBox)sender;
var node = ((FrameworkElement)sender).DataContext as ITreeNode;
SaveNewValue(node, textBox.Text);
}
void SaveNewValue(ITreeNode node, string newValue)
{
if(node != null && node.SetText(newValue)) {
// show adorner
var adornerLayer = AdornerLayer.GetAdornerLayer(dataGrid);
var adorners = adornerLayer.GetAdorners(dataGrid);
if (adorners != null && adorners.Length != 0)
adornerLayer.Remove(adorners[0]);
SavedAdorner adorner = new SavedAdorner(dataGrid);
adornerLayer.Add(adorner);
}
}
void PinButton_Checked(object sender, RoutedEventArgs e)
{
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveContent as ITextEditorProvider;
ToggleButton button = (ToggleButton)sender;
if (provider != null) {
ITextEditor editor = provider.TextEditor;
if (!string.IsNullOrEmpty(editor.FileName)) {
var pin = new PinBookmark(editor.FileName, LogicalPosition);
if (!BookmarkManager.Bookmarks.Contains(pin)) {
// show pinned DebuggerPopup
if (pin.Popup == null) {
pin.Popup = new DebuggerPopup(this, true);
pin.Popup.Placement = PlacementMode.Absolute;
Rect rect = new Rect(this.DesiredSize);
var point = this.PointToScreen(rect.TopRight);
pin.Popup.HorizontalOffset = point.X + 150;
pin.Popup.VerticalOffset = point.Y - 20;
pin.Popup.Open();
}
pin.Nodes.Add(button.DataContext as ITreeNode);
BookmarkManager.ToggleBookmark(
editor,
LogicalPosition.Line,
b => b.CanToggle && b is PinBookmark,
location => pin);
}
else
{
pin.Nodes.Add(button.DataContext as ITreeNode);
}
}
}
}
void PinButton_Unchecked(object sender, RoutedEventArgs e)
{
if (!showPinControl)
return;
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveContent as ITextEditorProvider;
if (provider != null) {
ITextEditor editor = provider.TextEditor;
if (!string.IsNullOrEmpty(editor.FileName)) {
// remove from pinned DebuggerPopup
var pin = new PinBookmark(editor.FileName, LogicalPosition);
if (!BookmarkManager.Bookmarks.Contains(pin))
return;
ToggleButton button = (ToggleButton)sender;
pin.Nodes.Remove(button.DataContext as ITreeNode);
}
}
}
public void ShowComment(bool show)
{
if(show && BorderComment.Height != 0)
return;
if(!show && BorderComment.Height != 40)
return;
DoubleAnimation animation = new DoubleAnimation();
animation.From = show ? 0 : 40;
animation.To = show ? 40 : 0;
animation.Duration = new Duration(TimeSpan.FromMilliseconds(300));
animation.SetValue(Storyboard.TargetProperty, BorderComment);
animation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Border.HeightProperty));
Storyboard board = new Storyboard();
board.Children.Add(animation);
board.Begin(this);
}
class SavedAdorner : Adorner
{
public SavedAdorner(UIElement adornedElement) : base(adornedElement)
{
Loaded += delegate { Show(); };
}
protected override void OnRender(DrawingContext drawingContext)
{
Rect adornedElementRect = new Rect(this.AdornedElement.DesiredSize);
// Some arbitrary drawing implements.
var formatedText = new FormattedText(StringParser.Parse("${res:ICSharpCode.SharpDevelop.Debugging.SavedString}"),
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
new Typeface(new FontFamily("Arial"),
FontStyles.Normal,
FontWeights.Black,
FontStretches.Expanded),
8d,
Brushes.Black);
drawingContext.DrawText(formatedText,
new Point(adornedElementRect.TopRight.X - formatedText.Width - 2,
adornedElementRect.TopRight.Y));
}
private void Show()
{
DoubleAnimation animation = new DoubleAnimation();
animation.From = 1;
animation.To = 0;
animation.Duration = new Duration(TimeSpan.FromSeconds(2));
animation.SetValue(Storyboard.TargetProperty, this);
animation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Rectangle.OpacityProperty));
Storyboard board = new Storyboard();
board.Children.Add(animation);
board.Begin(this);
}
}
}
}
}

4
src/Main/Base/Project/Src/Services/Debugger/Tooltips/ITreeNode.cs

@ -16,6 +16,8 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -16,6 +16,8 @@ namespace ICSharpCode.SharpDevelop.Debugging
string Text { get; }
bool CanSetText { get; }
string Type { get; }
ImageSource ImageSource { get; }
@ -27,5 +29,7 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -27,5 +29,7 @@ namespace ICSharpCode.SharpDevelop.Debugging
IEnumerable<IVisualizerCommand> VisualizerCommands { get; }
bool HasVisualizerCommands { get; }
bool SetText(string newValue);
}
}

57
src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinBookmark.cs

@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
// 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.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using ICSharpCode.Core;
using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Editor;
namespace Services.Debugger.Tooltips
{
public class PinBookmark : SDBookmark
{
string tooltip;
public DebuggerPopup Popup { get; set; }
public static readonly IImage PinImage = new ResourceServiceImage("Bookmarks.Pin");
public PinBookmark(FileName fileName, Location location) : base(fileName, location)
{
Nodes = new ObservableCollection<ITreeNode>();
Nodes.CollectionChanged += new NotifyCollectionChangedEventHandler(Nodes_CollectionChanged);
IsVisibleInBookmarkPad = false;
}
void Nodes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add ||
e.Action == NotifyCollectionChangedAction.Remove)
Popup.contentControl.ItemsSource = Nodes;
}
public ObservableCollection<ITreeNode> Nodes { get; set; }
public List<Tuple<string, string>> SavedNodes { get; set; }
public string Comment { get; set; }
public override IImage Image {
get {
return PinImage;
}
}
public string Tooltip {
get { return tooltip; }
set { tooltip = value; }
}
}
}

29
src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinCloseControl.xaml

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<UserControl
Background="Transparent"
x:Class="Services.Debugger.Tooltips.PinCloseControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="PinControlsDictionary.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<StackPanel>
<Button
Name="CloseButton"
Click="CloseButton_Click"
Template="{StaticResource CloseButtonTemplate}" />
<ToggleButton
Name="UnpinButton"
Checked="UnpinButton_Checked"
Unchecked="UnpinButton_Unchecked"
Template="{StaticResource PinButtonTemplate}" />
<ToggleButton
Name="CommentButton"
Checked="CommentButton_Checked"
Unchecked="CommentButton_Unchecked"
Template="{StaticResource CommentButtonTemplate}" />
</StackPanel>
</UserControl>

89
src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinCloseControl.xaml.cs

@ -0,0 +1,89 @@ @@ -0,0 +1,89 @@
// 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.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
namespace Services.Debugger.Tooltips
{
/// <summary>
/// Interaction logic for PinCloseControl.xaml
/// </summary>
public partial class PinCloseControl : UserControl
{
readonly DebuggerTooltipControl toolTipControl;
public PinCloseControl(DebuggerTooltipControl parent)
{
Margin = new Thickness(5, 0, 0, 0);
InitializeComponent();
this.toolTipControl = parent;
}
void Unpin()
{
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveContent as ITextEditorProvider;
if (provider != null) {
ITextEditor editor = provider.TextEditor;
if (!string.IsNullOrEmpty(editor.FileName)) {
var pin = new PinBookmark(editor.FileName, toolTipControl.LogicalPosition);
BookmarkManager.RemoveMark(pin);
}
}
}
void CloseButton_Click(object sender, RoutedEventArgs e)
{
Unpin();
toolTipControl.containingPopup.CloseSelfAndChildren();
}
void CommentButton_Checked(object sender, RoutedEventArgs e)
{
toolTipControl.ShowComment(true);
}
void CommentButton_Unchecked(object sender, RoutedEventArgs e)
{
toolTipControl.ShowComment(false);
}
void UnpinButton_Checked(object sender, RoutedEventArgs e)
{
Unpin();
}
void UnpinButton_Unchecked(object sender, RoutedEventArgs e)
{
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveContent as ITextEditorProvider;
if (provider != null) {
ITextEditor editor = provider.TextEditor;
if (!string.IsNullOrEmpty(editor.FileName)) {
var pin = new PinBookmark(editor.FileName, toolTipControl.LogicalPosition);
BookmarkManager.ToggleBookmark(
editor,
toolTipControl.LogicalPosition.Line,
b => b.CanToggle && b is PinBookmark,
location => pin);
}
}
}
}
}

151
src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinControlsDictionary.xaml

@ -0,0 +1,151 @@ @@ -0,0 +1,151 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<LinearGradientBrush x:Key="OrangeBrushKey" EndPoint="0,1" StartPoint="0,0">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0" Color="White" />
<GradientStop Offset="0.5" Color="Orange" />
<GradientStop Offset="1" Color="Orange" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="OrangePressedBrushKey" EndPoint="0,1" StartPoint="0,0">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="1" Color="White" />
<GradientStop Offset="0.5" Color="Orange" />
<GradientStop Offset="0" Color="Orange" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="SilverBrushKey" EndPoint="0,1" StartPoint="0,0">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0" Color="White" />
<GradientStop Offset="0.5" Color="LightGray" />
<GradientStop Offset="1" Color="LightGray" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="SilverPressedBrushKey" EndPoint="0,1" StartPoint="0,0">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="1" Color="White" />
<GradientStop Offset="0.5" Color="LightGray" />
<GradientStop Offset="0" Color="LightGray" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<ControlTemplate x:Key="CloseButtonTemplate" TargetType="Button">
<Border Width="16" Height="16" Name="TheBorder" CornerRadius="2,2,0,0" BorderThickness="1" BorderBrush="Black" Background="{StaticResource SilverPressedBrushKey}">
<Canvas>
<Line X1="3" X2="11" Y1="3" Y2="11" Stroke="Black" StrokeThickness="2"/>
<Line X1="3" X2="11" Y1="11" Y2="3" Stroke="Black" StrokeThickness="2"/>
</Canvas>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="true">
<Setter TargetName="TheBorder" Property="Background" Value="{StaticResource OrangeBrushKey}"/>
<Setter TargetName="TheBorder" Property="BorderBrush" Value="Silver"/>
</Trigger>
<Trigger Property="ButtonBase.IsPressed" Value="True">
<Setter TargetName="TheBorder" Property="Background" Value="{StaticResource OrangePressedBrushKey}"/>
<Setter TargetName="TheBorder" Property="BorderBrush" Value="Silver"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<TransformGroup x:Key="Rotate">
<RotateTransform Angle="270" CenterX="7" CenterY="7"/>
</TransformGroup>
<TransformGroup x:Key="RotateUnpin">
<RotateTransform Angle="270" CenterX="7" CenterY="7"/>
<RotateTransform Angle="-90" CenterX="7" CenterY="7"/>
<ScaleTransform ScaleY="-1" CenterX="7" CenterY="7"/>
</TransformGroup>
<TransformGroup x:Key="RotatePin">
<RotateTransform Angle="-90" CenterX="7" CenterY="7"/>
</TransformGroup>
<TransformGroup x:Key="FlipComment">
<ScaleTransform CenterX="7" CenterY="7" ScaleY="-1"/>
</TransformGroup>
<ControlTemplate x:Key="PinButtonTemplate" TargetType="ToggleButton">
<Border Width="16" Height="16" Name="TheBorder" CornerRadius="0" BorderThickness="1" BorderBrush="Black" Background="{StaticResource SilverPressedBrushKey}">
<Canvas Name="TheCanvas">
<Line X1="4" X2="10" Y1="2" Y2="2" Stroke="Black" StrokeThickness="1"/>
<Line X1="10" X2="10" Y1="3" Y2="9" Stroke="Black" StrokeThickness="1"/>
<Line X1="2" X2="12" Y1="9" Y2="9" Stroke="Black" StrokeThickness="1"/>
<Rectangle Fill="Black" Width="3" Height="6" Canvas.Left="3" Canvas.Top="3"/>
<Line X1="7" X2="7" Y1="10" Y2="13" Stroke="Black" StrokeThickness="1"/>
</Canvas>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="true">
<Setter TargetName="TheBorder" Property="Background" Value="{StaticResource OrangeBrushKey}"/>
<Setter TargetName="TheBorder" Property="BorderBrush" Value="Silver"/>
</Trigger>
<Trigger Property="ButtonBase.IsPressed" Value="True">
<Setter TargetName="TheCanvas" Property="RenderTransform" Value="{StaticResource RotatePin}"/>
<Setter TargetName="TheBorder" Property="Background" Value="{StaticResource OrangePressedBrushKey}"/>
<Setter TargetName="TheBorder" Property="BorderBrush" Value="Silver"/>
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="TheCanvas" Property="RenderTransform" Value="{StaticResource RotatePin}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="CommentButtonTemplate" TargetType="ToggleButton">
<Border Width="16" Height="16" Name="TheBorder" CornerRadius="0,0,2,2" BorderThickness="1" BorderBrush="Black" Background="{StaticResource SilverPressedBrushKey}">
<Canvas Name="TheCanvas">
<Line X1="2" Y1="3" X2="8" Y2="7" Stroke="Black" StrokeThickness="2"/>
<Line X1="7" Y1="6" X2="12" Y2="3" Stroke="Black" StrokeThickness="2"/>
<Line X1="2" Y1="8" X2="8" Y2="12" Stroke="Black" StrokeThickness="2"/>
<Line X1="8" Y1="11" X2="12" Y2="8" Stroke="Black" StrokeThickness="2"/>
</Canvas>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="true">
<Setter TargetName="TheBorder" Property="Background" Value="{StaticResource OrangeBrushKey}"/>
<Setter TargetName="TheBorder" Property="BorderBrush" Value="Silver"/>
</Trigger>
<Trigger Property="ButtonBase.IsPressed" Value="True">
<Setter TargetName="TheBorder" Property="Background" Value="{StaticResource OrangePressedBrushKey}"/>
<Setter TargetName="TheBorder" Property="BorderBrush" Value="Silver"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="TheCanvas" Property="RenderTransform" Value="{StaticResource FlipComment}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<SolidColorBrush x:Key="MouseOverPinBrush" Color="Black" />
<ControlTemplate x:Key="PinTooltipButtonTemplate" TargetType="ToggleButton">
<Border Width="16" Height="16" Name="TheBorder" CornerRadius="2" BorderBrush="Transparent" BorderThickness="1" Background="Transparent">
<Canvas RenderTransform="{StaticResource Rotate}" Name="TheCanvas">
<Line X1="4" X2="10" Y1="2" Y2="2" Name="Line1" Stroke="Silver" StrokeThickness="1"/>
<Line X1="10" X2="10" Y1="3" Y2="9" Name="Line2" Stroke="Silver" StrokeThickness="1"/>
<Line X1="2" X2="12" Y1="9" Y2="9" Name="Line3" Stroke="Silver" StrokeThickness="1"/>
<Rectangle Width="3" Height="6" Name="Rectangle" Fill="Silver" Canvas.Left="3" Canvas.Top="3"/>
<Line X1="7" X2="7" Y1="10" Y2="13" Name="Line4" Stroke="Silver" StrokeThickness="1"/>
</Canvas>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="ButtonBase.IsPressed" Value="True">
<Setter TargetName="TheCanvas" Property="RenderTransform" Value="{StaticResource RotateUnpin}"/>
</Trigger>
<Trigger Property="ButtonBase.IsMouseOver" Value="True">
<Setter TargetName="Line1" Property="Stroke" Value="{StaticResource MouseOverPinBrush}"/>
<Setter TargetName="Line2" Property="Stroke" Value="{StaticResource MouseOverPinBrush}"/>
<Setter TargetName="Line3" Property="Stroke" Value="{StaticResource MouseOverPinBrush}"/>
<Setter TargetName="Line4" Property="Stroke" Value="{StaticResource MouseOverPinBrush}"/>
<Setter TargetName="Rectangle" Property="Fill" Value="{StaticResource MouseOverPinBrush}"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="TheCanvas" Property="RenderTransform" Value="{StaticResource RotateUnpin}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ResourceDictionary>

BIN
src/Main/StartUp/Project/Resources/BitmapResources.resources

Binary file not shown.
Loading…
Cancel
Save