Basic window handling.

This commit is contained in:
Burak Kaan Köse
2024-07-13 03:45:55 +02:00
parent ef151aa7a6
commit e6e758e9ba
17 changed files with 124 additions and 53 deletions

View File

@@ -1,6 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using Wino.Core.Domain.Interfaces;
using Wino.Core.UWP.Services;
using Wino.Core.WinUI.Services;
using Wino.Services;
namespace Wino.Core.UWP
@@ -13,6 +14,7 @@ namespace Wino.Core.UWP
services.AddSingleton<INativeAppService, NativeAppService>();
services.AddSingleton<IStoreManagementService, StoreManagementService>();
services.AddSingleton<IBackgroundTaskService, BackgroundTaskService>();
services.AddSingleton<IAppShellService, AppShellService>();
services.AddTransient<IAppInitializerService, AppInitializerService>();
services.AddTransient<IConfigurationService, ConfigurationService>();

View File

@@ -0,0 +1,20 @@
using System;
using System.Threading.Tasks;
using Windows.UI.Core;
using Wino.Core.Domain.Interfaces;
namespace Wino.Core.UWP
{
public class UWPDispatcher : IDispatcher
{
private readonly CoreDispatcher _coreDispatcher;
public UWPDispatcher(CoreDispatcher coreDispatcher)
{
_coreDispatcher = coreDispatcher;
}
public Task ExecuteOnUIThread(Action action)
=> _coreDispatcher.RunAsync(CoreDispatcherPriority.Normal, () => action()).AsTask();
}
}

View File

@@ -0,0 +1,19 @@
#if NET8_0
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
#else
using Windows.UI.Xaml;
#endif
namespace Wino.Core.WinUI.Services
{
public interface IAppShellService
{
Window AppWindow { get; set; }
}
public class AppShellService : IAppShellService
{
public Window AppWindow { get; set; }
}
}

View File

@@ -2,7 +2,6 @@
using System.Threading.Tasks;
using Windows.ApplicationModel;
using Windows.Foundation.Metadata;
using Windows.Security.Authentication.Web;
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
using Windows.Storage;
@@ -27,7 +26,16 @@ namespace Wino.Services
private string _mimeMessagesFolder;
private string _editorBundlePath;
public string GetWebAuthenticationBrokerUri() => WebAuthenticationBroker.GetCurrentApplicationCallbackUri().AbsoluteUri;
public string GetWebAuthenticationBrokerUri()
{
#if NET8_0
// WinUI
return "wino://winomail.app";
#else
return WebAuthenticationBroker.GetCurrentApplicationCallbackUri().AbsoluteUri;
#endif
}
public async Task<string> GetMimeMessageStoragePath()
{

View File

@@ -165,8 +165,13 @@ namespace Wino.Services
// Save reference as this might be null when the user is in another app
#if NET8_0
// WinUI
#else
mainApplicationFrame = Window.Current.Content as Frame;
#endif
if (mainApplicationFrame == null) return;

View File

@@ -128,6 +128,7 @@
<Compile Include="Models\Personalization\SystemAppTheme.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\AppInitializerService.cs" />
<Compile Include="Services\AppShellService.cs" />
<Compile Include="Services\BackgroundSynchronizer.cs" />
<Compile Include="Services\BackgroundTaskService.cs" />
<Compile Include="Services\ClipboardService.cs" />