diff --git a/src/LogoFX.Client.Core.Platform.NETCore.Specs/LogoFX.Client.Core.Platform.NETCore.Specs.csproj b/src/LogoFX.Client.Core.Platform.NETCore.Specs/LogoFX.Client.Core.Platform.NETCore.Specs.csproj index 4d9f5ff..2b1ed78 100644 --- a/src/LogoFX.Client.Core.Platform.NETCore.Specs/LogoFX.Client.Core.Platform.NETCore.Specs.csproj +++ b/src/LogoFX.Client.Core.Platform.NETCore.Specs/LogoFX.Client.Core.Platform.NETCore.Specs.csproj @@ -6,14 +6,14 @@ true - - - + + + - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/LogoFX.Client.Core.Platform/android/Resources/Resource.Designer.cs b/src/LogoFX.Client.Core.Platform/android/Resources/Resource.Designer.cs index 42b5827..023023b 100644 --- a/src/LogoFX.Client.Core.Platform/android/Resources/Resource.Designer.cs +++ b/src/LogoFX.Client.Core.Platform/android/Resources/Resource.Designer.cs @@ -14,7 +14,7 @@ namespace LogoFX.Client.Core { - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "12.1.0.11")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "13.0.0.73")] public partial class Resource { diff --git a/src/LogoFX.Client.Core.Platform/src/CommonProperties.cs b/src/LogoFX.Client.Core.Platform/src/CommonProperties.cs index c1a6e50..4034b60 100644 --- a/src/LogoFX.Client.Core.Platform/src/CommonProperties.cs +++ b/src/LogoFX.Client.Core.Platform/src/CommonProperties.cs @@ -1,4 +1,7 @@ -#if NET || NETCORE +using System.Diagnostics.CodeAnalysis; +#if WINUI3 +using Microsoft.UI.Xaml; +#else using System.Windows; #endif @@ -14,26 +17,28 @@ public class CommonProperties /// /// /// - public static DependencyObject GetOwner(DependencyObject obj) - { - return (DependencyObject)obj.GetValue(OwnerProperty); - } + [SuppressMessage("ReSharper", "UnusedMember.Global")] + public static DependencyObject GetOwner(DependencyObject obj) + => (DependencyObject)obj.GetValue(OwnerProperty); /// /// Sets the owner value /// /// /// - public static void SetOwner(DependencyObject obj, DependencyObject value) - { - obj.SetValue(OwnerProperty, value); - } - + [SuppressMessage("ReSharper", "UnusedMember.Global")] + public static void SetOwner(DependencyObject obj, DependencyObject value) + => obj.SetValue(OwnerProperty, value); + // Using a DependencyProperty as the backing store for Owner. This enables animation, styling, binding, etc... /// /// Owner which is usually the parent. /// public static readonly DependencyProperty OwnerProperty = - DependencyProperty.RegisterAttached("Owner", typeof(DependencyObject), typeof(CommonProperties), new PropertyMetadata(null)); + DependencyProperty.RegisterAttached( + "Owner", + typeof(DependencyObject), + typeof(CommonProperties), + new PropertyMetadata(null)); } } diff --git a/src/LogoFX.Client.Core.Platform/src/Consts.cs b/src/LogoFX.Client.Core.Platform/src/Consts.cs index c755d8c..439309c 100644 --- a/src/LogoFX.Client.Core.Platform/src/Consts.cs +++ b/src/LogoFX.Client.Core.Platform/src/Consts.cs @@ -1,14 +1,22 @@ -namespace LogoFX.Client.Core +using System.Diagnostics.CodeAnalysis; + +namespace LogoFX.Client.Core { /// /// Dispatcher-related constants. /// + [SuppressMessage("ReSharper", "IdentifierTypo")] public static class Consts { /// /// The dispatcher priority /// - public const System.Windows.Threading.DispatcherPriority - DispatcherPriority = System.Windows.Threading.DispatcherPriority.DataBind; +#if WINUI3 + public const Microsoft.UI.Dispatching.DispatcherQueuePriority DispatcherPriority + = Microsoft.UI.Dispatching.DispatcherQueuePriority.Normal; +#else + public const System.Windows.Threading.DispatcherPriority DispatcherPriority + = System.Windows.Threading.DispatcherPriority.DataBind; +#endif } } diff --git a/src/LogoFX.Client.Core.Platform/src/PlatformDispatch.cs b/src/LogoFX.Client.Core.Platform/src/PlatformDispatch.cs index eb688e2..ef38804 100644 --- a/src/LogoFX.Client.Core.Platform/src/PlatformDispatch.cs +++ b/src/LogoFX.Client.Core.Platform/src/PlatformDispatch.cs @@ -1,4 +1,9 @@ +using System.Diagnostics.CodeAnalysis; +#if WINUI3 +using Microsoft.UI.Dispatching; +#else using System.Windows.Threading; +#endif using LogoFX.Client.Core; // ReSharper disable once CheckNamespace @@ -7,10 +12,14 @@ namespace System.Threading /// /// Platform-specific dispatcher /// + [SuppressMessage("ReSharper", "UnusedMember.Global")] public class PlatformDispatch : IDispatch { - private Action _dispatch; - +#if WINUI3 + private Action _dispatch; +#else + private Action _dispatch; +#endif private void EnsureDispatch() { if (_dispatch == null) @@ -24,27 +33,43 @@ private void EnsureDispatch() /// public void InitializeDispatch() { - var dispatcher = Dispatcher.CurrentDispatcher; - if (dispatcher == null) - throw new InvalidOperationException("Dispatch is not initialized correctly"); - _dispatch = (action, @async, priority) => + var dispatcher +#if WINUI3 + = DispatcherQueue.GetForCurrentThread(); +#else + = Dispatcher.CurrentDispatcher; +#endif + if (dispatcher == null) + { + throw new InvalidOperationException("Dispatch is not initialized correctly"); + } + + _dispatch = (action, async, priority) => { - if (!@async && dispatcher.CheckAccess()) + if (!async && +#if WINUI3 + dispatcher.HasThreadAccess +#else + dispatcher.CheckAccess() +#endif + ) { action(); } else { +#if WINUI3 + dispatcher.TryEnqueue(priority, () => action()); +#else dispatcher.BeginInvoke(action, priority); - } +#endif + } }; } /// public void BeginOnUiThread(Action action) - { - BeginOnUiThread(Consts.DispatcherPriority, action); - } + => BeginOnUiThread(Consts.DispatcherPriority, action); /// /// Begins the action on the UI thread according to the specified priority @@ -52,17 +77,20 @@ public void BeginOnUiThread(Action action) /// Desired priority /// Action public void BeginOnUiThread( - DispatcherPriority priority, Action action) +#if WINUI3 + DispatcherQueuePriority priority, +#else + DispatcherPriority priority, +#endif + Action action) { EnsureDispatch(); _dispatch(action, true, priority); } /// - public void OnUiThread(Action action) - { - OnUiThread(Consts.DispatcherPriority, action); - } + public void OnUiThread(Action action) + => OnUiThread(Consts.DispatcherPriority, action); /// /// Executes the action on the UI thread according to the specified priority @@ -70,7 +98,12 @@ public void OnUiThread(Action action) /// Desired priority /// Action public void OnUiThread( - DispatcherPriority priority, Action action) +#if WINUI3 + DispatcherQueuePriority priority, +#else + DispatcherPriority priority, +#endif + Action action) { EnsureDispatch(); _dispatch(action, false, priority); diff --git a/src/LogoFX.Client.Core.Platform/winui3/LogoFX.Client.Core.Platform.WinUI3.csproj b/src/LogoFX.Client.Core.Platform/winui3/LogoFX.Client.Core.Platform.WinUI3.csproj new file mode 100644 index 0000000..77da867 --- /dev/null +++ b/src/LogoFX.Client.Core.Platform/winui3/LogoFX.Client.Core.Platform.WinUI3.csproj @@ -0,0 +1,30 @@ + + + net6.0-windows10.0.19041.0 + 10.0.17763.0 + LogoFX.Client.Core + win10-x86;win10-x64;win10-arm64 + true + LogoFX.Client.Core.Platform + + + TRACE;WINUI3 + + + TRACE;WINUI3 + + + + + + + + + + + + + + + + diff --git a/src/LogoFX.Client.Core.Specs/LogoFX.Client.Core.Specs.csproj b/src/LogoFX.Client.Core.Specs/LogoFX.Client.Core.Specs.csproj index 16deff4..4e248cd 100644 --- a/src/LogoFX.Client.Core.Specs/LogoFX.Client.Core.Specs.csproj +++ b/src/LogoFX.Client.Core.Specs/LogoFX.Client.Core.Specs.csproj @@ -6,14 +6,14 @@ - - - + + + - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/LogoFX.Core.Specs.Common/LogoFX.Core.Specs.Common.csproj b/src/LogoFX.Core.Specs.Common/LogoFX.Core.Specs.Common.csproj index 993e718..d017f45 100644 --- a/src/LogoFX.Core.Specs.Common/LogoFX.Core.Specs.Common.csproj +++ b/src/LogoFX.Core.Specs.Common/LogoFX.Core.Specs.Common.csproj @@ -12,6 +12,6 @@ - + \ No newline at end of file diff --git a/src/LogoFX.Core.Specs/LogoFX.Core.Specs.csproj b/src/LogoFX.Core.Specs/LogoFX.Core.Specs.csproj index 77f2d0f..70bc57f 100644 --- a/src/LogoFX.Core.Specs/LogoFX.Core.Specs.csproj +++ b/src/LogoFX.Core.Specs/LogoFX.Core.Specs.csproj @@ -9,14 +9,14 @@ - - - + + + - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/LogoFX.Core.Tests/LogoFX.Core.Tests.csproj b/src/LogoFX.Core.Tests/LogoFX.Core.Tests.csproj index f9f0165..2e8d302 100644 --- a/src/LogoFX.Core.Tests/LogoFX.Core.Tests.csproj +++ b/src/LogoFX.Core.Tests/LogoFX.Core.Tests.csproj @@ -5,10 +5,10 @@ false - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/LogoFX.Core.sln b/src/LogoFX.Core.sln index 7fd30b0..30b38e6 100644 --- a/src/LogoFX.Core.sln +++ b/src/LogoFX.Core.sln @@ -53,6 +53,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LogoFX.Core.Specs", "LogoFX EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LogoFX.Core.Specs.Common", "LogoFX.Core.Specs.Common\LogoFX.Core.Specs.Common.csproj", "{C2C89A94-96B9-43DA-841C-3F78ED059DDF}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LogoFX.Client.Core.Platform.WinUI3", "LogoFX.Client.Core.Platform\winui3\LogoFX.Client.Core.Platform.WinUI3.csproj", "{74DFE24B-28FA-48B8-818D-9671F05EBFE2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -401,6 +403,22 @@ Global {C2C89A94-96B9-43DA-841C-3F78ED059DDF}.Release|x64.Build.0 = Release|Any CPU {C2C89A94-96B9-43DA-841C-3F78ED059DDF}.Release|x86.ActiveCfg = Release|Any CPU {C2C89A94-96B9-43DA-841C-3F78ED059DDF}.Release|x86.Build.0 = Release|Any CPU + {74DFE24B-28FA-48B8-818D-9671F05EBFE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {74DFE24B-28FA-48B8-818D-9671F05EBFE2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {74DFE24B-28FA-48B8-818D-9671F05EBFE2}.Debug|ARM.ActiveCfg = Debug|Any CPU + {74DFE24B-28FA-48B8-818D-9671F05EBFE2}.Debug|ARM.Build.0 = Debug|Any CPU + {74DFE24B-28FA-48B8-818D-9671F05EBFE2}.Debug|x64.ActiveCfg = Debug|Any CPU + {74DFE24B-28FA-48B8-818D-9671F05EBFE2}.Debug|x64.Build.0 = Debug|Any CPU + {74DFE24B-28FA-48B8-818D-9671F05EBFE2}.Debug|x86.ActiveCfg = Debug|Any CPU + {74DFE24B-28FA-48B8-818D-9671F05EBFE2}.Debug|x86.Build.0 = Debug|Any CPU + {74DFE24B-28FA-48B8-818D-9671F05EBFE2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {74DFE24B-28FA-48B8-818D-9671F05EBFE2}.Release|Any CPU.Build.0 = Release|Any CPU + {74DFE24B-28FA-48B8-818D-9671F05EBFE2}.Release|ARM.ActiveCfg = Release|Any CPU + {74DFE24B-28FA-48B8-818D-9671F05EBFE2}.Release|ARM.Build.0 = Release|Any CPU + {74DFE24B-28FA-48B8-818D-9671F05EBFE2}.Release|x64.ActiveCfg = Release|Any CPU + {74DFE24B-28FA-48B8-818D-9671F05EBFE2}.Release|x64.Build.0 = Release|Any CPU + {74DFE24B-28FA-48B8-818D-9671F05EBFE2}.Release|x86.ActiveCfg = Release|Any CPU + {74DFE24B-28FA-48B8-818D-9671F05EBFE2}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -427,6 +445,7 @@ Global {728663E9-62A0-4482-8F0A-832699835760} = {F555D153-CB40-4452-B5E4-E9731566272E} {DF5B56B9-783A-457F-B8E1-EEA9EE033E91} = {F555D153-CB40-4452-B5E4-E9731566272E} {C2C89A94-96B9-43DA-841C-3F78ED059DDF} = {F555D153-CB40-4452-B5E4-E9731566272E} + {74DFE24B-28FA-48B8-818D-9671F05EBFE2} = {F555D153-CB40-4452-B5E4-E9731566272E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {AC15861E-3935-4FBC-AA56-C0C4CFF71FC3} diff --git a/src/LogoFX.Practices.IoC.Specs/LogoFX.Practices.IoC.Specs.csproj b/src/LogoFX.Practices.IoC.Specs/LogoFX.Practices.IoC.Specs.csproj index 7a46210..739e32d 100644 --- a/src/LogoFX.Practices.IoC.Specs/LogoFX.Practices.IoC.Specs.csproj +++ b/src/LogoFX.Practices.IoC.Specs/LogoFX.Practices.IoC.Specs.csproj @@ -6,14 +6,14 @@ - - - + + + - - - - + + + + all runtime; build; native; contentfiles; analyzers