|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Collections.ObjectModel;
namespace WpfBulletGraph
{
/// <summary>
/// Interaction logic for BulletGraph.xaml
/// </summary>
public partial class BulletGraph : UserControl
{
#region properties
[Category("Bullet Graph")]
[Browsable(true)]
public double FeaturedMeasure
{
get { return BulletGraphWithLegend.GetFeaturedMeasure(this); }
set { BulletGraphWithLegend.SetFeaturedMeasure(this, value); }
}
[Category("Bullet Graph")]
[Browsable(true)]
public double ComparativeMeasure
{
get { return BulletGraphWithLegend.GetComparativeMeasure(this); }
set { BulletGraphWithLegend.SetComparativeMeasure(this, value); }
}
[Category("Bullet Graph")]
[Browsable(true)]
public double GraphRange
{
get { return BulletGraphWithLegend.GetGraphRange(this); }
set { BulletGraphWithLegend.SetGraphRange(this, value); }
}
[Category("Bullet Graph")]
[Browsable(true)]
public bool LeftToRight
{
get { return BulletGraphWithLegend.GetLeftToRight(this); }
set { BulletGraphWithLegend.SetLeftToRight(this, value); }
}
[Category("Bullet Graph")]
[Browsable(true)]
public QualitativeRanges QualitativeRanges
{
get { return BulletGraphWithLegend.GetQualitativeRanges(this); }
set { BulletGraphWithLegend.SetQualitativeRanges(this, value); }
}
#endregion
public BulletGraph()
{
InitializeComponent();
// add a handler to the GraphRange property. This is used to determine if the graph plots negative values.
DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(BulletGraphWithLegend.GraphRangeProperty, typeof(BulletGraphWithLegend));
if (dpd != null)
{
dpd.AddValueChanged(this, delegate
{
// sort the qualitative range items ascending or descending accordingly
qualitativeRangeBar.Items.SortDescriptions.Add(
new SortDescription("Maximum", this.GraphRange < 0 ? ListSortDirection.Ascending : ListSortDirection.Descending));
});
}
}
}
public class QualitativeRanges : ObservableCollection<QualitativeRange>
{ }
/// <summary>
/// Defines a single qualitative range within a bullet graph.
/// </summary>
public class QualitativeRange
{
private double? maximum;
public double? Maximum
{
get { return maximum; }
set { maximum = value; }
}
private Color color;
public Color Color
{
get { return color; }
set { color = value; }
}
public override string ToString()
{
return "Maximum: " + (Maximum.HasValue ? Maximum.ToString() : "<null>") + ", Color: " + Color;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.