TestTemplatedRoot.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using Avalonia.Controls;
  3. using Avalonia.Controls.Presenters;
  4. using Avalonia.Controls.Templates;
  5. using Avalonia.Layout;
  6. using Avalonia.LogicalTree;
  7. using Avalonia.Platform;
  8. using Avalonia.Rendering;
  9. using Avalonia.Styling;
  10. namespace Avalonia.UnitTests
  11. {
  12. public class TestTemplatedRoot : ContentControl, ILayoutRoot, IRenderRoot, ILogicalRoot
  13. {
  14. private readonly NameScope _nameScope = new NameScope();
  15. public TestTemplatedRoot()
  16. {
  17. LayoutManager = new LayoutManager(this);
  18. Template = new FuncControlTemplate<TestTemplatedRoot>((x, scope) => new ContentPresenter
  19. {
  20. Name = "PART_ContentPresenter",
  21. }.RegisterInNameScope(scope));
  22. }
  23. public Size ClientSize => new Size(100, 100);
  24. public Size MaxClientSize => Size.Infinity;
  25. public double LayoutScaling => 1;
  26. public ILayoutManager LayoutManager { get; set; }
  27. public double RenderScaling => 1;
  28. public IRenderTarget RenderTarget => null;
  29. public IRenderer Renderer => null;
  30. public IRenderTarget CreateRenderTarget()
  31. {
  32. throw new NotImplementedException();
  33. }
  34. public void Invalidate(Rect rect)
  35. {
  36. throw new NotImplementedException();
  37. }
  38. public Point PointToClient(PixelPoint p) => p.ToPoint(1);
  39. public PixelPoint PointToScreen(Point p) => PixelPoint.FromPoint(p, 1);
  40. }
  41. }