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,4 +1,6 @@
using System.Windows.Controls;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Controls;
namespace QuickLook.Plugin.LastResort
{
@@ -7,9 +9,57 @@ namespace QuickLook.Plugin.LastResort
/// </summary>
public partial class InfoPanel : UserControl
{
private bool _stop;
public InfoPanel()
{
InitializeComponent();
}
public bool Stop
{
set => _stop = value;
get => _stop;
}
public void DisplayInfo(string path)
{
var icon = IconHelper.GetBitmapFromPath(path, IconHelper.IconSizeEnum.ExtraLargeIcon).ToBitmapSource();
image.Source = icon;
var name = Path.GetFileName(path);
filename.Content = string.IsNullOrEmpty(name) ? path : name;
var last = File.GetLastWriteTime(path);
modDate.Content = $"{last.ToLongDateString()} {last.ToLongTimeString()}";
Stop = false;
Task.Run(() =>
{
if (File.Exists(path))
{
var size = new FileInfo(path).Length;
Dispatcher.Invoke(() => { totalSize.Content = size.ToPrettySize(2); });
}
else if (Directory.Exists(path))
{
long totalDirsL;
long totalFilesL;
long totalSizeL;
FileHelper.CountFolder(path, ref _stop, out totalDirsL, out totalFilesL, out totalSizeL);
if (!Stop)
Dispatcher.Invoke(() =>
{
totalSize.Content =
$"{totalSizeL.ToPrettySize(2)} ({totalDirsL} folders and {totalFilesL} files)";
});
}
});
}
}
}