Browse Source

Very simple implementation of remembering expanded nodes - just made ObjectGraphControl.Expanded static. It should be probably remembered separately per method (different variables in different methods have different meaning. Cleared on project close?).

pull/15/head
mkonicek 15 years ago
parent
commit
5f3c42bd2d
  1. 2
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraph/ObjectGraphBuilder.cs
  2. 20
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraphControl.xaml.cs
  3. 69
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraphWindow.xaml.cs

2
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraph/ObjectGraphBuilder.cs

@ -242,7 +242,7 @@ namespace Debugger.AddIn.Visualizers.Graph
propertyList.Add(new ObjectGraphProperty propertyList.Add(new ObjectGraphProperty
{ Name = memberProp.Name, { Name = memberProp.Name,
Expression = propExpression, Value = "", Expression = propExpression, Value = "",
PropInfo = memberProp, IsAtomic = true, TargetNode = null }); MemberInfo = memberProp, IsAtomic = true, TargetNode = null });
} }
return propertyList.Sorted(ObjectPropertyComparer.Instance); return propertyList.Sorted(ObjectPropertyComparer.Instance);

20
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraphControl.xaml.cs

@ -27,19 +27,19 @@ namespace Debugger.AddIn.Visualizers.Graph
/// </summary> /// </summary>
public partial class ObjectGraphControl : UserControl public partial class ObjectGraphControl : UserControl
{ {
private WindowsDebugger debuggerService; WindowsDebugger debuggerService;
private EnumViewModel<LayoutDirection> layoutViewModel; EnumViewModel<LayoutDirection> layoutViewModel;
private ObjectGraph objectGraph; ObjectGraph objectGraph;
private ObjectGraphBuilder objectGraphBuilder; ObjectGraphBuilder objectGraphBuilder;
private PositionedGraph oldPosGraph; PositionedGraph oldPosGraph;
private PositionedGraph currentPosGraph; PositionedGraph currentPosGraph;
private GraphDrawer graphDrawer; GraphDrawer graphDrawer;
static double mouseWheelZoomSpeed = 0.05; static double mouseWheelZoomSpeed = 0.05;
/// <summary> Long-lived map telling which graph nodes and content nodes the user expanded. </summary> /// <summary> Long-lived map telling which graph nodes and content nodes the user expanded. </summary>
private Expanded expanded = new Expanded(); static Expanded expanded = new Expanded();
public ObjectGraphControl() public ObjectGraphControl()
{ {
@ -136,7 +136,7 @@ namespace Debugger.AddIn.Visualizers.Graph
{ {
this.objectGraphBuilder = new ObjectGraphBuilder(debuggerService); this.objectGraphBuilder = new ObjectGraphBuilder(debuggerService);
Log.Debug("Debugger visualizer: Building graph for expression: " + txtExpression.Text); Log.Debug("Debugger visualizer: Building graph for expression: " + txtExpression.Text);
return this.objectGraphBuilder.BuildGraphForExpression(expression, this.expanded.Expressions); return this.objectGraphBuilder.BuildGraphForExpression(expression, expanded.Expressions);
} }
void LayoutGraph(ObjectGraph graph) void LayoutGraph(ObjectGraph graph)
@ -150,7 +150,7 @@ namespace Debugger.AddIn.Visualizers.Graph
this.oldPosGraph = this.currentPosGraph; this.oldPosGraph = this.currentPosGraph;
Log.Debug("Debugger visualizer: Calculating graph layout"); Log.Debug("Debugger visualizer: Calculating graph layout");
var layoutDirection = layoutViewModel.SelectedEnumValue; var layoutDirection = layoutViewModel.SelectedEnumValue;
this.currentPosGraph = new TreeLayout(layoutDirection).CalculateLayout(graph, this.expanded); this.currentPosGraph = new TreeLayout(layoutDirection).CalculateLayout(graph, expanded);
Log.Debug("Debugger visualizer: Graph layout done"); Log.Debug("Debugger visualizer: Graph layout done");
RegisterExpandCollapseEvents(this.currentPosGraph); RegisterExpandCollapseEvents(this.currentPosGraph);

69
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraphWindow.xaml.cs

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq;
using System.Text; using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
@ -13,7 +14,6 @@ using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Shapes; using System.Windows.Shapes;
using Debugger.AddIn.Visualizers.Graph.Layout; using Debugger.AddIn.Visualizers.Graph.Layout;
using ICSharpCode.SharpDevelop.Debugging; using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Services; using ICSharpCode.SharpDevelop.Services;
@ -27,73 +27,74 @@ namespace Debugger.AddIn.Visualizers.Graph
{ {
private WindowsDebugger debuggerService; private WindowsDebugger debuggerService;
public ObjectGraphWindow() private ObjectGraphWindow()
{ {
InitializeComponent(); InitializeComponent();
debuggerService = DebuggerService.CurrentDebugger as WindowsDebugger; debuggerService = DebuggerService.CurrentDebugger as WindowsDebugger;
if (debuggerService == null) if (debuggerService == null) throw new DebuggerVisualizerException("Only windows debugger is currently supported");
throw new ApplicationException("Only windows debugger is currently supported");
registerEvents();
instance = this;
} }
protected override void OnClosed(EventArgs e) protected override void OnClosed(EventArgs e)
{ {
base.OnClosed(e); base.OnClosed(e);
unregisterEvents(); UnregisterDebuggerEvents();
this.objectGraphControl.ClearUIControlCache(); this.objectGraphControl.ClearUIControlCache();
instance = null; ObjectGraphWindow.Instance = null; // allow release
} }
public ICSharpCode.NRefactory.Ast.Expression ShownExpression public ICSharpCode.NRefactory.Ast.Expression ShownExpression
{ {
get { get { return this.objectGraphControl.ShownExpression; }
return this.objectGraphControl.ShownExpression; set { this.objectGraphControl.ShownExpression = value; }
}
set {
this.objectGraphControl.ShownExpression = value;
}
} }
static ObjectGraphWindow instance;
/// <summary> When Window is visible, returns reference to the Window. Otherwise returns null. </summary> /// <summary> When Window is visible, returns reference to the Window. Otherwise returns null. </summary>
public static ObjectGraphWindow Instance public static ObjectGraphWindow Instance { get; private set; }
{
get { return instance; }
}
/// <summary>
/// Shows the singleton instance of ObjectGraphWindow and also returns it.
/// </summary>
/// <returns></returns>
public static ObjectGraphWindow EnsureShown() public static ObjectGraphWindow EnsureShown()
{ {
var window = ObjectGraphWindow.Instance ?? new ObjectGraphWindow(); if (ObjectGraphWindow.Instance == null) {
window.Topmost = true; ObjectGraphWindow.Instance = new ObjectGraphWindow();
window.Show(); ObjectGraphWindow.Instance.Topmost = true;
return window; }
ObjectGraphWindow.Instance.RegisterDebuggerEvents();
ObjectGraphWindow.Instance.Show();
return ObjectGraphWindow.Instance;
} }
private void registerEvents() static bool isDebuggerEventsRegistered = false;
void RegisterDebuggerEvents()
{ {
debuggerService.IsProcessRunningChanged += new EventHandler(debuggerService_IsProcessRunningChanged); if (!isDebuggerEventsRegistered) {
debuggerService.DebugStopped += new EventHandler(debuggerService_DebugStopped); debuggerService.IsProcessRunningChanged += DebuggerService_IsProcessRunningChanged;
debuggerService.DebugStopped += DebuggerService_DebugStopped;
// cannot use debuggerService.IsProcessRunningChanged.GetInvocationList() from outside
isDebuggerEventsRegistered = true;
}
} }
private void unregisterEvents() void UnregisterDebuggerEvents()
{ {
debuggerService.IsProcessRunningChanged -= new EventHandler(debuggerService_IsProcessRunningChanged); debuggerService.IsProcessRunningChanged -= DebuggerService_IsProcessRunningChanged;
debuggerService.DebugStopped -= new EventHandler(debuggerService_DebugStopped); debuggerService.DebugStopped -= DebuggerService_DebugStopped;
isDebuggerEventsRegistered = false;
} }
public void debuggerService_IsProcessRunningChanged(object sender, EventArgs e) void DebuggerService_IsProcessRunningChanged(object sender, EventArgs e)
{ {
// on step or breakpoint hit // on step or breakpoint hit
if (!debuggerService.IsProcessRunning) if (!debuggerService.IsProcessRunning) {
{
this.objectGraphControl.Refresh(); this.objectGraphControl.Refresh();
} }
} }
public void debuggerService_DebugStopped(object sender, EventArgs e) void DebuggerService_DebugStopped(object sender, EventArgs e)
{ {
this.Close(); this.Close();
} }

Loading…
Cancel
Save