LineNode.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (c) The Avalonia Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using System;
  4. using System.Collections.Generic;
  5. using Avalonia.Media;
  6. using Avalonia.VisualTree;
  7. namespace Avalonia.Rendering.SceneGraph
  8. {
  9. internal class LineNode : BrushDrawOperation
  10. {
  11. public LineNode(Matrix transform, Pen pen, Point p1, Point p2)
  12. {
  13. Bounds = new Rect(P1, P2);
  14. Transform = transform;
  15. Pen = Convert(pen);
  16. P1 = p1;
  17. P2 = p2;
  18. }
  19. public override Rect Bounds { get; }
  20. public Matrix Transform { get; }
  21. public Pen Pen { get; }
  22. public Point P1 { get; }
  23. public Point P2 { get; }
  24. public override IDictionary<IVisual, Scene> ChildScenes => null;
  25. public bool Equals(Matrix transform, Pen pen, Point p1, Point p2)
  26. {
  27. return transform == Transform && pen == Pen && p1 == P1 && p2 == P2;
  28. }
  29. public override void Render(IDrawingContextImpl context)
  30. {
  31. context.Transform = Transform;
  32. context.DrawLine(Pen, P1, P2);
  33. }
  34. public override bool HitTest(Point p)
  35. {
  36. // TODO: Implement line hit testing.
  37. return false;
  38. }
  39. }
  40. }