Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 12 additions & 28 deletions QuickLook.Plugin/QuickLook.Plugin.ImageViewer/ImagePanel.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
Margin="0,0,8,0"
Content=""
Style="{StaticResource CaptionButtonStyle}"
ToolTip="{Binding CopyTooltip, ElementName=imagePanel}"
Visibility="{Binding ElementName=imagePanel, Path=CopyIconVisibility}" />
<Button x:Name="buttonSaveAs"
Width="24"
Expand All @@ -127,41 +128,24 @@
Margin="0,0,8,0"
Content="&#xE946;"
Style="{StaticResource CaptionButtonStyle}"
Visibility="{Binding ElementName=imagePanel, Path=MetaIconVisibility}" />
ToolTipService.InitialShowDelay="0"
Visibility="{Binding ElementName=imagePanel, Path=MetaIconVisibility}">
<Button.ToolTip>
<ToolTip>
<TextBlock x:Name="textMetaContent"
FontSize="11"
Foreground="{DynamicResource WindowTextForeground}" />
</ToolTip>
</Button.ToolTip>
</Button>
<Button x:Name="buttonBackgroundColour"
Width="24"
Height="24"
Margin="0,0,8,0"
Content="&#xEF1F;"
Style="{StaticResource CaptionButtonStyle}"
ToolTip="{Binding BackgroundTooltip, ElementName=imagePanel}"
Visibility="{Binding ElementName=imagePanel, Path=BackgroundVisibility}" />
</StackPanel>
<TextBlock x:Name="textMeta"
Margin="0,40,8,0"
Padding="5,5,5,5"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Background="{DynamicResource CaptionBackground}"
FontSize="11"
Foreground="{DynamicResource WindowTextForeground}"
IsHitTestVisible="False">
<TextBlock.Inlines>
<Run FontWeight="SemiBold">Camera maker</Run>
<Run>:&#160;</Run>
<Run>SONY</Run>
</TextBlock.Inlines>
<TextBlock.Style>
<Style>
<Style.Setters>
<Setter Property="TextBlock.Visibility" Value="Collapsed" />
</Style.Setters>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=buttonMeta, Path=IsMouseOver}" Value="True">
<Setter Property="TextBlock.Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</UserControl>
43 changes: 30 additions & 13 deletions QuickLook.Plugin/QuickLook.Plugin.ImageViewer/ImagePanel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
Expand Down Expand Up @@ -66,6 +67,9 @@ public partial class ImagePanel : UserControl, INotifyPropertyChanged, IDisposab
private Visibility _reverseColorVisibility = Visibility.Collapsed;
private Visibility _metaIconVisibility = Visibility.Visible;

public string CopyTooltip { get; } = GetTranslation("IV_Copy");
public string BackgroundTooltip { get; } = GetTranslation("IV_Background");

public ImagePanel()
{
InitializeComponent();
Expand All @@ -78,11 +82,6 @@ public ImagePanel()

buttonReverseColor.Click += OnReverseColorOnClick;

buttonMeta.Click += (sender, e) =>
textMeta.Visibility = textMeta.Visibility == Visibility.Collapsed
? Visibility.Visible
: Visibility.Collapsed;

buttonBackgroundColour.Click += OnBackgroundColourOnClick;

SizeChanged += ImagePanel_SizeChanged;
Expand Down Expand Up @@ -111,6 +110,15 @@ public ImagePanel()
viewPanel.ManipulationDelta += ViewPanel_ManipulationDelta;
}

private static string GetTranslation(string key)
{
var translationFile = Path.Combine(
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
"Translations.config");

return TranslationHelper.Get(key, translationFile);
}

internal ImagePanel(ContextObject context, MetaProvider meta) : this()
{
ContextObject = context;
Expand Down Expand Up @@ -401,19 +409,28 @@ private void OnBackgroundColourOnClick(object sender, RoutedEventArgs e)

private void ShowMeta()
{
textMeta.Inlines.Clear();
Meta.GetExif().Values.ForEach(m =>
textMetaContent.Inlines.Clear();
Meta.GetExif()
.OrderBy(item => item.Key switch
{
"_.Size.Width" => 0,
"_.Size.Height" => 1,
_ => 2,
})
.Select(item => item.Value)
.ForEach(m =>
{
if (string.IsNullOrWhiteSpace(m.Item1) || string.IsNullOrWhiteSpace(m.Item2))
return;

textMeta.Inlines.Add(new Run(m.Item1) { FontWeight = FontWeights.SemiBold });
textMeta.Inlines.Add(": ");
textMeta.Inlines.Add(m.Item2);
textMeta.Inlines.Add("\r\n");
textMetaContent.Inlines.Add(new Run(m.Item1) { FontWeight = FontWeights.SemiBold });
textMetaContent.Inlines.Add(": ");
textMetaContent.Inlines.Add(m.Item2);
textMetaContent.Inlines.Add("\r\n");
});
textMeta.Inlines.Remove(textMeta.Inlines.LastInline);
if (!textMeta.Inlines.Any())
if (textMetaContent.Inlines.LastInline != null)
textMetaContent.Inlines.Remove(textMetaContent.Inlines.LastInline);
if (!textMetaContent.Inlines.Any())
MetaIconVisibility = Visibility.Collapsed;
}

Expand Down
Loading