diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/ImagePanel.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/ImagePanel.xaml.cs index c1b7d71..df85d63 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/ImagePanel.xaml.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/ImagePanel.xaml.cs @@ -48,6 +48,7 @@ namespace QuickLook.Plugin.ImageViewer private double _zoomFactor = 1d; private bool _zoomToFit = true; + private double _zoomToFitFactor; public ImagePanel() { @@ -119,6 +120,16 @@ namespace QuickLook.Plugin.ImageViewer } } + public double ZoomToFitFactor + { + get => _zoomToFitFactor; + private set + { + _zoomToFitFactor = value; + OnPropertyChanged(); + } + } + public double ZoomFactor { get => _zoomFactor; @@ -190,7 +201,7 @@ namespace QuickLook.Plugin.ImageViewer var newZoom = ZoomFactor + ZoomFactor * (delta.Scale.X - 1); - Zoom(newZoom, false); + Zoom(newZoom); viewPanel.ScrollToHorizontalOffset(viewPanel.HorizontalOffset - delta.Translation.X); viewPanel.ScrollToVerticalOffset(viewPanel.VerticalOffset - delta.Translation.Y); @@ -225,8 +236,6 @@ namespace QuickLook.Plugin.ImageViewer var delta = _dragInitPos.Value - e.GetPosition(viewPanel); - Debug.WriteLine(_dragInitPos.Value); - viewPanel.ScrollToHorizontalOffset(delta.X); viewPanel.ScrollToVerticalOffset(delta.Y); } @@ -248,7 +257,7 @@ namespace QuickLook.Plugin.ImageViewer // zoom var newZoom = ZoomFactor + ZoomFactor * e.Delta / 120 * 0.1; - Zoom(newZoom, false); + Zoom(newZoom); } public Size GetScrollSize() @@ -275,28 +284,34 @@ namespace QuickLook.Plugin.ImageViewer var factor = Math.Min(viewPanel.ActualWidth / viewPanelImage.Source.Width, viewPanel.ActualHeight / viewPanelImage.Source.Height); - Zoom(factor, true); + ZoomToFitFactor = factor; + + Zoom(factor); } public void ResetZoom() { - Zoom(1d, false, true); + Zoom(1d, true); } - public void Zoom(double factor, bool toFit, bool suppressEvent = false) + public void Zoom(double factor, bool suppressEvent = false) { if (viewPanelImage.Source == null) return; + if (ZoomFactor < ZoomToFitFactor && factor > ZoomToFitFactor + || ZoomFactor > ZoomToFitFactor && factor < ZoomToFitFactor) + { + factor = ZoomToFitFactor; + ZoomToFit = true; + } + factor = Math.Max(factor, MinZoomFactor); factor = Math.Min(factor, MaxZoomFactor); ZoomFactor = factor; - if (!toFit) - ZoomToFit = false; - - var position = toFit + var position = ZoomToFit ? new Point(viewPanelImage.Source.Width / 2, viewPanelImage.Source.Height / 2) : Mouse.GetPosition(viewPanelImage); diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Styles.xaml b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Styles.xaml index 1bd8f97..c7bb850 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Styles.xaml +++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Styles.xaml @@ -89,7 +89,7 @@ - + @@ -124,13 +124,14 @@ - - - + + + + diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml index fade94a..4c9a9e1 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml +++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml @@ -25,10 +25,10 @@ @@ -135,7 +135,7 @@ + Value="False"> @@ -145,25 +145,68 @@ - + \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs index a1a6c98..d76eefc 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs @@ -64,11 +64,7 @@ namespace QuickLook.Plugin.VideoViewer _context = context; buttonPlayPause.Click += TogglePlayPause; - //buttonMute.MouseLeftButtonUp += (sender, e) => - //{ - // mediaElement.IsMuted = false; - // buttonMute.Visibility = Visibility.Collapsed; - //}; + buttonTime.Click += (sender, e) => buttonTime.Tag = (string) buttonTime.Tag == "Time" ? "Length" : "Time"; buttonMute.Click += (sender, e) => IsMuted = !IsMuted; sliderProgress.PreviewMouseDown += (sender, e) => diff --git a/QuickLook/Controls/GlassLayer/ElementCoordinateConverter.cs b/QuickLook/Controls/GlassLayer/ElementCoordinateConverter.cs index 571d634..0ae269d 100644 --- a/QuickLook/Controls/GlassLayer/ElementCoordinateConverter.cs +++ b/QuickLook/Controls/GlassLayer/ElementCoordinateConverter.cs @@ -26,7 +26,7 @@ namespace QuickLook.Controls.GlassLayer { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - var glass = (GlassLayer) value; + var glass = value as GlassLayer; if (glass?.BlurredElement == null) return null; diff --git a/QuickLook/Styles/MainWindowStyles.xaml b/QuickLook/Styles/MainWindowStyles.xaml index 3649141..f9c4325 100644 --- a/QuickLook/Styles/MainWindowStyles.xaml +++ b/QuickLook/Styles/MainWindowStyles.xaml @@ -1,7 +1,6 @@  + xmlns:system="clr-namespace:System;assembly=mscorlib"> 6 6 32