WindowsMouseDevice.cs 882 B

1234567891011121314151617181920212223242526272829303132333435
  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.Input;
  5. using Avalonia.Interactivity;
  6. using Avalonia.Win32.Interop;
  7. namespace Avalonia.Win32.Input
  8. {
  9. class WindowsMouseDevice : MouseDevice
  10. {
  11. public static WindowsMouseDevice Instance { get; } = new WindowsMouseDevice();
  12. public WindowImpl CurrentWindow
  13. {
  14. get;
  15. set;
  16. }
  17. public override void Capture(IInputElement control)
  18. {
  19. base.Capture(control);
  20. if (control != null)
  21. {
  22. UnmanagedMethods.SetCapture(CurrentWindow.Handle.Handle);
  23. }
  24. else
  25. {
  26. UnmanagedMethods.ReleaseCapture();
  27. }
  28. }
  29. }
  30. }