mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
Made the Win10 share work, at least somewhat.
This commit is contained in:
parent
4da8f223da
commit
5779d2ac2b
7 changed files with 365 additions and 4 deletions
69
GreenshotWin10Plugin/MemoryRandomAccessStream.cs
Normal file
69
GreenshotWin10Plugin/MemoryRandomAccessStream.cs
Normal file
|
@ -0,0 +1,69 @@
|
|||
using System.IO;
|
||||
using Windows.Storage.Streams;
|
||||
|
||||
namespace GreenshotWin10Plugin
|
||||
{
|
||||
public sealed class MemoryRandomAccessStream : MemoryStream, IRandomAccessStream
|
||||
{
|
||||
public MemoryRandomAccessStream()
|
||||
{
|
||||
}
|
||||
|
||||
public MemoryRandomAccessStream(byte[] bytes)
|
||||
{
|
||||
Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
public IInputStream GetInputStreamAt(ulong position)
|
||||
{
|
||||
Seek((long)position, SeekOrigin.Begin);
|
||||
|
||||
return this.AsInputStream();
|
||||
}
|
||||
|
||||
public IOutputStream GetOutputStreamAt(ulong position)
|
||||
{
|
||||
Seek((long)position, SeekOrigin.Begin);
|
||||
|
||||
return this.AsOutputStream();
|
||||
}
|
||||
|
||||
ulong IRandomAccessStream.Position => (ulong)Position;
|
||||
|
||||
public ulong Size
|
||||
{
|
||||
get { return (ulong)Length; }
|
||||
set { SetLength((long)value); }
|
||||
}
|
||||
|
||||
public IRandomAccessStream CloneStream()
|
||||
{
|
||||
var cloned = new MemoryRandomAccessStream();
|
||||
CopyTo(cloned);
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public void Seek(ulong position)
|
||||
{
|
||||
Seek((long)position, SeekOrigin.Begin);
|
||||
}
|
||||
|
||||
public Windows.Foundation.IAsyncOperationWithProgress<IBuffer, uint> ReadAsync(IBuffer buffer, uint count, InputStreamOptions options)
|
||||
{
|
||||
var inputStream = GetInputStreamAt(0);
|
||||
return inputStream.ReadAsync(buffer, count, options);
|
||||
}
|
||||
|
||||
Windows.Foundation.IAsyncOperation<bool> IOutputStream.FlushAsync()
|
||||
{
|
||||
var outputStream = GetOutputStreamAt(0);
|
||||
return outputStream.FlushAsync();
|
||||
}
|
||||
|
||||
public Windows.Foundation.IAsyncOperationWithProgress<uint, uint> WriteAsync(IBuffer buffer)
|
||||
{
|
||||
var outputStream = GetOutputStreamAt(0);
|
||||
return outputStream.WriteAsync(buffer);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue