diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/GraphDiff.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/GraphDiff.cs index cac03f8138..3e1747a66a 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/GraphDiff.cs +++ b/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 { /// - /// Describes changes between 2 s. + /// Describes changes which occured between 2 s. /// public class GraphDiff { @@ -35,8 +35,8 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout } /// - /// Nodes in the old graph that were chaged. - /// These have matching new nodes, which can be obtained by . + /// 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 . /// public IList ChangedNodes { @@ -63,17 +63,5 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout matching[matchFrom] = matchTo; changedNodes.Add(matchFrom); } - - public GraphDiff() - { - - } - - /*public void MakeReadOnly() - { - addedNodes = ((List)addedNodes).AsReadOnly(); - deletedNodes = ((List)deletedNodes).AsReadOnly(); - changedNodes = ((List)changedNodes).AsReadOnly(); - }*/ } } diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/GraphMatcher.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/GraphMatcher.cs index dc241f67b8..3a4c5e0ff3 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/GraphMatcher.cs +++ b/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 { /// - /// Calculates diff of 2 s. + /// Calculates diff between 2 s. /// public class GraphMatcher { - public GraphMatcher() - { - } - + /// + /// Calculates diff between 2 s. + /// The describes a matching between nodes in the graphs, added and removed nodes. + /// 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 newNodeForHashCode = buildHashToNodeMap(newGraph); + Dictionary newNodeForHashCode = BuildHashToNodeMap(newGraph); Dictionary newNodeMatched = new Dictionary(); - 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 buildHashToNodeMap(PositionedGraph graph) + Dictionary BuildHashToNodeMap(PositionedGraph graph) { var hashToNodeMap = new Dictionary(); - 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 newNodeMap) + PositionedNode MatchNode(PositionedNode oldNode, Dictionary 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(); } diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/PresentationBindings/GridViewColumnHider.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/PresentationBindings/GridViewColumnHider.cs index 4a715ef318..1ea154e5cb 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/PresentationBindings/GridViewColumnHider.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/PresentationBindings/GridViewColumnHider.cs @@ -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 { 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 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; diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/PresentationBindings/GridViewHideableColumn.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/PresentationBindings/GridViewHideableColumn.cs index 1e86615558..7be07494f9 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/PresentationBindings/GridViewHideableColumn.cs +++ b/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; } } }