mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 03:36:44 +02:00
Added Tests and Refactored code (#2129)
* Added Tests and Refactored code * removed un-used file * delete test files when test completes * removed extra build configs * added clean-up method * removed unused variable * re-added removed attributtion * added error handling and move strings to string resource * added error handling to file explorer view model * moved varible assignment to if statement block * removed savin of settings file from the UI * re-added open source notice * added missing controls for powerrename and fancy zones * removed dead coded * remove un-used configuration * added error handling for file saving and updated powerreanme constructor * removed added configurations * added settings state
This commit is contained in:
@@ -130,12 +130,12 @@
|
||||
HorizontalAlignment="Left"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
|
||||
|
||||
|
||||
<TextBlock x:Uid="FancyZones_ZoneHighlightColor"
|
||||
Style="{StaticResource BodyTextBlockStyle}"
|
||||
Margin="{StaticResource SmallTopMargin}" />
|
||||
|
||||
<muxc:ColorPicker x:Name="ColorChoice"
|
||||
<muxc:ColorPicker x:Name="FancyZones_ZoneHighlightColor"
|
||||
Margin="0,6,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
IsMoreButtonVisible="True"
|
||||
@@ -146,15 +146,66 @@
|
||||
IsAlphaSliderVisible="True"
|
||||
IsAlphaTextInputVisible="True"
|
||||
Color="{Binding Path=ZoneHighlightColor, Mode=TwoWay, Source={StaticResource eventViewModel}}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||
DataContext="{Binding ZoneHighlightColor, Source={StaticResource eventViewModel}}"/>
|
||||
|
||||
<Button x:Uid="FancyZones_SaveColorChoice"
|
||||
<Button x:Uid="FancyZones_SaveZoneHighlightColor"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
Style="{StaticResource AccentButtonStyle}"
|
||||
Command = "{Binding SaveColorChoiceEventHandler, Source={StaticResource eventViewModel}}"
|
||||
CommandParameter="{Binding Color, ElementName=ColorChoice}"
|
||||
Command = "{Binding SaveZoneHighlightColorEventHandler, Source={StaticResource eventViewModel}}"
|
||||
CommandParameter="{Binding Color, ElementName=FancyZones_ZoneHighlightColor}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
|
||||
|
||||
<TextBlock x:Uid="FancyZones_InActiveColor"
|
||||
Style="{StaticResource BodyTextBlockStyle}"
|
||||
Margin="{StaticResource SmallTopMargin}" />
|
||||
|
||||
<muxc:ColorPicker x:Name="FancyZones_InActiveColor"
|
||||
Margin="0,6,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
IsMoreButtonVisible="True"
|
||||
IsColorSliderVisible="True"
|
||||
IsColorChannelTextInputVisible="True"
|
||||
IsHexInputVisible="True"
|
||||
IsAlphaEnabled="True"
|
||||
IsAlphaSliderVisible="True"
|
||||
IsAlphaTextInputVisible="True"
|
||||
Color="{Binding Path=ZoneInActiveColor, Mode=TwoWay, Source={StaticResource eventViewModel}}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||
DataContext="{Binding ZoneInActiveColor, Source={StaticResource eventViewModel}}"/>
|
||||
|
||||
<Button x:Uid="FancyZones_SaveZoneInActiveColor"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
Style="{StaticResource AccentButtonStyle}"
|
||||
Command = "{Binding SaveInActiveColorEventHandler, Source={StaticResource eventViewModel}}"
|
||||
CommandParameter="{Binding Color, ElementName=FancyZones_InActiveColor}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
|
||||
|
||||
<TextBlock x:Uid="FancyZones_BorderColor"
|
||||
Style="{StaticResource BodyTextBlockStyle}"
|
||||
Margin="{StaticResource SmallTopMargin}" />
|
||||
|
||||
<muxc:ColorPicker x:Name="FancyZones_BorderColor"
|
||||
Margin="0,6,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
IsMoreButtonVisible="True"
|
||||
IsColorSliderVisible="True"
|
||||
IsColorChannelTextInputVisible="True"
|
||||
IsHexInputVisible="True"
|
||||
IsAlphaEnabled="True"
|
||||
IsAlphaSliderVisible="True"
|
||||
IsAlphaTextInputVisible="True"
|
||||
Color="{Binding Path=ZoneBorderColor, Mode=TwoWay, Source={StaticResource eventViewModel}}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||
DataContext="{Binding ZoneBorderColor, Source={StaticResource eventViewModel}}"/>
|
||||
|
||||
<Button x:Uid="FancyZones_SaveBorderColor"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
Style="{StaticResource AccentButtonStyle}"
|
||||
Command = "{Binding SaveBorderColorEventHandler, Source={StaticResource eventViewModel}}"
|
||||
CommandParameter="{Binding Color, ElementName=FancyZones_BorderColor}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
|
||||
|
||||
<TextBlock x:Uid="FancyZones_ExcludeApps"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
||||
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
<Page
|
||||
<Page
|
||||
x:Class="Microsoft.PowerToys.Settings.UI.Views.GeneralPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Microsoft.PowerToys.Settings.UI.Views"
|
||||
xmlns:viewModel="using:Microsoft.PowerToys.Settings.UI.ViewModels"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
<Page.Resources>
|
||||
<viewModel:GeneralViewModel x:Key="eventViewModel"/>
|
||||
</Page.Resources>
|
||||
|
||||
|
||||
<Grid ColumnSpacing="{StaticResource DefaultColumnSpacing}" RowSpacing="{StaticResource DefaultRowSpacing}">
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="LayoutVisualStates">
|
||||
@@ -40,76 +46,70 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Orientation="Vertical">
|
||||
|
||||
<ToggleSwitch Header="Run at startup" x:Name="ToggleSwitch_RunAtStartUp" Margin="{StaticResource SmallTopMargin}" Toggled="ToggleSwitch_RunAtStartUp_Toggled" />
|
||||
<StackPanel Orientation="Vertical"
|
||||
x:Name="GeneralSettingsView">
|
||||
|
||||
<muxc:RadioButtons Header="Theme" Margin="{StaticResource MediumTopMargin}">
|
||||
<RadioButton x:Name="Radio_Theme_Dark" Content="Dark" Tag="Dark" Checked="Theme_Changed"/>
|
||||
<RadioButton x:Name="Radio_Theme_Light" Content="Light" Tag="Light" Checked="Theme_Changed"/>
|
||||
<RadioButton x:Name="Radio_Theme_Default" Content="System default" Tag="System" Checked="Theme_Changed"/>
|
||||
<ToggleSwitch x:Uid="GeneralPage_ToggleSwitch_RunAtStartUp"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsOn="{Binding Mode=TwoWay, Path=Startup}"/>
|
||||
|
||||
<muxc:RadioButtons x:Uid="RadioButtons_Name_Theme" Margin="{StaticResource SmallTopMargin}">
|
||||
<RadioButton x:Uid="GeneralPage_Radio_Theme_Dark"
|
||||
Content="Dark"
|
||||
IsChecked="{ Binding Mode=TwoWay, Path=IsDarkThemeRadioButtonChecked}"/>
|
||||
|
||||
<RadioButton x:Uid="GeneralPage_Radio_Theme_Light"
|
||||
Content="Light"
|
||||
IsChecked="{ Binding Mode=TwoWay, Path=IsLightThemeRadioButtonChecked}"/>
|
||||
|
||||
<RadioButton x:Uid="GeneralPage_Radio_Theme_Default"
|
||||
Content="System default"
|
||||
IsChecked="{ Binding Mode=TwoWay, Path=IsSystemThemeRadioButtonChecked}"/>
|
||||
</muxc:RadioButtons>
|
||||
|
||||
<!--
|
||||
<TextBlock Text="Default apps" Style="{StaticResource SettingsGroupTitleStyle}"/>
|
||||
<ToggleSwitch Header="Disable telemetry" IsOn="True" Margin="0,14,0,0" />
|
||||
<TextBlock Text="PowerToys currently respects the Windows data & feedback setting" Opacity="0.8" Margin="0,0,0,0" />
|
||||
-->
|
||||
|
||||
<Button
|
||||
Content="Restart as admin"
|
||||
Margin="{StaticResource MediumTopMargin}"
|
||||
Style="{StaticResource AccentButtonStyle}"
|
||||
Click="Restart_Elevated" />
|
||||
|
||||
<!--
|
||||
<TextBlock Text="Default apps" Style="{StaticResource SubtitleTextBlockStyle}" Margin="0,34,0,8"/>
|
||||
<ComboBox Header="Shell" SelectedIndex="0" MinWidth="240" Margin="0,14,0,0">
|
||||
<ComboBoxItem>PowerShell</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<ComboBox Header="Terminal" SelectedIndex="0" MinWidth="240" Margin="0,14,0,0">
|
||||
<ComboBoxItem>Windows Console</ComboBoxItem>
|
||||
</ComboBox>
|
||||
-->
|
||||
<Button x:Uid="GeneralPage_RestartAsAdmin_Button"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
Style="{StaticResource AccentButtonStyle}"
|
||||
Command = "{Binding RestartElevatedButtonEventHandler, Source={StaticResource eventViewModel}}"
|
||||
/>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel
|
||||
x:Name="SidePanel"
|
||||
Orientation="Vertical"
|
||||
HorizontalAlignment="Left"
|
||||
Width="{StaticResource SidePanelWidth}"
|
||||
Grid.Column="1">
|
||||
<StackPanel x:Name="SidePanel"
|
||||
Orientation="Vertical"
|
||||
HorizontalAlignment="Left"
|
||||
Width="{StaticResource SidePanelWidth}"
|
||||
Grid.Column="1">
|
||||
|
||||
<TextBlock
|
||||
Text="About PowerToys"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"
|
||||
Margin="{StaticResource XSmallBottomMargin}"/>
|
||||
<TextBlock
|
||||
Text="Version 0.15.2"
|
||||
FontWeight="Bold"
|
||||
Margin="{StaticResource SmallTopMargin}" />
|
||||
<HyperlinkButton
|
||||
Content="Release notes"
|
||||
NavigateUri="https://github.com/microsoft/PowerToys/releases" />
|
||||
<Button
|
||||
Content="Check for updates"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
Style="{StaticResource AccentButtonStyle}"
|
||||
Click="CheckForUpdates_Click" />
|
||||
<HyperlinkButton
|
||||
Content="Report a bug"
|
||||
NavigateUri="https://github.com/microsoft/PowerToys/issues"
|
||||
Margin="{StaticResource MediumTopMargin}" />
|
||||
<HyperlinkButton
|
||||
Content="Request a feature"
|
||||
NavigateUri="https://github.com/microsoft/PowerToys/issues"/>
|
||||
<HyperlinkButton
|
||||
Content="Privacy statement"
|
||||
NavigateUri="http://go.microsoft.com/fwlink/?LinkId=521839" />
|
||||
<HyperlinkButton
|
||||
Content="Open-source notice"
|
||||
NavigateUri="https://github.com/microsoft/PowerToys/blob/master/NOTICE.md" />
|
||||
<TextBlock x:Uid="GeneralPage_AboutPowerToysHeader"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"
|
||||
Margin="{StaticResource XSmallBottomMargin}"/>
|
||||
|
||||
<TextBlock Text="Version 0.15.2"
|
||||
FontWeight="Bold"
|
||||
Margin="{StaticResource SmallTopMargin}" />
|
||||
|
||||
<Button x:Uid="GeneralPage_CheckForUpdates"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
Style="{StaticResource AccentButtonStyle}"
|
||||
Foreground="White"
|
||||
Command = "{Binding CheckFoUpdatesEventHandler, Source={StaticResource eventViewModel}}"
|
||||
/>
|
||||
|
||||
<HyperlinkButton x:Uid="GeneralPage_ReportAbug"
|
||||
NavigateUri="https://github.com/microsoft/PowerToys/issues"
|
||||
Margin="{StaticResource SmallTopMargin}" />
|
||||
|
||||
<HyperlinkButton x:Uid="GeneralPage_RequestAFeature_URL"
|
||||
NavigateUri="https://github.com/microsoft/PowerToys/issues"/>
|
||||
|
||||
<HyperlinkButton x:Uid="GeneralPage_PrivacyStatement_URL"
|
||||
NavigateUri=" http://go.microsoft.com/fwlink/?LinkId=521839" />
|
||||
|
||||
<HyperlinkButton x:Uid="OpenSource_Notice"
|
||||
NavigateUri="https://github.com/microsoft/PowerToys/blob/master/NOTICE.md"
|
||||
/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.PowerToys.Settings.UI.Lib;
|
||||
using Microsoft.PowerToys.Settings.UI.ViewModels;
|
||||
using Windows.System;
|
||||
using Windows.UI.Popups;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
@@ -18,9 +20,9 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
public sealed partial class GeneralPage : Page
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets view model.
|
||||
/// Gets or sets view model.
|
||||
/// </summary>
|
||||
public GeneralViewModel ViewModel { get; } = new GeneralViewModel();
|
||||
public GeneralViewModel ViewModel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GeneralPage"/> class.
|
||||
@@ -28,122 +30,10 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
/// </summary>
|
||||
public GeneralPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
this.InitializeComponent();
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
GeneralSettings settings = null;
|
||||
try
|
||||
{
|
||||
// get settings file if they exist.
|
||||
settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
|
||||
|
||||
// load and apply theme settings
|
||||
ReLoadTheme(settings.Theme);
|
||||
|
||||
// load run on start-up settings value and update the ui state.
|
||||
ToggleSwitch_RunAtStartUp.IsOn = settings.Startup;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// create settings file if one is not found.
|
||||
settings = new GeneralSettings();
|
||||
SettingsUtils.SaveSettings(settings.ToJsonString(), string.Empty);
|
||||
|
||||
// load and apply theme settings
|
||||
ReLoadTheme(settings.Theme);
|
||||
|
||||
// load run on start up ui settings value and update the ui state.
|
||||
ToggleSwitch_RunAtStartUp.IsOn = settings.Startup;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update and save theme settings to json file.
|
||||
/// </summary>
|
||||
/// <param name="themeName">theme name.</param>
|
||||
private void ReLoadTheme(string themeName)
|
||||
{
|
||||
switch (themeName.ToLower())
|
||||
{
|
||||
case "light":
|
||||
ShellPage.ShellHandler.RequestedTheme = ElementTheme.Light;
|
||||
Radio_Theme_Light.IsChecked = true;
|
||||
break;
|
||||
case "dark":
|
||||
ShellPage.ShellHandler.RequestedTheme = ElementTheme.Dark;
|
||||
Radio_Theme_Dark.IsChecked = true;
|
||||
break;
|
||||
case "system":
|
||||
ShellPage.ShellHandler.RequestedTheme = ElementTheme.Default;
|
||||
Radio_Theme_Default.IsChecked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleSwitch_RunAtStartUp_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ToggleSwitch swt = sender as ToggleSwitch;
|
||||
|
||||
if (swt != null)
|
||||
{
|
||||
GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
|
||||
|
||||
string startup = swt.IsOn.ToString().ToLower();
|
||||
switch (startup)
|
||||
{
|
||||
case "true":
|
||||
settings.Startup = true;
|
||||
break;
|
||||
case "false":
|
||||
settings.Startup = false;
|
||||
break;
|
||||
}
|
||||
|
||||
SettingsUtils.SaveSettings(settings.ToJsonString(), string.Empty);
|
||||
OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings);
|
||||
|
||||
if (ShellPage.DefaultSndMSGCallback != null)
|
||||
{
|
||||
ShellPage.DefaultSndMSGCallback(outsettings.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Restart_Elevated(object sender, RoutedEventArgs e)
|
||||
{
|
||||
GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
|
||||
settings.RunElevated = true;
|
||||
OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings);
|
||||
|
||||
if (ShellPage.DefaultSndMSGCallback != null)
|
||||
{
|
||||
ShellPage.DefaultSndMSGCallback(outsettings.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void Theme_Changed(object sender, RoutedEventArgs e)
|
||||
{
|
||||
RadioButton rb = sender as RadioButton;
|
||||
|
||||
if (rb != null)
|
||||
{
|
||||
string themeName = rb.Tag.ToString();
|
||||
ReLoadTheme(themeName);
|
||||
|
||||
// update and save settings to file.
|
||||
GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
|
||||
settings.Theme = themeName;
|
||||
SettingsUtils.SaveSettings(settings.ToJsonString(), string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
private async void CheckForUpdates_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await Launcher.LaunchUriAsync(new Uri("https://github.com/microsoft/PowerToys/releases"));
|
||||
this.ViewModel = new GeneralViewModel();
|
||||
this.GeneralSettingsView.DataContext = this.ViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,40 +38,36 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Text="These settings allow you to manage your Windows File Explorer Addons."
|
||||
|
||||
<StackPanel Orientation="Vertical"
|
||||
x:Name="PowerPreviewSettingsView">
|
||||
<TextBlock x:Uid="FileExplorerPreview_Description"
|
||||
TextWrapping="Wrap"/>
|
||||
|
||||
<ToggleSwitch Header="Svg Preview Handler"
|
||||
x:Name="ToggleSwitch_Preview_SVG"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
Toggled="ToggleSwitch_Preview_SVG_Toggled" />
|
||||
<ToggleSwitch x:Uid="FileEplorerPreview_ToggleSwitch_Preview_SVG"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsOn="{Binding Mode=TwoWay, Path=SVGRenderIsEnebled}" />
|
||||
|
||||
<ToggleSwitch Header="Markdown Preview Handler"
|
||||
x:Name="ToggleSwitch_Preview_MD"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
Toggled="ToggleSwitch_Preview_MD_Toggled" />
|
||||
<ToggleSwitch x:Uid="FileEplorerPreview_ToggleSwitch_Preview_MD"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsOn="{Binding Mode=TwoWay, Path=MDRenderIsEnebled}" />
|
||||
|
||||
</StackPanel>
|
||||
<StackPanel
|
||||
x:Name="SidePanel"
|
||||
Orientation="Vertical"
|
||||
HorizontalAlignment="Left"
|
||||
Width="{StaticResource SidePanelWidth}"
|
||||
Grid.Column="1">
|
||||
<StackPanel x:Name="SidePanel"
|
||||
Orientation="Vertical"
|
||||
HorizontalAlignment="Left"
|
||||
Width="{StaticResource SidePanelWidth}"
|
||||
Grid.Column="1">
|
||||
|
||||
<TextBlock
|
||||
Text="About this feature"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"
|
||||
Margin="{StaticResource XSmallBottomMargin}"/>
|
||||
<TextBlock x:Uid="About_This_Feature"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"
|
||||
Margin="{StaticResource XSmallBottomMargin}"/>
|
||||
|
||||
<HyperlinkButton
|
||||
Content="Module overview"
|
||||
NavigateUri="https://github.com/microsoft/PowerToys/tree/master/src/modules/previewpane"/>
|
||||
<HyperlinkButton
|
||||
Content="Give feedback"
|
||||
NavigateUri="https://github.com/microsoft/PowerToys/issues"/>
|
||||
<HyperlinkButton x:Uid="Module_overview"
|
||||
NavigateUri="https://github.com/microsoft/PowerToys/tree/master/src/modules/previewpane"/>
|
||||
|
||||
<HyperlinkButton x:Uid="Give_Feedback"
|
||||
NavigateUri="https://github.com/microsoft/PowerToys/issues"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -2,7 +2,9 @@
|
||||
// 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 Microsoft.PowerToys.Settings.UI.Lib;
|
||||
using Microsoft.PowerToys.Settings.UI.ViewModels;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
@@ -14,67 +16,13 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
/// </summary>
|
||||
public sealed partial class PowerPreviewPage : Page
|
||||
{
|
||||
private const string PreviewPaneKey = "File Explorer Preview";
|
||||
public PowerPreviewViewModel viewModel { get; set; }
|
||||
|
||||
public PowerPreviewPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
PowerPreviewSettings settings;
|
||||
try
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
settings = SettingsUtils.GetSettings<PowerPreviewSettings>(PreviewPaneKey);
|
||||
ToggleSwitch_Preview_SVG.IsOn = settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.Value;
|
||||
ToggleSwitch_Preview_MD.IsOn = settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.Value;
|
||||
}
|
||||
catch
|
||||
{
|
||||
settings = new PowerPreviewSettings(PreviewPaneKey);
|
||||
SettingsUtils.SaveSettings(settings.ToJsonString(), PreviewPaneKey);
|
||||
ToggleSwitch_Preview_SVG.IsOn = settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.Value;
|
||||
ToggleSwitch_Preview_MD.IsOn = settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleSwitch_Preview_SVG_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ToggleSwitch swt = sender as ToggleSwitch;
|
||||
|
||||
if (swt != null)
|
||||
{
|
||||
PowerPreviewSettings settings = SettingsUtils.GetSettings<PowerPreviewSettings>(PreviewPaneKey);
|
||||
settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.Value = swt.IsOn;
|
||||
|
||||
if (ShellPage.DefaultSndMSGCallback != null)
|
||||
{
|
||||
SndPowerPreviewSettings snd = new SndPowerPreviewSettings(settings);
|
||||
SndModuleSettings<SndPowerPreviewSettings> ipcMessage = new SndModuleSettings<SndPowerPreviewSettings>(snd);
|
||||
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleSwitch_Preview_MD_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ToggleSwitch swt = sender as ToggleSwitch;
|
||||
|
||||
if (swt != null)
|
||||
{
|
||||
PowerPreviewSettings settings = SettingsUtils.GetSettings<PowerPreviewSettings>(PreviewPaneKey);
|
||||
settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.Value = swt.IsOn;
|
||||
|
||||
if (ShellPage.DefaultSndMSGCallback != null)
|
||||
{
|
||||
SndPowerPreviewSettings snd = new SndPowerPreviewSettings(settings);
|
||||
SndModuleSettings<SndPowerPreviewSettings> ipcMessage = new SndModuleSettings<SndPowerPreviewSettings>(snd);
|
||||
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
||||
}
|
||||
}
|
||||
this.InitializeComponent();
|
||||
viewModel = new PowerPreviewViewModel();
|
||||
this.PowerPreviewSettingsView.DataContext = viewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,74 +39,81 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Text="A Windows Shell Extension for more advanced bulk renaming using search and replace or regular expressions."
|
||||
<StackPanel Orientation="Vertical"
|
||||
x:Name="PowerRenameSettingsView">
|
||||
|
||||
<TextBlock x:Uid="PowerRename_Description"
|
||||
TextWrapping="Wrap"/>
|
||||
|
||||
<ToggleSwitch x:Name="Toggle_PowerRename_Enable"
|
||||
Header="Enable PowerRename"
|
||||
<ToggleSwitch x:Uid="PowerRename_Toggle_Enable"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
Toggled="Toggle_PowerRename_Enable_Toggled"
|
||||
IsOn="{Binding Mode=TwoWay, Path=IsEnabled}"
|
||||
/>
|
||||
|
||||
<TextBlock Text="Shell integration"
|
||||
<ToggleSwitch x:Uid="PowerRename_Toggle_AutoComplete"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsOn="{Binding Mode=TwoWay, Path=MRUEnabled}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||
/>
|
||||
|
||||
<TextBlock x:Uid="PowerRename_ShellIntergration"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
||||
|
||||
<ToggleSwitch x:Name="Toggle_PowerRename_EnableOnContextMenu"
|
||||
Header="Show on default context menu"
|
||||
<ToggleSwitch x:Uid="PowerRename_Toggle_EnableOnContextMenu"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
Toggled="Toggle_PowerRename_EnableOnContextMenu_Toggled"
|
||||
IsOn="{Binding Mode=TwoWay, Path=EnabledOnContextMenu}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||
/>
|
||||
|
||||
<ToggleSwitch x:Name="Toggle_PowerRename_EnableOnExtendedContextMenu"
|
||||
Header="Only show on extended context menu (Shift + Right-click)"
|
||||
<ToggleSwitch x:Uid="PowerRename_Toggle_EnableOnExtendedContextMenu"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
Toggled="Toggle_PowerRename_EnableOnExtendedContextMenu_Toggled"
|
||||
IsOn="{Binding Mode=TwoWay, Path=EnabledOnContextExtendedMenu}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||
/>
|
||||
|
||||
<TextBlock Text="Miscellaneous"
|
||||
<TextBlock x:Uid="Miscellaneous"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
||||
|
||||
<ToggleSwitch x:Name="Toggle_PowerRename_RestoreFlagsOnLaunch"
|
||||
Header="Restore search, replace and flags values on launch from previous run"
|
||||
<ToggleSwitch x:Uid="PowerRename_Toggle_RestoreFlagsOnLaunch"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
Toggled="Toggle_PowerRename_RestoreFlagsOnLaunch_Toggled"
|
||||
IsOn="{Binding Mode=TwoWay, Path=RestoreFlagsOnLaunch}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||
/>
|
||||
|
||||
<muxc:NumberBox x:Name="Toggle_PowerRename_MaxDispListNum"
|
||||
Header="Maximum numbers of items to show in recently used list"
|
||||
<muxc:NumberBox x:Name="PowerRename_Toggle_MaxDispListNum"
|
||||
SpinButtonPlacementMode="Inline"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
ValueChanged="Toggle_PowerRename_MaxDispListNum_ValueChanged"
|
||||
Value="{Binding Mode=TwoWay, Path=MaxDispListNum}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||
/>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
<StackPanel
|
||||
x:Name="SidePanel"
|
||||
Orientation="Vertical"
|
||||
HorizontalAlignment="Left"
|
||||
Width="{StaticResource SidePanelWidth}"
|
||||
Grid.Column="1">
|
||||
|
||||
|
||||
<StackPanel x:Name="SidePanel"
|
||||
Orientation="Vertical"
|
||||
HorizontalAlignment="Left"
|
||||
Width="{StaticResource SidePanelWidth}"
|
||||
Grid.Column="1">
|
||||
|
||||
<TextBlock x:Uid="About_This_Feature"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"
|
||||
Margin="{StaticResource XSmallBottomMargin}"/>
|
||||
|
||||
<HyperlinkButton x:Uid="Module_overview"
|
||||
NavigateUri="https://github.com/microsoft/PowerToys/tree/master/src/modules/powerrename"/>
|
||||
|
||||
<HyperlinkButton x:Uid="Give_Feedback"
|
||||
NavigateUri="https://github.com/microsoft/PowerToys/issues"/>
|
||||
|
||||
|
||||
<TextBlock
|
||||
Text="About this feature"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"
|
||||
Margin="{StaticResource XSmallBottomMargin}"/>
|
||||
|
||||
<HyperlinkButton
|
||||
Content="Module overview"
|
||||
NavigateUri="https://github.com/microsoft/PowerToys/tree/master/src/modules/powerrename"/>
|
||||
|
||||
<TextBlock
|
||||
Text="Attribution"
|
||||
x:Uid="AttributionTitle"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}" />
|
||||
|
||||
<HyperlinkButton
|
||||
Content="Chris Davis's SmartRenamer"
|
||||
NavigateUri="https://github.com/chrdavis/SmartRename" />
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -14,128 +14,14 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
{
|
||||
public sealed partial class PowerRenamePage : Page
|
||||
{
|
||||
public PowerRenameViewModel ViewModel { get; } = new PowerRenameViewModel();
|
||||
|
||||
private const string POWERTOYNAME = "PowerRename";
|
||||
public PowerRenameViewModel ViewModel { get; set; }
|
||||
|
||||
public PowerRenamePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
this.InitializeComponent();
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
PowerRenameSettings settings;
|
||||
try
|
||||
{
|
||||
settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
|
||||
UpdateView(settings);
|
||||
}
|
||||
catch
|
||||
{
|
||||
settings = new PowerRenameSettings(POWERTOYNAME);
|
||||
SettingsUtils.SaveSettings(settings.ToJsonString(), POWERTOYNAME);
|
||||
UpdateView(settings);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateView(PowerRenameSettings settings)
|
||||
{
|
||||
Toggle_PowerRename_Enable.IsOn = settings.properties.MruEnabled.Value;
|
||||
Toggle_PowerRename_EnableOnExtendedContextMenu.IsOn = settings.properties.ShowExtendedMenu.Value;
|
||||
Toggle_PowerRename_MaxDispListNum.Value = settings.properties.MaxMruSize.Value;
|
||||
Toggle_PowerRename_EnableOnContextMenu.IsOn = settings.properties.ShowIconInMenu.Value;
|
||||
Toggle_PowerRename_RestoreFlagsOnLaunch.IsOn = settings.properties.PersistInput.Value;
|
||||
}
|
||||
|
||||
private void Toggle_PowerRename_Enable_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ToggleSwitch swt = sender as ToggleSwitch;
|
||||
|
||||
if (swt != null)
|
||||
{
|
||||
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
|
||||
settings.properties.MruEnabled.Value = swt.IsOn;
|
||||
|
||||
if (ShellPage.DefaultSndMSGCallback != null)
|
||||
{
|
||||
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
|
||||
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(snd);
|
||||
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Toggle_PowerRename_EnableOnContextMenu_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ToggleSwitch swt = sender as ToggleSwitch;
|
||||
|
||||
if (swt != null)
|
||||
{
|
||||
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
|
||||
settings.properties.ShowIconInMenu.Value = swt.IsOn;
|
||||
|
||||
if (ShellPage.DefaultSndMSGCallback != null)
|
||||
{
|
||||
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
|
||||
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(snd);
|
||||
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Toggle_PowerRename_EnableOnExtendedContextMenu_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ToggleSwitch swt = sender as ToggleSwitch;
|
||||
|
||||
if (swt != null)
|
||||
{
|
||||
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
|
||||
settings.properties.ShowExtendedMenu.Value = swt.IsOn;
|
||||
|
||||
if (ShellPage.DefaultSndMSGCallback != null)
|
||||
{
|
||||
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
|
||||
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(snd);
|
||||
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Toggle_PowerRename_RestoreFlagsOnLaunch_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ToggleSwitch swt = sender as ToggleSwitch;
|
||||
|
||||
if (swt != null)
|
||||
{
|
||||
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
|
||||
settings.properties.PersistInput.Value = swt.IsOn;
|
||||
|
||||
if (ShellPage.DefaultSndMSGCallback != null)
|
||||
{
|
||||
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
|
||||
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(snd);
|
||||
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Toggle_PowerRename_MaxDispListNum_ValueChanged(NumberBox sender, NumberBoxValueChangedEventArgs args)
|
||||
{
|
||||
if (sender != null)
|
||||
{
|
||||
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
|
||||
settings.properties.MaxMruSize.Value = Convert.ToInt32(sender.Value);
|
||||
|
||||
if (ShellPage.DefaultSndMSGCallback != null)
|
||||
{
|
||||
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
|
||||
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(snd);
|
||||
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
||||
}
|
||||
}
|
||||
ViewModel = new PowerRenameViewModel();
|
||||
this.PowerRenameSettingsView.DataContext = ViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user