2020-04-18 06:25:08 +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.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
|
|
|
|
|
{
|
2020-04-27 08:34:03 +08:00
|
|
|
|
private const string ModuleName = "File Explorer";
|
2020-04-18 06:25:08 +08:00
|
|
|
|
|
|
|
|
|
private PowerPreviewSettings Settings { get; set; }
|
|
|
|
|
|
|
|
|
|
public PowerPreviewViewModel()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Settings = SettingsUtils.GetSettings<PowerPreviewSettings>(ModuleName);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
Settings = new PowerPreviewSettings();
|
|
|
|
|
SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-09 07:12:37 +08:00
|
|
|
|
this._svgRenderIsEnabled = Settings.properties.EnableSvg;
|
|
|
|
|
this._mdRenderIsEnabled = Settings.properties.EnableMd;
|
2020-04-18 06:25:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool _svgRenderIsEnabled = false;
|
|
|
|
|
private bool _mdRenderIsEnabled = false;
|
|
|
|
|
|
2020-05-03 18:17:06 +08:00
|
|
|
|
public bool SVGRenderIsEnabled
|
2020-04-18 06:25:08 +08:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _svgRenderIsEnabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != _svgRenderIsEnabled)
|
|
|
|
|
{
|
|
|
|
|
_svgRenderIsEnabled = value;
|
2020-05-09 07:12:37 +08:00
|
|
|
|
Settings.properties.EnableSvg = value;
|
2020-04-18 06:25:08 +08:00
|
|
|
|
RaisePropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-03 18:17:06 +08:00
|
|
|
|
public bool MDRenderIsEnabled
|
2020-04-18 06:25:08 +08:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _mdRenderIsEnabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != _mdRenderIsEnabled)
|
|
|
|
|
{
|
|
|
|
|
_mdRenderIsEnabled = value;
|
2020-05-09 07:12:37 +08:00
|
|
|
|
Settings.properties.EnableMd = value;
|
2020-04-18 06:25:08 +08:00
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|