mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-13 19:19:10 +00:00
Add Sketch file support to ThumbnailViewer plugin
This commit is contained in:
@@ -74,6 +74,20 @@ internal static class Handler
|
||||
context.PreferredSize = new Size { Width = 100, Height = 100 };
|
||||
}
|
||||
}
|
||||
else if (path.EndsWith(".sketch", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
try
|
||||
{
|
||||
using Stream imageData = ViewImage(path);
|
||||
BitmapImage bitmap = imageData.ReadAsBitmapImage();
|
||||
context.SetPreferredSizeFit(new Size(bitmap.PixelWidth, bitmap.PixelHeight), 0.8d);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_ = e;
|
||||
context.PreferredSize = new Size { Width = 100, Height = 100 };
|
||||
}
|
||||
}
|
||||
else if (path.EndsWith(".xmind", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
try
|
||||
@@ -195,6 +209,22 @@ internal static class Handler
|
||||
StreamResourceInfo info = Application.GetResourceStream(new Uri("pack://application:,,,/QuickLook.Plugin.ThumbnailViewer;component/Resources/broken.png"));
|
||||
return info?.Stream;
|
||||
}
|
||||
else if (path.EndsWith(".sketch", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
using ZipArchive archive = ZipArchive.Open(path, new());
|
||||
using IReader reader = archive.ExtractAllEntries();
|
||||
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
if (reader.Entry.Key!.EndsWith("previews/preview.png", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
MemoryStream ms = new();
|
||||
using EntryStream stream = reader.OpenEntryStream();
|
||||
stream.CopyTo(ms);
|
||||
return ms;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (path.EndsWith(".xmind", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
using ZipArchive archive = ZipArchive.Open(path, new());
|
||||
|
@@ -34,6 +34,7 @@ public class Plugin : IViewer
|
||||
".fig", // Figma
|
||||
".kra", // Krita
|
||||
".pip", ".pix", // Pixso
|
||||
".sketch", // Sketch
|
||||
".xd", // AdobeXD
|
||||
".xmind", // XMind
|
||||
]);
|
||||
|
Reference in New Issue
Block a user