Basic window handling.
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
using System.Reflection;
|
||||
|
||||
using System.Reflection;
|
||||
using Wino.Core.Domain.Enums;
|
||||
|
||||
#if !NET8_0
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
#endif
|
||||
namespace Wino.Core.Domain.Translations
|
||||
{
|
||||
public class WinoTranslationDictionary : Dictionary<string, string>
|
||||
|
||||
@@ -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>();
|
||||
|
||||
20
Wino.Core.UWP/Dispatcher.cs
Normal file
20
Wino.Core.UWP/Dispatcher.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
19
Wino.Core.UWP/Services/AppShellService.cs
Normal file
19
Wino.Core.UWP/Services/AppShellService.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -1,18 +1,25 @@
|
||||
using System.Text;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Wino.Core;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Services;
|
||||
|
||||
using Wino.Core.WinUI.Services;
|
||||
using Wino.Views;
|
||||
using WinUIEx;
|
||||
namespace Wino
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
public static MainWindow MainWindow = new MainWindow();
|
||||
private WindowEx m_Window;
|
||||
private Frame m_ShellFrame;
|
||||
|
||||
public App()
|
||||
{
|
||||
if (WebAuthenticator.CheckOAuthRedirectionActivation()) return;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
Services = ConfigureServices();
|
||||
@@ -29,19 +36,38 @@ namespace Wino
|
||||
_appInitializerService = Services.GetService<IAppInitializerService>();
|
||||
_synchronizerFactory = Services.GetService<IWinoSynchronizerFactory>();
|
||||
_translationService = Services.GetService<ITranslationService>();
|
||||
_appShellService = Services.GetService<IAppShellService>();
|
||||
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
}
|
||||
|
||||
protected override async void OnLaunched(LaunchActivatedEventArgs args)
|
||||
{
|
||||
ConfigureWindow();
|
||||
|
||||
_appShellService.AppWindow = m_Window;
|
||||
|
||||
foreach (var service in initializeServices)
|
||||
{
|
||||
await service.InitializeAsync();
|
||||
}
|
||||
|
||||
MainWindow.Activate();
|
||||
MainWindow.StartWino();
|
||||
m_ShellFrame.Navigate(typeof(AppShell));
|
||||
m_Window.Activate();
|
||||
}
|
||||
|
||||
private void ConfigureWindow()
|
||||
{
|
||||
m_Window = new WindowEx
|
||||
{
|
||||
SystemBackdrop = new MicaBackdrop(),
|
||||
ExtendsContentIntoTitleBar = true,
|
||||
MinWidth = 420
|
||||
};
|
||||
|
||||
m_ShellFrame = new Frame();
|
||||
|
||||
m_Window.Content = m_ShellFrame;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Window
|
||||
x:Class="Wino.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Frame x:Name="WindowFrame" />
|
||||
|
||||
</Window>
|
||||
@@ -1,18 +0,0 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Wino.Views;
|
||||
|
||||
namespace Wino
|
||||
{
|
||||
public sealed partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void StartWino()
|
||||
{
|
||||
WindowFrame.Navigate(typeof(AppShell));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,15 +8,15 @@
|
||||
IgnorableNamespaces="uap rescap">
|
||||
|
||||
<Identity
|
||||
Name="f531e70c-e2be-4ddb-aa1b-a1e0de9f3ab3"
|
||||
Publisher="CN=bkaan"
|
||||
Name="58272BurakKSE.WPCEx"
|
||||
Publisher="CN=51FBDAF3-E212-4149-89A2-A2636B3BC911"
|
||||
Version="1.0.0.0" />
|
||||
|
||||
<mp:PhoneIdentity PhoneProductId="f531e70c-e2be-4ddb-aa1b-a1e0de9f3ab3" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||
<mp:PhoneIdentity PhoneProductId="5f63c5a0-c3a9-4589-97ef-25dad4e4ec10" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||
|
||||
<Properties>
|
||||
<DisplayName>Wino.Mail.WinUI</DisplayName>
|
||||
<PublisherDisplayName>bkaan</PublisherDisplayName>
|
||||
<DisplayName>WPCEx</DisplayName>
|
||||
<PublisherDisplayName>Burak KÖSE</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
|
||||
@@ -42,6 +42,11 @@
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" Square71x71Logo="Assets\SmallTile.png" Square310x310Logo="Assets\LargeTile.png"/>
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
<Extensions>
|
||||
<uap:Extension Category="windows.protocol">
|
||||
<uap:Protocol Name="winomail.app"/>
|
||||
</uap:Extension>
|
||||
</Extensions>
|
||||
</Application>
|
||||
</Applications>
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<EnableMsixTooling>true</EnableMsixTooling>
|
||||
<WindowsSdkPackageVersion>10.0.19041.35-preview</WindowsSdkPackageVersion>
|
||||
<GenerateTemporaryStoreCertificate>True</GenerateTemporaryStoreCertificate>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="AppThemes\Custom.xaml" />
|
||||
@@ -99,7 +100,6 @@
|
||||
<Compile Include="..\Wino.Mail\Services\LaunchProtocolService.cs" Link="Services\LaunchProtocolService.cs" />
|
||||
<Compile Include="..\Wino.Mail\Services\PreferencesService.cs" Link="Services\PreferencesService.cs" />
|
||||
<Compile Include="..\Wino.Mail\Services\StatePersistenceService.cs" Link="Services\StatePersistenceService.cs" />
|
||||
<Compile Include="..\Wino.Mail\Services\ToastActivationService.cs" Link="Services\ToastActivationService.cs" />
|
||||
<Compile Include="..\Wino.Mail\Services\WinoNavigationService.cs" Link="Services\WinoNavigationService.cs" />
|
||||
<Compile Include="..\Wino.Mail\Styles\CommandBarItems.xaml.cs" Link="Styles\CommandBarItems.xaml.cs" />
|
||||
<Compile Include="..\Wino.Mail\Views\Account\AccountDetailsPage.xaml.cs" Link="Views\Account\AccountDetailsPage.xaml.cs" />
|
||||
|
||||
@@ -55,6 +55,8 @@ namespace Wino
|
||||
{
|
||||
base.OnWindowCreated(args);
|
||||
|
||||
_appShellService.AppWindow = args.Window;
|
||||
|
||||
LogActivation("Window is created.");
|
||||
|
||||
ConfigureTitleBar();
|
||||
|
||||
@@ -24,6 +24,7 @@ using Wino.MenuFlyouts.Context;
|
||||
using Wino.Views.Abstract;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
|
||||
#if NET8_0
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||
@@ -295,7 +296,7 @@ namespace Wino.Views
|
||||
/// </summary>
|
||||
public async void Receive(InfoBarMessageRequested message)
|
||||
{
|
||||
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
|
||||
await ViewModel.ExecuteUIThread(() =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(message.ActionButtonTitle) || message.Action == null)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Windows.Foundation;
|
||||
using Wino.Core.WinUI.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
#if NET8_0
|
||||
using Microsoft.UI.Xaml;
|
||||
@@ -11,6 +13,8 @@ namespace Wino.Controls.Advanced
|
||||
{
|
||||
public sealed partial class WinoAppTitleBar : UserControl
|
||||
{
|
||||
private IAppShellService _appShellService = App.Current.Services.GetService<IAppShellService>();
|
||||
|
||||
public event TypedEventHandler<WinoAppTitleBar, RoutedEventArgs> BackButtonClicked;
|
||||
|
||||
public string CoreWindowText
|
||||
@@ -152,11 +156,8 @@ namespace Wino.Controls.Advanced
|
||||
public WinoAppTitleBar()
|
||||
{
|
||||
InitializeComponent();
|
||||
#if NET8_0
|
||||
App.MainWindow.SetTitleBar(dragbar);
|
||||
#else
|
||||
Window.Current.SetTitleBar(dragbar);
|
||||
#endif
|
||||
|
||||
_appShellService.AppWindow.SetTitleBar(dragbar);
|
||||
}
|
||||
|
||||
private void BackClicked(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -18,6 +18,8 @@ using Wino.Core.UWP;
|
||||
using Wino.Mail.ViewModels;
|
||||
using Wino.Services;
|
||||
using Wino.Core.Services;
|
||||
using Wino.Core.WinUI.Services;
|
||||
|
||||
|
||||
#if NET8_0
|
||||
using Microsoft.UI.Xaml;
|
||||
@@ -40,6 +42,7 @@ namespace Wino
|
||||
private readonly IAppInitializerService _appInitializerService;
|
||||
private readonly IWinoSynchronizerFactory _synchronizerFactory;
|
||||
private readonly ITranslationService _translationService;
|
||||
private readonly IAppShellService _appShellService;
|
||||
|
||||
public new static App Current => (App)Application.Current;
|
||||
public IServiceProvider Services { get; }
|
||||
|
||||
@@ -11,9 +11,10 @@ using Wino.Mail.ViewModels.Messages;
|
||||
using Wino.Views;
|
||||
using Wino.Views.Account;
|
||||
using Wino.Views.Settings;
|
||||
using Wino.Core.WinUI.Services;
|
||||
|
||||
|
||||
#if NET8_0
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Media.Animation;
|
||||
#else
|
||||
@@ -27,6 +28,7 @@ namespace Wino.Services
|
||||
public class WinoNavigationService : IWinoNavigationService
|
||||
{
|
||||
private readonly IStatePersistanceService _statePersistanceService;
|
||||
private readonly IAppShellService _appShellService;
|
||||
|
||||
private WinoPage[] _renderingPageTypes = new WinoPage[]
|
||||
{
|
||||
@@ -34,9 +36,10 @@ namespace Wino.Services
|
||||
WinoPage.ComposePage
|
||||
};
|
||||
|
||||
|
||||
private Frame GetCoreFrame(NavigationReferenceFrame frameType)
|
||||
{
|
||||
if (Window.Current.Content is Frame appFrame && appFrame.Content is AppShell shellPage)
|
||||
if (_appShellService.AppWindow.Content is Frame appFrame && appFrame.Content is AppShell shellPage)
|
||||
return WinoVisualTreeHelper.GetChildObject<Frame>(shellPage, frameType.ToString());
|
||||
|
||||
return null;
|
||||
@@ -52,9 +55,10 @@ namespace Wino.Services
|
||||
}
|
||||
}
|
||||
|
||||
public WinoNavigationService(IStatePersistanceService statePersistanceService)
|
||||
public WinoNavigationService(IStatePersistanceService statePersistanceService, IAppShellService appShellService)
|
||||
{
|
||||
_statePersistanceService = statePersistanceService;
|
||||
_appShellService = appShellService;
|
||||
}
|
||||
|
||||
private Type GetPageType(WinoPage winoPage)
|
||||
|
||||
Reference in New Issue
Block a user