[Settings UI] Updated General Settings (#2676)

* updated general settings view

* moved text to string resource

* Update App.xaml.cs

* set run-elevated as a start-up argument
This commit is contained in:
Lavius Motileng
2020-05-05 10:02:31 -07:00
committed by GitHub
parent 67b2f28064
commit a722ce460c
11 changed files with 411 additions and 47 deletions

View File

@@ -58,6 +58,27 @@
Margin="{StaticResource SmallTopMargin}"
IsOn="{Binding Mode=TwoWay, Path=AutoDownloadUpdates, Source={StaticResource eventViewModel}}"/>
<TextBlock Text="{Binding Mode=TwoWay, Path=RunningAsAdminText, Source={StaticResource eventViewModel}}"
Style="{StaticResource SettingsGroupTitleStyle}"
Margin="{StaticResource MediumTopMargin}"/>
<ToggleSwitch Margin="{StaticResource SmallTopMargin}"
Header="{Binding Mode=TwoWay, Path=AlwaysRunAsAdminText, Source={StaticResource eventViewModel}}"
IsEnabled="{Binding Mode=TwoWay, Path=IsElevated, Source={StaticResource eventViewModel}}"
IsOn="{Binding Mode=TwoWay, Path=RunElevated, Source={StaticResource eventViewModel}}"/>
<Button x:Uid="GeneralPage_RestartAsAdmin_Button"
Margin="{StaticResource SmallTopMargin}"
Style="{StaticResource AccentButtonStyle}"
Command = "{Binding RestartElevatedButtonEventHandler, Source={StaticResource eventViewModel}}"
IsEnabled="{Binding Mode=TwoWay, Path=IsAdminButtonEnabled, Source={StaticResource eventViewModel}}"
/>
<TextBlock x:Uid="Appearancce_GroupSettings"
Style="{StaticResource SettingsGroupTitleStyle}"
Margin="{StaticResource MediumTopMargin}"/>
<muxc:RadioButtons x:Uid="RadioButtons_Name_Theme" Margin="{StaticResource SmallTopMargin}">
<RadioButton x:Uid="GeneralPage_Radio_Theme_Dark"
Content="Dark"
@@ -71,12 +92,6 @@
Content="System default"
IsChecked="{ Binding Mode=TwoWay, Path=IsSystemThemeRadioButtonChecked, Source={StaticResource eventViewModel}}"/>
</muxc:RadioButtons>
<Button x:Uid="GeneralPage_RestartAsAdmin_Button"
Margin="{StaticResource SmallTopMargin}"
Style="{StaticResource AccentButtonStyle}"
Command = "{Binding RestartElevatedButtonEventHandler, Source={StaticResource eventViewModel}}"
/>
</StackPanel>
<StackPanel x:Name="SidePanel"

View File

@@ -24,15 +24,22 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public static ShellPage ShellHandler { get; set; }
/// <summary>
/// Gets or sets iPC callback function for run on start up.
/// Gets or sets iPC default callback function.
/// </summary>
public static IPCMessageCallback DefaultSndMSGCallback { get; set; }
/// <summary>
/// Gets or sets iPC callback function for restart as admin.
/// </summary>
public static IPCMessageCallback SndRestartAsAdminMsgCallback { get; set; }
/// <summary>
/// Gets view model.
/// </summary>
public ShellViewModel ViewModel { get; } = new ShellViewModel();
public static bool IsElevated { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="ShellPage"/> class.
/// Shell page constructor.
@@ -48,12 +55,31 @@ namespace Microsoft.PowerToys.Settings.UI.Views
}
/// <summary>
/// Run on start up callback function elevated initialization.
/// Set Default IPC Message callback function.
/// </summary>
/// <param name="implmentation">delegate function implementation.</param>
public void SetDefaultSndMessageCallback(IPCMessageCallback implmentation)
{
DefaultSndMSGCallback = implmentation;
}
/// <summary>
/// Set restart as admin IPC callback function.
/// </summary>
/// <param name="implmentation">delegate function implementation.</param>
public void SetRestartAdminSndMessageCallback(IPCMessageCallback implmentation)
{
SndRestartAsAdminMsgCallback = implmentation;
}
public void SetElevationStatus(bool isElevated)
{
IsElevated = isElevated;
}
public void Refresh()
{
shellFrame.Navigate(typeof(GeneralPage));
}
}
}