mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-11 17:59:17 +00:00
57 lines
1.3 KiB
C#
57 lines
1.3 KiB
C#
using System.IO;
|
||
using System.Windows;
|
||
|
||
namespace QuickLook.Plugin.ImageViewer
|
||
{
|
||
public class Plugin : IViewer
|
||
{
|
||
private Size _imageSize;
|
||
private ImagePanel _ip;
|
||
|
||
public int Priority => 9999;
|
||
|
||
public bool CanHandle(string path)
|
||
{
|
||
// TODO: determine file type by content
|
||
|
||
if (Directory.Exists(path))
|
||
return false;
|
||
|
||
switch (Path.GetExtension(path).ToLower())
|
||
{
|
||
case ".bmp":
|
||
case ".gif":
|
||
case ".ico":
|
||
case ".jpg":
|
||
case ".png":
|
||
case ".wdp":
|
||
case ".tiff":
|
||
return true;
|
||
|
||
default:
|
||
return false;
|
||
}
|
||
}
|
||
|
||
public void Prepare(string path, ContextObject context)
|
||
{
|
||
_imageSize = ImageFileHelper.GetImageSize(path);
|
||
|
||
context.SetPreferredSizeFit(_imageSize, 0.8);
|
||
}
|
||
|
||
public void View(string path, ContextObject context)
|
||
{
|
||
_ip = new ImagePanel(path);
|
||
|
||
context.ViewerContent = _ip;
|
||
context.Title = $"{Path.GetFileName(path)} ({_imageSize.Width} × {_imageSize.Height})";
|
||
|
||
context.IsBusy = false;
|
||
}
|
||
|
||
public void Dispose()
|
||
{
|
||
}
|
||
}
|
||
} |