mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-11 17:59:17 +00:00
@@ -5,6 +5,7 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:QuickLook.Plugin.ImageViewer"
|
xmlns:local="clr-namespace:QuickLook.Plugin.ImageViewer"
|
||||||
xmlns:animatedImage="clr-namespace:QuickLook.Plugin.ImageViewer.AnimatedImage"
|
xmlns:animatedImage="clr-namespace:QuickLook.Plugin.ImageViewer.AnimatedImage"
|
||||||
|
xmlns:plugin="clr-namespace:QuickLook.Common.Plugin;assembly=QuickLook.Common"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
x:Name="imagePanel"
|
x:Name="imagePanel"
|
||||||
d:DesignHeight="300" d:DesignWidth="300">
|
d:DesignHeight="300" d:DesignWidth="300">
|
||||||
@@ -20,11 +21,32 @@
|
|||||||
<Grid>
|
<Grid>
|
||||||
<Rectangle Visibility="{Binding BackgroundVisibility, ElementName=imagePanel}"
|
<Rectangle Visibility="{Binding BackgroundVisibility, ElementName=imagePanel}"
|
||||||
RenderOptions.BitmapScalingMode="NearestNeighbor">
|
RenderOptions.BitmapScalingMode="NearestNeighbor">
|
||||||
<Rectangle.Fill>
|
<Rectangle.Style>
|
||||||
<ImageBrush x:Name="backgroundBrush" ImageSource="Resources/background-b.png" AlignmentY="Top"
|
<Style>
|
||||||
Viewport="0,0,32,32"
|
<Style.Triggers>
|
||||||
ViewportUnits="Absolute" Stretch="UniformToFill" TileMode="Tile" />
|
<DataTrigger Binding="{Binding ElementName=imagePanel,Path=Theme}" Value="{x:Static plugin:Themes.Dark}">
|
||||||
</Rectangle.Fill>
|
<Setter Property="Rectangle.Fill">
|
||||||
|
<Setter.Value>
|
||||||
|
<ImageBrush AlignmentY="Top" Viewport="0,0,32,32" RenderOptions.BitmapScalingMode="NearestNeighbor"
|
||||||
|
ImageSource="Resources/background-b.png"
|
||||||
|
ViewportUnits="Absolute" Stretch="UniformToFill" TileMode="Tile">
|
||||||
|
</ImageBrush>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</DataTrigger>
|
||||||
|
<DataTrigger Binding="{Binding ElementName=imagePanel,Path=Theme}" Value="{x:Static plugin:Themes.Light}">
|
||||||
|
<Setter Property="Rectangle.Fill">
|
||||||
|
<Setter.Value>
|
||||||
|
<ImageBrush AlignmentY="Top" Viewport="0,0,32,32" RenderOptions.BitmapScalingMode="NearestNeighbor"
|
||||||
|
ImageSource="Resources/background.png"
|
||||||
|
ViewportUnits="Absolute" Stretch="UniformToFill" TileMode="Tile">
|
||||||
|
</ImageBrush>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Rectangle.Style>
|
||||||
</Rectangle>
|
</Rectangle>
|
||||||
<ScrollViewer x:Name="viewPanel" BorderThickness="0" HorizontalScrollBarVisibility="Auto"
|
<ScrollViewer x:Name="viewPanel" BorderThickness="0" HorizontalScrollBarVisibility="Auto"
|
||||||
VerticalScrollBarVisibility="Auto" Focusable="False" IsManipulationEnabled="True">
|
VerticalScrollBarVisibility="Auto" Focusable="False" IsManipulationEnabled="True">
|
||||||
@@ -56,6 +78,11 @@
|
|||||||
Visibility="{Binding ElementName=imagePanel, Path=MetaIconVisibility}"
|
Visibility="{Binding ElementName=imagePanel, Path=MetaIconVisibility}"
|
||||||
Margin="0,8,8,0" Content="" />
|
Margin="0,8,8,0" Content="" />
|
||||||
|
|
||||||
|
<Button x:Name="buttonBackgroundColour" Style="{StaticResource CaptionButtonStyle}" Width="24" Height="24"
|
||||||
|
HorizontalAlignment="Right" VerticalAlignment="Top"
|
||||||
|
Visibility="{Binding ElementName=imagePanel, Path=BackgroundVisibility}"
|
||||||
|
Margin="0,8,40,0" Content="" />
|
||||||
|
|
||||||
<TextBlock x:Name="textMeta" IsHitTestVisible="False" Visibility="Collapsed" HorizontalAlignment="Right"
|
<TextBlock x:Name="textMeta" IsHitTestVisible="False" Visibility="Collapsed" HorizontalAlignment="Right"
|
||||||
VerticalAlignment="Top" FontSize="11"
|
VerticalAlignment="Top" FontSize="11"
|
||||||
Padding="5,5,5,5" Margin="0,40,8,0" Background="{DynamicResource CaptionBackground}"
|
Padding="5,5,5,5" Margin="0,40,8,0" Background="{DynamicResource CaptionBackground}"
|
||||||
|
@@ -33,6 +33,7 @@ using System.Windows.Threading;
|
|||||||
using QuickLook.Common.Annotations;
|
using QuickLook.Common.Annotations;
|
||||||
using QuickLook.Common.ExtensionMethods;
|
using QuickLook.Common.ExtensionMethods;
|
||||||
using QuickLook.Common.Helpers;
|
using QuickLook.Common.Helpers;
|
||||||
|
using QuickLook.Common.Plugin;
|
||||||
using QuickLook.Plugin.ImageViewer.Exiv2;
|
using QuickLook.Plugin.ImageViewer.Exiv2;
|
||||||
|
|
||||||
namespace QuickLook.Plugin.ImageViewer
|
namespace QuickLook.Plugin.ImageViewer
|
||||||
@@ -42,6 +43,7 @@ namespace QuickLook.Plugin.ImageViewer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class ImagePanel : UserControl, INotifyPropertyChanged, IDisposable
|
public partial class ImagePanel : UserControl, INotifyPropertyChanged, IDisposable
|
||||||
{
|
{
|
||||||
|
private readonly ContextObject _context;
|
||||||
private Visibility _backgroundVisibility = Visibility.Visible;
|
private Visibility _backgroundVisibility = Visibility.Visible;
|
||||||
private Point? _dragInitPos;
|
private Point? _dragInitPos;
|
||||||
private Uri _imageSource;
|
private Uri _imageSource;
|
||||||
@@ -70,10 +72,7 @@ namespace QuickLook.Plugin.ImageViewer
|
|||||||
? Visibility.Visible
|
? Visibility.Visible
|
||||||
: Visibility.Collapsed;
|
: Visibility.Collapsed;
|
||||||
|
|
||||||
var scale = DpiHelper.GetCurrentScaleFactor();
|
buttonBackgroundColour.Click += OnBackgroundColourOnClick;
|
||||||
backgroundBrush.Viewport = new Rect(new Size(
|
|
||||||
backgroundBrush.ImageSource.Width / scale.Horizontal,
|
|
||||||
backgroundBrush.ImageSource.Height / scale.Vertical));
|
|
||||||
|
|
||||||
SizeChanged += ImagePanel_SizeChanged;
|
SizeChanged += ImagePanel_SizeChanged;
|
||||||
|
|
||||||
@@ -86,11 +85,13 @@ namespace QuickLook.Plugin.ImageViewer
|
|||||||
viewPanel.ManipulationDelta += ViewPanel_ManipulationDelta;
|
viewPanel.ManipulationDelta += ViewPanel_ManipulationDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal ImagePanel(Meta meta) : this()
|
internal ImagePanel(ContextObject context, Meta meta) : this()
|
||||||
{
|
{
|
||||||
|
_context = context;
|
||||||
Meta = meta;
|
Meta = meta;
|
||||||
|
|
||||||
ShowMeta();
|
ShowMeta();
|
||||||
|
Theme = _context.Theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ShowZoomLevelInfo
|
public bool ShowZoomLevelInfo
|
||||||
@@ -104,6 +105,16 @@ namespace QuickLook.Plugin.ImageViewer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Themes Theme
|
||||||
|
{
|
||||||
|
get => _context?.Theme ?? Themes.Dark;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_context.Theme = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public BitmapScalingMode RenderMode
|
public BitmapScalingMode RenderMode
|
||||||
{
|
{
|
||||||
get => _renderMode;
|
get => _renderMode;
|
||||||
@@ -235,6 +246,13 @@ namespace QuickLook.Plugin.ImageViewer
|
|||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
private void OnBackgroundColourOnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Theme = Theme == Themes.Dark ? Themes.Light : Themes.Dark;
|
||||||
|
|
||||||
|
SettingHelper.Set("LastTheme", (int) Theme);
|
||||||
|
}
|
||||||
|
|
||||||
private void ShowMeta()
|
private void ShowMeta()
|
||||||
{
|
{
|
||||||
textMeta.Inlines.Clear();
|
textMeta.Inlines.Clear();
|
||||||
|
@@ -20,6 +20,7 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using ImageMagick;
|
using ImageMagick;
|
||||||
|
using QuickLook.Common.Helpers;
|
||||||
using QuickLook.Common.Plugin;
|
using QuickLook.Common.Plugin;
|
||||||
using QuickLook.Plugin.ImageViewer.Exiv2;
|
using QuickLook.Plugin.ImageViewer.Exiv2;
|
||||||
|
|
||||||
@@ -64,12 +65,12 @@ namespace QuickLook.Plugin.ImageViewer
|
|||||||
else
|
else
|
||||||
context.PreferredSize = new Size(800, 600);
|
context.PreferredSize = new Size(800, 600);
|
||||||
|
|
||||||
context.Theme = Themes.Dark;
|
context.Theme = (Themes) SettingHelper.Get("LastTheme", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void View(string path, ContextObject context)
|
public void View(string path, ContextObject context)
|
||||||
{
|
{
|
||||||
_ip = new ImagePanel(_meta);
|
_ip = new ImagePanel(context, _meta);
|
||||||
|
|
||||||
context.ViewerContent = _ip;
|
context.ViewerContent = _ip;
|
||||||
context.Title = _imageSize.IsEmpty
|
context.Title = _imageSize.IsEmpty
|
||||||
|
Reference in New Issue
Block a user