PowerToys/src/settings-ui/Settings.UI.Library/PowerPreviewProperties.cs

188 lines
5.2 KiB
C#
Raw Normal View History

// 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.
2020-08-18 01:00:56 +08:00
using System.Runtime.CompilerServices;
using System.Text.Json;
using System.Text.Json.Serialization;
2020-08-18 01:00:56 +08:00
using Microsoft.PowerToys.Settings.Telemetry;
using Microsoft.PowerToys.Telemetry;
namespace Microsoft.PowerToys.Settings.UI.Library
{
public class PowerPreviewProperties
2020-08-18 01:00:56 +08:00
{
private bool enableSvgPreview = true;
[JsonPropertyName("svg-previewer-toggle-setting")]
[JsonConverter(typeof(BoolPropertyJsonConverter))]
public bool EnableSvgPreview
{
get => enableSvgPreview;
2020-08-18 01:00:56 +08:00
set
{
if (value != enableSvgPreview)
2020-08-18 01:00:56 +08:00
{
LogTelemetryEvent(value);
enableSvgPreview = value;
2020-08-18 01:00:56 +08:00
}
}
}
private bool enableSvgThumbnail = true;
[JsonPropertyName("svg-thumbnail-toggle-setting")]
[JsonConverter(typeof(BoolPropertyJsonConverter))]
public bool EnableSvgThumbnail
{
get => enableSvgThumbnail;
2020-08-18 01:00:56 +08:00
set
{
if (value != enableSvgThumbnail)
2020-08-18 01:00:56 +08:00
{
LogTelemetryEvent(value);
enableSvgThumbnail = value;
2020-08-18 01:00:56 +08:00
}
}
}
private bool enableMdPreview = true;
2020-04-08 15:19:00 +08:00
[JsonPropertyName("md-previewer-toggle-setting")]
[JsonConverter(typeof(BoolPropertyJsonConverter))]
public bool EnableMdPreview
2020-08-18 01:00:56 +08:00
{
get => enableMdPreview;
2020-08-18 01:00:56 +08:00
set
{
if (value != enableMdPreview)
2020-08-18 01:00:56 +08:00
{
LogTelemetryEvent(value);
enableMdPreview = value;
2020-08-18 01:00:56 +08:00
}
}
}
Preview Handler for developer files (#15138) * Create Readme.md * Update Readme.md * Rebased to master * started integrating * Resolve merge conflict * Fixed merge conflict * Edited expect.txt * Tried implementig interfaces * Push * Push * push * push * Deleted no longer used files * push * push * Thanks @jaimecbernando for helping * can load via url * getting stuff semi stubbed out * full render without passing vars * making sure we clearly label the file was us * push * push * push (does not work) * Push * push * Added file size limit of 3 Kilobyte in standalone App (MoncaoPreview) * Added monacosrc to excludes.txt (spell checker) * Fixed XAMLHost loading issue and changed namespace of Settings.cs * push * Restructred some code in MonacoPreviewHandler (not functional) * MonacoPreview changes: Added maximal file size and error message as values in Settings.cs Increased maxFileSize to 10 KB Renamed variables and formed code according to style guidelines Added many comments Deleted usused code Added unimplemented(?) NavigationStarted method to prevent navigation in WebView Fixed scrollbar issues (Not beautiful, but still better) Removed never seen laoding window Added some debug information as well as some Exceptions. MonacoPreviewHandler Changes: Changed order of code executions (still not usable) * Push * Push * Push * push * Oh my god, it works * Added loading screen and resize * Added some comments, changed variable names and integrated some stuff from MonacoPreview to MonacoPreviewHandler; * Monaco Preview Handler: * Removed accessibilityhelpurl * Made background of loading screen like theme selected * dev tools open now in Debug mode automatically * Fixed error message for too big file size * push * Fixed a tiny bug * Updated a NuGet Pasckage * Removed some to-do points in FileHandler.cs and added them to #14957 * Removed some to-do points in FileHandler.cs and added them to #14957. Supressed a warning and styled a function better in PrebiewHandlerCommon * Fixed 2 comment typos and a font that didn't load. (Sadly his required enable CORS again :( ) * Removed old standalone project * Removed old unused files & rebase to master #1 * Deleted everything from the monaco source code expect the minified version * Push * Added summary of all functions. Restructred/simplified/clarified some code. * Added resources * Update bug_report.yml * Update translation_issue.yml * Update expect.txt * Update ProofOfConcept/MonacoPreview/monacoPreviewHandler/index.html Co-authored-by: Josh Soref <2119212+jsoref@users.noreply.github.com> * Update ProofOfConcept/MonacoPreview/monacoPreviewHandler/MonacoPreviewHandlerControl.cs Co-authored-by: Josh Soref <2119212+jsoref@users.noreply.github.com> * Update ProofOfConcept/MonacoPreview/monacoPreviewHandler/Resources.resx Co-authored-by: Josh Soref <2119212+jsoref@users.noreply.github.com> * Added some additional file types * Added additional file types * Moved to a json file for the available languages and some other changes * Added error message when WebView2 is not installed * Remoing throw error * Update expect.txt * Update excludes.txt * Update excludes.txt * Integrate Monaco preview handler into PowerToys * Update excludes.txt * Ignore .svg extension * Update signing list * Update signing list #2 * Changed monaco string * fix * Fixed wrong JSON field and changed date of Copyright * Added check if WebView is installed * Added error when webview2 is not installed * Increased file size limit to 50kb * Added new file generator for languages.json * Remove unvisible symbol at the beggining of the file * Regenerate resx file * Update MonacoPreviewHandler.csproj * tweaking script to ignore 1.0 check on theme dll * Update src/modules/previewpane/MonacoPreviewHandler/Properties/Resources.resx Co-authored-by: Franky Chen <franky920920+gpg@gmail.com> * Update src/modules/previewpane/MonacoPreviewHandler/MonacoPreviewHandlerControl.cs Co-authored-by: Franky Chen <franky920920+gpg@gmail.com> * Update src/modules/previewpane/MonacoPreviewHandler/MonacoPreviewHandlerControl.cs Co-authored-by: Franky Chen <franky920920+gpg@gmail.com> * Update src/settings-ui/Settings.UI/Strings/en-us/Resources.resw Co-authored-by: Franky Chen <franky920920+gpg@gmail.com> * Update excludes.txt * Update src/modules/previewpane/powerpreview/Resources.resx Co-authored-by: Franky Chen <franky920920+gpg@gmail.com> * Check and install WebView2 if needed * Run spellcheck script * Update ESRPSigning_core.json adding font * Update versionAndSignCheck.ps1 adding fonts to verify * Adding in Monaco usage * Update NOTICE.md * Update ESRPSigning_core.json * expect.txt update * Use Common.UI/ThemeManager.cs * No user facing strings should reference Monaco * Fix build error * monaco devdocs (#15691) * Create update-monaco-editor.md * Update and rename update-monaco-editor.md to readme.md * Update doc/devdocs/modules/powerpreview/monaco/readme.md Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com> * Update doc/devdocs/modules/powerpreview/monaco/readme.md Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com> * Update doc/devdocs/modules/powerpreview/monaco/readme.md Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com> * Update readme.md * Update readme.md Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com> * Fix WebView installer condition * Using system.text.json * Update ESRPSigning_core.json * Remove Newtonsoft.Json.dll from installer * Revert "WinUI bump (#15707)" This reverts commit b6a207c4b69b797dc5589aebbe162ef1f95fe83f. * Revert "Update Settings.UI.csproj (#15704)" This reverts commit 1a25dacc735621dc62a060fd8e6f52c86a1013cc. Co-authored-by: Clint Rutkas <clint@rutkas.com> Co-authored-by: Aaron Junker <aaron.junker@sus.schulen-stadtsh.ch> Co-authored-by: Clint Rutkas <crutkas@microsoft.com> Co-authored-by: Josh Soref <2119212+jsoref@users.noreply.github.com> Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Franky Chen <franky920920+gpg@gmail.com> Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
2022-01-26 04:02:10 +08:00
private bool enableMonacoPreview = true;
[JsonPropertyName("monaco-previewer-toggle-setting")]
[JsonConverter(typeof(BoolPropertyJsonConverter))]
public bool EnableMonacoPreview
{
get => enableMonacoPreview;
set
{
if (value != enableMonacoPreview)
{
LogTelemetryEvent(value);
enableMonacoPreview = value;
}
}
}
private bool enablePdfPreview = true;
[JsonPropertyName("pdf-previewer-toggle-setting")]
[JsonConverter(typeof(BoolPropertyJsonConverter))]
public bool EnablePdfPreview
{
get => enablePdfPreview;
set
{
if (value != enablePdfPreview)
{
LogTelemetryEvent(value);
enablePdfPreview = value;
}
}
}
private bool enablePdfThumbnail = true;
[JsonPropertyName("pdf-thumbnail-toggle-setting")]
[JsonConverter(typeof(BoolPropertyJsonConverter))]
public bool EnablePdfThumbnail
{
get => enablePdfThumbnail;
set
{
if (value != enablePdfThumbnail)
{
LogTelemetryEvent(value);
enablePdfThumbnail = value;
}
}
}
private bool enableGcodePreview = true;
[JsonPropertyName("gcode-previewer-toggle-setting")]
[JsonConverter(typeof(BoolPropertyJsonConverter))]
public bool EnableGcodePreview
{
get => enableGcodePreview;
set
{
if (value != enableGcodePreview)
{
LogTelemetryEvent(value);
enableGcodePreview = value;
}
}
}
private bool enableGcodeThumbnail = true;
[JsonPropertyName("gcode-thumbnail-toggle-setting")]
[JsonConverter(typeof(BoolPropertyJsonConverter))]
public bool EnableGcodeThumbnail
{
get => enableGcodeThumbnail;
set
{
if (value != enableGcodeThumbnail)
{
LogTelemetryEvent(value);
enableGcodeThumbnail = value;
}
}
}
private bool enableStlThumbnail = true;
[JsonPropertyName("stl-thumbnail-toggle-setting")]
[JsonConverter(typeof(BoolPropertyJsonConverter))]
public bool EnableStlThumbnail
{
get => enableStlThumbnail;
set
{
if (value != enableStlThumbnail)
{
LogTelemetryEvent(value);
enableStlThumbnail = value;
}
}
}
public PowerPreviewProperties()
{
}
public override string ToString()
{
return JsonSerializer.Serialize(this);
}
private static void LogTelemetryEvent(bool value, [CallerMemberName] string propertyName = null)
{
var dataEvent = new SettingsEnabledEvent()
{
Value = value,
Name = propertyName,
};
PowerToysTelemetry.Log.WriteEvent(dataEvent);
}
}
}