Line.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (c) The Perspex Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using Perspex.Media;
  4. namespace Perspex.Controls.Shapes
  5. {
  6. public class Line : Shape
  7. {
  8. public static readonly StyledProperty<Point> StartPointProperty =
  9. PerspexProperty.Register<Line, Point>("StartPoint");
  10. public static readonly StyledProperty<Point> EndPointProperty =
  11. PerspexProperty.Register<Line, Point>("EndPoint");
  12. static Line()
  13. {
  14. StrokeThicknessProperty.OverrideDefaultValue<Line>(1);
  15. AffectsGeometry(StartPointProperty);
  16. AffectsGeometry(EndPointProperty);
  17. }
  18. public Point StartPoint
  19. {
  20. get { return GetValue(StartPointProperty); }
  21. set { SetValue(StartPointProperty, value); }
  22. }
  23. public Point EndPoint
  24. {
  25. get { return GetValue(EndPointProperty); }
  26. set { SetValue(EndPointProperty, value); }
  27. }
  28. protected override Geometry CreateDefiningGeometry()
  29. {
  30. return new LineGeometry(StartPoint, EndPoint);
  31. }
  32. }
  33. }