show run as administrator in title (#28516)

This commit is contained in:
Davide Giacometti
2023-09-12 14:25:36 +02:00
committed by GitHub
parent baa7c7bc6c
commit b01a995062
4 changed files with 12 additions and 5 deletions

View File

@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using EnvironmentVariables.Helpers;
using EnvironmentVariables.ViewModels;
using ManagedCommon;
using Microsoft.Extensions.DependencyInjection;
@@ -42,6 +43,7 @@ namespace EnvironmentVariables
Host = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder().UseContentRoot(AppContext.BaseDirectory).ConfigureServices((context, services) =>
{
services.AddSingleton<IElevationHelper, ElevationHelper>();
services.AddTransient<MainViewModel>();
}).Build();

View File

@@ -41,8 +41,7 @@
x:Name="AppTitleTextBlock"
Grid.Column="2"
VerticalAlignment="Center"
Style="{StaticResource CaptionTextBlockStyle}"
Text="Environment Variables" />
Style="{StaticResource CaptionTextBlockStyle}" />
</Grid>
<views:MainPage Grid.Row="1" />

View File

@@ -3,8 +3,6 @@
// See the LICENSE file in the project root for more information.
using EnvironmentVariables.Helpers;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
using WinUIEx;
namespace EnvironmentVariables
@@ -22,7 +20,10 @@ namespace EnvironmentVariables
SetTitleBar(titleBar);
AppWindow.SetIcon("Assets/EnvironmentVariables/EnvironmentVariables.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;
}
}
}

View File

@@ -140,6 +140,7 @@
</data>
<data name="WindowTitle" xml:space="preserve">
<value>Environment Variables</value>
<comment>Title of the window when running as user</comment>
</data>
<data name="EditDialog.CloseButtonText" xml:space="preserve">
<value>Cancel</value>
@@ -165,4 +166,8 @@
<data name="Enabled.Header" xml:space="preserve">
<value>Enabled</value>
</data>
<data name="WindowAdminTitle" xml:space="preserve">
<value>Administrator: Environment Variables</value>
<comment>Title of the window when running as administrator</comment>
</data>
</root>