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-08-07 02:16:25 +08:00
|
|
|
|
_svgRenderIsEnabled = Settings.Properties.EnableSvgPreview;
|
|
|
|
|
_svgThumbnailIsEnabled = Settings.Properties.EnableSvgThumbnail;
|
|
|
|
|
_mdRenderIsEnabled = Settings.Properties.EnableMdPreview;
|
2020-04-18 06:25:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool _svgRenderIsEnabled = false;
|
|
|
|
|
private bool _mdRenderIsEnabled = false;
|
2020-07-22 07:27:12 +08:00
|
|
|
|
private bool _svgThumbnailIsEnabled = false;
|
2020-04-18 06:25:08 +08:00
|
|
|
|
|
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-07-24 02:01:49 +08:00
|
|
|
|
Settings.Properties.EnableSvgPreview = value;
|
2020-07-22 07:27:12 +08:00
|
|
|
|
RaisePropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool SVGThumbnailIsEnabled
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _svgThumbnailIsEnabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != _svgThumbnailIsEnabled)
|
|
|
|
|
{
|
|
|
|
|
_svgThumbnailIsEnabled = value;
|
2020-07-24 02:01:49 +08:00
|
|
|
|
Settings.Properties.EnableSvgThumbnail = 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-07-24 02:01:49 +08:00
|
|
|
|
Settings.Properties.EnableMdPreview = 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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|