blob: e69c9122a2c2c34c510c898266f861d531440109 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/*
* GNU AFFERO GENERAL PUBLIC LICENSE
* Version 3, 19 November 2007
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
using System;
using System.ComponentModel;
using Avalonia.Controls;
using Avalonia.Threading;
using MessageBox.Avalonia.Enums;
using UVtools.WPF.Extensions;
namespace UVtools.WPF
{
public partial class MainWindow
{
public ListBox ClipboardList;
public void InitClipboardLayers()
{
ClipboardList = this.FindControl<ListBox>(nameof(ClipboardList));
Clipboard.PropertyChanged += ClipboardOnPropertyChanged;
}
private void ClipboardOnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(Clipboard.CurrentIndex))
{
if (Clipboard.CurrentIndex < 0 || Clipboard.ChangedByClip) return;
if (Clipboard.ReallocatedLayerCount)
{
DispatcherTimer.RunOnce(() =>
{
RefreshProperties();
ResetDataContext();
}, TimeSpan.FromMilliseconds(1));
}
ShowLayer();
return;
}
}
public async void ClipboardClear()
{
if (await this.MessageBoxQuestion("Are you sure you want to clear the clipboard?\n" +
"Current layers will be placed as original layers\n" +
"This action is permanent!", "Clear clipboard?") != ButtonResult.Yes) return;
Clipboard.Clear(true);
}
}
}
|