Browse Source

Formatted code.

pull/15/head
mkonicek 15 years ago
parent
commit
5d2abad7b7
  1. 18
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/GraphDiff.cs
  2. 64
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/GraphMatcher.cs
  3. 15
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/PresentationBindings/GridViewColumnHider.cs
  4. 2
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/PresentationBindings/GridViewHideableColumn.cs

18
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/GraphDiff.cs

@ -9,7 +9,7 @@ using Debugger.AddIn.Visualizers.Utils;
namespace Debugger.AddIn.Visualizers.Graph.Layout namespace Debugger.AddIn.Visualizers.Graph.Layout
{ {
/// <summary> /// <summary>
/// Describes changes between 2 <see cref="PositionedGraph"/>s. /// Describes changes which occured between 2 <see cref="PositionedGraph"/>s.
/// </summary> /// </summary>
public class GraphDiff public class GraphDiff
{ {
@ -35,8 +35,8 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
} }
/// <summary> /// <summary>
/// Nodes in the old graph that were chaged. /// Nodes in the old graph that are present also in the new graph (they represent the same debuggee instance).
/// These have matching new nodes, which can be obtained by <see cref="GetMatchingNewNode"/>. /// The matching new nodes can be obtained by <see cref="GetMatchingNewNode"/>.
/// </summary> /// </summary>
public IList<PositionedNode> ChangedNodes public IList<PositionedNode> ChangedNodes
{ {
@ -63,17 +63,5 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
matching[matchFrom] = matchTo; matching[matchFrom] = matchTo;
changedNodes.Add(matchFrom); changedNodes.Add(matchFrom);
} }
public GraphDiff()
{
}
/*public void MakeReadOnly()
{
addedNodes = ((List<PositionedNode>)addedNodes).AsReadOnly();
deletedNodes = ((List<PositionedNode>)deletedNodes).AsReadOnly();
changedNodes = ((List<PositionedNode>)changedNodes).AsReadOnly();
}*/
} }
} }

64
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/GraphMatcher.cs

@ -8,92 +8,76 @@ using Debugger.AddIn.Visualizers.Utils;
namespace Debugger.AddIn.Visualizers.Graph.Layout namespace Debugger.AddIn.Visualizers.Graph.Layout
{ {
/// <summary> /// <summary>
/// Calculates diff of 2 <see cref="PositionedGraph"/>s. /// Calculates diff between 2 <see cref="PositionedGraph"/>s.
/// </summary> /// </summary>
public class GraphMatcher public class GraphMatcher
{ {
public GraphMatcher() /// <summary>
{ /// Calculates diff between 2 <see cref="PositionedGraph"/>s.
} /// The <see cref="GraphDiff"/> describes a matching between nodes in the graphs, added and removed nodes.
/// </summary>
public GraphDiff MatchGraphs(PositionedGraph oldGraph, PositionedGraph newGraph) public GraphDiff MatchGraphs(PositionedGraph oldGraph, PositionedGraph newGraph)
{ {
if (oldGraph == null) if (oldGraph == null) {
{ if (newGraph == null) {
if (newGraph == null)
{
return new GraphDiff(); return new GraphDiff();
} } else {
else
{
GraphDiff addAllDiff = new GraphDiff(); GraphDiff addAllDiff = new GraphDiff();
foreach (PositionedNode newNode in newGraph.Nodes) foreach (PositionedNode newNode in newGraph.Nodes)
addAllDiff.SetAdded(newNode); addAllDiff.SetAdded(newNode);
return addAllDiff; return addAllDiff;
} }
} } else if (newGraph == null) {
else if (newGraph == null)
{
GraphDiff removeAllDiff = new GraphDiff(); GraphDiff removeAllDiff = new GraphDiff();
foreach (PositionedNode oldNode in oldGraph.Nodes) foreach (PositionedNode oldNode in oldGraph.Nodes)
removeAllDiff.SetRemoved(oldNode); removeAllDiff.SetRemoved(oldNode);
return removeAllDiff; return removeAllDiff;
} }
// none of the graphs is null // none of the graphs is null
GraphDiff diff = new GraphDiff(); GraphDiff diff = new GraphDiff();
Dictionary<int, PositionedNode> newNodeForHashCode = buildHashToNodeMap(newGraph); Dictionary<int, PositionedNode> newNodeForHashCode = BuildHashToNodeMap(newGraph);
Dictionary<PositionedNode, bool> newNodeMatched = new Dictionary<PositionedNode, bool>(); Dictionary<PositionedNode, bool> newNodeMatched = new Dictionary<PositionedNode, bool>();
foreach (PositionedNode oldNode in oldGraph.Nodes) foreach (PositionedNode oldNode in oldGraph.Nodes) {
{ PositionedNode matchingNode = MatchNode(oldNode, newNodeForHashCode);
PositionedNode matchingNode = matchNode(oldNode, newNodeForHashCode);
if (matchingNode != null) if (matchingNode != null) {
{
diff.SetMatching(oldNode, matchingNode); diff.SetMatching(oldNode, matchingNode);
newNodeMatched[matchingNode] = true; newNodeMatched[matchingNode] = true;
} } else {
else
{
diff.SetRemoved(oldNode); diff.SetRemoved(oldNode);
} }
} }
foreach (PositionedNode newNode in newGraph.Nodes) foreach (PositionedNode newNode in newGraph.Nodes) {
{ if (!newNodeMatched.ContainsKey(newNode)) {
if (!newNodeMatched.ContainsKey(newNode))
{
diff.SetAdded(newNode); diff.SetAdded(newNode);
} }
} }
return diff; return diff;
} }
private Dictionary<int, PositionedNode> buildHashToNodeMap(PositionedGraph graph) Dictionary<int, PositionedNode> BuildHashToNodeMap(PositionedGraph graph)
{ {
var hashToNodeMap = new Dictionary<int, PositionedNode>(); var hashToNodeMap = new Dictionary<int, PositionedNode>();
foreach (PositionedNode node in graph.Nodes) foreach (PositionedNode node in graph.Nodes) {
{
hashToNodeMap[node.ObjectNode.HashCode] = node; hashToNodeMap[node.ObjectNode.HashCode] = node;
} }
return hashToNodeMap; return hashToNodeMap;
} }
private PositionedNode matchNode(PositionedNode oldNode, Dictionary<int, PositionedNode> newNodeMap) PositionedNode MatchNode(PositionedNode oldNode, Dictionary<int, PositionedNode> newNodeMap)
{ {
PositionedNode newNodeFound = newNodeMap.GetValue(oldNode.ObjectNode.HashCode); PositionedNode newNodeFound = newNodeMap.GetValue(oldNode.ObjectNode.HashCode);
if ((newNodeFound != null) && isSameAddress(oldNode, newNodeFound)) if ((newNodeFound != null) && IsSameAddress(oldNode, newNodeFound)) {
{
return newNodeFound; return newNodeFound;
} } else {
else
{
return null; return null;
} }
} }
private bool isSameAddress(PositionedNode node1, PositionedNode node2) bool IsSameAddress(PositionedNode node1, PositionedNode node2)
{ {
return node1.ObjectNode.PermanentReference.GetObjectAddress() == node2.ObjectNode.PermanentReference.GetObjectAddress(); return node1.ObjectNode.PermanentReference.GetObjectAddress() == node2.ObjectNode.PermanentReference.GetObjectAddress();
} }

15
src/AddIns/Debugger/Debugger.AddIn/Visualizers/PresentationBindings/GridViewColumnHider.cs

@ -23,10 +23,8 @@ namespace Debugger.AddIn.Visualizers
public bool IsVisible public bool IsVisible
{ {
get { return isVisible; } get { return isVisible; }
set set {
{ if (isVisible != value) {
if (isVisible != value)
{
isVisible = value; isVisible = value;
OnPropertyChanged("IsVisible"); OnPropertyChanged("IsVisible");
ExtensionMethods.RaiseEvent(IsVisibleChanged, this, EventArgs.Empty); ExtensionMethods.RaiseEvent(IsVisibleChanged, this, EventArgs.Empty);
@ -55,7 +53,10 @@ namespace Debugger.AddIn.Visualizers
{ {
foreach (var column in gridView.Columns) foreach (var column in gridView.Columns)
{ {
var columnWithVisibility = new GridViewColumnWithVisibility { Column = column, IsVisible = true }; // show / hide right in the beginning if supported
bool isDefaultVisible = (column is GridViewHideableColumn) ? ((GridViewHideableColumn)column).IsVisibleDefault : true;
// wrap into our ViewModel
var columnWithVisibility = new GridViewColumnWithVisibility { Column = column, IsVisible = isDefaultVisible };
allColumns.Add(columnWithVisibility); allColumns.Add(columnWithVisibility);
columnWithVisibility.IsVisibleChanged += columnWithVisibility_IsVisibleChanged; columnWithVisibility.IsVisibleChanged += columnWithVisibility_IsVisibleChanged;
} }
@ -74,8 +75,8 @@ namespace Debugger.AddIn.Visualizers
bool canBeHidden(GridViewColumn column) bool canBeHidden(GridViewColumn column)
{ {
var columnHideable = column as GridViewHideableColumn; var columnHideable = column as GridViewHideableColumn;
if (columnHideable != null && (!columnHideable.CanBeHidden)) // disable hiding if supported
{ if (columnHideable != null && (!columnHideable.CanBeHidden)) {
return false; return false;
} }
return true; return true;

2
src/AddIns/Debugger/Debugger.AddIn/Visualizers/PresentationBindings/GridViewHideableColumn.cs

@ -14,9 +14,11 @@ namespace Debugger.AddIn.Visualizers.PresentationBindings
public class GridViewHideableColumn : GridViewColumn public class GridViewHideableColumn : GridViewColumn
{ {
public bool CanBeHidden { get; set; } public bool CanBeHidden { get; set; }
public bool IsVisibleDefault { get; set; }
public GridViewHideableColumn() public GridViewHideableColumn()
{ {
this.IsVisibleDefault = true;
} }
} }
} }

Loading…
Cancel
Save