mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-16 21:32:39 +00:00
Finish ImageViewer; mouse drag to scroll
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
|
||||
namespace QuickLook.Plugin.LastResort
|
||||
{
|
||||
public class Plugin : IViewer
|
||||
{
|
||||
private InfoPanel _ip;
|
||||
private bool _stop;
|
||||
|
||||
public int Priority => int.MinValue;
|
||||
|
||||
@@ -16,7 +13,7 @@ namespace QuickLook.Plugin.LastResort
|
||||
return true;
|
||||
}
|
||||
|
||||
public void BoundSize(string path, ViewContentContainer container)
|
||||
public void Prepare(string path, ViewContentContainer container)
|
||||
{
|
||||
_ip = new InfoPanel();
|
||||
|
||||
@@ -26,55 +23,14 @@ namespace QuickLook.Plugin.LastResort
|
||||
|
||||
public void View(string path, ViewContentContainer container)
|
||||
{
|
||||
DisplayInfo(path);
|
||||
_ip.DisplayInfo(path);
|
||||
|
||||
container.SetContent(_ip);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
_stop = true;
|
||||
}
|
||||
|
||||
|
||||
private void DisplayInfo(string path)
|
||||
{
|
||||
var icon = IconHelper.GetBitmapFromPath(path, IconHelper.IconSizeEnum.ExtraLargeIcon).ToBitmapSource();
|
||||
|
||||
_ip.image.Source = icon;
|
||||
|
||||
var name = Path.GetFileName(path);
|
||||
_ip.filename.Content = string.IsNullOrEmpty(name) ? path : name;
|
||||
|
||||
var last = File.GetLastWriteTime(path);
|
||||
_ip.modDate.Content = $"{last.ToLongDateString()} {last.ToLongTimeString()}";
|
||||
|
||||
_stop = false;
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
var size = new FileInfo(path).Length;
|
||||
|
||||
_ip.Dispatcher.Invoke(() => { _ip.totalSize.Content = size.ToPrettySize(2); });
|
||||
}
|
||||
else if (Directory.Exists(path))
|
||||
{
|
||||
long totalDirs;
|
||||
long totalFiles;
|
||||
long totalSize;
|
||||
|
||||
FileHelper.CountFolder(path, ref _stop, out totalDirs, out totalFiles, out totalSize);
|
||||
|
||||
if (!_stop)
|
||||
_ip.Dispatcher.Invoke(() =>
|
||||
{
|
||||
_ip.totalSize.Content =
|
||||
$"{totalSize.ToPrettySize(2)} ({totalDirs} folders and {totalFiles} files.)";
|
||||
});
|
||||
}
|
||||
});
|
||||
_ip.Stop = true;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user