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:local="clr-namespace:QuickLook.Plugin.ImageViewer"
|
||||
xmlns:animatedImage="clr-namespace:QuickLook.Plugin.ImageViewer.AnimatedImage"
|
||||
xmlns:plugin="clr-namespace:QuickLook.Common.Plugin;assembly=QuickLook.Common"
|
||||
mc:Ignorable="d"
|
||||
x:Name="imagePanel"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
@@ -20,11 +21,32 @@
|
||||
<Grid>
|
||||
<Rectangle Visibility="{Binding BackgroundVisibility, ElementName=imagePanel}"
|
||||
RenderOptions.BitmapScalingMode="NearestNeighbor">
|
||||
<Rectangle.Fill>
|
||||
<ImageBrush x:Name="backgroundBrush" ImageSource="Resources/background-b.png" AlignmentY="Top"
|
||||
Viewport="0,0,32,32"
|
||||
ViewportUnits="Absolute" Stretch="UniformToFill" TileMode="Tile" />
|
||||
</Rectangle.Fill>
|
||||
<Rectangle.Style>
|
||||
<Style>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ElementName=imagePanel,Path=Theme}" Value="{x:Static plugin:Themes.Dark}">
|
||||
<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>
|
||||
<ScrollViewer x:Name="viewPanel" BorderThickness="0" HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Auto" Focusable="False" IsManipulationEnabled="True">
|
||||
@@ -56,6 +78,11 @@
|
||||
Visibility="{Binding ElementName=imagePanel, Path=MetaIconVisibility}"
|
||||
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"
|
||||
VerticalAlignment="Top" FontSize="11"
|
||||
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.ExtensionMethods;
|
||||
using QuickLook.Common.Helpers;
|
||||
using QuickLook.Common.Plugin;
|
||||
using QuickLook.Plugin.ImageViewer.Exiv2;
|
||||
|
||||
namespace QuickLook.Plugin.ImageViewer
|
||||
@@ -42,6 +43,7 @@ namespace QuickLook.Plugin.ImageViewer
|
||||
/// </summary>
|
||||
public partial class ImagePanel : UserControl, INotifyPropertyChanged, IDisposable
|
||||
{
|
||||
private readonly ContextObject _context;
|
||||
private Visibility _backgroundVisibility = Visibility.Visible;
|
||||
private Point? _dragInitPos;
|
||||
private Uri _imageSource;
|
||||
@@ -70,10 +72,7 @@ namespace QuickLook.Plugin.ImageViewer
|
||||
? Visibility.Visible
|
||||
: Visibility.Collapsed;
|
||||
|
||||
var scale = DpiHelper.GetCurrentScaleFactor();
|
||||
backgroundBrush.Viewport = new Rect(new Size(
|
||||
backgroundBrush.ImageSource.Width / scale.Horizontal,
|
||||
backgroundBrush.ImageSource.Height / scale.Vertical));
|
||||
buttonBackgroundColour.Click += OnBackgroundColourOnClick;
|
||||
|
||||
SizeChanged += ImagePanel_SizeChanged;
|
||||
|
||||
@@ -86,11 +85,13 @@ namespace QuickLook.Plugin.ImageViewer
|
||||
viewPanel.ManipulationDelta += ViewPanel_ManipulationDelta;
|
||||
}
|
||||
|
||||
internal ImagePanel(Meta meta) : this()
|
||||
internal ImagePanel(ContextObject context, Meta meta) : this()
|
||||
{
|
||||
_context = context;
|
||||
Meta = meta;
|
||||
|
||||
ShowMeta();
|
||||
Theme = _context.Theme;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
get => _renderMode;
|
||||
@@ -235,6 +246,13 @@ namespace QuickLook.Plugin.ImageViewer
|
||||
|
||||
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()
|
||||
{
|
||||
textMeta.Inlines.Clear();
|
||||
|
@@ -20,6 +20,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using ImageMagick;
|
||||
using QuickLook.Common.Helpers;
|
||||
using QuickLook.Common.Plugin;
|
||||
using QuickLook.Plugin.ImageViewer.Exiv2;
|
||||
|
||||
@@ -64,12 +65,12 @@ namespace QuickLook.Plugin.ImageViewer
|
||||
else
|
||||
context.PreferredSize = new Size(800, 600);
|
||||
|
||||
context.Theme = Themes.Dark;
|
||||
context.Theme = (Themes) SettingHelper.Get("LastTheme", 1);
|
||||
}
|
||||
|
||||
public void View(string path, ContextObject context)
|
||||
{
|
||||
_ip = new ImagePanel(_meta);
|
||||
_ip = new ImagePanel(context, _meta);
|
||||
|
||||
context.ViewerContent = _ip;
|
||||
context.Title = _imageSize.IsEmpty
|
||||
|
Reference in New Issue
Block a user