mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-17 22:12:38 +00:00
minor zoom improvements
This commit is contained in:
@@ -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);
|
||||
|
||||
|
@@ -89,7 +89,7 @@
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Fill" TargetName="grip" Value="{DynamicResource MainWindowBackground}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsKeyboardFocused" Value="true">
|
||||
<Trigger Property="IsKeyboardFocused" Value="False">
|
||||
<Setter Property="Fill" TargetName="grip" Value="{DynamicResource WindowTextForeground}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
@@ -124,13 +124,14 @@
|
||||
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="false" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="MinHeight" Value="26" />
|
||||
<Setter Property="MaxHeight" Value="26" />
|
||||
<Setter Property="Height" Value="26" />
|
||||
<Setter Property="MinHeight" Value="16" />
|
||||
<Setter Property="MaxHeight" Value="16" />
|
||||
<Setter Property="Height" Value="16" />
|
||||
<Setter Property="Minimum" Value="0" />
|
||||
<Setter Property="IsSnapToTickEnabled" Value="True" />
|
||||
<Setter Property="SmallChange" Value="0.01" />
|
||||
<Setter Property="LargeChange" Value="0.01" />
|
||||
<Setter Property="Focusable" Value="False" />
|
||||
<Setter Property="TickFrequency" Value="0.01" />
|
||||
<Setter Property="AutoToolTipPlacement" Value="None" />
|
||||
<Setter Property="IsMoveToPointEnabled" Value="True" />
|
||||
|
@@ -25,10 +25,10 @@
|
||||
<Grid x:Name="coverArtPersenter" ClipToBounds="True" Background="{StaticResource MainWindowBackground}">
|
||||
<Grid.Style>
|
||||
<Style TargetType="Grid">
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding HasVideo, ElementName=viewerPanel}" Value="True">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding HasVideo, ElementName=viewerPanel}" Value="False">
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
@@ -145,7 +145,8 @@
|
||||
<Button x:Name="buttonMute" DockPanel.Dock="Right">
|
||||
<Button.Style>
|
||||
<Style TargetType="Button" BasedOn="{StaticResource ControlButtonStyle}">
|
||||
<Setter Property="Content" Value="{Binding ElementName=mediaElement, Path=Volume, Converter={StaticResource VolumeToIconConverter}}" />
|
||||
<Setter Property="Content"
|
||||
Value="{Binding ElementName=mediaElement, Path=Volume, Converter={StaticResource VolumeToIconConverter}}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsMuted, ElementName=viewerPanel}"
|
||||
Value="True">
|
||||
@@ -155,15 +156,57 @@
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
<Button Width="Auto" Style="{StaticResource ControlButtonStyle}" DockPanel.Dock="Right">
|
||||
<TextBlock DockPanel.Dock="Right" VerticalAlignment="Center" FontSize="11" FontFamily="{Binding ElementName=viewerPanel, Path=FontFamily}"
|
||||
Foreground="{DynamicResource CaptionButtonIconForeground}"
|
||||
Text="{Binding ElementName=mediaElement, Path=Time, Converter={StaticResource TimeSpanToShortStringConverter}}" />
|
||||
<Button x:Name="buttonTime" Width="37" Style="{StaticResource ControlButtonStyle}" DockPanel.Dock="Right" Tag="Time">
|
||||
<TextBlock VerticalAlignment="Center" FontSize="11"
|
||||
FontFamily="{Binding ElementName=viewerPanel, Path=FontFamily}"
|
||||
Foreground="{DynamicResource CaptionButtonIconForeground}">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ElementName=buttonTime, Path=Tag}" Value="Time">
|
||||
<Setter Property="Text"
|
||||
Value="{Binding ElementName=mediaElement, Path=Time, Converter={StaticResource TimeSpanToShortStringConverter}}" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding ElementName=buttonTime, Path=Tag}" Value="Length">
|
||||
<Setter Property="Text"
|
||||
Value="{Binding ElementName=mediaElement, Path=Length, Converter={StaticResource TimeSpanToShortStringConverter}}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
</Button>
|
||||
<Slider x:Name="sliderProgress" Style="{StaticResource PositionSliderStyle}"
|
||||
SmallChange="0.00001" LargeChange="0.01" Maximum="1"
|
||||
Value="{Binding Position, ElementName=mediaElement}" />
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
<!--<Grid Height="32" Width="100" HorizontalAlignment="Right" VerticalAlignment="Bottom"
|
||||
Background="{DynamicResource CaptionBackground}" Margin="0,0,0,32">
|
||||
<Grid.Style>
|
||||
<Style TargetType="Grid">
|
||||
<Setter Property="Opacity" Value="0" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ElementName=buttonMute, Path=IsMouseOver}" Value="True">
|
||||
<DataTrigger.EnterActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard TargetProperty="Opacity">
|
||||
<DoubleAnimation To="1" Duration="0:0:0.1" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</DataTrigger.EnterActions>
|
||||
<DataTrigger.ExitActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard TargetProperty="Opacity">
|
||||
<DoubleAnimation To="0" Duration="0:0:0.1" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</DataTrigger.ExitActions>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Grid.Style>
|
||||
<Slider Style="{StaticResource CustomSliderStyle}" Width="100" Maximum="100" Value="{Binding ElementName=mediaElement, Path=Volume}" />
|
||||
</Grid>-->
|
||||
</Grid>
|
||||
</UserControl>
|
@@ -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) =>
|
||||
|
@@ -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;
|
||||
|
@@ -1,7 +1,6 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:fa="http://schemas.fontawesome.io/icons/">
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
<system:Double x:Key="MainWindowShadowBlurRadius">6</system:Double>
|
||||
<Thickness x:Key="MainWindowShadowPaddingThinkness">6</Thickness>
|
||||
<system:Double x:Key="MainWindowCaptionHeight">32</system:Double>
|
||||
|
Reference in New Issue
Block a user