Stubs.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Reactive.Disposables;
  5. using System.Threading.Tasks;
  6. using Avalonia.Controls;
  7. using Avalonia.Controls.Platform;
  8. using Avalonia.Input;
  9. using Avalonia.Input.Platform;
  10. using Avalonia.Input.Raw;
  11. using Avalonia.Platform;
  12. using Avalonia.Rendering;
  13. namespace Avalonia.DesignerSupport.Remote
  14. {
  15. class WindowStub : IPopupImpl, IWindowImpl
  16. {
  17. public Action Deactivated { get; set; }
  18. public Action Activated { get; set; }
  19. public IPlatformHandle Handle { get; }
  20. public Size MaxClientSize { get; }
  21. public Size ClientSize { get; }
  22. public double Scaling { get; }
  23. public IEnumerable<object> Surfaces { get; }
  24. public Action<RawInputEventArgs> Input { get; set; }
  25. public Action<Rect> Paint { get; set; }
  26. public Action<Size> Resized { get; set; }
  27. public Action<double> ScalingChanged { get; set; }
  28. public Func<bool> Closing { get; set; }
  29. public Action Closed { get; set; }
  30. public IMouseDevice MouseDevice { get; } = new MouseDevice();
  31. public Point Position { get; set; }
  32. public Action<Point> PositionChanged { get; set; }
  33. public WindowState WindowState { get; set; }
  34. public IRenderer CreateRenderer(IRenderRoot root) => new ImmediateRenderer(root);
  35. public void Dispose()
  36. {
  37. }
  38. public void Invalidate(Rect rect)
  39. {
  40. }
  41. public void SetInputRoot(IInputRoot inputRoot)
  42. {
  43. }
  44. public Point PointToClient(Point point) => point;
  45. public Point PointToScreen(Point point) => point;
  46. public void SetCursor(IPlatformHandle cursor)
  47. {
  48. }
  49. public void Show()
  50. {
  51. }
  52. public void Hide()
  53. {
  54. }
  55. public void BeginMoveDrag()
  56. {
  57. }
  58. public void BeginResizeDrag(WindowEdge edge)
  59. {
  60. }
  61. public void Activate()
  62. {
  63. }
  64. public void Resize(Size clientSize)
  65. {
  66. }
  67. public IScreenImpl Screen { get; } = new ScreenStub();
  68. public void SetTitle(string title)
  69. {
  70. }
  71. public IDisposable ShowDialog() => Disposable.Empty;
  72. public void SetSystemDecorations(bool enabled)
  73. {
  74. }
  75. public void SetIcon(IWindowIconImpl icon)
  76. {
  77. }
  78. public void ShowTaskbarIcon(bool value)
  79. {
  80. }
  81. }
  82. class ClipboardStub : IClipboard
  83. {
  84. public Task<string> GetTextAsync() => Task.FromResult("");
  85. public Task SetTextAsync(string text) => Task.CompletedTask;
  86. public Task ClearAsync() => Task.CompletedTask;
  87. }
  88. class CursorFactoryStub : IStandardCursorFactory
  89. {
  90. public IPlatformHandle GetCursor(StandardCursorType cursorType) => new PlatformHandle(IntPtr.Zero, "STUB");
  91. }
  92. class IconLoaderStub : IPlatformIconLoader
  93. {
  94. class IconStub : IWindowIconImpl
  95. {
  96. public void Save(Stream outputStream)
  97. {
  98. }
  99. }
  100. public IWindowIconImpl LoadIcon(string fileName) => new IconStub();
  101. public IWindowIconImpl LoadIcon(Stream stream) => new IconStub();
  102. public IWindowIconImpl LoadIcon(IBitmapImpl bitmap) => new IconStub();
  103. }
  104. class SystemDialogsStub : ISystemDialogImpl
  105. {
  106. public Task<string[]> ShowFileDialogAsync(FileDialog dialog, IWindowImpl parent) =>
  107. Task.FromResult((string[]) null);
  108. public Task<string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent) =>
  109. Task.FromResult((string) null);
  110. }
  111. class ScreenStub : IScreenImpl
  112. {
  113. public int ScreenCount => 1;
  114. public Screen[] AllScreens { get; } =
  115. {new Screen(new Rect(0, 0, 4000, 4000), new Rect(0, 0, 4000, 4000), true)};
  116. }
  117. }