From 9edb06c1cc50ce08ef8f7fc38b21d1cfa6006d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Kaan=20K=C3=B6se?= Date: Thu, 11 Jul 2024 16:38:43 +0200 Subject: [PATCH] Standartization of Core.UWP project file for NET8 WinUI --- .../Extensions/ElementThemeExtensions.cs | 8 +++-- Wino.Core.UWP/Services/KeyPressService.cs | 11 +++++-- Wino.Core.UWP/Services/NativeAppService.cs | 12 ++++++-- Wino.Core.UWP/Services/NotificationBuilder.cs | 7 ++++- Wino.Core.UWP/Services/ThemeService.cs | 29 ++++++++++++++---- .../Services/UnderlyingThemeService.cs | 7 ++++- Wino.Core.UWP/Wino.Core.WinUI.csproj | 30 +++++++++++++++++++ Wino.WinUI.sln | 6 ++++ 8 files changed, 95 insertions(+), 15 deletions(-) create mode 100644 Wino.Core.UWP/Wino.Core.WinUI.csproj diff --git a/Wino.Core.UWP/Extensions/ElementThemeExtensions.cs b/Wino.Core.UWP/Extensions/ElementThemeExtensions.cs index 4f7fd145..e75a417f 100644 --- a/Wino.Core.UWP/Extensions/ElementThemeExtensions.cs +++ b/Wino.Core.UWP/Extensions/ElementThemeExtensions.cs @@ -1,5 +1,9 @@ -using Windows.UI.Xaml; -using Wino.Core.Domain.Enums; +using Wino.Core.Domain.Enums; +#if NET8_0 +using Microsoft.UI.Xaml; +#else +using Windows.UI.Xaml; +#endif namespace Wino.Core.UWP.Extensions { diff --git a/Wino.Core.UWP/Services/KeyPressService.cs b/Wino.Core.UWP/Services/KeyPressService.cs index 02a557d0..0ad85e20 100644 --- a/Wino.Core.UWP/Services/KeyPressService.cs +++ b/Wino.Core.UWP/Services/KeyPressService.cs @@ -1,8 +1,15 @@ -using Windows.System; + +using Windows.System; using Windows.UI.Core; -using Windows.UI.Xaml; + using Wino.Core.Domain.Interfaces; +#if NET8_0 +using Microsoft.UI.Xaml; +#else +using Windows.UI.Xaml; +#endif + namespace Wino.Core.UWP.Services { public class KeyPressService : IKeyPressService diff --git a/Wino.Core.UWP/Services/NativeAppService.cs b/Wino.Core.UWP/Services/NativeAppService.cs index 27d4b3cc..9e0d4c04 100644 --- a/Wino.Core.UWP/Services/NativeAppService.cs +++ b/Wino.Core.UWP/Services/NativeAppService.cs @@ -9,11 +9,17 @@ using Windows.Storage; using Windows.Storage.Streams; using Windows.System; using Windows.UI.Shell; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; + using Wino.Core.Domain.Interfaces; using Wino.Core.Domain.Models.Authorization; +#if NET8_0 +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +#else +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +#endif namespace Wino.Services { public class NativeAppService : INativeAppService @@ -100,7 +106,7 @@ namespace Wino.Services await Launcher.LaunchFileAsync(file); } - public Task LaunchUriAsync(Uri uri) => Xamarin.Essentials.Launcher.OpenAsync(uri); + public Task LaunchUriAsync(Uri uri) => Launcher.LaunchUriAsync(uri).AsTask(); public string GetFullAppVersion() { diff --git a/Wino.Core.UWP/Services/NotificationBuilder.cs b/Wino.Core.UWP/Services/NotificationBuilder.cs index c967819b..6b10c604 100644 --- a/Wino.Core.UWP/Services/NotificationBuilder.cs +++ b/Wino.Core.UWP/Services/NotificationBuilder.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.Toolkit.Uwp.Notifications; using Windows.Data.Xml.Dom; using Windows.UI.Notifications; using Wino.Core.Domain; @@ -12,6 +11,12 @@ using Wino.Core.Domain.Interfaces; using Wino.Core.Domain.Models.MailItem; using Wino.Core.Services; +#if NET8_0 +using CommunityToolkit.WinUI.Notifications; +#else +using Microsoft.Toolkit.Uwp.Notifications; +#endif + namespace Wino.Core.UWP.Services { // TODO: Refactor this thing. It's garbage. diff --git a/Wino.Core.UWP/Services/ThemeService.cs b/Wino.Core.UWP/Services/ThemeService.cs index 9649a625..c7ef8391 100644 --- a/Wino.Core.UWP/Services/ThemeService.cs +++ b/Wino.Core.UWP/Services/ThemeService.cs @@ -6,15 +6,12 @@ using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; using System.Threading.Tasks; using CommunityToolkit.Mvvm.Messaging; -using Microsoft.Toolkit.Uwp.Helpers; + using Newtonsoft.Json; using Windows.Storage; -using Windows.UI; + using Windows.UI.ViewManagement; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Markup; -using Windows.UI.Xaml.Media; + using Wino.Core.Domain; using Wino.Core.Domain.Enums; using Wino.Core.Domain.Exceptions; @@ -25,6 +22,22 @@ using Wino.Core.UWP.Extensions; using Wino.Core.UWP.Models.Personalization; using Wino.Core.UWP.Services; +#if NET8_0 +using Microsoft.UI.Xaml.Controls; +using CommunityToolkit.WinUI.Helpers; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Markup; +using Microsoft.UI; +#else +using Windows.UI; +using Windows.UI.Xaml.Controls; +using Microsoft.Toolkit.Uwp.Helpers; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Markup; + +#endif namespace Wino.Services { /// @@ -226,7 +239,11 @@ namespace Wino.Services // Change accent color if specified. if (!string.IsNullOrEmpty(hex)) { +#if NET8_0 + var brush = new SolidColorBrush(CommunityToolkit.WinUI.Helpers.ColorHelper.ToColor(hex)); +#else var brush = new SolidColorBrush(Microsoft.Toolkit.Uwp.Helpers.ColorHelper.ToColor(hex)); +#endif if (_applicationResourceManager.ContainsResourceKey("SystemAccentColor")) _applicationResourceManager.ReplaceResource("SystemAccentColor", brush); diff --git a/Wino.Core.UWP/Services/UnderlyingThemeService.cs b/Wino.Core.UWP/Services/UnderlyingThemeService.cs index 5f88a393..f2cb377d 100644 --- a/Wino.Core.UWP/Services/UnderlyingThemeService.cs +++ b/Wino.Core.UWP/Services/UnderlyingThemeService.cs @@ -1,7 +1,12 @@ using Windows.UI.ViewManagement; -using Windows.UI.Xaml; using Wino.Core.Domain.Interfaces; +#if NET8_0 +using Microsoft.UI.Xaml; +#else +using Windows.UI.Xaml; +#endif + namespace Wino.Core.UWP.Services { public class UnderlyingThemeService : IUnderlyingThemeService diff --git a/Wino.Core.UWP/Wino.Core.WinUI.csproj b/Wino.Core.UWP/Wino.Core.WinUI.csproj new file mode 100644 index 00000000..36a5e08d --- /dev/null +++ b/Wino.Core.UWP/Wino.Core.WinUI.csproj @@ -0,0 +1,30 @@ + + + net8.0-windows10.0.19041.0 + 10.0.17763.0 + Wino.Core.WinUI + win-x86;win-x64;win-arm64 + win10-x86;win10-x64;win10-arm64 + true + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Wino.WinUI.sln b/Wino.WinUI.sln index 269b8d34..fef06837 100644 --- a/Wino.WinUI.sln +++ b/Wino.WinUI.sln @@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wino.Mail.ViewModels.NET8", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wino.Core.NET8", "Wino.Core\Wino.Core.NET8.csproj", "{FEC05E9C-4186-4ECF-A522-C8EB5C187F0D}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wino.Core.WinUI", "Wino.Core.UWP\Wino.Core.WinUI.csproj", "{FF3C03F7-4E9B-4333-9A9D-2BB1D1241C56}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,6 +29,10 @@ Global {FEC05E9C-4186-4ECF-A522-C8EB5C187F0D}.Debug|Any CPU.Build.0 = Debug|Any CPU {FEC05E9C-4186-4ECF-A522-C8EB5C187F0D}.Release|Any CPU.ActiveCfg = Release|Any CPU {FEC05E9C-4186-4ECF-A522-C8EB5C187F0D}.Release|Any CPU.Build.0 = Release|Any CPU + {FF3C03F7-4E9B-4333-9A9D-2BB1D1241C56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FF3C03F7-4E9B-4333-9A9D-2BB1D1241C56}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FF3C03F7-4E9B-4333-9A9D-2BB1D1241C56}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FF3C03F7-4E9B-4333-9A9D-2BB1D1241C56}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE