User/lamotile/add powerrename settings (#1813)

* added powerrename settings

* removed pop-up message

* removed unused files

* revrted changes to old settings

* updated solution file

* added ToJsonString() method

* added JSON property for the powertoy name
This commit is contained in:
Lavius Motileng 2020-04-02 06:08:56 -07:00
parent 3015ffd950
commit 89b44f5126
16 changed files with 346 additions and 125 deletions

View File

@ -194,6 +194,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.PowerToys.Settings.UI.Lib", "src\core\Microsoft.PowerToys.Settings.UI.Lib\Microsoft.PowerToys.Settings.UI.Lib.csproj", "{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test", "src\core\Test\Test.csproj", "{C266BF3A-B9B8-4047-8ADD-E22A6AE1DFFC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
@ -650,6 +652,14 @@ Global
{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Release|Any CPU.Build.0 = Release|Any CPU
{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Release|x64.ActiveCfg = Release|Any CPU
{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Release|x64.Build.0 = Release|Any CPU
{C266BF3A-B9B8-4047-8ADD-E22A6AE1DFFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C266BF3A-B9B8-4047-8ADD-E22A6AE1DFFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C266BF3A-B9B8-4047-8ADD-E22A6AE1DFFC}.Debug|x64.ActiveCfg = Debug|Any CPU
{C266BF3A-B9B8-4047-8ADD-E22A6AE1DFFC}.Debug|x64.Build.0 = Debug|Any CPU
{C266BF3A-B9B8-4047-8ADD-E22A6AE1DFFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C266BF3A-B9B8-4047-8ADD-E22A6AE1DFFC}.Release|Any CPU.Build.0 = Release|Any CPU
{C266BF3A-B9B8-4047-8ADD-E22A6AE1DFFC}.Release|x64.ActiveCfg = Release|Any CPU
{C266BF3A-B9B8-4047-8ADD-E22A6AE1DFFC}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -699,6 +709,7 @@ Global
{4EB9C181-96E2-4587-AB98-2DB84C1A2310} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
{C073B057-B157-40F0-8678-1DCD119D841C} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
{C266BF3A-B9B8-4047-8ADD-E22A6AE1DFFC} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
namespace Microsoft.PowerToys.Settings.UI.Lib
{
public abstract class BasePTModuleSettings
{
public string name { get; set; }
public string version { get; set; }
public virtual string ToJsonString()
{
return JsonSerializer.Serialize(this);
}
}
}

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
namespace Microsoft.PowerToys.Settings.UI.Lib
{
public class GeneralSettings
{
@ -30,7 +30,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
this.powertoys_version = "v0.15.3";
}
public override string ToString()
public string ToJsonString()
{
return JsonSerializer.Serialize(this);
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Microsoft.PowerToys.Settings.UI.Lib
{
public interface IPowerToySettings
{
string name { get; set; }
string version { get; set; }
string ToJsonString();
}
}

View File

@ -2,70 +2,62 @@
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib
{
/// <summary>
/// This class models the settings for the PowerPreview class.
/// Eaxmple JSON:
/// {
/// "name": "File Explorer Preview",
/// "properties": {
/// "IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL": { "value": true },
/// "PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID": { "value": true }
/// },
/// "version": "1.0"
/// }
/// </summary>
public class PowerPreviewSettings
public class PowerPreviewSettings : BasePTModuleSettings
{
public string name { get; set; }
public Properties properties { get; set; }
public string version { get; set; }
public PowerPreviewProperties properties { get; set; }
public PowerPreviewSettings()
{
this.properties = new Properties();
this.properties = new PowerPreviewProperties();
this.version = "1";
this.name = "_unset_";
}
public PowerPreviewSettings(string ptName)
{
this.properties = new Properties();
this.properties = new PowerPreviewProperties();
this.version = "1";
this.name = ptName;
}
public override string ToString()
public override string ToJsonString()
{
return "{\"" + this.name + "\":" + JsonSerializer.Serialize(this) + "}";
return JsonSerializer.Serialize(this);
}
}
public class Property
public class PowerPreviewProperties
{
public bool value { get; set; }
public BoolProperty IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL { get; set; }
public BoolProperty PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID { get; set; }
public PowerPreviewProperties()
{
this.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL = new BoolProperty();
this.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID = new BoolProperty();
}
public override string ToString()
{
return JsonSerializer.Serialize(this);
}
}
public class Properties
public class SndPowerPreviewSettings
{
public Property IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL { get; set; }
public Property PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID { get; set; }
[JsonPropertyName("File Explorer Preview")]
public PowerPreviewSettings File_Explorer_Preview { get; set; }
public Properties()
public SndPowerPreviewSettings(PowerPreviewSettings settings)
{
this.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL = new Property();
this.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID = new Property();
this.File_Explorer_Preview = settings;
}
public override string ToString()
public string ToJsonString()
{
return JsonSerializer.Serialize(this);
}

View File

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib
{
public class PowerRenameSettings : BasePTModuleSettings
{
public PowerRenameProperties properties { get; set; }
public PowerRenameSettings()
{
this.properties = new PowerRenameProperties();
this.version = "1";
this.name = "_unset_";
}
public PowerRenameSettings(string ptName)
{
this.properties = new PowerRenameProperties();
this.version = "1";
this.name = ptName;
}
public override string ToJsonString()
{
return JsonSerializer.Serialize(this);
}
}
public class PowerRenameProperties
{
public PowerRenameProperties()
{
this.bool_persist_input = new BoolProperty();
this.bool_mru_enabled = new BoolProperty();
this.int_max_mru_size = new IntProperty();
this.bool_show_icon_on_menu = new BoolProperty();
this.bool_show_extended_menu = new BoolProperty();
}
public BoolProperty bool_persist_input { get; set; }
public BoolProperty bool_mru_enabled { get; set; }
public IntProperty int_max_mru_size { get; set; }
public BoolProperty bool_show_icon_on_menu { get; set; }
public BoolProperty bool_show_extended_menu { get; set; }
}
public class SndPowerRenameSettings
{
[JsonPropertyName("PowerRename")]
public PowerRenameSettings PowerRename { get; set; }
public SndPowerRenameSettings(PowerRenameSettings settings)
{
this.PowerRename = settings;
}
public string ToJsonString()
{
return JsonSerializer.Serialize(this);
}
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
namespace Microsoft.PowerToys.Settings.UI.Lib
{
public class BoolProperty
{
public bool value { get; set; }
public override string ToString()
{
return JsonSerializer.Serialize(this);
}
}
public class IntProperty
{
public int value { get; set; }
public override string ToString()
{
return JsonSerializer.Serialize(this);
}
}
}

View File

@ -39,13 +39,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
/// Save settings to a json file.
/// </summary>
/// <param name="settings">dynamic json settings object.</param>
public static void SaveSettings<T>(T settings, string powertoy)
public static void SaveSettings(string jsonSettings, string powertoy)
{
if(settings != null)
if(jsonSettings != null)
{
System.IO.File.WriteAllText(
SettingsUtils.GetSettingsPath(powertoy),
settings.ToString());
jsonSettings.ToString());
}
}
}

View File

@ -5,24 +5,18 @@ using System.Text.Json;
namespace Microsoft.PowerToys.Settings.UI.Lib
{
/// <summary>
/// PowerToys runner expects a json text that contains one of the following attributes: refresh, general and powertoys.
/// The one for general settings is placed in the General settings model. This class represents the json text that starts with the "powertoys" attribute.
/// this will tell the runner that we are sending settings for a powertoy module and not for general settings.
/// </summary>
/// <typeparam name="M">M stands for the Model of PT Module Settings to be sent.</typeparam>
public class SndModuleSettings<M>
public class SndModuleSettings<S>
{
public M powertoys { get; set; }
public S powertoys { get; set; }
public SndModuleSettings(M ptModuleSettings)
public SndModuleSettings(S settings)
{
this.powertoys = ptModuleSettings;
this.powertoys = settings;
}
public override string ToString()
public string ToJsonString()
{
return "{\"powertoys\":" + this.powertoys.ToString() + "}";
return JsonSerializer.Serialize(this);
}
}
}

View File

@ -32,7 +32,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
{
this.InitializeComponent();
}
/// <inheritdoc/>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
@ -52,7 +52,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
{
// create settings file if one is not found.
settings = new GeneralSettings();
SettingsUtils.SaveSettings<GeneralSettings>(settings, string.Empty);
SettingsUtils.SaveSettings(settings.ToJsonString(), string.Empty);
// load and apply theme settings
this.ReLoadTheme(settings.theme);
@ -103,7 +103,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
break;
}
SettingsUtils.SaveSettings<GeneralSettings>(settings, string.Empty);
SettingsUtils.SaveSettings(settings.ToJsonString(), string.Empty);
OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings);
if (ShellPage.Default_SndMSG_Callback != null)
@ -129,16 +129,16 @@ namespace Microsoft.PowerToys.Settings.UI.Views
{
RadioButton rb = sender as RadioButton;
//if (rb != null)
//{
// string themeName = rb.Tag.ToString();
// this.ReLoadTheme(themeName);
if (rb != null)
{
string themeName = rb.Tag.ToString();
this.ReLoadTheme(themeName);
// // update and save settings to file.
// GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
// settings.theme = themeName;
// SettingsUtils.SaveSettings<GeneralSettings>(settings, string.Empty);
//}
// 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)
@ -146,4 +146,4 @@ namespace Microsoft.PowerToys.Settings.UI.Views
await Launcher.LaunchUriAsync(new Uri("https://github.com/microsoft/PowerToys/releases"));
}
}
}
}

View File

@ -46,7 +46,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
catch(Exception exp)
{
settings = new PowerPreviewSettings(POWERTOY_NAME);
SettingsUtils.SaveSettings<PowerPreviewSettings>(settings, POWERTOY_NAME);
SettingsUtils.SaveSettings(settings.ToJsonString(), POWERTOY_NAME);
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;
}
@ -61,11 +61,11 @@ namespace Microsoft.PowerToys.Settings.UI.Views
PowerPreviewSettings settings = SettingsUtils.GetSettings<PowerPreviewSettings>(POWERTOY_NAME);
settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.value = swt.IsOn;
SndModuleSettings<PowerPreviewSettings> moduleSettings = new SndModuleSettings<PowerPreviewSettings>(settings);
if (ShellPage.Default_SndMSG_Callback != null)
{
ShellPage.Default_SndMSG_Callback(moduleSettings.ToString());
SndPowerPreviewSettings snd = new SndPowerPreviewSettings(settings);
SndModuleSettings<SndPowerPreviewSettings> ipcMessage = new SndModuleSettings<SndPowerPreviewSettings>(snd);
ShellPage.Default_SndMSG_Callback(ipcMessage.ToJsonString());
}
}
}
@ -79,13 +79,14 @@ namespace Microsoft.PowerToys.Settings.UI.Views
PowerPreviewSettings settings = SettingsUtils.GetSettings<PowerPreviewSettings>(POWERTOY_NAME);
settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.value = swt.IsOn;
SndModuleSettings<PowerPreviewSettings> moduleSettings = new SndModuleSettings<PowerPreviewSettings>(settings);
if (ShellPage.Default_SndMSG_Callback != null)
{
ShellPage.Default_SndMSG_Callback(moduleSettings.ToString());
SndPowerPreviewSettings snd = new SndPowerPreviewSettings(settings);
SndModuleSettings<SndPowerPreviewSettings> ipcMessage = new SndModuleSettings<SndPowerPreviewSettings>(snd);
ShellPage.Default_SndMSG_Callback(ipcMessage.ToJsonString());
}
}
}
}
}

View File

@ -2,7 +2,6 @@
x:Class="Microsoft.PowerToys.Settings.UI.Views.PowerRenamePage"
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:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
@ -44,37 +43,43 @@
<TextBlock Text="A Windows Shell Extension for more advanced bulk renaming using search and replace or regular expressions."
TextWrapping="Wrap"/>
<ToggleSwitch Header="Enable PowerRename"
IsOn="True"
Margin="{StaticResource SmallTopMargin}" />
<ToggleSwitch x:Name="Toggle_PowerRename_Enable"
Header="Enable PowerRename"
Margin="{StaticResource SmallTopMargin}"
Toggled="Toggle_PowerRename_Enable_Toggled"
/>
<TextBlock Text="Shell integration"
Style="{StaticResource SettingsGroupTitleStyle}"/>
<TextBlock Text="Shell integration"
Style="{StaticResource SettingsGroupTitleStyle}"/>
<CheckBox Content="Show on default context menu"
IsChecked="True"
Margin="{StaticResource SmallTopMargin}"/>
<ToggleSwitch x:Name="Toggle_PowerRename_EnableOnContextMenu"
Header="Show on default context menu"
Margin="{StaticResource SmallTopMargin}"
Toggled="Toggle_PowerRename_EnableOnContextMenu_Toggled"
/>
<CheckBox Content="Only show on extended context menu (Shift + Right-click)"
IsChecked="True"
Margin="{StaticResource SmallTopMargin}" />
<ToggleSwitch x:Name="Toggle_PowerRename_EnableOnExtendedContextMenu"
Header="Only show on extended context menu (Shift + Right-click)"
Margin="{StaticResource SmallTopMargin}"
Toggled="Toggle_PowerRename_EnableOnExtendedContextMenu_Toggled"
/>
<TextBlock Text="Miscellaneous"
Style="{StaticResource SettingsGroupTitleStyle}"/>
<CheckBox Content="Enable autocomplete and autosuggest of recently used inputs for search and replace values"
IsChecked="True"
Margin="{StaticResource SmallTopMargin}"/>
<ToggleSwitch x:Name="Toggle_PowerRename_RestoreFlagsOnLaunch"
Header="Restore search, replace and flags values on launch from previous run"
Margin="{StaticResource SmallTopMargin}"
Toggled="Toggle_PowerRename_RestoreFlagsOnLaunch_Toggled"
/>
<CheckBox Content="Restore search, replace and flags values on launch from previous run"
IsChecked="True"
Margin="{StaticResource SmallTopMargin}" />
<muxc:NumberBox Header="Maximum numbers of items to show in recently used list"
Value="10"
<muxc:NumberBox x:Name="Toggle_PowerRename_MaxDispListNum"
Header="Maximum numbers of items to show in recently used list"
SpinButtonPlacementMode="Inline"
HorizontalAlignment="Left"
Margin="{StaticResource SmallTopMargin}" />
Margin="{StaticResource SmallTopMargin}"
ValueChanged="Toggle_PowerRename_MaxDispListNum_ValueChanged"
/>
</StackPanel>
@ -91,12 +96,14 @@
<HyperlinkButton Content="Module overview" NavigateUri="https://github.com/microsoft/PowerToys/tree/master/src/modules/powerrename"/>
<HyperlinkButton Content="Give feedback"/>
<!--
<TextBlock Text="Contributors"
Style="{StaticResource SettingsGroupTitleStyle}"/>
<HyperlinkButton Content="Contributor name"/>
<HyperlinkButton Content="Contributor name"/>
<HyperlinkButton Content="Contributor name"/>
-->
</StackPanel>
</Grid>
</Page>

View File

@ -1,11 +1,15 @@
using Microsoft.PowerToys.Settings.UI.ViewModels;
using Microsoft.PowerToys.Settings.UI.Lib;
using Microsoft.PowerToys.Settings.UI.ViewModels;
using Microsoft.UI.Xaml.Controls;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.ServiceModel.Channels;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
@ -19,10 +23,128 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public sealed partial class PowerRenamePage : Page
{
public PowerRenameViewModel ViewModel { get; } = new PowerRenameViewModel();
private const string POWERTOY_NAME = "PowerRename";
public PowerRenamePage()
{
this.InitializeComponent();
}
/// <inheritdoc/>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
PowerRenameSettings settings;
try
{
settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOY_NAME);
UpdateView(settings);
}
catch (Exception exp)
{
settings = new PowerRenameSettings(POWERTOY_NAME);
SettingsUtils.SaveSettings(settings.ToJsonString(), POWERTOY_NAME);
UpdateView(settings);
}
}
private void UpdateView(PowerRenameSettings settings)
{
this.Toggle_PowerRename_Enable.IsOn = settings.properties.bool_mru_enabled.value;
this.Toggle_PowerRename_EnableOnExtendedContextMenu.IsOn = settings.properties.bool_show_extended_menu.value;
this.Toggle_PowerRename_MaxDispListNum.Value = settings.properties.int_max_mru_size.value;
this.Toggle_PowerRename_EnableOnContextMenu.IsOn = settings.properties.bool_show_icon_on_menu.value;
this.Toggle_PowerRename_RestoreFlagsOnLaunch.IsOn = settings.properties.bool_persist_input.value;
}
private void Toggle_PowerRename_Enable_Toggled(object sender, RoutedEventArgs e)
{
ToggleSwitch swt = sender as ToggleSwitch;
if (swt != null)
{
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOY_NAME);
settings.properties.bool_mru_enabled.value = swt.IsOn;
if (ShellPage.Default_SndMSG_Callback != null)
{
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(snd);
ShellPage.Default_SndMSG_Callback(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>(POWERTOY_NAME);
settings.properties.bool_show_icon_on_menu.value = swt.IsOn;
if (ShellPage.Default_SndMSG_Callback != null)
{
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(snd);
ShellPage.Default_SndMSG_Callback(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>(POWERTOY_NAME);
settings.properties.bool_show_extended_menu.value = swt.IsOn;
if (ShellPage.Default_SndMSG_Callback != null)
{
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(snd);
ShellPage.Default_SndMSG_Callback(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>(POWERTOY_NAME);
settings.properties.bool_persist_input.value = swt.IsOn;
if (ShellPage.Default_SndMSG_Callback != null)
{
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(snd);
ShellPage.Default_SndMSG_Callback(ipcMessage.ToJsonString());
}
}
}
private void Toggle_PowerRename_MaxDispListNum_ValueChanged(NumberBox sender, NumberBoxValueChangedEventArgs args)
{
if (sender != null)
{
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOY_NAME);
settings.properties.int_max_mru_size.value = Convert.ToInt32(sender.Value);
if (ShellPage.Default_SndMSG_Callback != null)
{
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(snd);
ShellPage.Default_SndMSG_Callback(ipcMessage.ToJsonString());
}
}
}
}
}

View File

@ -1,21 +0,0 @@
using Microsoft.PowerToys.Settings.UI.Lib;
using Microsoft.PowerToys.Settings.UI.ViewModels;
using System;
using System.IO;
using System.Text.Json;
namespace Test
{
class Program
{
static void Main(string[] args)
{
PowerPreviewSettings pvst = new PowerPreviewSettings();
pvst.name = "File Explorer";
SndModuleSettings<PowerPreviewSettings> snd = new SndModuleSettings<PowerPreviewSettings>(pvst);
Console.WriteLine(snd.ToString());
}
}
}

View File

@ -1,12 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.PowerToys.Settings.UI.Lib\Microsoft.PowerToys.Settings.UI.Lib.csproj" />
</ItemGroup>
</Project>

View File

@ -250,7 +250,9 @@ public:
CSettings::SetMaxMRUSize(values.get_int_value(L"int_max_mru_size").value());
CSettings::SetShowIconOnMenu(values.get_bool_value(L"bool_show_icon_on_menu").value());
CSettings::SetExtendedContextMenuOnly(values.get_bool_value(L"bool_show_extended_menu").value());
values.save_to_settings_file();
Trace::SettingsChanged();
}
catch (std::exception)