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; @@ -9,7 +9,7 @@ using Debugger.AddIn.Visualizers.Utils;
namespace Debugger.AddIn.Visualizers.Graph.Layout
{
/// <summary>
/// Describes changes between 2 <see cref="PositionedGraph"/>s.
/// Describes changes which occured between 2 <see cref="PositionedGraph"/>s.
/// </summary>
public class GraphDiff
{
@ -35,8 +35,8 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -35,8 +35,8 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
}
/// <summary>
/// Nodes in the old graph that were chaged.
/// These have matching new nodes, which can be obtained by <see cref="GetMatchingNewNode"/>.
/// Nodes in the old graph that are present also in the new graph (they represent the same debuggee instance).
/// The matching new nodes can be obtained by <see cref="GetMatchingNewNode"/>.
/// </summary>
public IList<PositionedNode> ChangedNodes
{
@ -63,17 +63,5 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -63,17 +63,5 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
matching[matchFrom] = matchTo;
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; @@ -8,92 +8,76 @@ using Debugger.AddIn.Visualizers.Utils;
namespace Debugger.AddIn.Visualizers.Graph.Layout
{
/// <summary>
/// Calculates diff of 2 <see cref="PositionedGraph"/>s.
/// Calculates diff between 2 <see cref="PositionedGraph"/>s.
/// </summary>
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)
{
if (oldGraph == null)
{
if (newGraph == null)
{
if (oldGraph == null) {
if (newGraph == null) {
return new GraphDiff();
}
else
{
} else {
GraphDiff addAllDiff = new GraphDiff();
foreach (PositionedNode newNode in newGraph.Nodes)
addAllDiff.SetAdded(newNode);
return addAllDiff;
}
}
else if (newGraph == null)
{
} else if (newGraph == null) {
GraphDiff removeAllDiff = new GraphDiff();
foreach (PositionedNode oldNode in oldGraph.Nodes)
removeAllDiff.SetRemoved(oldNode);
return removeAllDiff;
}
// none of the graphs is null
GraphDiff diff = new GraphDiff();
Dictionary<int, PositionedNode> newNodeForHashCode = buildHashToNodeMap(newGraph);
Dictionary<int, PositionedNode> newNodeForHashCode = BuildHashToNodeMap(newGraph);
Dictionary<PositionedNode, bool> newNodeMatched = new Dictionary<PositionedNode, bool>();
foreach (PositionedNode oldNode in oldGraph.Nodes)
{
PositionedNode matchingNode = matchNode(oldNode, newNodeForHashCode);
if (matchingNode != null)
{
foreach (PositionedNode oldNode in oldGraph.Nodes) {
PositionedNode matchingNode = MatchNode(oldNode, newNodeForHashCode);
if (matchingNode != null) {
diff.SetMatching(oldNode, matchingNode);
newNodeMatched[matchingNode] = true;
}
else
{
} else {
diff.SetRemoved(oldNode);
}
}
foreach (PositionedNode newNode in newGraph.Nodes)
{
if (!newNodeMatched.ContainsKey(newNode))
{
foreach (PositionedNode newNode in newGraph.Nodes) {
if (!newNodeMatched.ContainsKey(newNode)) {
diff.SetAdded(newNode);
}
}
return diff;
}
private Dictionary<int, PositionedNode> buildHashToNodeMap(PositionedGraph graph)
Dictionary<int, PositionedNode> BuildHashToNodeMap(PositionedGraph graph)
{
var hashToNodeMap = new Dictionary<int, PositionedNode>();
foreach (PositionedNode node in graph.Nodes)
{
foreach (PositionedNode node in graph.Nodes) {
hashToNodeMap[node.ObjectNode.HashCode] = node;
}
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);
if ((newNodeFound != null) && isSameAddress(oldNode, newNodeFound))
{
if ((newNodeFound != null) && IsSameAddress(oldNode, newNodeFound)) {
return newNodeFound;
}
else
{
} else {
return null;
}
}
private bool isSameAddress(PositionedNode node1, PositionedNode node2)
bool IsSameAddress(PositionedNode node1, PositionedNode node2)
{
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 @@ -23,10 +23,8 @@ namespace Debugger.AddIn.Visualizers
public bool IsVisible
{
get { return isVisible; }
set
{
if (isVisible != value)
{
set {
if (isVisible != value) {
isVisible = value;
OnPropertyChanged("IsVisible");
ExtensionMethods.RaiseEvent(IsVisibleChanged, this, EventArgs.Empty);
@ -55,7 +53,10 @@ namespace Debugger.AddIn.Visualizers @@ -55,7 +53,10 @@ namespace Debugger.AddIn.Visualizers
{
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);
columnWithVisibility.IsVisibleChanged += columnWithVisibility_IsVisibleChanged;
}
@ -74,8 +75,8 @@ namespace Debugger.AddIn.Visualizers @@ -74,8 +75,8 @@ namespace Debugger.AddIn.Visualizers
bool canBeHidden(GridViewColumn column)
{
var columnHideable = column as GridViewHideableColumn;
if (columnHideable != null && (!columnHideable.CanBeHidden))
{
// disable hiding if supported
if (columnHideable != null && (!columnHideable.CanBeHidden)) {
return false;
}
return true;

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

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

Loading…
Cancel
Save