14 changed files with 1268 additions and 0 deletions
@ -0,0 +1,90 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
using System.Windows; |
||||||
|
|
||||||
|
namespace TreeMaps.Controls |
||||||
|
{ |
||||||
|
public class SquarifiedTreeMapsPanel : TreeMapsPanel |
||||||
|
{ |
||||||
|
#region protected methods
|
||||||
|
|
||||||
|
protected override Rect GetRectangle(RowOrientation orientation, WeightUIElement item, double x, double y, double width, double height) |
||||||
|
{ |
||||||
|
if (orientation == RowOrientation.Horizontal) |
||||||
|
return new Rect(x, y, width, item.RealArea / width); |
||||||
|
else |
||||||
|
return new Rect(x, y, item.RealArea / height, height); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void ComputeNextPosition(RowOrientation orientation, ref double xPos, ref double yPos, double width, double height) |
||||||
|
{ |
||||||
|
if (orientation == RowOrientation.Horizontal) |
||||||
|
yPos += height; |
||||||
|
else |
||||||
|
xPos += width; |
||||||
|
} |
||||||
|
|
||||||
|
protected override void ComputeBounds() |
||||||
|
{ |
||||||
|
this.Squarify(this.ManagedItems, new List<WeightUIElement>(), this.GetShortestSide()); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region private methods
|
||||||
|
|
||||||
|
private void Squarify(List<WeightUIElement> items, List<WeightUIElement> row, double sideLength) |
||||||
|
{ |
||||||
|
if (items.Count == 0) |
||||||
|
{ |
||||||
|
this.AddRowToLayout(row); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
WeightUIElement item = items[0]; |
||||||
|
List<WeightUIElement> row2 = new List<WeightUIElement>(row); |
||||||
|
row2.Add(item); |
||||||
|
List<WeightUIElement> items2 = new List<WeightUIElement>(items); |
||||||
|
items2.RemoveAt(0); |
||||||
|
|
||||||
|
double worst1 = this.Worst(row, sideLength); |
||||||
|
double worst2 = this.Worst(row2, sideLength); |
||||||
|
|
||||||
|
if (row.Count == 0 || worst1 > worst2) |
||||||
|
this.Squarify(items2, row2, sideLength); |
||||||
|
else |
||||||
|
{ |
||||||
|
this.AddRowToLayout(row); |
||||||
|
this.Squarify(items, new List<WeightUIElement>(), this.GetShortestSide()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void AddRowToLayout(List<WeightUIElement> row) |
||||||
|
{ |
||||||
|
base.ComputeTreeMaps(row); |
||||||
|
} |
||||||
|
|
||||||
|
private double Worst(List<WeightUIElement> row, double sideLength) |
||||||
|
{ |
||||||
|
if (row.Count == 0) return 0; |
||||||
|
|
||||||
|
double maxArea = 0; |
||||||
|
double minArea = double.MaxValue; |
||||||
|
double totalArea = 0; |
||||||
|
foreach (WeightUIElement item in row) |
||||||
|
{ |
||||||
|
maxArea = Math.Max(maxArea, item.RealArea); |
||||||
|
minArea = Math.Min(minArea, item.RealArea); |
||||||
|
totalArea += item.RealArea; |
||||||
|
} |
||||||
|
if (minArea == double.MaxValue) minArea = 0; |
||||||
|
|
||||||
|
double val1 = (sideLength * sideLength * maxArea) / (totalArea * totalArea); |
||||||
|
double val2 = (totalArea * totalArea) / (sideLength * sideLength * minArea); |
||||||
|
return Math.Max(val1, val2); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,239 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
using System.Windows.Controls; |
||||||
|
using System.Windows; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Reflection; |
||||||
|
using System.Windows.Data; |
||||||
|
|
||||||
|
namespace TreeMaps.Controls |
||||||
|
{ |
||||||
|
[TemplatePart(Name = TreeMapItem.HeaderPartName, Type = typeof(FrameworkElement))] |
||||||
|
public class TreeMapItem : HeaderedItemsControl |
||||||
|
{ |
||||||
|
#region consts
|
||||||
|
|
||||||
|
private const string HeaderPartName = "PART_Header"; |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region fields
|
||||||
|
|
||||||
|
private double _area; |
||||||
|
private TreeMaps _parentTreeMaps; |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region dependency properties
|
||||||
|
|
||||||
|
public static DependencyProperty TreeMapModeProperty |
||||||
|
= DependencyProperty.Register("TreeMapMode", typeof(TreeMapAlgo), typeof(TreeMapItem), new FrameworkPropertyMetadata(TreeMapAlgo.Squarified,FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsArrange)); |
||||||
|
|
||||||
|
public static readonly DependencyProperty ValuePropertyNameProperty |
||||||
|
= DependencyProperty.Register("ValuePropertyName", typeof(string), typeof(TreeMapItem), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsParentArrange | FrameworkPropertyMetadataOptions.AffectsParentMeasure)); |
||||||
|
|
||||||
|
public static readonly DependencyProperty LevelProperty |
||||||
|
= DependencyProperty.Register("Level", typeof(int), typeof(TreeMapItem),new FrameworkPropertyMetadata(0,FrameworkPropertyMetadataOptions.AffectsRender)); |
||||||
|
|
||||||
|
public static readonly DependencyProperty MaxDepthProperty |
||||||
|
= DependencyProperty.Register("MaxDepth", typeof(int), typeof(TreeMapItem),new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender)); |
||||||
|
|
||||||
|
public static readonly DependencyProperty MinAreaProperty |
||||||
|
= DependencyProperty.Register("MinArea", typeof(int), typeof(TreeMapItem), new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender)); |
||||||
|
|
||||||
|
public static readonly DependencyProperty ShouldRecurseProperty |
||||||
|
= DependencyProperty.Register("ShouldRecurse", typeof(bool), typeof(TreeMapItem), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender)); |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region ctors
|
||||||
|
|
||||||
|
static TreeMapItem() |
||||||
|
{ |
||||||
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(TreeMapItem), new FrameworkPropertyMetadata(typeof(TreeMapItem))); |
||||||
|
} |
||||||
|
|
||||||
|
public TreeMapItem() |
||||||
|
{ |
||||||
|
this.VerticalAlignment = VerticalAlignment.Stretch; |
||||||
|
this.HorizontalAlignment = HorizontalAlignment.Stretch; |
||||||
|
this.VerticalContentAlignment = VerticalAlignment.Stretch; |
||||||
|
this.HorizontalContentAlignment = HorizontalAlignment.Stretch; |
||||||
|
|
||||||
|
this.SnapsToDevicePixels = true; |
||||||
|
} |
||||||
|
|
||||||
|
public TreeMapItem(int level, int maxDepth, int minArea, string valuePropertyName) |
||||||
|
: this() |
||||||
|
{ |
||||||
|
this.ValuePropertyName = valuePropertyName; |
||||||
|
this.Level = level; |
||||||
|
this.MaxDepth = maxDepth; |
||||||
|
this.MinArea = minArea; |
||||||
|
} |
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region properties
|
||||||
|
|
||||||
|
public TreeMapAlgo TreeMapMode |
||||||
|
{ |
||||||
|
get { return (TreeMapAlgo)this.GetValue(TreeMapItem.TreeMapModeProperty); } |
||||||
|
set { this.SetValue(TreeMapItem.TreeMapModeProperty, value); } |
||||||
|
} |
||||||
|
|
||||||
|
public string ValuePropertyName |
||||||
|
{ |
||||||
|
get { return (string)this.GetValue(TreeMapItem.ValuePropertyNameProperty); } |
||||||
|
set { this.SetValue(TreeMapItem.ValuePropertyNameProperty, value); } |
||||||
|
} |
||||||
|
|
||||||
|
public int MaxDepth |
||||||
|
{ |
||||||
|
get { return (int)this.GetValue(TreeMapItem.MaxDepthProperty); } |
||||||
|
internal set { this.SetValue(TreeMapItem.MaxDepthProperty, value); } |
||||||
|
} |
||||||
|
|
||||||
|
public int MinArea |
||||||
|
{ |
||||||
|
get { return (int)this.GetValue(TreeMapItem.MinAreaProperty); } |
||||||
|
internal set { this.SetValue(TreeMapItem.MinAreaProperty, value); } |
||||||
|
} |
||||||
|
|
||||||
|
public bool ShouldRecurse |
||||||
|
{ |
||||||
|
get { return (bool)this.GetValue(TreeMapItem.ShouldRecurseProperty); } |
||||||
|
internal set { this.SetValue(TreeMapItem.ShouldRecurseProperty, value); } |
||||||
|
} |
||||||
|
|
||||||
|
public int Level |
||||||
|
{ |
||||||
|
get { return (int)this.GetValue(TreeMapItem.LevelProperty); } |
||||||
|
set { this.SetValue(TreeMapItem.LevelProperty, value); } |
||||||
|
} |
||||||
|
|
||||||
|
internal double Area |
||||||
|
{ |
||||||
|
get { return _area; } |
||||||
|
} |
||||||
|
|
||||||
|
internal ItemsControl ParentItemsControl |
||||||
|
{ |
||||||
|
get { return ItemsControl.ItemsControlFromItemContainer(this); } |
||||||
|
} |
||||||
|
|
||||||
|
internal TreeMaps ParentTreeMap |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
for (ItemsControl control = this.ParentItemsControl; control != null; control = ItemsControl.ItemsControlFromItemContainer(control)) |
||||||
|
{ |
||||||
|
TreeMaps view = control as TreeMaps; |
||||||
|
if (view != null) |
||||||
|
return view; |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
internal TreeMapItem ParentTreeMapItem |
||||||
|
{ |
||||||
|
get { return (this.ParentItemsControl as TreeMapItem); } |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region protected methods
|
||||||
|
|
||||||
|
protected override Size ArrangeOverride(Size arrangeBounds) |
||||||
|
{ |
||||||
|
Size size = base.ArrangeOverride(arrangeBounds); |
||||||
|
if (this.IsValidSize(size)) |
||||||
|
_area = size.Width * size.Height; |
||||||
|
else |
||||||
|
_area = 0; |
||||||
|
this.UpdateShouldRecurse(); |
||||||
|
|
||||||
|
return size; |
||||||
|
} |
||||||
|
|
||||||
|
protected override DependencyObject GetContainerForItemOverride() |
||||||
|
{ |
||||||
|
return new TreeMapItem(this.Level+1,this.MaxDepth,this.MinArea,this.ValuePropertyName); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
protected override void OnVisualParentChanged(DependencyObject oldParent) |
||||||
|
{ |
||||||
|
base.OnVisualParentChanged(oldParent); |
||||||
|
_parentTreeMaps = this.ParentTreeMap; |
||||||
|
if (_parentTreeMaps != null) |
||||||
|
{ |
||||||
|
Binding bindingMode = new Binding(TreeMaps.TreeMapModeProperty.Name); |
||||||
|
bindingMode.Source = _parentTreeMaps; |
||||||
|
BindingOperations.SetBinding(this, TreeMapItem.TreeMapModeProperty, bindingMode); |
||||||
|
|
||||||
|
Binding bindingValue = new Binding(TreeMaps.ValuePropertyNameProperty.Name); |
||||||
|
bindingValue.Source = _parentTreeMaps; |
||||||
|
BindingOperations.SetBinding(this, TreeMapItem.ValuePropertyNameProperty, bindingValue); |
||||||
|
|
||||||
|
Binding bindingMinArea = new Binding(TreeMaps.MinAreaProperty.Name); |
||||||
|
bindingMinArea.Source = _parentTreeMaps; |
||||||
|
BindingOperations.SetBinding(this, TreeMapItem.MinAreaProperty, bindingMinArea); |
||||||
|
|
||||||
|
Binding bindingMaxDepth = new Binding(TreeMaps.MaxDepthProperty.Name); |
||||||
|
bindingMaxDepth.Source = _parentTreeMaps; |
||||||
|
BindingOperations.SetBinding(this, TreeMapItem.MaxDepthProperty, bindingMaxDepth); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) |
||||||
|
{ |
||||||
|
base.OnPropertyChanged(e); |
||||||
|
if (e.Property == TreeMapItem.ValuePropertyNameProperty || e.Property == TreeMapItem.DataContextProperty) |
||||||
|
{ |
||||||
|
if (this.ValuePropertyName != null && this.DataContext != null) |
||||||
|
{ |
||||||
|
Binding binding = new Binding(this.ValuePropertyName); |
||||||
|
binding.Source = this.DataContext; |
||||||
|
BindingOperations.SetBinding(this, TreeMapsPanel.WeightProperty, binding); |
||||||
|
} |
||||||
|
} |
||||||
|
else if (e.Property == TreeMapItem.MaxDepthProperty) |
||||||
|
this.UpdateShouldRecurse(); |
||||||
|
else if (e.Property == TreeMapItem.MinAreaProperty) |
||||||
|
this.UpdateShouldRecurse(); |
||||||
|
else if (e.Property == TreeMapItem.LevelProperty) |
||||||
|
this.UpdateShouldRecurse(); |
||||||
|
} |
||||||
|
|
||||||
|
protected override bool IsItemItsOwnContainerOverride(object item) |
||||||
|
{ |
||||||
|
return (item is TreeMapItem); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region private methods
|
||||||
|
|
||||||
|
private bool IsValidSize(Size size) |
||||||
|
{ |
||||||
|
return (!size.IsEmpty && size.Width > 0 && size.Width != double.NaN && size.Height > 0 && size.Height != double.NaN); |
||||||
|
} |
||||||
|
|
||||||
|
private void UpdateShouldRecurse() |
||||||
|
{ |
||||||
|
if (!this.HasHeader) |
||||||
|
{ |
||||||
|
this.ShouldRecurse = false; |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
this.ShouldRecurse = ((this.MaxDepth == 0) || (this.Level < this.MaxDepth)) && ((this.MinArea == 0) || (this.Area >this.MinArea)); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,92 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
using System.Windows.Controls; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Shapes; |
||||||
|
using System.Windows.Media; |
||||||
|
|
||||||
|
namespace TreeMaps.Controls |
||||||
|
{ |
||||||
|
|
||||||
|
public class TreeMaps: ItemsControl |
||||||
|
{ |
||||||
|
#region fields
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region dependency properties
|
||||||
|
|
||||||
|
public static DependencyProperty TreeMapModeProperty |
||||||
|
= DependencyProperty.Register("TreeMapMode", typeof(TreeMapAlgo), typeof(TreeMaps), new FrameworkPropertyMetadata(TreeMapAlgo.Squarified,FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsArrange)); |
||||||
|
|
||||||
|
public static DependencyProperty ValuePropertyNameProperty |
||||||
|
= DependencyProperty.Register("ValuePropertyName", typeof(string), typeof(TreeMaps),new FrameworkPropertyMetadata(null,FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsArrange)); |
||||||
|
|
||||||
|
public static DependencyProperty MaxDepthProperty |
||||||
|
= DependencyProperty.Register("MaxDepth", typeof(int), typeof(TreeMaps),new FrameworkPropertyMetadata(1,FrameworkPropertyMetadataOptions.AffectsRender)); |
||||||
|
|
||||||
|
public static readonly DependencyProperty MinAreaProperty |
||||||
|
= DependencyProperty.Register("MinArea", typeof(int), typeof(TreeMaps),new FrameworkPropertyMetadata(64,FrameworkPropertyMetadataOptions.AffectsRender)); |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ctors
|
||||||
|
|
||||||
|
static TreeMaps() |
||||||
|
{ |
||||||
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(TreeMaps), new FrameworkPropertyMetadata(typeof(TreeMaps))); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region properties
|
||||||
|
|
||||||
|
public TreeMapAlgo TreeMapMode |
||||||
|
{ |
||||||
|
get { return (TreeMapAlgo)this.GetValue(TreeMaps.TreeMapModeProperty); } |
||||||
|
set { this.SetValue(TreeMaps.TreeMapModeProperty, value); } |
||||||
|
} |
||||||
|
|
||||||
|
public int MaxDepth |
||||||
|
{ |
||||||
|
get { return (int)this.GetValue(TreeMaps.MaxDepthProperty); } |
||||||
|
set { this.SetValue(TreeMaps.MaxDepthProperty, value); } |
||||||
|
} |
||||||
|
|
||||||
|
public int MinArea |
||||||
|
{ |
||||||
|
get { return (int)this.GetValue(TreeMaps.MinAreaProperty); } |
||||||
|
set { this.SetValue(TreeMaps.MinAreaProperty, value); } |
||||||
|
} |
||||||
|
|
||||||
|
public string ValuePropertyName |
||||||
|
{ |
||||||
|
get { return (string)this.GetValue(TreeMaps.ValuePropertyNameProperty); } |
||||||
|
set { this.SetValue(TreeMaps.ValuePropertyNameProperty, value); } |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region protected methods
|
||||||
|
|
||||||
|
protected override DependencyObject GetContainerForItemOverride() |
||||||
|
{ |
||||||
|
return new TreeMapItem(1, this.MaxDepth, this.MinArea, this.ValuePropertyName); |
||||||
|
} |
||||||
|
|
||||||
|
protected override bool IsItemItsOwnContainerOverride(object item) |
||||||
|
{ |
||||||
|
return (item is TreeMapItem); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public enum TreeMapAlgo |
||||||
|
{ |
||||||
|
Standard, |
||||||
|
Squarified |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,292 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
using System.Windows.Controls; |
||||||
|
using System.Windows; |
||||||
|
|
||||||
|
namespace TreeMaps.Controls |
||||||
|
{ |
||||||
|
public class TreeMapsPanel : Panel |
||||||
|
{ |
||||||
|
#region fields
|
||||||
|
|
||||||
|
private Rect _emptyArea; |
||||||
|
private double _weightSum = 0; |
||||||
|
private List<WeightUIElement> _items = new List<WeightUIElement>(); |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region dependency properties
|
||||||
|
|
||||||
|
public static readonly DependencyProperty |
||||||
|
WeightProperty = DependencyProperty.RegisterAttached("Weight", typeof(double),typeof(TreeMapsPanel),new FrameworkPropertyMetadata(1.0,FrameworkPropertyMetadataOptions.AffectsParentArrange|FrameworkPropertyMetadataOptions.AffectsParentMeasure)); |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region enum
|
||||||
|
|
||||||
|
protected enum RowOrientation |
||||||
|
{ |
||||||
|
Horizontal, |
||||||
|
Vertical |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region properties
|
||||||
|
|
||||||
|
public static double GetWeight(DependencyObject uiElement) |
||||||
|
{ |
||||||
|
if (uiElement == null) |
||||||
|
return 0; |
||||||
|
else |
||||||
|
return (double)uiElement.GetValue(TreeMapsPanel.WeightProperty); |
||||||
|
} |
||||||
|
|
||||||
|
public static void SetWeight(DependencyObject uiElement, double value) |
||||||
|
{ |
||||||
|
if (uiElement != null) |
||||||
|
uiElement.SetValue(TreeMapsPanel.WeightProperty, value); |
||||||
|
} |
||||||
|
|
||||||
|
protected Rect EmptyArea |
||||||
|
{ |
||||||
|
get { return _emptyArea; } |
||||||
|
set { _emptyArea = value; } |
||||||
|
} |
||||||
|
|
||||||
|
protected List<WeightUIElement> ManagedItems |
||||||
|
{ |
||||||
|
get { return _items; } |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region protected methods
|
||||||
|
|
||||||
|
protected override Size ArrangeOverride(Size arrangeSize) |
||||||
|
{ |
||||||
|
foreach (WeightUIElement child in this.ManagedItems) |
||||||
|
child.UIElement.Arrange(new Rect(child.ComputedLocation, child.ComputedSize)); |
||||||
|
return arrangeSize; |
||||||
|
} |
||||||
|
|
||||||
|
protected override Size MeasureOverride(Size constraint) |
||||||
|
{ |
||||||
|
this.EmptyArea = new Rect(0, 0, constraint.Width, constraint.Height); |
||||||
|
this.PrepareItems(); |
||||||
|
|
||||||
|
double area = this.EmptyArea.Width * this.EmptyArea.Height; |
||||||
|
foreach (WeightUIElement item in this.ManagedItems) |
||||||
|
item.RealArea = area * item.Weight / _weightSum; |
||||||
|
|
||||||
|
this.ComputeBounds(); |
||||||
|
|
||||||
|
foreach (WeightUIElement child in this.ManagedItems) |
||||||
|
{ |
||||||
|
if (this.IsValidSize(child.ComputedSize)) |
||||||
|
child.UIElement.Measure(child.ComputedSize); |
||||||
|
else |
||||||
|
child.UIElement.Measure(new Size(0, 0)); |
||||||
|
} |
||||||
|
|
||||||
|
return constraint; |
||||||
|
} |
||||||
|
|
||||||
|
protected virtual void ComputeBounds() |
||||||
|
{ |
||||||
|
this.ComputeTreeMaps(this.ManagedItems); |
||||||
|
} |
||||||
|
|
||||||
|
protected double GetShortestSide() |
||||||
|
{ |
||||||
|
return Math.Min(this.EmptyArea.Width, this.EmptyArea.Height); |
||||||
|
} |
||||||
|
|
||||||
|
protected RowOrientation GetOrientation() |
||||||
|
{ |
||||||
|
return (this.EmptyArea.Width > this.EmptyArea.Height ? RowOrientation.Horizontal : RowOrientation.Vertical); |
||||||
|
} |
||||||
|
|
||||||
|
protected virtual Rect GetRectangle(RowOrientation orientation, WeightUIElement item, double x, double y, double width, double height) |
||||||
|
{ |
||||||
|
if (orientation == RowOrientation.Horizontal) |
||||||
|
return new Rect(x, y, item.RealArea / height, height); |
||||||
|
else |
||||||
|
return new Rect(x, y, width, item.RealArea / width); |
||||||
|
} |
||||||
|
|
||||||
|
protected virtual void ComputeNextPosition(RowOrientation orientation, ref double xPos, ref double yPos, double width, double height) |
||||||
|
{ |
||||||
|
if (orientation == RowOrientation.Horizontal) |
||||||
|
xPos += width; |
||||||
|
else |
||||||
|
yPos += height; |
||||||
|
} |
||||||
|
|
||||||
|
protected void ComputeTreeMaps(List<WeightUIElement> items) |
||||||
|
{ |
||||||
|
RowOrientation orientation = this.GetOrientation(); |
||||||
|
|
||||||
|
double areaSum = 0; |
||||||
|
|
||||||
|
foreach (WeightUIElement item in items) |
||||||
|
areaSum += item.RealArea; |
||||||
|
|
||||||
|
Rect currentRow; |
||||||
|
if (orientation == RowOrientation.Horizontal) |
||||||
|
{ |
||||||
|
currentRow = new Rect(_emptyArea.X, _emptyArea.Y, areaSum / _emptyArea.Height, _emptyArea.Height); |
||||||
|
_emptyArea = new Rect(_emptyArea.X + currentRow.Width, _emptyArea.Y, Math.Max(0, _emptyArea.Width - currentRow.Width), _emptyArea.Height); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
currentRow = new Rect(_emptyArea.X, _emptyArea.Y, _emptyArea.Width, areaSum / _emptyArea.Width); |
||||||
|
_emptyArea = new Rect(_emptyArea.X, _emptyArea.Y + currentRow.Height, _emptyArea.Width, Math.Max(0, _emptyArea.Height - currentRow.Height)); |
||||||
|
} |
||||||
|
|
||||||
|
double prevX = currentRow.X; |
||||||
|
double prevY = currentRow.Y; |
||||||
|
|
||||||
|
foreach (WeightUIElement item in items) |
||||||
|
{ |
||||||
|
Rect rect = this.GetRectangle(orientation, item, prevX, prevY, currentRow.Width, currentRow.Height); |
||||||
|
|
||||||
|
item.AspectRatio = rect.Width / rect.Height; |
||||||
|
item.ComputedSize = rect.Size; |
||||||
|
item.ComputedLocation = rect.Location; |
||||||
|
|
||||||
|
this.ComputeNextPosition(orientation, ref prevX, ref prevY, rect.Width, rect.Height); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region private methods
|
||||||
|
|
||||||
|
private bool IsValidSize(Size size) |
||||||
|
{ |
||||||
|
return (!size.IsEmpty && size.Width > 0 && size.Width != double.NaN && size.Height > 0 && size.Height != double.NaN); |
||||||
|
} |
||||||
|
|
||||||
|
private bool IsValidItem(WeightUIElement item) |
||||||
|
{ |
||||||
|
return (item != null && item.Weight != double.NaN && Math.Round(item.Weight, 0) != 0); |
||||||
|
} |
||||||
|
|
||||||
|
private void PrepareItems() |
||||||
|
{ |
||||||
|
|
||||||
|
_weightSum = 0; |
||||||
|
this.ManagedItems.Clear(); |
||||||
|
|
||||||
|
|
||||||
|
foreach (UIElement child in this.Children) |
||||||
|
{ |
||||||
|
WeightUIElement element = new WeightUIElement(child, TreeMapsPanel.GetWeight(child)); |
||||||
|
if (this.IsValidItem(element)) |
||||||
|
{ |
||||||
|
_weightSum += element.Weight; |
||||||
|
this.ManagedItems.Add(element); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
element.ComputedSize = Size.Empty; |
||||||
|
element.ComputedLocation = new Point(0, 0); |
||||||
|
element.UIElement.Measure(element.ComputedSize); |
||||||
|
element.UIElement.Visibility = Visibility.Collapsed; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
this.ManagedItems.Sort(WeightUIElement.CompareByValueDecreasing); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region inner classes
|
||||||
|
|
||||||
|
protected class WeightUIElement |
||||||
|
{ |
||||||
|
#region fields
|
||||||
|
|
||||||
|
private double _weight; |
||||||
|
private double _area; |
||||||
|
private UIElement _element; |
||||||
|
private Size _desiredSize; |
||||||
|
private Point _desiredLocation; |
||||||
|
private double _ratio; |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ctors
|
||||||
|
|
||||||
|
public WeightUIElement(UIElement element, double weight) |
||||||
|
{ |
||||||
|
_element = element; |
||||||
|
_weight = weight; |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region properties
|
||||||
|
|
||||||
|
internal Size ComputedSize |
||||||
|
{ |
||||||
|
get { return _desiredSize; } |
||||||
|
set { _desiredSize = value; } |
||||||
|
} |
||||||
|
|
||||||
|
internal Point ComputedLocation |
||||||
|
{ |
||||||
|
get { return _desiredLocation; } |
||||||
|
set { _desiredLocation = value; } |
||||||
|
} |
||||||
|
public double AspectRatio |
||||||
|
{ |
||||||
|
get { return _ratio; } |
||||||
|
set { _ratio = value; } |
||||||
|
} |
||||||
|
public double Weight |
||||||
|
{ |
||||||
|
get { return _weight; } |
||||||
|
} |
||||||
|
public double RealArea |
||||||
|
{ |
||||||
|
get { return _area; } |
||||||
|
set { _area = value; } |
||||||
|
} |
||||||
|
|
||||||
|
public UIElement UIElement |
||||||
|
{ |
||||||
|
get { return _element; } |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region static members
|
||||||
|
|
||||||
|
public static int CompareByValueDecreasing(WeightUIElement x, WeightUIElement y) |
||||||
|
{ |
||||||
|
if (x == null) |
||||||
|
{ |
||||||
|
if (y == null) |
||||||
|
return -1; |
||||||
|
else |
||||||
|
return 0; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
if (y == null) |
||||||
|
return 1; |
||||||
|
else |
||||||
|
return x.Weight.CompareTo(y.Weight) * -1; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,40 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Data; |
||||||
|
|
||||||
|
namespace TreeMaps.Controls |
||||||
|
{ |
||||||
|
public class ValueDataTemplate : HierarchicalDataTemplate |
||||||
|
{ |
||||||
|
#region fields
|
||||||
|
|
||||||
|
private BindingBase _valueBinding; |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ctors
|
||||||
|
|
||||||
|
public ValueDataTemplate() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public ValueDataTemplate(object dataType) |
||||||
|
: base(dataType) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region properties
|
||||||
|
|
||||||
|
public BindingBase AreaValue |
||||||
|
{ |
||||||
|
get { return _valueBinding; } |
||||||
|
set { _valueBinding = value; } |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,62 @@ |
|||||||
|
#region Using directives
|
||||||
|
|
||||||
|
using System.Reflection; |
||||||
|
using System.Runtime.CompilerServices; |
||||||
|
using System.Resources; |
||||||
|
using System.Globalization; |
||||||
|
using System.Windows; |
||||||
|
using System.Runtime.InteropServices; |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("SquarifiedTreeMaps")] |
||||||
|
[assembly: AssemblyDescription("")] |
||||||
|
[assembly: AssemblyConfiguration("")] |
||||||
|
[assembly: AssemblyCompany("")] |
||||||
|
[assembly: AssemblyProduct("SquarifiedTreeMaps")] |
||||||
|
[assembly: AssemblyCopyright("Copyright @ 2007")] |
||||||
|
[assembly: AssemblyTrademark("")] |
||||||
|
[assembly: AssemblyCulture("")] |
||||||
|
[assembly: ComVisible(false)] |
||||||
|
|
||||||
|
//In order to begin building localizable applications, set
|
||||||
|
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||||
|
//inside a <PropertyGroup>. For example, if you are using US english
|
||||||
|
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||||
|
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||||
|
//the line below to match the UICulture setting in the project file.
|
||||||
|
|
||||||
|
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||||
|
|
||||||
|
|
||||||
|
// Specifies the location in which theme dictionaries are stored for types in an assembly.
|
||||||
|
[assembly: ThemeInfo( |
||||||
|
// Specifies the location of system theme-specific resource dictionaries for this project.
|
||||||
|
// The default setting in this project is "None" since this default project does not
|
||||||
|
// include these user-defined theme files:
|
||||||
|
// Themes\Aero.NormalColor.xaml
|
||||||
|
// Themes\Classic.xaml
|
||||||
|
// Themes\Luna.Homestead.xaml
|
||||||
|
// Themes\Luna.Metallic.xaml
|
||||||
|
// Themes\Luna.NormalColor.xaml
|
||||||
|
// Themes\Royale.NormalColor.xaml
|
||||||
|
ResourceDictionaryLocation.None, |
||||||
|
|
||||||
|
// Specifies the location of the system non-theme specific resource dictionary:
|
||||||
|
// Themes\generic.xaml
|
||||||
|
ResourceDictionaryLocation.SourceAssembly)] |
||||||
|
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
[assembly: AssemblyVersion("1.0.*")] |
||||||
@ -0,0 +1,63 @@ |
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:2.0.50727.312
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace TreeMaps.Properties { |
||||||
|
using System; |
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
|
/// </summary>
|
||||||
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||||
|
// class via a tool like ResGen or Visual Studio.
|
||||||
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
|
// with the /str option, or rebuild your VS project.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] |
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
||||||
|
internal class Resources { |
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan; |
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture; |
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] |
||||||
|
internal Resources() { |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager { |
||||||
|
get { |
||||||
|
if (object.ReferenceEquals(resourceMan, null)) { |
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TreeMaps.Properties.Resources", typeof(Resources).Assembly); |
||||||
|
resourceMan = temp; |
||||||
|
} |
||||||
|
return resourceMan; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
|
/// resource lookups using this strongly typed resource class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
||||||
|
internal static global::System.Globalization.CultureInfo Culture { |
||||||
|
get { |
||||||
|
return resourceCulture; |
||||||
|
} |
||||||
|
set { |
||||||
|
resourceCulture = value; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,117 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<root> |
||||||
|
<!-- |
||||||
|
Microsoft ResX Schema |
||||||
|
|
||||||
|
Version 2.0 |
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format |
||||||
|
that is mostly human readable. The generation and parsing of the |
||||||
|
various data types are done through the TypeConverter classes |
||||||
|
associated with the data types. |
||||||
|
|
||||||
|
Example: |
||||||
|
|
||||||
|
... ado.net/XML headers & schema ... |
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader> |
||||||
|
<resheader name="version">2.0</resheader> |
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value> |
||||||
|
</data> |
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
||||||
|
<comment>This is a comment</comment> |
||||||
|
</data> |
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple |
||||||
|
name/value pairs. |
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a |
||||||
|
type or mimetype. Type corresponds to a .NET class that support |
||||||
|
text/value conversion through the TypeConverter architecture. |
||||||
|
Classes that don't support this are serialized and stored with the |
||||||
|
mimetype set. |
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the |
||||||
|
ResXResourceReader how to depersist the object. This is currently not |
||||||
|
extensible. For a given mimetype the value must be set accordingly: |
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format |
||||||
|
that the ResXResourceWriter will generate, however the reader can |
||||||
|
read any of the formats listed below. |
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64 |
||||||
|
value : The object must be serialized with |
||||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter |
||||||
|
: and then encoded with base64 encoding. |
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64 |
||||||
|
value : The object must be serialized with |
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
||||||
|
: and then encoded with base64 encoding. |
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64 |
||||||
|
value : The object must be serialized into a byte array |
||||||
|
: using a System.ComponentModel.TypeConverter |
||||||
|
: and then encoded with base64 encoding. |
||||||
|
--> |
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
||||||
|
<xsd:element name="root" msdata:IsDataSet="true"> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:choice maxOccurs="unbounded"> |
||||||
|
<xsd:element name="metadata"> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:sequence> |
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
||||||
|
</xsd:sequence> |
||||||
|
<xsd:attribute name="name" type="xsd:string" /> |
||||||
|
<xsd:attribute name="type" type="xsd:string" /> |
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" /> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
<xsd:element name="assembly"> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:attribute name="alias" type="xsd:string" /> |
||||||
|
<xsd:attribute name="name" type="xsd:string" /> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
<xsd:element name="data"> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:sequence> |
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
||||||
|
</xsd:sequence> |
||||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> |
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
<xsd:element name="resheader"> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:sequence> |
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||||
|
</xsd:sequence> |
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" /> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
</xsd:choice> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
</xsd:schema> |
||||||
|
<resheader name="resmimetype"> |
||||||
|
<value>text/microsoft-resx</value> |
||||||
|
</resheader> |
||||||
|
<resheader name="version"> |
||||||
|
<value>2.0</value> |
||||||
|
</resheader> |
||||||
|
<resheader name="reader"> |
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||||
|
</resheader> |
||||||
|
<resheader name="writer"> |
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||||
|
</resheader> |
||||||
|
</root> |
||||||
@ -0,0 +1,26 @@ |
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:2.0.50727.312
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace TreeMaps.Properties { |
||||||
|
|
||||||
|
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] |
||||||
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { |
||||||
|
|
||||||
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); |
||||||
|
|
||||||
|
public static Settings Default { |
||||||
|
get { |
||||||
|
return defaultInstance; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,7 @@ |
|||||||
|
<?xml version='1.0' encoding='iso-8859-1'?> |
||||||
|
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> |
||||||
|
<Profiles> |
||||||
|
<Profile Name="(Default)" /> |
||||||
|
</Profiles> |
||||||
|
<Settings /> |
||||||
|
</SettingsFile> |
||||||
@ -0,0 +1,126 @@ |
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||||
|
xmlns:l="clr-namespace:TreeMaps.Controls" |
||||||
|
> |
||||||
|
<Style TargetType="{x:Type l:TreeMaps}"> |
||||||
|
|
||||||
|
<Setter Property="ItemsPanel"> |
||||||
|
<Setter.Value> |
||||||
|
<ItemsPanelTemplate> |
||||||
|
<l:SquarifiedTreeMapsPanel SnapsToDevicePixels="True"/> |
||||||
|
</ItemsPanelTemplate> |
||||||
|
</Setter.Value> |
||||||
|
</Setter> |
||||||
|
|
||||||
|
<Setter Property="Template"> |
||||||
|
<Setter.Value> |
||||||
|
<ControlTemplate TargetType="{x:Type l:TreeMaps}"> |
||||||
|
<Border |
||||||
|
Name="Bd" |
||||||
|
BorderBrush="{TemplateBinding BorderBrush}" |
||||||
|
BorderThickness="{TemplateBinding BorderThickness}" |
||||||
|
Background="{TemplateBinding Background}" |
||||||
|
Padding="{TemplateBinding Padding}" |
||||||
|
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" |
||||||
|
> |
||||||
|
<ItemsPresenter/> |
||||||
|
</Border> |
||||||
|
</ControlTemplate> |
||||||
|
</Setter.Value> |
||||||
|
</Setter> |
||||||
|
|
||||||
|
<Style.Triggers> |
||||||
|
<Trigger Property="TreeMapMode" Value="Standard"> |
||||||
|
<Setter Property="ItemsPanel"> |
||||||
|
<Setter.Value> |
||||||
|
<ItemsPanelTemplate> |
||||||
|
<l:TreeMapsPanel SnapsToDevicePixels="True"/> |
||||||
|
</ItemsPanelTemplate> |
||||||
|
</Setter.Value> |
||||||
|
</Setter> |
||||||
|
</Trigger> |
||||||
|
</Style.Triggers> |
||||||
|
|
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style TargetType="{x:Type l:TreeMapItem}"> |
||||||
|
|
||||||
|
<Setter Property="ItemsPanel"> |
||||||
|
<Setter.Value> |
||||||
|
<ItemsPanelTemplate> |
||||||
|
<l:SquarifiedTreeMapsPanel SnapsToDevicePixels="True"/> |
||||||
|
</ItemsPanelTemplate> |
||||||
|
</Setter.Value> |
||||||
|
</Setter> |
||||||
|
|
||||||
|
<Setter Property="Template"> |
||||||
|
<Setter.Value> |
||||||
|
<ControlTemplate TargetType="{x:Type l:TreeMapItem}"> |
||||||
|
<Border |
||||||
|
Background="{TemplateBinding Background}" |
||||||
|
BorderBrush="{TemplateBinding BorderBrush}" |
||||||
|
BorderThickness="{TemplateBinding BorderThickness}" |
||||||
|
Padding="{TemplateBinding Padding}" |
||||||
|
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" |
||||||
|
Visibility="{TemplateBinding Visibility}" |
||||||
|
Margin="{TemplateBinding Margin}" |
||||||
|
> |
||||||
|
<Grid> |
||||||
|
<ContentPresenter |
||||||
|
x:Name="PART_Header" |
||||||
|
ContentSource="Header" |
||||||
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" |
||||||
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" |
||||||
|
/> |
||||||
|
<ItemsPresenter |
||||||
|
x:Name="ItemsHost" |
||||||
|
Grid.Row="1" |
||||||
|
/> |
||||||
|
</Grid> |
||||||
|
</Border> |
||||||
|
</ControlTemplate> |
||||||
|
</Setter.Value> |
||||||
|
</Setter> |
||||||
|
<Style.Triggers> |
||||||
|
<Trigger Property="ShouldRecurse" Value="false"> |
||||||
|
<Setter Property="Template"> |
||||||
|
<Setter.Value> |
||||||
|
<ControlTemplate TargetType="{x:Type l:TreeMapItem}"> |
||||||
|
<Border |
||||||
|
Background="{TemplateBinding Background}" |
||||||
|
BorderBrush="{TemplateBinding BorderBrush}" |
||||||
|
BorderThickness="{TemplateBinding BorderThickness}" |
||||||
|
Padding="{TemplateBinding Padding}" |
||||||
|
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" |
||||||
|
Visibility="{TemplateBinding Visibility}" |
||||||
|
Margin="{TemplateBinding Margin}" |
||||||
|
> |
||||||
|
<Grid> |
||||||
|
<ContentPresenter |
||||||
|
x:Name="PART_Header" |
||||||
|
ContentSource="Header" |
||||||
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" |
||||||
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" |
||||||
|
/> |
||||||
|
</Grid> |
||||||
|
</Border> |
||||||
|
</ControlTemplate> |
||||||
|
</Setter.Value> |
||||||
|
</Setter> |
||||||
|
</Trigger> |
||||||
|
|
||||||
|
<Trigger Property="TreeMapMode" Value="Standard"> |
||||||
|
<Setter Property="ItemsPanel"> |
||||||
|
<Setter.Value> |
||||||
|
<ItemsPanelTemplate> |
||||||
|
<l:TreeMapsPanel SnapsToDevicePixels="True"/> |
||||||
|
</ItemsPanelTemplate> |
||||||
|
</Setter.Value> |
||||||
|
</Setter> |
||||||
|
</Trigger> |
||||||
|
|
||||||
|
</Style.Triggers> |
||||||
|
|
||||||
|
</Style> |
||||||
|
|
||||||
|
</ResourceDictionary> |
||||||
@ -0,0 +1,104 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> |
||||||
|
<PropertyGroup> |
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||||
|
<ProjectGuid>{3ED2897F-1A8A-4106-89D2-4D342860D480}</ProjectGuid> |
||||||
|
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> |
||||||
|
<RootNamespace>TreeMaps</RootNamespace> |
||||||
|
<AssemblyName>TreeMaps</AssemblyName> |
||||||
|
<WarningLevel>4</WarningLevel> |
||||||
|
<OutputType>Library</OutputType> |
||||||
|
<MinFrameworkVersionRequired>3.0</MinFrameworkVersionRequired> |
||||||
|
<Install>true</Install> |
||||||
|
<InstallFrom>Web</InstallFrom> |
||||||
|
<UpdateEnabled>true</UpdateEnabled> |
||||||
|
<UpdateMode>Foreground</UpdateMode> |
||||||
|
<UpdateInterval>7</UpdateInterval> |
||||||
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits> |
||||||
|
<UpdatePeriodically>false</UpdatePeriodically> |
||||||
|
<UpdateRequired>false</UpdateRequired> |
||||||
|
<MapFileExtensions>false</MapFileExtensions> |
||||||
|
<ApplicationVersion>1.0.0.*</ApplicationVersion> |
||||||
|
<IsWebBootstrapper>true</IsWebBootstrapper> |
||||||
|
<BootstrapperEnabled>true</BootstrapperEnabled> |
||||||
|
<PublishUrl>Publish\</PublishUrl> |
||||||
|
<StartupObject> |
||||||
|
</StartupObject> |
||||||
|
<TargetFrameworkProfile /> |
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||||
|
<DebugSymbols>true</DebugSymbols> |
||||||
|
<DebugType>full</DebugType> |
||||||
|
<Optimize>false</Optimize> |
||||||
|
<OutputPath>.\bin\Debug\</OutputPath> |
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||||
|
<DebugSymbols>false</DebugSymbols> |
||||||
|
<Optimize>true</Optimize> |
||||||
|
<OutputPath>.\bin\Release\</OutputPath> |
||||||
|
<DefineConstants>TRACE</DefineConstants> |
||||||
|
</PropertyGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Reference Include="mscorlib" /> |
||||||
|
<Reference Include="System" /> |
||||||
|
<Reference Include="System.Core"> |
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||||
|
</Reference> |
||||||
|
<Reference Include="System.Data" /> |
||||||
|
<Reference Include="System.Data.DataSetExtensions"> |
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||||
|
</Reference> |
||||||
|
<Reference Include="System.Xaml"> |
||||||
|
<RequiredTargetFramework>4.0</RequiredTargetFramework> |
||||||
|
</Reference> |
||||||
|
<Reference Include="System.Xml" /> |
||||||
|
<Reference Include="System.Xml.Linq"> |
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||||
|
</Reference> |
||||||
|
<Reference Include="WindowsBase" /> |
||||||
|
<Reference Include="PresentationCore" /> |
||||||
|
<Reference Include="PresentationFramework" /> |
||||||
|
<Reference Include="UIAutomationProvider" /> |
||||||
|
<Reference Include="UIAutomationTypes" /> |
||||||
|
<Reference Include="ReachFramework" /> |
||||||
|
<Reference Include="System.Printing" /> |
||||||
|
<Reference Include="System.ServiceModel" /> |
||||||
|
<Reference Include="System.Runtime.Serialization" /> |
||||||
|
<Reference Include="System.IdentityModel" /> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Page Include="Themes\generic.xaml" /> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Compile Include="Controls\SquarifiedTreeMapsPanel.cs" /> |
||||||
|
<Compile Include="Controls\TreeMapItem.cs" /> |
||||||
|
<Compile Include="Controls\TreeMaps.cs" /> |
||||||
|
<Compile Include="Controls\TreeMapsPanel.cs" /> |
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" /> |
||||||
|
<EmbeddedResource Include="Properties\Resources.resx"> |
||||||
|
<Generator>ResXFileCodeGenerator</Generator> |
||||||
|
<SubType>Designer</SubType> |
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput> |
||||||
|
</EmbeddedResource> |
||||||
|
<None Include="Properties\Settings.settings"> |
||||||
|
<Generator>SettingsSingleFileGenerator</Generator> |
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput> |
||||||
|
</None> |
||||||
|
<Compile Include="Properties\Resources.Designer.cs"> |
||||||
|
<AutoGen>True</AutoGen> |
||||||
|
<DesignTime>True</DesignTime> |
||||||
|
<DependentUpon>Resources.resx</DependentUpon> |
||||||
|
</Compile> |
||||||
|
<Compile Include="Properties\Settings.Designer.cs"> |
||||||
|
<AutoGen>True</AutoGen> |
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput> |
||||||
|
<DependentUpon>Settings.settings</DependentUpon> |
||||||
|
</Compile> |
||||||
|
<AppDesigner Include="Properties\" /> |
||||||
|
</ItemGroup> |
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" /> |
||||||
|
</Project> |
||||||
@ -0,0 +1,6 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> |
||||||
|
<PropertyGroup> |
||||||
|
<ProjectView>ShowAllFiles</ProjectView> |
||||||
|
</PropertyGroup> |
||||||
|
</Project> |
||||||
Loading…
Reference in new issue