File tree 2 files changed +47
-0
lines changed 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 1
1
using Microsoft . Extensions . DependencyInjection ;
2
2
using Pixed . Application . Platform ;
3
3
using Pixed . Common . DependencyInjection ;
4
+ using Pixed . Common . Platform ;
4
5
5
6
namespace Pixed . Android ;
6
7
internal class AndroidDependencyRegister : IDependencyRegister
7
8
{
8
9
public void Register ( ref IServiceCollection collection )
9
10
{
10
11
collection . AddSingleton < IPlatformFolder , PlatformFolder > ( ) ;
12
+ collection . AddSingleton < IClipboardHandle , PlatformClipboard > ( ) ;
11
13
}
12
14
}
Original file line number Diff line number Diff line change
1
+ using Avalonia . Input ;
2
+ using Avalonia . Input . Platform ;
3
+ using Pixed . Common . Platform ;
4
+
5
+ namespace Pixed . Android ;
6
+ internal class PlatformClipboard : IClipboardHandle
7
+ {
8
+ private byte [ ] ? _copiedBuffer ;
9
+ public Task ClearAsync ( )
10
+ {
11
+ _copiedBuffer = null ;
12
+ return Task . CompletedTask ;
13
+ }
14
+
15
+ public Task < object ? > GetDataAsync ( string format )
16
+ {
17
+ if ( format != "PNG" || _copiedBuffer == null )
18
+ {
19
+ return Task . FromResult < object ? > ( null ) ;
20
+ }
21
+
22
+ return Task . FromResult < object ? > ( _copiedBuffer ) ;
23
+ }
24
+
25
+ public Task < string [ ] > GetFormatsAsync ( )
26
+ {
27
+ return Task . FromResult < string [ ] > ( _copiedBuffer == null ? [ ] : [ "PNG" ] ) ;
28
+ }
29
+
30
+ public void Initialize ( IClipboard clipboard )
31
+ {
32
+ }
33
+
34
+ public Task SetDataObjectAsync ( IDataObject data )
35
+ {
36
+ var png = data . Get ( "PNG" ) ;
37
+
38
+ if ( png != null && png is byte [ ] array )
39
+ {
40
+ _copiedBuffer = array ;
41
+ }
42
+
43
+ return Task . CompletedTask ;
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments