Switch back to WPF server.

This commit is contained in:
Burak Kaan Köse
2024-07-19 04:26:06 +02:00
parent 756cf5992c
commit 7d0934b679
11 changed files with 57 additions and 166 deletions

View File

@@ -17,14 +17,14 @@
</Extensions>
<Identity
Name="58272BurakKSE.WPCEx"
Name="58272BurakKSE.WinoMailPreview"
Publisher="CN=51FBDAF3-E212-4149-89A2-A2636B3BC911"
Version="1.0.0.0" />
Version="0.0.1.0" />
<mp:PhoneIdentity PhoneProductId="5f63c5a0-c3a9-4589-97ef-25dad4e4ec10" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
<mp:PhoneIdentity PhoneProductId="efeba1ea-0f3a-484d-8ac6-5f03a08ba6a9" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
<Properties>
<DisplayName>WPCEx</DisplayName>
<DisplayName>Wino Mail (Preview)</DisplayName>
<PublisherDisplayName>Burak KÖSE</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
@@ -72,6 +72,13 @@
</uap:Protocol>
</uap:Extension>
<!-- SessionConnected task for background synchronization on startup. -->
<!--<Extension Category="windows.backgroundTasks" EntryPoint="Wino.BackgroundTasks.SessionConnectedTask">
<BackgroundTasks>
<Task Type="systemEvent" />
</BackgroundTasks>
</Extension>-->
<!-- File Assosication: EML -->
<uap:Extension Category="windows.fileTypeAssociation">
<uap:FileTypeAssociation Name="eml">

View File

@@ -199,7 +199,7 @@
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="5.0.5" />
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="5.0.5" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240627000" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240701003-experimental2" />
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
<PackageReference Include="WinUIEx" Version="2.3.4" />
<Manifest Include="$(ApplicationManifest)" />

View File

@@ -13,7 +13,6 @@
Publisher="CN=51FBDAF3-E212-4149-89A2-A2636B3BC911"
Version="1.8.0.0" />
<Extensions>
<!-- Publisher Cache Folders -->
<Extension Category="windows.publisherCacheFolders">
@@ -57,11 +56,11 @@
<Extension Category="windows.updateTask" EntryPoint="Wino.BackgroundTasks.AppUpdatedTask" />
<!-- SessionConnected task for background synchronization on startup. -->
<Extension Category="windows.backgroundTasks" EntryPoint="Wino.BackgroundTasks.SessionConnectedTask">
<!--<Extension Category="windows.backgroundTasks" EntryPoint="Wino.BackgroundTasks.SessionConnectedTask">
<BackgroundTasks>
<Task Type="systemEvent" />
</BackgroundTasks>
</Extension>
</Extension>-->
<!-- Protocol activation: mailto -->
<uap:Extension Category="windows.protocol">

View File

@@ -161,6 +161,6 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Wino.Mail.WinUI\Wino.Mail.WinUI.csproj" />
<ProjectReference Include="..\Wino.Server.NET8\Wino.Server.NET8.csproj" />
<ProjectReference Include="..\Wino.Server\Wino.Server.csproj" />
</ItemGroup>
</Project>

View File

@@ -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">
<Application.Resources>
<ResourceDictionary Source="TrayIconResources.xaml" />

View File

@@ -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<ServerViewModel>();
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<IConfigurationService, ConfigurationService>();
services.AddSingleton<INativeAppService, NativeAppService>();
services.AddSingleton<IPreferencesService, PreferencesService>();
//services.AddSingleton<IConfigurationService, ConfigurationService>();
//services.AddSingleton<INativeAppService, NativeAppService>();
//services.AddSingleton<IPreferencesService, PreferencesService>();
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);
}
}
}

View File

@@ -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;
}
}

View File

@@ -1,42 +0,0 @@
<ResourceDictionary
x:Class="Wino.Server.WinUI.TrayIconResources"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:domain="using:Wino.Core.Domain"
xmlns:tb="using:H.NotifyIcon"
xmlns:local="using:Wino.Server.WinUI">
<XamlUICommand
x:Key="LaunchCommand"
Label="Launch"
Description="Activates Wino Mail window.">
<XamlUICommand.IconSource>
<SymbolIconSource Symbol="Accept" />
</XamlUICommand.IconSource>
</XamlUICommand>
<XamlUICommand
x:Key="TerminateCommand"
Label="Quit"
Description="Close Wino Mail completely.">
<XamlUICommand.IconSource>
<SymbolIconSource Symbol="ClosePane" />
</XamlUICommand.IconSource>
</XamlUICommand>
<tb:TaskbarIcon
x:Key="TrayIcon"
Visibility="Visible"
ToolTipText="Wino Mail"
ContextMenuMode="SecondWindow"
LeftClickCommand="{StaticResource LaunchCommand}"
NoLeftClickDelay="True"
IconSource="\Images\Wino_Icon.ico">
<tb:TaskbarIcon.ContextFlyout>
<MenuFlyout>
<MenuFlyoutItem Command="{StaticResource LaunchCommand}" />
<MenuFlyoutItem Command="{StaticResource TerminateCommand}" />
</MenuFlyout>
</tb:TaskbarIcon.ContextFlyout>
</tb:TaskbarIcon>
</ResourceDictionary>

View File

@@ -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();
}
}
}

View File

@@ -6,7 +6,8 @@
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<UseWPF>true</UseWPF>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<RuntimeIdentifiers Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) &gt;= 8">win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) &lt; 8">win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<CsWinRTComponent>true</CsWinRTComponent>
<CsWinRTWindowsMetadata>10.0.22621.0</CsWinRTWindowsMetadata>
</PropertyGroup>
@@ -16,12 +17,6 @@
<ItemGroup>
<None Remove="Images\Wino_Icon.ico" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Wino.Core.UWP\Services\ConfigurationService.cs" Link="Services\ConfigurationService.cs" />
<Compile Include="..\Wino.Core.UWP\Services\NativeAppService.cs" Link="Services\NativeAppService.cs" />
<Compile Include="..\Wino.Core.UWP\Services\NotificationBuilder.cs" Link="Services\NotificationBuilder.cs" />
<Compile Include="..\Wino.Core.UWP\Services\PreferencesService.cs" Link="Services\PreferencesService.cs" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Wino_Icon.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@@ -32,11 +27,9 @@
<PackageReference Include="H.NotifyIcon.Wpf" Version="2.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Wino.Core.Domain\Wino.Core.Domain.csproj" />
<ProjectReference Include="..\Wino.Core\Wino.Core.csproj" />
<ProjectReference Include="..\Wino.Messages\Wino.Messaging.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Services\" />
<ProjectReference Include="..\Wino.Core.Domain\Wino.Core.Domain.NET8.csproj" />
<ProjectReference Include="..\Wino.Core.UWP\Wino.Core.WinUI.csproj" />
<ProjectReference Include="..\Wino.Core\Wino.Core.NET8.csproj" />
<ProjectReference Include="..\Wino.Messages\Wino.Messaging.NET8.csproj" />
</ItemGroup>
</Project>

View File

@@ -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