787a6e9f48
UI navigation framework Related Work Items: #408, #414, #416
67 lines
2.0 KiB
C#
67 lines
2.0 KiB
C#
using FoxTube.Services;
|
|
using System;
|
|
using Windows.ApplicationModel.Core;
|
|
using Windows.Security.Credentials;
|
|
using Windows.UI;
|
|
using Windows.UI.ViewManagement;
|
|
|
|
namespace FoxTube.Utils
|
|
{
|
|
public static class Utils
|
|
{
|
|
/// <summary>
|
|
/// Terminates current application session
|
|
/// </summary>
|
|
public static void CloseApp() =>
|
|
CoreApplication.Exit();
|
|
|
|
/// <summary>
|
|
/// Restarts application
|
|
/// </summary>
|
|
public static void RestartApp() =>
|
|
RestartApp(null);
|
|
|
|
/// <summary>
|
|
/// Restarts application with specified parameters
|
|
/// </summary>
|
|
/// <param name="args">Parameters which will be provided to new application instance</param>
|
|
public static async void RestartApp(string args) =>
|
|
await CoreApplication.RequestRestartAsync(args ?? "");
|
|
|
|
public static async void InitializeFailsafeProtocol()
|
|
{
|
|
Metrics.AddEvent("Failsafe protocol initiated");
|
|
await StorageService.ClearStorage();
|
|
PasswordVault passwordVault = new PasswordVault();
|
|
foreach (PasswordCredential credential in passwordVault.RetrieveAll())
|
|
passwordVault.Remove(credential);
|
|
RestartApp();
|
|
}
|
|
|
|
public static void UpdateTitleBarTheme(bool isDark)
|
|
{
|
|
ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
|
|
titleBar.ButtonBackgroundColor = Colors.Transparent;
|
|
titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
|
|
titleBar.ButtonInactiveForegroundColor = Colors.Gray;
|
|
|
|
if (isDark)
|
|
{
|
|
titleBar.ButtonForegroundColor =
|
|
titleBar.ButtonHoverForegroundColor =
|
|
titleBar.ButtonPressedForegroundColor = Colors.White;
|
|
titleBar.ButtonHoverBackgroundColor = Color.FromArgb(50, 255, 255, 255);
|
|
titleBar.ButtonPressedBackgroundColor = Color.FromArgb(30, 255, 255, 255);
|
|
}
|
|
else
|
|
{
|
|
titleBar.ButtonForegroundColor =
|
|
titleBar.ButtonHoverForegroundColor =
|
|
titleBar.ButtonPressedForegroundColor = Colors.Black;
|
|
titleBar.ButtonHoverBackgroundColor = Color.FromArgb(50, 0, 0, 0);
|
|
titleBar.ButtonPressedBackgroundColor = Color.FromArgb(70, 0, 0, 0);
|
|
}
|
|
}
|
|
}
|
|
}
|