WindowImpl.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. using Avalonia.Controls;
  3. using Avalonia.Native.Interop;
  4. using Avalonia.Platform;
  5. namespace Avalonia.Native
  6. {
  7. class WindowImpl : WindowBaseImpl, IWindowImpl
  8. {
  9. IAvnWindow _native;
  10. public WindowImpl(IAvaloniaNativeFactory factory)
  11. {
  12. using (var e = new WindowEvents(this))
  13. Init(_native = factory.CreateWindow(e), factory.CreateScreens());
  14. }
  15. class WindowEvents : WindowBaseEvents, IAvnWindowEvents
  16. {
  17. readonly WindowImpl _parent;
  18. public WindowEvents(WindowImpl parent) : base(parent)
  19. {
  20. _parent = parent;
  21. }
  22. void IAvnWindowEvents.WindowStateChanged(AvnWindowState state)
  23. {
  24. _parent.WindowStateChanged?.Invoke((WindowState)state);
  25. }
  26. }
  27. public IAvnWindow Native => _native;
  28. public IDisposable ShowDialog()
  29. {
  30. return null;
  31. }
  32. public void CanResize(bool value)
  33. {
  34. _native.CanResize = value;
  35. }
  36. public void SetSystemDecorations(bool enabled)
  37. {
  38. _native.HasDecorations = enabled;
  39. }
  40. public void SetTitle(string title)
  41. {
  42. }
  43. public WindowState WindowState
  44. {
  45. get
  46. {
  47. return (WindowState)_native.GetWindowState();
  48. }
  49. set
  50. {
  51. _native.SetWindowState((AvnWindowState)value);
  52. }
  53. }
  54. public Action<WindowState> WindowStateChanged { get; set; }
  55. public void ShowTaskbarIcon(bool value)
  56. {
  57. }
  58. public void SetIcon(IWindowIconImpl icon)
  59. {
  60. }
  61. public Func<bool> Closing { get; set; }
  62. }
  63. }