@ -4,7 +4,11 @@
@@ -4,7 +4,11 @@
// <owner name="Martin Koníček" email="martin.konicek@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System ;
using System.Collections.Generic ;
using System.Collections.ObjectModel ;
using System.Linq ;
using System.Reflection ;
using System.Text ;
using System.Windows ;
using System.Windows.Controls ;
@ -13,11 +17,10 @@ using System.Windows.Data;
@@ -13,11 +17,10 @@ using System.Windows.Data;
using System.Windows.Documents ;
using System.Windows.Input ;
using System.Windows.Media ;
using Debugger.AddIn.Visualizers.Graph.Layout ;
using System ;
using System.Collections.Generic ;
using System.Linq ;
using Debugger.AddIn.Visualizers.Common ;
using Debugger.AddIn.Visualizers.Graph.Layout ;
using System.Windows.Threading ;
namespace Debugger.AddIn.Visualizers.Graph.Drawing
{
@ -61,6 +64,53 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing
@@ -61,6 +64,53 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing
this . view = getInitialView ( this . root ) ;
// data virtualization, PropertyNodeViewModel implements IEvaluate
this . listView . ItemsSource = new VirtualizingObservableCollection < ContentNode > ( this . view ) ;
int maxLen = this . view . Max ( contentNode = > { return contentNode . Name . Length ; } ) ;
int spaces = Math . Max ( ( int ) ( maxLen * 1.5 ) , 0 ) ;
string sp = "" ;
for ( int i = 0 ; i < spaces ; i + + )
sp + = " " ;
GridView gv = listView . View as GridView ;
gv . Columns [ 1 ] . Header = "Name" + sp ;
//AutoSizeColumns();
/ * DispatcherTimer t = new DispatcherTimer ( ) ;
t . Interval = TimeSpan . FromMilliseconds ( 1 0 0 0 ) ;
t . Start ( ) ;
t . Tick + = ( s , ee ) = > { AutoSizeColumns ( ) ; t . Stop ( ) ; } ; * /
}
}
public void AutoSizeColumns ( )
{
//listView.UpdateLayout();
//listView.Measure(new Size(800, 800));
//double sum = 0;
GridView gv = listView . View as GridView ;
if ( gv ! = null )
{
foreach ( var c in gv . Columns )
{
//var header = c.Header as GridViewColumnHeader;
// Code below was found in GridViewColumnHeader.OnGripperDoubleClicked() event handler (using Reflector)
// i.e. it is the same code that is executed when the gripper is double clicked
//var uw = c.GetType().GetMethod("UpdateActualWidth", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic);
//uw.Invoke(c, new object[] { });
//if (double.IsNaN(c.Width))
{
c . Width = c . ActualWidth ;
}
c . Width = double . NaN ;
/ * var dw = c . GetType ( ) . GetProperty ( "DesiredWidth" , BindingFlags . Instance | BindingFlags . InvokeMethod | BindingFlags . NonPublic ) ;
double desired = ( double ) dw . GetValue ( c , null ) ;
c . Width = c . ActualWidth ; // ActualWidth is not correct until GridViewRowPresenter gets measured
c . Width = double . NaN ;
sum + = c . Width ; * /
}
}
}
@ -85,6 +135,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing
@@ -85,6 +135,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing
PositionedNodeProperty property = clickedNode . Property ;
//property.IsPropertyExpanded = !property.IsPropertyExpanded; // done by databinding
clickedButton . Content = property . IsPropertyExpanded ? "-" : "+" ;
if ( property . IsPropertyExpanded )
{
OnPropertyExpanded ( property ) ;
@ -112,6 +163,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing
@@ -112,6 +163,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing
this . view . Insert ( clickedIndex + i , childNode ) ;
i + + ;
}
// insertChildren(clickedNode, this.view, clickedIndex); // TODO
OnContentNodeExpanded ( clickedNode ) ;
}
else
@ -125,18 +177,20 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing
@@ -125,18 +177,20 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing
OnContentNodeCollapsed ( clickedNode ) ;
}
//AutoSizeColumns();
// set to Auto again to resize columns
var colName = ( this . listView . View as GridView ) . Columns [ 0 ] ;
/ * var colName = ( this . listView . View as GridView ) . Columns [ 0 ] ;
var colValue = ( this . listView . View as GridView ) . Columns [ 1 ] ;
colName . Width = 3 0 0 ;
colName . Width = double . NaN ;
colValue . Width = 3 0 0 ;
colValue . Width = double . NaN ;
//this.view.Insert(0, new NestedNodeViewModel ());
//this.view.Insert(0, new ContentNode ());
//this.view.RemoveAt(0);
this . listView . UpdateLayout ( ) ;
this . listView . Width = colName . ActualWidth + colValue . ActualWidth + 3 0 ;
this . listView . Width = double . NaN ;
this . listView . Width = double . NaN ; * /
}
private ObservableCollection < ContentNode > getInitialView ( ContentNode root )