mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
50 lines
1.9 KiB
C#
50 lines
1.9 KiB
C#
|
|
// Copyright (c) Microsoft Corporation
|
|||
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|||
|
|
// See the LICENSE file in the project root for more information.
|
|||
|
|
|
|||
|
|
using System;
|
|||
|
|
using System.Linq;
|
|||
|
|
using FileLocksmithUI.Helpers;
|
|||
|
|
using ManagedCommon;
|
|||
|
|
using Microsoft.UI.Dispatching;
|
|||
|
|
using Microsoft.UI.Xaml;
|
|||
|
|
|
|||
|
|
namespace FileLocksmithUI
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Provides application-specific behavior to supplement the default Application class.
|
|||
|
|
/// </summary>
|
|||
|
|
public partial class App : Application
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Initializes a new instance of the <see cref="App"/> class.
|
|||
|
|
/// Initializes the singleton application object. This is the first line of authored code
|
|||
|
|
/// executed, and as such is the logical equivalent of main() or WinMain().
|
|||
|
|
/// </summary>
|
|||
|
|
public App()
|
|||
|
|
{
|
|||
|
|
this.InitializeComponent();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Invoked when the application is launched normally by the end user. Other entry points
|
|||
|
|
/// will be used such as when the application is launched to open a specific file.
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="args">Details about the launch request and process.</param>
|
|||
|
|
protected override void OnLaunched(LaunchActivatedEventArgs args)
|
|||
|
|
{
|
|||
|
|
if (PowerToys.GPOWrapper.GPOWrapper.GetConfiguredFileLocksmithEnabledValue() == PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
|
|||
|
|
{
|
|||
|
|
Logger.LogWarning("Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.");
|
|||
|
|
Environment.Exit(0); // Current.Exit won't work until there's a window opened.
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_window = new MainWindow(Environment.GetCommandLineArgs().Contains("--elevated"));
|
|||
|
|
_window.Activate();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private Window _window;
|
|||
|
|
}
|
|||
|
|
}
|