mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-02-28 01:00:17 +08:00
Async busy indicator; Change plugin interface, and more
This commit is contained in:
@@ -45,17 +45,19 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Prepare(string path, ViewContentContainer container)
|
||||
public void BoundViewSize(string path, ViewerObject context)
|
||||
{
|
||||
container.PreferedSize = new Size {Width = 800, Height = 600};
|
||||
context.PreferredSize = new Size {Width = 800, Height = 600};
|
||||
}
|
||||
|
||||
public void View(string path, ViewContentContainer container)
|
||||
public void View(string path, ViewerObject context)
|
||||
{
|
||||
_panel = new ArchiveInfoPanel(path);
|
||||
|
||||
container.SetContent(_panel);
|
||||
container.Title = $"{Path.GetFileName(path)}";
|
||||
context.ViewerContent = _panel;
|
||||
context.Title = $"{Path.GetFileName(path)}";
|
||||
|
||||
context.IsBusy = false;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -33,19 +33,21 @@ namespace QuickLook.Plugin.ImageViewer
|
||||
}
|
||||
}
|
||||
|
||||
public void Prepare(string path, ViewContentContainer container)
|
||||
public void BoundViewSize(string path, ViewerObject context)
|
||||
{
|
||||
_imageSize = ImageFileHelper.GetImageSize(path);
|
||||
|
||||
container.SetPreferedSizeFit(_imageSize, 0.8);
|
||||
context.SetPreferredSizeFit(_imageSize, 0.8);
|
||||
}
|
||||
|
||||
public void View(string path, ViewContentContainer container)
|
||||
public void View(string path, ViewerObject context)
|
||||
{
|
||||
_ip = new ImagePanel(path);
|
||||
|
||||
container.SetContent(_ip);
|
||||
container.Title = $"{Path.GetFileName(path)} ({_imageSize.Width} × {_imageSize.Height})";
|
||||
context.ViewerContent = _ip;
|
||||
context.Title = $"{Path.GetFileName(path)} ({_imageSize.Width} × {_imageSize.Height})";
|
||||
|
||||
context.IsBusy = false;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -31,12 +31,12 @@ namespace QuickLook.Plugin.OfficeViewer
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Prepare(string path, ViewContentContainer container)
|
||||
public void BoundViewSize(string path, ViewerObject context)
|
||||
{
|
||||
container.SetPreferedSizeFit(new Size {Width = 800, Height = 600}, 0.8);
|
||||
context.SetPreferredSizeFit(new Size {Width = 800, Height = 600}, 0.8);
|
||||
}
|
||||
|
||||
public void View(string path, ViewContentContainer container)
|
||||
public void View(string path, ViewerObject context)
|
||||
{
|
||||
using (var officeApp = new OfficeInteropWrapper(path))
|
||||
{
|
||||
@@ -59,12 +59,14 @@ namespace QuickLook.Plugin.OfficeViewer
|
||||
throw ex;
|
||||
}
|
||||
|
||||
container.Title = $"{Path.GetFileName(path)} (1 / {_pdfViewer.TotalPages})";
|
||||
context.Title = $"{Path.GetFileName(path)} (1 / {_pdfViewer.TotalPages})";
|
||||
};
|
||||
_pdfViewer.CurrentPageChanged += (sender, e) => container.Title =
|
||||
_pdfViewer.CurrentPageChanged += (sender, e) => context.Title =
|
||||
$"{Path.GetFileName(path)} ({_pdfViewer.CurrectPage + 1} / {_pdfViewer.TotalPages})";
|
||||
|
||||
container.SetContent(_pdfViewer);
|
||||
context.ViewerContent = _pdfViewer;
|
||||
|
||||
context.IsBusy = false;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
public class Plugin : IViewer
|
||||
{
|
||||
private PdfViewerControl _pdfControl;
|
||||
|
||||
public int Priority => int.MaxValue;
|
||||
|
||||
public bool CanHandle(string path)
|
||||
@@ -23,26 +24,28 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
}
|
||||
}
|
||||
|
||||
public void Prepare(string path, ViewContentContainer container)
|
||||
public void BoundViewSize(string path, ViewerObject context)
|
||||
{
|
||||
_pdfControl = new PdfViewerControl();
|
||||
|
||||
var desiredSize = _pdfControl.GetDesiredControlSizeByFirstPage(path);
|
||||
|
||||
container.SetPreferedSizeFit(desiredSize, 0.8);
|
||||
context.SetPreferredSizeFit(desiredSize, 0.8);
|
||||
}
|
||||
|
||||
public void View(string path, ViewContentContainer container)
|
||||
public void View(string path, ViewerObject context)
|
||||
{
|
||||
container.SetContent(_pdfControl);
|
||||
context.ViewerContent = _pdfControl;
|
||||
|
||||
_pdfControl.Loaded += (sender, e) =>
|
||||
{
|
||||
_pdfControl.LoadPdf(path);
|
||||
|
||||
container.Title = $"{Path.GetFileName(path)} (1 / {_pdfControl.TotalPages})";
|
||||
_pdfControl.CurrentPageChanged += (sender2, e2) => container.Title =
|
||||
context.Title = $"{Path.GetFileName(path)} (1 / {_pdfControl.TotalPages})";
|
||||
_pdfControl.CurrentPageChanged += (sender2, e2) => context.Title =
|
||||
$"{Path.GetFileName(path)} ({_pdfControl.CurrectPage + 1} / {_pdfControl.TotalPages})";
|
||||
|
||||
context.IsBusy = false;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -40,17 +40,19 @@ namespace QuickLook.Plugin.TextViewer
|
||||
}
|
||||
}
|
||||
|
||||
public void Prepare(string path, ViewContentContainer container)
|
||||
public void BoundViewSize(string path, ViewerObject context)
|
||||
{
|
||||
container.PreferedSize = new Size {Width = 800, Height = 600};
|
||||
context.PreferredSize = new Size {Width = 800, Height = 600};
|
||||
}
|
||||
|
||||
public void View(string path, ViewContentContainer container)
|
||||
public void View(string path, ViewerObject context)
|
||||
{
|
||||
_tvp = new TextViewerPanel(path);
|
||||
|
||||
container.SetContent(_tvp);
|
||||
container.Title = $"{Path.GetFileName(path)}";
|
||||
context.ViewerContent = _tvp;
|
||||
context.Title = $"{Path.GetFileName(path)}";
|
||||
|
||||
context.IsBusy = false;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
Reference in New Issue
Block a user