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:
@@ -49,6 +49,7 @@ public partial class ImagePanel : UserControl, INotifyPropertyChanged, IDisposab
|
||||
private bool _isZoomFactorFirstSet = true;
|
||||
private DateTime _lastZoomTime = DateTime.MinValue;
|
||||
private double _maxZoomFactor = 3d;
|
||||
private Visibility _copyIconVisibility = Visibility.Visible;
|
||||
private MetaProvider _meta;
|
||||
private Visibility _metaIconVisibility = Visibility.Visible;
|
||||
private double _minZoomFactor = 0.1d;
|
||||
@@ -67,6 +68,8 @@ public partial class ImagePanel : UserControl, INotifyPropertyChanged, IDisposab
|
||||
|
||||
Resources.MergedDictionaries.Clear();
|
||||
|
||||
buttonCopy.Click += OnCopyOnClick;
|
||||
|
||||
buttonMeta.Click += (sender, e) =>
|
||||
textMeta.Visibility = textMeta.Visibility == Visibility.Collapsed
|
||||
? 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
|
||||
{
|
||||
get => _backgroundVisibility;
|
||||
@@ -274,6 +287,28 @@ public partial class ImagePanel : UserControl, INotifyPropertyChanged, IDisposab
|
||||
|
||||
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)
|
||||
{
|
||||
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}");
|
||||
|
||||
Dispatcher.BeginInvoke(new Action(() => ZoomChanged?.Invoke(this, new EventArgs())),
|
||||
Dispatcher.BeginInvoke(new Action(() => ZoomChanged?.Invoke(this, EventArgs.Empty)),
|
||||
DispatcherPriority.Background);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user