Finish ImageViewer; mouse drag to scroll

This commit is contained in:
Paddy Xu
2017-04-26 00:48:40 +03:00
parent c38c640af5
commit fa764b2e69
20 changed files with 445 additions and 61 deletions

View File

@@ -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;
}
}
}