From 90b405952e13080f842d03c4597b13e374b5b630 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 25 Jun 2020 21:10:02 +0300 Subject: [PATCH 001/751] Extracted ANGLE-based EGL display to a separate class and added some DX-interop features --- .../Angle/AngleEglInterface.cs | 31 +++++++ .../Angle/AngleWin32EglDisplay.cs | 88 +++++++++++++++++++ src/Avalonia.OpenGL/EglConsts.cs | 10 +++ src/Avalonia.OpenGL/EglDisplay.cs | 76 ++++++++-------- src/Avalonia.OpenGL/EglGlPlatformFeature.cs | 7 +- src/Avalonia.OpenGL/EglInterface.cs | 29 ++++-- src/Windows/Avalonia.Win32/Win32GlManager.cs | 3 +- 7 files changed, 190 insertions(+), 54 deletions(-) create mode 100644 src/Avalonia.OpenGL/Angle/AngleEglInterface.cs create mode 100644 src/Avalonia.OpenGL/Angle/AngleWin32EglDisplay.cs diff --git a/src/Avalonia.OpenGL/Angle/AngleEglInterface.cs b/src/Avalonia.OpenGL/Angle/AngleEglInterface.cs new file mode 100644 index 0000000000..375b93c27c --- /dev/null +++ b/src/Avalonia.OpenGL/Angle/AngleEglInterface.cs @@ -0,0 +1,31 @@ +using System; +using System.Runtime.InteropServices; +using Avalonia.Platform; +using Avalonia.Platform.Interop; + +namespace Avalonia.OpenGL.Angle +{ + public class AngleEglInterface : EglInterface + { + [DllImport("libegl.dll", CharSet = CharSet.Ansi)] + static extern IntPtr eglGetProcAddress(string proc); + + public AngleEglInterface() : base(LoadAngle()) + { + + } + + static Func LoadAngle() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + throw new PlatformNotSupportedException(); + { + var disp = eglGetProcAddress("eglGetPlatformDisplayEXT"); + if (disp == IntPtr.Zero) + throw new OpenGlException("libegl.dll doesn't have eglGetPlatformDisplayEXT entry point"); + return eglGetProcAddress; + } + } + + } +} diff --git a/src/Avalonia.OpenGL/Angle/AngleWin32EglDisplay.cs b/src/Avalonia.OpenGL/Angle/AngleWin32EglDisplay.cs new file mode 100644 index 0000000000..530411bfea --- /dev/null +++ b/src/Avalonia.OpenGL/Angle/AngleWin32EglDisplay.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +using static Avalonia.OpenGL.EglConsts; + +namespace Avalonia.OpenGL.Angle +{ + public class AngleWin32EglDisplay : EglDisplay + { + struct AngleInfo + { + public IntPtr Display { get; set; } + public AngleOptions.PlatformApi PlatformApi { get; set; } + } + + static AngleInfo CreateAngleDisplay(EglInterface _egl) + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + throw new PlatformNotSupportedException(); + var display = IntPtr.Zero; + AngleOptions.PlatformApi angleApi = default; + { + if (_egl.GetPlatformDisplayEXT == null) + throw new OpenGlException("eglGetPlatformDisplayEXT is not supported by libegl.dll"); + + var allowedApis = AvaloniaLocator.Current.GetService()?.AllowedPlatformApis + ?? new List {AngleOptions.PlatformApi.DirectX9}; + + foreach (var platformApi in allowedApis) + { + int dapi; + if (platformApi == AngleOptions.PlatformApi.DirectX9) + dapi = EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE; + else if (platformApi == AngleOptions.PlatformApi.DirectX11) + dapi = EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE; + else + continue; + + display = _egl.GetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, IntPtr.Zero, + new[] { EGL_PLATFORM_ANGLE_TYPE_ANGLE, dapi, EGL_NONE }); + if (display != IntPtr.Zero) + { + angleApi = platformApi; + break; + } + } + + if (display == IntPtr.Zero) + throw new OpenGlException("Unable to create ANGLE display"); + return new AngleInfo { Display = display, PlatformApi = angleApi }; + } + } + + private AngleWin32EglDisplay(EglInterface egl, AngleInfo info) : base(egl, info.Display) + { + PlatformApi = info.PlatformApi; + } + + public AngleWin32EglDisplay(EglInterface egl) : this(egl, CreateAngleDisplay(egl)) + { + + } + + public AngleWin32EglDisplay() : this(new AngleEglInterface()) + { + + } + + public AngleOptions.PlatformApi PlatformApi { get; } + + public IntPtr GetDirect3DDevice() + { + if (!EglInterface.QueryDisplayAttribExt(Handle, EglConsts.EGL_DEVICE_EXT, out var eglDevice)) + throw new OpenGlException("Unable to get EGL_DEVICE_EXT"); + if (!EglInterface.QueryDeviceAttribExt(eglDevice, PlatformApi == AngleOptions.PlatformApi.DirectX9 ? EGL_D3D9_DEVICE_ANGLE : EGL_D3D11_DEVICE_ANGLE, out var d3dDeviceHandle)) + throw new OpenGlException("Unable to get EGL_D3D9_DEVICE_ANGLE"); + return d3dDeviceHandle; + } + + public EglSurface WrapDirect3D11Texture(IntPtr handle) + { + if (PlatformApi != AngleOptions.PlatformApi.DirectX11) + throw new InvalidOperationException("Current platform API is " + PlatformApi); + return CreatePBufferFromClientBuffer(EGL_D3D_TEXTURE_ANGLE, handle, new[] { EGL_NONE, EGL_NONE }); + } + } +} diff --git a/src/Avalonia.OpenGL/EglConsts.cs b/src/Avalonia.OpenGL/EglConsts.cs index 62fb3faef6..d09537eb86 100644 --- a/src/Avalonia.OpenGL/EglConsts.cs +++ b/src/Avalonia.OpenGL/EglConsts.cs @@ -192,5 +192,15 @@ namespace Avalonia.OpenGL public const int EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE = 0x320F; public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_WARP_ANGLE = 0x320B; public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_REFERENCE_ANGLE = 0x320C; + + //EXT_device_query + public const int EGL_DEVICE_EXT = 0x322C; + + //ANGLE_device_d3d + public const int EGL_D3D9_DEVICE_ANGLE = 0x33A0; + public const int EGL_D3D11_DEVICE_ANGLE = 0x33A1; + + public const int EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE = 0x3200; + public const int EGL_D3D_TEXTURE_ANGLE = 0x33A3; } } diff --git a/src/Avalonia.OpenGL/EglDisplay.cs b/src/Avalonia.OpenGL/EglDisplay.cs index 0436f6ac52..7b194e4346 100644 --- a/src/Avalonia.OpenGL/EglDisplay.cs +++ b/src/Avalonia.OpenGL/EglDisplay.cs @@ -15,7 +15,6 @@ namespace Avalonia.OpenGL private readonly int _surfaceType; public IntPtr Handle => _display; - private AngleOptions.PlatformApi? _angleApi; private int _sampleCount; private int _stencilSize; private GlVersion _version; @@ -24,56 +23,41 @@ namespace Avalonia.OpenGL { } - public EglDisplay(EglInterface egl, int platformType, IntPtr platformDisplay, int[] attrs) - { - _egl = egl; + static IntPtr CreateDisplay(EglInterface egl, int platformType, IntPtr platformDisplay, int[] attrs) + { + var display = IntPtr.Zero; if (platformType == -1 && platformDisplay == IntPtr.Zero) { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - if (_egl.GetPlatformDisplayEXT == null) - throw new OpenGlException("eglGetPlatformDisplayEXT is not supported by libegl.dll"); - - var allowedApis = AvaloniaLocator.Current.GetService()?.AllowedPlatformApis - ?? new List {AngleOptions.PlatformApi.DirectX9}; - - foreach (var platformApi in allowedApis) - { - int dapi; - if (platformApi == AngleOptions.PlatformApi.DirectX9) - dapi = EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE; - else if (platformApi == AngleOptions.PlatformApi.DirectX11) - dapi = EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE; - else - continue; - - _display = _egl.GetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, IntPtr.Zero, - new[] {EGL_PLATFORM_ANGLE_TYPE_ANGLE, dapi, EGL_NONE}); - if (_display != IntPtr.Zero) - { - _angleApi = platformApi; - break; - } - } - - if (_display == IntPtr.Zero) - throw new OpenGlException("Unable to create ANGLE display"); - } - - if (_display == IntPtr.Zero) - _display = _egl.GetDisplay(IntPtr.Zero); + if (display == IntPtr.Zero) + display = egl.GetDisplay(IntPtr.Zero); } else { - if (_egl.GetPlatformDisplayEXT == null) + if (egl.GetPlatformDisplayEXT == null) throw new OpenGlException("eglGetPlatformDisplayEXT is not supported by libegl"); - _display = _egl.GetPlatformDisplayEXT(platformType, platformDisplay, attrs); + display = egl.GetPlatformDisplayEXT(platformType, platformDisplay, attrs); } + + if (display == IntPtr.Zero) + throw OpenGlException.GetFormattedException("eglGetDisplay", egl); + return display; + } - if (_display == IntPtr.Zero) - throw OpenGlException.GetFormattedException("eglGetDisplay", _egl); + public EglDisplay(EglInterface egl, int platformType, IntPtr platformDisplay, int[] attrs) + : this(egl, CreateDisplay(egl, platformType, platformDisplay, attrs)) + { + + } + public EglDisplay(EglInterface egl, IntPtr display) + { + _egl = egl; + _display = display; + if(_display == IntPtr.Zero) + throw new ArgumentException(); + + if (!_egl.Initialize(_display, out var major, out var minor)) throw OpenGlException.GetFormattedException("eglInitialize", _egl); @@ -172,5 +156,15 @@ namespace Avalonia.OpenGL throw OpenGlException.GetFormattedException("eglCreateWindowSurface", _egl); return new EglSurface(this, _egl, s); } + + public EglSurface CreatePBufferFromClientBuffer (int bufferType, IntPtr handle, int[] attribs) + { + var s = _egl.CreatePbufferFromClientBuffer(_display, bufferType, handle, + _config, attribs); + + if (s == IntPtr.Zero) + throw OpenGlException.GetFormattedException("eglCreatePbufferFromClientBuffer", _egl); + return new EglSurface(this, _egl, s); + } } } diff --git a/src/Avalonia.OpenGL/EglGlPlatformFeature.cs b/src/Avalonia.OpenGL/EglGlPlatformFeature.cs index f59c6b7751..7e9383432c 100644 --- a/src/Avalonia.OpenGL/EglGlPlatformFeature.cs +++ b/src/Avalonia.OpenGL/EglGlPlatformFeature.cs @@ -20,12 +20,13 @@ namespace Avalonia.OpenGL if (feature != null) AvaloniaLocator.CurrentMutable.Bind().ToConstant(feature); } - - public static EglGlPlatformFeature TryCreate() + + public static EglGlPlatformFeature TryCreate() => TryCreate(() => new EglDisplay()); + public static EglGlPlatformFeature TryCreate(Func displayFactory) { try { - var disp = new EglDisplay(); + var disp = displayFactory(); return new EglGlPlatformFeature { _display = disp, diff --git a/src/Avalonia.OpenGL/EglInterface.cs b/src/Avalonia.OpenGL/EglInterface.cs index c0665a1ea1..666c0d8351 100644 --- a/src/Avalonia.OpenGL/EglInterface.cs +++ b/src/Avalonia.OpenGL/EglInterface.cs @@ -17,25 +17,21 @@ namespace Avalonia.OpenGL } + public EglInterface(Func getProcAddress) : base(getProcAddress) + { + + } + public EglInterface(string library) : base(Load(library)) { } - [DllImport("libegl.dll", CharSet = CharSet.Ansi)] - static extern IntPtr eglGetProcAddress(string proc); static Func Load() { var os = AvaloniaLocator.Current.GetService().GetRuntimeInfo().OperatingSystem; if(os == OperatingSystemType.Linux || os == OperatingSystemType.Android) return Load("libEGL.so.1"); - if (os == OperatingSystemType.WinNT) - { - var disp = eglGetProcAddress("eglGetPlatformDisplayEXT"); - if (disp == IntPtr.Zero) - throw new OpenGlException("libegl.dll doesn't have eglGetPlatformDisplayEXT entry point"); - return eglGetProcAddress; - } throw new PlatformNotSupportedException(); } @@ -147,6 +143,21 @@ namespace Avalonia.OpenGL return null; return Marshal.PtrToStringAnsi(rv); } + + public delegate IntPtr EglCreatePbufferFromClientBuffer(IntPtr display, int buftype, IntPtr buffer, IntPtr config, int[] attrib_list); + [GlEntryPoint("eglCreatePbufferFromClientBuffer")] + + public EglCreatePbufferFromClientBuffer CreatePbufferFromClientBuffer { get; } + + public delegate bool EglQueryDisplayAttribEXT(IntPtr display, int attr, out IntPtr res); + + [GlEntryPoint("eglQueryDisplayAttribEXT"), GlOptionalEntryPoint] + public EglQueryDisplayAttribEXT QueryDisplayAttribExt { get; } + + public delegate bool EglQueryDeviceAttribEXT(IntPtr display, int attr, out IntPtr res); + + [GlEntryPoint("eglQueryDeviceAttribEXT"), GlOptionalEntryPoint] + public EglQueryDisplayAttribEXT QueryDeviceAttribExt { get; } // ReSharper restore UnassignedGetOnlyAutoProperty } diff --git a/src/Windows/Avalonia.Win32/Win32GlManager.cs b/src/Windows/Avalonia.Win32/Win32GlManager.cs index 585e68056b..bd188ad53a 100644 --- a/src/Windows/Avalonia.Win32/Win32GlManager.cs +++ b/src/Windows/Avalonia.Win32/Win32GlManager.cs @@ -1,4 +1,5 @@ using Avalonia.OpenGL; +using Avalonia.OpenGL.Angle; namespace Avalonia.Win32 { @@ -15,7 +16,7 @@ namespace Avalonia.Win32 { if (!s_attemptedToInitialize) { - EglFeature = EglGlPlatformFeature.TryCreate(); + EglFeature = EglGlPlatformFeature.TryCreate(() => new AngleWin32EglDisplay()); s_attemptedToInitialize = true; } From a34fefc998d9dce6416b8d7de8f89f86869cb3a7 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 25 Jun 2020 21:32:29 +0300 Subject: [PATCH 002/751] Allow more customization for EglGlPlatformSurface --- src/Avalonia.OpenGL/EglGlPlatformSurface.cs | 84 ++------------ .../EglGlPlatformSurfaceBase.cs | 103 ++++++++++++++++++ 2 files changed, 112 insertions(+), 75 deletions(-) create mode 100644 src/Avalonia.OpenGL/EglGlPlatformSurfaceBase.cs diff --git a/src/Avalonia.OpenGL/EglGlPlatformSurface.cs b/src/Avalonia.OpenGL/EglGlPlatformSurface.cs index 3e4befe2c6..21fadff19e 100644 --- a/src/Avalonia.OpenGL/EglGlPlatformSurface.cs +++ b/src/Avalonia.OpenGL/EglGlPlatformSurface.cs @@ -3,33 +3,26 @@ using System.Threading; namespace Avalonia.OpenGL { - public class EglGlPlatformSurface : IGlPlatformSurface + public class EglGlPlatformSurface : EglGlPlatformSurfaceBase { - public interface IEglWindowGlPlatformSurfaceInfo - { - IntPtr Handle { get; } - PixelSize Size { get; } - double Scaling { get; } - } - private readonly EglDisplay _display; private readonly EglContext _context; private readonly IEglWindowGlPlatformSurfaceInfo _info; - public EglGlPlatformSurface(EglContext context, IEglWindowGlPlatformSurfaceInfo info) + public EglGlPlatformSurface(EglContext context, IEglWindowGlPlatformSurfaceInfo info) : base() { _display = context.Display; _context = context; _info = info; } - - public IGlPlatformSurfaceRenderTarget CreateGlRenderTarget() + + public override IGlPlatformSurfaceRenderTarget CreateGlRenderTarget() { var glSurface = _display.CreateWindowSurface(_info.Handle); return new RenderTarget(_display, _context, glSurface, _info); } - class RenderTarget : IGlPlatformSurfaceRenderTargetWithCorruptionInfo + class RenderTarget : EglPlatformSurfaceRenderTargetBase { private readonly EglDisplay _display; private readonly EglContext _context; @@ -38,7 +31,7 @@ namespace Avalonia.OpenGL private PixelSize _initialSize; public RenderTarget(EglDisplay display, EglContext context, - EglSurface glSurface, IEglWindowGlPlatformSurfaceInfo info) + EglSurface glSurface, IEglWindowGlPlatformSurfaceInfo info) : base(display, context) { _display = display; _context = context; @@ -47,70 +40,11 @@ namespace Avalonia.OpenGL _initialSize = info.Size; } - public void Dispose() => _glSurface.Dispose(); + public override void Dispose() => _glSurface.Dispose(); - public bool IsCorrupted => _initialSize != _info.Size; - - public IGlPlatformSurfaceRenderingSession BeginDraw() - { - var l = _context.Lock(); - try - { - if (IsCorrupted) - throw new RenderTargetCorruptedException(); - var restoreContext = _context.MakeCurrent(_glSurface); - _display.EglInterface.WaitClient(); - _display.EglInterface.WaitGL(); - _display.EglInterface.WaitNative(EglConsts.EGL_CORE_NATIVE_ENGINE); - - return new Session(_display, _context, _glSurface, _info, l, restoreContext); - } - catch - { - l.Dispose(); - throw; - } - } + public override bool IsCorrupted => _initialSize != _info.Size; - class Session : IGlPlatformSurfaceRenderingSession - { - private readonly EglContext _context; - private readonly EglSurface _glSurface; - private readonly IEglWindowGlPlatformSurfaceInfo _info; - private readonly EglDisplay _display; - private IDisposable _lock; - private readonly IDisposable _restoreContext; - - - public Session(EglDisplay display, EglContext context, - EglSurface glSurface, IEglWindowGlPlatformSurfaceInfo info, - IDisposable @lock, IDisposable restoreContext) - { - _context = context; - _display = display; - _glSurface = glSurface; - _info = info; - _lock = @lock; - _restoreContext = restoreContext; - } - - public void Dispose() - { - _context.GlInterface.Flush(); - _display.EglInterface.WaitGL(); - _glSurface.SwapBuffers(); - _display.EglInterface.WaitClient(); - _display.EglInterface.WaitGL(); - _display.EglInterface.WaitNative(EglConsts.EGL_CORE_NATIVE_ENGINE); - _restoreContext.Dispose(); - _lock.Dispose(); - } - - public IGlContext Context => _context; - public PixelSize Size => _info.Size; - public double Scaling => _info.Scaling; - public bool IsYFlipped { get; } - } + public override IGlPlatformSurfaceRenderingSession BeginDraw() => base.BeginDraw(_glSurface, _info); } } } diff --git a/src/Avalonia.OpenGL/EglGlPlatformSurfaceBase.cs b/src/Avalonia.OpenGL/EglGlPlatformSurfaceBase.cs new file mode 100644 index 0000000000..00c7c4796c --- /dev/null +++ b/src/Avalonia.OpenGL/EglGlPlatformSurfaceBase.cs @@ -0,0 +1,103 @@ +using System; + +namespace Avalonia.OpenGL +{ + public abstract class EglGlPlatformSurfaceBase : IGlPlatformSurface + { + public interface IEglWindowGlPlatformSurfaceInfo + { + IntPtr Handle { get; } + PixelSize Size { get; } + double Scaling { get; } + } + + public abstract IGlPlatformSurfaceRenderTarget CreateGlRenderTarget(); + } + + public abstract class EglPlatformSurfaceRenderTargetBase : IGlPlatformSurfaceRenderTargetWithCorruptionInfo + { + private readonly EglDisplay _display; + private readonly EglContext _context; + + protected EglPlatformSurfaceRenderTargetBase(EglDisplay display, EglContext context) + { + _display = display; + _context = context; + } + + public abstract bool IsCorrupted { get; } + + public virtual void Dispose() + { + + } + + public abstract IGlPlatformSurfaceRenderingSession BeginDraw(); + + protected IGlPlatformSurfaceRenderingSession BeginDraw(EglSurface surface, + EglGlPlatformSurfaceBase.IEglWindowGlPlatformSurfaceInfo info, Action onFinish = null, bool isYFlipped = false) + { + var l = _context.Lock(); + try + { + if (IsCorrupted) + throw new RenderTargetCorruptedException(); + var restoreContext = _context.MakeCurrent(surface); + _display.EglInterface.WaitClient(); + _display.EglInterface.WaitGL(); + _display.EglInterface.WaitNative(EglConsts.EGL_CORE_NATIVE_ENGINE); + + return new Session(_display, _context, surface, info, l, restoreContext, onFinish, isYFlipped); + } + catch + { + l.Dispose(); + throw; + } + } + + class Session : IGlPlatformSurfaceRenderingSession + { + private readonly EglContext _context; + private readonly EglSurface _glSurface; + private readonly EglGlPlatformSurfaceBase.IEglWindowGlPlatformSurfaceInfo _info; + private readonly EglDisplay _display; + private readonly IDisposable _lock; + private readonly IDisposable _restoreContext; + private readonly Action _onFinish; + + + public Session(EglDisplay display, EglContext context, + EglSurface glSurface, EglGlPlatformSurfaceBase.IEglWindowGlPlatformSurfaceInfo info, + IDisposable @lock, IDisposable restoreContext, Action onFinish, bool isYFlipped) + { + IsYFlipped = isYFlipped; + _context = context; + _display = display; + _glSurface = glSurface; + _info = info; + _lock = @lock; + _restoreContext = restoreContext; + _onFinish = onFinish; + } + + public void Dispose() + { + _context.GlInterface.Flush(); + _display.EglInterface.WaitGL(); + _glSurface.SwapBuffers(); + _display.EglInterface.WaitClient(); + _display.EglInterface.WaitGL(); + _display.EglInterface.WaitNative(EglConsts.EGL_CORE_NATIVE_ENGINE); + _restoreContext.Dispose(); + _lock.Dispose(); + _onFinish?.Invoke(); + } + + public IGlContext Context => _context; + public PixelSize Size => _info.Size; + public double Scaling => _info.Scaling; + public bool IsYFlipped { get; } + } + } +} From 92880f6d037de3a5e62f770a32bda4a33edc92bc Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 25 Jun 2020 17:32:02 -0300 Subject: [PATCH 003/751] force dx11 --- samples/ControlCatalog.NetCore/Program.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/samples/ControlCatalog.NetCore/Program.cs b/samples/ControlCatalog.NetCore/Program.cs index 5df8c1be64..06cf3e6b61 100644 --- a/samples/ControlCatalog.NetCore/Program.cs +++ b/samples/ControlCatalog.NetCore/Program.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Threading; using Avalonia; using Avalonia.Dialogs; +using Avalonia.OpenGL; using Avalonia.ReactiveUI; namespace ControlCatalog.NetCore @@ -65,6 +66,10 @@ namespace ControlCatalog.NetCore EnableMultitouch = true, AllowEglInitialization = true }) + .With(new AngleOptions + { + AllowedPlatformApis = new System.Collections.Generic.List { AngleOptions.PlatformApi.DirectX11} + }) .UseSkia() .UseReactiveUI() .UseManagedSystemDialogs() From 459e9db2fb04a05abbf830363db5fed73eed64c3 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 25 Jun 2020 17:35:43 -0300 Subject: [PATCH 004/751] add Composition interfaces. --- .../Avalonia.Win32/Avalonia.Win32.csproj | 1 + .../Composition/CompositionHost.cs | 145 ++++++++++++ .../Avalonia.Win32/Composition/D2DEffects.cs | 91 ++++++++ .../GRAPHICS_EFFECT_PROPERTY_MAPPING.cs | 18 ++ .../Composition/GaussianBlurEffect.cs | 79 +++++++ .../Composition/ICompositorDesktopInterop.cs | 14 ++ .../Composition/ICompositorDesktopInterop1.cs | 69 ++++++ .../Composition/ICompositorInterop.cs | 139 +++++++++++ .../Composition/IGraphicsEffectD2D1Interop.cs | 24 ++ .../IGraphicsEffectD2D1Interop1.cs | 217 ++++++++++++++++++ src/Windows/Avalonia.Win32/WindowImpl.cs | 2 + 11 files changed, 799 insertions(+) create mode 100644 src/Windows/Avalonia.Win32/Composition/CompositionHost.cs create mode 100644 src/Windows/Avalonia.Win32/Composition/D2DEffects.cs create mode 100644 src/Windows/Avalonia.Win32/Composition/GRAPHICS_EFFECT_PROPERTY_MAPPING.cs create mode 100644 src/Windows/Avalonia.Win32/Composition/GaussianBlurEffect.cs create mode 100644 src/Windows/Avalonia.Win32/Composition/ICompositorDesktopInterop.cs create mode 100644 src/Windows/Avalonia.Win32/Composition/ICompositorDesktopInterop1.cs create mode 100644 src/Windows/Avalonia.Win32/Composition/ICompositorInterop.cs create mode 100644 src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop.cs create mode 100644 src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop1.cs diff --git a/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj b/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj index 49700710e9..34f71daf52 100644 --- a/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj +++ b/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj @@ -7,6 +7,7 @@ + diff --git a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs new file mode 100644 index 0000000000..223c208829 --- /dev/null +++ b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs @@ -0,0 +1,145 @@ +using System; +using System.Runtime.InteropServices; +using Avalonia.OpenGL.Angle; +using Windows.UI.Composition; +using WinRT; + +namespace Avalonia.Win32 +{ + class CompositionHost + { + internal enum DISPATCHERQUEUE_THREAD_APARTMENTTYPE + { + DQTAT_COM_NONE = 0, + DQTAT_COM_ASTA = 1, + DQTAT_COM_STA = 2 + }; + + internal enum DISPATCHERQUEUE_THREAD_TYPE + { + DQTYPE_THREAD_DEDICATED = 1, + DQTYPE_THREAD_CURRENT = 2, + }; + + [StructLayout(LayoutKind.Sequential)] + internal struct DispatcherQueueOptions + { + public int dwSize; + + [MarshalAs(UnmanagedType.I4)] + public DISPATCHERQUEUE_THREAD_TYPE threadType; + + [MarshalAs(UnmanagedType.I4)] + public DISPATCHERQUEUE_THREAD_APARTMENTTYPE apartmentType; + }; + + [DllImport("coremessaging.dll", EntryPoint = "CreateDispatcherQueueController", CharSet = CharSet.Unicode)] + internal static extern IntPtr CreateDispatcherQueueController(DispatcherQueueOptions options, out IntPtr dispatcherQueueController); + + public static CompositionHost Instance { get; } = new CompositionHost(); + + private Compositor _compositor; + private Windows.System.DispatcherQueueController _dispatcherQueueController; + private Windows.UI.Composition.Desktop.DesktopWindowTarget _target; + + private CompositionHost() + { + } + + public void AddElement(float size, float x, float y) + { + if (_target.Root != null) + { + var visuals = _target.Root.As().Children; + + var visual = _compositor.CreateSpriteVisual(); + + var element = _compositor.CreateSpriteVisual(); + var rand = new Random(); + + element.Brush = _compositor.CreateColorBrush(new Windows.UI.Color { A = 255, R = (byte)(rand.NextDouble() * 255), G = (byte)(rand.NextDouble() * 255), B = (byte)(rand.NextDouble() * 255) }); + element.Size = new System.Numerics.Vector2(size, size); + element.Offset = new System.Numerics.Vector3(x, y, 0.0f); + + var animation = _compositor.CreateVector3KeyFrameAnimation(); + var bottom = (float)600 - element.Size.Y; + animation.InsertKeyFrame(1, new System.Numerics.Vector3(element.Offset.X, bottom, 0)); + + animation.Duration = TimeSpan.FromSeconds(2); + animation.DelayTime = TimeSpan.FromSeconds(3); + element.StartAnimation("Offset", animation); + visuals.InsertAtTop(element); + + visuals.InsertAtTop(visual); + } + } + + public void Initialize(IntPtr hwnd) + { + EnsureDispatcherQueue(); + if (_dispatcherQueueController != null) + _compositor = new Windows.UI.Composition.Compositor(); + + CreateDesktopWindowTarget(hwnd); + CreateCompositionRoot(); + + var interop = _compositor.As(); + + var display = Win32GlManager.EglFeature.Display as AngleWin32EglDisplay; + + var gDevice = interop.CreateGraphicsDevice(display.GetDirect3DDevice()); + + gDevice.CreateDrawingSurface(new Windows.Foundation.Size(100,100), Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized, Windows.Graphics.DirectX.DirectXAlphaMode.Premultiplied); + + } + + public void CreateBlur() + { + var effect = new GaussianBlurEffect(); + var effectFactory = _compositor.CreateEffectFactory(effect); + var blurBrush = effectFactory.CreateBrush(); + + var backDropBrush = _compositor.CreateBackdropBrush(); + + blurBrush.SetSourceParameter("backdrop", backDropBrush); + + var visual = _compositor.CreateSpriteVisual(); + + visual.RelativeSizeAdjustment = new System.Numerics.Vector2(1.0f, 1.0f); + visual.Brush = blurBrush; + + _target.Root = visual; + } + + void CreateCompositionRoot() + { + var root = _compositor.CreateContainerVisual(); + root.RelativeSizeAdjustment = new System.Numerics.Vector2(1.0f, 1.0f); + //root.Offset = new System.Numerics.Vector3(0, 0, 0); + _target.Root = root; + } + + void CreateDesktopWindowTarget(IntPtr window) + { + var interop = _compositor.As(); + + interop.CreateDesktopWindowTarget(window, false, out var windowTarget); + _target = Windows.UI.Composition.Desktop.DesktopWindowTarget.FromAbi(windowTarget); + } + + void EnsureDispatcherQueue() + { + if (_dispatcherQueueController == null) + { + DispatcherQueueOptions options = new DispatcherQueueOptions(); + options.apartmentType = DISPATCHERQUEUE_THREAD_APARTMENTTYPE.DQTAT_COM_STA; + options.threadType = DISPATCHERQUEUE_THREAD_TYPE.DQTYPE_THREAD_CURRENT; + options.dwSize = Marshal.SizeOf(typeof(DispatcherQueueOptions)); + + CreateDispatcherQueueController(options, out var queue); + _dispatcherQueueController = Windows.System.DispatcherQueueController.FromAbi(queue); + } + } + } +} + diff --git a/src/Windows/Avalonia.Win32/Composition/D2DEffects.cs b/src/Windows/Avalonia.Win32/Composition/D2DEffects.cs new file mode 100644 index 0000000000..1c761ee082 --- /dev/null +++ b/src/Windows/Avalonia.Win32/Composition/D2DEffects.cs @@ -0,0 +1,91 @@ +using System; + + +namespace Avalonia.Win32 +{ + class D2DEffects + { + public static readonly Guid CLSID_D2D12DAffineTransform = new Guid(0x6AA97485, 0x6354, 0x4CFC, 0x90, 0x8C, 0xE4, 0xA7, 0x4F, 0x62, 0xC9, 0x6C); + + public static readonly Guid CLSID_D2D13DPerspectiveTransform = new Guid(0xC2844D0B, 0x3D86, 0x46E7, 0x85, 0xBA, 0x52, 0x6C, 0x92, 0x40, 0xF3, 0xFB); + + public static readonly Guid CLSID_D2D13DTransform = new Guid(0xE8467B04, 0xEC61, 0x4B8A, 0xB5, 0xDE, 0xD4, 0xD7, 0x3D, 0xEB, 0xEA, 0x5A); + + public static readonly Guid CLSID_D2D1ArithmeticComposite = new Guid(0xFC151437, 0x049A, 0x4784, 0xA2, 0x4A, 0xF1, 0xC4, 0xDA, 0xF2, 0x09, 0x87); + + public static readonly Guid CLSID_D2D1Atlas = new Guid(0x913E2BE4, 0xFDCF, 0x4FE2, 0xA5, 0xF0, 0x24, 0x54, 0xF1, 0x4F, 0xF4, 0x08); + + public static readonly Guid CLSID_D2D1BitmapSource = new Guid(0x5FB6C24D, 0xC6DD, 0x4231, 0x94, 0x4, 0x50, 0xF4, 0xD5, 0xC3, 0x25, 0x2D); + + public static readonly Guid CLSID_D2D1Blend = new Guid(0x81C5B77B, 0x13F8, 0x4CDD, 0xAD, 0x20, 0xC8, 0x90, 0x54, 0x7A, 0xC6, 0x5D); + + public static readonly Guid CLSID_D2D1Border = new Guid(0x2A2D49C0, 0x4ACF, 0x43C7, 0x8C, 0x6A, 0x7C, 0x4A, 0x27, 0x87, 0x4D, 0x27); + + public static readonly Guid CLSID_D2D1Brightness = new Guid(0x8CEA8D1E, 0x77B0, 0x4986, 0xB3, 0xB9, 0x2F, 0x0C, 0x0E, 0xAE, 0x78, 0x87); + + public static readonly Guid CLSID_D2D1ColorManagement = new Guid(0x1A28524C, 0xFDD6, 0x4AA4, 0xAE, 0x8F, 0x83, 0x7E, 0xB8, 0x26, 0x7B, 0x37); + + public static readonly Guid CLSID_D2D1ColorMatrix = new Guid(0x921F03D6, 0x641C, 0x47DF, 0x85, 0x2D, 0xB4, 0xBB, 0x61, 0x53, 0xAE, 0x11); + + public static readonly Guid CLSID_D2D1Composite = new Guid(0x48FC9F51, 0xF6AC, 0x48F1, 0x8B, 0x58, 0x3B, 0x28, 0xAC, 0x46, 0xF7, 0x6D); + + public static readonly Guid CLSID_D2D1ConvolveMatrix = new Guid(0x407F8C08, 0x5533, 0x4331, 0xA3, 0x41, 0x23, 0xCC, 0x38, 0x77, 0x84, 0x3E); + + public static readonly Guid CLSID_D2D1Crop = new Guid(0xE23F7110, 0x0E9A, 0x4324, 0xAF, 0x47, 0x6A, 0x2C, 0x0C, 0x46, 0xF3, 0x5B); + + public static readonly Guid CLSID_D2D1DirectionalBlur = new Guid(0x174319A6, 0x58E9, 0x49B2, 0xBB, 0x63, 0xCA, 0xF2, 0xC8, 0x11, 0xA3, 0xDB); + + public static readonly Guid CLSID_D2D1DiscreteTransfer = new Guid(0x90866FCD, 0x488E, 0x454B, 0xAF, 0x06, 0xE5, 0x04, 0x1B, 0x66, 0xC3, 0x6C); + + public static readonly Guid CLSID_D2D1DisplacementMap = new Guid(0xEDC48364, 0x417, 0x4111, 0x94, 0x50, 0x43, 0x84, 0x5F, 0xA9, 0xF8, 0x90); + + public static readonly Guid CLSID_D2D1DistantDiffuse = new Guid(0x3E7EFD62, 0xA32D, 0x46D4, 0xA8, 0x3C, 0x52, 0x78, 0x88, 0x9A, 0xC9, 0x54); + + public static readonly Guid CLSID_D2D1DistantSpecular = new Guid(0x428C1EE5, 0x77B8, 0x4450, 0x8A, 0xB5, 0x72, 0x21, 0x9C, 0x21, 0xAB, 0xDA); + + public static readonly Guid CLSID_D2D1DpiCompensation = new Guid(0x6C26C5C7, 0x34E0, 0x46FC, 0x9C, 0xFD, 0xE5, 0x82, 0x37, 0x6, 0xE2, 0x28); + + public static readonly Guid CLSID_D2D1Flood = new Guid(0x61C23C20, 0xAE69, 0x4D8E, 0x94, 0xCF, 0x50, 0x07, 0x8D, 0xF6, 0x38, 0xF2); + + public static readonly Guid CLSID_D2D1GammaTransfer = new Guid(0x409444C4, 0xC419, 0x41A0, 0xB0, 0xC1, 0x8C, 0xD0, 0xC0, 0xA1, 0x8E, 0x42); + + public static readonly Guid CLSID_D2D1GaussianBlur = new Guid(0x1FEB6D69, 0x2FE6, 0x4AC9, 0x8C, 0x58, 0x1D, 0x7F, 0x93, 0xE7, 0xA6, 0xA5); + + public static readonly Guid CLSID_D2D1Scale = new Guid(0x9DAF9369, 0x3846, 0x4D0E, 0xA4, 0x4E, 0xC, 0x60, 0x79, 0x34, 0xA5, 0xD7); + + public static readonly Guid CLSID_D2D1Histogram = new Guid(0x881DB7D0, 0xF7EE, 0x4D4D, 0xA6, 0xD2, 0x46, 0x97, 0xAC, 0xC6, 0x6E, 0xE8); + + public static readonly Guid CLSID_D2D1HueRotation = new Guid(0x0F4458EC, 0x4B32, 0x491B, 0x9E, 0x85, 0xBD, 0x73, 0xF4, 0x4D, 0x3E, 0xB6); + + public static readonly Guid CLSID_D2D1LinearTransfer = new Guid(0xAD47C8FD, 0x63EF, 0x4ACC, 0x9B, 0x51, 0x67, 0x97, 0x9C, 0x03, 0x6C, 0x06); + + public static readonly Guid CLSID_D2D1LuminanceToAlpha = new Guid(0x41251AB7, 0x0BEB, 0x46F8, 0x9D, 0xA7, 0x59, 0xE9, 0x3F, 0xCC, 0xE5, 0xDE); + + public static readonly Guid CLSID_D2D1Morphology = new Guid(0xEAE6C40D, 0x626A, 0x4C2D, 0xBF, 0xCB, 0x39, 0x10, 0x01, 0xAB, 0xE2, 0x02); + + public static readonly Guid CLSID_D2D1OpacityMetadata = new Guid(0x6C53006A, 0x4450, 0x4199, 0xAA, 0x5B, 0xAD, 0x16, 0x56, 0xFE, 0xCE, 0x5E); + + public static readonly Guid CLSID_D2D1PointDiffuse = new Guid(0xB9E303C3, 0xC08C, 0x4F91, 0x8B, 0x7B, 0x38, 0x65, 0x6B, 0xC4, 0x8C, 0x20); + + public static readonly Guid CLSID_D2D1PointSpecular = new Guid(0x09C3CA26, 0x3AE2, 0x4F09, 0x9E, 0xBC, 0xED, 0x38, 0x65, 0xD5, 0x3F, 0x22); + + public static readonly Guid CLSID_D2D1Premultiply = new Guid(0x06EAB419, 0xDEED, 0x4018, 0x80, 0xD2, 0x3E, 0x1D, 0x47, 0x1A, 0xDE, 0xB2); + + public static readonly Guid CLSID_D2D1Saturation = new Guid(0x5CB2D9CF, 0x327D, 0x459F, 0xA0, 0xCE, 0x40, 0xC0, 0xB2, 0x08, 0x6B, 0xF7); + + public static readonly Guid CLSID_D2D1Shadow = new Guid(0xC67EA361, 0x1863, 0x4E69, 0x89, 0xDB, 0x69, 0x5D, 0x3E, 0x9A, 0x5B, 0x6B); + + public static readonly Guid CLSID_D2D1SpotDiffuse = new Guid(0x818A1105, 0x7932, 0x44F4, 0xAA, 0x86, 0x08, 0xAE, 0x7B, 0x2F, 0x2C, 0x93); + + public static readonly Guid CLSID_D2D1SpotSpecular = new Guid(0xEDAE421E, 0x7654, 0x4A37, 0x9D, 0xB8, 0x71, 0xAC, 0xC1, 0xBE, 0xB3, 0xC1); + + public static readonly Guid CLSID_D2D1TableTransfer = new Guid(0x5BF818C3, 0x5E43, 0x48CB, 0xB6, 0x31, 0x86, 0x83, 0x96, 0xD6, 0xA1, 0xD4); + + public static readonly Guid CLSID_D2D1Tile = new Guid(0xB0784138, 0x3B76, 0x4BC5, 0xB1, 0x3B, 0x0F, 0xA2, 0xAD, 0x02, 0x65, 0x9F); + + public static readonly Guid CLSID_D2D1Turbulence = new Guid(0xCF2BB6AE, 0x889A, 0x4AD7, 0xBA, 0x29, 0xA2, 0xFD, 0x73, 0x2C, 0x9F, 0xC9); + + public static readonly Guid CLSID_D2D1UnPremultiply = new Guid(0xFB9AC489, 0xAD8D, 0x41ED, 0x99, 0x99, 0xBB, 0x63, 0x47, 0xD1, 0x10, 0xF7); + } +} + diff --git a/src/Windows/Avalonia.Win32/Composition/GRAPHICS_EFFECT_PROPERTY_MAPPING.cs b/src/Windows/Avalonia.Win32/Composition/GRAPHICS_EFFECT_PROPERTY_MAPPING.cs new file mode 100644 index 0000000000..f5d5fc4ad3 --- /dev/null +++ b/src/Windows/Avalonia.Win32/Composition/GRAPHICS_EFFECT_PROPERTY_MAPPING.cs @@ -0,0 +1,18 @@ +namespace Windows.Graphics.Effects.Interop +{ + public enum GRAPHICS_EFFECT_PROPERTY_MAPPING + { + GRAPHICS_EFFECT_PROPERTY_MAPPING_UNKNOWN, + GRAPHICS_EFFECT_PROPERTY_MAPPING_DIRECT, + GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORX, + GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORY, + GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORZ, + GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORW, + GRAPHICS_EFFECT_PROPERTY_MAPPING_RECT_TO_VECTOR4, + GRAPHICS_EFFECT_PROPERTY_MAPPING_RADIANS_TO_DEGREES, + GRAPHICS_EFFECT_PROPERTY_MAPPING_COLORMATRIX_ALPHA_MODE, + GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR3, + GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR4 + }; +} + diff --git a/src/Windows/Avalonia.Win32/Composition/GaussianBlurEffect.cs b/src/Windows/Avalonia.Win32/Composition/GaussianBlurEffect.cs new file mode 100644 index 0000000000..19595e8977 --- /dev/null +++ b/src/Windows/Avalonia.Win32/Composition/GaussianBlurEffect.cs @@ -0,0 +1,79 @@ +using System; +using Windows.Graphics.Effects; +using Windows.Graphics.Effects.Interop; +using Windows.UI.Composition; + + +namespace Avalonia.Win32 +{ + class GaussianBlurEffect : IGraphicsEffect, IGraphicsEffectSource, global::Windows.Graphics.Effects.Interop.IGraphicsEffectD2D1Interop + { + enum D2D1_GAUSSIANBLUR_OPTIMIZATION + { + D2D1_GAUSSIANBLUR_OPTIMIZATION_SPEED, + D2D1_GAUSSIANBLUR_OPTIMIZATION_BALANCED, + D2D1_GAUSSIANBLUR_OPTIMIZATION_QUALITY, + D2D1_GAUSSIANBLUR_OPTIMIZATION_FORCE_DWORD + }; + + enum D2D1_BORDER_MODE + { + D2D1_BORDER_MODE_SOFT, + D2D1_BORDER_MODE_HARD, + D2D1_BORDER_MODE_FORCE_DWORD + }; + + enum D2D1GaussianBlurProp + { + D2D1_GAUSSIANBLUR_PROP_STANDARD_DEVIATION, + D2D1_GAUSSIANBLUR_PROP_OPTIMIZATION, + D2D1_GAUSSIANBLUR_PROP_BORDER_MODE, + D2D1_GAUSSIANBLUR_PROP_FORCE_DWORD + }; + + public string Name { get; set; } + + public Guid EffectId => D2DEffects.CLSID_D2D1GaussianBlur; + + public uint PropertyCount => 3; + + public uint SourceCount => 1; + + public uint GetNamedPropertyMapping(string name, out GRAPHICS_EFFECT_PROPERTY_MAPPING mapping) + { + throw new NotImplementedException(); + } + + public object GetProperty(uint index) + { + switch ((D2D1GaussianBlurProp)index) + { + case D2D1GaussianBlurProp.D2D1_GAUSSIANBLUR_PROP_STANDARD_DEVIATION: + return 30.0f; + + case D2D1GaussianBlurProp.D2D1_GAUSSIANBLUR_PROP_OPTIMIZATION: + return (UInt32)D2D1_GAUSSIANBLUR_OPTIMIZATION.D2D1_GAUSSIANBLUR_OPTIMIZATION_SPEED; + + case D2D1GaussianBlurProp.D2D1_GAUSSIANBLUR_PROP_BORDER_MODE: + return (UInt32)D2D1_BORDER_MODE.D2D1_BORDER_MODE_HARD; + } + + return null; + } + + private IGraphicsEffectSource _source = new CompositionEffectSourceParameter("backdrop"); + + public IGraphicsEffectSource GetSource(uint index) + { + if (index == 0) + { + return _source; + } + else + { + return null; + } + } + } +} + diff --git a/src/Windows/Avalonia.Win32/Composition/ICompositorDesktopInterop.cs b/src/Windows/Avalonia.Win32/Composition/ICompositorDesktopInterop.cs new file mode 100644 index 0000000000..1d4cd3450f --- /dev/null +++ b/src/Windows/Avalonia.Win32/Composition/ICompositorDesktopInterop.cs @@ -0,0 +1,14 @@ +using System; +using System.Runtime.InteropServices; +using WinRT; + +namespace Windows.UI.Composition.Desktop +{ + [WindowsRuntimeType] + [Guid("29E691FA-4567-4DCA-B319-D0F207EB6807")] + public interface ICompositorDesktopInterop + { + void CreateDesktopWindowTarget(IntPtr hwndTarget, bool isTopmost, out IntPtr test); + } +} + diff --git a/src/Windows/Avalonia.Win32/Composition/ICompositorDesktopInterop1.cs b/src/Windows/Avalonia.Win32/Composition/ICompositorDesktopInterop1.cs new file mode 100644 index 0000000000..1c3f06d679 --- /dev/null +++ b/src/Windows/Avalonia.Win32/Composition/ICompositorDesktopInterop1.cs @@ -0,0 +1,69 @@ +using WinRT; + +namespace ABI.Windows.UI.Composition.Desktop +{ + using global::System; + using global::System.Runtime.InteropServices; + + [Guid("29E691FA-4567-4DCA-B319-D0F207EB6807")] + internal class ICompositorDesktopInterop : global::Windows.UI.Composition.Desktop.ICompositorDesktopInterop + + { + [Guid("29E691FA-4567-4DCA-B319-D0F207EB6807")] + public struct Vftbl + { + public delegate int _CreateDesktopWindowTarget(IntPtr thisPtr, IntPtr hwndTarget, byte isTopMost, out IntPtr desktopWindowTarget); + + internal global::WinRT.Interop.IUnknownVftbl IUnknownVftbl; + public _CreateDesktopWindowTarget CreateDesktopWindowTarget; + + + public static readonly Vftbl AbiToProjectionVftable; + public static readonly IntPtr AbiToProjectionVftablePtr; + + static Vftbl() + { + AbiToProjectionVftable = new Vftbl + { + IUnknownVftbl = global::WinRT.Interop.IUnknownVftbl.AbiToProjectionVftbl, + CreateDesktopWindowTarget = Do_Abi_Create_Desktop_Window_Target + }; + AbiToProjectionVftablePtr = Marshal.AllocHGlobal(Marshal.SizeOf()); + Marshal.StructureToPtr(AbiToProjectionVftable, AbiToProjectionVftablePtr, false); + } + + private static int Do_Abi_Create_Desktop_Window_Target(IntPtr thisPtr, IntPtr hwndTarget, byte isTopMost, out IntPtr desktopWindowTarget) + { + try + { + ComWrappersSupport.FindObject(thisPtr).CreateDesktopWindowTarget(hwndTarget, isTopMost != 0, out desktopWindowTarget); + return 0; + } + catch (Exception ex) + { + desktopWindowTarget = IntPtr.Zero; + return Marshal.GetHRForException(ex); + } + } + } + internal static ObjectReference FromAbi(IntPtr thisPtr) => ObjectReference.FromAbi(thisPtr); + + public static implicit operator ICompositorDesktopInterop(IObjectReference obj) => (obj != null) ? new ICompositorDesktopInterop(obj) : null; + protected readonly ObjectReference _obj; + public IObjectReference ObjRef { get => _obj; } + public IntPtr ThisPtr => _obj.ThisPtr; + public ObjectReference AsInterface() => _obj.As(); + public A As() => _obj.AsType(); + public ICompositorDesktopInterop(IObjectReference obj) : this(obj.As()) { } + internal ICompositorDesktopInterop(ObjectReference obj) + { + _obj = obj; + } + + public void CreateDesktopWindowTarget(IntPtr hwndTarget, bool isTopmost, out IntPtr test) + { + Marshal.ThrowExceptionForHR(_obj.Vftbl.CreateDesktopWindowTarget(ThisPtr, hwndTarget, isTopmost ? (byte)1 : (byte)0, out test)); + } + } +} + diff --git a/src/Windows/Avalonia.Win32/Composition/ICompositorInterop.cs b/src/Windows/Avalonia.Win32/Composition/ICompositorInterop.cs new file mode 100644 index 0000000000..d9b25e497e --- /dev/null +++ b/src/Windows/Avalonia.Win32/Composition/ICompositorInterop.cs @@ -0,0 +1,139 @@ +using System; +using System.Runtime.InteropServices; +using WinRT; + +namespace Windows.UI.Composition.Interop +{ + [WindowsRuntimeType] + [Guid("25297D5C-3AD4-4C9C-B5CF-E36A38512330")] + public interface ICompositorInterop + { + ICompositionSurface CreateCompositionSurfaceForHandle(IntPtr swapChain); + + ICompositionSurface CreateCompositionSurfaceForSwapChain(IntPtr swapChain); + + CompositionGraphicsDevice CreateGraphicsDevice(IntPtr renderingDevice); + } +} + +namespace ABI.Windows.UI.Composition.Interop +{ + using global::System; + using global::System.Runtime.InteropServices; + using global::Windows.UI.Composition; + + [Guid("25297D5C-3AD4-4C9C-B5CF-E36A38512330")] + internal class ICompositorInterop : global::Windows.UI.Composition.Interop.ICompositorInterop + + { + [Guid("25297D5C-3AD4-4C9C-B5CF-E36A38512330")] + public struct Vftbl + { + public delegate int _CreateCompositionSurfaceForHandle(IntPtr ThisPtr, IntPtr swapChain, out IntPtr result); + public delegate int _CreateCompositionSurfaceForSwapChain(IntPtr ThisPtr, IntPtr swapChain, out IntPtr result); + public delegate int _CreateGraphicsDevice(IntPtr ThisPtr, IntPtr renderingDevice, out IntPtr result); + + internal global::WinRT.Interop.IUnknownVftbl IUnknownVftbl; + public _CreateCompositionSurfaceForHandle CreateCompositionSurfaceForHandle; + public _CreateCompositionSurfaceForSwapChain CreateCompositionSurfaceForSwapChain; + public _CreateGraphicsDevice CreateGraphicsDevice; + + + public static readonly Vftbl AbiToProjectionVftable; + public static readonly IntPtr AbiToProjectionVftablePtr; + + static Vftbl() + { + AbiToProjectionVftable = new Vftbl + { + IUnknownVftbl = global::WinRT.Interop.IUnknownVftbl.AbiToProjectionVftbl, + + CreateCompositionSurfaceForHandle = Do_Abi_Create_Composition_Surface_For_Handle, + CreateCompositionSurfaceForSwapChain = Do_Abi_Create_Composition_Surface_For_SwapChain, + CreateGraphicsDevice= Do_Abi_Create_Graphics_Device + }; + AbiToProjectionVftablePtr = Marshal.AllocHGlobal(Marshal.SizeOf()); + Marshal.StructureToPtr(AbiToProjectionVftable, AbiToProjectionVftablePtr, false); + } + + private static int Do_Abi_Create_Composition_Surface_For_Handle(IntPtr thisPtr, IntPtr swapChain, out IntPtr surface) + { + try + { + surface = IntPtr.Zero; + //surface = ComWrappersSupport.FindObject(thisPtr).CreateCompositionSurfaceForHandle(swapChain); + return 0; + } + catch (Exception ex) + { + surface = IntPtr.Zero; + return Marshal.GetHRForException(ex); + } + } + + private static int Do_Abi_Create_Composition_Surface_For_SwapChain(IntPtr thisPtr, IntPtr swapChain, out IntPtr surface) + { + try + { + surface = IntPtr.Zero; + //surface = ComWrappersSupport.FindObject(thisPtr).CreateCompositionSurfaceForSwapChain(swapChain); + return 0; + } + catch (Exception ex) + { + surface = IntPtr.Zero; + return Marshal.GetHRForException(ex); + } + } + + private static int Do_Abi_Create_Graphics_Device(IntPtr thisPtr, IntPtr renderingDevice, out IntPtr graphicsDevice) + { + try + { + graphicsDevice = ComWrappersSupport.FindObject(thisPtr).CreateGraphicsDevice(renderingDevice).ThisPtr; + return 0; + } + catch (Exception ex) + { + graphicsDevice = IntPtr.Zero; + return Marshal.GetHRForException(ex); + } + } + } + internal static ObjectReference FromAbi(IntPtr thisPtr) => ObjectReference.FromAbi(thisPtr); + + public static implicit operator ICompositorInterop(IObjectReference obj) => (obj != null) ? new ICompositorInterop(obj) : null; + protected readonly ObjectReference _obj; + public IObjectReference ObjRef { get => _obj; } + public IntPtr ThisPtr => _obj.ThisPtr; + public ObjectReference AsInterface() => _obj.As(); + public A As() => _obj.AsType(); + public ICompositorInterop(IObjectReference obj) : this(obj.As()) { } + internal ICompositorInterop(ObjectReference obj) + { + _obj = obj; + } + + public ICompositionSurface CreateCompositionSurfaceForHandle(IntPtr swapChain) + { + Marshal.ThrowExceptionForHR(_obj.Vftbl.CreateCompositionSurfaceForHandle(ThisPtr, swapChain, out var compositionSurface)); + + return null; + } + + public ICompositionSurface CreateCompositionSurfaceForSwapChain(IntPtr swapChain) + { + Marshal.ThrowExceptionForHR(_obj.Vftbl.CreateCompositionSurfaceForSwapChain(ThisPtr, swapChain, out var compositionSurface)); + + return null; + } + + public CompositionGraphicsDevice CreateGraphicsDevice(IntPtr renderingDevice) + { + Marshal.ThrowExceptionForHR(_obj.Vftbl.CreateGraphicsDevice(ThisPtr, renderingDevice, out var graphicsDevice)); + + return CompositionGraphicsDevice.FromAbi(graphicsDevice); + } + } +} + diff --git a/src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop.cs b/src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop.cs new file mode 100644 index 0000000000..74d3939a98 --- /dev/null +++ b/src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; +using WinRT; + +namespace Windows.Graphics.Effects.Interop +{ + [WindowsRuntimeType] + [Guid("2FC57384-A068-44D7-A331-30982FCF7177")] + public interface IGraphicsEffectD2D1Interop + { + Guid EffectId { get; } + + uint GetNamedPropertyMapping(string name, out GRAPHICS_EFFECT_PROPERTY_MAPPING mapping); + + object GetProperty(uint index); + + uint PropertyCount { get; } + + IGraphicsEffectSource GetSource(uint index); + + uint SourceCount { get; } + } +} + diff --git a/src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop1.cs b/src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop1.cs new file mode 100644 index 0000000000..9d053c9e22 --- /dev/null +++ b/src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop1.cs @@ -0,0 +1,217 @@ +using WinRT; + +namespace ABI.Windows.Graphics.Effects.Interop +{ + using global::System; + using global::System.Runtime.InteropServices; + + [Guid("2FC57384-A068-44D7-A331-30982FCF7177")] + internal class IGraphicsEffectD2D1Interop : global::Windows.Graphics.Effects.Interop.IGraphicsEffectD2D1Interop + + { + [Guid("2FC57384-A068-44D7-A331-30982FCF7177")] + public struct Vftbl + { + public delegate int _GetEffectId(IntPtr thisPtr, out Guid guid); + public delegate int _GetNamedPropertyMapping(IntPtr thisPtr, IntPtr name, IntPtr index, IntPtr mapping); + public delegate int _GetProperty(IntPtr thisPtr, uint index, out IntPtr value); + public unsafe delegate int _GetPropertyCount(IntPtr thisPtr, uint* count); + public delegate int _GetSource(IntPtr thisPtr, uint index, out IntPtr source); + public delegate int _GetSourceCount(IntPtr thisPtr, out uint count); + + internal global::WinRT.Interop.IUnknownVftbl IUnknownVftbl; + public _GetEffectId GetEffectId; + public _GetNamedPropertyMapping GetNamedPropertyMapping; + public _GetPropertyCount GetPropertyCount; + public _GetProperty GetProperty; + public _GetSource GetSource; + public _GetSourceCount GetSourceCount; + + public static readonly Vftbl AbiToProjectionVftable; + public static readonly IntPtr AbiToProjectionVftablePtr; + + unsafe static Vftbl() + { + AbiToProjectionVftable = new Vftbl + { + IUnknownVftbl = global::WinRT.Interop.IUnknownVftbl.AbiToProjectionVftbl, + GetEffectId = Do_Abi_Get_Effect_Id, + GetNamedPropertyMapping = Do_Abi_Get_Property_Mapping, + GetPropertyCount = Do_Abi_Get_Property_Count, + GetProperty = Do_Abi_Get_Property, + GetSource = Do_Abi_Get_Source, + GetSourceCount = Do_Abi_Get_Source_Count + + }; + AbiToProjectionVftablePtr = Marshal.AllocHGlobal(Marshal.SizeOf()); + Marshal.StructureToPtr(AbiToProjectionVftable, AbiToProjectionVftablePtr, false); + } + + private static int Do_Abi_Get_Effect_Id(IntPtr thisPtr, out Guid guid) + { + guid = default; + + try + { + guid = ComWrappersSupport.FindObject(thisPtr).EffectId; + } + catch (Exception ex) + { + return Marshal.GetHRForException(ex); + } + + return 0; + } + + private static int Do_Abi_Get_Property_Mapping(IntPtr thisPtr, IntPtr name, IntPtr index, IntPtr mapping) + { + try + { + ComWrappersSupport.FindObject(thisPtr).GetNamedPropertyMapping(MarshalString.FromAbi(name), out var mappingResult); + } + catch (Exception ex) + { + return Marshal.GetHRForException(ex); + } + + return 0; + } + + private static int Do_Abi_Get_Property(IntPtr thisPtr, uint index, out IntPtr value) + { + value = default; + + try + { + value = MarshalInspectable.CreateMarshaler( + ComWrappersSupport.FindObject(thisPtr).GetProperty(index)) + .As(Guid.Parse("4BD682DD-7554-40E9-9A9B-82654EDE7E62")) + .GetRef(); + + } + catch (Exception ex) + { + return Marshal.GetHRForException(ex); + } + + return 0; + } + + unsafe private static int Do_Abi_Get_Property_Count(IntPtr thisPtr, uint* count) + { + + try + { + var res = ComWrappersSupport.FindObject(thisPtr).PropertyCount; + + if (count != null) + { + *count = res; + } + } + catch (Exception ex) + { + return Marshal.GetHRForException(ex); + } + + return 0; + } + + private static int Do_Abi_Get_Source(IntPtr thisPtr, uint index, out IntPtr value) + { + value = default; + + try + { + var source = ComWrappersSupport.FindObject(thisPtr).GetSource(index); + + value = MarshalInterface.FromManaged(source); + } + catch (Exception ex) + { + return Marshal.GetHRForException(ex); + } + + return 0; + } + + private static int Do_Abi_Get_Source_Count(IntPtr thisPtr, out uint count) + { + count = default; + + try + { + count = ComWrappersSupport.FindObject(thisPtr).SourceCount; + } + catch (Exception ex) + { + return Marshal.GetHRForException(ex); + } + + return 0; + } + } + internal static ObjectReference FromAbi(IntPtr thisPtr) => ObjectReference.FromAbi(thisPtr); + + public static implicit operator IGraphicsEffectD2D1Interop(IObjectReference obj) => (obj != null) ? new IGraphicsEffectD2D1Interop(obj) : null; + protected readonly ObjectReference _obj; + public IObjectReference ObjRef { get => _obj; } + public IntPtr ThisPtr => _obj.ThisPtr; + + public ObjectReference AsInterface() => _obj.As(); + public A As() => _obj.AsType(); + public IGraphicsEffectD2D1Interop(IObjectReference obj) : this(obj.As()) { } + internal IGraphicsEffectD2D1Interop(ObjectReference obj) + { + _obj = obj; + } + + public Guid EffectId + { + get + { + Marshal.ThrowExceptionForHR(_obj.Vftbl.GetEffectId(ThisPtr, out Guid guid)); + return guid; + } + } + + public uint PropertyCount + { + get + { + unsafe + { + uint count = default; + Marshal.ThrowExceptionForHR(_obj.Vftbl.GetPropertyCount(ThisPtr, &count)); + return count; + } + } + } + + public uint SourceCount + { + get + { + Marshal.ThrowExceptionForHR(_obj.Vftbl.GetSourceCount(ThisPtr, out uint count)); + return count; + } + } + + public uint GetNamedPropertyMapping(string name, out global::Windows.Graphics.Effects.Interop.GRAPHICS_EFFECT_PROPERTY_MAPPING mapping) + { + throw new NotImplementedException(); + } + + public object GetProperty(uint index) + { + // Marshal.ThrowExceptionForHR(_obj.Vftbl.GetProperty(ThisPtr, index, out IntPtr value)); + throw new NotImplementedException(); + } + + public global::Windows.Graphics.Effects.IGraphicsEffectSource GetSource(uint index) + { + throw new NotImplementedException(); + } + } +} + diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index 36398eb810..ab07bdebb3 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -599,6 +599,8 @@ namespace Avalonia.Win32 _scaling = dpix / 96.0; } } + + CompositionHost.Instance.Initialize(_hwnd); } private void CreateDropTarget() From bd2b283ad7d4df2e2088916823b174e6d37d9d24 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 25 Jun 2020 18:30:43 -0300 Subject: [PATCH 005/751] add drawing surface interop.. --- .../Composition/CompositionHost.cs | 21 ++- .../ICompositionDrawingSurfaceInterop.cs | 135 ++++++++++++++++++ .../IGraphicsEffectD2D1Interop1.cs | 2 +- 3 files changed, 155 insertions(+), 3 deletions(-) create mode 100644 src/Windows/Avalonia.Win32/Composition/ICompositionDrawingSurfaceInterop.cs diff --git a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs index 223c208829..a94fd82e1a 100644 --- a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs +++ b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs @@ -2,6 +2,7 @@ using System.Runtime.InteropServices; using Avalonia.OpenGL.Angle; using Windows.UI.Composition; +using Windows.UI.Composition.Interop; using WinRT; namespace Avalonia.Win32 @@ -89,8 +90,24 @@ namespace Avalonia.Win32 var gDevice = interop.CreateGraphicsDevice(display.GetDirect3DDevice()); - gDevice.CreateDrawingSurface(new Windows.Foundation.Size(100,100), Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized, Windows.Graphics.DirectX.DirectXAlphaMode.Premultiplied); - + var surface = gDevice.CreateDrawingSurface(new Windows.Foundation.Size(100,100), Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized, Windows.Graphics.DirectX.DirectXAlphaMode.Premultiplied); + + var surfaceInterop = surface.As(); + + surfaceInterop.BeginDraw(new Windows.Foundation.Rect(0, 0, 100, 100), Guid.Parse("6f15aaf2-d208-4e89-9ab4-489535d34f9c"), out var texture, new Windows.Foundation.Point(0, 0)); + surfaceInterop.EndDraw(); + + var brush = _compositor.CreateSurfaceBrush(surface); + + var visual = _compositor.CreateSpriteVisual(); + + visual.RelativeSizeAdjustment = new System.Numerics.Vector2(1.0f, 1.0f); + visual.Brush = brush; + + _target.Root = visual; + + AddElement(100, 200, 200); + } public void CreateBlur() diff --git a/src/Windows/Avalonia.Win32/Composition/ICompositionDrawingSurfaceInterop.cs b/src/Windows/Avalonia.Win32/Composition/ICompositionDrawingSurfaceInterop.cs new file mode 100644 index 0000000000..fd9387b59e --- /dev/null +++ b/src/Windows/Avalonia.Win32/Composition/ICompositionDrawingSurfaceInterop.cs @@ -0,0 +1,135 @@ +using System; +using System.Runtime.InteropServices; +using Windows.Foundation; +using WinRT; + +namespace Windows.UI.Composition.Interop +{ + [WindowsRuntimeType] + [Guid("FD04E6E3-FE0C-4C3C-AB19-A07601A576EE")] + public interface ICompositionDrawingSurfaceInterop + { + void BeginDraw(Rect updateRect, Guid iid, out IntPtr updateObject, Point point); + + void EndDraw(); + + void Resize(Size sizePixels); + + void ResumeDraw(); + + void Scroll(Rect scrollRect, Rect clipRect, int offsetX, int offsetY); + + void SuspendDraw(); + } +} + +namespace ABI.Windows.UI.Composition.Interop +{ + using global::System; + using global::System.Runtime.InteropServices; + using global::Windows.UI.Composition; + + [Guid("FD04E6E3-FE0C-4C3C-AB19-A07601A576EE")] + internal class ICompositionDrawingSurfaceInterop : global::Windows.UI.Composition.Interop.ICompositionDrawingSurfaceInterop + + { + [Guid("FD04E6E3-FE0C-4C3C-AB19-A07601A576EE")] + public struct Vftbl + { + public delegate int _BeginDraw(IntPtr ThisPtr, Guid iid, out IntPtr updateObject, Point updateOffset); + public delegate int _EndDraw(IntPtr ThisPtr); + public delegate int _Resize(IntPtr ThisPtr, Size sizePixels); + public delegate int _ResumeDraw(IntPtr ThisPtr); + public delegate int _Scroll(IntPtr ThisPtr, Rect scrollRect, Rect clipRect, int offsetX, int offsetY); + public delegate int _SuspendDraw(IntPtr ThisPtr); + + internal global::WinRT.Interop.IUnknownVftbl IUnknownVftbl; + public _BeginDraw BeginDraw; + public _EndDraw EndDraw; + public _Resize Resize; + public _ResumeDraw ResumeDraw; + public _Scroll Scroll; + public _SuspendDraw SuspendDraw; + + public static readonly Vftbl AbiToProjectionVftable; + public static readonly IntPtr AbiToProjectionVftablePtr; + + static Vftbl() + { + AbiToProjectionVftable = new Vftbl + { + IUnknownVftbl = global::WinRT.Interop.IUnknownVftbl.AbiToProjectionVftbl, + + BeginDraw = Do_Abi_BeginDraw, + EndDraw = Do_Abi_EndDraw, + Resize = Do_Abi_Resize + + + }; + AbiToProjectionVftablePtr = Marshal.AllocHGlobal(Marshal.SizeOf()); + Marshal.StructureToPtr(AbiToProjectionVftable, AbiToProjectionVftablePtr, false); + } + + private static int Do_Abi_BeginDraw(IntPtr ThisPtr, Guid iid, out IntPtr updateObject, Point updateOffset) + { + updateObject = IntPtr.Zero; + return 0; + } + + private static int Do_Abi_EndDraw(IntPtr ThisPtr) + { + return 0; + } + + private static int Do_Abi_Resize(IntPtr ThisPtr, Size sizePixels) + { + return 0; + } + } + internal static ObjectReference FromAbi(IntPtr thisPtr) => ObjectReference.FromAbi(thisPtr); + + public static implicit operator ICompositionDrawingSurfaceInterop(IObjectReference obj) => (obj != null) ? new ICompositionDrawingSurfaceInterop(obj) : null; + protected readonly ObjectReference _obj; + public IObjectReference ObjRef { get => _obj; } + public IntPtr ThisPtr => _obj.ThisPtr; + public ObjectReference AsInterface() => _obj.As(); + public A As() => _obj.AsType(); + + public ICompositionDrawingSurfaceInterop(IObjectReference obj) : this(obj.As()) { } + internal ICompositionDrawingSurfaceInterop(ObjectReference obj) + { + _obj = obj; + } + + public void BeginDraw(Rect updateRect, Guid iid, out IntPtr updateObject, Point point) + { + Marshal.ThrowExceptionForHR(_obj.Vftbl.BeginDraw(ThisPtr, iid, out updateObject, point)); + } + + public void EndDraw() + { + Marshal.ThrowExceptionForHR(_obj.Vftbl.EndDraw(ThisPtr)); + } + + public void Resize(Size sizePixels) + { + throw new NotImplementedException(); + } + + public void ResumeDraw() + { + throw new NotImplementedException(); + } + + public void Scroll(Rect scrollRect, Rect clipRect, int offsetX, int offsetY) + { + throw new NotImplementedException(); + } + + public void SuspendDraw() + { + throw new NotImplementedException(); + } + } +} + diff --git a/src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop1.cs b/src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop1.cs index 9d053c9e22..8466b05fb5 100644 --- a/src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop1.cs +++ b/src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop1.cs @@ -122,7 +122,7 @@ namespace ABI.Windows.Graphics.Effects.Interop value = default; try - { + { var source = ComWrappersSupport.FindObject(thisPtr).GetSource(index); value = MarshalInterface.FromManaged(source); From 016935a0235844b0d0b1fed42735c26f22060b72 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Fri, 26 Jun 2020 11:54:23 -0300 Subject: [PATCH 006/751] attached composition gl surface to composition tree. --- .../Composition/CompositionHost.cs | 67 +++++++++++++++++-- src/Windows/Avalonia.Win32/WindowImpl.cs | 11 +-- 2 files changed, 69 insertions(+), 9 deletions(-) diff --git a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs index a94fd82e1a..961c3b0319 100644 --- a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs +++ b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.InteropServices; +using Avalonia.OpenGL; using Avalonia.OpenGL.Angle; using Windows.UI.Composition; using Windows.UI.Composition.Interop; @@ -7,6 +8,61 @@ using WinRT; namespace Avalonia.Win32 { + public class CompositionEglGlPlatformSurface : EglGlPlatformSurfaceBase + { + private readonly EglDisplay _display; + private readonly EglContext _context; + private readonly IEglWindowGlPlatformSurfaceInfo _info; + private ICompositionDrawingSurfaceInterop _surfaceInterop; + + public CompositionEglGlPlatformSurface(EglContext context, IEglWindowGlPlatformSurfaceInfo info) : base() + { + _display = context.Display; + _context = context; + _info = info; + } + + public void AttachToCompositionTree(IntPtr hwnd) + { + _surfaceInterop = CompositionHost.Instance.Initialize(hwnd); + } + + public override IGlPlatformSurfaceRenderTarget CreateGlRenderTarget() + { + var glSurface = _display.CreateWindowSurface(_info.Handle); + return new CompositionRenderTarget(_display, _context, glSurface, _surfaceInterop, _info); + } + + class CompositionRenderTarget : EglPlatformSurfaceRenderTargetBase + { + private readonly EglDisplay _display; + private readonly EglContext _context; + private readonly EglSurface _glSurface; + private readonly IEglWindowGlPlatformSurfaceInfo _info; + private PixelSize _initialSize; + private readonly ICompositionDrawingSurfaceInterop _surfaceInterop; + + public CompositionRenderTarget(EglDisplay display, EglContext context, + EglSurface glSurface, ICompositionDrawingSurfaceInterop interopSurface, IEglWindowGlPlatformSurfaceInfo info) : base(display, context) + { + _display = display; + _context = context; + _glSurface = glSurface; + _surfaceInterop = interopSurface; + _info = info; + _initialSize = info.Size; + } + + public override void Dispose() => _glSurface.Dispose(); + + public override bool IsCorrupted => _initialSize != _info.Size; + + public override IGlPlatformSurfaceRenderingSession BeginDraw() => base.BeginDraw(_glSurface, _info); + } + } + + + class CompositionHost { internal enum DISPATCHERQUEUE_THREAD_APARTMENTTYPE @@ -75,7 +131,7 @@ namespace Avalonia.Win32 } } - public void Initialize(IntPtr hwnd) + public ICompositionDrawingSurfaceInterop Initialize(IntPtr hwnd) { EnsureDispatcherQueue(); if (_dispatcherQueueController != null) @@ -90,13 +146,13 @@ namespace Avalonia.Win32 var gDevice = interop.CreateGraphicsDevice(display.GetDirect3DDevice()); - var surface = gDevice.CreateDrawingSurface(new Windows.Foundation.Size(100,100), Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized, Windows.Graphics.DirectX.DirectXAlphaMode.Premultiplied); + var surface = gDevice.CreateDrawingSurface(new Windows.Foundation.Size(100, 100), Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized, Windows.Graphics.DirectX.DirectXAlphaMode.Premultiplied); var surfaceInterop = surface.As(); - surfaceInterop.BeginDraw(new Windows.Foundation.Rect(0, 0, 100, 100), Guid.Parse("6f15aaf2-d208-4e89-9ab4-489535d34f9c"), out var texture, new Windows.Foundation.Point(0, 0)); - surfaceInterop.EndDraw(); - + //surfaceInterop.BeginDraw(new Windows.Foundation.Rect(0, 0, 100, 100), Guid.Parse("6f15aaf2-d208-4e89-9ab4-489535d34f9c"), out var texture, new Windows.Foundation.Point(0, 0)); + //surfaceInterop.EndDraw(); + var brush = _compositor.CreateSurfaceBrush(surface); var visual = _compositor.CreateSpriteVisual(); @@ -108,6 +164,7 @@ namespace Avalonia.Win32 AddElement(100, 200, 200); + return surfaceInterop; } public void CreateBlur() diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index ab07bdebb3..03d2a328a6 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -100,7 +100,12 @@ namespace Avalonia.Win32 _framebuffer = new FramebufferManager(_hwnd); if (Win32GlManager.EglFeature != null) - _gl = new EglGlPlatformSurface(Win32GlManager.EglFeature.DeferredContext, this); + _gl = new CompositionEglGlPlatformSurface(Win32GlManager.EglFeature.DeferredContext, this); + + if (_gl is CompositionEglGlPlatformSurface cgl) + { + cgl.AttachToCompositionTree(_hwnd); + } Screen = new ScreenImpl(); @@ -598,9 +603,7 @@ namespace Avalonia.Win32 { _scaling = dpix / 96.0; } - } - - CompositionHost.Instance.Initialize(_hwnd); + } } private void CreateDropTarget() From 203e346a4d855dba07d64173844434fa31fdd1f1 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Fri, 26 Jun 2020 12:49:48 -0300 Subject: [PATCH 007/751] make begindraw work. --- .../Composition/CompositionHost.cs | 96 +++++++++++++++---- .../ICompositionDrawingSurfaceInterop.cs | 45 ++++++--- 2 files changed, 110 insertions(+), 31 deletions(-) diff --git a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs index 961c3b0319..5f20d18faf 100644 --- a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs +++ b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs @@ -28,36 +28,99 @@ namespace Avalonia.Win32 } public override IGlPlatformSurfaceRenderTarget CreateGlRenderTarget() - { - var glSurface = _display.CreateWindowSurface(_info.Handle); - return new CompositionRenderTarget(_display, _context, glSurface, _surfaceInterop, _info); + { + return new CompositionRenderTarget(_display, _context, _surfaceInterop, _info); } class CompositionRenderTarget : EglPlatformSurfaceRenderTargetBase { private readonly EglDisplay _display; - private readonly EglContext _context; - private readonly EglSurface _glSurface; + private readonly EglContext _context; private readonly IEglWindowGlPlatformSurfaceInfo _info; private PixelSize _initialSize; private readonly ICompositionDrawingSurfaceInterop _surfaceInterop; - public CompositionRenderTarget(EglDisplay display, EglContext context, - EglSurface glSurface, ICompositionDrawingSurfaceInterop interopSurface, IEglWindowGlPlatformSurfaceInfo info) : base(display, context) + public CompositionRenderTarget(EglDisplay display, EglContext context, ICompositionDrawingSurfaceInterop interopSurface, IEglWindowGlPlatformSurfaceInfo info) : base(display, context) { _display = display; - _context = context; - _glSurface = glSurface; + _context = context; _surfaceInterop = interopSurface; _info = info; _initialSize = info.Size; } - public override void Dispose() => _glSurface.Dispose(); + public override bool IsCorrupted => _initialSize != _info.Size; + + public override IGlPlatformSurfaceRenderingSession BeginDraw() + { + var l = _context.Lock(); + + var iid = Guid.Parse("6f15aaf2-d208-4e89-9ab4-489535d34f9c"); + var updateRect = new RECT { right = _info.Size.Width, bottom = _info.Size.Height }; + var offset = new POINT(); + + _surfaceInterop.Resize(new POINT { X = _info.Size.Width, Y = _info.Size.Height }); + _surfaceInterop.BeginDraw( + ref updateRect, + ref iid, + out IntPtr texture, ref offset); - public override bool IsCorrupted => _initialSize != _info.Size; + var surface = (_display as AngleWin32EglDisplay).WrapDirect3D11Texture(texture); - public override IGlPlatformSurfaceRenderingSession BeginDraw() => base.BeginDraw(_glSurface, _info); + var restoreContext = _context.MakeCurrent(surface); + + return new Session(_display, _context, null, _info, l, restoreContext, () => { }, true); + } + + public override void Dispose() + { + _surfaceInterop.EndDraw(); + base.Dispose(); + } + } + + class Session : IGlPlatformSurfaceRenderingSession + { + private readonly EglContext _context; + private readonly EglSurface _glSurface; + private readonly EglGlPlatformSurfaceBase.IEglWindowGlPlatformSurfaceInfo _info; + private readonly EglDisplay _display; + private readonly IDisposable _lock; + private readonly IDisposable _restoreContext; + private readonly Action _onFinish; + + + public Session(EglDisplay display, EglContext context, + EglSurface glSurface, EglGlPlatformSurfaceBase.IEglWindowGlPlatformSurfaceInfo info, + IDisposable @lock, IDisposable restoreContext, Action onFinish, bool isYFlipped) + { + IsYFlipped = isYFlipped; + _context = context; + _display = display; + _glSurface = glSurface; + _info = info; + _lock = @lock; + _restoreContext = restoreContext; + _onFinish = onFinish; + } + + public void Dispose() + { + _context.GlInterface.Flush(); + _display.EglInterface.WaitGL(); + _glSurface?.SwapBuffers(); + _display.EglInterface.WaitClient(); + _display.EglInterface.WaitGL(); + _display.EglInterface.WaitNative(EglConsts.EGL_CORE_NATIVE_ENGINE); + _restoreContext.Dispose(); + _lock.Dispose(); + _onFinish?.Invoke(); + } + + public IGlContext Context => _context; + public PixelSize Size => _info.Size; + public double Scaling => _info.Scaling; + public bool IsYFlipped { get; } } } @@ -146,12 +209,11 @@ namespace Avalonia.Win32 var gDevice = interop.CreateGraphicsDevice(display.GetDirect3DDevice()); - var surface = gDevice.CreateDrawingSurface(new Windows.Foundation.Size(100, 100), Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized, Windows.Graphics.DirectX.DirectXAlphaMode.Premultiplied); - - var surfaceInterop = surface.As(); + var surface = gDevice.CreateDrawingSurface(new Windows.Foundation.Size(100, 100), + Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized, + Windows.Graphics.DirectX.DirectXAlphaMode.Premultiplied); - //surfaceInterop.BeginDraw(new Windows.Foundation.Rect(0, 0, 100, 100), Guid.Parse("6f15aaf2-d208-4e89-9ab4-489535d34f9c"), out var texture, new Windows.Foundation.Point(0, 0)); - //surfaceInterop.EndDraw(); + var surfaceInterop = surface.As(); var brush = _compositor.CreateSurfaceBrush(surface); diff --git a/src/Windows/Avalonia.Win32/Composition/ICompositionDrawingSurfaceInterop.cs b/src/Windows/Avalonia.Win32/Composition/ICompositionDrawingSurfaceInterop.cs index fd9387b59e..8fea5f293b 100644 --- a/src/Windows/Avalonia.Win32/Composition/ICompositionDrawingSurfaceInterop.cs +++ b/src/Windows/Avalonia.Win32/Composition/ICompositionDrawingSurfaceInterop.cs @@ -1,23 +1,39 @@ using System; using System.Runtime.InteropServices; -using Windows.Foundation; using WinRT; namespace Windows.UI.Composition.Interop { + public struct POINT + { + public int X; + public int Y; + } + + public struct RECT + { + public int left; + public int top; + public int right; + public int bottom; + + public int Width => right - left; + public int Height => bottom - top; + } + [WindowsRuntimeType] [Guid("FD04E6E3-FE0C-4C3C-AB19-A07601A576EE")] public interface ICompositionDrawingSurfaceInterop { - void BeginDraw(Rect updateRect, Guid iid, out IntPtr updateObject, Point point); + void BeginDraw(ref RECT updateRect, ref Guid iid, out IntPtr updateObject, ref POINT point); void EndDraw(); - void Resize(Size sizePixels); + void Resize(POINT sizePixels); void ResumeDraw(); - void Scroll(Rect scrollRect, Rect clipRect, int offsetX, int offsetY); + void Scroll(RECT scrollRect, RECT clipRect, int offsetX, int offsetY); void SuspendDraw(); } @@ -28,6 +44,7 @@ namespace ABI.Windows.UI.Composition.Interop using global::System; using global::System.Runtime.InteropServices; using global::Windows.UI.Composition; + using global::Windows.UI.Composition.Interop; [Guid("FD04E6E3-FE0C-4C3C-AB19-A07601A576EE")] internal class ICompositionDrawingSurfaceInterop : global::Windows.UI.Composition.Interop.ICompositionDrawingSurfaceInterop @@ -36,11 +53,11 @@ namespace ABI.Windows.UI.Composition.Interop [Guid("FD04E6E3-FE0C-4C3C-AB19-A07601A576EE")] public struct Vftbl { - public delegate int _BeginDraw(IntPtr ThisPtr, Guid iid, out IntPtr updateObject, Point updateOffset); + public delegate int _BeginDraw(IntPtr ThisPtr, ref RECT updateRect, ref Guid iid, out IntPtr updateObject, ref POINT updateOffset); public delegate int _EndDraw(IntPtr ThisPtr); - public delegate int _Resize(IntPtr ThisPtr, Size sizePixels); + public delegate int _Resize(IntPtr ThisPtr, POINT sizePixels); public delegate int _ResumeDraw(IntPtr ThisPtr); - public delegate int _Scroll(IntPtr ThisPtr, Rect scrollRect, Rect clipRect, int offsetX, int offsetY); + public delegate int _Scroll(IntPtr ThisPtr, RECT scrollRect, RECT clipRect, int offsetX, int offsetY); public delegate int _SuspendDraw(IntPtr ThisPtr); internal global::WinRT.Interop.IUnknownVftbl IUnknownVftbl; @@ -70,7 +87,7 @@ namespace ABI.Windows.UI.Composition.Interop Marshal.StructureToPtr(AbiToProjectionVftable, AbiToProjectionVftablePtr, false); } - private static int Do_Abi_BeginDraw(IntPtr ThisPtr, Guid iid, out IntPtr updateObject, Point updateOffset) + private static int Do_Abi_BeginDraw(IntPtr ThisPtr, ref RECT updateRect, ref Guid iid, out IntPtr updateObject, ref POINT updateOffset) { updateObject = IntPtr.Zero; return 0; @@ -81,7 +98,7 @@ namespace ABI.Windows.UI.Composition.Interop return 0; } - private static int Do_Abi_Resize(IntPtr ThisPtr, Size sizePixels) + private static int Do_Abi_Resize(IntPtr ThisPtr, POINT sizePixels) { return 0; } @@ -101,9 +118,9 @@ namespace ABI.Windows.UI.Composition.Interop _obj = obj; } - public void BeginDraw(Rect updateRect, Guid iid, out IntPtr updateObject, Point point) + public void BeginDraw(ref RECT updateRect, ref Guid iid, out IntPtr updateObject, ref POINT point) { - Marshal.ThrowExceptionForHR(_obj.Vftbl.BeginDraw(ThisPtr, iid, out updateObject, point)); + Marshal.ThrowExceptionForHR(_obj.Vftbl.BeginDraw(ThisPtr, ref updateRect, ref iid, out updateObject, ref point)); } public void EndDraw() @@ -111,9 +128,9 @@ namespace ABI.Windows.UI.Composition.Interop Marshal.ThrowExceptionForHR(_obj.Vftbl.EndDraw(ThisPtr)); } - public void Resize(Size sizePixels) + public void Resize(POINT sizePixels) { - throw new NotImplementedException(); + Marshal.ThrowExceptionForHR(_obj.Vftbl.Resize(ThisPtr, sizePixels)); } public void ResumeDraw() @@ -121,7 +138,7 @@ namespace ABI.Windows.UI.Composition.Interop throw new NotImplementedException(); } - public void Scroll(Rect scrollRect, Rect clipRect, int offsetX, int offsetY) + public void Scroll(RECT scrollRect, RECT clipRect, int offsetX, int offsetY) { throw new NotImplementedException(); } From 6adb1d062475ec8679ef01048bba24902c2c95b8 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Fri, 26 Jun 2020 12:51:37 -0300 Subject: [PATCH 008/751] pass in wrapped surface to session. --- src/Windows/Avalonia.Win32/Composition/CompositionHost.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs index 5f20d18faf..02291d93ed 100644 --- a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs +++ b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs @@ -69,7 +69,7 @@ namespace Avalonia.Win32 var restoreContext = _context.MakeCurrent(surface); - return new Session(_display, _context, null, _info, l, restoreContext, () => { }, true); + return new Session(_display, _context, surface, _info, l, restoreContext, () => { }, true); } public override void Dispose() @@ -108,7 +108,7 @@ namespace Avalonia.Win32 { _context.GlInterface.Flush(); _display.EglInterface.WaitGL(); - _glSurface?.SwapBuffers(); + _glSurface.SwapBuffers(); _display.EglInterface.WaitClient(); _display.EglInterface.WaitGL(); _display.EglInterface.WaitNative(EglConsts.EGL_CORE_NATIVE_ENGINE); From f5dd50e8ea855a8e903af1e872648b60c5e7de52 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Fri, 26 Jun 2020 12:56:46 -0300 Subject: [PATCH 009/751] call enddraw. --- src/Windows/Avalonia.Win32/Composition/CompositionHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs index 02291d93ed..b82fbc7d1d 100644 --- a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs +++ b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs @@ -69,7 +69,7 @@ namespace Avalonia.Win32 var restoreContext = _context.MakeCurrent(surface); - return new Session(_display, _context, surface, _info, l, restoreContext, () => { }, true); + return new Session(_display, _context, surface, _info, l, restoreContext, () => { _surfaceInterop.EndDraw(); }, true); } public override void Dispose() From f0c2ff7394715407368979f5361f7746a032099e Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Fri, 26 Jun 2020 13:02:03 -0300 Subject: [PATCH 010/751] call base.BeginDraw we dont need our own session class. --- .../Composition/CompositionHost.cs | 52 +------------------ 1 file changed, 1 insertion(+), 51 deletions(-) diff --git a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs index b82fbc7d1d..3837134643 100644 --- a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs +++ b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs @@ -69,58 +69,8 @@ namespace Avalonia.Win32 var restoreContext = _context.MakeCurrent(surface); - return new Session(_display, _context, surface, _info, l, restoreContext, () => { _surfaceInterop.EndDraw(); }, true); + return base.BeginDraw(surface, _info, () => { _surfaceInterop.EndDraw(); }, true); } - - public override void Dispose() - { - _surfaceInterop.EndDraw(); - base.Dispose(); - } - } - - class Session : IGlPlatformSurfaceRenderingSession - { - private readonly EglContext _context; - private readonly EglSurface _glSurface; - private readonly EglGlPlatformSurfaceBase.IEglWindowGlPlatformSurfaceInfo _info; - private readonly EglDisplay _display; - private readonly IDisposable _lock; - private readonly IDisposable _restoreContext; - private readonly Action _onFinish; - - - public Session(EglDisplay display, EglContext context, - EglSurface glSurface, EglGlPlatformSurfaceBase.IEglWindowGlPlatformSurfaceInfo info, - IDisposable @lock, IDisposable restoreContext, Action onFinish, bool isYFlipped) - { - IsYFlipped = isYFlipped; - _context = context; - _display = display; - _glSurface = glSurface; - _info = info; - _lock = @lock; - _restoreContext = restoreContext; - _onFinish = onFinish; - } - - public void Dispose() - { - _context.GlInterface.Flush(); - _display.EglInterface.WaitGL(); - _glSurface.SwapBuffers(); - _display.EglInterface.WaitClient(); - _display.EglInterface.WaitGL(); - _display.EglInterface.WaitNative(EglConsts.EGL_CORE_NATIVE_ENGINE); - _restoreContext.Dispose(); - _lock.Dispose(); - _onFinish?.Invoke(); - } - - public IGlContext Context => _context; - public PixelSize Size => _info.Size; - public double Scaling => _info.Scaling; - public bool IsYFlipped { get; } } } From 53f3bc6e7fe84fc0fb3bf9e5f11fd327664ff9ca Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Fri, 26 Jun 2020 13:25:24 -0300 Subject: [PATCH 011/751] working rendering. --- .../Composition/CompositionHost.cs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs index 3837134643..d4bbb67a3b 100644 --- a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs +++ b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs @@ -28,14 +28,14 @@ namespace Avalonia.Win32 } public override IGlPlatformSurfaceRenderTarget CreateGlRenderTarget() - { + { return new CompositionRenderTarget(_display, _context, _surfaceInterop, _info); } class CompositionRenderTarget : EglPlatformSurfaceRenderTargetBase { private readonly EglDisplay _display; - private readonly EglContext _context; + private readonly EglContext _context; private readonly IEglWindowGlPlatformSurfaceInfo _info; private PixelSize _initialSize; private readonly ICompositionDrawingSurfaceInterop _surfaceInterop; @@ -43,7 +43,7 @@ namespace Avalonia.Win32 public CompositionRenderTarget(EglDisplay display, EglContext context, ICompositionDrawingSurfaceInterop interopSurface, IEglWindowGlPlatformSurfaceInfo info) : base(display, context) { _display = display; - _context = context; + _context = context; _surfaceInterop = interopSurface; _info = info; _initialSize = info.Size; @@ -53,8 +53,6 @@ namespace Avalonia.Win32 public override IGlPlatformSurfaceRenderingSession BeginDraw() { - var l = _context.Lock(); - var iid = Guid.Parse("6f15aaf2-d208-4e89-9ab4-489535d34f9c"); var updateRect = new RECT { right = _info.Size.Width, bottom = _info.Size.Height }; var offset = new POINT(); @@ -67,8 +65,6 @@ namespace Avalonia.Win32 var surface = (_display as AngleWin32EglDisplay).WrapDirect3D11Texture(texture); - var restoreContext = _context.MakeCurrent(surface); - return base.BeginDraw(surface, _info, () => { _surfaceInterop.EndDraw(); }, true); } } @@ -159,11 +155,11 @@ namespace Avalonia.Win32 var gDevice = interop.CreateGraphicsDevice(display.GetDirect3DDevice()); - var surface = gDevice.CreateDrawingSurface(new Windows.Foundation.Size(100, 100), - Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized, + var surface = gDevice.CreateDrawingSurface(new Windows.Foundation.Size(100, 100), + Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized, Windows.Graphics.DirectX.DirectXAlphaMode.Premultiplied); - var surfaceInterop = surface.As(); + var surfaceInterop = surface.As(); var brush = _compositor.CreateSurfaceBrush(surface); @@ -174,7 +170,7 @@ namespace Avalonia.Win32 _target.Root = visual; - AddElement(100, 200, 200); + //CreateBlur(); return surfaceInterop; } From e53dfc0d360cb1c34706ae81b54bda7aed65b4c2 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Fri, 26 Jun 2020 14:02:51 -0300 Subject: [PATCH 012/751] add blur and avalonia surface visual ontop of blur. --- samples/ControlCatalog/MainWindow.xaml | 3 ++- .../Avalonia.Win32/Composition/CompositionHost.cs | 11 +++++++---- .../Avalonia.Win32/Interop/UnmanagedMethods.cs | 1 + src/Windows/Avalonia.Win32/WindowImpl.cs | 4 ++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/samples/ControlCatalog/MainWindow.xaml b/samples/ControlCatalog/MainWindow.xaml index 76422bc130..c34e392d40 100644 --- a/samples/ControlCatalog/MainWindow.xaml +++ b/samples/ControlCatalog/MainWindow.xaml @@ -7,7 +7,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="clr-namespace:ControlCatalog.ViewModels" xmlns:v="clr-namespace:ControlCatalog.Views" - x:Class="ControlCatalog.MainWindow" WindowState="{Binding WindowState, Mode=TwoWay}" Background="{DynamicResource SystemControlPageBackgroundAltHighBrush}"> + TransparencyLevelHint="Transparent" + x:Class="ControlCatalog.MainWindow" WindowState="{Binding WindowState, Mode=TwoWay}" Background="{x:Null}"> diff --git a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs index d4bbb67a3b..874bdaaf69 100644 --- a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs +++ b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs @@ -155,7 +155,7 @@ namespace Avalonia.Win32 var gDevice = interop.CreateGraphicsDevice(display.GetDirect3DDevice()); - var surface = gDevice.CreateDrawingSurface(new Windows.Foundation.Size(100, 100), + var surface = gDevice.CreateDrawingSurface(new Windows.Foundation.Size(0, 0), Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized, Windows.Graphics.DirectX.DirectXAlphaMode.Premultiplied); @@ -167,10 +167,13 @@ namespace Avalonia.Win32 visual.RelativeSizeAdjustment = new System.Numerics.Vector2(1.0f, 1.0f); visual.Brush = brush; + //_target.Root = visual; - _target.Root = visual; + CreateBlur(); + + var visuals = _target.Root.As().Children; - //CreateBlur(); + visuals.InsertAtTop(visual); return surfaceInterop; } @@ -196,7 +199,7 @@ namespace Avalonia.Win32 void CreateCompositionRoot() { var root = _compositor.CreateContainerVisual(); - root.RelativeSizeAdjustment = new System.Numerics.Vector2(1.0f, 1.0f); + root.RelativeSizeAdjustment = new System.Numerics.Vector2(1.0f, 1.0f); //root.Offset = new System.Numerics.Vector3(0, 0, 0); _target.Root = root; } diff --git a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs index b3b38db1ab..bef65a06d8 100644 --- a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs +++ b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs @@ -465,6 +465,7 @@ namespace Avalonia.Win32.Interop WS_VSCROLL = 0x200000, WS_EX_DLGMODALFRAME = 0x00000001, WS_EX_NOPARENTNOTIFY = 0x00000004, + WS_EX_NOREDIRECTIONBITMAP = 0x00200000, WS_EX_TOPMOST = 0x00000008, WS_EX_ACCEPTFILES = 0x00000010, WS_EX_TRANSPARENT = 0x00000020, diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index 03d2a328a6..fdde128800 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -106,6 +106,10 @@ namespace Avalonia.Win32 { cgl.AttachToCompositionTree(_hwnd); } + else + { + CompositionHost.Instance.Initialize(_hwnd); + } Screen = new ScreenImpl(); From 1f9e395fabb55234e452cdfe94562774e950e61a Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Fri, 26 Jun 2020 14:53:05 -0300 Subject: [PATCH 013/751] hack to clear window context, and only call interopsurface.resize when size actually changes. --- .../Composition/CompositionHost.cs | 33 +++++++++++++++++-- .../Composition/GaussianBlurEffect.cs | 2 +- src/Windows/Avalonia.Win32/WindowImpl.cs | 2 ++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs index 874bdaaf69..fd76e4a523 100644 --- a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs +++ b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs @@ -51,13 +51,42 @@ namespace Avalonia.Win32 public override bool IsCorrupted => _initialSize != _info.Size; + bool _firstRun = true; + POINT lastSize; public override IGlPlatformSurfaceRenderingSession BeginDraw() { + if (_firstRun) + { + _firstRun = false; + var windowSurface = new EglGlPlatformSurface(Win32GlManager.EglFeature.DeferredContext, _info); + + using (var target = windowSurface.CreateGlRenderTarget()) + { + using (var session = target.BeginDraw()) + { + using (session.Context.MakeCurrent()) + { + var gl = _context.GlInterface; + gl.Viewport(0, 0, _info.Size.Width, _info.Size.Height); + gl.ClearStencil(0); + gl.ClearColor(0, 0, 0, 0); + gl.Clear(GlConsts.GL_COLOR_BUFFER_BIT | GlConsts.GL_DEPTH_BUFFER_BIT); + gl.Flush(); + } + } + } + } + + var iid = Guid.Parse("6f15aaf2-d208-4e89-9ab4-489535d34f9c"); var updateRect = new RECT { right = _info.Size.Width, bottom = _info.Size.Height }; var offset = new POINT(); - _surfaceInterop.Resize(new POINT { X = _info.Size.Width, Y = _info.Size.Height }); + if (lastSize.X != _info.Size.Width || lastSize.Y != _info.Size.Height) + { + lastSize = new POINT { X = _info.Size.Width, Y = _info.Size.Height }; + _surfaceInterop.Resize(lastSize); + } _surfaceInterop.BeginDraw( ref updateRect, ref iid, @@ -65,7 +94,7 @@ namespace Avalonia.Win32 var surface = (_display as AngleWin32EglDisplay).WrapDirect3D11Texture(texture); - return base.BeginDraw(surface, _info, () => { _surfaceInterop.EndDraw(); }, true); + return base.BeginDraw(surface, _info, () => { _surfaceInterop.EndDraw(); Marshal.Release(texture); surface.Dispose(); }, true); } } } diff --git a/src/Windows/Avalonia.Win32/Composition/GaussianBlurEffect.cs b/src/Windows/Avalonia.Win32/Composition/GaussianBlurEffect.cs index 19595e8977..4e1be3af1a 100644 --- a/src/Windows/Avalonia.Win32/Composition/GaussianBlurEffect.cs +++ b/src/Windows/Avalonia.Win32/Composition/GaussianBlurEffect.cs @@ -52,7 +52,7 @@ namespace Avalonia.Win32 return 30.0f; case D2D1GaussianBlurProp.D2D1_GAUSSIANBLUR_PROP_OPTIMIZATION: - return (UInt32)D2D1_GAUSSIANBLUR_OPTIMIZATION.D2D1_GAUSSIANBLUR_OPTIMIZATION_SPEED; + return (UInt32)D2D1_GAUSSIANBLUR_OPTIMIZATION.D2D1_GAUSSIANBLUR_OPTIMIZATION_BALANCED; case D2D1GaussianBlurProp.D2D1_GAUSSIANBLUR_PROP_BORDER_MODE: return (UInt32)D2D1_BORDER_MODE.D2D1_BORDER_MODE_HARD; diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index fdde128800..151a998673 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -100,7 +100,9 @@ namespace Avalonia.Win32 _framebuffer = new FramebufferManager(_hwnd); if (Win32GlManager.EglFeature != null) + { _gl = new CompositionEglGlPlatformSurface(Win32GlManager.EglFeature.DeferredContext, this); + } if (_gl is CompositionEglGlPlatformSurface cgl) { From 372f8e3938088ed882f006e32e1d7b083149a145 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Fri, 26 Jun 2020 15:29:35 -0300 Subject: [PATCH 014/751] 1 graphics device, 1 surface and visual tree per window. --- .../Composition/CompositionHost.cs | 49 +++++++++---------- src/Windows/Avalonia.Win32/WindowImpl.cs | 2 +- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs index fd76e4a523..1735b22035 100644 --- a/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs +++ b/src/Windows/Avalonia.Win32/Composition/CompositionHost.cs @@ -24,7 +24,7 @@ namespace Avalonia.Win32 public void AttachToCompositionTree(IntPtr hwnd) { - _surfaceInterop = CompositionHost.Instance.Initialize(hwnd); + _surfaceInterop = CompositionHost.Instance.InitialiseWindowCompositionTree(hwnd); } public override IGlPlatformSurfaceRenderTarget CreateGlRenderTarget() @@ -47,6 +47,8 @@ namespace Avalonia.Win32 _surfaceInterop = interopSurface; _info = info; _initialSize = info.Size; + lastSize = new POINT { X = _info.Size.Width, Y = _info.Size.Height }; + _surfaceInterop.Resize(lastSize); } public override bool IsCorrupted => _initialSize != _info.Size; @@ -85,7 +87,7 @@ namespace Avalonia.Win32 if (lastSize.X != _info.Size.Width || lastSize.Y != _info.Size.Height) { lastSize = new POINT { X = _info.Size.Width, Y = _info.Size.Height }; - _surfaceInterop.Resize(lastSize); + // _surfaceInterop.Resize(lastSize); } _surfaceInterop.BeginDraw( ref updateRect, @@ -135,17 +137,18 @@ namespace Avalonia.Win32 private Compositor _compositor; private Windows.System.DispatcherQueueController _dispatcherQueueController; - private Windows.UI.Composition.Desktop.DesktopWindowTarget _target; + private CompositionGraphicsDevice _graphicsDevice; private CompositionHost() { + Initialize(); } - public void AddElement(float size, float x, float y) + public void AddElement(CompositionTarget target, float size, float x, float y) { - if (_target.Root != null) + if (target.Root != null) { - var visuals = _target.Root.As().Children; + var visuals = target.Root.As().Children; var visual = _compositor.CreateSpriteVisual(); @@ -169,22 +172,24 @@ namespace Avalonia.Win32 } } - public ICompositionDrawingSurfaceInterop Initialize(IntPtr hwnd) + private void Initialize() { EnsureDispatcherQueue(); if (_dispatcherQueueController != null) _compositor = new Windows.UI.Composition.Compositor(); - CreateDesktopWindowTarget(hwnd); - CreateCompositionRoot(); - var interop = _compositor.As(); var display = Win32GlManager.EglFeature.Display as AngleWin32EglDisplay; - var gDevice = interop.CreateGraphicsDevice(display.GetDirect3DDevice()); + _graphicsDevice = interop.CreateGraphicsDevice(display.GetDirect3DDevice()); + } + + public ICompositionDrawingSurfaceInterop InitialiseWindowCompositionTree(IntPtr hwnd) + { + var target = CreateDesktopWindowTarget(hwnd); - var surface = gDevice.CreateDrawingSurface(new Windows.Foundation.Size(0, 0), + var surface = _graphicsDevice.CreateDrawingSurface(new Windows.Foundation.Size(0, 0), Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized, Windows.Graphics.DirectX.DirectXAlphaMode.Premultiplied); @@ -198,16 +203,16 @@ namespace Avalonia.Win32 visual.Brush = brush; //_target.Root = visual; - CreateBlur(); + target.Root = CreateBlur(); - var visuals = _target.Root.As().Children; + var visuals = target.Root.As().Children; visuals.InsertAtTop(visual); return surfaceInterop; } - public void CreateBlur() + public SpriteVisual CreateBlur() { var effect = new GaussianBlurEffect(); var effectFactory = _compositor.CreateEffectFactory(effect); @@ -222,23 +227,15 @@ namespace Avalonia.Win32 visual.RelativeSizeAdjustment = new System.Numerics.Vector2(1.0f, 1.0f); visual.Brush = blurBrush; - _target.Root = visual; - } - - void CreateCompositionRoot() - { - var root = _compositor.CreateContainerVisual(); - root.RelativeSizeAdjustment = new System.Numerics.Vector2(1.0f, 1.0f); - //root.Offset = new System.Numerics.Vector3(0, 0, 0); - _target.Root = root; + return visual; } - void CreateDesktopWindowTarget(IntPtr window) + CompositionTarget CreateDesktopWindowTarget(IntPtr window) { var interop = _compositor.As(); interop.CreateDesktopWindowTarget(window, false, out var windowTarget); - _target = Windows.UI.Composition.Desktop.DesktopWindowTarget.FromAbi(windowTarget); + return Windows.UI.Composition.Desktop.DesktopWindowTarget.FromAbi(windowTarget); } void EnsureDispatcherQueue() diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index 151a998673..bcccdf4810 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -110,7 +110,7 @@ namespace Avalonia.Win32 } else { - CompositionHost.Instance.Initialize(_hwnd); + CompositionHost.Instance.InitialiseWindowCompositionTree(_hwnd); } Screen = new ScreenImpl(); From a42e8cbdede4d8d2509eaf5ac8a848ef62835351 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 13 Jul 2020 22:19:33 +0200 Subject: [PATCH 015/751] Nullable enable Avalonia.Input. --- src/Avalonia.Input/AccessKeyHandler.cs | 22 +++--- src/Avalonia.Input/Avalonia.Input.csproj | 2 + src/Avalonia.Input/DataObject.cs | 6 +- src/Avalonia.Input/DragDropDevice.cs | 6 +- src/Avalonia.Input/FocusManager.cs | 47 ++++++------ .../GestureRecognizerCollection.cs | 16 ++-- .../ScrollGestureRecognizer.cs | 15 ++-- src/Avalonia.Input/Gestures.cs | 9 ++- src/Avalonia.Input/IAccessKeyHandler.cs | 2 +- src/Avalonia.Input/IDataObject.cs | 6 +- src/Avalonia.Input/IFocusManager.cs | 6 +- src/Avalonia.Input/IInputElement.cs | 2 +- src/Avalonia.Input/IInputRoot.cs | 4 +- src/Avalonia.Input/IKeyboardDevice.cs | 4 +- src/Avalonia.Input/IPointer.cs | 4 +- src/Avalonia.Input/IPointerDevice.cs | 4 +- src/Avalonia.Input/InputElement.cs | 8 +- src/Avalonia.Input/InputExtensions.cs | 2 +- src/Avalonia.Input/KeyEventArgs.cs | 2 +- src/Avalonia.Input/KeyboardDevice.cs | 8 +- .../KeyboardNavigationHandler.cs | 13 ++-- src/Avalonia.Input/MouseDevice.cs | 73 ++++++++++--------- .../Navigation/TabNavigation.cs | 42 ++++++----- src/Avalonia.Input/Pointer.cs | 9 +-- src/Avalonia.Input/PointerEventArgs.cs | 14 ++-- src/Avalonia.Input/Raw/RawDragEventType.cs | 2 +- src/Avalonia.Input/Raw/RawInputEventArgs.cs | 2 +- src/Avalonia.Input/TextInputEventArgs.cs | 4 +- 28 files changed, 172 insertions(+), 162 deletions(-) diff --git a/src/Avalonia.Input/AccessKeyHandler.cs b/src/Avalonia.Input/AccessKeyHandler.cs index 96f0bb59b3..660584e2ed 100644 --- a/src/Avalonia.Input/AccessKeyHandler.cs +++ b/src/Avalonia.Input/AccessKeyHandler.cs @@ -28,7 +28,7 @@ namespace Avalonia.Input /// /// The window to which the handler belongs. /// - private IInputRoot _owner; + private IInputRoot? _owner; /// /// Whether access keys are currently being shown; @@ -48,17 +48,17 @@ namespace Avalonia.Input /// /// Element to restore following AltKey taking focus. /// - private IInputElement _restoreFocusElement; + private IInputElement? _restoreFocusElement; /// /// The window's main menu. /// - private IMainMenu _mainMenu; + private IMainMenu? _mainMenu; /// /// Gets or sets the window's main menu. /// - public IMainMenu MainMenu + public IMainMenu? MainMenu { get => _mainMenu; set @@ -86,14 +86,12 @@ namespace Avalonia.Input /// public void SetOwner(IInputRoot owner) { - Contract.Requires(owner != null); - if (_owner != null) { throw new InvalidOperationException("AccessKeyHandler owner has already been set."); } - _owner = owner; + _owner = owner ?? throw new ArgumentNullException(nameof(owner)); _owner.AddHandler(InputElement.KeyDownEvent, OnPreviewKeyDown, RoutingStrategies.Tunnel); _owner.AddHandler(InputElement.KeyDownEvent, OnKeyDown, RoutingStrategies.Bubble); @@ -149,7 +147,7 @@ namespace Avalonia.Input // When Alt is pressed without a main menu, or with a closed main menu, show // access key markers in the window (i.e. "_File"). - _owner.ShowAccessKeys = _showingAccessKeys = true; + _owner!.ShowAccessKeys = _showingAccessKeys = true; } else { @@ -241,7 +239,7 @@ namespace Avalonia.Input { if (_showingAccessKeys) { - _owner.ShowAccessKeys = false; + _owner!.ShowAccessKeys = false; } } @@ -250,13 +248,13 @@ namespace Avalonia.Input /// private void CloseMenu() { - MainMenu.Close(); - _owner.ShowAccessKeys = _showingAccessKeys = false; + MainMenu!.Close(); + _owner!.ShowAccessKeys = _showingAccessKeys = false; } private void MainMenuClosed(object sender, EventArgs e) { - _owner.ShowAccessKeys = false; + _owner!.ShowAccessKeys = false; } } } diff --git a/src/Avalonia.Input/Avalonia.Input.csproj b/src/Avalonia.Input/Avalonia.Input.csproj index ea560ce2ea..58927e2c93 100644 --- a/src/Avalonia.Input/Avalonia.Input.csproj +++ b/src/Avalonia.Input/Avalonia.Input.csproj @@ -1,6 +1,8 @@  netstandard2.0 + Enable + CS8600;CS8602;CS8603 diff --git a/src/Avalonia.Input/DataObject.cs b/src/Avalonia.Input/DataObject.cs index 60d7d67606..688f5f9cc8 100644 --- a/src/Avalonia.Input/DataObject.cs +++ b/src/Avalonia.Input/DataObject.cs @@ -11,7 +11,7 @@ namespace Avalonia.Input return _items.ContainsKey(dataFormat); } - public object Get(string dataFormat) + public object? Get(string dataFormat) { if (_items.ContainsKey(dataFormat)) return _items[dataFormat]; @@ -23,12 +23,12 @@ namespace Avalonia.Input return _items.Keys; } - public IEnumerable GetFileNames() + public IEnumerable? GetFileNames() { return Get(DataFormats.FileNames) as IEnumerable; } - public string GetText() + public string? GetText() { return Get(DataFormats.Text) as string; } diff --git a/src/Avalonia.Input/DragDropDevice.cs b/src/Avalonia.Input/DragDropDevice.cs index bcd962bc31..30a08eda17 100644 --- a/src/Avalonia.Input/DragDropDevice.cs +++ b/src/Avalonia.Input/DragDropDevice.cs @@ -9,9 +9,9 @@ namespace Avalonia.Input { public static readonly DragDropDevice Instance = new DragDropDevice(); - private Interactive _lastTarget = null; + private Interactive? _lastTarget = null; - private Interactive GetTarget(IInputRoot root, Point local) + private Interactive? GetTarget(IInputRoot root, Point local) { var target = root.InputHitTest(local)?.GetSelfAndVisualAncestors()?.OfType()?.FirstOrDefault(); if (target != null && DragDrop.GetAllowDrop(target)) @@ -19,7 +19,7 @@ namespace Avalonia.Input return null; } - private DragDropEffects RaiseDragEvent(Interactive target, IInputRoot inputRoot, Point point, RoutedEvent routedEvent, DragDropEffects operation, IDataObject data, KeyModifiers modifiers) + private DragDropEffects RaiseDragEvent(Interactive? target, IInputRoot inputRoot, Point point, RoutedEvent routedEvent, DragDropEffects operation, IDataObject data, KeyModifiers modifiers) { if (target == null) return DragDropEffects.None; diff --git a/src/Avalonia.Input/FocusManager.cs b/src/Avalonia.Input/FocusManager.cs index 66355da8b9..a1f1478f51 100644 --- a/src/Avalonia.Input/FocusManager.cs +++ b/src/Avalonia.Input/FocusManager.cs @@ -15,8 +15,8 @@ namespace Avalonia.Input /// /// The focus scopes in which the focus is currently defined. /// - private readonly ConditionalWeakTable _focusScopes = - new ConditionalWeakTable(); + private readonly ConditionalWeakTable _focusScopes = + new ConditionalWeakTable(); /// /// Initializes a new instance of the class. @@ -37,12 +37,12 @@ namespace Avalonia.Input /// /// Gets the currently focused . /// - public IInputElement Current => KeyboardDevice.Instance?.FocusedElement; + public IInputElement? Current => KeyboardDevice.Instance?.FocusedElement; /// /// Gets the current focus scope. /// - public IFocusScope Scope + public IFocusScope? Scope { get; private set; @@ -55,7 +55,7 @@ namespace Avalonia.Input /// The method by which focus was changed. /// Any key modifiers active at the time of focus. public void Focus( - IInputElement control, + IInputElement? control, NavigationMethod method = NavigationMethod.Unspecified, KeyModifiers keyModifiers = KeyModifiers.None) { @@ -75,17 +75,18 @@ namespace Avalonia.Input // If control is null, set focus to the topmost focus scope. foreach (var scope in GetFocusScopeAncestors(Current).Reverse().ToList()) { - IInputElement element; - - if (_focusScopes.TryGetValue(scope, out element) && element != null) + if (_focusScopes.TryGetValue(scope, out var element) && element != null) { Focus(element, method); return; } } - // Couldn't find a focus scope, clear focus. - SetFocusedElement(Scope, null); + if (Scope is object) + { + // Couldn't find a focus scope, clear focus. + SetFocusedElement(Scope, null); + } } } @@ -102,13 +103,13 @@ namespace Avalonia.Input /// public void SetFocusedElement( IFocusScope scope, - IInputElement element, + IInputElement? element, NavigationMethod method = NavigationMethod.Unspecified, KeyModifiers keyModifiers = KeyModifiers.None) { - Contract.Requires(scope != null); + scope = scope ?? throw new ArgumentNullException(nameof(scope)); - if (_focusScopes.TryGetValue(scope, out IInputElement existingElement)) + if (_focusScopes.TryGetValue(scope, out var existingElement)) { if (element != existingElement) { @@ -133,11 +134,9 @@ namespace Avalonia.Input /// The new focus scope. public void SetFocusScope(IFocusScope scope) { - Contract.Requires(scope != null); + scope = scope ?? throw new ArgumentNullException(nameof(scope)); - IInputElement e; - - if (!_focusScopes.TryGetValue(scope, out e)) + if (!_focusScopes.TryGetValue(scope, out var e)) { // TODO: Make this do something useful, i.e. select the first focusable // control, select a control that the user has specified to have default @@ -164,17 +163,19 @@ namespace Avalonia.Input /// The focus scopes. private static IEnumerable GetFocusScopeAncestors(IInputElement control) { - while (control != null) + IInputElement? c = control; + + while (c != null) { - var scope = control as IFocusScope; + var scope = c as IFocusScope; - if (scope != null && control.VisualRoot?.IsVisible == true) + if (scope != null && c.VisualRoot?.IsVisible == true) { yield return scope; } - control = control.GetVisualParent() ?? - ((control as IHostedVisualTreeRoot)?.Host as IInputElement); + c = c.GetVisualParent() ?? + ((c as IHostedVisualTreeRoot)?.Host as IInputElement); } } @@ -190,7 +191,7 @@ namespace Avalonia.Input if (sender == e.Source && ev.GetCurrentPoint(visual).Properties.IsLeftButtonPressed) { - IVisual element = ev.Pointer?.Captured ?? e.Source as IInputElement; + IVisual? element = ev.Pointer?.Captured ?? e.Source as IInputElement; while (element != null) { diff --git a/src/Avalonia.Input/GestureRecognizers/GestureRecognizerCollection.cs b/src/Avalonia.Input/GestureRecognizers/GestureRecognizerCollection.cs index 112abb1a4e..54ef0b1a68 100644 --- a/src/Avalonia.Input/GestureRecognizers/GestureRecognizerCollection.cs +++ b/src/Avalonia.Input/GestureRecognizers/GestureRecognizerCollection.cs @@ -1,8 +1,6 @@ -using System; using System.Collections; using System.Collections.Generic; using Avalonia.Controls; -using Avalonia.Data; using Avalonia.LogicalTree; using Avalonia.Styling; @@ -11,8 +9,8 @@ namespace Avalonia.Input.GestureRecognizers public class GestureRecognizerCollection : IReadOnlyCollection, IGestureRecognizerActionsDispatcher { private readonly IInputElement _inputElement; - private List _recognizers; - private Dictionary _pointerGrabs; + private List? _recognizers; + private Dictionary? _pointerGrabs; public GestureRecognizerCollection(IInputElement inputElement) @@ -72,7 +70,7 @@ namespace Avalonia.Input.GestureRecognizers { if (_recognizers == null) return false; - if (_pointerGrabs.TryGetValue(e.Pointer, out var capture)) + if (_pointerGrabs!.TryGetValue(e.Pointer, out var capture)) { capture.PointerReleased(e); } @@ -90,7 +88,7 @@ namespace Avalonia.Input.GestureRecognizers { if (_recognizers == null) return false; - if (_pointerGrabs.TryGetValue(e.Pointer, out var capture)) + if (_pointerGrabs!.TryGetValue(e.Pointer, out var capture)) { capture.PointerMoved(e); } @@ -108,7 +106,7 @@ namespace Avalonia.Input.GestureRecognizers { if (_recognizers == null) return; - _pointerGrabs.Remove(e.Pointer); + _pointerGrabs!.Remove(e.Pointer); foreach (var r in _recognizers) { r.PointerCaptureLost(e.Pointer); @@ -118,8 +116,8 @@ namespace Avalonia.Input.GestureRecognizers void IGestureRecognizerActionsDispatcher.Capture(IPointer pointer, IGestureRecognizer recognizer) { pointer.Capture(_inputElement); - _pointerGrabs[pointer] = recognizer; - foreach (var r in _recognizers) + _pointerGrabs![pointer] = recognizer; + foreach (var r in _recognizers!) { if (r != recognizer) r.PointerCaptureLost(pointer); diff --git a/src/Avalonia.Input/GestureRecognizers/ScrollGestureRecognizer.cs b/src/Avalonia.Input/GestureRecognizers/ScrollGestureRecognizer.cs index e022401c8e..3858cc04f2 100644 --- a/src/Avalonia.Input/GestureRecognizers/ScrollGestureRecognizer.cs +++ b/src/Avalonia.Input/GestureRecognizers/ScrollGestureRecognizer.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics; -using Avalonia.Interactivity; using Avalonia.Threading; namespace Avalonia.Input.GestureRecognizers @@ -11,9 +10,9 @@ namespace Avalonia.Input.GestureRecognizers { private bool _scrolling; private Point _trackedRootPoint; - private IPointer _tracking; - private IInputElement _target; - private IGestureRecognizerActionsDispatcher _actions; + private IPointer? _tracking; + private IInputElement? _target; + private IGestureRecognizerActionsDispatcher? _actions; private bool _canHorizontallyScroll; private bool _canVerticallyScroll; private int _gestureId; @@ -95,7 +94,7 @@ namespace Avalonia.Input.GestureRecognizers _scrolling = true; if (_scrolling) { - _actions.Capture(e.Pointer, this); + _actions!.Capture(e.Pointer, this); } } @@ -110,7 +109,7 @@ namespace Avalonia.Input.GestureRecognizers _trackedRootPoint = rootPoint; if (elapsed.TotalSeconds > 0) _inertia = vector / elapsed.TotalSeconds; - _target.RaiseEvent(new ScrollGestureEventArgs(_gestureId, vector)); + _target!.RaiseEvent(new ScrollGestureEventArgs(_gestureId, vector)); e.Handled = true; } } @@ -128,7 +127,7 @@ namespace Avalonia.Input.GestureRecognizers { _inertia = default; _scrolling = false; - _target.RaiseEvent(new ScrollGestureEndedEventArgs(_gestureId)); + _target!.RaiseEvent(new ScrollGestureEndedEventArgs(_gestureId)); _gestureId = 0; _lastMoveTimestamp = null; } @@ -165,7 +164,7 @@ namespace Avalonia.Input.GestureRecognizers var speed = _inertia * Math.Pow(0.15, st.Elapsed.TotalSeconds); var distance = speed * elapsedSinceLastTick.TotalSeconds; - _target.RaiseEvent(new ScrollGestureEventArgs(_gestureId, distance)); + _target!.RaiseEvent(new ScrollGestureEventArgs(_gestureId, distance)); diff --git a/src/Avalonia.Input/Gestures.cs b/src/Avalonia.Input/Gestures.cs index 0efc20b196..5751719d61 100644 --- a/src/Avalonia.Input/Gestures.cs +++ b/src/Avalonia.Input/Gestures.cs @@ -29,7 +29,9 @@ namespace Avalonia.Input RoutedEvent.Register( "ScrollGestureEnded", RoutingStrategies.Bubble, typeof(Gestures)); +#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type. private static WeakReference s_lastPress = new WeakReference(null); +#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type. static Gestures() { @@ -69,6 +71,11 @@ namespace Avalonia.Input private static void PointerPressed(RoutedEventArgs ev) { + if (ev.Source is null) + { + return; + } + if (ev.Route == RoutingStrategies.Bubble) { var e = (PointerPressedEventArgs)ev; @@ -76,7 +83,7 @@ namespace Avalonia.Input if (e.ClickCount <= 1) { - s_lastPress = new WeakReference(e.Source); + s_lastPress = new WeakReference(ev.Source); } else if (s_lastPress != null && e.ClickCount == 2 && e.GetCurrentPoint(visual).Properties.IsLeftButtonPressed) { diff --git a/src/Avalonia.Input/IAccessKeyHandler.cs b/src/Avalonia.Input/IAccessKeyHandler.cs index 3e6510320f..e484d003c7 100644 --- a/src/Avalonia.Input/IAccessKeyHandler.cs +++ b/src/Avalonia.Input/IAccessKeyHandler.cs @@ -8,7 +8,7 @@ namespace Avalonia.Input /// /// Gets or sets the window's main menu. /// - IMainMenu MainMenu { get; set; } + IMainMenu? MainMenu { get; set; } /// /// Sets the owner of the access key handler. diff --git a/src/Avalonia.Input/IDataObject.cs b/src/Avalonia.Input/IDataObject.cs index 1aa8fd63d5..1db008aa3a 100644 --- a/src/Avalonia.Input/IDataObject.cs +++ b/src/Avalonia.Input/IDataObject.cs @@ -23,17 +23,17 @@ namespace Avalonia.Input /// Returns the dragged text if the DataObject contains any text. /// /// - string GetText(); + string? GetText(); /// /// Returns a list of filenames if the DataObject contains filenames. /// /// - IEnumerable GetFileNames(); + IEnumerable? GetFileNames(); /// /// Tries to get the data of the given DataFormat. /// - object Get(string dataFormat); + object? Get(string dataFormat); } } diff --git a/src/Avalonia.Input/IFocusManager.cs b/src/Avalonia.Input/IFocusManager.cs index 9122cc428d..e1b5087c3d 100644 --- a/src/Avalonia.Input/IFocusManager.cs +++ b/src/Avalonia.Input/IFocusManager.cs @@ -8,12 +8,12 @@ namespace Avalonia.Input /// /// Gets the currently focused . /// - IInputElement Current { get; } + IInputElement? Current { get; } /// /// Gets the current focus scope. /// - IFocusScope Scope { get; } + IFocusScope? Scope { get; } /// /// Focuses a control. @@ -22,7 +22,7 @@ namespace Avalonia.Input /// The method by which focus was changed. /// Any key modifiers active at the time of focus. void Focus( - IInputElement control, + IInputElement? control, NavigationMethod method = NavigationMethod.Unspecified, KeyModifiers keyModifiers = KeyModifiers.None); diff --git a/src/Avalonia.Input/IInputElement.cs b/src/Avalonia.Input/IInputElement.cs index c30d74c965..12fec82368 100644 --- a/src/Avalonia.Input/IInputElement.cs +++ b/src/Avalonia.Input/IInputElement.cs @@ -78,7 +78,7 @@ namespace Avalonia.Input /// /// Gets or sets the associated mouse cursor. /// - Cursor Cursor { get; } + Cursor? Cursor { get; } /// /// Gets a value indicating whether this control and all its parents are enabled. diff --git a/src/Avalonia.Input/IInputRoot.cs b/src/Avalonia.Input/IInputRoot.cs index eeb7e4323e..3e2b8cc477 100644 --- a/src/Avalonia.Input/IInputRoot.cs +++ b/src/Avalonia.Input/IInputRoot.cs @@ -20,7 +20,7 @@ namespace Avalonia.Input /// /// Gets or sets the input element that the pointer is currently over. /// - IInputElement PointerOverElement { get; set; } + IInputElement? PointerOverElement { get; set; } /// /// Gets or sets a value indicating whether access keys are shown in the window. @@ -31,6 +31,6 @@ namespace Avalonia.Input /// Gets associated mouse device /// [CanBeNull] - IMouseDevice MouseDevice { get; } + IMouseDevice? MouseDevice { get; } } } diff --git a/src/Avalonia.Input/IKeyboardDevice.cs b/src/Avalonia.Input/IKeyboardDevice.cs index ba7e0484ee..9506dc36fb 100644 --- a/src/Avalonia.Input/IKeyboardDevice.cs +++ b/src/Avalonia.Input/IKeyboardDevice.cs @@ -58,10 +58,10 @@ namespace Avalonia.Input public interface IKeyboardDevice : IInputDevice, INotifyPropertyChanged { - IInputElement FocusedElement { get; } + IInputElement? FocusedElement { get; } void SetFocusedElement( - IInputElement element, + IInputElement? element, NavigationMethod method, KeyModifiers modifiers); } diff --git a/src/Avalonia.Input/IPointer.cs b/src/Avalonia.Input/IPointer.cs index a3f051ce7f..7af48cef82 100644 --- a/src/Avalonia.Input/IPointer.cs +++ b/src/Avalonia.Input/IPointer.cs @@ -3,8 +3,8 @@ namespace Avalonia.Input public interface IPointer { int Id { get; } - void Capture(IInputElement control); - IInputElement Captured { get; } + void Capture(IInputElement? control); + IInputElement? Captured { get; } PointerType Type { get; } bool IsPrimary { get; } diff --git a/src/Avalonia.Input/IPointerDevice.cs b/src/Avalonia.Input/IPointerDevice.cs index bf001dda15..1f82cb1ed7 100644 --- a/src/Avalonia.Input/IPointerDevice.cs +++ b/src/Avalonia.Input/IPointerDevice.cs @@ -6,10 +6,10 @@ namespace Avalonia.Input public interface IPointerDevice : IInputDevice { [Obsolete("Use IPointer")] - IInputElement Captured { get; } + IInputElement? Captured { get; } [Obsolete("Use IPointer")] - void Capture(IInputElement control); + void Capture(IInputElement? control); [Obsolete("Use PointerEventArgs.GetPosition")] Point GetPosition(IVisual relativeTo); diff --git a/src/Avalonia.Input/InputElement.cs b/src/Avalonia.Input/InputElement.cs index 0616c70d82..25f2d553d7 100644 --- a/src/Avalonia.Input/InputElement.cs +++ b/src/Avalonia.Input/InputElement.cs @@ -37,8 +37,8 @@ namespace Avalonia.Input /// /// Gets or sets associated mouse cursor. /// - public static readonly StyledProperty CursorProperty = - AvaloniaProperty.Register(nameof(Cursor), null, true); + public static readonly StyledProperty CursorProperty = + AvaloniaProperty.Register(nameof(Cursor), null, true); /// /// Defines the property. @@ -160,7 +160,7 @@ namespace Avalonia.Input private bool _isFocused; private bool _isFocusVisible; private bool _isPointerOver; - private GestureRecognizerCollection _gestureRecognizers; + private GestureRecognizerCollection? _gestureRecognizers; /// /// Initializes static members of the class. @@ -336,7 +336,7 @@ namespace Avalonia.Input /// /// Gets or sets associated mouse cursor. /// - public Cursor Cursor + public Cursor? Cursor { get { return GetValue(CursorProperty); } set { SetValue(CursorProperty, value); } diff --git a/src/Avalonia.Input/InputExtensions.cs b/src/Avalonia.Input/InputExtensions.cs index 4babe711f2..0c7615a472 100644 --- a/src/Avalonia.Input/InputExtensions.cs +++ b/src/Avalonia.Input/InputExtensions.cs @@ -33,7 +33,7 @@ namespace Avalonia.Input /// The element to test. /// The point on . /// The topmost at the specified position. - public static IInputElement InputHitTest(this IInputElement element, Point p) + public static IInputElement? InputHitTest(this IInputElement element, Point p) { Contract.Requires(element != null); diff --git a/src/Avalonia.Input/KeyEventArgs.cs b/src/Avalonia.Input/KeyEventArgs.cs index 267376262b..67cd5a520a 100644 --- a/src/Avalonia.Input/KeyEventArgs.cs +++ b/src/Avalonia.Input/KeyEventArgs.cs @@ -5,7 +5,7 @@ namespace Avalonia.Input { public class KeyEventArgs : RoutedEventArgs { - public IKeyboardDevice Device { get; set; } + public IKeyboardDevice? Device { get; set; } public Key Key { get; set; } diff --git a/src/Avalonia.Input/KeyboardDevice.cs b/src/Avalonia.Input/KeyboardDevice.cs index 0321b0bdf3..187670a26b 100644 --- a/src/Avalonia.Input/KeyboardDevice.cs +++ b/src/Avalonia.Input/KeyboardDevice.cs @@ -8,9 +8,9 @@ namespace Avalonia.Input { public class KeyboardDevice : IKeyboardDevice, INotifyPropertyChanged { - private IInputElement _focusedElement; + private IInputElement? _focusedElement; - public event PropertyChangedEventHandler PropertyChanged; + public event PropertyChangedEventHandler? PropertyChanged; public static IKeyboardDevice Instance => AvaloniaLocator.Current.GetService(); @@ -18,7 +18,7 @@ namespace Avalonia.Input public IFocusManager FocusManager => AvaloniaLocator.Current.GetService(); - public IInputElement FocusedElement + public IInputElement? FocusedElement { get { @@ -33,7 +33,7 @@ namespace Avalonia.Input } public void SetFocusedElement( - IInputElement element, + IInputElement? element, NavigationMethod method, KeyModifiers keyModifiers) { diff --git a/src/Avalonia.Input/KeyboardNavigationHandler.cs b/src/Avalonia.Input/KeyboardNavigationHandler.cs index c425eeeedb..dbefe63789 100644 --- a/src/Avalonia.Input/KeyboardNavigationHandler.cs +++ b/src/Avalonia.Input/KeyboardNavigationHandler.cs @@ -13,7 +13,7 @@ namespace Avalonia.Input /// /// The window to which the handler belongs. /// - private IInputRoot _owner; + private IInputRoot? _owner; /// /// Sets the owner of the keyboard navigation handler. @@ -24,15 +24,12 @@ namespace Avalonia.Input /// public void SetOwner(IInputRoot owner) { - Contract.Requires(owner != null); - if (_owner != null) { throw new InvalidOperationException("AccessKeyHandler owner has already been set."); } - _owner = owner; - + _owner = owner ?? throw new ArgumentNullException(nameof(owner)); _owner.AddHandler(InputElement.KeyDownEvent, OnKeyDown); } @@ -45,11 +42,11 @@ namespace Avalonia.Input /// The next element in the specified direction, or null if /// was the last in the requested direction. /// - public static IInputElement GetNext( + public static IInputElement? GetNext( IInputElement element, NavigationDirection direction) { - Contract.Requires(element != null); + element = element ?? throw new ArgumentNullException(nameof(element)); var customHandler = element.GetSelfAndVisualAncestors() .OfType() @@ -97,7 +94,7 @@ namespace Avalonia.Input NavigationDirection direction, KeyModifiers keyModifiers = KeyModifiers.None) { - Contract.Requires(element != null); + element = element ?? throw new ArgumentNullException(nameof(element)); var next = GetNext(element, direction); diff --git a/src/Avalonia.Input/MouseDevice.cs b/src/Avalonia.Input/MouseDevice.cs index 188ddd9835..cec5029c18 100644 --- a/src/Avalonia.Input/MouseDevice.cs +++ b/src/Avalonia.Input/MouseDevice.cs @@ -20,7 +20,7 @@ namespace Avalonia.Input private readonly Pointer _pointer; private bool _disposed; - public MouseDevice(Pointer pointer = null) + public MouseDevice(Pointer? pointer = null) { _pointer = pointer ?? new Pointer(Pointer.GetNextFreeId(), PointerType.Mouse, true); } @@ -34,7 +34,7 @@ namespace Avalonia.Input /// method. /// [Obsolete("Use IPointer instead")] - public IInputElement Captured => _pointer.Captured; + public IInputElement? Captured => _pointer.Captured; /// /// Gets the mouse position, in screen coordinates. @@ -54,7 +54,7 @@ namespace Avalonia.Input /// within the control's bounds or not. The current mouse capture control is exposed /// by the property. /// - public void Capture(IInputElement control) + public void Capture(IInputElement? control) { _pointer.Capture(control); } @@ -66,7 +66,7 @@ namespace Avalonia.Input /// The mouse position in the control's coordinates. public Point GetPosition(IVisual relativeTo) { - Contract.Requires(relativeTo != null); + relativeTo = relativeTo ?? throw new ArgumentNullException(nameof(relativeTo)); if (relativeTo.VisualRoot == null) { @@ -75,7 +75,7 @@ namespace Avalonia.Input var rootPoint = relativeTo.VisualRoot.PointToClient(Position); var transform = relativeTo.VisualRoot.TransformToVisual(relativeTo); - return rootPoint * transform.Value; + return rootPoint * transform!.Value; } public void ProcessRawEvent(RawInputEventArgs e) @@ -126,7 +126,7 @@ namespace Avalonia.Input private void ProcessRawEvent(RawPointerEventArgs e) { - Contract.Requires(e != null); + e = e ?? throw new ArgumentNullException(nameof(e)); var mouse = (MouseDevice)e.Device; if(mouse._disposed) @@ -173,8 +173,8 @@ namespace Avalonia.Input private void LeaveWindow(IMouseDevice device, ulong timestamp, IInputRoot root, PointerPointProperties properties, KeyModifiers inputModifiers) { - Contract.Requires(device != null); - Contract.Requires(root != null); + device = device ?? throw new ArgumentNullException(nameof(device)); + root = root ?? throw new ArgumentNullException(nameof(root)); ClearPointerOver(this, timestamp, root, properties, inputModifiers); } @@ -214,8 +214,8 @@ namespace Avalonia.Input PointerPointProperties properties, KeyModifiers inputModifiers) { - Contract.Requires(device != null); - Contract.Requires(root != null); + device = device ?? throw new ArgumentNullException(nameof(device)); + root = root ?? throw new ArgumentNullException(nameof(root)); var hit = HitTest(root, p); @@ -250,10 +250,10 @@ namespace Avalonia.Input private bool MouseMove(IMouseDevice device, ulong timestamp, IInputRoot root, Point p, PointerPointProperties properties, KeyModifiers inputModifiers) { - Contract.Requires(device != null); - Contract.Requires(root != null); + device = device ?? throw new ArgumentNullException(nameof(device)); + root = root ?? throw new ArgumentNullException(nameof(root)); - IInputElement source; + IInputElement? source; if (_pointer.Captured == null) { @@ -265,18 +265,23 @@ namespace Avalonia.Input source = _pointer.Captured; } - var e = new PointerEventArgs(InputElement.PointerMovedEvent, source, _pointer, root, - p, timestamp, properties, inputModifiers); + if (source is object) + { + var e = new PointerEventArgs(InputElement.PointerMovedEvent, source, _pointer, root, + p, timestamp, properties, inputModifiers); - source?.RaiseEvent(e); - return e.Handled; + source.RaiseEvent(e); + return e.Handled; + } + + return false; } private bool MouseUp(IMouseDevice device, ulong timestamp, IInputRoot root, Point p, PointerPointProperties props, KeyModifiers inputModifiers) { - Contract.Requires(device != null); - Contract.Requires(root != null); + device = device ?? throw new ArgumentNullException(nameof(device)); + root = root ?? throw new ArgumentNullException(nameof(root)); var hit = HitTest(root, p); @@ -298,8 +303,8 @@ namespace Avalonia.Input PointerPointProperties props, Vector delta, KeyModifiers inputModifiers) { - Contract.Requires(device != null); - Contract.Requires(root != null); + device = device ?? throw new ArgumentNullException(nameof(device)); + root = root ?? throw new ArgumentNullException(nameof(root)); var hit = HitTest(root, p); @@ -317,21 +322,21 @@ namespace Avalonia.Input private IInteractive GetSource(IVisual hit) { - Contract.Requires(hit != null); + hit = hit ?? throw new ArgumentNullException(nameof(hit)); return _pointer.Captured ?? (hit as IInteractive) ?? hit.GetSelfAndVisualAncestors().OfType().FirstOrDefault(); } - private IInputElement HitTest(IInputElement root, Point p) + private IInputElement? HitTest(IInputElement root, Point p) { - Contract.Requires(root != null); + root = root ?? throw new ArgumentNullException(nameof(root)); return _pointer.Captured ?? root.InputHitTest(p); } - PointerEventArgs CreateSimpleEvent(RoutedEvent ev, ulong timestamp, IInteractive source, + PointerEventArgs CreateSimpleEvent(RoutedEvent ev, ulong timestamp, IInteractive? source, PointerPointProperties properties, KeyModifiers inputModifiers) { @@ -343,8 +348,8 @@ namespace Avalonia.Input PointerPointProperties properties, KeyModifiers inputModifiers) { - Contract.Requires(device != null); - Contract.Requires(root != null); + device = device ?? throw new ArgumentNullException(nameof(device)); + root = root ?? throw new ArgumentNullException(nameof(root)); var element = root.PointerOverElement; var e = CreateSimpleEvent(InputElement.PointerLeaveEvent, timestamp, element, properties, inputModifiers); @@ -384,12 +389,12 @@ namespace Avalonia.Input } } - private IInputElement SetPointerOver(IPointerDevice device, ulong timestamp, IInputRoot root, Point p, + private IInputElement? SetPointerOver(IPointerDevice device, ulong timestamp, IInputRoot root, Point p, PointerPointProperties properties, KeyModifiers inputModifiers) { - Contract.Requires(device != null); - Contract.Requires(root != null); + device = device ?? throw new ArgumentNullException(nameof(device)); + root = root ?? throw new ArgumentNullException(nameof(root)); var element = root.InputHitTest(p); @@ -412,11 +417,11 @@ namespace Avalonia.Input PointerPointProperties properties, KeyModifiers inputModifiers) { - Contract.Requires(device != null); - Contract.Requires(root != null); - Contract.Requires(element != null); + device = device ?? throw new ArgumentNullException(nameof(device)); + root = root ?? throw new ArgumentNullException(nameof(root)); + element = element ?? throw new ArgumentNullException(nameof(element)); - IInputElement branch = null; + IInputElement? branch = null; var el = element; diff --git a/src/Avalonia.Input/Navigation/TabNavigation.cs b/src/Avalonia.Input/Navigation/TabNavigation.cs index cd377f1df6..6f6d68940b 100644 --- a/src/Avalonia.Input/Navigation/TabNavigation.cs +++ b/src/Avalonia.Input/Navigation/TabNavigation.cs @@ -22,15 +22,17 @@ namespace Avalonia.Input.Navigation /// The next element in the specified direction, or null if /// was the last in the requested direction. /// - public static IInputElement GetNextInTabOrder( + public static IInputElement? GetNextInTabOrder( IInputElement element, NavigationDirection direction, bool outsideElement = false) { - Contract.Requires(element != null); - Contract.Requires( - direction == NavigationDirection.Next || - direction == NavigationDirection.Previous); + element = element ?? throw new ArgumentNullException(nameof(element)); + + if (direction != NavigationDirection.Next && direction != NavigationDirection.Previous) + { + throw new ArgumentException("Invalid direction: must be Next or Previous."); + } var container = element.GetVisualParent(); @@ -110,7 +112,7 @@ namespace Avalonia.Input.Navigation if (customNext.handled) { - yield return customNext.next; + yield return customNext.next!; } else { @@ -143,12 +145,14 @@ namespace Avalonia.Input.Navigation /// If true will not descend into to find next control. /// /// The next element, or null if the element is the last. - private static IInputElement GetNextInContainer( + private static IInputElement? GetNextInContainer( IInputElement element, IInputElement container, NavigationDirection direction, bool outsideElement) { + IInputElement? e = element; + if (direction == NavigationDirection.Next && !outsideElement) { var descendant = GetFocusableDescendants(element, direction).FirstOrDefault(); @@ -167,13 +171,13 @@ namespace Avalonia.Input.Navigation // INavigableContainer. if (navigable != null) { - while (element != null) + while (e != null) { - element = navigable.GetControl(direction, element, false); + e = navigable.GetControl(direction, e, false); - if (element != null && - element.CanFocus() && - KeyboardNavigation.GetIsTabStop((InputElement) element)) + if (e != null && + e.CanFocus() && + KeyboardNavigation.GetIsTabStop((InputElement)e)) { break; } @@ -183,12 +187,12 @@ namespace Avalonia.Input.Navigation { // TODO: Do a spatial search here if the container doesn't implement // INavigableContainer. - element = null; + e = null; } - if (element != null && direction == NavigationDirection.Previous) + if (e != null && direction == NavigationDirection.Previous) { - var descendant = GetFocusableDescendants(element, direction).LastOrDefault(); + var descendant = GetFocusableDescendants(e, direction).LastOrDefault(); if (descendant != null) { @@ -196,7 +200,7 @@ namespace Avalonia.Input.Navigation } } - return element; + return e; } return null; @@ -209,13 +213,13 @@ namespace Avalonia.Input.Navigation /// The container. /// The direction of the search. /// The first element, or null if there are no more elements. - private static IInputElement GetFirstInNextContainer( + private static IInputElement? GetFirstInNextContainer( IInputElement element, IInputElement container, NavigationDirection direction) { var parent = container.GetVisualParent(); - IInputElement next = null; + IInputElement? next = null; if (parent != null) { @@ -268,7 +272,7 @@ namespace Avalonia.Input.Navigation return next; } - private static (bool handled, IInputElement next) GetCustomNext(IInputElement element, + private static (bool handled, IInputElement? next) GetCustomNext(IInputElement element, NavigationDirection direction) { if (element is ICustomKeyboardNavigation custom) diff --git a/src/Avalonia.Input/Pointer.cs b/src/Avalonia.Input/Pointer.cs index 00222e92cf..a477711584 100644 --- a/src/Avalonia.Input/Pointer.cs +++ b/src/Avalonia.Input/Pointer.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Avalonia.Interactivity; using Avalonia.VisualTree; namespace Avalonia.Input @@ -20,7 +19,7 @@ namespace Avalonia.Input public int Id { get; } - IInputElement FindCommonParent(IInputElement control1, IInputElement control2) + IInputElement? FindCommonParent(IInputElement? control1, IInputElement? control2) { if (control1 == null || control2 == null) return null; @@ -28,12 +27,12 @@ namespace Avalonia.Input return control2.GetSelfAndVisualAncestors().OfType().FirstOrDefault(seen.Contains); } - protected virtual void PlatformCapture(IInputElement element) + protected virtual void PlatformCapture(IInputElement? element) { } - public void Capture(IInputElement control) + public void Capture(IInputElement? control) { if (Captured != null) Captured.DetachedFromVisualTree -= OnCaptureDetached; @@ -66,7 +65,7 @@ namespace Avalonia.Input } - public IInputElement Captured { get; private set; } + public IInputElement? Captured { get; private set; } public PointerType Type { get; } public bool IsPrimary { get; } diff --git a/src/Avalonia.Input/PointerEventArgs.cs b/src/Avalonia.Input/PointerEventArgs.cs index 9cc42ffa69..1cbddf89aa 100644 --- a/src/Avalonia.Input/PointerEventArgs.cs +++ b/src/Avalonia.Input/PointerEventArgs.cs @@ -7,14 +7,14 @@ namespace Avalonia.Input { public class PointerEventArgs : RoutedEventArgs { - private readonly IVisual _rootVisual; + private readonly IVisual? _rootVisual; private readonly Point _rootVisualPosition; private readonly PointerPointProperties _properties; public PointerEventArgs(RoutedEvent routedEvent, - IInteractive source, + IInteractive? source, IPointer pointer, - IVisual rootVisual, Point rootVisualPosition, + IVisual? rootVisual, Point rootVisualPosition, ulong timestamp, PointerPointProperties properties, KeyModifiers modifiers) @@ -40,8 +40,8 @@ namespace Avalonia.Input public void ProcessRawEvent(RawInputEventArgs ev) => throw new NotSupportedException(); - public IInputElement Captured => _ev.Pointer.Captured; - public void Capture(IInputElement control) + public IInputElement? Captured => _ev.Pointer.Captured; + public void Capture(IInputElement? control) { _ev.Pointer.Capture(control); } @@ -52,7 +52,7 @@ namespace Avalonia.Input public IPointer Pointer { get; } public ulong Timestamp { get; } - private IPointerDevice _device; + private IPointerDevice? _device; [Obsolete("Use Pointer to get pointer-specific information")] public IPointerDevice Device => _device ?? (_device = new EmulatedDevice(this)); @@ -76,7 +76,7 @@ namespace Avalonia.Input public KeyModifiers KeyModifiers { get; } - public Point GetPosition(IVisual relativeTo) + public Point GetPosition(IVisual? relativeTo) { if (_rootVisual == null) return default; diff --git a/src/Avalonia.Input/Raw/RawDragEventType.cs b/src/Avalonia.Input/Raw/RawDragEventType.cs index 9635f77467..77f17a5a41 100644 --- a/src/Avalonia.Input/Raw/RawDragEventType.cs +++ b/src/Avalonia.Input/Raw/RawDragEventType.cs @@ -7,4 +7,4 @@ DragLeave, Drop } -} \ No newline at end of file +} diff --git a/src/Avalonia.Input/Raw/RawInputEventArgs.cs b/src/Avalonia.Input/Raw/RawInputEventArgs.cs index b85563b24a..dcc5f27a79 100644 --- a/src/Avalonia.Input/Raw/RawInputEventArgs.cs +++ b/src/Avalonia.Input/Raw/RawInputEventArgs.cs @@ -21,7 +21,7 @@ namespace Avalonia.Input.Raw /// The root from which the event originates. public RawInputEventArgs(IInputDevice device, ulong timestamp, IInputRoot root) { - Contract.Requires(device != null); + device = device ?? throw new ArgumentNullException(nameof(device)); Device = device; Timestamp = timestamp; diff --git a/src/Avalonia.Input/TextInputEventArgs.cs b/src/Avalonia.Input/TextInputEventArgs.cs index 6e763d3b56..cda0103749 100644 --- a/src/Avalonia.Input/TextInputEventArgs.cs +++ b/src/Avalonia.Input/TextInputEventArgs.cs @@ -4,8 +4,8 @@ namespace Avalonia.Input { public class TextInputEventArgs : RoutedEventArgs { - public IKeyboardDevice Device { get; set; } + public IKeyboardDevice? Device { get; set; } - public string Text { get; set; } + public string? Text { get; set; } } } From dc2e7a2ffab9fce17a7581b7bac1429845ac246f Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 17 Jul 2020 16:39:01 +0200 Subject: [PATCH 016/751] iOS build? --- Avalonia.sln | 125 +++++------- dirs.proj | 2 +- src/iOS/Avalonia.iOS/Avalonia.iOS.csproj | 1 - src/iOS/Avalonia.iOS/Clipboard.cs | 2 + src/iOS/Avalonia.iOS/EmbeddableImpl.cs | 4 - .../Specific/KeyboardEventsHelper.cs | 11 +- src/iOS/Avalonia.iOS/TopLevelImpl.cs | 17 +- src/iOS/Avalonia.iOS/WindowingPlatformImpl.cs | 2 +- .../AppDelegate.cs | 39 ---- .../Avalonia.iOSTestApplication.csproj | 191 ------------------ .../Entitlements.plist | 5 - .../GettingStarted.Xamarin | 4 - .../Avalonia.iOSTestApplication/Info.plist | 38 ---- src/iOS/Avalonia.iOSTestApplication/Main.cs | 20 -- .../Properties/AssemblyInfo.cs | 36 ---- .../Resources/Default-568h@2x.png | Bin 2215 -> 0 bytes .../SimpleApp.xaml | 6 - .../SimpleApp.xaml.cs | 20 -- .../SimpleControl.cs | 20 -- 19 files changed, 78 insertions(+), 465 deletions(-) delete mode 100644 src/iOS/Avalonia.iOSTestApplication/AppDelegate.cs delete mode 100644 src/iOS/Avalonia.iOSTestApplication/Avalonia.iOSTestApplication.csproj delete mode 100644 src/iOS/Avalonia.iOSTestApplication/Entitlements.plist delete mode 100644 src/iOS/Avalonia.iOSTestApplication/GettingStarted.Xamarin delete mode 100644 src/iOS/Avalonia.iOSTestApplication/Info.plist delete mode 100644 src/iOS/Avalonia.iOSTestApplication/Main.cs delete mode 100644 src/iOS/Avalonia.iOSTestApplication/Properties/AssemblyInfo.cs delete mode 100644 src/iOS/Avalonia.iOSTestApplication/Resources/Default-568h@2x.png delete mode 100644 src/iOS/Avalonia.iOSTestApplication/SimpleApp.xaml delete mode 100644 src/iOS/Avalonia.iOSTestApplication/SimpleApp.xaml.cs delete mode 100644 src/iOS/Avalonia.iOSTestApplication/SimpleControl.cs diff --git a/Avalonia.sln b/Avalonia.sln index 4954260e12..3ee107707f 100644 --- a/Avalonia.sln +++ b/Avalonia.sln @@ -87,8 +87,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "iOS", "iOS", "{0CB0B92E-6CF EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.iOS", "src\iOS\Avalonia.iOS\Avalonia.iOS.csproj", "{4488AD85-1495-4809-9AA4-DDFE0A48527E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.iOSTestApplication", "src\iOS\Avalonia.iOSTestApplication\Avalonia.iOSTestApplication.csproj", "{8C923867-8A8F-4F6B-8B80-47D9E8436166}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.LeakTests", "tests\Avalonia.LeakTests\Avalonia.LeakTests.csproj", "{E1AA3DBF-9056-4530-9376-18119A7A3FFE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.UnitTests", "tests\Avalonia.UnitTests\Avalonia.UnitTests.csproj", "{88060192-33D5-4932-B0F9-8BD2763E857D}" @@ -207,11 +205,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NativeEmbedSample", "sample EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Themes.Fluent", "src\Avalonia.Themes.Fluent\Avalonia.Themes.Fluent.csproj", "{C42D2FC1-A531-4ED4-84B9-89AEC7C962FC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Headless", "src\Avalonia.Headless\Avalonia.Headless.csproj", "{8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Headless", "src\Avalonia.Headless\Avalonia.Headless.csproj", "{8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Headless.Vnc", "src\Avalonia.Headless.Vnc\Avalonia.Headless.Vnc.csproj", "{B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Headless.Vnc", "src\Avalonia.Headless.Vnc\Avalonia.Headless.Vnc.csproj", "{B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Markup.Xaml.Loader", "src\Markup\Avalonia.Markup.Xaml.Loader\Avalonia.Markup.Xaml.Loader.csproj", "{909A8CBD-7D0E-42FD-B841-022AD8925820}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Markup.Xaml.Loader", "src\Markup\Avalonia.Markup.Xaml.Loader\Avalonia.Markup.Xaml.Loader.csproj", "{909A8CBD-7D0E-42FD-B841-022AD8925820}" EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution @@ -940,26 +938,6 @@ Global {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Release|iPhone.Build.0 = Release|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.Ad-Hoc|Any CPU.ActiveCfg = Ad-Hoc|iPhone - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Ad-Hoc|iPhoneSimulator - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.Ad-Hoc|iPhoneSimulator.Build.0 = Ad-Hoc|iPhoneSimulator - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.AppStore|Any CPU.ActiveCfg = AppStore|iPhone - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.AppStore|iPhone.ActiveCfg = AppStore|iPhone - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.AppStore|iPhone.Build.0 = AppStore|iPhone - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.AppStore|iPhoneSimulator.ActiveCfg = AppStore|iPhoneSimulator - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.AppStore|iPhoneSimulator.Build.0 = AppStore|iPhoneSimulator - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.Debug|Any CPU.ActiveCfg = Debug|iPhone - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.Debug|iPhone.ActiveCfg = Debug|iPhone - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.Debug|iPhone.Build.0 = Debug|iPhone - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.Release|Any CPU.ActiveCfg = Release|iPhone - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.Release|iPhone.ActiveCfg = Release|iPhone - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.Release|iPhone.Build.0 = Release|iPhone - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator - {8C923867-8A8F-4F6B-8B80-47D9E8436166}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator {E1AA3DBF-9056-4530-9376-18119A7A3FFE}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU {E1AA3DBF-9056-4530-9376-18119A7A3FFE}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU {E1AA3DBF-9056-4530-9376-18119A7A3FFE}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU @@ -1832,54 +1810,6 @@ Global {3278F3A9-9509-4A3F-A15B-BDC8B5BFF632}.Release|iPhone.Build.0 = Release|Any CPU {3278F3A9-9509-4A3F-A15B-BDC8B5BFF632}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {3278F3A9-9509-4A3F-A15B-BDC8B5BFF632}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.AppStore|Any CPU.Build.0 = Debug|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.AppStore|iPhone.ActiveCfg = Debug|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.AppStore|iPhone.Build.0 = Debug|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Debug|iPhone.Build.0 = Debug|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Release|Any CPU.Build.0 = Release|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Release|iPhone.ActiveCfg = Release|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Release|iPhone.Build.0 = Release|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.AppStore|Any CPU.Build.0 = Debug|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.AppStore|iPhone.ActiveCfg = Debug|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.AppStore|iPhone.Build.0 = Debug|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Debug|iPhone.Build.0 = Debug|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Release|Any CPU.Build.0 = Release|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Release|iPhone.ActiveCfg = Release|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Release|iPhone.Build.0 = Release|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU {4D55985A-1EE2-4F25-AD39-6EA8BC04F8FB}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU {4D55985A-1EE2-4F25-AD39-6EA8BC04F8FB}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU {4D55985A-1EE2-4F25-AD39-6EA8BC04F8FB}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU @@ -2000,6 +1930,54 @@ Global {C42D2FC1-A531-4ED4-84B9-89AEC7C962FC}.Release|iPhone.Build.0 = Release|Any CPU {C42D2FC1-A531-4ED4-84B9-89AEC7C962FC}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {C42D2FC1-A531-4ED4-84B9-89AEC7C962FC}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.AppStore|iPhone.Build.0 = Debug|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Debug|iPhone.Build.0 = Debug|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Release|Any CPU.Build.0 = Release|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Release|iPhone.ActiveCfg = Release|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Release|iPhone.Build.0 = Release|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {8C89950F-F5D9-47FC-8066-CBC1EC3DF8FC}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.AppStore|iPhone.Build.0 = Debug|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Debug|iPhone.Build.0 = Debug|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Release|Any CPU.Build.0 = Release|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Release|iPhone.ActiveCfg = Release|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Release|iPhone.Build.0 = Release|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {B859AE7C-F34F-4A9E-88AE-E0E7229FDE1E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU {909A8CBD-7D0E-42FD-B841-022AD8925820}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU {909A8CBD-7D0E-42FD-B841-022AD8925820}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU {909A8CBD-7D0E-42FD-B841-022AD8925820}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU @@ -2050,7 +2028,6 @@ Global {7B92AF71-6287-4693-9DCB-BD5B6E927E23} = {7CF9789C-F1D3-4D0E-90E5-F1DF67A2753F} {FF69B927-C545-49AE-8E16-3D14D621AA12} = {7CF9789C-F1D3-4D0E-90E5-F1DF67A2753F} {4488AD85-1495-4809-9AA4-DDFE0A48527E} = {0CB0B92E-6CFF-4240-80A5-CCAFE75D91E1} - {8C923867-8A8F-4F6B-8B80-47D9E8436166} = {0CB0B92E-6CFF-4240-80A5-CCAFE75D91E1} {E1AA3DBF-9056-4530-9376-18119A7A3FFE} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} {88060192-33D5-4932-B0F9-8BD2763E857D} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} {410AC439-81A1-4EB5-B5E9-6A7FC6B77F4B} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} diff --git a/dirs.proj b/dirs.proj index 26c8f54b23..a48ad6e03d 100644 --- a/dirs.proj +++ b/dirs.proj @@ -13,7 +13,7 @@ - + diff --git a/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj b/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj index e57fcc643f..683c256b7b 100644 --- a/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj +++ b/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj @@ -6,7 +6,6 @@ - diff --git a/src/iOS/Avalonia.iOS/Clipboard.cs b/src/iOS/Avalonia.iOS/Clipboard.cs index 2deb49473f..8103d6ddf4 100644 --- a/src/iOS/Avalonia.iOS/Clipboard.cs +++ b/src/iOS/Avalonia.iOS/Clipboard.cs @@ -1,4 +1,6 @@ +using System; using System.Threading.Tasks; +using Avalonia.Input; using Avalonia.Input.Platform; using UIKit; diff --git a/src/iOS/Avalonia.iOS/EmbeddableImpl.cs b/src/iOS/Avalonia.iOS/EmbeddableImpl.cs index d299ff99c1..ce3c45d79b 100644 --- a/src/iOS/Avalonia.iOS/EmbeddableImpl.cs +++ b/src/iOS/Avalonia.iOS/EmbeddableImpl.cs @@ -19,9 +19,5 @@ namespace Avalonia.iOS { return Disposable.Empty; } - - public void SetSystemDecorations(SystemDecorations enabled) - { - } } } diff --git a/src/iOS/Avalonia.iOS/Specific/KeyboardEventsHelper.cs b/src/iOS/Avalonia.iOS/Specific/KeyboardEventsHelper.cs index cdf244d330..4d76539560 100644 --- a/src/iOS/Avalonia.iOS/Specific/KeyboardEventsHelper.cs +++ b/src/iOS/Avalonia.iOS/Specific/KeyboardEventsHelper.cs @@ -37,7 +37,7 @@ namespace Avalonia.iOS.Specific /// view.ResignFirstResponder(); /// /// View that needs keyboard events and show/hide keyboard - internal class KeyboardEventsHelper where TView : UIView, ITopLevelImpl + internal class KeyboardEventsHelper where TView : UIView, ITopLevelImpl, IGetInputRoot { private TView _view; private IInputElement _lastFocusedElement; @@ -70,13 +70,13 @@ namespace Avalonia.iOS.Specific public void InsertText(string text) { - var rawTextEvent = new RawTextInputEventArgs(KeyboardDevice.Instance, (uint)DateTime.Now.Ticks, text); + var rawTextEvent = new RawTextInputEventArgs(KeyboardDevice.Instance, (uint)DateTime.Now.Ticks, _view.GetInputRoot(), text); _view.Input(rawTextEvent); } private void HandleKey(Key key, RawKeyEventType type) { - var rawKeyEvent = new RawKeyEventArgs(KeyboardDevice.Instance, (uint)DateTime.Now.Ticks, type, key, RawInputModifiers.None); + var rawKeyEvent = new RawKeyEventArgs(KeyboardDevice.Instance, (uint)DateTime.Now.Ticks, _view.GetInputRoot(), type, key, RawInputModifiers.None); _view.Input(rawKeyEvent); } @@ -144,4 +144,9 @@ namespace Avalonia.iOS.Specific HandleEvents = false; } } + + internal interface IGetInputRoot + { + IInputRoot GetInputRoot(); + } } diff --git a/src/iOS/Avalonia.iOS/TopLevelImpl.cs b/src/iOS/Avalonia.iOS/TopLevelImpl.cs index 83a68990d7..ea6f560e9c 100644 --- a/src/iOS/Avalonia.iOS/TopLevelImpl.cs +++ b/src/iOS/Avalonia.iOS/TopLevelImpl.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Avalonia.Controls; using Avalonia.Controls.Platform.Surfaces; using Avalonia.Input; using Avalonia.Input.Raw; @@ -14,7 +15,7 @@ using UIKit; namespace Avalonia.iOS { [Adopts("UIKeyInput")] - class TopLevelImpl : UIView, ITopLevelImpl, IFramebufferPlatformSurface + class TopLevelImpl : UIView, ITopLevelImpl, IFramebufferPlatformSurface, IGetInputRoot { private readonly KeyboardEventsHelper _keyboardHelper; @@ -139,7 +140,19 @@ namespace Avalonia.iOS public ILockedFramebuffer Lock() => new EmulatedFramebuffer(this); public IPopupImpl CreatePopup() => null; - + + public void SetTransparencyLevelHint(WindowTransparencyLevel transparencyLevel) + { + //No-op + } + + public IInputRoot GetInputRoot() => _inputRoot; + public Action LostFocus { get; set; } + public Action TransparencyLevelChanged { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + + public WindowTransparencyLevel TransparencyLevel => WindowTransparencyLevel.None; + + public AcrylicPlatformCompensationLevels AcrylicCompensationLevels => new AcrylicPlatformCompensationLevels(0, 0, 0); } } diff --git a/src/iOS/Avalonia.iOS/WindowingPlatformImpl.cs b/src/iOS/Avalonia.iOS/WindowingPlatformImpl.cs index aaca5f53d6..8e7578e49e 100644 --- a/src/iOS/Avalonia.iOS/WindowingPlatformImpl.cs +++ b/src/iOS/Avalonia.iOS/WindowingPlatformImpl.cs @@ -10,7 +10,7 @@ namespace Avalonia.iOS throw new NotSupportedException(); } - public WindowImpl CreateEmbeddableWindow() + public IWindowImpl CreateEmbeddableWindow() { throw new NotSupportedException(); } diff --git a/src/iOS/Avalonia.iOSTestApplication/AppDelegate.cs b/src/iOS/Avalonia.iOSTestApplication/AppDelegate.cs deleted file mode 100644 index 4591fb2ae8..0000000000 --- a/src/iOS/Avalonia.iOSTestApplication/AppDelegate.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using Foundation; -using Avalonia.Controls; -using Avalonia.iOS; -using Avalonia.Media; -using Avalonia.Threading; -using UIKit; - -namespace Avalonia.iOSTestApplication -{ - // The UIApplicationDelegate for the application. This class is responsible for launching the - // User Interface of the application, as well as listening (and optionally responding) to - // application events from iOS. - [Register("AppDelegate")] - public partial class AppDelegate : UIApplicationDelegate - { - public override UIWindow Window { get; set; } - - // - // This method is invoked when the application has loaded and is ready to run. In this - // method you should instantiate the window, load the UI into it and then make the window - // visible. - // - // You have 17 seconds to return from this method, or iOS will terminate your application. - // - public override bool FinishedLaunching(UIApplication uiapp, NSDictionary options) - { - AppBuilder.Configure().UseSkia().UseiOS().SetupWithoutStarting(); - Window = new AvaloniaWindow { Content = new SimpleControl()}; - Window.MakeKeyAndVisible(); - return true; - } - } - - -} \ No newline at end of file diff --git a/src/iOS/Avalonia.iOSTestApplication/Avalonia.iOSTestApplication.csproj b/src/iOS/Avalonia.iOSTestApplication/Avalonia.iOSTestApplication.csproj deleted file mode 100644 index 34c8ae7605..0000000000 --- a/src/iOS/Avalonia.iOSTestApplication/Avalonia.iOSTestApplication.csproj +++ /dev/null @@ -1,191 +0,0 @@ - - - - Debug - iPhoneSimulator - {8C923867-8A8F-4F6B-8B80-47D9E8436166} - {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Exe - Avalonia.iOSTestApplication - Resources - AvaloniaiOSTestApplication - - - true - full - false - bin\iPhoneSimulator\Debug - DEBUG - prompt - 4 - false - i386 - SdkOnly - true - - - none - true - bin\iPhoneSimulator\Release - prompt - 4 - None - i386 - false - - - true - full - false - bin\iPhone\Debug - DEBUG - prompt - 4 - false - ARMv7, ARM64 - Entitlements.plist - iPhone Developer - True - 9.1 - None - False - False - False - False - True - True - True - False - - - - none - true - bin\iPhone\Release - prompt - 4 - Entitlements.plist - ARMv7, ARM64 - false - iPhone Developer - - - none - True - bin\iPhone\Ad-Hoc - prompt - 4 - False - ARMv7, ARM64 - Entitlements.plist - True - Automatic:AdHoc - iPhone Distribution - - - none - True - bin\iPhone\AppStore - prompt - 4 - False - ARMv7, ARM64 - Entitlements.plist - Automatic:AppStore - iPhone Distribution - - - true - - - - - - - - - - - - - - - - - - - - - - - - - {3e53a01a-b331-47f3-b828-4a5717e77a24} - Avalonia.Markup.Xaml - - - {6417e941-21bc-467b-a771-0de389353ce6} - Avalonia.Markup - - - {d211e587-d8bc-45b9-95a4-f297c8fa5200} - Avalonia.Animation - - - {b09b78d8-9b26-48b0-9149-d64a2f120f3f} - Avalonia.Base - - - {d2221c82-4a25-4583-9b43-d791e3f6820c} - Avalonia.Controls - - - {7062ae20-5dcc-4442-9645-8195bdece63e} - Avalonia.Diagnostics - - - {62024b2d-53eb-4638-b26b-85eeaa54866e} - Avalonia.Input - - - {6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b} - Avalonia.Interactivity - - - {42472427-4774-4c81-8aff-9f27b8e31721} - Avalonia.Layout - - - {eb582467-6abb-43a1-b052-e981ba910e3a} - Avalonia.Visuals - - - {f1baa01a-f176-4c6a-b39d-5b40bb1b148f} - Avalonia.Styling - - - {3e10a5fa-e8da-48b1-ad44-6a5b6cb7750f} - Avalonia.Themes.Default - - - {7d2d3083-71dd-4cc9-8907-39a0d86fb322} - Avalonia.Skia - false - false - - - {4488ad85-1495-4809-9aa4-ddfe0a48527e} - Avalonia.iOS - false - false - - - - - - - - - - - diff --git a/src/iOS/Avalonia.iOSTestApplication/Entitlements.plist b/src/iOS/Avalonia.iOSTestApplication/Entitlements.plist deleted file mode 100644 index 0c67376eba..0000000000 --- a/src/iOS/Avalonia.iOSTestApplication/Entitlements.plist +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/src/iOS/Avalonia.iOSTestApplication/GettingStarted.Xamarin b/src/iOS/Avalonia.iOSTestApplication/GettingStarted.Xamarin deleted file mode 100644 index 810f716685..0000000000 --- a/src/iOS/Avalonia.iOSTestApplication/GettingStarted.Xamarin +++ /dev/null @@ -1,4 +0,0 @@ - - GS\iOS\CS\iOSApp\GettingStarted.html - false - \ No newline at end of file diff --git a/src/iOS/Avalonia.iOSTestApplication/Info.plist b/src/iOS/Avalonia.iOSTestApplication/Info.plist deleted file mode 100644 index 44e29bed12..0000000000 --- a/src/iOS/Avalonia.iOSTestApplication/Info.plist +++ /dev/null @@ -1,38 +0,0 @@ - - - - - CFBundleDisplayName - Avalonia.iOSTestApplication - CFBundleIdentifier - com.your-company.Avalonia.iOSTestApplication - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1.0 - UIDeviceFamily - - 1 - 2 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - MinimumOSVersion - 8.0 - CFBundleIconFiles - - Default-568h@2x.png - - - diff --git a/src/iOS/Avalonia.iOSTestApplication/Main.cs b/src/iOS/Avalonia.iOSTestApplication/Main.cs deleted file mode 100644 index a2e0d635cc..0000000000 --- a/src/iOS/Avalonia.iOSTestApplication/Main.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -using Foundation; -using UIKit; - -namespace Avalonia.iOSTestApplication -{ - public class Application - { - // This is the main entry point of the application. - static void Main(string[] args) - { - // if you want to use a different Application Delegate class from "AppDelegate" - // you can specify it here. - UIApplication.Main(args, null, "AppDelegate"); - } - } -} \ No newline at end of file diff --git a/src/iOS/Avalonia.iOSTestApplication/Properties/AssemblyInfo.cs b/src/iOS/Avalonia.iOSTestApplication/Properties/AssemblyInfo.cs deleted file mode 100644 index 9154e2a135..0000000000 --- a/src/iOS/Avalonia.iOSTestApplication/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Avalonia.iOSTestApplication")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Avalonia.iOSTestApplication")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("8c923867-8a8f-4f6b-8b80-47d9e8436166")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/iOS/Avalonia.iOSTestApplication/Resources/Default-568h@2x.png b/src/iOS/Avalonia.iOSTestApplication/Resources/Default-568h@2x.png deleted file mode 100644 index 29973dcbed50cb67f5f522d4fd9cb5caddda6cc4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2215 zcmeAS@N?(olHy`uVBq!ia0y~yU}|7sU@72W0*ZWnTNDnYI14-?iy0WWg+Z8+Vb&Z8 z1_q8uPZ!6Kid%0F8ZrWv99r$Ma}qo=E%%Q~loCIFNg8Dsze diff --git a/src/iOS/Avalonia.iOSTestApplication/SimpleApp.xaml b/src/iOS/Avalonia.iOSTestApplication/SimpleApp.xaml deleted file mode 100644 index 214bcd8797..0000000000 --- a/src/iOS/Avalonia.iOSTestApplication/SimpleApp.xaml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/iOS/Avalonia.iOSTestApplication/SimpleApp.xaml.cs b/src/iOS/Avalonia.iOSTestApplication/SimpleApp.xaml.cs deleted file mode 100644 index b287755ef6..0000000000 --- a/src/iOS/Avalonia.iOSTestApplication/SimpleApp.xaml.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Avalonia.Markup.Xaml; -using Foundation; -using UIKit; - -namespace Avalonia.iOSTestApplication -{ - public class SimpleApp : Avalonia.Application - { - public override void Initialize() - { - //Enforce load - new Avalonia.Themes.Default.DefaultTheme(); - AvaloniaXamlLoader.Load(this); - } - } -} \ No newline at end of file diff --git a/src/iOS/Avalonia.iOSTestApplication/SimpleControl.cs b/src/iOS/Avalonia.iOSTestApplication/SimpleControl.cs deleted file mode 100644 index 7e888f65bc..0000000000 --- a/src/iOS/Avalonia.iOSTestApplication/SimpleControl.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Avalonia.Controls; -using Avalonia.Media; - -namespace Avalonia.iOSTestApplication -{ - class SimpleControl : ContentControl - { - public SimpleControl() - { - Content = new Button() {Content = "WAT"}; - MinWidth = 100; - MinHeight = 200; - Background = Brushes.CadetBlue; - } - } -} \ No newline at end of file From 7c3cf89e3ae0c909ca1f1ae93423feb6583bc5fe Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 17 Jul 2020 16:51:08 +0200 Subject: [PATCH 017/751] build? --- build/iOSWorkarounds.props | 5 ----- global.json | 2 +- samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 build/iOSWorkarounds.props diff --git a/build/iOSWorkarounds.props b/build/iOSWorkarounds.props deleted file mode 100644 index fe46295770..0000000000 --- a/build/iOSWorkarounds.props +++ /dev/null @@ -1,5 +0,0 @@ - - - $(MSBuildToolsPath)\..\Roslyn - - diff --git a/global.json b/global.json index a3fdca9bed..128511eb48 100644 --- a/global.json +++ b/global.json @@ -4,7 +4,7 @@ }, "msbuild-sdks": { "Microsoft.Build.Traversal": "1.0.43", - "MSBuild.Sdk.Extras": "2.0.46", + "MSBuild.Sdk.Extras": "2.0.54", "AggregatePackage.NuGet.Sdk" : "0.1.12" } } diff --git a/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj b/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj index 7596e4cfe2..3354df5597 100644 --- a/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj +++ b/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj @@ -175,6 +175,5 @@ - From d59a74dc7f434143a2e5b0fddbd7504c85b7a231 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 17 Jul 2020 17:00:07 +0200 Subject: [PATCH 018/751] build? --- src/iOS/Avalonia.iOS/Avalonia.iOS.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj b/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj index 683c256b7b..ef0d8068a2 100644 --- a/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj +++ b/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj @@ -10,5 +10,4 @@ - From c22b71aa50cc0b74848be1db1723376a736f7b3a Mon Sep 17 00:00:00 2001 From: Yatao Li Date: Thu, 6 Aug 2020 17:41:32 +0800 Subject: [PATCH 019/751] update build.ps1 to put downloaded dotnet in PATH --- build.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.ps1 b/build.ps1 index 57e2f80075..3672e82d3b 100644 --- a/build.ps1 +++ b/build.ps1 @@ -62,6 +62,8 @@ else { } else { ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath } } + + $env:PATH="$DotNetDirectory;$env:PATH" } Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)" From 0daf5f771e91f14df210b32be140b362cbfc6001 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sun, 16 Aug 2020 21:00:55 +0100 Subject: [PATCH 020/751] dont generate sharpgen sources. --- src/Avalonia.Native/Avalonia.Native.csproj | 2 +- src/Avalonia.Native/Generated/Enumerations.cs | 628 ++++ src/Avalonia.Native/Generated/Functions.cs | 5 + src/Avalonia.Native/Generated/Interfaces.cs | 3092 +++++++++++++++++ src/Avalonia.Native/Generated/LocalInterop.cs | 202 ++ src/Avalonia.Native/Generated/Structures.cs | 246 ++ 6 files changed, 4174 insertions(+), 1 deletion(-) create mode 100644 src/Avalonia.Native/Generated/Enumerations.cs create mode 100644 src/Avalonia.Native/Generated/Functions.cs create mode 100644 src/Avalonia.Native/Generated/Interfaces.cs create mode 100644 src/Avalonia.Native/Generated/LocalInterop.cs create mode 100644 src/Avalonia.Native/Generated/Structures.cs diff --git a/src/Avalonia.Native/Avalonia.Native.csproj b/src/Avalonia.Native/Avalonia.Native.csproj index 1a2bdeef1e..9c3eaed2d8 100644 --- a/src/Avalonia.Native/Avalonia.Native.csproj +++ b/src/Avalonia.Native/Avalonia.Native.csproj @@ -19,7 +19,7 @@ - + diff --git a/src/Avalonia.Native/Generated/Enumerations.cs b/src/Avalonia.Native/Generated/Enumerations.cs new file mode 100644 index 0000000000..0b30ce50c0 --- /dev/null +++ b/src/Avalonia.Native/Generated/Enumerations.cs @@ -0,0 +1,628 @@ +// + +namespace Avalonia.Native.Interop +{ + /// + /// No documentation. + /// + /// AvnDragDropEffects + /// AvnDragDropEffects + public enum AvnDragDropEffects : System.Int32 + { + /// + /// No documentation. + /// + /// None + /// None + None = unchecked ((System.Int32)(0)), + /// + /// No documentation. + /// + /// Copy + /// Copy + Copy = unchecked ((System.Int32)(1)), + /// + /// No documentation. + /// + /// Move + /// Move + Move = unchecked ((System.Int32)(2)), + /// + /// No documentation. + /// + /// Link + /// Link + Link = unchecked ((System.Int32)(4))} + + /// + /// No documentation. + /// + /// AvnDragEventType + /// AvnDragEventType + public enum AvnDragEventType : System.Int32 + { + /// + /// No documentation. + /// + /// Enter + /// Enter + Enter = unchecked ((System.Int32)(0)), + /// + /// No documentation. + /// + /// Over + /// Over + Over = unchecked ((System.Int32)(1)), + /// + /// No documentation. + /// + /// Leave + /// Leave + Leave = unchecked ((System.Int32)(2)), + /// + /// No documentation. + /// + /// Drop + /// Drop + Drop = unchecked ((System.Int32)(3))} + + /// + /// No documentation. + /// + /// AvnExtendClientAreaChromeHints + /// AvnExtendClientAreaChromeHints + public enum AvnExtendClientAreaChromeHints : System.Int32 + { + /// + /// No documentation. + /// + /// AvnNoChrome + /// AvnNoChrome + AvnNoChrome = unchecked ((System.Int32)(0)), + /// + /// No documentation. + /// + /// AvnSystemChrome + /// AvnSystemChrome + AvnSystemChrome = unchecked ((System.Int32)(1)), + /// + /// No documentation. + /// + /// AvnPreferSystemChrome + /// AvnPreferSystemChrome + AvnPreferSystemChrome = unchecked ((System.Int32)(2)), + /// + /// No documentation. + /// + /// AvnOSXThickTitleBar + /// AvnOSXThickTitleBar + AvnOSXThickTitleBar = unchecked ((System.Int32)(8)), + /// + /// No documentation. + /// + /// AvnDefaultChrome + /// AvnDefaultChrome + AvnDefaultChrome = unchecked ((System.Int32)(1))} + + /// + /// No documentation. + /// + /// AvnInputModifiers + /// AvnInputModifiers + public enum AvnInputModifiers : System.Int32 + { + /// + /// No documentation. + /// + /// AvnInputModifiersNone + /// AvnInputModifiersNone + AvnInputModifiersNone = unchecked ((System.Int32)(0)), + /// + /// No documentation. + /// + /// Alt + /// Alt + Alt = unchecked ((System.Int32)(1)), + /// + /// No documentation. + /// + /// Control + /// Control + Control = unchecked ((System.Int32)(2)), + /// + /// No documentation. + /// + /// Shift + /// Shift + Shift = unchecked ((System.Int32)(4)), + /// + /// No documentation. + /// + /// Windows + /// Windows + Windows = unchecked ((System.Int32)(8)), + /// + /// No documentation. + /// + /// LeftMouseButton + /// LeftMouseButton + LeftMouseButton = unchecked ((System.Int32)(16)), + /// + /// No documentation. + /// + /// RightMouseButton + /// RightMouseButton + RightMouseButton = unchecked ((System.Int32)(32)), + /// + /// No documentation. + /// + /// MiddleMouseButton + /// MiddleMouseButton + MiddleMouseButton = unchecked ((System.Int32)(64)), + /// + /// No documentation. + /// + /// XButton1MouseButton + /// XButton1MouseButton + XButton1MouseButton = unchecked ((System.Int32)(128)), + /// + /// No documentation. + /// + /// XButton2MouseButton + /// XButton2MouseButton + XButton2MouseButton = unchecked ((System.Int32)(256))} + + /// + /// No documentation. + /// + /// AvnMenuItemToggleType + /// AvnMenuItemToggleType + public enum AvnMenuItemToggleType : System.Int32 + { + /// + /// No documentation. + /// + /// None + /// None + None = unchecked ((System.Int32)(0)), + /// + /// No documentation. + /// + /// CheckMark + /// CheckMark + CheckMark = unchecked ((System.Int32)(1)), + /// + /// No documentation. + /// + /// Radio + /// Radio + Radio = unchecked ((System.Int32)(2))} + + /// + /// No documentation. + /// + /// AvnPixelFormat + /// AvnPixelFormat + public enum AvnPixelFormat : System.Int32 + { + /// + /// No documentation. + /// + /// kAvnRgb565 + /// kAvnRgb565 + KAvnRgb565 = unchecked ((System.Int32)(0)), + /// + /// No documentation. + /// + /// kAvnRgba8888 + /// kAvnRgba8888 + KAvnRgba8888 = unchecked ((System.Int32)(1)), + /// + /// No documentation. + /// + /// kAvnBgra8888 + /// kAvnBgra8888 + KAvnBgra8888 = unchecked ((System.Int32)(2))} + + /// + /// No documentation. + /// + /// AvnRawKeyEventType + /// AvnRawKeyEventType + public enum AvnRawKeyEventType : System.Int32 + { + /// + /// No documentation. + /// + /// KeyDown + /// KeyDown + KeyDown = unchecked ((System.Int32)(0)), + /// + /// No documentation. + /// + /// KeyUp + /// KeyUp + KeyUp = unchecked ((System.Int32)(1))} + + /// + /// No documentation. + /// + /// AvnRawMouseEventType + /// AvnRawMouseEventType + public enum AvnRawMouseEventType : System.Int32 + { + /// + /// No documentation. + /// + /// LeaveWindow + /// LeaveWindow + LeaveWindow = unchecked ((System.Int32)(0)), + /// + /// No documentation. + /// + /// LeftButtonDown + /// LeftButtonDown + LeftButtonDown = unchecked ((System.Int32)(1)), + /// + /// No documentation. + /// + /// LeftButtonUp + /// LeftButtonUp + LeftButtonUp = unchecked ((System.Int32)(2)), + /// + /// No documentation. + /// + /// RightButtonDown + /// RightButtonDown + RightButtonDown = unchecked ((System.Int32)(3)), + /// + /// No documentation. + /// + /// RightButtonUp + /// RightButtonUp + RightButtonUp = unchecked ((System.Int32)(4)), + /// + /// No documentation. + /// + /// MiddleButtonDown + /// MiddleButtonDown + MiddleButtonDown = unchecked ((System.Int32)(5)), + /// + /// No documentation. + /// + /// MiddleButtonUp + /// MiddleButtonUp + MiddleButtonUp = unchecked ((System.Int32)(6)), + /// + /// No documentation. + /// + /// XButton1Down + /// XButton1Down + XButton1Down = unchecked ((System.Int32)(7)), + /// + /// No documentation. + /// + /// XButton1Up + /// XButton1Up + XButton1Up = unchecked ((System.Int32)(8)), + /// + /// No documentation. + /// + /// XButton2Down + /// XButton2Down + XButton2Down = unchecked ((System.Int32)(9)), + /// + /// No documentation. + /// + /// XButton2Up + /// XButton2Up + XButton2Up = unchecked ((System.Int32)(10)), + /// + /// No documentation. + /// + /// Move + /// Move + Move = unchecked ((System.Int32)(11)), + /// + /// No documentation. + /// + /// Wheel + /// Wheel + Wheel = unchecked ((System.Int32)(12)), + /// + /// No documentation. + /// + /// NonClientLeftButtonDown + /// NonClientLeftButtonDown + NonClientLeftButtonDown = unchecked ((System.Int32)(13)), + /// + /// No documentation. + /// + /// TouchBegin + /// TouchBegin + TouchBegin = unchecked ((System.Int32)(14)), + /// + /// No documentation. + /// + /// TouchUpdate + /// TouchUpdate + TouchUpdate = unchecked ((System.Int32)(15)), + /// + /// No documentation. + /// + /// TouchEnd + /// TouchEnd + TouchEnd = unchecked ((System.Int32)(16)), + /// + /// No documentation. + /// + /// TouchCancel + /// TouchCancel + TouchCancel = unchecked ((System.Int32)(17))} + + /// + /// No documentation. + /// + /// AvnStandardCursorType + /// AvnStandardCursorType + public enum AvnStandardCursorType : System.Int32 + { + /// + /// No documentation. + /// + /// CursorArrow + /// CursorArrow + CursorArrow = unchecked ((System.Int32)(0)), + /// + /// No documentation. + /// + /// CursorIbeam + /// CursorIbeam + CursorIbeam = unchecked ((System.Int32)(1)), + /// + /// No documentation. + /// + /// CursorWait + /// CursorWait + CursorWait = unchecked ((System.Int32)(2)), + /// + /// No documentation. + /// + /// CursorCross + /// CursorCross + CursorCross = unchecked ((System.Int32)(3)), + /// + /// No documentation. + /// + /// CursorUpArrow + /// CursorUpArrow + CursorUpArrow = unchecked ((System.Int32)(4)), + /// + /// No documentation. + /// + /// CursorSizeWestEast + /// CursorSizeWestEast + CursorSizeWestEast = unchecked ((System.Int32)(5)), + /// + /// No documentation. + /// + /// CursorSizeNorthSouth + /// CursorSizeNorthSouth + CursorSizeNorthSouth = unchecked ((System.Int32)(6)), + /// + /// No documentation. + /// + /// CursorSizeAll + /// CursorSizeAll + CursorSizeAll = unchecked ((System.Int32)(7)), + /// + /// No documentation. + /// + /// CursorNo + /// CursorNo + CursorNo = unchecked ((System.Int32)(8)), + /// + /// No documentation. + /// + /// CursorHand + /// CursorHand + CursorHand = unchecked ((System.Int32)(9)), + /// + /// No documentation. + /// + /// CursorAppStarting + /// CursorAppStarting + CursorAppStarting = unchecked ((System.Int32)(10)), + /// + /// No documentation. + /// + /// CursorHelp + /// CursorHelp + CursorHelp = unchecked ((System.Int32)(11)), + /// + /// No documentation. + /// + /// CursorTopSide + /// CursorTopSide + CursorTopSide = unchecked ((System.Int32)(12)), + /// + /// No documentation. + /// + /// CursorBottomSize + /// CursorBottomSize + CursorBottomSize = unchecked ((System.Int32)(13)), + /// + /// No documentation. + /// + /// CursorLeftSide + /// CursorLeftSide + CursorLeftSide = unchecked ((System.Int32)(14)), + /// + /// No documentation. + /// + /// CursorRightSide + /// CursorRightSide + CursorRightSide = unchecked ((System.Int32)(15)), + /// + /// No documentation. + /// + /// CursorTopLeftCorner + /// CursorTopLeftCorner + CursorTopLeftCorner = unchecked ((System.Int32)(16)), + /// + /// No documentation. + /// + /// CursorTopRightCorner + /// CursorTopRightCorner + CursorTopRightCorner = unchecked ((System.Int32)(17)), + /// + /// No documentation. + /// + /// CursorBottomLeftCorner + /// CursorBottomLeftCorner + CursorBottomLeftCorner = unchecked ((System.Int32)(18)), + /// + /// No documentation. + /// + /// CursorBottomRightCorner + /// CursorBottomRightCorner + CursorBottomRightCorner = unchecked ((System.Int32)(19)), + /// + /// No documentation. + /// + /// CursorDragMove + /// CursorDragMove + CursorDragMove = unchecked ((System.Int32)(20)), + /// + /// No documentation. + /// + /// CursorDragCopy + /// CursorDragCopy + CursorDragCopy = unchecked ((System.Int32)(21)), + /// + /// No documentation. + /// + /// CursorDragLink + /// CursorDragLink + CursorDragLink = unchecked ((System.Int32)(22)), + /// + /// No documentation. + /// + /// CursorNone + /// CursorNone + CursorNone = unchecked ((System.Int32)(23))} + + /// + /// No documentation. + /// + /// AvnWindowEdge + /// AvnWindowEdge + public enum AvnWindowEdge : System.Int32 + { + /// + /// No documentation. + /// + /// WindowEdgeNorthWest + /// WindowEdgeNorthWest + WindowEdgeNorthWest = unchecked ((System.Int32)(0)), + /// + /// No documentation. + /// + /// WindowEdgeNorth + /// WindowEdgeNorth + WindowEdgeNorth = unchecked ((System.Int32)(1)), + /// + /// No documentation. + /// + /// WindowEdgeNorthEast + /// WindowEdgeNorthEast + WindowEdgeNorthEast = unchecked ((System.Int32)(2)), + /// + /// No documentation. + /// + /// WindowEdgeWest + /// WindowEdgeWest + WindowEdgeWest = unchecked ((System.Int32)(3)), + /// + /// No documentation. + /// + /// WindowEdgeEast + /// WindowEdgeEast + WindowEdgeEast = unchecked ((System.Int32)(4)), + /// + /// No documentation. + /// + /// WindowEdgeSouthWest + /// WindowEdgeSouthWest + WindowEdgeSouthWest = unchecked ((System.Int32)(5)), + /// + /// No documentation. + /// + /// WindowEdgeSouth + /// WindowEdgeSouth + WindowEdgeSouth = unchecked ((System.Int32)(6)), + /// + /// No documentation. + /// + /// WindowEdgeSouthEast + /// WindowEdgeSouthEast + WindowEdgeSouthEast = unchecked ((System.Int32)(7))} + + /// + /// No documentation. + /// + /// AvnWindowState + /// AvnWindowState + public enum AvnWindowState : System.Int32 + { + /// + /// No documentation. + /// + /// Normal + /// Normal + Normal = unchecked ((System.Int32)(0)), + /// + /// No documentation. + /// + /// Minimized + /// Minimized + Minimized = unchecked ((System.Int32)(1)), + /// + /// No documentation. + /// + /// Maximized + /// Maximized + Maximized = unchecked ((System.Int32)(2)), + /// + /// No documentation. + /// + /// FullScreen + /// FullScreen + FullScreen = unchecked ((System.Int32)(3))} + + /// + /// No documentation. + /// + /// SystemDecorations + /// SystemDecorations + public enum SystemDecorations : System.Int32 + { + /// + /// No documentation. + /// + /// SystemDecorationsNone + /// SystemDecorationsNone + SystemDecorationsNone = unchecked ((System.Int32)(0)), + /// + /// No documentation. + /// + /// SystemDecorationsBorderOnly + /// SystemDecorationsBorderOnly + SystemDecorationsBorderOnly = unchecked ((System.Int32)(1)), + /// + /// No documentation. + /// + /// SystemDecorationsFull + /// SystemDecorationsFull + SystemDecorationsFull = unchecked ((System.Int32)(2))} +} \ No newline at end of file diff --git a/src/Avalonia.Native/Generated/Functions.cs b/src/Avalonia.Native/Generated/Functions.cs new file mode 100644 index 0000000000..6ab648dc50 --- /dev/null +++ b/src/Avalonia.Native/Generated/Functions.cs @@ -0,0 +1,5 @@ +// + +namespace Avalonia.Native.Interop +{ +} \ No newline at end of file diff --git a/src/Avalonia.Native/Generated/Interfaces.cs b/src/Avalonia.Native/Generated/Interfaces.cs new file mode 100644 index 0000000000..161ada1e50 --- /dev/null +++ b/src/Avalonia.Native/Generated/Interfaces.cs @@ -0,0 +1,3092 @@ +// + +namespace Avalonia.Native.Interop +{ + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f01")] + public partial class IAvaloniaNativeFactory : SharpGen.Runtime.ComObject + { + public IAvaloniaNativeFactory(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvaloniaNativeFactory(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvaloniaNativeFactory(nativePtr); + /// + /// No documentation. + /// + /// GetMacOptions + /// GetMacOptions + public Avalonia.Native.Interop.IAvnMacOptions MacOptions + { + get => GetMacOptions(); + } + + /// + /// No documentation. + /// + /// SetAppMenu + /// SetAppMenu + public Avalonia.Native.Interop.IAvnMenu AppMenu + { + set => SetAppMenu(value); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvaloniaNativeFactory::Initialize([In] IAvnGCHandleDeallocatorCallback* deallocator) + /// IAvaloniaNativeFactory::Initialize + public unsafe void Initialize(Avalonia.Native.Interop.IAvnGCHandleDeallocatorCallback deallocator) + { + System.IntPtr deallocator_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + deallocator_ = SharpGen.Runtime.CppObject.ToCallbackPtr(deallocator); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)deallocator_, (*(void ***)this._nativePointer)[3]); + System.GC.KeepAlive(deallocator); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// IAvnMacOptions* IAvaloniaNativeFactory::GetMacOptions() + /// IAvaloniaNativeFactory::GetMacOptions + internal unsafe Avalonia.Native.Interop.IAvnMacOptions GetMacOptions() + { + Avalonia.Native.Interop.IAvnMacOptions __result__; + System.IntPtr __result__native = System.IntPtr.Zero; + __result__native = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, (*(void ***)this._nativePointer)[4]); + if (__result__native != System.IntPtr.Zero) + __result__ = new Avalonia.Native.Interop.IAvnMacOptions(__result__native); + else + __result__ = null; + return __result__; + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// No documentation. + /// HRESULT IAvaloniaNativeFactory::CreateWindow([In] IAvnWindowEvents* cb,[In] IAvnGlContext* gl,[In] IAvnWindow** ppv) + /// IAvaloniaNativeFactory::CreateWindow + public unsafe Avalonia.Native.Interop.IAvnWindow CreateWindow(Avalonia.Native.Interop.IAvnWindowEvents cb, Avalonia.Native.Interop.IAvnGlContext gl) + { + System.IntPtr cb_ = System.IntPtr.Zero; + System.IntPtr gl_ = System.IntPtr.Zero; + Avalonia.Native.Interop.IAvnWindow vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + cb_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cb); + gl_ = SharpGen.Runtime.CppObject.ToCallbackPtr(gl); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)cb_, (void *)gl_, &vOut_, (*(void ***)this._nativePointer)[5]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnWindow(vOut_); + else + vOut = null; + System.GC.KeepAlive(cb); + System.GC.KeepAlive(gl); + __result__.CheckError(); + return vOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// No documentation. + /// HRESULT IAvaloniaNativeFactory::CreatePopup([In] IAvnWindowEvents* cb,[In] IAvnGlContext* gl,[In] IAvnPopup** ppv) + /// IAvaloniaNativeFactory::CreatePopup + public unsafe Avalonia.Native.Interop.IAvnPopup CreatePopup(Avalonia.Native.Interop.IAvnWindowEvents cb, Avalonia.Native.Interop.IAvnGlContext gl) + { + System.IntPtr cb_ = System.IntPtr.Zero; + System.IntPtr gl_ = System.IntPtr.Zero; + Avalonia.Native.Interop.IAvnPopup vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + cb_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cb); + gl_ = SharpGen.Runtime.CppObject.ToCallbackPtr(gl); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)cb_, (void *)gl_, &vOut_, (*(void ***)this._nativePointer)[6]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnPopup(vOut_); + else + vOut = null; + System.GC.KeepAlive(cb); + System.GC.KeepAlive(gl); + __result__.CheckError(); + return vOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvaloniaNativeFactory::CreatePlatformThreadingInterface([In] IAvnPlatformThreadingInterface** ppv) + /// IAvaloniaNativeFactory::CreatePlatformThreadingInterface + public unsafe Avalonia.Native.Interop.IAvnPlatformThreadingInterface CreatePlatformThreadingInterface() + { + Avalonia.Native.Interop.IAvnPlatformThreadingInterface vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[7]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnPlatformThreadingInterface(vOut_); + else + vOut = null; + __result__.CheckError(); + return vOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvaloniaNativeFactory::CreateSystemDialogs([In] IAvnSystemDialogs** ppv) + /// IAvaloniaNativeFactory::CreateSystemDialogs + public unsafe Avalonia.Native.Interop.IAvnSystemDialogs CreateSystemDialogs() + { + Avalonia.Native.Interop.IAvnSystemDialogs vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[8]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnSystemDialogs(vOut_); + else + vOut = null; + __result__.CheckError(); + return vOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvaloniaNativeFactory::CreateScreens([In] IAvnScreens** ppv) + /// IAvaloniaNativeFactory::CreateScreens + public unsafe Avalonia.Native.Interop.IAvnScreens CreateScreens() + { + Avalonia.Native.Interop.IAvnScreens vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[9]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnScreens(vOut_); + else + vOut = null; + __result__.CheckError(); + return vOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvaloniaNativeFactory::CreateClipboard([In] IAvnClipboard** ppv) + /// IAvaloniaNativeFactory::CreateClipboard + public unsafe Avalonia.Native.Interop.IAvnClipboard CreateClipboard() + { + Avalonia.Native.Interop.IAvnClipboard vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[10]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnClipboard(vOut_); + else + vOut = null; + __result__.CheckError(); + return vOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvaloniaNativeFactory::CreateDndClipboard([In] IAvnClipboard** ppv) + /// IAvaloniaNativeFactory::CreateDndClipboard + public unsafe Avalonia.Native.Interop.IAvnClipboard CreateDndClipboard() + { + Avalonia.Native.Interop.IAvnClipboard vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[11]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnClipboard(vOut_); + else + vOut = null; + __result__.CheckError(); + return vOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvaloniaNativeFactory::CreateCursorFactory([In] IAvnCursorFactory** ppv) + /// IAvaloniaNativeFactory::CreateCursorFactory + public unsafe Avalonia.Native.Interop.IAvnCursorFactory CreateCursorFactory() + { + Avalonia.Native.Interop.IAvnCursorFactory vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[12]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnCursorFactory(vOut_); + else + vOut = null; + __result__.CheckError(); + return vOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvaloniaNativeFactory::ObtainGlDisplay([In] IAvnGlDisplay** ppv) + /// IAvaloniaNativeFactory::ObtainGlDisplay + public unsafe Avalonia.Native.Interop.IAvnGlDisplay ObtainGlDisplay() + { + Avalonia.Native.Interop.IAvnGlDisplay vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[13]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnGlDisplay(vOut_); + else + vOut = null; + __result__.CheckError(); + return vOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvaloniaNativeFactory::SetAppMenu([In] IAvnMenu* menu) + /// IAvaloniaNativeFactory::SetAppMenu + internal unsafe void SetAppMenu(Avalonia.Native.Interop.IAvnMenu menu) + { + System.IntPtr menu_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + menu_ = SharpGen.Runtime.CppObject.ToCallbackPtr(menu); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)menu_, (*(void ***)this._nativePointer)[14]); + System.GC.KeepAlive(menu); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvaloniaNativeFactory::CreateMenu([In] IAvnMenuEvents* cb,[In] IAvnMenu** ppv) + /// IAvaloniaNativeFactory::CreateMenu + public unsafe Avalonia.Native.Interop.IAvnMenu CreateMenu(Avalonia.Native.Interop.IAvnMenuEvents cb) + { + System.IntPtr cb_ = System.IntPtr.Zero; + Avalonia.Native.Interop.IAvnMenu vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + cb_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cb); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)cb_, &vOut_, (*(void ***)this._nativePointer)[15]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnMenu(vOut_); + else + vOut = null; + System.GC.KeepAlive(cb); + __result__.CheckError(); + return vOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvaloniaNativeFactory::CreateMenuItem([In] IAvnMenuItem** ppv) + /// IAvaloniaNativeFactory::CreateMenuItem + public unsafe Avalonia.Native.Interop.IAvnMenuItem CreateMenuItem() + { + Avalonia.Native.Interop.IAvnMenuItem vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[16]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnMenuItem(vOut_); + else + vOut = null; + __result__.CheckError(); + return vOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvaloniaNativeFactory::CreateMenuItemSeperator([In] IAvnMenuItem** ppv) + /// IAvaloniaNativeFactory::CreateMenuItemSeperator + public unsafe Avalonia.Native.Interop.IAvnMenuItem CreateMenuItemSeperator() + { + Avalonia.Native.Interop.IAvnMenuItem vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[17]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnMenuItem(vOut_); + else + vOut = null; + __result__.CheckError(); + return vOut; + } + } + + class IAvnActionCallbackShadow : SharpGen.Runtime.ComObjectShadow + { + protected unsafe class IAvnActionCallbackVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl + { + public IAvnActionCallbackVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) + { + AddMethod(new RunDelegate(Run)); + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate void RunDelegate(System.IntPtr thisObject); + private static unsafe void Run(System.IntPtr thisObject) + { + try + { + IAvnActionCallback @this = (IAvnActionCallback)ToShadow(thisObject).Callback; + @this.Run(); + } + catch (System.Exception __exception__) + { + IAvnActionCallback @this = (IAvnActionCallback)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + } + } + } + + protected override SharpGen.Runtime.CppObjectVtbl Vtbl + { + get; + } + + = new Avalonia.Native.Interop.IAvnActionCallbackShadow.IAvnActionCallbackVtbl(0); + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f08"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnActionCallbackShadow))] + public partial interface IAvnActionCallback : SharpGen.Runtime.IUnknown + { + void Run(); + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f0f")] + public partial class IAvnClipboard : SharpGen.Runtime.ComObject + { + public IAvnClipboard(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnClipboard(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnClipboard(nativePtr); + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnClipboard::GetText([In] char* type,[In] IAvnString** ppv) + /// IAvnClipboard::GetText + public unsafe Avalonia.Native.Interop.IAvnString GetText(System.String type) + { + System.IntPtr type_; + Avalonia.Native.Interop.IAvnString vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + type_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(type); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)type_, &vOut_, (*(void ***)this._nativePointer)[3]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnString(vOut_); + else + vOut = null; + System.Runtime.InteropServices.Marshal.FreeHGlobal(type_); + __result__.CheckError(); + return vOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// No documentation. + /// HRESULT IAvnClipboard::SetText([In] char* type,[In] void* utf8Text) + /// IAvnClipboard::SetText + public unsafe void SetText(System.String type, System.IntPtr utf8Text) + { + System.IntPtr type_; + SharpGen.Runtime.Result __result__; + type_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(type); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)type_, (void *)utf8Text, (*(void ***)this._nativePointer)[4]); + System.Runtime.InteropServices.Marshal.FreeHGlobal(type_); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnClipboard::ObtainFormats([In] IAvnStringArray** ppv) + /// IAvnClipboard::ObtainFormats + public unsafe Avalonia.Native.Interop.IAvnStringArray ObtainFormats() + { + Avalonia.Native.Interop.IAvnStringArray vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[5]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnStringArray(vOut_); + else + vOut = null; + __result__.CheckError(); + return vOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnClipboard::GetStrings([In] char* type,[In] IAvnStringArray** ppv) + /// IAvnClipboard::GetStrings + public unsafe Avalonia.Native.Interop.IAvnStringArray GetStrings(System.String type) + { + System.IntPtr type_; + Avalonia.Native.Interop.IAvnStringArray vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + type_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(type); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)type_, &vOut_, (*(void ***)this._nativePointer)[6]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnStringArray(vOut_); + else + vOut = null; + System.Runtime.InteropServices.Marshal.FreeHGlobal(type_); + __result__.CheckError(); + return vOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// No documentation. + /// No documentation. + /// HRESULT IAvnClipboard::SetBytes([In] char* type,[In] void* utf8Text,[In] int len) + /// IAvnClipboard::SetBytes + public unsafe void SetBytes(System.String type, System.IntPtr utf8Text, System.Int32 len) + { + System.IntPtr type_; + SharpGen.Runtime.Result __result__; + type_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(type); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)type_, (void *)utf8Text, len, (*(void ***)this._nativePointer)[7]); + System.Runtime.InteropServices.Marshal.FreeHGlobal(type_); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnClipboard::GetBytes([In] char* type,[In] IAvnString** ppv) + /// IAvnClipboard::GetBytes + public unsafe Avalonia.Native.Interop.IAvnString GetBytes(System.String type) + { + System.IntPtr type_; + Avalonia.Native.Interop.IAvnString vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + type_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(type); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)type_, &vOut_, (*(void ***)this._nativePointer)[8]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnString(vOut_); + else + vOut = null; + System.Runtime.InteropServices.Marshal.FreeHGlobal(type_); + __result__.CheckError(); + return vOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnClipboard::Clear() + /// IAvnClipboard::Clear + public unsafe void Clear() + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[9]); + __result__.CheckError(); + } + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f10")] + public partial class IAvnCursor : SharpGen.Runtime.ComObject + { + public IAvnCursor(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnCursor(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnCursor(nativePtr); + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f11")] + public partial class IAvnCursorFactory : SharpGen.Runtime.ComObject + { + public IAvnCursorFactory(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnCursorFactory(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnCursorFactory(nativePtr); + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnCursorFactory::GetCursor([In] AvnStandardCursorType cursorType,[Out] IAvnCursor** retOut) + /// IAvnCursorFactory::GetCursor + public unsafe Avalonia.Native.Interop.IAvnCursor GetCursor(Avalonia.Native.Interop.AvnStandardCursorType cursorType) + { + Avalonia.Native.Interop.IAvnCursor retOut; + System.IntPtr retOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, unchecked ((System.Int32)cursorType), &retOut_, (*(void ***)this._nativePointer)[3]); + if (retOut_ != System.IntPtr.Zero) + retOut = new Avalonia.Native.Interop.IAvnCursor(retOut_); + else + retOut = null; + __result__.CheckError(); + return retOut; + } + } + + class IAvnDndResultCallbackShadow : SharpGen.Runtime.ComObjectShadow + { + protected unsafe class IAvnDndResultCallbackVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl + { + public IAvnDndResultCallbackVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) + { + AddMethod(new OnDragAndDropCompleteDelegate(OnDragAndDropComplete)); + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate void OnDragAndDropCompleteDelegate(System.IntPtr thisObject, int arg0); + private static unsafe void OnDragAndDropComplete(System.IntPtr thisObject, int param0) + { + try + { + Avalonia.Native.Interop.AvnDragDropEffects effecct = default (Avalonia.Native.Interop.AvnDragDropEffects); + effecct = (Avalonia.Native.Interop.AvnDragDropEffects)param0; + IAvnDndResultCallback @this = (IAvnDndResultCallback)ToShadow(thisObject).Callback; + @this.OnDragAndDropComplete(effecct); + } + catch (System.Exception __exception__) + { + IAvnDndResultCallback @this = (IAvnDndResultCallback)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + } + } + } + + protected override SharpGen.Runtime.CppObjectVtbl Vtbl + { + get; + } + + = new Avalonia.Native.Interop.IAvnDndResultCallbackShadow.IAvnDndResultCallbackVtbl(0); + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f21"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnDndResultCallbackShadow))] + public partial interface IAvnDndResultCallback : SharpGen.Runtime.IUnknown + { + void OnDragAndDropComplete(Avalonia.Native.Interop.AvnDragDropEffects effecct); + } + + class IAvnGCHandleDeallocatorCallbackShadow : SharpGen.Runtime.ComObjectShadow + { + protected unsafe class IAvnGCHandleDeallocatorCallbackVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl + { + public IAvnGCHandleDeallocatorCallbackVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) + { + AddMethod(new FreeGCHandleDelegate(FreeGCHandle)); + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate void FreeGCHandleDelegate(System.IntPtr thisObject, void *arg0); + private static unsafe void FreeGCHandle(System.IntPtr thisObject, void *param0) + { + try + { + System.IntPtr handle = default (System.IntPtr); + handle = (System.IntPtr)param0; + IAvnGCHandleDeallocatorCallback @this = (IAvnGCHandleDeallocatorCallback)ToShadow(thisObject).Callback; + @this.FreeGCHandle(handle); + } + catch (System.Exception __exception__) + { + IAvnGCHandleDeallocatorCallback @this = (IAvnGCHandleDeallocatorCallback)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + } + } + } + + protected override SharpGen.Runtime.CppObjectVtbl Vtbl + { + get; + } + + = new Avalonia.Native.Interop.IAvnGCHandleDeallocatorCallbackShadow.IAvnGCHandleDeallocatorCallbackVtbl(0); + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f22"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnGCHandleDeallocatorCallbackShadow))] + public partial interface IAvnGCHandleDeallocatorCallback : SharpGen.Runtime.IUnknown + { + void FreeGCHandle(System.IntPtr handle); + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f14")] + public partial class IAvnGlContext : SharpGen.Runtime.ComObject + { + public IAvnGlContext(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnGlContext(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnGlContext(nativePtr); + /// + /// No documentation. + /// + /// GetSampleCount + /// GetSampleCount + public System.Int32 SampleCount + { + get => GetSampleCount(); + } + + /// + /// No documentation. + /// + /// GetStencilSize + /// GetStencilSize + public System.Int32 StencilSize + { + get => GetStencilSize(); + } + + /// + /// No documentation. + /// + /// GetNativeHandle + /// GetNativeHandle + public System.IntPtr NativeHandle + { + get => GetNativeHandle(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnGlContext::MakeCurrent([In] IUnknown** ppv) + /// IAvnGlContext::MakeCurrent + public unsafe SharpGen.Runtime.IUnknown MakeCurrent() + { + SharpGen.Runtime.IUnknown vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[3]); + if (vOut_ != System.IntPtr.Zero) + vOut = new SharpGen.Runtime.ComObject(vOut_); + else + vOut = null; + __result__.CheckError(); + return vOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnGlContext::LegacyMakeCurrent() + /// IAvnGlContext::LegacyMakeCurrent + public unsafe void LegacyMakeCurrent() + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[4]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// int IAvnGlContext::GetSampleCount() + /// IAvnGlContext::GetSampleCount + internal unsafe System.Int32 GetSampleCount() + { + System.Int32 __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[5]); + return __result__; + } + + /// + /// No documentation. + /// + /// No documentation. + /// int IAvnGlContext::GetStencilSize() + /// IAvnGlContext::GetStencilSize + internal unsafe System.Int32 GetStencilSize() + { + System.Int32 __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[6]); + return __result__; + } + + /// + /// No documentation. + /// + /// No documentation. + /// void* IAvnGlContext::GetNativeHandle() + /// IAvnGlContext::GetNativeHandle + internal unsafe System.IntPtr GetNativeHandle() + { + System.IntPtr __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, (*(void ***)this._nativePointer)[7]); + return __result__; + } + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f13")] + public partial class IAvnGlDisplay : SharpGen.Runtime.ComObject + { + public IAvnGlDisplay(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnGlDisplay(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnGlDisplay(nativePtr); + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnGlDisplay::CreateContext([In] IAvnGlContext* share,[In] IAvnGlContext** ppv) + /// IAvnGlDisplay::CreateContext + public unsafe Avalonia.Native.Interop.IAvnGlContext CreateContext(Avalonia.Native.Interop.IAvnGlContext share) + { + System.IntPtr share_ = System.IntPtr.Zero; + Avalonia.Native.Interop.IAvnGlContext vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + share_ = SharpGen.Runtime.CppObject.ToCallbackPtr(share); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)share_, &vOut_, (*(void ***)this._nativePointer)[3]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnGlContext(vOut_); + else + vOut = null; + System.GC.KeepAlive(share); + __result__.CheckError(); + return vOut; + } + + /// + /// No documentation. + /// + /// void IAvnGlDisplay::LegacyClearCurrentContext() + /// IAvnGlDisplay::LegacyClearCurrentContext + public unsafe void LegacyClearCurrentContext() + { + Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (*(void ***)this._nativePointer)[4]); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnGlDisplay::WrapContext([In] void* native,[In] IAvnGlContext** ppv) + /// IAvnGlDisplay::WrapContext + public unsafe Avalonia.Native.Interop.IAvnGlContext WrapContext(System.IntPtr native) + { + Avalonia.Native.Interop.IAvnGlContext vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)native, &vOut_, (*(void ***)this._nativePointer)[5]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnGlContext(vOut_); + else + vOut = null; + __result__.CheckError(); + return vOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// void* IAvnGlDisplay::GetProcAddress([In] char* proc) + /// IAvnGlDisplay::GetProcAddress + public unsafe System.IntPtr GetProcAddress(System.String rocRef) + { + System.IntPtr rocRef_; + System.IntPtr __result__; + rocRef_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(rocRef); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, (void *)rocRef_, (*(void ***)this._nativePointer)[6]); + System.Runtime.InteropServices.Marshal.FreeHGlobal(rocRef_); + return __result__; + } + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f16")] + public partial class IAvnGlSurfaceRenderingSession : SharpGen.Runtime.ComObject + { + public IAvnGlSurfaceRenderingSession(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnGlSurfaceRenderingSession(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnGlSurfaceRenderingSession(nativePtr); + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnGlSurfaceRenderingSession::GetPixelSize([In] AvnPixelSize* ret) + /// IAvnGlSurfaceRenderingSession::GetPixelSize + public unsafe Avalonia.Native.Interop.AvnPixelSize GetPixelSize() + { + Avalonia.Native.Interop.AvnPixelSize ret; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[3]); + __result__.CheckError(); + return ret; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnGlSurfaceRenderingSession::GetScaling([In] double* ret) + /// IAvnGlSurfaceRenderingSession::GetScaling + public unsafe System.Double GetScaling() + { + System.Double ret; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[4]); + __result__.CheckError(); + return ret; + } + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f15")] + public partial class IAvnGlSurfaceRenderTarget : SharpGen.Runtime.ComObject + { + public IAvnGlSurfaceRenderTarget(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnGlSurfaceRenderTarget(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnGlSurfaceRenderTarget(nativePtr); + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnGlSurfaceRenderTarget::BeginDrawing([In] IAvnGlSurfaceRenderingSession** ret) + /// IAvnGlSurfaceRenderTarget::BeginDrawing + public unsafe Avalonia.Native.Interop.IAvnGlSurfaceRenderingSession BeginDrawing() + { + Avalonia.Native.Interop.IAvnGlSurfaceRenderingSession ret; + System.IntPtr ret_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret_, (*(void ***)this._nativePointer)[3]); + if (ret_ != System.IntPtr.Zero) + ret = new Avalonia.Native.Interop.IAvnGlSurfaceRenderingSession(ret_); + else + ret = null; + __result__.CheckError(); + return ret; + } + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f0a")] + public partial class IAvnLoopCancellation : SharpGen.Runtime.ComObject + { + public IAvnLoopCancellation(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnLoopCancellation(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnLoopCancellation(nativePtr); + /// + /// No documentation. + /// + /// void IAvnLoopCancellation::Cancel() + /// IAvnLoopCancellation::Cancel + public unsafe void Cancel() + { + Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (*(void ***)this._nativePointer)[3]); + } + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f07")] + public partial class IAvnMacOptions : SharpGen.Runtime.ComObject + { + public IAvnMacOptions(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnMacOptions(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnMacOptions(nativePtr); + /// + /// No documentation. + /// + /// SetShowInDock + /// SetShowInDock + public System.Int32 ShowInDock + { + set => SetShowInDock(value); + } + + /// + /// No documentation. + /// + /// SetApplicationTitle + /// SetApplicationTitle + public System.IntPtr ApplicationTitle + { + set => SetApplicationTitle(value); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnMacOptions::SetShowInDock([In] int show) + /// IAvnMacOptions::SetShowInDock + internal unsafe void SetShowInDock(System.Int32 show) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, show, (*(void ***)this._nativePointer)[3]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnMacOptions::SetApplicationTitle([In] void* utf8string) + /// IAvnMacOptions::SetApplicationTitle + internal unsafe void SetApplicationTitle(System.IntPtr utf8string) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)utf8string, (*(void ***)this._nativePointer)[4]); + __result__.CheckError(); + } + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f17")] + public partial class IAvnMenu : SharpGen.Runtime.ComObject + { + public IAvnMenu(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnMenu(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnMenu(nativePtr); + /// + /// No documentation. + /// + /// SetTitle + /// SetTitle + public System.IntPtr Title + { + set => SetTitle(value); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// No documentation. + /// HRESULT IAvnMenu::InsertItem([In] int index,[In] IAvnMenuItem* item) + /// IAvnMenu::InsertItem + public unsafe void InsertItem(System.Int32 index, Avalonia.Native.Interop.IAvnMenuItem item) + { + System.IntPtr item_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + item_ = SharpGen.Runtime.CppObject.ToCallbackPtr(item); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, index, (void *)item_, (*(void ***)this._nativePointer)[3]); + System.GC.KeepAlive(item); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnMenu::RemoveItem([In] IAvnMenuItem* item) + /// IAvnMenu::RemoveItem + public unsafe void RemoveItem(Avalonia.Native.Interop.IAvnMenuItem item) + { + System.IntPtr item_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + item_ = SharpGen.Runtime.CppObject.ToCallbackPtr(item); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)item_, (*(void ***)this._nativePointer)[4]); + System.GC.KeepAlive(item); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnMenu::SetTitle([In] void* utf8String) + /// IAvnMenu::SetTitle + internal unsafe void SetTitle(System.IntPtr utf8String) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)utf8String, (*(void ***)this._nativePointer)[5]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnMenu::Clear() + /// IAvnMenu::Clear + public unsafe void Clear() + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[6]); + __result__.CheckError(); + } + } + + class IAvnMenuEventsShadow : SharpGen.Runtime.ComObjectShadow + { + protected unsafe class IAvnMenuEventsVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl + { + public IAvnMenuEventsVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) + { + AddMethod(new NeedsUpdateDelegate(NeedsUpdate)); + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate void NeedsUpdateDelegate(System.IntPtr thisObject); + private static unsafe void NeedsUpdate(System.IntPtr thisObject) + { + try + { + IAvnMenuEvents @this = (IAvnMenuEvents)ToShadow(thisObject).Callback; + @this.NeedsUpdate(); + } + catch (System.Exception __exception__) + { + IAvnMenuEvents @this = (IAvnMenuEvents)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + } + } + } + + protected override SharpGen.Runtime.CppObjectVtbl Vtbl + { + get; + } + + = new Avalonia.Native.Interop.IAvnMenuEventsShadow.IAvnMenuEventsVtbl(0); + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f1A"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnMenuEventsShadow))] + public partial interface IAvnMenuEvents : SharpGen.Runtime.IUnknown + { + void NeedsUpdate(); + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f19")] + public partial class IAvnMenuItem : SharpGen.Runtime.ComObject + { + public IAvnMenuItem(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnMenuItem(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnMenuItem(nativePtr); + /// + /// No documentation. + /// + /// SetSubMenu + /// SetSubMenu + public Avalonia.Native.Interop.IAvnMenu SubMenu + { + set => SetSubMenu(value); + } + + /// + /// No documentation. + /// + /// SetTitle + /// SetTitle + public System.IntPtr Title + { + set => SetTitle(value); + } + + /// + /// No documentation. + /// + /// SetIsChecked + /// SetIsChecked + public System.Boolean IsChecked + { + set => SetIsChecked(value); + } + + /// + /// No documentation. + /// + /// SetToggleType + /// SetToggleType + public Avalonia.Native.Interop.AvnMenuItemToggleType ToggleType + { + set => SetToggleType(value); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnMenuItem::SetSubMenu([In] IAvnMenu* menu) + /// IAvnMenuItem::SetSubMenu + internal unsafe void SetSubMenu(Avalonia.Native.Interop.IAvnMenu menu) + { + System.IntPtr menu_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + menu_ = SharpGen.Runtime.CppObject.ToCallbackPtr(menu); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)menu_, (*(void ***)this._nativePointer)[3]); + System.GC.KeepAlive(menu); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnMenuItem::SetTitle([In] void* utf8String) + /// IAvnMenuItem::SetTitle + internal unsafe void SetTitle(System.IntPtr utf8String) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)utf8String, (*(void ***)this._nativePointer)[4]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// No documentation. + /// HRESULT IAvnMenuItem::SetGesture([In] void* utf8String,[In] AvnInputModifiers modifiers) + /// IAvnMenuItem::SetGesture + public unsafe void SetGesture(System.IntPtr utf8String, Avalonia.Native.Interop.AvnInputModifiers modifiers) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)utf8String, unchecked ((System.Int32)modifiers), (*(void ***)this._nativePointer)[5]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// No documentation. + /// HRESULT IAvnMenuItem::SetAction([In] IAvnPredicateCallback* predicate,[In] IAvnActionCallback* callback) + /// IAvnMenuItem::SetAction + public unsafe void SetAction(Avalonia.Native.Interop.IAvnPredicateCallback redicateRef, Avalonia.Native.Interop.IAvnActionCallback callback) + { + System.IntPtr redicateRef_ = System.IntPtr.Zero; + System.IntPtr callback_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + redicateRef_ = SharpGen.Runtime.CppObject.ToCallbackPtr(redicateRef); + callback_ = SharpGen.Runtime.CppObject.ToCallbackPtr(callback); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)redicateRef_, (void *)callback_, (*(void ***)this._nativePointer)[6]); + System.GC.KeepAlive(redicateRef); + System.GC.KeepAlive(callback); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnMenuItem::SetIsChecked([In] bool isChecked) + /// IAvnMenuItem::SetIsChecked + internal unsafe void SetIsChecked(System.Boolean isChecked) + { + System.Byte isChecked_; + SharpGen.Runtime.Result __result__; + isChecked_ = (System.Byte)(isChecked ? 1 : 0); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, isChecked_, (*(void ***)this._nativePointer)[7]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnMenuItem::SetToggleType([In] AvnMenuItemToggleType toggleType) + /// IAvnMenuItem::SetToggleType + internal unsafe void SetToggleType(Avalonia.Native.Interop.AvnMenuItemToggleType toggleType) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, unchecked ((System.Int32)toggleType), (*(void ***)this._nativePointer)[8]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// No documentation. + /// HRESULT IAvnMenuItem::SetIcon([In] void* data,[In] size_t length) + /// IAvnMenuItem::SetIcon + public unsafe void SetIcon(System.IntPtr data, SharpGen.Runtime.PointerSize length) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)data, (void *)length, (*(void ***)this._nativePointer)[9]); + __result__.CheckError(); + } + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f20")] + public partial class IAvnNativeControlHost : SharpGen.Runtime.ComObject + { + public IAvnNativeControlHost(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnNativeControlHost(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnNativeControlHost(nativePtr); + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnNativeControlHost::CreateDefaultChild([In] void* parent,[Out] void** retOut) + /// IAvnNativeControlHost::CreateDefaultChild + public unsafe System.IntPtr CreateDefaultChild(System.IntPtr arentRef) + { + System.IntPtr retOut; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)arentRef, &retOut, (*(void ***)this._nativePointer)[3]); + __result__.CheckError(); + return retOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// IAvnNativeControlHostTopLevelAttachment* IAvnNativeControlHost::CreateAttachment() + /// IAvnNativeControlHost::CreateAttachment + public unsafe Avalonia.Native.Interop.IAvnNativeControlHostTopLevelAttachment CreateAttachment() + { + Avalonia.Native.Interop.IAvnNativeControlHostTopLevelAttachment __result__; + System.IntPtr __result__native = System.IntPtr.Zero; + __result__native = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, (*(void ***)this._nativePointer)[4]); + if (__result__native != System.IntPtr.Zero) + __result__ = new Avalonia.Native.Interop.IAvnNativeControlHostTopLevelAttachment(__result__native); + else + __result__ = null; + return __result__; + } + + /// + /// No documentation. + /// + /// No documentation. + /// void IAvnNativeControlHost::DestroyDefaultChild([In] void* child) + /// IAvnNativeControlHost::DestroyDefaultChild + public unsafe void DestroyDefaultChild(System.IntPtr child) + { + Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (void *)child, (*(void ***)this._nativePointer)[5]); + } + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f21")] + public partial class IAvnNativeControlHostTopLevelAttachment : SharpGen.Runtime.ComObject + { + public IAvnNativeControlHostTopLevelAttachment(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnNativeControlHostTopLevelAttachment(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnNativeControlHostTopLevelAttachment(nativePtr); + /// + /// No documentation. + /// + /// GetParentHandle + /// GetParentHandle + public System.IntPtr ParentHandle + { + get => GetParentHandle(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// void* IAvnNativeControlHostTopLevelAttachment::GetParentHandle() + /// IAvnNativeControlHostTopLevelAttachment::GetParentHandle + internal unsafe System.IntPtr GetParentHandle() + { + System.IntPtr __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, (*(void ***)this._nativePointer)[3]); + return __result__; + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnNativeControlHostTopLevelAttachment::InitializeWithChildHandle([In] void* child) + /// IAvnNativeControlHostTopLevelAttachment::InitializeWithChildHandle + public unsafe void InitializeWithChildHandle(System.IntPtr child) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)child, (*(void ***)this._nativePointer)[4]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnNativeControlHostTopLevelAttachment::AttachTo([In] IAvnNativeControlHost* host) + /// IAvnNativeControlHostTopLevelAttachment::AttachTo + public unsafe void AttachTo(Avalonia.Native.Interop.IAvnNativeControlHost host) + { + System.IntPtr host_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + host_ = SharpGen.Runtime.CppObject.ToCallbackPtr(host); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)host_, (*(void ***)this._nativePointer)[5]); + System.GC.KeepAlive(host); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// No documentation. + /// No documentation. + /// void IAvnNativeControlHostTopLevelAttachment::ShowInBounds([In] float x,[In] float y,[In] float width,[In] float height) + /// IAvnNativeControlHostTopLevelAttachment::ShowInBounds + public unsafe void ShowInBounds(System.Single x, System.Single y, System.Single width, System.Single height) + { + Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, x, y, width, height, (*(void ***)this._nativePointer)[6]); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// void IAvnNativeControlHostTopLevelAttachment::HideWithSize([In] float width,[In] float height) + /// IAvnNativeControlHostTopLevelAttachment::HideWithSize + public unsafe void HideWithSize(System.Single width, System.Single height) + { + Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, width, height, (*(void ***)this._nativePointer)[7]); + } + + /// + /// No documentation. + /// + /// void IAvnNativeControlHostTopLevelAttachment::ReleaseChild() + /// IAvnNativeControlHostTopLevelAttachment::ReleaseChild + public unsafe void ReleaseChild() + { + Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (*(void ***)this._nativePointer)[8]); + } + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f0b")] + public partial class IAvnPlatformThreadingInterface : SharpGen.Runtime.ComObject + { + public IAvnPlatformThreadingInterface(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnPlatformThreadingInterface(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnPlatformThreadingInterface(nativePtr); + /// + /// No documentation. + /// + /// GetCurrentThreadIsLoopThread + /// GetCurrentThreadIsLoopThread + public System.Boolean CurrentThreadIsLoopThread + { + get => GetCurrentThreadIsLoopThread(); + } + + /// + /// No documentation. + /// + /// SetSignaledCallback + /// SetSignaledCallback + public Avalonia.Native.Interop.IAvnSignaledCallback SignaledCallback + { + set => SetSignaledCallback(value); + } + + /// + /// No documentation. + /// + /// No documentation. + /// bool IAvnPlatformThreadingInterface::GetCurrentThreadIsLoopThread() + /// IAvnPlatformThreadingInterface::GetCurrentThreadIsLoopThread + internal unsafe System.Boolean GetCurrentThreadIsLoopThread() + { + System.Boolean __result__; + System.Byte __result__native; + __result__native = Avalonia.Native.LocalInterop.CalliThisCallSystemByte(this._nativePointer, (*(void ***)this._nativePointer)[3]); + __result__ = __result__native != 0; + return __result__; + } + + /// + /// No documentation. + /// + /// No documentation. + /// void IAvnPlatformThreadingInterface::SetSignaledCallback([In] IAvnSignaledCallback* cb) + /// IAvnPlatformThreadingInterface::SetSignaledCallback + internal unsafe void SetSignaledCallback(Avalonia.Native.Interop.IAvnSignaledCallback cb) + { + System.IntPtr cb_ = System.IntPtr.Zero; + cb_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cb); + Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (void *)cb_, (*(void ***)this._nativePointer)[4]); + System.GC.KeepAlive(cb); + } + + /// + /// No documentation. + /// + /// No documentation. + /// IAvnLoopCancellation* IAvnPlatformThreadingInterface::CreateLoopCancellation() + /// IAvnPlatformThreadingInterface::CreateLoopCancellation + public unsafe Avalonia.Native.Interop.IAvnLoopCancellation CreateLoopCancellation() + { + Avalonia.Native.Interop.IAvnLoopCancellation __result__; + System.IntPtr __result__native = System.IntPtr.Zero; + __result__native = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, (*(void ***)this._nativePointer)[5]); + if (__result__native != System.IntPtr.Zero) + __result__ = new Avalonia.Native.Interop.IAvnLoopCancellation(__result__native); + else + __result__ = null; + return __result__; + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnPlatformThreadingInterface::RunLoop([In] IAvnLoopCancellation* cancel) + /// IAvnPlatformThreadingInterface::RunLoop + public unsafe void RunLoop(Avalonia.Native.Interop.IAvnLoopCancellation cancel) + { + System.IntPtr cancel_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + cancel_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cancel); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)cancel_, (*(void ***)this._nativePointer)[6]); + System.GC.KeepAlive(cancel); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// void IAvnPlatformThreadingInterface::Signal([In] int priority) + /// IAvnPlatformThreadingInterface::Signal + public unsafe void Signal(System.Int32 priority) + { + Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, priority, (*(void ***)this._nativePointer)[7]); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// No documentation. + /// No documentation. + /// IUnknown* IAvnPlatformThreadingInterface::StartTimer([In] int priority,[In] int ms,[In] IAvnActionCallback* callback) + /// IAvnPlatformThreadingInterface::StartTimer + public unsafe SharpGen.Runtime.ComObject StartTimer(System.Int32 priority, System.Int32 ms, Avalonia.Native.Interop.IAvnActionCallback callback) + { + System.IntPtr callback_ = System.IntPtr.Zero; + SharpGen.Runtime.ComObject __result__; + System.IntPtr __result__native = System.IntPtr.Zero; + callback_ = SharpGen.Runtime.CppObject.ToCallbackPtr(callback); + __result__native = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, priority, ms, (void *)callback_, (*(void ***)this._nativePointer)[8]); + if (__result__native != System.IntPtr.Zero) + __result__ = new SharpGen.Runtime.ComObject(__result__native); + else + __result__ = null; + System.GC.KeepAlive(callback); + return __result__; + } + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f03")] + public partial class IAvnPopup : Avalonia.Native.Interop.IAvnWindowBase + { + public IAvnPopup(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnPopup(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnPopup(nativePtr); + } + + class IAvnPredicateCallbackShadow : SharpGen.Runtime.ComObjectShadow + { + protected unsafe class IAvnPredicateCallbackVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl + { + public IAvnPredicateCallbackVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) + { + AddMethod(new EvaluateDelegate(Evaluate)); + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate System.Byte EvaluateDelegate(System.IntPtr thisObject); + private static unsafe System.Byte Evaluate(System.IntPtr thisObject) + { + try + { + System.Boolean __result__ = default (System.Boolean); + System.Byte __result__native; + IAvnPredicateCallback @this = (IAvnPredicateCallback)ToShadow(thisObject).Callback; + __result__ = @this.Evaluate(); + __result__native = (System.Byte)(__result__ ? 1 : 0); + return __result__native; + } + catch (System.Exception __exception__) + { + IAvnPredicateCallback @this = (IAvnPredicateCallback)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + return default (System.Byte); + } + } + } + + protected override SharpGen.Runtime.CppObjectVtbl Vtbl + { + get; + } + + = new Avalonia.Native.Interop.IAvnPredicateCallbackShadow.IAvnPredicateCallbackVtbl(0); + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f18"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnPredicateCallbackShadow))] + public partial interface IAvnPredicateCallback : SharpGen.Runtime.IUnknown + { + System.Boolean Evaluate(); + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f0e")] + public partial class IAvnScreens : SharpGen.Runtime.ComObject + { + public IAvnScreens(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnScreens(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnScreens(nativePtr); + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnScreens::GetScreenCount([In] int* ret) + /// IAvnScreens::GetScreenCount + public unsafe System.Int32 GetScreenCount() + { + System.Int32 ret; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[3]); + __result__.CheckError(); + return ret; + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnScreens::GetScreen([In] int index,[In] AvnScreen* ret) + /// IAvnScreens::GetScreen + public unsafe Avalonia.Native.Interop.AvnScreen GetScreen(System.Int32 index) + { + Avalonia.Native.Interop.AvnScreen ret; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, index, &ret, (*(void ***)this._nativePointer)[4]); + __result__.CheckError(); + return ret; + } + } + + class IAvnSignaledCallbackShadow : SharpGen.Runtime.ComObjectShadow + { + protected unsafe class IAvnSignaledCallbackVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl + { + public IAvnSignaledCallbackVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) + { + AddMethod(new SignaledDelegate(Signaled)); + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate void SignaledDelegate(System.IntPtr thisObject, int arg0, System.Byte arg1); + private static unsafe void Signaled(System.IntPtr thisObject, int param0, System.Byte param1) + { + try + { + System.Int32 priority = default (System.Int32); + priority = (System.Int32)param0; + System.Boolean priorityContainsMeaningfulValue = default (System.Boolean); + System.Byte priorityContainsMeaningfulValue_ = (System.Byte)param1; + IAvnSignaledCallback @this = (IAvnSignaledCallback)ToShadow(thisObject).Callback; + priorityContainsMeaningfulValue = priorityContainsMeaningfulValue_ != 0; + @this.Signaled(priority, priorityContainsMeaningfulValue); + } + catch (System.Exception __exception__) + { + IAvnSignaledCallback @this = (IAvnSignaledCallback)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + } + } + } + + protected override SharpGen.Runtime.CppObjectVtbl Vtbl + { + get; + } + + = new Avalonia.Native.Interop.IAvnSignaledCallbackShadow.IAvnSignaledCallbackVtbl(0); + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f09"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnSignaledCallbackShadow))] + public partial interface IAvnSignaledCallback : SharpGen.Runtime.IUnknown + { + void Signaled(System.Int32 priority, System.Boolean priorityContainsMeaningfulValue); + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f17")] + public partial class IAvnString : SharpGen.Runtime.ComObject + { + public IAvnString(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnString(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnString(nativePtr); + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnString::Pointer([Out] void** retOut) + /// IAvnString::Pointer + public unsafe System.IntPtr Pointer() + { + System.IntPtr retOut; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &retOut, (*(void ***)this._nativePointer)[3]); + __result__.CheckError(); + return retOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnString::Length([In] int* ret) + /// IAvnString::Length + public unsafe System.Int32 Length() + { + System.Int32 ret; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[4]); + __result__.CheckError(); + return ret; + } + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f20")] + public partial class IAvnStringArray : SharpGen.Runtime.ComObject + { + public IAvnStringArray(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnStringArray(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnStringArray(nativePtr); + /// + /// No documentation. + /// + /// GetCount + /// GetCount + public System.UInt32 Count + { + get => GetCount(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// unsigned int IAvnStringArray::GetCount() + /// IAvnStringArray::GetCount + internal unsafe System.UInt32 GetCount() + { + System.UInt32 __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallSystemUInt32(this._nativePointer, (*(void ***)this._nativePointer)[3]); + return __result__; + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnStringArray::Get([In] unsigned int index,[In] IAvnString** ppv) + /// IAvnStringArray::Get + public unsafe Avalonia.Native.Interop.IAvnString Get(System.UInt32 index) + { + Avalonia.Native.Interop.IAvnString vOut; + System.IntPtr vOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, index, &vOut_, (*(void ***)this._nativePointer)[4]); + if (vOut_ != System.IntPtr.Zero) + vOut = new Avalonia.Native.Interop.IAvnString(vOut_); + else + vOut = null; + __result__.CheckError(); + return vOut; + } + } + + class IAvnSystemDialogEventsShadow : SharpGen.Runtime.ComObjectShadow + { + protected unsafe class IAvnSystemDialogEventsVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl + { + public IAvnSystemDialogEventsVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) + { + AddMethod(new OnCompletedDelegate(OnCompleted)); + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate void OnCompletedDelegate(System.IntPtr thisObject, int arg0, void *arg1); + private static unsafe void OnCompleted(System.IntPtr thisObject, int param0, void *param1) + { + try + { + System.Int32 numResults = default (System.Int32); + numResults = (System.Int32)param0; + System.IntPtr trFirstResultRef = default (System.IntPtr); + trFirstResultRef = (System.IntPtr)param1; + IAvnSystemDialogEvents @this = (IAvnSystemDialogEvents)ToShadow(thisObject).Callback; + @this.OnCompleted(numResults, trFirstResultRef); + } + catch (System.Exception __exception__) + { + IAvnSystemDialogEvents @this = (IAvnSystemDialogEvents)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + } + } + } + + protected override SharpGen.Runtime.CppObjectVtbl Vtbl + { + get; + } + + = new Avalonia.Native.Interop.IAvnSystemDialogEventsShadow.IAvnSystemDialogEventsVtbl(0); + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f0c"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnSystemDialogEventsShadow))] + public partial interface IAvnSystemDialogEvents : SharpGen.Runtime.IUnknown + { + void OnCompleted(System.Int32 numResults, System.IntPtr trFirstResultRef); + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f0d")] + public partial class IAvnSystemDialogs : SharpGen.Runtime.ComObject + { + public IAvnSystemDialogs(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnSystemDialogs(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnSystemDialogs(nativePtr); + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// No documentation. + /// No documentation. + /// void IAvnSystemDialogs::SelectFolderDialog([In] IAvnWindow* parentWindowHandle,[In] IAvnSystemDialogEvents* events,[In] const char* title,[In] const char* initialPath) + /// IAvnSystemDialogs::SelectFolderDialog + public unsafe void SelectFolderDialog(Avalonia.Native.Interop.IAvnWindow arentWindowHandleRef, Avalonia.Native.Interop.IAvnSystemDialogEvents events, System.String title, System.String initialPath) + { + System.IntPtr arentWindowHandleRef_ = System.IntPtr.Zero; + System.IntPtr events_ = System.IntPtr.Zero; + System.IntPtr title_; + System.IntPtr initialPath_; + arentWindowHandleRef_ = SharpGen.Runtime.CppObject.ToCallbackPtr(arentWindowHandleRef); + events_ = SharpGen.Runtime.CppObject.ToCallbackPtr(events); + title_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(title); + initialPath_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(initialPath); + Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (void *)arentWindowHandleRef_, (void *)events_, (void *)title_, (void *)initialPath_, (*(void ***)this._nativePointer)[3]); + System.GC.KeepAlive(arentWindowHandleRef); + System.GC.KeepAlive(events); + System.Runtime.InteropServices.Marshal.FreeHGlobal(title_); + System.Runtime.InteropServices.Marshal.FreeHGlobal(initialPath_); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// No documentation. + /// No documentation. + /// No documentation. + /// No documentation. + /// No documentation. + /// void IAvnSystemDialogs::OpenFileDialog([In] IAvnWindow* parentWindowHandle,[In] IAvnSystemDialogEvents* events,[In] bool allowMultiple,[In] const char* title,[In] const char* initialDirectory,[In] const char* initialFile,[In] const char* filters) + /// IAvnSystemDialogs::OpenFileDialog + public unsafe void OpenFileDialog(Avalonia.Native.Interop.IAvnWindow arentWindowHandleRef, Avalonia.Native.Interop.IAvnSystemDialogEvents events, System.Boolean allowMultiple, System.String title, System.String initialDirectory, System.String initialFile, System.String filters) + { + System.IntPtr arentWindowHandleRef_ = System.IntPtr.Zero; + System.IntPtr events_ = System.IntPtr.Zero; + System.Byte allowMultiple_; + System.IntPtr title_; + System.IntPtr initialDirectory_; + System.IntPtr initialFile_; + System.IntPtr filters_; + arentWindowHandleRef_ = SharpGen.Runtime.CppObject.ToCallbackPtr(arentWindowHandleRef); + events_ = SharpGen.Runtime.CppObject.ToCallbackPtr(events); + allowMultiple_ = (System.Byte)(allowMultiple ? 1 : 0); + title_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(title); + initialDirectory_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(initialDirectory); + initialFile_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(initialFile); + filters_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(filters); + Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (void *)arentWindowHandleRef_, (void *)events_, allowMultiple_, (void *)title_, (void *)initialDirectory_, (void *)initialFile_, (void *)filters_, (*(void ***)this._nativePointer)[4]); + System.GC.KeepAlive(arentWindowHandleRef); + System.GC.KeepAlive(events); + System.Runtime.InteropServices.Marshal.FreeHGlobal(title_); + System.Runtime.InteropServices.Marshal.FreeHGlobal(initialDirectory_); + System.Runtime.InteropServices.Marshal.FreeHGlobal(initialFile_); + System.Runtime.InteropServices.Marshal.FreeHGlobal(filters_); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// No documentation. + /// No documentation. + /// No documentation. + /// No documentation. + /// void IAvnSystemDialogs::SaveFileDialog([In] IAvnWindow* parentWindowHandle,[In] IAvnSystemDialogEvents* events,[In] const char* title,[In] const char* initialDirectory,[In] const char* initialFile,[In] const char* filters) + /// IAvnSystemDialogs::SaveFileDialog + public unsafe void SaveFileDialog(Avalonia.Native.Interop.IAvnWindow arentWindowHandleRef, Avalonia.Native.Interop.IAvnSystemDialogEvents events, System.String title, System.String initialDirectory, System.String initialFile, System.String filters) + { + System.IntPtr arentWindowHandleRef_ = System.IntPtr.Zero; + System.IntPtr events_ = System.IntPtr.Zero; + System.IntPtr title_; + System.IntPtr initialDirectory_; + System.IntPtr initialFile_; + System.IntPtr filters_; + arentWindowHandleRef_ = SharpGen.Runtime.CppObject.ToCallbackPtr(arentWindowHandleRef); + events_ = SharpGen.Runtime.CppObject.ToCallbackPtr(events); + title_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(title); + initialDirectory_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(initialDirectory); + initialFile_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(initialFile); + filters_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(filters); + Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (void *)arentWindowHandleRef_, (void *)events_, (void *)title_, (void *)initialDirectory_, (void *)initialFile_, (void *)filters_, (*(void ***)this._nativePointer)[5]); + System.GC.KeepAlive(arentWindowHandleRef); + System.GC.KeepAlive(events); + System.Runtime.InteropServices.Marshal.FreeHGlobal(title_); + System.Runtime.InteropServices.Marshal.FreeHGlobal(initialDirectory_); + System.Runtime.InteropServices.Marshal.FreeHGlobal(initialFile_); + System.Runtime.InteropServices.Marshal.FreeHGlobal(filters_); + } + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f04")] + public partial class IAvnWindow : Avalonia.Native.Interop.IAvnWindowBase + { + public IAvnWindow(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnWindow(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnWindow(nativePtr); + /// + /// No documentation. + /// + /// SetEnabled + /// SetEnabled + public System.Boolean Enabled + { + set => SetEnabled(value); + } + + /// + /// No documentation. + /// + /// SetParent + /// SetParent + public Avalonia.Native.Interop.IAvnWindow Parent + { + set => SetParent(value); + } + + /// + /// No documentation. + /// + /// SetCanResize + /// SetCanResize + public System.Boolean CanResize + { + set => SetCanResize(value); + } + + /// + /// No documentation. + /// + /// SetDecorations + /// SetDecorations + public Avalonia.Native.Interop.SystemDecorations Decorations + { + set => SetDecorations(value); + } + + /// + /// No documentation. + /// + /// SetTitle + /// SetTitle + public System.IntPtr Title + { + set => SetTitle(value); + } + + /// + /// No documentation. + /// + /// SetTitleBarColor + /// SetTitleBarColor + public Avalonia.Native.Interop.AvnColor TitleBarColor + { + set => SetTitleBarColor(value); + } + + /// + /// No documentation. + /// + /// SetExtendClientArea + /// SetExtendClientArea + public System.Boolean ExtendClientArea + { + set => SetExtendClientArea(value); + } + + /// + /// No documentation. + /// + /// SetExtendClientAreaHints + /// SetExtendClientAreaHints + public Avalonia.Native.Interop.AvnExtendClientAreaChromeHints ExtendClientAreaHints + { + set => SetExtendClientAreaHints(value); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindow::SetEnabled([In] bool enable) + /// IAvnWindow::SetEnabled + internal unsafe void SetEnabled(System.Boolean enable) + { + System.Byte enable_; + SharpGen.Runtime.Result __result__; + enable_ = (System.Byte)(enable ? 1 : 0); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, enable_, (*(void ***)this._nativePointer)[30]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindow::SetParent([In] IAvnWindow* parent) + /// IAvnWindow::SetParent + internal unsafe void SetParent(Avalonia.Native.Interop.IAvnWindow arentRef) + { + System.IntPtr arentRef_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + arentRef_ = SharpGen.Runtime.CppObject.ToCallbackPtr(arentRef); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)arentRef_, (*(void ***)this._nativePointer)[31]); + System.GC.KeepAlive(arentRef); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindow::SetCanResize([In] bool value) + /// IAvnWindow::SetCanResize + internal unsafe void SetCanResize(System.Boolean value) + { + System.Byte value_; + SharpGen.Runtime.Result __result__; + value_ = (System.Byte)(value ? 1 : 0); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, value_, (*(void ***)this._nativePointer)[32]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindow::SetDecorations([In] SystemDecorations value) + /// IAvnWindow::SetDecorations + internal unsafe void SetDecorations(Avalonia.Native.Interop.SystemDecorations value) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, unchecked ((System.Int32)value), (*(void ***)this._nativePointer)[33]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindow::SetTitle([In] void* utf8Title) + /// IAvnWindow::SetTitle + internal unsafe void SetTitle(System.IntPtr utf8Title) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)utf8Title, (*(void ***)this._nativePointer)[34]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindow::SetTitleBarColor([In] AvnColor color) + /// IAvnWindow::SetTitleBarColor + internal unsafe void SetTitleBarColor(Avalonia.Native.Interop.AvnColor color) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, color, (*(void ***)this._nativePointer)[35]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindow::SetWindowState([In] AvnWindowState state) + /// IAvnWindow::SetWindowState + public unsafe void SetWindowState(Avalonia.Native.Interop.AvnWindowState state) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, unchecked ((System.Int32)state), (*(void ***)this._nativePointer)[36]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnWindow::GetWindowState([In] AvnWindowState* ret) + /// IAvnWindow::GetWindowState + public unsafe Avalonia.Native.Interop.AvnWindowState GetWindowState() + { + Avalonia.Native.Interop.AvnWindowState ret; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[37]); + __result__.CheckError(); + return ret; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnWindow::TakeFocusFromChildren() + /// IAvnWindow::TakeFocusFromChildren + public unsafe void TakeFocusFromChildren() + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[38]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindow::SetExtendClientArea([In] bool enable) + /// IAvnWindow::SetExtendClientArea + internal unsafe void SetExtendClientArea(System.Boolean enable) + { + System.Byte enable_; + SharpGen.Runtime.Result __result__; + enable_ = (System.Byte)(enable ? 1 : 0); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, enable_, (*(void ***)this._nativePointer)[39]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindow::SetExtendClientAreaHints([In] AvnExtendClientAreaChromeHints hints) + /// IAvnWindow::SetExtendClientAreaHints + internal unsafe void SetExtendClientAreaHints(Avalonia.Native.Interop.AvnExtendClientAreaChromeHints hints) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, unchecked ((System.Int32)hints), (*(void ***)this._nativePointer)[40]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnWindow::GetExtendTitleBarHeight([In] double* ret) + /// IAvnWindow::GetExtendTitleBarHeight + public unsafe System.Double GetExtendTitleBarHeight() + { + System.Double ret; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[41]); + __result__.CheckError(); + return ret; + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindow::SetExtendTitleBarHeight([In] double value) + /// IAvnWindow::SetExtendTitleBarHeight + public unsafe void SetExtendTitleBarHeight(System.Double value) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, value, (*(void ***)this._nativePointer)[42]); + __result__.CheckError(); + } + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f02")] + public partial class IAvnWindowBase : SharpGen.Runtime.ComObject + { + public IAvnWindowBase(System.IntPtr nativePtr): base (nativePtr) + { + } + + public static explicit operator IAvnWindowBase(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnWindowBase(nativePtr); + /// + /// No documentation. + /// + /// SetTopMost + /// SetTopMost + public System.Boolean TopMost + { + set => SetTopMost(value); + } + + /// + /// No documentation. + /// + /// SetCursor + /// SetCursor + public Avalonia.Native.Interop.IAvnCursor Cursor + { + set => SetCursor(value); + } + + /// + /// No documentation. + /// + /// SetMainMenu + /// SetMainMenu + public Avalonia.Native.Interop.IAvnMenu MainMenu + { + set => SetMainMenu(value); + } + + /// + /// No documentation. + /// + /// SetBlurEnabled + /// SetBlurEnabled + public System.Boolean BlurEnabled + { + set => SetBlurEnabled(value); + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnWindowBase::Show() + /// IAvnWindowBase::Show + public unsafe void Show() + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[3]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnWindowBase::Hide() + /// IAvnWindowBase::Hide + public unsafe void Hide() + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[4]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnWindowBase::Close() + /// IAvnWindowBase::Close + public unsafe void Close() + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[5]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnWindowBase::Activate() + /// IAvnWindowBase::Activate + public unsafe void Activate() + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[6]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnWindowBase::GetClientSize([In] AvnSize* ret) + /// IAvnWindowBase::GetClientSize + public unsafe Avalonia.Native.Interop.AvnSize GetClientSize() + { + Avalonia.Native.Interop.AvnSize ret; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[7]); + __result__.CheckError(); + return ret; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnWindowBase::GetScaling([In] double* ret) + /// IAvnWindowBase::GetScaling + public unsafe System.Double GetScaling() + { + System.Double ret; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[8]); + __result__.CheckError(); + return ret; + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindowBase::SetMinMaxSize([In] AvnSize minSize,[In] AvnSize maxSize) + /// IAvnWindowBase::SetMinMaxSize + public unsafe void SetMinMaxSize(Avalonia.Native.Interop.AvnSize minSize, Avalonia.Native.Interop.AvnSize maxSize) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, minSize, maxSize, (*(void ***)this._nativePointer)[9]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindowBase::Resize([In] double width,[In] double height) + /// IAvnWindowBase::Resize + public unsafe void Resize(System.Double width, System.Double height) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, width, height, (*(void ***)this._nativePointer)[10]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindowBase::Invalidate([In] AvnRect rect) + /// IAvnWindowBase::Invalidate + public unsafe void Invalidate(Avalonia.Native.Interop.AvnRect rect) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, rect, (*(void ***)this._nativePointer)[11]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnWindowBase::BeginMoveDrag() + /// IAvnWindowBase::BeginMoveDrag + public unsafe void BeginMoveDrag() + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[12]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindowBase::BeginResizeDrag([In] AvnWindowEdge edge) + /// IAvnWindowBase::BeginResizeDrag + public unsafe void BeginResizeDrag(Avalonia.Native.Interop.AvnWindowEdge edge) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, unchecked ((System.Int32)edge), (*(void ***)this._nativePointer)[13]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnWindowBase::GetPosition([In] AvnPoint* ret) + /// IAvnWindowBase::GetPosition + public unsafe Avalonia.Native.Interop.AvnPoint GetPosition() + { + Avalonia.Native.Interop.AvnPoint ret; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[14]); + __result__.CheckError(); + return ret; + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindowBase::SetPosition([In] AvnPoint point) + /// IAvnWindowBase::SetPosition + public unsafe void SetPosition(Avalonia.Native.Interop.AvnPoint point) + { + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, point, (*(void ***)this._nativePointer)[15]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindowBase::PointToClient([In] AvnPoint point,[In] AvnPoint* ret) + /// IAvnWindowBase::PointToClient + public unsafe Avalonia.Native.Interop.AvnPoint PointToClient(Avalonia.Native.Interop.AvnPoint point) + { + Avalonia.Native.Interop.AvnPoint ret; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, point, &ret, (*(void ***)this._nativePointer)[16]); + __result__.CheckError(); + return ret; + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindowBase::PointToScreen([In] AvnPoint point,[In] AvnPoint* ret) + /// IAvnWindowBase::PointToScreen + public unsafe Avalonia.Native.Interop.AvnPoint PointToScreen(Avalonia.Native.Interop.AvnPoint point) + { + Avalonia.Native.Interop.AvnPoint ret; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, point, &ret, (*(void ***)this._nativePointer)[17]); + __result__.CheckError(); + return ret; + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindowBase::ThreadSafeSetSwRenderedFrame([In] AvnFramebuffer* fb,[In] IUnknown* dispose) + /// IAvnWindowBase::ThreadSafeSetSwRenderedFrame + public unsafe void ThreadSafeSetSwRenderedFrame(ref Avalonia.Native.Interop.AvnFramebuffer fb, SharpGen.Runtime.IUnknown dispose) + { + System.IntPtr dispose_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + dispose_ = SharpGen.Runtime.CppObject.ToCallbackPtr(dispose); + fixed (void *fb_ = &fb) + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, fb_, (void *)dispose_, (*(void ***)this._nativePointer)[18]); + System.GC.KeepAlive(dispose); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindowBase::SetTopMost([In] bool value) + /// IAvnWindowBase::SetTopMost + internal unsafe void SetTopMost(System.Boolean value) + { + System.Byte value_; + SharpGen.Runtime.Result __result__; + value_ = (System.Byte)(value ? 1 : 0); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, value_, (*(void ***)this._nativePointer)[19]); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindowBase::SetCursor([In] IAvnCursor* cursor) + /// IAvnWindowBase::SetCursor + internal unsafe void SetCursor(Avalonia.Native.Interop.IAvnCursor cursor) + { + System.IntPtr cursor_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + cursor_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cursor); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)cursor_, (*(void ***)this._nativePointer)[20]); + System.GC.KeepAlive(cursor); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnWindowBase::CreateGlRenderTarget([In] IAvnGlSurfaceRenderTarget** ret) + /// IAvnWindowBase::CreateGlRenderTarget + public unsafe Avalonia.Native.Interop.IAvnGlSurfaceRenderTarget CreateGlRenderTarget() + { + Avalonia.Native.Interop.IAvnGlSurfaceRenderTarget ret; + System.IntPtr ret_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret_, (*(void ***)this._nativePointer)[21]); + if (ret_ != System.IntPtr.Zero) + ret = new Avalonia.Native.Interop.IAvnGlSurfaceRenderTarget(ret_); + else + ret = null; + __result__.CheckError(); + return ret; + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindowBase::SetMainMenu([In] IAvnMenu* menu) + /// IAvnWindowBase::SetMainMenu + internal unsafe void SetMainMenu(Avalonia.Native.Interop.IAvnMenu menu) + { + System.IntPtr menu_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + menu_ = SharpGen.Runtime.CppObject.ToCallbackPtr(menu); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)menu_, (*(void ***)this._nativePointer)[22]); + System.GC.KeepAlive(menu); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnWindowBase::ObtainNSWindowHandle([Out] void** retOut) + /// IAvnWindowBase::ObtainNSWindowHandle + public unsafe System.IntPtr ObtainNSWindowHandle() + { + System.IntPtr retOut; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &retOut, (*(void ***)this._nativePointer)[23]); + __result__.CheckError(); + return retOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnWindowBase::ObtainNSWindowHandleRetained([Out] void** retOut) + /// IAvnWindowBase::ObtainNSWindowHandleRetained + public unsafe System.IntPtr ObtainNSWindowHandleRetained() + { + System.IntPtr retOut; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &retOut, (*(void ***)this._nativePointer)[24]); + __result__.CheckError(); + return retOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnWindowBase::ObtainNSViewHandle([Out] void** retOut) + /// IAvnWindowBase::ObtainNSViewHandle + public unsafe System.IntPtr ObtainNSViewHandle() + { + System.IntPtr retOut; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &retOut, (*(void ***)this._nativePointer)[25]); + __result__.CheckError(); + return retOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnWindowBase::ObtainNSViewHandleRetained([Out] void** retOut) + /// IAvnWindowBase::ObtainNSViewHandleRetained + public unsafe System.IntPtr ObtainNSViewHandleRetained() + { + System.IntPtr retOut; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &retOut, (*(void ***)this._nativePointer)[26]); + __result__.CheckError(); + return retOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// HRESULT IAvnWindowBase::CreateNativeControlHost([Out] IAvnNativeControlHost** retOut) + /// IAvnWindowBase::CreateNativeControlHost + public unsafe Avalonia.Native.Interop.IAvnNativeControlHost CreateNativeControlHost() + { + Avalonia.Native.Interop.IAvnNativeControlHost retOut; + System.IntPtr retOut_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &retOut_, (*(void ***)this._nativePointer)[27]); + if (retOut_ != System.IntPtr.Zero) + retOut = new Avalonia.Native.Interop.IAvnNativeControlHost(retOut_); + else + retOut = null; + __result__.CheckError(); + return retOut; + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// No documentation. + /// No documentation. + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindowBase::BeginDragAndDropOperation([In] AvnDragDropEffects effects,[In] AvnPoint point,[In] IAvnClipboard* clipboard,[In] IAvnDndResultCallback* cb,[In] void* sourceHandle) + /// IAvnWindowBase::BeginDragAndDropOperation + public unsafe void BeginDragAndDropOperation(Avalonia.Native.Interop.AvnDragDropEffects effects, Avalonia.Native.Interop.AvnPoint point, Avalonia.Native.Interop.IAvnClipboard clipboard, Avalonia.Native.Interop.IAvnDndResultCallback cb, System.IntPtr sourceHandle) + { + System.IntPtr clipboard_ = System.IntPtr.Zero; + System.IntPtr cb_ = System.IntPtr.Zero; + SharpGen.Runtime.Result __result__; + clipboard_ = SharpGen.Runtime.CppObject.ToCallbackPtr(clipboard); + cb_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cb); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, unchecked ((System.Int32)effects), point, (void *)clipboard_, (void *)cb_, (void *)sourceHandle, (*(void ***)this._nativePointer)[28]); + System.GC.KeepAlive(clipboard); + System.GC.KeepAlive(cb); + __result__.CheckError(); + } + + /// + /// No documentation. + /// + /// No documentation. + /// No documentation. + /// HRESULT IAvnWindowBase::SetBlurEnabled([In] bool enable) + /// IAvnWindowBase::SetBlurEnabled + internal unsafe void SetBlurEnabled(System.Boolean enable) + { + System.Byte enable_; + SharpGen.Runtime.Result __result__; + enable_ = (System.Byte)(enable ? 1 : 0); + __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, enable_, (*(void ***)this._nativePointer)[29]); + __result__.CheckError(); + } + } + + class IAvnWindowBaseEventsShadow : SharpGen.Runtime.ComObjectShadow + { + protected unsafe class IAvnWindowBaseEventsVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl + { + public IAvnWindowBaseEventsVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 13) + { + AddMethod(new PaintDelegate(Paint)); + AddMethod(new ClosedDelegate(Closed)); + AddMethod(new ActivatedDelegate(Activated)); + AddMethod(new DeactivatedDelegate(Deactivated)); + AddMethod(new ResizedDelegate(Resized)); + AddMethod(new PositionChangedDelegate(PositionChanged)); + AddMethod(new RawMouseEventDelegate(RawMouseEvent)); + AddMethod(new RawKeyEventDelegate(RawKeyEvent)); + AddMethod(new RawTextInputEventDelegate(RawTextInputEvent)); + AddMethod(new ScalingChangedDelegate(ScalingChanged)); + AddMethod(new RunRenderPriorityJobsDelegate(RunRenderPriorityJobs)); + AddMethod(new LostFocusDelegate(LostFocus)); + AddMethod(new DragEventDelegate(DragEvent)); + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate int PaintDelegate(System.IntPtr thisObject); + private static unsafe int Paint(System.IntPtr thisObject) + { + try + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + @this.Paint(); + return SharpGen.Runtime.Result.Ok.Code; + } + catch (System.Exception __exception__) + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + return SharpGen.Runtime.Result.GetResultFromException(__exception__).Code; + } + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate void ClosedDelegate(System.IntPtr thisObject); + private static unsafe void Closed(System.IntPtr thisObject) + { + try + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + @this.Closed(); + } + catch (System.Exception __exception__) + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + } + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate void ActivatedDelegate(System.IntPtr thisObject); + private static unsafe void Activated(System.IntPtr thisObject) + { + try + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + @this.Activated(); + } + catch (System.Exception __exception__) + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + } + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate void DeactivatedDelegate(System.IntPtr thisObject); + private static unsafe void Deactivated(System.IntPtr thisObject) + { + try + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + @this.Deactivated(); + } + catch (System.Exception __exception__) + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + } + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate void ResizedDelegate(System.IntPtr thisObject, void *arg0); + private static unsafe void Resized(System.IntPtr thisObject, void *param0) + { + try + { + Avalonia.Native.Interop.AvnSize size = System.Runtime.CompilerServices.Unsafe.AsRef(param0); + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + @this.Resized(size); + } + catch (System.Exception __exception__) + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + } + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate void PositionChangedDelegate(System.IntPtr thisObject, Avalonia.Native.Interop.AvnPoint arg0); + private static unsafe void PositionChanged(System.IntPtr thisObject, Avalonia.Native.Interop.AvnPoint param0) + { + try + { + Avalonia.Native.Interop.AvnPoint position = default (Avalonia.Native.Interop.AvnPoint); + position = (Avalonia.Native.Interop.AvnPoint)param0; + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + @this.PositionChanged(position); + } + catch (System.Exception __exception__) + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + } + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate void RawMouseEventDelegate(System.IntPtr thisObject, int arg0, System.UInt32 arg1, int arg2, Avalonia.Native.Interop.AvnPoint arg3, Avalonia.Native.Interop.AvnVector arg4); + private static unsafe void RawMouseEvent(System.IntPtr thisObject, int param0, System.UInt32 param1, int param2, Avalonia.Native.Interop.AvnPoint param3, Avalonia.Native.Interop.AvnVector param4) + { + try + { + Avalonia.Native.Interop.AvnRawMouseEventType type = default (Avalonia.Native.Interop.AvnRawMouseEventType); + type = (Avalonia.Native.Interop.AvnRawMouseEventType)param0; + System.UInt32 timeStamp = default (System.UInt32); + timeStamp = (System.UInt32)param1; + Avalonia.Native.Interop.AvnInputModifiers modifiers = default (Avalonia.Native.Interop.AvnInputModifiers); + modifiers = (Avalonia.Native.Interop.AvnInputModifiers)param2; + Avalonia.Native.Interop.AvnPoint point = default (Avalonia.Native.Interop.AvnPoint); + point = (Avalonia.Native.Interop.AvnPoint)param3; + Avalonia.Native.Interop.AvnVector delta = default (Avalonia.Native.Interop.AvnVector); + delta = (Avalonia.Native.Interop.AvnVector)param4; + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + @this.RawMouseEvent(type, timeStamp, modifiers, point, delta); + } + catch (System.Exception __exception__) + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + } + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate System.Byte RawKeyEventDelegate(System.IntPtr thisObject, int arg0, System.UInt32 arg1, int arg2, System.UInt32 arg3); + private static unsafe System.Byte RawKeyEvent(System.IntPtr thisObject, int param0, System.UInt32 param1, int param2, System.UInt32 param3) + { + try + { + System.Boolean __result__ = default (System.Boolean); + System.Byte __result__native; + Avalonia.Native.Interop.AvnRawKeyEventType type = default (Avalonia.Native.Interop.AvnRawKeyEventType); + type = (Avalonia.Native.Interop.AvnRawKeyEventType)param0; + System.UInt32 timeStamp = default (System.UInt32); + timeStamp = (System.UInt32)param1; + Avalonia.Native.Interop.AvnInputModifiers modifiers = default (Avalonia.Native.Interop.AvnInputModifiers); + modifiers = (Avalonia.Native.Interop.AvnInputModifiers)param2; + System.UInt32 key = default (System.UInt32); + key = (System.UInt32)param3; + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + __result__ = @this.RawKeyEvent(type, timeStamp, modifiers, key); + __result__native = (System.Byte)(__result__ ? 1 : 0); + return __result__native; + } + catch (System.Exception __exception__) + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + return default (System.Byte); + } + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate System.Byte RawTextInputEventDelegate(System.IntPtr thisObject, System.UInt32 arg0, void *arg1); + private static unsafe System.Byte RawTextInputEvent(System.IntPtr thisObject, System.UInt32 param0, void *param1) + { + try + { + System.Boolean __result__ = default (System.Boolean); + System.Byte __result__native; + System.UInt32 timeStamp = default (System.UInt32); + timeStamp = (System.UInt32)param0; + System.String text = default (System.String); + System.IntPtr text_ = (System.IntPtr)param1; + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + text = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(text_); + __result__ = @this.RawTextInputEvent(timeStamp, text); + __result__native = (System.Byte)(__result__ ? 1 : 0); + return __result__native; + } + catch (System.Exception __exception__) + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + return default (System.Byte); + } + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate void ScalingChangedDelegate(System.IntPtr thisObject, double arg0); + private static unsafe void ScalingChanged(System.IntPtr thisObject, double param0) + { + try + { + System.Double scaling = default (System.Double); + scaling = (System.Double)param0; + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + @this.ScalingChanged(scaling); + } + catch (System.Exception __exception__) + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + } + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate void RunRenderPriorityJobsDelegate(System.IntPtr thisObject); + private static unsafe void RunRenderPriorityJobs(System.IntPtr thisObject) + { + try + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + @this.RunRenderPriorityJobs(); + } + catch (System.Exception __exception__) + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + } + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate void LostFocusDelegate(System.IntPtr thisObject); + private static unsafe void LostFocus(System.IntPtr thisObject) + { + try + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + @this.LostFocus(); + } + catch (System.Exception __exception__) + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + } + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate Avalonia.Native.Interop.AvnDragDropEffects DragEventDelegate(System.IntPtr thisObject, int arg0, Avalonia.Native.Interop.AvnPoint arg1, int arg2, int arg3, void *arg4, void *arg5); + private static unsafe Avalonia.Native.Interop.AvnDragDropEffects DragEvent(System.IntPtr thisObject, int param0, Avalonia.Native.Interop.AvnPoint param1, int param2, int param3, void *param4, void *param5) + { + try + { + Avalonia.Native.Interop.AvnDragDropEffects __result__ = default (Avalonia.Native.Interop.AvnDragDropEffects); + Avalonia.Native.Interop.AvnDragEventType type = default (Avalonia.Native.Interop.AvnDragEventType); + type = (Avalonia.Native.Interop.AvnDragEventType)param0; + Avalonia.Native.Interop.AvnPoint position = default (Avalonia.Native.Interop.AvnPoint); + position = (Avalonia.Native.Interop.AvnPoint)param1; + Avalonia.Native.Interop.AvnInputModifiers modifiers = default (Avalonia.Native.Interop.AvnInputModifiers); + modifiers = (Avalonia.Native.Interop.AvnInputModifiers)param2; + Avalonia.Native.Interop.AvnDragDropEffects effects = default (Avalonia.Native.Interop.AvnDragDropEffects); + effects = (Avalonia.Native.Interop.AvnDragDropEffects)param3; + Avalonia.Native.Interop.IAvnClipboard clipboard = default (Avalonia.Native.Interop.IAvnClipboard); + System.IntPtr clipboard_ = (System.IntPtr)param4; + System.IntPtr dataObjectHandle = default (System.IntPtr); + dataObjectHandle = (System.IntPtr)param5; + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + if (clipboard_ != System.IntPtr.Zero) + clipboard = new Avalonia.Native.Interop.IAvnClipboard(clipboard_); + else + clipboard = null; + __result__ = @this.DragEvent(type, position, modifiers, effects, clipboard, dataObjectHandle); + return __result__; + } + catch (System.Exception __exception__) + { + IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + return default (Avalonia.Native.Interop.AvnDragDropEffects); + } + } + } + + protected override SharpGen.Runtime.CppObjectVtbl Vtbl + { + get; + } + + = new Avalonia.Native.Interop.IAvnWindowBaseEventsShadow.IAvnWindowBaseEventsVtbl(0); + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f05"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnWindowBaseEventsShadow))] + public partial interface IAvnWindowBaseEvents : SharpGen.Runtime.IUnknown + { + void Paint(); + void Closed(); + void Activated(); + void Deactivated(); + void Resized(Avalonia.Native.Interop.AvnSize size); + void PositionChanged(Avalonia.Native.Interop.AvnPoint position); + void RawMouseEvent(Avalonia.Native.Interop.AvnRawMouseEventType type, System.UInt32 timeStamp, Avalonia.Native.Interop.AvnInputModifiers modifiers, Avalonia.Native.Interop.AvnPoint point, Avalonia.Native.Interop.AvnVector delta); + System.Boolean RawKeyEvent(Avalonia.Native.Interop.AvnRawKeyEventType type, System.UInt32 timeStamp, Avalonia.Native.Interop.AvnInputModifiers modifiers, System.UInt32 key); + System.Boolean RawTextInputEvent(System.UInt32 timeStamp, System.String text); + void ScalingChanged(System.Double scaling); + void RunRenderPriorityJobs(); + void LostFocus(); + Avalonia.Native.Interop.AvnDragDropEffects DragEvent(Avalonia.Native.Interop.AvnDragEventType type, Avalonia.Native.Interop.AvnPoint position, Avalonia.Native.Interop.AvnInputModifiers modifiers, Avalonia.Native.Interop.AvnDragDropEffects effects, Avalonia.Native.Interop.IAvnClipboard clipboard, System.IntPtr dataObjectHandle); + } + + class IAvnWindowEventsShadow : Avalonia.Native.Interop.IAvnWindowBaseEventsShadow + { + protected unsafe class IAvnWindowEventsVtbl : Avalonia.Native.Interop.IAvnWindowBaseEventsShadow.IAvnWindowBaseEventsVtbl + { + public IAvnWindowEventsVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 3) + { + AddMethod(new ClosingDelegate(Closing)); + AddMethod(new WindowStateChangedDelegate(WindowStateChanged)); + AddMethod(new GotInputWhenDisabledDelegate(GotInputWhenDisabled)); + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate System.Byte ClosingDelegate(System.IntPtr thisObject); + private static unsafe System.Byte Closing(System.IntPtr thisObject) + { + try + { + System.Boolean __result__ = default (System.Boolean); + System.Byte __result__native; + IAvnWindowEvents @this = (IAvnWindowEvents)ToShadow(thisObject).Callback; + __result__ = @this.Closing(); + __result__native = (System.Byte)(__result__ ? 1 : 0); + return __result__native; + } + catch (System.Exception __exception__) + { + IAvnWindowEvents @this = (IAvnWindowEvents)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + return default (System.Byte); + } + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate void WindowStateChangedDelegate(System.IntPtr thisObject, int arg0); + private static unsafe void WindowStateChanged(System.IntPtr thisObject, int param0) + { + try + { + Avalonia.Native.Interop.AvnWindowState state = default (Avalonia.Native.Interop.AvnWindowState); + state = (Avalonia.Native.Interop.AvnWindowState)param0; + IAvnWindowEvents @this = (IAvnWindowEvents)ToShadow(thisObject).Callback; + @this.WindowStateChanged(state); + } + catch (System.Exception __exception__) + { + IAvnWindowEvents @this = (IAvnWindowEvents)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + } + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] + private delegate void GotInputWhenDisabledDelegate(System.IntPtr thisObject); + private static unsafe void GotInputWhenDisabled(System.IntPtr thisObject) + { + try + { + IAvnWindowEvents @this = (IAvnWindowEvents)ToShadow(thisObject).Callback; + @this.GotInputWhenDisabled(); + } + catch (System.Exception __exception__) + { + IAvnWindowEvents @this = (IAvnWindowEvents)ToShadow(thisObject).Callback; + (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); + } + } + } + + protected override SharpGen.Runtime.CppObjectVtbl Vtbl + { + get; + } + + = new Avalonia.Native.Interop.IAvnWindowEventsShadow.IAvnWindowEventsVtbl(0); + } + + [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f06"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnWindowEventsShadow))] + public partial interface IAvnWindowEvents : Avalonia.Native.Interop.IAvnWindowBaseEvents + { + System.Boolean Closing(); + void WindowStateChanged(Avalonia.Native.Interop.AvnWindowState state); + void GotInputWhenDisabled(); + } +} \ No newline at end of file diff --git a/src/Avalonia.Native/Generated/LocalInterop.cs b/src/Avalonia.Native/Generated/LocalInterop.cs new file mode 100644 index 0000000000..41e69a6bdc --- /dev/null +++ b/src/Avalonia.Native/Generated/LocalInterop.cs @@ -0,0 +1,202 @@ +// + +namespace Avalonia.Native +{ + internal static partial class LocalInterop + { + public static unsafe int CalliThisCallint(void *thisObject, void *methodPtr) + { + throw null; + } + + public static unsafe void CalliThisCallvoid(void *thisObject, void *methodPtr) + { + throw null; + } + + public static unsafe void CalliThisCallvoid(void *thisObject, void *param0, void *methodPtr) + { + throw null; + } + + public static unsafe void CalliThisCallvoid0(void *thisObject, Avalonia.Native.Interop.AvnPoint param0, void *methodPtr) + { + throw null; + } + + public static unsafe void CalliThisCallvoid0(void *thisObject, int param0, System.UInt32 param1, int param2, Avalonia.Native.Interop.AvnPoint param3, Avalonia.Native.Interop.AvnVector param4, void *methodPtr) + { + throw null; + } + + public static unsafe System.Byte CalliThisCallSystemByte(void *thisObject, int param0, System.UInt32 param1, int param2, System.UInt32 param3, void *methodPtr) + { + throw null; + } + + public static unsafe System.Byte CalliThisCallSystemByte(void *thisObject, System.UInt32 param0, void *param1, void *methodPtr) + { + throw null; + } + + public static unsafe void CalliThisCallvoid(void *thisObject, double param0, void *methodPtr) + { + throw null; + } + + public static unsafe Avalonia.Native.Interop.AvnDragDropEffects CalliThisCallAvaloniaNativeInteropAvnDragDropEffects0(void *thisObject, int param0, Avalonia.Native.Interop.AvnPoint param1, int param2, int param3, void *param4, void *param5, void *methodPtr) + { + throw null; + } + + public static unsafe System.Byte CalliThisCallSystemByte(void *thisObject, void *methodPtr) + { + throw null; + } + + public static unsafe void CalliThisCallvoid(void *thisObject, int param0, void *methodPtr) + { + throw null; + } + + public static unsafe int CalliThisCallint(void *thisObject, void *param0, void *methodPtr) + { + throw null; + } + + public static unsafe int CalliThisCallint0(void *thisObject, Avalonia.Native.Interop.AvnSize param0, Avalonia.Native.Interop.AvnSize param1, void *methodPtr) + { + throw null; + } + + public static unsafe int CalliThisCallint(void *thisObject, double param0, double param1, void *methodPtr) + { + throw null; + } + + public static unsafe int CalliThisCallint0(void *thisObject, Avalonia.Native.Interop.AvnRect param0, void *methodPtr) + { + throw null; + } + + public static unsafe int CalliThisCallint(void *thisObject, int param0, void *methodPtr) + { + throw null; + } + + public static unsafe int CalliThisCallint0(void *thisObject, Avalonia.Native.Interop.AvnPoint param0, void *methodPtr) + { + throw null; + } + + public static unsafe int CalliThisCallint0(void *thisObject, Avalonia.Native.Interop.AvnPoint param0, void *param1, void *methodPtr) + { + throw null; + } + + public static unsafe int CalliThisCallint(void *thisObject, void *param0, void *param1, void *methodPtr) + { + throw null; + } + + public static unsafe int CalliThisCallint(void *thisObject, System.Byte param0, void *methodPtr) + { + throw null; + } + + public static unsafe int CalliThisCallint0(void *thisObject, int param0, Avalonia.Native.Interop.AvnPoint param1, void *param2, void *param3, void *param4, void *methodPtr) + { + throw null; + } + + public static unsafe int CalliThisCallint0(void *thisObject, Avalonia.Native.Interop.AvnColor param0, void *methodPtr) + { + throw null; + } + + public static unsafe int CalliThisCallint(void *thisObject, double param0, void *methodPtr) + { + throw null; + } + + public static unsafe System.IntPtr CalliThisCallSystemIntPtr(void *thisObject, void *methodPtr) + { + throw null; + } + + public static unsafe System.IntPtr CalliThisCallSystemIntPtr(void *thisObject, int param0, int param1, void *param2, void *methodPtr) + { + throw null; + } + + public static unsafe void CalliThisCallvoid(void *thisObject, int param0, void *param1, void *methodPtr) + { + throw null; + } + + public static unsafe void CalliThisCallvoid(void *thisObject, void *param0, void *param1, void *param2, void *param3, void *methodPtr) + { + throw null; + } + + public static unsafe void CalliThisCallvoid(void *thisObject, void *param0, void *param1, System.Byte param2, void *param3, void *param4, void *param5, void *param6, void *methodPtr) + { + throw null; + } + + public static unsafe void CalliThisCallvoid(void *thisObject, void *param0, void *param1, void *param2, void *param3, void *param4, void *param5, void *methodPtr) + { + throw null; + } + + public static unsafe int CalliThisCallint(void *thisObject, int param0, void *param1, void *methodPtr) + { + throw null; + } + + public static unsafe int CalliThisCallint(void *thisObject, void *param0, void *param1, int param2, void *methodPtr) + { + throw null; + } + + public static unsafe System.IntPtr CalliThisCallSystemIntPtr(void *thisObject, void *param0, void *methodPtr) + { + throw null; + } + + public static unsafe int CalliThisCallint(void *thisObject, void *param0, int param1, void *methodPtr) + { + throw null; + } + + public static unsafe System.UInt32 CalliThisCallSystemUInt32(void *thisObject, void *methodPtr) + { + throw null; + } + + public static unsafe int CalliThisCallint(void *thisObject, System.UInt32 param0, void *param1, void *methodPtr) + { + throw null; + } + + public static unsafe void CalliThisCallvoid(void *thisObject, float param0, float param1, float param2, float param3, void *methodPtr) + { + throw null; + } + + public static unsafe void CalliThisCallvoid(void *thisObject, float param0, float param1, void *methodPtr) + { + throw null; + } + + public static unsafe int CalliThisCallint(void *thisObject, void *param0, void *param1, void *param2, void *methodPtr) + { + throw null; + } + + public static unsafe void CalliThisCallvoid(void *thisObject, int param0, System.Byte param1, void *methodPtr) + { + throw null; + } + } +} \ No newline at end of file diff --git a/src/Avalonia.Native/Generated/Structures.cs b/src/Avalonia.Native/Generated/Structures.cs new file mode 100644 index 0000000000..fc871a2516 --- /dev/null +++ b/src/Avalonia.Native/Generated/Structures.cs @@ -0,0 +1,246 @@ +// + +namespace Avalonia.Native.Interop +{ + /// + /// No documentation. + /// + /// AvnColor + /// AvnColor + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] + public partial struct AvnColor + { + /// + /// No documentation. + /// + /// Alpha + /// Alpha + public System.Byte Alpha; + /// + /// No documentation. + /// + /// Red + /// Red + public System.Byte Red; + /// + /// No documentation. + /// + /// Green + /// Green + public System.Byte Green; + /// + /// No documentation. + /// + /// Blue + /// Blue + public System.Byte Blue; + } + + /// + /// No documentation. + /// + /// AvnFramebuffer + /// AvnFramebuffer + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] + public partial struct AvnFramebuffer + { + /// + /// No documentation. + /// + /// Data + /// Data + public System.IntPtr Data; + /// + /// No documentation. + /// + /// Width + /// Width + public System.Int32 Width; + /// + /// No documentation. + /// + /// Height + /// Height + public System.Int32 Height; + /// + /// No documentation. + /// + /// Stride + /// Stride + public System.Int32 Stride; + /// + /// No documentation. + /// + /// Dpi + /// Dpi + public Avalonia.Native.Interop.AvnVector Dpi; + /// + /// No documentation. + /// + /// PixelFormat + /// PixelFormat + public Avalonia.Native.Interop.AvnPixelFormat PixelFormat; + } + + /// + /// No documentation. + /// + /// AvnPixelSize + /// AvnPixelSize + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] + public partial struct AvnPixelSize + { + /// + /// No documentation. + /// + /// Width + /// Width + public System.Int32 Width; + /// + /// No documentation. + /// + /// Height + /// Height + public System.Int32 Height; + } + + /// + /// No documentation. + /// + /// AvnPoint + /// AvnPoint + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] + public partial struct AvnPoint + { + /// + /// No documentation. + /// + /// X + /// X + public System.Double X; + /// + /// No documentation. + /// + /// Y + /// Y + public System.Double Y; + } + + /// + /// No documentation. + /// + /// AvnRect + /// AvnRect + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] + public partial struct AvnRect + { + /// + /// No documentation. + /// + /// X + /// X + public System.Double X; + /// + /// No documentation. + /// + /// Y + /// Y + public System.Double Y; + /// + /// No documentation. + /// + /// Width + /// Width + public System.Double Width; + /// + /// No documentation. + /// + /// Height + /// Height + public System.Double Height; + } + + /// + /// No documentation. + /// + /// AvnScreen + /// AvnScreen + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] + public partial struct AvnScreen + { + /// + /// No documentation. + /// + /// Bounds + /// Bounds + public Avalonia.Native.Interop.AvnRect Bounds; + /// + /// No documentation. + /// + /// WorkingArea + /// WorkingArea + public Avalonia.Native.Interop.AvnRect WorkingArea; + /// + /// No documentation. + /// + /// PixelDensity + /// PixelDensity + public System.Single PixelDensity; + /// + /// No documentation. + /// + /// Primary + /// Primary + public bool Primary + { + get => 0 != _Primary; + set => _Primary = (System.Byte)(value ? 1 : 0); + } + + internal System.Byte _Primary; + } + + /// + /// No documentation. + /// + /// AvnSize + /// AvnSize + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] + public partial struct AvnSize + { + /// + /// No documentation. + /// + /// Width + /// Width + public System.Double Width; + /// + /// No documentation. + /// + /// Height + /// Height + public System.Double Height; + } + + /// + /// No documentation. + /// + /// AvnVector + /// AvnVector + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] + public partial struct AvnVector + { + /// + /// No documentation. + /// + /// X + /// X + public System.Double X; + /// + /// No documentation. + /// + /// Y + /// Y + public System.Double Y; + } +} \ No newline at end of file From df19b1c1274a3c7cf3160a29e55cdaba5fde5a65 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sun, 16 Aug 2020 22:07:50 +0100 Subject: [PATCH 021/751] change api stability to preview3. --- build/ApiDiff.props | 2 +- src/Avalonia.Base/ApiCompatBaseline.txt | 6 ------ src/Avalonia.Controls/ApiCompatBaseline.txt | 7 ------- src/Avalonia.Visuals/ApiCompatBaseline.txt | 14 -------------- 4 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 src/Avalonia.Base/ApiCompatBaseline.txt delete mode 100644 src/Avalonia.Controls/ApiCompatBaseline.txt delete mode 100644 src/Avalonia.Visuals/ApiCompatBaseline.txt diff --git a/build/ApiDiff.props b/build/ApiDiff.props index 1573dc2dd6..da82fbcc51 100644 --- a/build/ApiDiff.props +++ b/build/ApiDiff.props @@ -1,6 +1,6 @@  - 0.10.0-preview2 + 0.10.0-preview3 $(PackageId) Avalonia diff --git a/src/Avalonia.Base/ApiCompatBaseline.txt b/src/Avalonia.Base/ApiCompatBaseline.txt deleted file mode 100644 index b0b7371cd7..0000000000 --- a/src/Avalonia.Base/ApiCompatBaseline.txt +++ /dev/null @@ -1,6 +0,0 @@ -Compat issues with assembly Avalonia.Base: -MembersMustExist : Member 'public void Avalonia.DirectProperty..ctor(System.String, System.Func, System.Action, Avalonia.DirectPropertyMetadata, System.Boolean)' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'protected void Avalonia.DirectPropertyBase..ctor(Avalonia.AvaloniaProperty, System.Type, Avalonia.PropertyMetadata, System.Boolean)' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'protected void Avalonia.DirectPropertyBase..ctor(System.String, System.Type, Avalonia.PropertyMetadata, System.Boolean)' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public System.Boolean Avalonia.DirectPropertyBase.IsDataValidationEnabled.get()' does not exist in the implementation but it does exist in the contract. -Total Issues: 4 diff --git a/src/Avalonia.Controls/ApiCompatBaseline.txt b/src/Avalonia.Controls/ApiCompatBaseline.txt deleted file mode 100644 index 0a2415a263..0000000000 --- a/src/Avalonia.Controls/ApiCompatBaseline.txt +++ /dev/null @@ -1,7 +0,0 @@ -Compat issues with assembly Avalonia.Controls: -MembersMustExist : Member 'protected void Avalonia.Controls.ComboBox.PopupClosedOverride(Avalonia.Controls.Primitives.PopupClosedEventArgs)' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public Avalonia.StyledProperty Avalonia.StyledProperty Avalonia.Controls.Primitives.Popup.StaysOpenProperty' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public void Avalonia.Controls.Primitives.Popup.add_Closed(System.EventHandler)' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public void Avalonia.Controls.Primitives.Popup.remove_Closed(System.EventHandler)' does not exist in the implementation but it does exist in the contract. -TypesMustExist : Type 'Avalonia.Controls.Primitives.PopupClosedEventArgs' does not exist in the implementation but it does exist in the contract. -Total Issues: 5 diff --git a/src/Avalonia.Visuals/ApiCompatBaseline.txt b/src/Avalonia.Visuals/ApiCompatBaseline.txt deleted file mode 100644 index 849e957a72..0000000000 --- a/src/Avalonia.Visuals/ApiCompatBaseline.txt +++ /dev/null @@ -1,14 +0,0 @@ -Compat issues with assembly Avalonia.Visuals: -EnumValuesMustMatch : Enum value 'Avalonia.Media.FontStyle Avalonia.Media.FontStyle.Italic' is (System.Int32)1 in the implementation but (System.Int32)2 in the contract. -EnumValuesMustMatch : Enum value 'Avalonia.Media.FontStyle Avalonia.Media.FontStyle.Oblique' is (System.Int32)2 in the implementation but (System.Int32)1 in the contract. -InterfacesShouldHaveSameMembers : Interface member 'public Avalonia.Platform.AlphaFormat Avalonia.Platform.IPlatformRenderInterface.DefaultAlphaFormat' is present in the implementation but not in the contract. -InterfacesShouldHaveSameMembers : Interface member 'public Avalonia.Platform.PixelFormat Avalonia.Platform.IPlatformRenderInterface.DefaultPixelFormat' is present in the implementation but not in the contract. -InterfacesShouldHaveSameMembers : Interface member 'public Avalonia.Platform.IWriteableBitmapImpl Avalonia.Platform.IPlatformRenderInterface.CreateWriteableBitmap(Avalonia.PixelSize, Avalonia.Vector, Avalonia.Platform.PixelFormat, Avalonia.Platform.AlphaFormat)' is present in the implementation but not in the contract. -InterfacesShouldHaveSameMembers : Interface member 'public Avalonia.Platform.IWriteableBitmapImpl Avalonia.Platform.IPlatformRenderInterface.CreateWriteableBitmap(Avalonia.PixelSize, Avalonia.Vector, System.Nullable)' is present in the contract but not in the implementation. -MembersMustExist : Member 'public Avalonia.Platform.IWriteableBitmapImpl Avalonia.Platform.IPlatformRenderInterface.CreateWriteableBitmap(Avalonia.PixelSize, Avalonia.Vector, System.Nullable)' does not exist in the implementation but it does exist in the contract. -InterfacesShouldHaveSameMembers : Interface member 'public Avalonia.Platform.AlphaFormat Avalonia.Platform.IPlatformRenderInterface.DefaultAlphaFormat.get()' is present in the implementation but not in the contract. -InterfacesShouldHaveSameMembers : Interface member 'public Avalonia.Platform.PixelFormat Avalonia.Platform.IPlatformRenderInterface.DefaultPixelFormat.get()' is present in the implementation but not in the contract. -InterfacesShouldHaveSameMembers : Interface member 'public Avalonia.Platform.IBitmapImpl Avalonia.Platform.IPlatformRenderInterface.LoadBitmap(Avalonia.Platform.PixelFormat, Avalonia.Platform.AlphaFormat, System.IntPtr, Avalonia.PixelSize, Avalonia.Vector, System.Int32)' is present in the implementation but not in the contract. -InterfacesShouldHaveSameMembers : Interface member 'public Avalonia.Platform.IBitmapImpl Avalonia.Platform.IPlatformRenderInterface.LoadBitmap(Avalonia.Platform.PixelFormat, System.IntPtr, Avalonia.PixelSize, Avalonia.Vector, System.Int32)' is present in the contract but not in the implementation. -MembersMustExist : Member 'public Avalonia.Platform.IBitmapImpl Avalonia.Platform.IPlatformRenderInterface.LoadBitmap(Avalonia.Platform.PixelFormat, System.IntPtr, Avalonia.PixelSize, Avalonia.Vector, System.Int32)' does not exist in the implementation but it does exist in the contract. -Total Issues: 12 From 1828acc05c139fc6e5a097a8f245eb85501fcbdc Mon Sep 17 00:00:00 2001 From: Arthur Date: Mon, 17 Aug 2020 01:33:59 +0300 Subject: [PATCH 022/751] Changing http links to https --- readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index c1bf5bbfde..ccdbbfb967 100644 --- a/readme.md +++ b/readme.md @@ -16,7 +16,7 @@ To see the status of some of our features, please see our [Roadmap](https://gith ## 🚀 Getting Started -The Avalonia [Visual Studio Extension](https://marketplace.visualstudio.com/items?itemName=AvaloniaTeam.AvaloniaforVisualStudio) contains project and control templates that will help you get started, or you can use the .NET Core CLI. For a starter guide see our [documentation](http://avaloniaui.net/docs/quickstart/create-new-project). +The Avalonia [Visual Studio Extension](https://marketplace.visualstudio.com/items?itemName=AvaloniaTeam.AvaloniaforVisualStudio) contains project and control templates that will help you get started, or you can use the .NET Core CLI. For a starter guide see our [documentation](https://avaloniaui.net/docs/quickstart/create-new-project). Avalonia is delivered via NuGet package manager. You can find the packages here: https://www.nuget.org/packages/Avalonia/ @@ -47,7 +47,7 @@ We also have a [nightly build](https://github.com/AvaloniaUI/Avalonia/wiki/Using ## Documentation -Documentation can be found on our website at http://avaloniaui.net/docs/. We also have a [tutorial](http://avaloniaui.net/docs/tutorial/) over there for newcomers. +Documentation can be found on our website at https://avaloniaui.net/docs/. We also have a [tutorial](https://avaloniaui.net/docs/tutorial/) over there for newcomers. ## Building and Using @@ -68,7 +68,7 @@ Avalonia is licenced under the [MIT licence](licence.md). ## Contributors -This project exists thanks to all the people who contribute. [[Contribute](http://avaloniaui.net/contributing)]. +This project exists thanks to all the people who contribute. [[Contribute](https://avaloniaui.net/contributing)]. ### Backers From c8d26de9489387f82ce66313db3651a093762c85 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 17 Aug 2020 16:05:20 +0100 Subject: [PATCH 023/751] Add failing unit test. --- .../TextBoxTests.cs | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/Avalonia.Controls.UnitTests/TextBoxTests.cs b/tests/Avalonia.Controls.UnitTests/TextBoxTests.cs index af3b68f4a0..7a409d494c 100644 --- a/tests/Avalonia.Controls.UnitTests/TextBoxTests.cs +++ b/tests/Avalonia.Controls.UnitTests/TextBoxTests.cs @@ -17,6 +17,46 @@ namespace Avalonia.Controls.UnitTests { public class TextBoxTests { + [Fact] + public void Opening_Context_Menu_Does_not_Loose_Selection() + { + using (UnitTestApplication.Start(FocusServices)) + { + var target1 = new TextBox + { + Template = CreateTemplate(), + Text = "1234", + ContextMenu = new TestContextMenu() + }; + + var target2 = new TextBox + { + Template = CreateTemplate(), + Text = "5678" + }; + + var sp = new StackPanel(); + sp.Children.Add(target1); + sp.Children.Add(target2); + + target1.ApplyTemplate(); + target2.ApplyTemplate(); + + var root = new TestRoot() { Child = sp }; + + target1.SelectionStart = 0; + target1.SelectionEnd = 3; + + target1.Focus(); + Assert.False(target2.IsFocused); + Assert.True(target1.IsFocused); + + target2.Focus(); + + Assert.Equal("123", target1.SelectedText); + } + } + [Fact] public void DefaultBindingMode_Should_Be_TwoWay() { @@ -694,5 +734,13 @@ namespace Avalonia.Controls.UnitTests public Task GetDataAsync(string format) => Task.FromResult((object)null); } + + private class TestContextMenu : ContextMenu + { + public TestContextMenu() + { + IsOpen = true; + } + } } } From 54cedcea877ea7f8026df77cc09070e11ba1734c Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 17 Aug 2020 16:06:07 +0100 Subject: [PATCH 024/751] dont allow text selection to be lost when context menu is opened... i.e. for copy and paste to work. --- src/Avalonia.Controls/ContextMenu.cs | 3 +-- src/Avalonia.Controls/TextBox.cs | 11 ++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Controls/ContextMenu.cs b/src/Avalonia.Controls/ContextMenu.cs index b4e4dd5071..9bb4cc4816 100644 --- a/src/Avalonia.Controls/ContextMenu.cs +++ b/src/Avalonia.Controls/ContextMenu.cs @@ -280,9 +280,8 @@ namespace Avalonia.Controls } _popup.Child = this; - _popup.IsOpen = true; - IsOpen = true; + _popup.IsOpen = true; RaiseEvent(new RoutedEventArgs { diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index 7e28d88581..4e742b3b7b 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -410,10 +410,15 @@ namespace Avalonia.Controls protected override void OnLostFocus(RoutedEventArgs e) { base.OnLostFocus(e); - SelectionStart = 0; - SelectionEnd = 0; + + if (ContextMenu == null || !ContextMenu.IsOpen) + { + SelectionStart = 0; + SelectionEnd = 0; + RevealPassword = false; + } + _presenter?.HideCaret(); - RevealPassword = false; } protected override void OnTextInput(TextInputEventArgs e) From 89bf711602f59b871dceafcce51bdff837f7fa37 Mon Sep 17 00:00:00 2001 From: danwalmsley Date: Mon, 17 Aug 2020 16:59:33 +0100 Subject: [PATCH 025/751] Lose not Loose! Co-authored-by: Steven Kirk --- tests/Avalonia.Controls.UnitTests/TextBoxTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Avalonia.Controls.UnitTests/TextBoxTests.cs b/tests/Avalonia.Controls.UnitTests/TextBoxTests.cs index 7a409d494c..f41938a9bb 100644 --- a/tests/Avalonia.Controls.UnitTests/TextBoxTests.cs +++ b/tests/Avalonia.Controls.UnitTests/TextBoxTests.cs @@ -18,7 +18,7 @@ namespace Avalonia.Controls.UnitTests public class TextBoxTests { [Fact] - public void Opening_Context_Menu_Does_not_Loose_Selection() + public void Opening_Context_Menu_Does_not_Lose_Selection() { using (UnitTestApplication.Start(FocusServices)) { From 9ff731ab701cc61d5e750ac2ed922b9c70c7ff8c Mon Sep 17 00:00:00 2001 From: Maksym Katsydan Date: Mon, 17 Aug 2020 19:39:55 -0400 Subject: [PATCH 026/751] Fix another missing resources on default theme (including #4376) --- src/Avalonia.Controls.DataGrid/Themes/Default.xaml | 10 +++++----- src/Avalonia.Themes.Default/SplitView.xaml | 2 +- src/Avalonia.Themes.Default/TimePicker.xaml | 2 +- src/Avalonia.Themes.Default/ToggleSwitch.xaml | 14 +++++++------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Avalonia.Controls.DataGrid/Themes/Default.xaml b/src/Avalonia.Controls.DataGrid/Themes/Default.xaml index 738732f671..1d4d88825f 100644 --- a/src/Avalonia.Controls.DataGrid/Themes/Default.xaml +++ b/src/Avalonia.Controls.DataGrid/Themes/Default.xaml @@ -28,7 +28,7 @@ - + @@ -188,7 +188,7 @@ + TextBox A control into which the user can input text - + - + - + - + - - - + + + - - resm fonts - - - - - - - - res fonts - - - - - + + resm fonts + + + + + + + + res fonts + + + + + diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index 86f66fa90d..7798c71377 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -1,3 +1,4 @@ +using System.Windows.Input; using Avalonia.Input.Platform; using System; using System.Collections.Generic; @@ -103,6 +104,21 @@ namespace Avalonia.Controls public static readonly StyledProperty RevealPasswordProperty = AvaloniaProperty.Register(nameof(RevealPassword)); + + public static readonly DirectProperty CanCutProperty = + AvaloniaProperty.RegisterDirect( + nameof(CanCut), + o => o.CanCut); + + public static readonly DirectProperty CanCopyProperty = + AvaloniaProperty.RegisterDirect( + nameof(CanCopy), + o => o.CanCopy); + + public static readonly DirectProperty CanPasteProperty = + AvaloniaProperty.RegisterDirect( + nameof(CanPaste), + o => o.CanPaste); struct UndoRedoState : IEquatable { @@ -126,6 +142,9 @@ namespace Avalonia.Controls private UndoRedoHelper _undoRedoHelper; private bool _isUndoingRedoing; private bool _ignoreTextChanges; + private bool _canCut; + private bool _canCopy; + private bool _canPaste; private string _newLine = Environment.NewLine; private static readonly string[] invalidCharacters = new String[1] { "\u007f" }; @@ -370,6 +389,33 @@ namespace Avalonia.Controls set { SetAndRaise(NewLineProperty, ref _newLine, value); } } + /// + /// Property for determining if the Cut command can be executed. + /// + public bool CanCut + { + get { return _canCut; } + private set { SetAndRaise(CanCutProperty, ref _canCut, value); } + } + + /// + /// Property for determining if the Copy command can be executed. + /// + public bool CanCopy + { + get { return _canCopy; } + private set { SetAndRaise(CanCopyProperty, ref _canCopy, value); } + } + + /// + /// Property for determining if the Paste command can be executed. + /// + public bool CanPaste + { + get { return _canPaste; } + private set { SetAndRaise(CanPasteProperty, ref _canPaste, value); } + } + protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { _presenter = e.NameScope.Get("PART_TextPresenter"); @@ -387,9 +433,19 @@ namespace Avalonia.Controls if (change.Property == TextProperty) { UpdatePseudoclasses(); + UpdateCommandStates(); } } + private void UpdateCommandStates() + { + var text = GetSelection(); + var b1 = string.IsNullOrEmpty(text); + CanCopy = !b1; + CanCut = !b1; + CanPaste = !IsReadOnly; + } + protected override void OnGotFocus(GotFocusEventArgs e) { base.OnGotFocus(e); @@ -404,6 +460,8 @@ namespace Avalonia.Controls SelectAll(); } + UpdateCommandStates(); + _presenter?.ShowCaret(); } @@ -418,6 +476,8 @@ namespace Avalonia.Controls RevealPassword = false; } + UpdateCommandStates(); + _presenter?.HideCaret(); } @@ -462,6 +522,9 @@ namespace Avalonia.Controls public async void Cut() { + var text = GetSelection(); + if (text is null) return; + _undoRedoHelper.Snapshot(); Copy(); DeleteSelection(); @@ -470,17 +533,18 @@ namespace Avalonia.Controls public async void Copy() { + var text = GetSelection(); + if (text is null) return; + await ((IClipboard)AvaloniaLocator.Current.GetService(typeof(IClipboard))) - .SetTextAsync(GetSelection()); + .SetTextAsync(text); } public async void Paste() { var text = await ((IClipboard)AvaloniaLocator.Current.GetService(typeof(IClipboard))).GetTextAsync(); - if (text == null) - { - return; - } + + if (text is null) return; _undoRedoHelper.Snapshot(); HandleTextInput(text); From e93ac83ae43b9a2b88311cc11c8e2aa793b3eab5 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 18 Aug 2020 15:14:56 +0100 Subject: [PATCH 031/751] add gesture text. --- samples/ControlCatalog/Pages/TextBoxPage.xaml | 6 +++--- src/Avalonia.Controls/TextBox.cs | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/samples/ControlCatalog/Pages/TextBoxPage.xaml b/samples/ControlCatalog/Pages/TextBoxPage.xaml index 88094c70f3..5317e46e81 100644 --- a/samples/ControlCatalog/Pages/TextBoxPage.xaml +++ b/samples/ControlCatalog/Pages/TextBoxPage.xaml @@ -3,9 +3,9 @@ - - - + + + diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index 7798c71377..3b81b5b020 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -19,6 +19,15 @@ namespace Avalonia.Controls { public class TextBox : TemplatedControl, UndoRedoHelper.IUndoRedoHost { + public static KeyGesture CutGesture { get; } = + AvaloniaLocator.Current.GetService()?.Cut.FirstOrDefault(); + + public static KeyGesture CopyGesture { get; } = AvaloniaLocator.Current + .GetService()?.Copy.FirstOrDefault(); + + public static KeyGesture PasteGesture { get; } = AvaloniaLocator.Current + .GetService()?.Paste.FirstOrDefault(); + public static readonly StyledProperty AcceptsReturnProperty = AvaloniaProperty.Register(nameof(AcceptsReturn)); From 5ea8c57f760e755edd03d12f06c13bfda5f2f1f1 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 18 Aug 2020 15:15:22 +0100 Subject: [PATCH 032/751] move standard textbox context menu to the templates. --- samples/ControlCatalog/Pages/TextBoxPage.xaml | 12 ------------ src/Avalonia.Themes.Default/TextBox.xaml | 8 ++++++++ src/Avalonia.Themes.Fluent/TextBox.xaml | 7 +++++++ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/samples/ControlCatalog/Pages/TextBoxPage.xaml b/samples/ControlCatalog/Pages/TextBoxPage.xaml index 5317e46e81..df410c2116 100644 --- a/samples/ControlCatalog/Pages/TextBoxPage.xaml +++ b/samples/ControlCatalog/Pages/TextBoxPage.xaml @@ -1,18 +1,6 @@ - - - - - - - - - - TextBox A control into which the user can input text diff --git a/src/Avalonia.Themes.Default/TextBox.xaml b/src/Avalonia.Themes.Default/TextBox.xaml index 8384cccada..e9d5857d67 100644 --- a/src/Avalonia.Themes.Default/TextBox.xaml +++ b/src/Avalonia.Themes.Default/TextBox.xaml @@ -1,4 +1,11 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From aa5bc078a7782908560865c3682cbd387acd7708 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 18 Aug 2020 14:59:22 -0700 Subject: [PATCH 037/751] Re-enable SharpGenTools.Sdk to patch calli but disable codegen (#4512) --- src/Avalonia.Native/Avalonia.Native.csproj | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Native/Avalonia.Native.csproj b/src/Avalonia.Native/Avalonia.Native.csproj index 9c3eaed2d8..f084411c2f 100644 --- a/src/Avalonia.Native/Avalonia.Native.csproj +++ b/src/Avalonia.Native/Avalonia.Native.csproj @@ -7,6 +7,7 @@ /usr/bin/castxml /usr/local/bin/castxml true + false @@ -18,8 +19,8 @@ - - + + From cd180770fbd46ff4f33721ed5ca81f477c72c0db Mon Sep 17 00:00:00 2001 From: Kiminuo Date: Wed, 19 Aug 2020 12:33:14 +0200 Subject: [PATCH 038/751] AppBuilderBase: Allow to specify app factory. --- src/Avalonia.Controls/AppBuilderBase.cs | 17 +++++++ .../AppBuilderTests.cs | 44 ++++++++++++++++++- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/AppBuilderBase.cs b/src/Avalonia.Controls/AppBuilderBase.cs index d69052ad3d..f616a42cac 100644 --- a/src/Avalonia.Controls/AppBuilderBase.cs +++ b/src/Avalonia.Controls/AppBuilderBase.cs @@ -88,6 +88,23 @@ namespace Avalonia.Controls }; } + /// + /// Begin configuring an . + /// + /// Factory function for . + /// The subclass of to configure. + /// is useful for passing of dependencies to . + /// An instance. + public static TAppBuilder Configure(Func appFactory) + where TApp : Application + { + return new TAppBuilder() + { + ApplicationType = typeof(TApp), + _appFactory = appFactory + }; + } + protected TAppBuilder Self => (TAppBuilder)this; public TAppBuilder AfterSetup(Action callback) diff --git a/tests/Avalonia.Controls.UnitTests/AppBuilderTests.cs b/tests/Avalonia.Controls.UnitTests/AppBuilderTests.cs index b5004bc6a5..06ec9158fe 100644 --- a/tests/Avalonia.Controls.UnitTests/AppBuilderTests.cs +++ b/tests/Avalonia.Controls.UnitTests/AppBuilderTests.cs @@ -1,4 +1,5 @@ -using Avalonia.Controls.UnitTests; +using System; +using Avalonia.Controls.UnitTests; using Avalonia.Platform; using Xunit; @@ -18,6 +19,22 @@ namespace Avalonia.Controls.UnitTests { } + public class AppWithDependencies : Application + { + public AppWithDependencies() + { + throw new NotSupportedException(); + } + + public AppWithDependencies(object dependencyA, object dependencyB) + { + DependencyA = dependencyA; + DependencyB = dependencyB; + } + public object DependencyA { get; } + public object DependencyB { get; } + } + public class DefaultModule { public static bool IsLoaded = false; @@ -53,7 +70,30 @@ namespace Avalonia.Controls.UnitTests IsLoaded = true; } } - + + [Fact] + public void UseAppFactory() + { + using (AvaloniaLocator.EnterScope()) + { + ResetModuleLoadStates(); + + Func appFactory = () => new AppWithDependencies(dependencyA: new object(), dependencyB: new object()); + + var builder = AppBuilder.Configure(appFactory) + .UseWindowingSubsystem(() => { }) + .UseRenderingSubsystem(() => { }) + .UseAvaloniaModules() + .SetupWithoutStarting(); + + AppWithDependencies app = (AppWithDependencies)builder.Instance; + Assert.NotNull(app.DependencyA); + Assert.NotNull(app.DependencyB); + + Assert.True(DefaultModule.IsLoaded); + } + } + [Fact] public void LoadsDefaultModule() { From 793f1b7453993255f544a9ae561187896ccc24ac Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Tue, 9 Jun 2020 17:44:05 +0200 Subject: [PATCH 039/751] Allow support at CanExecute when binding a method --- .../AlwaysEnabledDelegateCommand.cs | 41 ---- .../Data/Converters/DefaultValueConverter.cs | 2 +- .../Converters/MethodToCommandConverter.cs | 182 ++++++++++++++++++ .../Metadata/DependsOnAttribute.cs | 2 +- 4 files changed, 184 insertions(+), 43 deletions(-) delete mode 100644 src/Avalonia.Base/Data/Converters/AlwaysEnabledDelegateCommand.cs create mode 100644 src/Avalonia.Base/Data/Converters/MethodToCommandConverter.cs diff --git a/src/Avalonia.Base/Data/Converters/AlwaysEnabledDelegateCommand.cs b/src/Avalonia.Base/Data/Converters/AlwaysEnabledDelegateCommand.cs deleted file mode 100644 index 7f4c83772d..0000000000 --- a/src/Avalonia.Base/Data/Converters/AlwaysEnabledDelegateCommand.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Globalization; -using System.Reflection; -using System.Windows.Input; -using Avalonia.Utilities; - -namespace Avalonia.Data.Converters -{ - class AlwaysEnabledDelegateCommand : ICommand - { - private readonly Delegate action; - - private ParameterInfo parameterInfo; - - public AlwaysEnabledDelegateCommand(Delegate action) - { - this.action = action; - var parameters = action.Method.GetParameters(); - parameterInfo = parameters.Length == 0 ? null : parameters[0]; - } - -#pragma warning disable 0067 - public event EventHandler CanExecuteChanged; -#pragma warning restore 0067 - - public bool CanExecute(object parameter) => true; - - public void Execute(object parameter) - { - if (parameterInfo == null) - { - action.DynamicInvoke(); - } - else - { - TypeUtilities.TryConvert(parameterInfo.ParameterType, parameter, CultureInfo.CurrentCulture, out object convertedParameter); - action.DynamicInvoke(convertedParameter); - } - } - } -} diff --git a/src/Avalonia.Base/Data/Converters/DefaultValueConverter.cs b/src/Avalonia.Base/Data/Converters/DefaultValueConverter.cs index 5e80a15059..83f7e02c16 100644 --- a/src/Avalonia.Base/Data/Converters/DefaultValueConverter.cs +++ b/src/Avalonia.Base/Data/Converters/DefaultValueConverter.cs @@ -33,7 +33,7 @@ namespace Avalonia.Data.Converters if (typeof(ICommand).IsAssignableFrom(targetType) && value is Delegate d && d.Method.GetParameters().Length <= 1) { - return new AlwaysEnabledDelegateCommand(d); + return new MethodToCommandConverter(d); } if (TypeUtilities.TryConvert(targetType, value, culture, out object result)) diff --git a/src/Avalonia.Base/Data/Converters/MethodToCommandConverter.cs b/src/Avalonia.Base/Data/Converters/MethodToCommandConverter.cs new file mode 100644 index 0000000000..c638fe56e6 --- /dev/null +++ b/src/Avalonia.Base/Data/Converters/MethodToCommandConverter.cs @@ -0,0 +1,182 @@ +using System; +using System.Globalization; +using System.Linq; +using System.Linq.Expressions; +using System.Reflection; +using System.Windows.Input; +using Avalonia.Utilities; + +namespace Avalonia.Data.Converters +{ + class MethodToCommandConverter : ICommand + { + readonly static Func AlwaysEnabled = (_) => true; + readonly static MethodInfo tryConvert = typeof(TypeUtilities) + .GetMethod(nameof(TypeUtilities.TryConvert), BindingFlags.Public | BindingFlags.Static); + readonly static PropertyInfo currentCulture = typeof(CultureInfo) + .GetProperty(nameof(CultureInfo.CurrentCulture), BindingFlags.Public | BindingFlags.Static); + readonly Func canExecute; + readonly Action execute; + + public MethodToCommandConverter(Delegate action) + { + var target = action.Target; + var canExecuteMethodName = "Can" + action.Method.Name; + var parameters = action.Method.GetParameters(); + var parameterInfo = parameters.Length == 0 ? null : parameters[0].ParameterType; + + if (parameterInfo == null) + { + execute = CreateExecute(target, action.Method); + } + else + { + execute = CreateExecute(target, action.Method, parameterInfo); + } + + var canExecuteMethod = action.Method.DeclaringType.GetRuntimeMethods() + .FirstOrDefault(m => m.Name == canExecuteMethodName + && m.GetParameters().Length == 1 + && m.GetParameters()[0].ParameterType == typeof(object)); + if (canExecuteMethod == null) + { + canExecute = AlwaysEnabled; + } + else + { + canExecute = CreateCanExecute(target, canExecuteMethod); + var dependencyProperties = canExecuteMethod + .GetCustomAttributes(typeof(Metadata.DependsOnAttribute), true) + .OfType() + .Select(x => x.Name) + .ToArray(); + if (dependencyProperties.Any() + && target is System.ComponentModel.INotifyPropertyChanged inpc) + { + System.ComponentModel.PropertyChangedEventHandler invalidateCanExecuteHandler = (s, e) => + { + if (string.IsNullOrWhiteSpace(e.PropertyName) + || dependencyProperties.Contains(e.PropertyName)) + { + Threading.Dispatcher.UIThread.Post(() => CanExecuteChanged?.Invoke(this, EventArgs.Empty) + , Threading.DispatcherPriority.Input); + } + }; + inpc.PropertyChanged += invalidateCanExecuteHandler; + } + } + + + } + +#pragma warning disable 0067 + public event EventHandler CanExecuteChanged; +#pragma warning restore 0067 + + public bool CanExecute(object parameter) => canExecute(parameter); + + public void Execute(object parameter) => execute(parameter); + + + static Action CreateExecute(object target + , System.Reflection.MethodInfo method) + { + + var parameter = Expression.Parameter(typeof(object), "parameter"); + + var instance = Expression.Convert + ( + Expression.Constant(target), + method.DeclaringType + ); + + + var call = Expression.Call + ( + instance, + method + ); + + + return Expression + .Lambda>(call, parameter) + .Compile(); + } + + static Action CreateExecute(object target + , System.Reflection.MethodInfo method + , Type parameterType) + { + + var parameter = Expression.Parameter(typeof(object), "parameter"); + + var instance = Expression.Convert + ( + Expression.Constant(target), + method.DeclaringType + ); + + Expression body; + + if (parameterType == typeof(object)) + { + body = Expression.Call(instance, + method, + parameter + ); + } + else + { + var arg0 = Expression.Variable(typeof(object), "argX"); + var convertCall = Expression.Call(tryConvert, + Expression.Constant(parameterType), + parameter, + Expression.Property(null, currentCulture), + arg0 + ); + + var call = Expression.Call(instance, + method, + Expression.Convert(arg0, parameterType) + ); + body = Expression.Block(new[] { arg0 }, + convertCall, + call + ); + + } + Action action = null; + try + { + action = Expression + .Lambda>(body, parameter) + .Compile(); + } + catch (Exception ex) + { + throw ex; + } + return action; + } + + static Func CreateCanExecute(object target + , System.Reflection.MethodInfo method) + { + var parameter = Expression.Parameter(typeof(object), "parameter"); + var instance = Expression.Convert + ( + Expression.Constant(target), + method.DeclaringType + ); + var call = Expression.Call + ( + instance, + method, + parameter + ); + return Expression + .Lambda>(call, parameter) + .Compile(); + } + } +} diff --git a/src/Avalonia.Base/Metadata/DependsOnAttribute.cs b/src/Avalonia.Base/Metadata/DependsOnAttribute.cs index 92c6a58170..caee71ebfd 100644 --- a/src/Avalonia.Base/Metadata/DependsOnAttribute.cs +++ b/src/Avalonia.Base/Metadata/DependsOnAttribute.cs @@ -5,7 +5,7 @@ namespace Avalonia.Metadata /// /// Indicates that the property depends on the value of another property in markup. /// - [AttributeUsage(AttributeTargets.Property)] + [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method, Inherited = true, AllowMultiple = true)] public class DependsOnAttribute : Attribute { /// From 9f3ed1c8fe1de02fd8e98cb43ed5eb5c2575676a Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Tue, 9 Jun 2020 17:44:45 +0200 Subject: [PATCH 040/751] Add testing --- .../Data/BindingTests_Method.cs | 100 +++++++++++++++++- 1 file changed, 96 insertions(+), 4 deletions(-) diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests_Method.cs b/tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests_Method.cs index a7a004bd49..e1a7803821 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests_Method.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests_Method.cs @@ -1,5 +1,4 @@ -using System.Reactive.Subjects; -using System.Windows.Input; +using System.ComponentModel; using Avalonia.Controls; using Avalonia.Input; using Avalonia.UnitTests; @@ -56,7 +55,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.Data Assert.Equal("Called 5", vm.Value); } } - + [Fact] public void Binding_Method_To_TextBlock_Text_Works() { @@ -79,6 +78,68 @@ namespace Avalonia.Markup.Xaml.UnitTests.Data } } + + [Theory] + [InlineData(null, "Not called")] + [InlineData("A", "Do A")] + public void Binding_Method_With_Parameter_To_Command_CanExecute(object commandParameter, string result) + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + +