From 819024be9fbad4bb42501492d02b97d0e5d19ed4 Mon Sep 17 00:00:00 2001 From: PeterForstmeier Date: Mon, 19 Sep 2011 21:06:24 +0200 Subject: [PATCH] Add TreeMaps.csproj again --- .../CodeQuality/CodeQualityAnalysis.csproj | 4 + .../Controls/SquarifiedTreeMapsPanel.cs | 90 ++++++ .../TreeMaps/Controls/TreeMapItem.cs | 239 ++++++++++++++ .../CodeQuality/TreeMaps/Controls/TreeMaps.cs | 92 ++++++ .../TreeMaps/Controls/TreeMapsPanel.cs | 292 ++++++++++++++++++ .../TreeMaps/Controls/ValueDataTemplate.cs | 40 +++ .../TreeMaps/Properties/AssemblyInfo.cs | 62 ++++ .../TreeMaps/Properties/Resources.Designer.cs | 63 ++++ .../TreeMaps/Properties/Resources.resx | 117 +++++++ .../TreeMaps/Properties/Settings.Designer.cs | 26 ++ .../TreeMaps/Properties/Settings.settings | 7 + .../CodeQuality/TreeMaps/Themes/generic.xaml | 126 ++++++++ .../CodeQuality/TreeMaps/TreeMaps.csproj | 104 +++++++ .../CodeQuality/TreeMaps/TreeMaps.csproj.user | 6 + 14 files changed, 1268 insertions(+) create mode 100644 src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/SquarifiedTreeMapsPanel.cs create mode 100644 src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/TreeMapItem.cs create mode 100644 src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/TreeMaps.cs create mode 100644 src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/TreeMapsPanel.cs create mode 100644 src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/ValueDataTemplate.cs create mode 100644 src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/AssemblyInfo.cs create mode 100644 src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/Resources.Designer.cs create mode 100644 src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/Resources.resx create mode 100644 src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/Settings.Designer.cs create mode 100644 src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/Settings.settings create mode 100644 src/AddIns/Analysis/CodeQuality/TreeMaps/Themes/generic.xaml create mode 100644 src/AddIns/Analysis/CodeQuality/TreeMaps/TreeMaps.csproj create mode 100644 src/AddIns/Analysis/CodeQuality/TreeMaps/TreeMaps.csproj.user diff --git a/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj b/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj index 481dcddd90..a9bd8864f6 100644 --- a/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj +++ b/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj @@ -258,6 +258,10 @@ {3ED2897F-1A8A-4106-89D2-4D342860D480} TreeMaps + + {3ED2897F-1A8A-4106-89D2-4D342860D480} + TreeMaps + diff --git a/src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/SquarifiedTreeMapsPanel.cs b/src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/SquarifiedTreeMapsPanel.cs new file mode 100644 index 0000000000..6a0086e5e3 --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/SquarifiedTreeMapsPanel.cs @@ -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(), this.GetShortestSide()); + } + + #endregion + + #region private methods + + private void Squarify(List items, List row, double sideLength) + { + if (items.Count == 0) + { + this.AddRowToLayout(row); + return; + } + + WeightUIElement item = items[0]; + List row2 = new List(row); + row2.Add(item); + List items2 = new List(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(), this.GetShortestSide()); + } + } + + private void AddRowToLayout(List row) + { + base.ComputeTreeMaps(row); + } + + private double Worst(List 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 + } +} diff --git a/src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/TreeMapItem.cs b/src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/TreeMapItem.cs new file mode 100644 index 0000000000..02f23c9ad7 --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/TreeMapItem.cs @@ -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 + + } +} diff --git a/src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/TreeMaps.cs b/src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/TreeMaps.cs new file mode 100644 index 0000000000..e47aebdb51 --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/TreeMaps.cs @@ -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 + } +} diff --git a/src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/TreeMapsPanel.cs b/src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/TreeMapsPanel.cs new file mode 100644 index 0000000000..3168eaeb2d --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/TreeMapsPanel.cs @@ -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 _items = new List(); + + #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 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 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 + + } +} diff --git a/src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/ValueDataTemplate.cs b/src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/ValueDataTemplate.cs new file mode 100644 index 0000000000..d5786a95f1 --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/TreeMaps/Controls/ValueDataTemplate.cs @@ -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 + } +} diff --git a/src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/AssemblyInfo.cs b/src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..b23baac6f8 --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/AssemblyInfo.cs @@ -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 +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the 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.*")] diff --git a/src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/Resources.Designer.cs b/src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..a7606266ed --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace TreeMaps.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // 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() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [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; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/Resources.resx b/src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/Resources.resx new file mode 100644 index 0000000000..3e18af958a --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/Settings.Designer.cs b/src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/Settings.Designer.cs new file mode 100644 index 0000000000..59a68ca80a --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +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; + } + } + } +} diff --git a/src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/Settings.settings b/src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/Settings.settings new file mode 100644 index 0000000000..4024694778 --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/TreeMaps/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/AddIns/Analysis/CodeQuality/TreeMaps/Themes/generic.xaml b/src/AddIns/Analysis/CodeQuality/TreeMaps/Themes/generic.xaml new file mode 100644 index 0000000000..ad2a775cfe --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/TreeMaps/Themes/generic.xaml @@ -0,0 +1,126 @@ + + + + + + \ No newline at end of file diff --git a/src/AddIns/Analysis/CodeQuality/TreeMaps/TreeMaps.csproj b/src/AddIns/Analysis/CodeQuality/TreeMaps/TreeMaps.csproj new file mode 100644 index 0000000000..839d01939b --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/TreeMaps/TreeMaps.csproj @@ -0,0 +1,104 @@ + + + + Debug + AnyCPU + {3ED2897F-1A8A-4106-89D2-4D342860D480} + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + TreeMaps + TreeMaps + 4 + Library + 3.0 + true + Web + true + Foreground + 7 + Days + false + false + false + 1.0.0.* + true + true + Publish\ + + + + v4.0 + + + true + full + false + .\bin\Debug\ + DEBUG;TRACE + + + false + true + .\bin\Release\ + TRACE + + + + + + 3.5 + + + + 3.5 + + + 4.0 + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + + + ResXFileCodeGenerator + Designer + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + True + Resources.resx + + + True + True + Settings.settings + + + + + + \ No newline at end of file diff --git a/src/AddIns/Analysis/CodeQuality/TreeMaps/TreeMaps.csproj.user b/src/AddIns/Analysis/CodeQuality/TreeMaps/TreeMaps.csproj.user new file mode 100644 index 0000000000..0889eaf53d --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/TreeMaps/TreeMaps.csproj.user @@ -0,0 +1,6 @@ + + + + ShowAllFiles + + \ No newline at end of file