mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-11 17:59:17 +00:00
Add a copy button to the image viewer #1399
This commit is contained in:
@@ -91,12 +91,22 @@
|
|||||||
</Border.Resources>
|
</Border.Resources>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
<StackPanel Margin="0,8,0,0"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<Button x:Name="buttonCopy"
|
||||||
|
Width="24"
|
||||||
|
Height="24"
|
||||||
|
Margin="0,0,8,0"
|
||||||
|
Content=""
|
||||||
|
Style="{StaticResource CaptionButtonStyle}"
|
||||||
|
Visibility="{Binding ElementName=imagePanel, Path=CopyIconVisibility}" />
|
||||||
|
|
||||||
<Button x:Name="buttonMeta"
|
<Button x:Name="buttonMeta"
|
||||||
Width="24"
|
Width="24"
|
||||||
Height="24"
|
Height="24"
|
||||||
Margin="0,8,40,0"
|
Margin="0,0,8,0"
|
||||||
HorizontalAlignment="Right"
|
|
||||||
VerticalAlignment="Top"
|
|
||||||
Content=""
|
Content=""
|
||||||
Style="{StaticResource CaptionButtonStyle}"
|
Style="{StaticResource CaptionButtonStyle}"
|
||||||
Visibility="{Binding ElementName=imagePanel, Path=MetaIconVisibility}" />
|
Visibility="{Binding ElementName=imagePanel, Path=MetaIconVisibility}" />
|
||||||
@@ -104,12 +114,11 @@
|
|||||||
<Button x:Name="buttonBackgroundColour"
|
<Button x:Name="buttonBackgroundColour"
|
||||||
Width="24"
|
Width="24"
|
||||||
Height="24"
|
Height="24"
|
||||||
Margin="0,8,8,0"
|
Margin="0,0,8,0"
|
||||||
HorizontalAlignment="Right"
|
|
||||||
VerticalAlignment="Top"
|
|
||||||
Content=""
|
Content=""
|
||||||
Style="{StaticResource CaptionButtonStyle}"
|
Style="{StaticResource CaptionButtonStyle}"
|
||||||
Visibility="{Binding ElementName=imagePanel, Path=BackgroundVisibility}" />
|
Visibility="{Binding ElementName=imagePanel, Path=BackgroundVisibility}" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
<TextBlock x:Name="textMeta"
|
<TextBlock x:Name="textMeta"
|
||||||
Margin="0,40,8,0"
|
Margin="0,40,8,0"
|
||||||
|
@@ -49,6 +49,7 @@ public partial class ImagePanel : UserControl, INotifyPropertyChanged, IDisposab
|
|||||||
private bool _isZoomFactorFirstSet = true;
|
private bool _isZoomFactorFirstSet = true;
|
||||||
private DateTime _lastZoomTime = DateTime.MinValue;
|
private DateTime _lastZoomTime = DateTime.MinValue;
|
||||||
private double _maxZoomFactor = 3d;
|
private double _maxZoomFactor = 3d;
|
||||||
|
private Visibility _copyIconVisibility = Visibility.Visible;
|
||||||
private MetaProvider _meta;
|
private MetaProvider _meta;
|
||||||
private Visibility _metaIconVisibility = Visibility.Visible;
|
private Visibility _metaIconVisibility = Visibility.Visible;
|
||||||
private double _minZoomFactor = 0.1d;
|
private double _minZoomFactor = 0.1d;
|
||||||
@@ -67,6 +68,8 @@ public partial class ImagePanel : UserControl, INotifyPropertyChanged, IDisposab
|
|||||||
|
|
||||||
Resources.MergedDictionaries.Clear();
|
Resources.MergedDictionaries.Clear();
|
||||||
|
|
||||||
|
buttonCopy.Click += OnCopyOnClick;
|
||||||
|
|
||||||
buttonMeta.Click += (sender, e) =>
|
buttonMeta.Click += (sender, e) =>
|
||||||
textMeta.Visibility = textMeta.Visibility == Visibility.Collapsed
|
textMeta.Visibility = textMeta.Visibility == Visibility.Collapsed
|
||||||
? Visibility.Visible
|
? Visibility.Visible
|
||||||
@@ -162,6 +165,16 @@ public partial class ImagePanel : UserControl, INotifyPropertyChanged, IDisposab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Visibility CopyIconVisibility
|
||||||
|
{
|
||||||
|
get => _copyIconVisibility;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_copyIconVisibility = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Visibility BackgroundVisibility
|
public Visibility BackgroundVisibility
|
||||||
{
|
{
|
||||||
get => _backgroundVisibility;
|
get => _backgroundVisibility;
|
||||||
@@ -274,6 +287,28 @@ public partial class ImagePanel : UserControl, INotifyPropertyChanged, IDisposab
|
|||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
private void OnCopyOnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_source is not null)
|
||||||
|
{
|
||||||
|
Clipboard.SetImage(_source);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (viewPanelImage.Source is BitmapSource bitmapSource)
|
||||||
|
{
|
||||||
|
Clipboard.SetImage(bitmapSource);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
///
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OnBackgroundColourOnClick(object sender, RoutedEventArgs e)
|
private void OnBackgroundColourOnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Theme = Theme == Themes.Dark ? Themes.Light : Themes.Dark;
|
Theme = Theme == Themes.Dark ? Themes.Light : Themes.Dark;
|
||||||
@@ -499,7 +534,7 @@ public partial class ImagePanel : UserControl, INotifyPropertyChanged, IDisposab
|
|||||||
|
|
||||||
Debug.WriteLine($"FireZoomChangedEvent fired: {Thread.CurrentThread.ManagedThreadId}");
|
Debug.WriteLine($"FireZoomChangedEvent fired: {Thread.CurrentThread.ManagedThreadId}");
|
||||||
|
|
||||||
Dispatcher.BeginInvoke(new Action(() => ZoomChanged?.Invoke(this, new EventArgs())),
|
Dispatcher.BeginInvoke(new Action(() => ZoomChanged?.Invoke(this, EventArgs.Empty)),
|
||||||
DispatcherPriority.Background);
|
DispatcherPriority.Background);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user