2020-04-08 01:19:14 +08:00
|
|
|
|
// 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 System;
|
|
|
|
|
using Microsoft.PowerToys.Settings.UI.Lib;
|
2020-04-02 21:08:56 +08:00
|
|
|
|
using Microsoft.PowerToys.Settings.UI.ViewModels;
|
|
|
|
|
using Microsoft.UI.Xaml.Controls;
|
2020-03-27 23:58:53 +08:00
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
using Windows.UI.Xaml.Controls;
|
|
|
|
|
using Windows.UI.Xaml.Navigation;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Views
|
|
|
|
|
{
|
|
|
|
|
public sealed partial class PowerRenamePage : Page
|
|
|
|
|
{
|
|
|
|
|
public PowerRenameViewModel ViewModel { get; } = new PowerRenameViewModel();
|
2020-04-08 01:19:14 +08:00
|
|
|
|
|
|
|
|
|
private const string POWERTOYNAME = "PowerRename";
|
2020-03-27 23:58:53 +08:00
|
|
|
|
|
|
|
|
|
public PowerRenamePage()
|
|
|
|
|
{
|
2020-04-11 06:22:07 +08:00
|
|
|
|
InitializeComponent();
|
2020-03-27 23:58:53 +08:00
|
|
|
|
}
|
2020-04-02 21:08:56 +08:00
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
protected override void OnNavigatedTo(NavigationEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnNavigatedTo(e);
|
|
|
|
|
PowerRenameSettings settings;
|
|
|
|
|
try
|
|
|
|
|
{
|
2020-04-08 01:19:14 +08:00
|
|
|
|
settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
|
2020-04-11 06:22:07 +08:00
|
|
|
|
UpdateView(settings);
|
2020-04-02 21:08:56 +08:00
|
|
|
|
}
|
2020-04-08 01:19:14 +08:00
|
|
|
|
catch
|
2020-04-02 21:08:56 +08:00
|
|
|
|
{
|
2020-04-08 01:19:14 +08:00
|
|
|
|
settings = new PowerRenameSettings(POWERTOYNAME);
|
|
|
|
|
SettingsUtils.SaveSettings(settings.ToJsonString(), POWERTOYNAME);
|
2020-04-11 06:22:07 +08:00
|
|
|
|
UpdateView(settings);
|
2020-04-02 21:08:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateView(PowerRenameSettings settings)
|
|
|
|
|
{
|
2020-04-11 06:22:07 +08:00
|
|
|
|
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;
|
2020-04-02 21:08:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Toggle_PowerRename_Enable_Toggled(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ToggleSwitch swt = sender as ToggleSwitch;
|
|
|
|
|
|
|
|
|
|
if (swt != null)
|
|
|
|
|
{
|
2020-04-08 01:19:14 +08:00
|
|
|
|
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
|
2020-04-11 06:22:07 +08:00
|
|
|
|
settings.properties.MruEnabled.value = swt.IsOn;
|
2020-04-02 21:08:56 +08:00
|
|
|
|
|
2020-04-08 01:19:14 +08:00
|
|
|
|
if (ShellPage.DefaultSndMSGCallback != null)
|
2020-04-02 21:08:56 +08:00
|
|
|
|
{
|
|
|
|
|
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
|
|
|
|
|
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(snd);
|
2020-04-08 01:19:14 +08:00
|
|
|
|
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
2020-04-02 21:08:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-08 01:19:14 +08:00
|
|
|
|
|
2020-04-02 21:08:56 +08:00
|
|
|
|
private void Toggle_PowerRename_EnableOnContextMenu_Toggled(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ToggleSwitch swt = sender as ToggleSwitch;
|
|
|
|
|
|
|
|
|
|
if (swt != null)
|
|
|
|
|
{
|
2020-04-08 01:19:14 +08:00
|
|
|
|
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
|
2020-04-11 06:22:07 +08:00
|
|
|
|
settings.properties.ShowIconInMenu.value = swt.IsOn;
|
2020-04-02 21:08:56 +08:00
|
|
|
|
|
2020-04-08 01:19:14 +08:00
|
|
|
|
if (ShellPage.DefaultSndMSGCallback != null)
|
2020-04-02 21:08:56 +08:00
|
|
|
|
{
|
|
|
|
|
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
|
|
|
|
|
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(snd);
|
2020-04-08 01:19:14 +08:00
|
|
|
|
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
2020-04-02 21:08:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Toggle_PowerRename_EnableOnExtendedContextMenu_Toggled(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ToggleSwitch swt = sender as ToggleSwitch;
|
|
|
|
|
|
|
|
|
|
if (swt != null)
|
|
|
|
|
{
|
2020-04-08 01:19:14 +08:00
|
|
|
|
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
|
2020-04-11 06:22:07 +08:00
|
|
|
|
settings.properties.ShowExtendedMenu.value = swt.IsOn;
|
2020-04-02 21:08:56 +08:00
|
|
|
|
|
2020-04-08 01:19:14 +08:00
|
|
|
|
if (ShellPage.DefaultSndMSGCallback != null)
|
2020-04-02 21:08:56 +08:00
|
|
|
|
{
|
|
|
|
|
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
|
|
|
|
|
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(snd);
|
2020-04-08 01:19:14 +08:00
|
|
|
|
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
2020-04-02 21:08:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Toggle_PowerRename_RestoreFlagsOnLaunch_Toggled(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ToggleSwitch swt = sender as ToggleSwitch;
|
|
|
|
|
|
|
|
|
|
if (swt != null)
|
|
|
|
|
{
|
2020-04-08 01:19:14 +08:00
|
|
|
|
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
|
2020-04-11 06:22:07 +08:00
|
|
|
|
settings.properties.PersistInput.value = swt.IsOn;
|
2020-04-02 21:08:56 +08:00
|
|
|
|
|
2020-04-08 01:19:14 +08:00
|
|
|
|
if (ShellPage.DefaultSndMSGCallback != null)
|
2020-04-02 21:08:56 +08:00
|
|
|
|
{
|
|
|
|
|
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
|
|
|
|
|
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(snd);
|
2020-04-08 01:19:14 +08:00
|
|
|
|
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
2020-04-02 21:08:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Toggle_PowerRename_MaxDispListNum_ValueChanged(NumberBox sender, NumberBoxValueChangedEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
if (sender != null)
|
|
|
|
|
{
|
2020-04-08 01:19:14 +08:00
|
|
|
|
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
|
2020-04-11 06:22:07 +08:00
|
|
|
|
settings.properties.MaxMruSize.value = Convert.ToInt32(sender.Value);
|
2020-04-02 21:08:56 +08:00
|
|
|
|
|
2020-04-08 01:19:14 +08:00
|
|
|
|
if (ShellPage.DefaultSndMSGCallback != null)
|
2020-04-02 21:08:56 +08:00
|
|
|
|
{
|
|
|
|
|
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
|
|
|
|
|
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(snd);
|
2020-04-08 01:19:14 +08:00
|
|
|
|
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
2020-04-02 21:08:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-03-27 23:58:53 +08:00
|
|
|
|
}
|
|
|
|
|
}
|