Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Formatted code.

  • Loading branch information...
commit 5d2abad7b75367d2b59815484bffe5ba0fca27cc 1 parent 5c7d954
@mkonicek mkonicek authored
View
18 src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/GraphDiff.cs
@@ -9,7 +9,7 @@
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 @@ public IList<PositionedNode> RemovedNodes
}
/// <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 @@ internal void SetMatching(PositionedNode matchFrom, PositionedNode matchTo)
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();
- }*/
}
}
View
64 src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/GraphMatcher.cs
@@ -8,92 +8,76 @@
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();
}
View
15 src/AddIns/Debugger/Debugger.AddIn/Visualizers/PresentationBindings/GridViewColumnHider.cs
@@ -23,10 +23,8 @@ public string Header
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 @@ void initializeColumns()
{
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 @@ void columnWithVisibility_IsVisibleChanged(object sender, EventArgs e)
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;
View
2  src/AddIns/Debugger/Debugger.AddIn/Visualizers/PresentationBindings/GridViewHideableColumn.cs
@@ -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;
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.