TestRoot.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 Avalonia.Controls;
  5. using Avalonia.Input;
  6. using Avalonia.Layout;
  7. using Avalonia.Platform;
  8. using Avalonia.Rendering;
  9. using Avalonia.Styling;
  10. namespace Avalonia.UnitTests
  11. {
  12. public class TestRoot : Decorator, IFocusScope, ILayoutRoot, INameScope, IRenderRoot, IStyleRoot
  13. {
  14. private readonly NameScope _nameScope = new NameScope();
  15. event EventHandler<NameScopeEventArgs> INameScope.Registered
  16. {
  17. add { _nameScope.Registered += value; ++NameScopeRegisteredSubscribers; }
  18. remove { _nameScope.Registered -= value; --NameScopeRegisteredSubscribers; }
  19. }
  20. public event EventHandler<NameScopeEventArgs> Unregistered
  21. {
  22. add { _nameScope.Unregistered += value; ++NameScopeUnregisteredSubscribers; }
  23. remove { _nameScope.Unregistered -= value; --NameScopeUnregisteredSubscribers; }
  24. }
  25. public int NameScopeRegisteredSubscribers { get; private set; }
  26. public int NameScopeUnregisteredSubscribers { get; private set; }
  27. public Size ClientSize => new Size(100, 100);
  28. public Size MaxClientSize => Size.Infinity;
  29. public double LayoutScaling => 1;
  30. public ILayoutManager LayoutManager => AvaloniaLocator.Current.GetService<ILayoutManager>();
  31. public IRenderTarget RenderTarget => null;
  32. public IRenderer Renderer => null;
  33. public IRenderTarget CreateRenderTarget()
  34. {
  35. throw new NotImplementedException();
  36. }
  37. public void Invalidate(Rect rect)
  38. {
  39. throw new NotImplementedException();
  40. }
  41. public Point PointToClient(Point p) => p;
  42. public Point PointToScreen(Point p) => p;
  43. void INameScope.Register(string name, object element)
  44. {
  45. _nameScope.Register(name, element);
  46. }
  47. object INameScope.Find(string name)
  48. {
  49. return _nameScope.Find(name);
  50. }
  51. void INameScope.Unregister(string name)
  52. {
  53. _nameScope.Unregister(name);
  54. }
  55. }
  56. }