mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
[General]Display in titlebar/tray if running as admin (#28425)
* display in titlebar if running as admin * show run as admin in tray tooltip
This commit is contained in:
committed by
GitHub
parent
63975600f1
commit
ebd051ff61
@@ -6,7 +6,6 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:views="using:PowerToys.FileLocksmithUI.Views"
|
||||
xmlns:winuiex="using:WinUIEx"
|
||||
x:Uid="AppTitle"
|
||||
Width="680"
|
||||
MinWidth="480"
|
||||
MinHeight="320"
|
||||
@@ -39,7 +38,6 @@
|
||||
Height="16"/>
|
||||
<TextBlock
|
||||
x:Name="AppTitleTextBlock"
|
||||
x:Uid="AppTitleText"
|
||||
Grid.Column="2"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource CaptionTextBlockStyle}" />
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
using System;
|
||||
using Microsoft.UI.Windowing;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using PowerToys.FileLocksmithUI.Helpers;
|
||||
using WinUIEx;
|
||||
|
||||
namespace FileLocksmithUI
|
||||
@@ -21,6 +21,11 @@ namespace FileLocksmithUI
|
||||
SetTitleBar(AppTitleBar);
|
||||
Activated += MainWindow_Activated;
|
||||
AppWindow.SetIcon("Assets/FileLocksmith/Icon.ico");
|
||||
|
||||
var loader = ResourceLoaderInstance.ResourceLoader;
|
||||
var title = isElevated ? loader.GetString("AppAdminTitle") : loader.GetString("AppTitle");
|
||||
Title = title;
|
||||
AppTitleTextBlock.Text = title;
|
||||
}
|
||||
|
||||
private void MainWindow_Activated(object sender, WindowActivatedEventArgs args)
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// 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 Microsoft.Windows.ApplicationModel.Resources;
|
||||
|
||||
namespace PowerToys.FileLocksmithUI.Helpers
|
||||
{
|
||||
internal static class ResourceLoaderInstance
|
||||
{
|
||||
internal static ResourceLoader ResourceLoader { get; private set; }
|
||||
|
||||
static ResourceLoaderInstance()
|
||||
{
|
||||
ResourceLoader = new Microsoft.Windows.ApplicationModel.Resources.ResourceLoader("PowerToys.FileLocksmithUI.pri");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,11 +117,9 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="AppTitle.Title" xml:space="preserve">
|
||||
<value>File Locksmith</value>
|
||||
</data>
|
||||
<data name="AppTitleText.Text" xml:space="preserve">
|
||||
<data name="AppTitle" xml:space="preserve">
|
||||
<value>File Locksmith</value>
|
||||
<comment>Title of the window when running as user.</comment>
|
||||
</data>
|
||||
<data name="EmptyListDescription.Text" xml:space="preserve">
|
||||
<value>No results</value>
|
||||
@@ -162,4 +160,8 @@
|
||||
<data name="User.Header" xml:space="preserve">
|
||||
<value>User</value>
|
||||
</data>
|
||||
<data name="AppAdminTitle" xml:space="preserve">
|
||||
<value>Administrator: File Locksmith</value>
|
||||
<comment>Title of the window when running as administrator.</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -37,8 +37,7 @@
|
||||
x:Name="AppTitleTextBlock"
|
||||
Grid.Column="2"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
VerticalAlignment="Center"
|
||||
Text="Hosts File Editor" />
|
||||
VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
|
||||
<views:MainPage Grid.Row="1" />
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// 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 Hosts.Helpers;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
@@ -19,7 +18,11 @@ namespace Hosts
|
||||
ExtendsContentIntoTitleBar = true;
|
||||
SetTitleBar(titleBar);
|
||||
AppWindow.SetIcon("Assets/Hosts/Hosts.ico");
|
||||
Title = ResourceLoaderInstance.ResourceLoader.GetString("WindowTitle");
|
||||
|
||||
var loader = ResourceLoaderInstance.ResourceLoader;
|
||||
var title = App.GetService<IElevationHelper>().IsElevated ? loader.GetString("WindowAdminTitle") : loader.GetString("WindowTitle");
|
||||
Title = title;
|
||||
AppTitleTextBlock.Text = title;
|
||||
|
||||
BringToForeground();
|
||||
|
||||
|
||||
@@ -307,8 +307,12 @@
|
||||
<data name="WarningDialog_Title" xml:space="preserve">
|
||||
<value>Warning</value>
|
||||
</data>
|
||||
<data name="WindowAdminTitle" xml:space="preserve">
|
||||
<value>Administrator: Hosts File Editor</value>
|
||||
<comment>Title of the window when running as administrator. "Hosts File Editor" is the name of the utility. "Hosts" refers to the system hosts file, do not loc</comment>
|
||||
</data>
|
||||
<data name="WindowTitle" xml:space="preserve">
|
||||
<value>Hosts File Editor</value>
|
||||
<comment>"Hosts File Editor" is the name of the utility. "Hosts" refers to the system hosts file, do not loc</comment>
|
||||
<comment>Title of the window when running as user. "Hosts File Editor" is the name of the utility. "Hosts" refers to the system hosts file, do not loc</comment>
|
||||
</data>
|
||||
</root>
|
||||
Reference in New Issue
Block a user