forked from zxbmmmmmmmmm/Flarum-UWP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.xaml.cs
77 lines (63 loc) · 2.5 KB
/
App.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using Windows.ApplicationModel.Activation;
using Windows.UI;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using FlarumUWP.Services;
namespace FlarumUWP
{
public sealed partial class App : Application
{
private Lazy<ActivationService> _activationService;
private ActivationService ActivationService
{
get { return _activationService.Value; }
}
public App()
{
InitializeComponent();
UnhandledException += OnAppUnhandledException;
// Deferred execution until used. Check https://docs.microsoft.com/dotnet/api/system.lazy-1 for further info on Lazy<T> class.
_activationService = new Lazy<ActivationService>(CreateActivationService);
}
protected override async void OnLaunched(LaunchActivatedEventArgs args)
{
var coreTitleBar = Windows.ApplicationModel.Core.CoreApplication.GetCurrentView().TitleBar;
var appTitleBar = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar;
coreTitleBar.ExtendViewIntoTitleBar = false;
/*coreTitleBar.ExtendViewIntoTitleBar = true;
appTitleBar.ButtonBackgroundColor = Colors.Transparent;*/
var uiSettings = new UISettings();
//appTitleBar.ButtonForegroundColor = uiSettings.GetColorValue(UIColorType.Background);
if (!args.PrelaunchActivated)
{
await ActivationService.ActivateAsync(args);
}
}
private void UpdateAccentColorForeground(FrameworkElement element)
{
var uiSettings = new UISettings();
Color c = uiSettings.GetColorValue(UIColorType.Accent);
element.RequestedTheme = ((5 * c.G + 2 * c.R + c.B) <= 8 * 128)
? ElementTheme.Light
: ElementTheme.Dark;
}
protected override async void OnActivated(IActivatedEventArgs args)
{
await ActivationService.ActivateAsync(args);
}
private void OnAppUnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e)
{
e.Handled = true;
_ = e.Message;
}
private ActivationService CreateActivationService()
{
return new ActivationService(this, typeof(Views.HomePage), new Lazy<UIElement>(CreateShell));
}
private UIElement CreateShell()
{
return new Views.ShellPage();
}
}
}