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 Microsoft.PowerToys.Settings.UI.Lib;
|
2020-03-30 17:02:25 +08:00
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
using Windows.UI.Xaml.Controls;
|
|
|
|
|
using Windows.UI.Xaml.Navigation;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Views
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// An empty page that can be used on its own or navigated to within a Frame.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed partial class PowerPreviewPage : Page
|
|
|
|
|
{
|
2020-04-11 06:22:07 +08:00
|
|
|
|
private const string PreviewPaneKey = "File Explorer Preview";
|
2020-03-30 17:02:25 +08:00
|
|
|
|
|
|
|
|
|
public PowerPreviewPage()
|
|
|
|
|
{
|
2020-04-11 06:22:07 +08:00
|
|
|
|
InitializeComponent();
|
2020-03-30 17:02:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
protected override void OnNavigatedTo(NavigationEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
PowerPreviewSettings settings;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
base.OnNavigatedTo(e);
|
2020-04-11 06:22:07 +08:00
|
|
|
|
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;
|
2020-03-30 17:02:25 +08:00
|
|
|
|
}
|
2020-04-08 01:19:14 +08:00
|
|
|
|
catch
|
2020-03-30 17:02:25 +08:00
|
|
|
|
{
|
2020-04-11 06:22:07 +08:00
|
|
|
|
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;
|
2020-03-30 17:02:25 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ToggleSwitch_Preview_SVG_Toggled(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ToggleSwitch swt = sender as ToggleSwitch;
|
|
|
|
|
|
|
|
|
|
if (swt != null)
|
|
|
|
|
{
|
2020-04-11 06:22:07 +08:00
|
|
|
|
PowerPreviewSettings settings = SettingsUtils.GetSettings<PowerPreviewSettings>(PreviewPaneKey);
|
2020-03-30 17:02:25 +08:00
|
|
|
|
settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.value = swt.IsOn;
|
|
|
|
|
|
2020-04-08 01:19:14 +08:00
|
|
|
|
if (ShellPage.DefaultSndMSGCallback != null)
|
2020-03-30 17:02:25 +08:00
|
|
|
|
{
|
2020-04-02 21:08:56 +08:00
|
|
|
|
SndPowerPreviewSettings snd = new SndPowerPreviewSettings(settings);
|
|
|
|
|
SndModuleSettings<SndPowerPreviewSettings> ipcMessage = new SndModuleSettings<SndPowerPreviewSettings>(snd);
|
2020-04-08 01:19:14 +08:00
|
|
|
|
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
2020-03-30 17:02:25 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ToggleSwitch_Preview_MD_Toggled(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ToggleSwitch swt = sender as ToggleSwitch;
|
|
|
|
|
|
|
|
|
|
if (swt != null)
|
|
|
|
|
{
|
2020-04-11 06:22:07 +08:00
|
|
|
|
PowerPreviewSettings settings = SettingsUtils.GetSettings<PowerPreviewSettings>(PreviewPaneKey);
|
2020-03-30 17:02:25 +08:00
|
|
|
|
settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.value = swt.IsOn;
|
|
|
|
|
|
2020-04-08 01:19:14 +08:00
|
|
|
|
if (ShellPage.DefaultSndMSGCallback != null)
|
2020-03-30 17:02:25 +08:00
|
|
|
|
{
|
2020-04-02 21:08:56 +08:00
|
|
|
|
SndPowerPreviewSettings snd = new SndPowerPreviewSettings(settings);
|
|
|
|
|
SndModuleSettings<SndPowerPreviewSettings> ipcMessage = new SndModuleSettings<SndPowerPreviewSettings>(snd);
|
2020-04-08 01:19:14 +08:00
|
|
|
|
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
2020-03-30 17:02:25 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|