//------------------------------------------ // ArrowLine.cs (c) 2007 by Charles Petzold //------------------------------------------ using System.Windows; using System.Windows.Media; namespace DrawGraph { public class ArrowLine : ArrowLineBase { /// /// Identifies the X1 dependency property. /// public static readonly DependencyProperty X1Property = DependencyProperty.Register("X1", typeof(double), typeof(ArrowLine), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsMeasure)); /// /// Gets or sets the x-coordinate of the ArrowLine start point. /// public double X1 { set { SetValue(X1Property, value); } get { return (double)GetValue(X1Property); } } /// /// Identifies the Y1 dependency property. /// public static readonly DependencyProperty Y1Property = DependencyProperty.Register("Y1", typeof(double), typeof(ArrowLine), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsMeasure)); /// /// Gets or sets the y-coordinate of the ArrowLine start point. /// public double Y1 { set { SetValue(Y1Property, value); } get { return (double)GetValue(Y1Property); } } /// /// Identifies the X2 dependency property. /// public static readonly DependencyProperty X2Property = DependencyProperty.Register("X2", typeof(double), typeof(ArrowLine), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsMeasure)); /// /// Gets or sets the x-coordinate of the ArrowLine end point. /// public double X2 { set { SetValue(X2Property, value); } get { return (double)GetValue(X2Property); } } /// /// Identifies the Y2 dependency property. /// public static readonly DependencyProperty Y2Property = DependencyProperty.Register("Y2", typeof(double), typeof(ArrowLine), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsMeasure)); /// /// Gets or sets the y-coordinate of the ArrowLine end point. /// public double Y2 { set { SetValue(Y2Property, value); } get { return (double)GetValue(Y2Property); } } /// /// Gets a value that represents the Geometry of the ArrowLine. /// protected override Geometry DefiningGeometry { get { // Clear out the PathGeometry. pathgeo.Figures.Clear(); // Define a single PathFigure with the points. pathfigLine.StartPoint = new Point(X1, Y1); polysegLine.Points.Clear(); polysegLine.Points.Add(new Point(X2, Y2)); pathgeo.Figures.Add(pathfigLine); // Call the base property to add arrows on the ends. return base.DefiningGeometry; } } } }