mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-24 04:12:32 +08:00
[FileExplorer] StlThumbnailProvider (#15568)
* Adds StlThumbnailProvider * Spell checker fixes * Adds missing changes * Attempts to fix alpha background issue * Adds missing dependency references * Upgrades .NET Core 3.1 to .NET 5 * Updates Helix Toolkit to fix .net5 compatibility * Return null bitmap If STL model is empty
This commit is contained in:
parent
edc43e39ca
commit
cccadec44c
1
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
1
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -48,6 +48,7 @@ body:
|
|||||||
- PowerRename
|
- PowerRename
|
||||||
- PowerToys Run
|
- PowerToys Run
|
||||||
- Shortcut Guide
|
- Shortcut Guide
|
||||||
|
- STL Thumbnail
|
||||||
- SVG Preview
|
- SVG Preview
|
||||||
- SVG Thumbnail
|
- SVG Thumbnail
|
||||||
- Settings
|
- Settings
|
||||||
|
1
.github/actions/spell-check/excludes.txt
vendored
1
.github/actions/spell-check/excludes.txt
vendored
@ -26,6 +26,7 @@ ignore$
|
|||||||
\.pdf$
|
\.pdf$
|
||||||
\.PNG$
|
\.PNG$
|
||||||
\.png$
|
\.png$
|
||||||
|
\.stl$
|
||||||
\.woff$
|
\.woff$
|
||||||
\.zip$
|
\.zip$
|
||||||
^doc/devdocs/akaLinks\.md$
|
^doc/devdocs/akaLinks\.md$
|
||||||
|
3
.github/actions/spell-check/expect.txt
vendored
3
.github/actions/spell-check/expect.txt
vendored
@ -1103,6 +1103,7 @@ LPVOID
|
|||||||
LPW
|
LPW
|
||||||
lpwndpl
|
lpwndpl
|
||||||
LPWSTR
|
LPWSTR
|
||||||
|
LReader
|
||||||
LRESULT
|
LRESULT
|
||||||
lshift
|
lshift
|
||||||
lstrcmp
|
lstrcmp
|
||||||
@ -1397,6 +1398,7 @@ outsettings
|
|||||||
OVERLAPPEDWINDOW
|
OVERLAPPEDWINDOW
|
||||||
overlaywindow
|
overlaywindow
|
||||||
Overridable
|
Overridable
|
||||||
|
Oversampling
|
||||||
OWNDC
|
OWNDC
|
||||||
PACL
|
PACL
|
||||||
PAINTSTRUCT
|
PAINTSTRUCT
|
||||||
@ -1861,6 +1863,7 @@ STEPIT
|
|||||||
stgm
|
stgm
|
||||||
STGMEDIUM
|
STGMEDIUM
|
||||||
sticpl
|
sticpl
|
||||||
|
stl
|
||||||
stoi
|
stoi
|
||||||
stol
|
stol
|
||||||
stoll
|
stoll
|
||||||
|
@ -57,6 +57,8 @@
|
|||||||
"modules\\FileExplorerPreview\\PowerToys.PdfThumbnailProvider.comhost.dll",
|
"modules\\FileExplorerPreview\\PowerToys.PdfThumbnailProvider.comhost.dll",
|
||||||
"modules\\FileExplorerPreview\\PowerToys.powerpreview.dll",
|
"modules\\FileExplorerPreview\\PowerToys.powerpreview.dll",
|
||||||
"modules\\FileExplorerPreview\\PowerToys.PreviewHandlerCommon.dll",
|
"modules\\FileExplorerPreview\\PowerToys.PreviewHandlerCommon.dll",
|
||||||
|
"modules\\FileExplorerPreview\\PowerToys.StlThumbnailProvider.dll",
|
||||||
|
"modules\\FileExplorerPreview\\PowerToys.StlThumbnailProvider.comhost.dll",
|
||||||
"modules\\FileExplorerPreview\\PowerToys.SvgPreviewHandler.dll",
|
"modules\\FileExplorerPreview\\PowerToys.SvgPreviewHandler.dll",
|
||||||
"modules\\FileExplorerPreview\\PowerToys.SvgPreviewHandler.comhost.dll",
|
"modules\\FileExplorerPreview\\PowerToys.SvgPreviewHandler.comhost.dll",
|
||||||
"modules\\FileExplorerPreview\\PowerToys.SvgThumbnailProvider.dll",
|
"modules\\FileExplorerPreview\\PowerToys.SvgThumbnailProvider.dll",
|
||||||
@ -165,6 +167,8 @@
|
|||||||
"NLog.dll",
|
"NLog.dll",
|
||||||
"HtmlAgilityPack.dll",
|
"HtmlAgilityPack.dll",
|
||||||
"Markdig.Signed.dll",
|
"Markdig.Signed.dll",
|
||||||
|
"HelixToolkit.dll",
|
||||||
|
"HelixToolkit.Core.Wpf.dll",
|
||||||
"Mages.Core.dll",
|
"Mages.Core.dll",
|
||||||
"JetBrains.Annotations.dll",
|
"JetBrains.Annotations.dll",
|
||||||
"ICSharpCode.SharpZipLib.dll",
|
"ICSharpCode.SharpZipLib.dll",
|
||||||
|
@ -103,6 +103,7 @@ steps:
|
|||||||
testAssemblyVer2: |
|
testAssemblyVer2: |
|
||||||
**\UnitTests-GcodeThumbnailProvider.dll
|
**\UnitTests-GcodeThumbnailProvider.dll
|
||||||
**\UnitTests-SvgThumbnailProvider.dll
|
**\UnitTests-SvgThumbnailProvider.dll
|
||||||
|
**\UnitTests-StlThumbnailProvider.dll
|
||||||
**\UnitTests-PdfThumbnailProvider.dll
|
**\UnitTests-PdfThumbnailProvider.dll
|
||||||
**\Settings.UI.UnitTests.dll
|
**\Settings.UI.UnitTests.dll
|
||||||
**\UnitTests-MarkdownPreviewHandler.dll
|
**\UnitTests-MarkdownPreviewHandler.dll
|
||||||
|
@ -390,6 +390,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Community.PowerToys.Run.Plu
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MousePointerCrosshair", "src\modules\MouseUtils\MousePointerCrosshair\MousePointerCrosshair.vcxproj", "{EAE14C0E-7A6B-45DA-9080-A7D8C077BA6E}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MousePointerCrosshair", "src\modules\MouseUtils\MousePointerCrosshair\MousePointerCrosshair.vcxproj", "{EAE14C0E-7A6B-45DA-9080-A7D8C077BA6E}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StlThumbnailProvider", "src\modules\previewpane\StlThumbnailProvider\StlThumbnailProvider.csproj", "{F7C8C0F1-5431-4347-89D0-8E5354F93CF2}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests-StlThumbnailProvider", "src\modules\previewpane\UnitTests-StlThumbnailProvider\UnitTests-StlThumbnailProvider.csproj", "{F1F6B6B6-9F18-4A17-8B5C-97DF552C53DC}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|x64 = Debug|x64
|
Debug|x64 = Debug|x64
|
||||||
@ -1053,6 +1057,18 @@ Global
|
|||||||
{EAE14C0E-7A6B-45DA-9080-A7D8C077BA6E}.Release|x64.ActiveCfg = Release|x64
|
{EAE14C0E-7A6B-45DA-9080-A7D8C077BA6E}.Release|x64.ActiveCfg = Release|x64
|
||||||
{EAE14C0E-7A6B-45DA-9080-A7D8C077BA6E}.Release|x64.Build.0 = Release|x64
|
{EAE14C0E-7A6B-45DA-9080-A7D8C077BA6E}.Release|x64.Build.0 = Release|x64
|
||||||
{EAE14C0E-7A6B-45DA-9080-A7D8C077BA6E}.Release|x86.ActiveCfg = Release|x64
|
{EAE14C0E-7A6B-45DA-9080-A7D8C077BA6E}.Release|x86.ActiveCfg = Release|x64
|
||||||
|
{F7C8C0F1-5431-4347-89D0-8E5354F93CF2}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{F7C8C0F1-5431-4347-89D0-8E5354F93CF2}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{F7C8C0F1-5431-4347-89D0-8E5354F93CF2}.Debug|x86.ActiveCfg = Debug|x64
|
||||||
|
{F7C8C0F1-5431-4347-89D0-8E5354F93CF2}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{F7C8C0F1-5431-4347-89D0-8E5354F93CF2}.Release|x64.Build.0 = Release|x64
|
||||||
|
{F7C8C0F1-5431-4347-89D0-8E5354F93CF2}.Release|x86.ActiveCfg = Release|x64
|
||||||
|
{F1F6B6B6-9F18-4A17-8B5C-97DF552C53DC}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{F1F6B6B6-9F18-4A17-8B5C-97DF552C53DC}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{F1F6B6B6-9F18-4A17-8B5C-97DF552C53DC}.Debug|x86.ActiveCfg = Debug|x64
|
||||||
|
{F1F6B6B6-9F18-4A17-8B5C-97DF552C53DC}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{F1F6B6B6-9F18-4A17-8B5C-97DF552C53DC}.Release|x64.Build.0 = Release|x64
|
||||||
|
{F1F6B6B6-9F18-4A17-8B5C-97DF552C53DC}.Release|x86.ActiveCfg = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@ -1181,6 +1197,8 @@ Global
|
|||||||
{48A0A19E-A0BE-4256-ACF8-CC3B80291AF9} = {60CD2D4F-C3B9-4897-9821-FCA5098B41CE}
|
{48A0A19E-A0BE-4256-ACF8-CC3B80291AF9} = {60CD2D4F-C3B9-4897-9821-FCA5098B41CE}
|
||||||
{9F94B303-5E21-4364-9362-64426F8DB932} = {4AFC9975-2456-4C70-94A4-84073C1CED93}
|
{9F94B303-5E21-4364-9362-64426F8DB932} = {4AFC9975-2456-4C70-94A4-84073C1CED93}
|
||||||
{EAE14C0E-7A6B-45DA-9080-A7D8C077BA6E} = {322566EF-20DC-43A6-B9F8-616AF942579A}
|
{EAE14C0E-7A6B-45DA-9080-A7D8C077BA6E} = {322566EF-20DC-43A6-B9F8-616AF942579A}
|
||||||
|
{F7C8C0F1-5431-4347-89D0-8E5354F93CF2} = {2F305555-C296-497E-AC20-5FA1B237996A}
|
||||||
|
{F1F6B6B6-9F18-4A17-8B5C-97DF552C53DC} = {2F305555-C296-497E-AC20-5FA1B237996A}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
|
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
|
||||||
|
@ -877,6 +877,13 @@
|
|||||||
<File Source="$(var.BinX64Dir)modules\FileExplorerPreview\PowerToys.GcodeThumbnailProvider.comhost.dll" />
|
<File Source="$(var.BinX64Dir)modules\FileExplorerPreview\PowerToys.GcodeThumbnailProvider.comhost.dll" />
|
||||||
<File Source="$(var.BinX64Dir)modules\FileExplorerPreview\PowerToys.GcodeThumbnailProvider.runtimeconfig.json" />
|
<File Source="$(var.BinX64Dir)modules\FileExplorerPreview\PowerToys.GcodeThumbnailProvider.runtimeconfig.json" />
|
||||||
<File Source="$(var.BinX64Dir)modules\FileExplorerPreview\PowerToys.GcodeThumbnailProvider.deps.json" />
|
<File Source="$(var.BinX64Dir)modules\FileExplorerPreview\PowerToys.GcodeThumbnailProvider.deps.json" />
|
||||||
|
<!-- File to include dll for Stl Thumbnail Provider -->
|
||||||
|
<File Source="$(var.BinX64Dir)modules\FileExplorerPreview\PowerToys.StlThumbnailProvider.dll" />
|
||||||
|
<File Source="$(var.BinX64Dir)modules\FileExplorerPreview\PowerToys.StlThumbnailProvider.comhost.dll" />
|
||||||
|
<File Source="$(var.BinX64Dir)modules\FileExplorerPreview\PowerToys.StlThumbnailProvider.runtimeconfig.json" />
|
||||||
|
<File Source="$(var.BinX64Dir)modules\FileExplorerPreview\PowerToys.StlThumbnailProvider.deps.json" />
|
||||||
|
<File Source="$(var.BinX64Dir)modules\FileExplorerPreview\HelixToolkit.dll" />
|
||||||
|
<File Source="$(var.BinX64Dir)modules\FileExplorerPreview\HelixToolkit.Core.Wpf.dll" />
|
||||||
</Component>
|
</Component>
|
||||||
</DirectoryRef>
|
</DirectoryRef>
|
||||||
|
|
||||||
|
@ -106,6 +106,20 @@ inline registry::ChangeSet getGcodeThumbnailHandlerChangeSet(const std::wstring
|
|||||||
L".gcode");
|
L".gcode");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline registry::ChangeSet getStlThumbnailHandlerChangeSet(const std::wstring installationDir, const bool perUser)
|
||||||
|
{
|
||||||
|
using namespace registry::shellex;
|
||||||
|
return generatePreviewHandler(PreviewHandlerType::thumbnail,
|
||||||
|
perUser,
|
||||||
|
L"{8BC8AFC2-4E7C-4695-818E-8C1FFDCEA2AF}",
|
||||||
|
get_std_product_version(),
|
||||||
|
(fs::path{ installationDir } / LR"d(modules\FileExplorerPreview\PowerToys.StlThumbnailProvider.comhost.dll)d").wstring(),
|
||||||
|
registry::DOTNET_COMPONENT_CATEGORY_CLSID,
|
||||||
|
L"Microsoft.PowerToys.ThumbnailHandler.Stl.StlThumbnailProvider",
|
||||||
|
L"Stl Thumbnail Provider",
|
||||||
|
L".stl");
|
||||||
|
}
|
||||||
|
|
||||||
inline std::vector<registry::ChangeSet> getAllModulesChangeSets(const std::wstring installationDir)
|
inline std::vector<registry::ChangeSet> getAllModulesChangeSets(const std::wstring installationDir)
|
||||||
{
|
{
|
||||||
constexpr bool PER_USER = true;
|
constexpr bool PER_USER = true;
|
||||||
@ -115,5 +129,6 @@ inline std::vector<registry::ChangeSet> getAllModulesChangeSets(const std::wstri
|
|||||||
getGcodePreviewHandlerChangeSet(installationDir, PER_USER),
|
getGcodePreviewHandlerChangeSet(installationDir, PER_USER),
|
||||||
getSvgThumbnailHandlerChangeSet(installationDir, PER_USER),
|
getSvgThumbnailHandlerChangeSet(installationDir, PER_USER),
|
||||||
getPdfThumbnailHandlerChangeSet(installationDir, PER_USER),
|
getPdfThumbnailHandlerChangeSet(installationDir, PER_USER),
|
||||||
getGcodeThumbnailHandlerChangeSet(installationDir, PER_USER) };
|
getGcodeThumbnailHandlerChangeSet(installationDir, PER_USER),
|
||||||
|
getStlThumbnailHandlerChangeSet(installationDir, PER_USER) };
|
||||||
}
|
}
|
@ -0,0 +1,145 @@
|
|||||||
|
// 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;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.InteropServices.ComTypes;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Media3D;
|
||||||
|
using Common.ComInterlop;
|
||||||
|
using Common.Utilities;
|
||||||
|
using HelixToolkit.Wpf;
|
||||||
|
using Bitmap = System.Drawing.Bitmap;
|
||||||
|
|
||||||
|
namespace Microsoft.PowerToys.ThumbnailHandler.Stl
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Stl Thumbnail Provider.
|
||||||
|
/// </summary>
|
||||||
|
[Guid("8BC8AFC2-4E7C-4695-818E-8C1FFDCEA2AF")]
|
||||||
|
[ClassInterface(ClassInterfaceType.None)]
|
||||||
|
[ComVisible(true)]
|
||||||
|
public class StlThumbnailProvider : IInitializeWithStream, IThumbnailProvider
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the stream object to access file.
|
||||||
|
/// </summary>
|
||||||
|
public IStream Stream { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The maximum dimension (width or height) thumbnail we will generate.
|
||||||
|
/// </summary>
|
||||||
|
private const uint MaxThumbnailSize = 10000;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the Stl model into a Viewport3D and renders a bitmap of it.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="stream">The Stream instance for the Stl content.</param>
|
||||||
|
/// <param name="cx">The maximum thumbnail size, in pixels.</param>
|
||||||
|
/// <returns>A thumbnail rendered from the Stl model.</returns>
|
||||||
|
public static Bitmap GetThumbnail(Stream stream, uint cx)
|
||||||
|
{
|
||||||
|
if (cx > MaxThumbnailSize || stream == null || stream.Length == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bitmap thumbnail = null;
|
||||||
|
|
||||||
|
var stlReader = new StLReader
|
||||||
|
{
|
||||||
|
DefaultMaterial = new DiffuseMaterial(new SolidColorBrush(Color.FromRgb(255, 201, 36))),
|
||||||
|
};
|
||||||
|
|
||||||
|
var model = stlReader.Read(stream);
|
||||||
|
|
||||||
|
if (model.Bounds == Rect3D.Empty)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var viewport = new System.Windows.Controls.Viewport3D();
|
||||||
|
|
||||||
|
viewport.Measure(new Size(cx, cx));
|
||||||
|
viewport.Arrange(new Rect(0, 0, cx, cx));
|
||||||
|
|
||||||
|
var modelVisual = new ModelVisual3D()
|
||||||
|
{
|
||||||
|
Transform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), 180)),
|
||||||
|
};
|
||||||
|
viewport.Children.Add(modelVisual);
|
||||||
|
viewport.Children.Add(new DefaultLights());
|
||||||
|
|
||||||
|
var perspectiveCamera = new PerspectiveCamera
|
||||||
|
{
|
||||||
|
Position = new Point3D(1, 2, 1),
|
||||||
|
LookDirection = new Vector3D(-1, -2, -1),
|
||||||
|
UpDirection = new Vector3D(0, 0, 1),
|
||||||
|
FieldOfView = 20,
|
||||||
|
NearPlaneDistance = 0.1,
|
||||||
|
FarPlaneDistance = double.PositiveInfinity,
|
||||||
|
};
|
||||||
|
viewport.Camera = perspectiveCamera;
|
||||||
|
|
||||||
|
modelVisual.Content = model;
|
||||||
|
|
||||||
|
perspectiveCamera.ZoomExtents(viewport);
|
||||||
|
|
||||||
|
var bitmapExporter = new BitmapExporter
|
||||||
|
{
|
||||||
|
Background = new SolidColorBrush(Colors.Transparent),
|
||||||
|
OversamplingMultiplier = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
var bitmapStream = new MemoryStream();
|
||||||
|
|
||||||
|
bitmapExporter.Export(viewport, bitmapStream);
|
||||||
|
|
||||||
|
bitmapStream.Position = 0;
|
||||||
|
|
||||||
|
thumbnail = new Bitmap(bitmapStream);
|
||||||
|
|
||||||
|
return thumbnail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void Initialize(IStream pstream, uint grfMode)
|
||||||
|
{
|
||||||
|
// Ignore the grfMode always use read mode to access the file.
|
||||||
|
this.Stream = pstream;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void GetThumbnail(uint cx, out IntPtr phbmp, out WTS_ALPHATYPE pdwAlpha)
|
||||||
|
{
|
||||||
|
phbmp = IntPtr.Zero;
|
||||||
|
pdwAlpha = WTS_ALPHATYPE.WTSAT_UNKNOWN;
|
||||||
|
|
||||||
|
if (cx == 0 || cx > MaxThumbnailSize)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var stream = new ReadonlyStream(this.Stream as IStream))
|
||||||
|
{
|
||||||
|
using (var memStream = new MemoryStream())
|
||||||
|
{
|
||||||
|
stream.CopyTo(memStream);
|
||||||
|
|
||||||
|
memStream.Position = 0;
|
||||||
|
|
||||||
|
using (Bitmap thumbnail = GetThumbnail(memStream, cx))
|
||||||
|
{
|
||||||
|
if (thumbnail != null && thumbnail.Size.Width > 0 && thumbnail.Size.Height > 0)
|
||||||
|
{
|
||||||
|
phbmp = thumbnail.GetHbitmap(System.Drawing.Color.Transparent);
|
||||||
|
pdwAlpha = WTS_ALPHATYPE.WTSAT_ARGB;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Platforms>x64</Platforms>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ProjectGuid>{F7C8C0F1-5431-4347-89D0-8E5354F93CF2}</ProjectGuid>
|
||||||
|
<RootNamespace>Microsoft.PowerToys.ThumbnailHandler.Stl</RootNamespace>
|
||||||
|
<AssemblyName>PowerToys.StlThumbnailProvider</AssemblyName>
|
||||||
|
<AssemblyTitle>PowerToys.StlThumbnailProvider</AssemblyTitle>
|
||||||
|
<AssemblyDescription>PowerToys StlPreviewHandler</AssemblyDescription>
|
||||||
|
<AssemblyCompany>Microsoft Corporation</AssemblyCompany>
|
||||||
|
<AssemblyCopyright>Copyright (C) 2020 Microsoft Corporation</AssemblyCopyright>
|
||||||
|
<AssemblyProduct>PowerToys</AssemblyProduct>
|
||||||
|
<TargetFramework>net5.0-windows</TargetFramework>
|
||||||
|
<EnableComHosting>true</EnableComHosting>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<Company>Microsoft Corporation</Company>
|
||||||
|
<Product>PowerToys</Product>
|
||||||
|
<NeutralLanguage>en-US</NeutralLanguage>
|
||||||
|
<Description>PowerToys StlPreviewHandler</Description>
|
||||||
|
<Copyright>Copyright (C) 2020 Microsoft Corporation</Copyright>
|
||||||
|
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileExplorerPreview\</OutputPath>
|
||||||
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
|
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||||
|
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Import Project="..\..\..\Version.props" />
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="HelixToolkit" Version="2.20.1" />
|
||||||
|
<PackageReference Include="HelixToolkit.Core.Wpf" Version="2.20.1" />
|
||||||
|
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.CodeAnalysis.VersionCheckAnalyzer" Version="3.3.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="3.3.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.NetCore.Analyzers" Version="3.3.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.NetFramework.Analyzers" Version="3.3.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="..\..\..\codeAnalysis\GlobalSuppressions.cs" Link="GlobalSuppressions.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\ManagedTelemetry.csproj" />
|
||||||
|
<ProjectReference Include="..\Common\PreviewHandlerCommon.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json">
|
||||||
|
<Link>StyleCop.json</Link>
|
||||||
|
</AdditionalFiles>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
Binary file not shown.
@ -0,0 +1,111 @@
|
|||||||
|
// 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;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.InteropServices.ComTypes;
|
||||||
|
using Common.ComInterlop;
|
||||||
|
using Microsoft.PowerToys.STATestExtension;
|
||||||
|
using Microsoft.PowerToys.ThumbnailHandler.Stl;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using Moq;
|
||||||
|
|
||||||
|
namespace StlThumbnailProviderUnitTests
|
||||||
|
{
|
||||||
|
[STATestClass]
|
||||||
|
public class StlThumbnailProviderTests
|
||||||
|
{
|
||||||
|
[TestMethod]
|
||||||
|
public void GetThumbnailValidStreamStl()
|
||||||
|
{
|
||||||
|
// Act
|
||||||
|
var file = File.ReadAllBytes("HelperFiles/sample.stl");
|
||||||
|
|
||||||
|
StlThumbnailProvider provider = new StlThumbnailProvider();
|
||||||
|
|
||||||
|
provider.Initialize(GetMockStream(file), 0);
|
||||||
|
|
||||||
|
provider.GetThumbnail(256, out IntPtr bitmap, out WTS_ALPHATYPE alphaType);
|
||||||
|
|
||||||
|
Assert.IsTrue(bitmap != IntPtr.Zero);
|
||||||
|
Assert.IsTrue(alphaType == WTS_ALPHATYPE.WTSAT_ARGB);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void GetThumbnailInValidSizeStl()
|
||||||
|
{
|
||||||
|
// Act
|
||||||
|
var file = File.ReadAllBytes("HelperFiles/sample.stl");
|
||||||
|
|
||||||
|
StlThumbnailProvider provider = new StlThumbnailProvider();
|
||||||
|
|
||||||
|
provider.Initialize(GetMockStream(file), 0);
|
||||||
|
|
||||||
|
provider.GetThumbnail(0, out IntPtr bitmap, out WTS_ALPHATYPE alphaType);
|
||||||
|
|
||||||
|
Assert.IsTrue(bitmap == IntPtr.Zero);
|
||||||
|
Assert.IsTrue(alphaType == WTS_ALPHATYPE.WTSAT_UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void GetThumbnailToBigStl()
|
||||||
|
{
|
||||||
|
// Act
|
||||||
|
var file = File.ReadAllBytes("HelperFiles/sample.stl");
|
||||||
|
|
||||||
|
StlThumbnailProvider provider = new StlThumbnailProvider();
|
||||||
|
|
||||||
|
provider.Initialize(GetMockStream(file), 0);
|
||||||
|
|
||||||
|
provider.GetThumbnail(10001, out IntPtr bitmap, out WTS_ALPHATYPE alphaType);
|
||||||
|
|
||||||
|
Assert.IsTrue(bitmap == IntPtr.Zero);
|
||||||
|
Assert.IsTrue(alphaType == WTS_ALPHATYPE.WTSAT_UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void CheckNoStlEmptyStreamShouldReturnNullBitmap()
|
||||||
|
{
|
||||||
|
using (var stream = new MemoryStream())
|
||||||
|
{
|
||||||
|
Bitmap thumbnail = StlThumbnailProvider.GetThumbnail(stream, 256);
|
||||||
|
Assert.IsTrue(thumbnail == null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void CheckNoStlNullStreamShouldReturnNullBitmap()
|
||||||
|
{
|
||||||
|
Bitmap thumbnail = StlThumbnailProvider.GetThumbnail(null, 256);
|
||||||
|
Assert.IsTrue(thumbnail == null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IStream GetMockStream(byte[] sourceArray)
|
||||||
|
{
|
||||||
|
var streamMock = new Mock<IStream>();
|
||||||
|
int bytesRead = 0;
|
||||||
|
|
||||||
|
streamMock
|
||||||
|
.Setup(x => x.Read(It.IsAny<byte[]>(), It.IsAny<int>(), It.IsAny<IntPtr>()))
|
||||||
|
.Callback<byte[], int, IntPtr>((buffer, countToRead, bytesReadPtr) =>
|
||||||
|
{
|
||||||
|
int actualCountToRead = Math.Min(sourceArray.Length - bytesRead, countToRead);
|
||||||
|
if (actualCountToRead > 0)
|
||||||
|
{
|
||||||
|
Array.Copy(sourceArray, bytesRead, buffer, 0, actualCountToRead);
|
||||||
|
Marshal.WriteInt32(bytesReadPtr, actualCountToRead);
|
||||||
|
bytesRead += actualCountToRead;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Marshal.WriteInt32(bytesReadPtr, 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return streamMock.Object;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Platforms>x64</Platforms>
|
||||||
|
<AssemblyTitle>UnitTests-StlThumbnailProvider</AssemblyTitle>
|
||||||
|
<AssemblyDescription>PowerToys UnitTests-StlThumbnailProvider</AssemblyDescription>
|
||||||
|
<AssemblyCompany>Microsoft Corporation</AssemblyCompany>
|
||||||
|
<AssemblyCopyright>Copyright (C) 2020 Microsoft Corporation</AssemblyCopyright>
|
||||||
|
<AssemblyProduct>PowerToys</AssemblyProduct>
|
||||||
|
<AssemblyTitle>UnitTests-StlThumbnailProvider</AssemblyTitle>
|
||||||
|
<Company>Microsoft Corporation</Company>
|
||||||
|
<Product>PowerToys</Product>
|
||||||
|
<NeutralLanguage>en-US</NeutralLanguage>
|
||||||
|
<Description>PowerToys UnitTests-StlThumbnailProvider</Description>
|
||||||
|
<Copyright>Copyright (C) 2021 Microsoft Corporation</Copyright>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<ProjectGuid>{F1F6B6B6-9F18-4A17-8B5C-97DF552C53DC}</ProjectGuid>
|
||||||
|
<RootNamespace>StlThumbnailProviderUnitTests</RootNamespace>
|
||||||
|
<TargetFramework>net5.0-windows10.0.18362.0</TargetFramework>
|
||||||
|
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
|
||||||
|
<IsCodedUITest>False</IsCodedUITest>
|
||||||
|
<TestProjectType>UnitTest</TestProjectType>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Import Project="..\..\..\Version.props" />
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="HelperFiles\sample.stl" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Castle.Core" Version="4.4.1" />
|
||||||
|
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.CodeAnalysis.VersionCheckAnalyzer" Version="3.3.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="3.3.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.NetCore.Analyzers" Version="3.3.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.NetFramework.Analyzers" Version="3.3.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Moq" Version="4.16.1" />
|
||||||
|
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||||
|
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
|
||||||
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
|
||||||
|
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Common\PreviewHandlerCommon.csproj" />
|
||||||
|
<ProjectReference Include="..\StlThumbnailProvider\StlThumbnailProvider.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="..\..\..\codeAnalysis\GlobalSuppressions.cs" Link="GlobalSuppressions.cs" />
|
||||||
|
<Compile Include="..\STATestClassAttribute.cs" Link="STATestClassAttribute.cs" />
|
||||||
|
<Compile Include="..\STATestMethodAttribute.cs" Link="STATestMethodAttribute.cs" />
|
||||||
|
<AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json">
|
||||||
|
<Link>StyleCop.json</Link>
|
||||||
|
</AdditionalFiles>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="HelperFiles\sample.stl">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
@ -40,6 +40,9 @@ const CLSID CLSID_GcodePreviewHandler = { 0xec52dea8, 0x7c9f, 0x4130, { 0xa7, 0x
|
|||||||
// BFEE99B4-B74D-4348-BCA5-E757029647FF
|
// BFEE99B4-B74D-4348-BCA5-E757029647FF
|
||||||
const GUID CLSID_GcodeThumbnailProvider = { 0xbfee99b4, 0xb74d, 0x4348, { 0xbc, 0xa5, 0xe7, 0x57, 0x02, 0x96, 0x47, 0xff } };
|
const GUID CLSID_GcodeThumbnailProvider = { 0xbfee99b4, 0xb74d, 0x4348, { 0xbc, 0xa5, 0xe7, 0x57, 0x02, 0x96, 0x47, 0xff } };
|
||||||
|
|
||||||
|
// 8BC8AFC2-4E7C-4695-818E-8C1FFDCEA2AF
|
||||||
|
const GUID CLSID_StlThumbnailProvider = { 0x8bc8afc2, 0x4e7c, 0x4695, { 0x81, 0x8e, 0x8c, 0x1f, 0xfd, 0xce, 0xa2, 0xaf } };
|
||||||
|
|
||||||
// Pairs of NativeClsid vs ManagedClsid used for preview handlers.
|
// Pairs of NativeClsid vs ManagedClsid used for preview handlers.
|
||||||
const std::vector<std::pair<CLSID, CLSID>> NativeToManagedClsid({
|
const std::vector<std::pair<CLSID, CLSID>> NativeToManagedClsid({
|
||||||
{ CLSID_SHIMActivateMdPreviewHandler, CLSID_MdPreviewHandler },
|
{ CLSID_SHIMActivateMdPreviewHandler, CLSID_MdPreviewHandler },
|
||||||
|
@ -186,4 +186,7 @@
|
|||||||
<data name="Prevpane_Gcode_Settings_Displayname" xml:space="preserve">
|
<data name="Prevpane_Gcode_Settings_Displayname" xml:space="preserve">
|
||||||
<value>G-code Previewer</value>
|
<value>G-code Previewer</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Stl_Thumbnail_Provider_Settings_Description" xml:space="preserve">
|
||||||
|
<value>Stl Thumbnail Provider</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
@ -54,6 +54,10 @@ PowerPreviewModule::PowerPreviewModule() :
|
|||||||
.settingDescription = GET_RESOURCE_STRING(IDS_GCODE_THUMBNAIL_PROVIDER_SETTINGS_DESCRIPTION),
|
.settingDescription = GET_RESOURCE_STRING(IDS_GCODE_THUMBNAIL_PROVIDER_SETTINGS_DESCRIPTION),
|
||||||
.registryChanges = getGcodeThumbnailHandlerChangeSet(installationDir, installPerUser) });
|
.registryChanges = getGcodeThumbnailHandlerChangeSet(installationDir, installPerUser) });
|
||||||
|
|
||||||
|
m_fileExplorerModules.push_back({ .settingName = L"stl-thumbnail-toggle-setting",
|
||||||
|
.settingDescription = GET_RESOURCE_STRING(IDS_STL_THUMBNAIL_PROVIDER_SETTINGS_DESCRIPTION),
|
||||||
|
.registryChanges = getStlThumbnailHandlerChangeSet(installationDir, installPerUser) });
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PowerToysSettings::PowerToyValues settings =
|
PowerToysSettings::PowerToyValues settings =
|
||||||
|
@ -131,6 +131,23 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 PowerPreviewProperties()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
|||||||
_gcodeRenderIsEnabled = Settings.Properties.EnableGcodePreview;
|
_gcodeRenderIsEnabled = Settings.Properties.EnableGcodePreview;
|
||||||
_pdfThumbnailIsEnabled = Settings.Properties.EnablePdfThumbnail;
|
_pdfThumbnailIsEnabled = Settings.Properties.EnablePdfThumbnail;
|
||||||
_gcodeThumbnailIsEnabled = Settings.Properties.EnableGcodeThumbnail;
|
_gcodeThumbnailIsEnabled = Settings.Properties.EnableGcodeThumbnail;
|
||||||
|
_stlThumbnailIsEnabled = Settings.Properties.EnableStlThumbnail;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _svgRenderIsEnabled;
|
private bool _svgRenderIsEnabled;
|
||||||
@ -62,6 +63,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
|||||||
private bool _svgThumbnailIsEnabled;
|
private bool _svgThumbnailIsEnabled;
|
||||||
private bool _pdfThumbnailIsEnabled;
|
private bool _pdfThumbnailIsEnabled;
|
||||||
private bool _gcodeThumbnailIsEnabled;
|
private bool _gcodeThumbnailIsEnabled;
|
||||||
|
private bool _stlThumbnailIsEnabled;
|
||||||
|
|
||||||
public bool SVGRenderIsEnabled
|
public bool SVGRenderIsEnabled
|
||||||
{
|
{
|
||||||
@ -189,6 +191,24 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool STLThumbnailIsEnabled
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _stlThumbnailIsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value != _stlThumbnailIsEnabled)
|
||||||
|
{
|
||||||
|
_stlThumbnailIsEnabled = value;
|
||||||
|
Settings.Properties.EnableStlThumbnail = value;
|
||||||
|
RaisePropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string GetSettingsSubPath()
|
public string GetSettingsSubPath()
|
||||||
{
|
{
|
||||||
return _settingsConfigFileFolder + "\\" + ModuleName;
|
return _settingsConfigFileFolder + "\\" + ModuleName;
|
||||||
|
@ -63,6 +63,7 @@ namespace ViewModelTests
|
|||||||
Assert.AreEqual(originalSettings.Properties.EnableSvgThumbnail, viewModel.SVGThumbnailIsEnabled);
|
Assert.AreEqual(originalSettings.Properties.EnableSvgThumbnail, viewModel.SVGThumbnailIsEnabled);
|
||||||
Assert.AreEqual(originalSettings.Properties.EnablePdfThumbnail, viewModel.PDFThumbnailIsEnabled);
|
Assert.AreEqual(originalSettings.Properties.EnablePdfThumbnail, viewModel.PDFThumbnailIsEnabled);
|
||||||
Assert.AreEqual(originalSettings.Properties.EnableGcodeThumbnail, viewModel.GCODEThumbnailIsEnabled);
|
Assert.AreEqual(originalSettings.Properties.EnableGcodeThumbnail, viewModel.GCODEThumbnailIsEnabled);
|
||||||
|
Assert.AreEqual(originalSettings.Properties.EnableStlThumbnail, viewModel.STLThumbnailIsEnabled);
|
||||||
|
|
||||||
// Verify that the stub file was used
|
// Verify that the stub file was used
|
||||||
var expectedCallCount = 2; // once via the view model, and once by the test (GetSettings<T>)
|
var expectedCallCount = 2; // once via the view model, and once by the test (GetSettings<T>)
|
||||||
@ -141,6 +142,24 @@ namespace ViewModelTests
|
|||||||
viewModel.GCODEThumbnailIsEnabled = true;
|
viewModel.GCODEThumbnailIsEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void STLThumbnailIsEnabledShouldPrevHandlerWhenSuccessful()
|
||||||
|
{
|
||||||
|
// Assert
|
||||||
|
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||||
|
{
|
||||||
|
SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg);
|
||||||
|
Assert.IsTrue(snd.PowertoysSetting.FileExplorerPreviewSettings.Properties.EnableStlThumbnail);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// arrange
|
||||||
|
PowerPreviewViewModel viewModel = new PowerPreviewViewModel(SettingsRepository<PowerPreviewSettings>.GetInstance(mockPowerPreviewSettingsUtils.Object), SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, PowerPreviewSettings.ModuleName);
|
||||||
|
|
||||||
|
// act
|
||||||
|
viewModel.STLThumbnailIsEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void MDRenderIsEnabledShouldPrevHandlerWhenSuccessful()
|
public void MDRenderIsEnabledShouldPrevHandlerWhenSuccessful()
|
||||||
{
|
{
|
||||||
|
@ -632,6 +632,10 @@
|
|||||||
<value>Enable SVG (.svg) thumbnails</value>
|
<value>Enable SVG (.svg) thumbnails</value>
|
||||||
<comment>Do you want this feature on / off</comment>
|
<comment>Do you want this feature on / off</comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="FileExplorerPreview_ToggleSwitch_STL_Thumbnail.Header" xml:space="preserve">
|
||||||
|
<value>Enable STL (.stl) thumbnails</value>
|
||||||
|
<comment>Do you want this feature on / off</comment>
|
||||||
|
</data>
|
||||||
<data name="FileExplorerPreview_ToggleSwitch_PDF_Thumbnail.Header" xml:space="preserve">
|
<data name="FileExplorerPreview_ToggleSwitch_PDF_Thumbnail.Header" xml:space="preserve">
|
||||||
<value>Enable PDF (.pdf) thumbnails</value>
|
<value>Enable PDF (.pdf) thumbnails</value>
|
||||||
<comment>Do you want this feature on / off</comment>
|
<comment>Do you want this feature on / off</comment>
|
||||||
|
@ -77,6 +77,13 @@
|
|||||||
x:Uid="ToggleSwitch"/>
|
x:Uid="ToggleSwitch"/>
|
||||||
</controls:Setting.ActionContent>
|
</controls:Setting.ActionContent>
|
||||||
</controls:Setting>
|
</controls:Setting>
|
||||||
|
|
||||||
|
<controls:Setting x:Uid="FileExplorerPreview_ToggleSwitch_STL_Thumbnail" Icon="">
|
||||||
|
<controls:Setting.ActionContent>
|
||||||
|
<ToggleSwitch IsOn="{x:Bind Mode=TwoWay, Path=ViewModel.STLThumbnailIsEnabled}"
|
||||||
|
x:Uid="ToggleSwitch"/>
|
||||||
|
</controls:Setting.ActionContent>
|
||||||
|
</controls:Setting>
|
||||||
</controls:SettingsGroup>
|
</controls:SettingsGroup>
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -19,6 +19,7 @@ namespace
|
|||||||
{ HKEY_CLASSES_ROOT, L"CLSID\\{ec52dea8-7c9f-4130-a77b-1737d0418507}" },
|
{ HKEY_CLASSES_ROOT, L"CLSID\\{ec52dea8-7c9f-4130-a77b-1737d0418507}" },
|
||||||
{ HKEY_CLASSES_ROOT, L"CLSID\\{BCC13D15-9720-4CC4-8371-EA74A274741E}" },
|
{ HKEY_CLASSES_ROOT, L"CLSID\\{BCC13D15-9720-4CC4-8371-EA74A274741E}" },
|
||||||
{ HKEY_CLASSES_ROOT, L"CLSID\\{BFEE99B4-B74D-4348-BCA5-E757029647FF}" },
|
{ HKEY_CLASSES_ROOT, L"CLSID\\{BFEE99B4-B74D-4348-BCA5-E757029647FF}" },
|
||||||
|
{ HKEY_CLASSES_ROOT, L"CLSID\\{8BC8AFC2-4E7C-4695-818E-8C1FFDCEA2AF}" },
|
||||||
{ HKEY_CLASSES_ROOT, L"CLSID\\{51B4D7E5-7568-4234-B4BB-47FB3C016A69}\\InprocServer32" },
|
{ HKEY_CLASSES_ROOT, L"CLSID\\{51B4D7E5-7568-4234-B4BB-47FB3C016A69}\\InprocServer32" },
|
||||||
{ HKEY_CLASSES_ROOT, L"CLSID\\{0440049F-D1DC-4E46-B27B-98393D79486B}" },
|
{ HKEY_CLASSES_ROOT, L"CLSID\\{0440049F-D1DC-4E46-B27B-98393D79486B}" },
|
||||||
{ HKEY_CLASSES_ROOT, L"AllFileSystemObjects\\ShellEx\\ContextMenuHandlers\\PowerRenameExt" },
|
{ HKEY_CLASSES_ROOT, L"AllFileSystemObjects\\ShellEx\\ContextMenuHandlers\\PowerRenameExt" },
|
||||||
@ -29,7 +30,8 @@ namespace
|
|||||||
{ HKEY_CLASSES_ROOT, L".pdf\\shellex\\{8895b1c6-b41f-4c1c-a562-0d564250836f}" },
|
{ HKEY_CLASSES_ROOT, L".pdf\\shellex\\{8895b1c6-b41f-4c1c-a562-0d564250836f}" },
|
||||||
{ HKEY_CLASSES_ROOT, L".pdf\\shellex\\{E357FCCD-A995-4576-B01F-234630154E96}" },
|
{ HKEY_CLASSES_ROOT, L".pdf\\shellex\\{E357FCCD-A995-4576-B01F-234630154E96}" },
|
||||||
{ HKEY_CLASSES_ROOT, L".gcode\\shellex\\{8895b1c6-b41f-4c1c-a562-0d564250836f}" },
|
{ HKEY_CLASSES_ROOT, L".gcode\\shellex\\{8895b1c6-b41f-4c1c-a562-0d564250836f}" },
|
||||||
{ HKEY_CLASSES_ROOT, L".gcode\\shellex\\{E357FCCD-A995-4576-B01F-234630154E96}" }
|
{ HKEY_CLASSES_ROOT, L".gcode\\shellex\\{E357FCCD-A995-4576-B01F-234630154E96}" },
|
||||||
|
{ HKEY_CLASSES_ROOT, L".stl\\shellex\\{E357FCCD-A995-4576-B01F-234630154E96}" }
|
||||||
};
|
};
|
||||||
|
|
||||||
vector<tuple<HKEY, wstring, wstring>> registryValues = {
|
vector<tuple<HKEY, wstring, wstring>> registryValues = {
|
||||||
|
Loading…
Reference in New Issue
Block a user