Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions ElectronNET.API/Clipboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,40 @@ public void Write(Data data, string type = "")
BridgeConnector.Socket.Emit("clipboard-write", JObject.FromObject(data, _jsonSerializer), type);
}

/// <summary>
/// Reads an image from the clipboard.
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public Task<NativeImage> ReadImageAsync(string type = "")
{
var taskCompletionSource = new TaskCompletionSource<NativeImage>();

BridgeConnector.Socket.On("clipboard-readImage-Completed", (image) =>
{
BridgeConnector.Socket.Off("clipboard-readImage-Completed");

var nativeImage = ((JObject)image).ToObject<NativeImage>();

taskCompletionSource.SetResult(nativeImage);

});

BridgeConnector.Socket.Emit("clipboard-readImage", type);

return taskCompletionSource.Task;
}

/// <summary>
/// Writes an image to the clipboard.
/// </summary>
/// <param name="image"></param>
/// <param name="type"></param>
public void WriteImage(NativeImage image, string type = "")
{
BridgeConnector.Socket.Emit("clipboard-writeImage", JsonConvert.SerializeObject(image), type);
}

private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
Expand Down
1 change: 1 addition & 0 deletions ElectronNET.API/ElectronNET.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ This package contains the API to access the "native" electron API.</Description>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="SocketIoClientDotNet" Version="1.0.5" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
</ItemGroup>

</Project>
33 changes: 33 additions & 0 deletions ElectronNET.API/Entities/AddRepresentationOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class AddRepresentationOptions
{
/// <summary>
/// Gets or sets the width
/// </summary>
public int? Width { get; set; }

/// <summary>
/// Gets or sets the height
/// </summary>
public int? Height { get; set; }

/// <summary>
/// Gets or sets the scalefactor
/// </summary>
public float ScaleFactor { get; set; } = 1.0f;

/// <summary>
/// Gets or sets the buffer
/// </summary>
public byte[] Buffer { get; set; }

/// <summary>
/// Gets or sets the dataURL
/// </summary>
public string DataUrl { get; set; }
}
}
13 changes: 13 additions & 0 deletions ElectronNET.API/Entities/BitmapOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class BitmapOptions
{
/// <summary>
/// Gets or sets the scale factor
/// </summary>
public float ScaleFactor { get; set; } = 1.0f;
}
}
23 changes: 23 additions & 0 deletions ElectronNET.API/Entities/CreateFromBitmapOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class CreateFromBitmapOptions
{
/// <summary>
/// Gets or sets the width
/// </summary>
public int? Width { get; set; }

/// <summary>
/// Gets or sets the height
/// </summary>
public int? Height { get; set; }

/// <summary>
/// Gets or sets the scalefactor
/// </summary>
public float ScaleFactor { get; set; } = 1.0f;
}
}
23 changes: 23 additions & 0 deletions ElectronNET.API/Entities/CreateFromBufferOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class CreateFromBufferOptions
{
/// <summary>
/// Gets or sets the width
/// </summary>
public int? Width { get; set; }

/// <summary>
/// Gets or sets the height
/// </summary>
public int? Height { get; set; }

/// <summary>
/// Gets or sets the scalefactor
/// </summary>
public float ScaleFactor { get; set; } = 1.0f;
}
}
Loading