forked from QL-Win/QuickLook.Plugin.HelloWorld
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathPlugin.cs
45 lines (36 loc) · 1.01 KB
/
Plugin.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using QuickLook.Common.Plugin;
namespace QuickLook.Plugin.TorrentViewer
{
public class Plugin : IViewer
{
private TorrentInfoPanel _panel;
public int Priority => 0;
public void Init()
{
}
public bool CanHandle(string path)
{
return File.Exists(path) && path.EndsWith(".torrent", StringComparison.OrdinalIgnoreCase);
}
public void Prepare(string path, ContextObject context)
{
context.PreferredSize = new Size {Width = 800, Height = 400};
}
public void View(string path, ContextObject context)
{
_panel = new TorrentInfoPanel(path);
context.ViewerContent = _panel;
context.Title = $"{Path.GetFileName(path)}";
context.IsBusy = false;
}
public void Cleanup()
{
_panel?.Dispose();
_panel = null;
}
}
}