Fixing WinUI build and bringing Wino.Server basics.
16
Wino.Server.NET8/App.xaml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Application
|
||||
x:Class="Wino.Server.NET8.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Wino.Server.NET8">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
|
||||
<!-- Other merged dictionaries here -->
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<!-- Other app resources here -->
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
35
Wino.Server.NET8/App.xaml.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using H.NotifyIcon;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
|
||||
namespace Wino.Server.NET8
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
public TaskbarIcon? TrayIcon { get; private set; }
|
||||
public Window? Window { get; set; }
|
||||
|
||||
public bool HandleClosedEvents { get; set; } = true;
|
||||
public App()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnLaunched(LaunchActivatedEventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void InitializeTrayIcon()
|
||||
{
|
||||
var showHideWindowCommand = (XamlUICommand)Resources["ShowHideWindowCommand"];
|
||||
// showHideWindowCommand.ExecuteRequested ;
|
||||
|
||||
var exitApplicationCommand = (XamlUICommand)Resources["ExitApplicationCommand"];
|
||||
//exitApplicationCommand.ExecuteRequested += ExitApplicationCommand_ExecuteRequested;
|
||||
|
||||
TrayIcon = (TaskbarIcon)Resources["TrayIcon"];
|
||||
TrayIcon.ForceCreate();
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Wino.Server.NET8/Assets/LockScreenLogo.scale-200.png
Normal file
|
After Width: | Height: | Size: 432 B |
BIN
Wino.Server.NET8/Assets/SplashScreen.scale-200.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
Wino.Server.NET8/Assets/Square150x150Logo.scale-200.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
Wino.Server.NET8/Assets/Square44x44Logo.scale-200.png
Normal file
|
After Width: | Height: | Size: 637 B |
|
After Width: | Height: | Size: 283 B |
BIN
Wino.Server.NET8/Assets/StoreLogo.png
Normal file
|
After Width: | Height: | Size: 456 B |
BIN
Wino.Server.NET8/Assets/Wide310x150Logo.scale-200.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
Wino.Server.NET8/Assets/Wino_Icon.ico
Normal file
|
After Width: | Height: | Size: 124 KiB |
51
Wino.Server.NET8/Package.appxmanifest
Normal file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<Package
|
||||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
|
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
|
||||
IgnorableNamespaces="uap rescap">
|
||||
|
||||
<Identity
|
||||
Name="f7498058-466c-48d4-bc53-0afe4ec4de31"
|
||||
Publisher="CN=bkaan"
|
||||
Version="1.0.0.0" />
|
||||
|
||||
<mp:PhoneIdentity PhoneProductId="f7498058-466c-48d4-bc53-0afe4ec4de31" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||
|
||||
<Properties>
|
||||
<DisplayName>Wino.Server.NET8</DisplayName>
|
||||
<PublisherDisplayName>bkaan</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
|
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
<Resource Language="x-generate"/>
|
||||
</Resources>
|
||||
|
||||
<Applications>
|
||||
<Application Id="App"
|
||||
Executable="$targetnametoken$.exe"
|
||||
EntryPoint="$targetentrypoint$">
|
||||
<uap:VisualElements
|
||||
DisplayName="Wino.Server.NET8"
|
||||
Description="Wino.Server.NET8"
|
||||
BackgroundColor="transparent"
|
||||
Square150x150Logo="Assets\Square150x150Logo.png"
|
||||
Square44x44Logo="Assets\Square44x44Logo.png">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
|
||||
<Capabilities>
|
||||
<rescap:Capability Name="runFullTrust" />
|
||||
</Capabilities>
|
||||
</Package>
|
||||
97
Wino.Server.NET8/Program.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.UI.Dispatching;
|
||||
using Microsoft.Windows.AppLifecycle;
|
||||
using Wino.Server.NET8;
|
||||
|
||||
namespace Wino.Server
|
||||
{
|
||||
class Program
|
||||
{
|
||||
private const string WinoActivationKey = nameof(WinoActivationKey);
|
||||
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
WinRT.ComWrappersSupport.InitializeComWrappers();
|
||||
bool isRedirect = DecideRedirection();
|
||||
if (!isRedirect)
|
||||
{
|
||||
Microsoft.UI.Xaml.Application.Start((p) =>
|
||||
{
|
||||
var context = new DispatcherQueueSynchronizationContext(
|
||||
DispatcherQueue.GetForCurrentThread());
|
||||
SynchronizationContext.SetSynchronizationContext(context);
|
||||
new App();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static bool DecideRedirection()
|
||||
{
|
||||
bool isRedirect = false;
|
||||
|
||||
AppActivationArguments args = AppInstance.GetCurrent().GetActivatedEventArgs();
|
||||
ExtendedActivationKind kind = args.Kind;
|
||||
|
||||
try
|
||||
{
|
||||
AppInstance keyInstance = AppInstance.FindOrRegisterForKey(WinoActivationKey);
|
||||
|
||||
if (keyInstance.IsCurrent)
|
||||
{
|
||||
keyInstance.Activated += OnActivated;
|
||||
}
|
||||
else
|
||||
{
|
||||
isRedirect = true;
|
||||
RedirectActivationTo(args, keyInstance);
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return isRedirect;
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
||||
private static extern IntPtr CreateEvent(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, string lpName);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern bool SetEvent(IntPtr hEvent);
|
||||
|
||||
[DllImport("ole32.dll")]
|
||||
private static extern uint CoWaitForMultipleObjects(uint dwFlags, uint dwMilliseconds, ulong nHandles, IntPtr[] pHandles, out uint dwIndex);
|
||||
|
||||
private static IntPtr redirectEventHandle = IntPtr.Zero;
|
||||
|
||||
// Do the redirection on another thread, and use a non-blocking
|
||||
// wait method to wait for the redirection to complete.
|
||||
public static void RedirectActivationTo(
|
||||
AppActivationArguments args, AppInstance keyInstance)
|
||||
{
|
||||
redirectEventHandle = CreateEvent(IntPtr.Zero, true, false, null);
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
keyInstance.RedirectActivationToAsync(args).AsTask().Wait();
|
||||
SetEvent(redirectEventHandle);
|
||||
});
|
||||
|
||||
uint CWMO_DEFAULT = 0;
|
||||
uint INFINITE = 0xFFFFFFFF;
|
||||
|
||||
_ = CoWaitForMultipleObjects(CWMO_DEFAULT, INFINITE, 1, new IntPtr[] { redirectEventHandle }, out uint handleIndex);
|
||||
}
|
||||
|
||||
private static void OnActivated(object sender, AppActivationArguments args)
|
||||
{
|
||||
ExtendedActivationKind kind = args.Kind;
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Wino.Server.NET8/Properties/launchSettings.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"profiles": {
|
||||
"Wino.Server.NET8 (Package)": {
|
||||
"commandName": "MsixPackage"
|
||||
},
|
||||
"Wino.Server.NET8 (Unpackaged)": {
|
||||
"commandName": "Project"
|
||||
}
|
||||
}
|
||||
}
|
||||
45
Wino.Server.NET8/TrayIconResources.xaml
Normal file
@@ -0,0 +1,45 @@
|
||||
<ResourceDictionary
|
||||
x:Class="Wino.Server.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">
|
||||
|
||||
<!-- TODO: Localize by Translator. -->
|
||||
|
||||
<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>
|
||||
17
Wino.Server.NET8/TrayIconResources.xaml.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.UI.Xaml;
|
||||
|
||||
namespace Wino.Server
|
||||
{
|
||||
partial class TrayIconResources : ResourceDictionary
|
||||
{
|
||||
public TrayIconResources()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
98
Wino.Server.NET8/Wino.Server.NET8.csproj
Normal file
@@ -0,0 +1,98 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<RootNamespace>Wino.Server</RootNamespace>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<Platforms>x86;x64;ARM64</Platforms>
|
||||
<RuntimeIdentifiers Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) >= 8">win-x86;win-x64;win-arm64</RuntimeIdentifiers>
|
||||
<RuntimeIdentifiers Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) < 8">win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<EnableMsixTooling>true</EnableMsixTooling>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Disable XAML generated main to enable single activation. -->
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<DefineConstants>DISABLE_XAML_GENERATED_MAIN</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
|
||||
<DefineConstants>DISABLE_XAML_GENERATED_MAIN</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
|
||||
<DefineConstants>DISABLE_XAML_GENERATED_MAIN</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<DefineConstants>DISABLE_XAML_GENERATED_MAIN</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm64'">
|
||||
<DefineConstants>DISABLE_XAML_GENERATED_MAIN</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm64'">
|
||||
<DefineConstants>DISABLE_XAML_GENERATED_MAIN</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="Assets\Wino_Icon.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="app.manifest" />
|
||||
<None Remove="TrayIconResources.xaml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||
<Content Include="Assets\LockScreenLogo.scale-200.png" />
|
||||
<Content Include="Assets\Square150x150Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
|
||||
<Content Include="Assets\StoreLogo.png" />
|
||||
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="H.NotifyIcon.WinUI" Version="2.1.0" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1" />
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240627000" />
|
||||
<Manifest Include="$(ApplicationManifest)" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--
|
||||
Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
|
||||
Tools extension to be activated for this project even if the Windows App SDK Nuget
|
||||
package has not yet been restored.
|
||||
-->
|
||||
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
|
||||
<ProjectCapability Include="Msix" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<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>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="app.manifest">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Update="TrayIconResources.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
|
||||
<!--
|
||||
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution
|
||||
Explorer "Package and Publish" context menu entry to be enabled for this project even if
|
||||
the Windows App SDK Nuget package has not yet been restored.
|
||||
-->
|
||||
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
|
||||
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
19
Wino.Server.NET8/app.manifest
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="Wino.Server.NET8.app"/>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- The ID below informs the system that this application is compatible with OS features first introduced in Windows 10.
|
||||
It is necessary to support features in unpackaged applications, for example the custom titlebar implementation.
|
||||
For more info see https://docs.microsoft.com/windows/apps/windows-app-sdk/use-windows-app-sdk-run-time#declare-os-compatibility-in-your-application-manifest -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
||||
</application>
|
||||
</compatibility>
|
||||
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
</assembly>
|
||||