mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 19:26:39 +02:00
* Raising Telemetry events when svg and markdown preview pane is turned off * Properly serializing Bool property. This allows us to be backwards compatible with .17 settings but interact with the properties as boolean elements, and fire events on property changed notification
87 lines
2.6 KiB
C#
87 lines
2.6 KiB
C#
// 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.Runtime.CompilerServices;
|
|
using Microsoft.PowerToys.Settings.UI.Helpers;
|
|
using Microsoft.PowerToys.Settings.UI.Lib;
|
|
using Microsoft.PowerToys.Settings.UI.Views;
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|
{
|
|
public class PowerPreviewViewModel : Observable
|
|
{
|
|
private const string ModuleName = "File Explorer";
|
|
|
|
private PowerPreviewSettings Settings { get; set; }
|
|
|
|
public PowerPreviewViewModel()
|
|
{
|
|
try
|
|
{
|
|
Settings = SettingsUtils.GetSettings<PowerPreviewSettings>(ModuleName);
|
|
}
|
|
catch
|
|
{
|
|
Settings = new PowerPreviewSettings();
|
|
SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
|
|
}
|
|
|
|
this._svgRenderIsEnabled = Settings.properties.EnableSvg;
|
|
this._mdRenderIsEnabled = Settings.properties.EnableMd;
|
|
}
|
|
|
|
private bool _svgRenderIsEnabled = false;
|
|
private bool _mdRenderIsEnabled = false;
|
|
|
|
public bool SVGRenderIsEnabled
|
|
{
|
|
get
|
|
{
|
|
return _svgRenderIsEnabled;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (value != _svgRenderIsEnabled)
|
|
{
|
|
_svgRenderIsEnabled = value;
|
|
Settings.properties.EnableSvg = value;
|
|
RaisePropertyChanged();
|
|
}
|
|
}
|
|
}
|
|
|
|
public bool MDRenderIsEnabled
|
|
{
|
|
get
|
|
{
|
|
return _mdRenderIsEnabled;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (value != _mdRenderIsEnabled)
|
|
{
|
|
_mdRenderIsEnabled = value;
|
|
Settings.properties.EnableMd = value;
|
|
RaisePropertyChanged();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void RaisePropertyChanged([CallerMemberName] string propertyName = null)
|
|
{
|
|
// Notify UI of property change
|
|
OnPropertyChanged(propertyName);
|
|
|
|
if (ShellPage.DefaultSndMSGCallback != null)
|
|
{
|
|
SndPowerPreviewSettings snd = new SndPowerPreviewSettings(Settings);
|
|
SndModuleSettings<SndPowerPreviewSettings> ipcMessage = new SndModuleSettings<SndPowerPreviewSettings>(snd);
|
|
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
|
}
|
|
}
|
|
}
|
|
}
|