Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit afea20f

Browse files
committed
UI update on pin control
1 parent a575d62 commit afea20f

14 files changed

Lines changed: 447 additions & 249 deletions

File tree

-266 Bytes
Loading

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

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
using System.Globalization;
88
using System.Reflection;
99
using System.Runtime.InteropServices;
10+
using System.Text;
1011
using System.Windows.Forms;
11-
1212
using Debugger.AddIn.Visualizers;
1313
using Debugger.MetaData;
1414
using ICSharpCode.Core;
@@ -74,6 +74,55 @@ public override string Text {
7474
}
7575
}
7676

77+
public override string FullName {
78+
get {
79+
if (!evaluated) EvaluateExpression();
80+
81+
if (expression is MemberReferenceExpression) {
82+
var memberExpression = (MemberReferenceExpression)expression;
83+
84+
Expression currentExpression = memberExpression;
85+
Stack<string> stack = new Stack<string>();
86+
while (currentExpression is MemberReferenceExpression)
87+
{
88+
var exp = (MemberReferenceExpression)currentExpression;
89+
stack.Push(exp.MemberName);
90+
stack.Push(".");
91+
92+
currentExpression = exp.TargetObject;
93+
}
94+
95+
if (currentExpression is CastExpression) {
96+
var castExpression = (CastExpression)currentExpression;
97+
currentExpression = castExpression.Expression;
98+
99+
if (currentExpression is IdentifierExpression) {
100+
var identifierExpression = (IdentifierExpression)castExpression.Expression;
101+
stack.Push(identifierExpression.Identifier);
102+
}
103+
104+
while (currentExpression is MemberReferenceExpression)
105+
{
106+
var exp = (MemberReferenceExpression)currentExpression;
107+
stack.Push(exp.MemberName);
108+
stack.Push(".");
109+
110+
currentExpression = exp.TargetObject;
111+
}
112+
}
113+
114+
// create fullname
115+
StringBuilder sb = new StringBuilder();
116+
while(stack.Count > 0)
117+
sb.Append(stack.Pop());
118+
119+
return sb.ToString();
120+
}
121+
122+
return Name.Trim();
123+
}
124+
}
125+
77126
public override string Type {
78127
get {
79128
if (!evaluated) EvaluateExpression();
@@ -284,6 +333,8 @@ bool ShowAsHex(object i)
284333

285334
public override bool SetText(string newText)
286335
{
336+
string fullName = FullName;
337+
287338
Value val = null;
288339
try {
289340
val = this.Expression.Evaluate(WindowsDebugger.DebuggedProcess);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cul
124124
b.Append(pin.PopupPosition.X);
125125
b.Append('|');
126126
b.Append(pin.PopupPosition.Y);
127-
b.Append('|');
128-
127+
129128
//popup nodes
130129
foreach(var node in pin.Nodes) {
130+
b.Append('|');
131131
b.Append(""); // image
132132
b.Append('|');
133-
b.Append(node.Name);
133+
b.Append(node.FullName);
134134
b.Append('|');
135135
b.Append(node.Text);
136136
}

src/Main/Base/Project/Src/Editor/AvalonEdit/PinLayer.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,6 @@ void onDragDelta(object sender, DragDeltaEventArgs e)
111111

112112
Canvas.SetLeft(currnetThumb, left);
113113
Canvas.SetTop(currnetThumb, top);
114-
115-
var pinControl = TryFindChild<PinDebuggerControl>(currnetThumb);
116-
if (pinControl != null) {
117-
pinControl.Location = new Point { X = left, Y = top };
118-
pinControl.Mark.PopupPosition = pinControl.Location;
119-
pinControl.Opacity = 1d;
120-
}
121114
}
122115

123116
void currentThumb_DragCompleted(object sender, DragCompletedEventArgs e)
@@ -126,8 +119,13 @@ void currentThumb_DragCompleted(object sender, DragCompletedEventArgs e)
126119
currnetThumb.Cursor = Cursors.Arrow;
127120

128121
var pinControl = TryFindChild<PinDebuggerControl>(currnetThumb);
129-
if (pinControl != null)
122+
if (pinControl != null) {
123+
double left = Canvas.GetLeft(currnetThumb);
124+
double top = Canvas.GetTop(currnetThumb);
130125
pinControl.Opacity = 1d;
126+
pinControl.Location = new Point { X = left, Y = top };
127+
pinControl.Mark.PopupPosition = pinControl.Location;
128+
}
131129
}
132130

133131
void currentThumb_DragStarted(object sender, DragStartedEventArgs e)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public class DebuggerPopup : Popup
1919
{
2020
internal DebuggerTooltipControl contentControl;
2121

22-
public DebuggerPopup(DebuggerTooltipControl parentControl)
22+
public DebuggerPopup(DebuggerTooltipControl parentControl, bool showPins = true)
2323
{
24-
this.contentControl = new DebuggerTooltipControl(parentControl);
24+
this.contentControl = new DebuggerTooltipControl(parentControl, showPins);
2525
this.contentControl.containingPopup = this;
2626
this.Child = this.contentControl;
2727
this.IsLeaf = false;

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

Lines changed: 0 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -10,137 +10,6 @@
1010
<ResourceDictionary
1111
Source="PinControlsDictionary.xaml" />
1212
</ResourceDictionary.MergedDictionaries>
13-
<!-- TODO move styles to ResourceDictionary -->
14-
<Style
15-
x:Key="ExpandCollapseToggleStyle"
16-
TargetType="{x:Type ToggleButton}">
17-
<Setter
18-
Property="Focusable"
19-
Value="False" />
20-
<Setter
21-
Property="Width"
22-
Value="19" />
23-
<Setter
24-
Property="Height"
25-
Value="13" />
26-
<Setter
27-
Property="Template">
28-
<Setter.Value>
29-
<ControlTemplate
30-
TargetType="{x:Type ToggleButton}">
31-
<Border
32-
Width="19"
33-
Height="13"
34-
Background="Transparent">
35-
<Border
36-
Width="9"
37-
Height="9"
38-
BorderThickness="1"
39-
BorderBrush="#FF7898B5"
40-
CornerRadius="1"
41-
SnapsToDevicePixels="true">
42-
<Border.Background>
43-
<LinearGradientBrush
44-
StartPoint="0,0"
45-
EndPoint="1,1">
46-
<LinearGradientBrush.GradientStops>
47-
<GradientStop
48-
Color="White"
49-
Offset=".2" />
50-
<GradientStop
51-
Color="#FFC0B7A6"
52-
Offset="1" />
53-
</LinearGradientBrush.GradientStops>
54-
</LinearGradientBrush>
55-
</Border.Background>
56-
<Path
57-
x:Name="ExpandPath"
58-
Margin="1,1,1,1"
59-
Fill="Black"
60-
Data="M 0 2 L 0 3 L 2 3 L 2 5 L 3 5 L 3 3 L 5 3 L 5 2 L 3 2 L 3 0 L 2 0 L 2 2 Z" />
61-
</Border>
62-
</Border>
63-
<ControlTemplate.Triggers>
64-
<Trigger
65-
Property="IsChecked"
66-
Value="True">
67-
<Setter
68-
Property="Data"
69-
TargetName="ExpandPath"
70-
Value="M 0 2 L 0 3 L 5 3 L 5 2 Z" />
71-
</Trigger>
72-
</ControlTemplate.Triggers>
73-
</ControlTemplate>
74-
</Setter.Value>
75-
</Setter>
76-
</Style>
77-
<Style
78-
x:Key="upDownBorderStyle"
79-
TargetType="{x:Type Border}">
80-
<Setter
81-
Property="BorderBrush"
82-
Value="Gray" />
83-
<Setter
84-
Property="HorizontalAlignment"
85-
Value="Stretch" />
86-
<Setter
87-
Property="Margin"
88-
Value="0" />
89-
<Setter
90-
Property="Padding"
91-
Value="0" />
92-
<Setter
93-
Property="Background"
94-
Value="#FFECF7FC" />
95-
<Setter
96-
Property="Height"
97-
Value="14" />
98-
<Style.Triggers>
99-
<DataTrigger
100-
Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled}"
101-
Value="False">
102-
<Setter
103-
Property="Background"
104-
Value="#FFE0E0E0"></Setter>
105-
</DataTrigger>
106-
</Style.Triggers>
107-
</Style>
108-
<Style
109-
x:Key="upButtonStyle"
110-
TargetType="{x:Type RepeatButton}">
111-
<Setter
112-
Property="Template">
113-
<Setter.Value>
114-
<ControlTemplate
115-
TargetType="{x:Type RepeatButton}">
116-
<Border
117-
Style="{StaticResource upDownBorderStyle}"
118-
BorderThickness="1 1 1 0">
119-
<ContentPresenter
120-
HorizontalAlignment="Center"></ContentPresenter>
121-
</Border>
122-
</ControlTemplate>
123-
</Setter.Value>
124-
</Setter>
125-
</Style>
126-
<Style
127-
x:Key="downButtonStyle"
128-
TargetType="{x:Type RepeatButton}">
129-
<Setter
130-
Property="Template">
131-
<Setter.Value>
132-
<ControlTemplate
133-
TargetType="{x:Type RepeatButton}">
134-
<Border
135-
Style="{StaticResource upDownBorderStyle}"
136-
BorderThickness="1 0 1 1">
137-
<ContentPresenter
138-
HorizontalAlignment="Center"></ContentPresenter>
139-
</Border>
140-
</ControlTemplate>
141-
</Setter.Value>
142-
</Setter>
143-
</Style>
14413
</ResourceDictionary>
14514
</UserControl.Resources>
14615
<StackPanel
@@ -314,7 +183,6 @@
314183
Style="{StaticResource TextStyle}"
315184
IsEnabled="{Binding CanSetText}"
316185
KeyUp="TextBox_KeyUp"
317-
LostFocus="TextBox_LostFocus"
318186
Margin="4 0"
319187
Text="{Binding Path=Text}" />
320188
</DataTemplate>

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

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,26 @@ namespace ICSharpCode.SharpDevelop.Debugging
2929
/// </summary>
3030
public partial class DebuggerTooltipControl : UserControl, ITooltip
3131
{
32-
private readonly double ChildPopupOpenXOffet = 16;
33-
private readonly double ChildPopupOpenYOffet = 15;
34-
private readonly int InitialItemsCount = 12;
35-
private readonly int VisibleItemsCount = 11;
36-
32+
private const double ChildPopupOpenXOffet = 16;
33+
private const double ChildPopupOpenYOffet = 15;
34+
private const int InitialItemsCount = 12;
35+
private const int VisibleItemsCount = 11;
36+
37+
private bool showPins = true;
38+
private LazyItemsControl<ITreeNode> lazyGrid;
39+
private IEnumerable<ITreeNode> itemsSource;
40+
3741
public DebuggerTooltipControl()
3842
{
3943
InitializeComponent();
44+
45+
Loaded += new RoutedEventHandler(OnLoaded);
4046
}
4147

4248
public DebuggerTooltipControl(ITreeNode node)
4349
: this(new ITreeNode[] { node })
4450
{
45-
Loaded += new RoutedEventHandler(OnLoaded);
51+
4652
}
4753

4854
public DebuggerTooltipControl(IEnumerable<ITreeNode> nodes)
@@ -51,31 +57,36 @@ public DebuggerTooltipControl(IEnumerable<ITreeNode> nodes)
5157
this.itemsSource = nodes;
5258
}
5359

54-
public DebuggerTooltipControl(DebuggerTooltipControl parentControl)
60+
public DebuggerTooltipControl(DebuggerTooltipControl parentControl, bool showPins = true)
5561
: this()
5662
{
5763
this.parentControl = parentControl;
64+
this.showPins = showPins;
5865
}
5966

6067
private void OnLoaded(object sender, RoutedEventArgs e)
6168
{
62-
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
63-
var editor = provider.TextEditor;
64-
if (editor == null) return;
65-
66-
// verify if at the line of the root there's a pin bookmark
67-
var pin = BookmarkManager.Bookmarks.Find(
68-
b => b is PinBookmark &&
69-
b.Location.Line == LogicalPosition.Line &&
70-
b.FileName == editor.FileName) as PinBookmark;
71-
72-
if (pin != null) {
73-
foreach (var node in this.itemsSource) {
74-
if (pin.ContainsNode(node))
75-
node.IsChecked = true;
69+
if (showPins) {
70+
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
71+
var editor = provider.TextEditor;
72+
if (editor == null) return;
73+
74+
// verify if at the line of the root there's a pin bookmark
75+
var pin = BookmarkManager.Bookmarks.Find(
76+
b => b is PinBookmark &&
77+
b.Location.Line == LogicalPosition.Line &&
78+
b.FileName == editor.FileName) as PinBookmark;
79+
80+
if (pin != null) {
81+
foreach (var node in this.itemsSource) {
82+
if (pin.ContainsNode(node))
83+
node.IsChecked = true;
84+
}
7685
}
7786
}
78-
87+
else {
88+
dataGrid.Columns[5].Visibility = Visibility.Collapsed;
89+
}
7990
SetItemsSource(this.itemsSource);
8091
}
8192

@@ -86,10 +97,6 @@ protected void OnClosed()
8697
this.Closed(this, new RoutedEventArgs());
8798
}
8899
}
89-
90-
private LazyItemsControl<ITreeNode> lazyGrid;
91-
92-
IEnumerable<ITreeNode> itemsSource;
93100

94101
public IEnumerable<ITreeNode> ItemsSource {
95102
get { return this.itemsSource; }
@@ -131,8 +138,8 @@ public bool Close(bool mouseClick)
131138
}
132139
}
133140

134-
DebuggerPopup childPopup { get; set; }
135-
DebuggerTooltipControl parentControl { get; set; }
141+
private DebuggerPopup childPopup { get; set; }
142+
private DebuggerTooltipControl parentControl { get; set; }
136143
internal DebuggerPopup containingPopup { get; set; }
137144

138145
bool isChildExpanded

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public interface ITreeNode
1414
{
1515
string Name { get; }
1616

17+
string FullName { get; }
18+
1719
string Text { get; }
1820

1921
bool CanSetText { get; }

0 commit comments

Comments
 (0)