From 7d0934b6795ce805a1764ff6b704e9f481cdc8c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Kaan=20K=C3=B6se?= Date: Fri, 19 Jul 2024 04:26:06 +0200 Subject: [PATCH] Switch back to WPF server. --- Wino.Mail.WinUI/Package.appxmanifest | 15 +++++-- Wino.Mail.WinUI/Wino.Mail.WinUI.csproj | 2 +- Wino.Packaging/Package.appxmanifest | 5 +-- Wino.Packaging/Wino.Packaging.wapproj | 2 +- Wino.Server/App.xaml | 1 + Wino.Server/App.xaml.cs | 40 ++++++------------- Wino.Server/Program.cs | 25 ------------ Wino.Server/TrayIconResources.xaml | 42 -------------------- Wino.Server/TrayIconResources.xaml.cs | 17 -------- Wino.Server/Wino.Server.csproj | 19 +++------ Wino.WinUI.sln | 55 +++++++++++--------------- 11 files changed, 57 insertions(+), 166 deletions(-) delete mode 100644 Wino.Server/Program.cs delete mode 100644 Wino.Server/TrayIconResources.xaml delete mode 100644 Wino.Server/TrayIconResources.xaml.cs diff --git a/Wino.Mail.WinUI/Package.appxmanifest b/Wino.Mail.WinUI/Package.appxmanifest index d57d74cf..d61e59d4 100644 --- a/Wino.Mail.WinUI/Package.appxmanifest +++ b/Wino.Mail.WinUI/Package.appxmanifest @@ -17,14 +17,14 @@ + Version="0.0.1.0" /> - + - WPCEx + Wino Mail (Preview) Burak KÖSE Assets\StoreLogo.png @@ -72,6 +72,13 @@ + + + diff --git a/Wino.Mail.WinUI/Wino.Mail.WinUI.csproj b/Wino.Mail.WinUI/Wino.Mail.WinUI.csproj index 94d25b84..79466454 100644 --- a/Wino.Mail.WinUI/Wino.Mail.WinUI.csproj +++ b/Wino.Mail.WinUI/Wino.Mail.WinUI.csproj @@ -199,7 +199,7 @@ - + diff --git a/Wino.Packaging/Package.appxmanifest b/Wino.Packaging/Package.appxmanifest index 1db30356..b5950108 100644 --- a/Wino.Packaging/Package.appxmanifest +++ b/Wino.Packaging/Package.appxmanifest @@ -13,7 +13,6 @@ Publisher="CN=51FBDAF3-E212-4149-89A2-A2636B3BC911" Version="1.8.0.0" /> - @@ -57,11 +56,11 @@ - + diff --git a/Wino.Packaging/Wino.Packaging.wapproj b/Wino.Packaging/Wino.Packaging.wapproj index 0d5d5472..bf6efb39 100644 --- a/Wino.Packaging/Wino.Packaging.wapproj +++ b/Wino.Packaging/Wino.Packaging.wapproj @@ -161,6 +161,6 @@ - + \ No newline at end of file diff --git a/Wino.Server/App.xaml b/Wino.Server/App.xaml index 212bf19b..f36b711a 100644 --- a/Wino.Server/App.xaml +++ b/Wino.Server/App.xaml @@ -2,6 +2,7 @@ x:Class="Wino.Server.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + ShutdownMode="OnExplicitShutdown" xmlns:local="clr-namespace:Wino.Server"> diff --git a/Wino.Server/App.xaml.cs b/Wino.Server/App.xaml.cs index 1c214895..4613542a 100644 --- a/Wino.Server/App.xaml.cs +++ b/Wino.Server/App.xaml.cs @@ -1,16 +1,14 @@ using System; using System.Threading; using System.Threading.Tasks; +using System.Windows; using H.NotifyIcon; using Microsoft.Extensions.DependencyInjection; -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Input; using Windows.Storage; using Wino.Core; using Wino.Core.Domain.Interfaces; using Wino.Core.Services; -using Wino.Core.UWP.Services; -using Wino.Services; +//using Wino.Core.UWP; namespace Wino.Server { @@ -29,17 +27,12 @@ namespace Wino.Server public new static App Current => (App)Application.Current; - private TaskbarIcon notifyIcon; + private TaskbarIcon? notifyIcon; private static Mutex _mutex = null; private EventWaitHandle _eventWaitHandle; public IServiceProvider Services { get; private set; } - public App() - { - InitializeComponent(); - } - private IServiceProvider ConfigureServices() { var services = new ServiceCollection(); @@ -48,13 +41,14 @@ namespace Wino.Server services.AddTransient(); services.RegisterCoreServices(); + // services.RegisterCoreUWPServices(); // Below services belongs to UWP.Core package and some APIs are not available for WPF. // We register them here to avoid compilation errors. - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); + //services.AddSingleton(); + //services.AddSingleton(); + //services.AddSingleton(); return services.BuildServiceProvider(); } @@ -78,10 +72,8 @@ namespace Wino.Server return serverViewModel; } - protected override void OnLaunched(LaunchActivatedEventArgs args) + protected override async void OnStartup(StartupEventArgs e) { - base.OnLaunched(args); - _mutex = new Mutex(true, WinoServerAppName, out bool isCreatedNew); _eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, WinoServerActiatedName); @@ -110,6 +102,7 @@ namespace Wino.Server Services = ConfigureServices(); + base.OnStartup(e); var serverViewModel = await InitializeNewServerAsync(); @@ -124,21 +117,14 @@ namespace Wino.Server _eventWaitHandle.Set(); // Terminate this instance. - // Shutdown(); + Shutdown(); } - } - private void InitializeNotifyIcon() + protected override void OnExit(ExitEventArgs e) { - var showHideWindowCommand = (XamlUICommand)Resources["ShowHideWindowCommand"]; - showHideWindowCommand.ExecuteRequested += ShowHideWindowCommand_ExecuteRequested; - - var exitApplicationCommand = (XamlUICommand)Resources["ExitApplicationCommand"]; - exitApplicationCommand.ExecuteRequested += ExitApplicationCommand_ExecuteRequested; - - notifyIcon = (TaskbarIcon)Resources["TrayIcon"]; - notifyIcon.ForceCreate(); + notifyIcon?.Dispose(); + base.OnExit(e); } } } diff --git a/Wino.Server/Program.cs b/Wino.Server/Program.cs deleted file mode 100644 index 59b627b0..00000000 --- a/Wino.Server/Program.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.UI.Dispatching; - -namespace Wino.Server.WinUI -{ - [STAThread] - static async Task Main(string[] args) - { - WinRT.ComWrappersSupport.InitializeComWrappers(); - bool isRedirect = await DecideRedirection(); - if (!isRedirect) - { - Microsoft.UI.Xaml.Application.Start((p) => - { - var context = new DispatcherQueueSynchronizationContext( - DispatcherQueue.GetForCurrentThread()); - SynchronizationContext.SetSynchronizationContext(context); - new App(); - }); - } - return 0; - } -} diff --git a/Wino.Server/TrayIconResources.xaml b/Wino.Server/TrayIconResources.xaml deleted file mode 100644 index 73a6b342..00000000 --- a/Wino.Server/TrayIconResources.xaml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Wino.Server/TrayIconResources.xaml.cs b/Wino.Server/TrayIconResources.xaml.cs deleted file mode 100644 index f9caa347..00000000 --- a/Wino.Server/TrayIconResources.xaml.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.UI.Xaml; - -namespace Wino.Server.WinUI -{ - partial class TrayIconResources : ResourceDictionary - { - public TrayIconResources() - { - this.InitializeComponent(); - } - } -} diff --git a/Wino.Server/Wino.Server.csproj b/Wino.Server/Wino.Server.csproj index fea550e4..abc3c4f5 100644 --- a/Wino.Server/Wino.Server.csproj +++ b/Wino.Server/Wino.Server.csproj @@ -6,7 +6,8 @@ true true true - + win-x86;win-x64;win-arm64 + win10-x86;win10-x64;win10-arm64 true 10.0.22621.0 @@ -16,12 +17,6 @@ - - - - - - Always @@ -32,11 +27,9 @@ - - - - - - + + + + \ No newline at end of file diff --git a/Wino.WinUI.sln b/Wino.WinUI.sln index 9172f241..66bd0023 100644 --- a/Wino.WinUI.sln +++ b/Wino.WinUI.sln @@ -17,10 +17,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wino.Mail.WinUI", "Wino.Mai EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wino.Messaging.NET8", "Wino.Messages\Wino.Messaging.NET8.csproj", "{88A9B1A8-BC59-4852-93D0-37A5D357ABC6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wino.Server.NET8", "Wino.Server.NET8\Wino.Server.NET8.csproj", "{A3B3BDBB-5946-4058-8038-55A97DBCFB38}" -EndProject Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "Wino.Packaging", "Wino.Packaging\Wino.Packaging.wapproj", "{760F5F31-8EE3-4B83-80F3-0E4FFBCC737C}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wino.Server", "Wino.Server\Wino.Server.csproj", "{AF809A28-F49B-4E8C-8363-A882612C41A7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -146,7 +146,6 @@ Global {955936B2-112B-4756-8BC7-67FF12BF9759}.Debug|ARM64.Deploy.0 = Debug|ARM64 {955936B2-112B-4756-8BC7-67FF12BF9759}.Debug|x64.ActiveCfg = Debug|x64 {955936B2-112B-4756-8BC7-67FF12BF9759}.Debug|x64.Build.0 = Debug|x64 - {955936B2-112B-4756-8BC7-67FF12BF9759}.Debug|x64.Deploy.0 = Debug|x64 {955936B2-112B-4756-8BC7-67FF12BF9759}.Debug|x86.ActiveCfg = Debug|x86 {955936B2-112B-4756-8BC7-67FF12BF9759}.Debug|x86.Build.0 = Debug|x86 {955936B2-112B-4756-8BC7-67FF12BF9759}.Debug|x86.Deploy.0 = Debug|x86 @@ -185,36 +184,6 @@ Global {88A9B1A8-BC59-4852-93D0-37A5D357ABC6}.Release|x64.Build.0 = Release|Any CPU {88A9B1A8-BC59-4852-93D0-37A5D357ABC6}.Release|x86.ActiveCfg = Release|Any CPU {88A9B1A8-BC59-4852-93D0-37A5D357ABC6}.Release|x86.Build.0 = Release|Any CPU - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Debug|Any CPU.ActiveCfg = Debug|x64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Debug|Any CPU.Build.0 = Debug|x64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Debug|Any CPU.Deploy.0 = Debug|x64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Debug|ARM.ActiveCfg = Debug|x64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Debug|ARM.Build.0 = Debug|x64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Debug|ARM.Deploy.0 = Debug|x64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Debug|ARM64.Build.0 = Debug|ARM64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Debug|ARM64.Deploy.0 = Debug|ARM64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Debug|x64.ActiveCfg = Debug|x64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Debug|x64.Build.0 = Debug|x64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Debug|x64.Deploy.0 = Debug|x64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Debug|x86.ActiveCfg = Debug|x86 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Debug|x86.Build.0 = Debug|x86 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Debug|x86.Deploy.0 = Debug|x86 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Release|Any CPU.ActiveCfg = Release|x64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Release|Any CPU.Build.0 = Release|x64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Release|Any CPU.Deploy.0 = Release|x64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Release|ARM.ActiveCfg = Release|x64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Release|ARM.Build.0 = Release|x64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Release|ARM.Deploy.0 = Release|x64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Release|ARM64.ActiveCfg = Release|ARM64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Release|ARM64.Build.0 = Release|ARM64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Release|ARM64.Deploy.0 = Release|ARM64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Release|x64.ActiveCfg = Release|x64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Release|x64.Build.0 = Release|x64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Release|x64.Deploy.0 = Release|x64 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Release|x86.ActiveCfg = Release|x86 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Release|x86.Build.0 = Release|x86 - {A3B3BDBB-5946-4058-8038-55A97DBCFB38}.Release|x86.Deploy.0 = Release|x86 {760F5F31-8EE3-4B83-80F3-0E4FFBCC737C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {760F5F31-8EE3-4B83-80F3-0E4FFBCC737C}.Debug|Any CPU.Build.0 = Debug|Any CPU {760F5F31-8EE3-4B83-80F3-0E4FFBCC737C}.Debug|Any CPU.Deploy.0 = Debug|Any CPU @@ -245,6 +214,26 @@ Global {760F5F31-8EE3-4B83-80F3-0E4FFBCC737C}.Release|x86.ActiveCfg = Release|x86 {760F5F31-8EE3-4B83-80F3-0E4FFBCC737C}.Release|x86.Build.0 = Release|x86 {760F5F31-8EE3-4B83-80F3-0E4FFBCC737C}.Release|x86.Deploy.0 = Release|x86 + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Debug|ARM.ActiveCfg = Debug|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Debug|ARM.Build.0 = Debug|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Debug|ARM64.Build.0 = Debug|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Debug|x64.ActiveCfg = Debug|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Debug|x64.Build.0 = Debug|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Debug|x86.ActiveCfg = Debug|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Debug|x86.Build.0 = Debug|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Release|Any CPU.Build.0 = Release|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Release|ARM.ActiveCfg = Release|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Release|ARM.Build.0 = Release|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Release|ARM64.ActiveCfg = Release|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Release|ARM64.Build.0 = Release|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Release|x64.ActiveCfg = Release|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Release|x64.Build.0 = Release|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Release|x86.ActiveCfg = Release|Any CPU + {AF809A28-F49B-4E8C-8363-A882612C41A7}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE