protected override Rect GetRectangle(RowOrientation orientation, TreeMapItem 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);
 }
예제 #2
0
 public static int CompareByValueDecreasing(TreeMapItem x, TreeMapItem y)
 {
     if (x == null)
     {
         return y == null ? -1 : 0;
     }
     else
     {
         return y == null ? 1 : x.Weight.CompareTo(y.Weight) * -1;
     }
 }
        private void PrepareItems()
        {
            _totalWeight = 0;
            Items.Clear();

            foreach (var child in Children)
            {
                var element = new TreeMapItem(child, GetWeight(child));
                if (this.IsValidItem(element))
                {
                    _totalWeight += element.Weight;
                    Items.Add(element);
                }
                else
                {
                    element.ComputedSize = Size.Empty;
                    element.ComputedLocation = new Point(0, 0);
                    element.UIElement.Measure(element.ComputedSize);
                    element.UIElement.Visibility = Visibility.Collapsed;
                }
            }

            Items.Sort(TreeMapItem.CompareByValueDecreasing);
        }
 private bool IsValidItem(TreeMapItem item)
 {
     return (item != null && !double.IsNaN(item.Weight) && Math.Round(item.Weight, 0) != 0);
 }