Fix and normalize whitespace

This commit is contained in:
softworkz
2025-11-09 03:50:24 +01:00
parent c1e7b84ec6
commit 84b3c59353
50 changed files with 429 additions and 231 deletions

View File

@@ -28,6 +28,6 @@ namespace ElectronNET.API.Entities
/// <summary>
/// Gets or sets the dataURL
/// </summary>
public string DataUrl { get; set; }
public string DataUrl { get; set; }
}
}

View File

@@ -1,12 +1,13 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities {
namespace ElectronNET.API.Entities
{
/// <summary>
/// The cause of the change
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum CookieChangedCause
public enum CookieChangedCause
{
/// <summary>
///The cookie was changed directly by a consumer's action.

View File

@@ -1,10 +1,12 @@
using System.ComponentModel;
namespace ElectronNET.API.Entities {
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class CookieDetails {
public class CookieDetails
{
/// <summary>
/// The URL to associate the cookie with. The callback will be rejected if the URL is invalid.
/// </summary>
@@ -19,7 +21,7 @@ namespace ElectronNET.API.Entities {
/// <summary>
/// (optional) - The value of the cookie. Empty by default if omitted.
/// </summary>
[DefaultValue("")]
[DefaultValue("")]
public string Value { get; set; }
/// <summary>
@@ -31,13 +33,13 @@ namespace ElectronNET.API.Entities {
/// <summary>
/// (optional) - The path of the cookie. Empty by default if omitted.
/// </summary>
[DefaultValue("")]
[DefaultValue("")]
public string Path { get; set; }
/// <summary>
/// (optional) - Whether the cookie is marked as secure. Defaults to false.
/// </summary>
[DefaultValue(false)]
[DefaultValue(false)]
public bool Secure { get; set; }
/// <summary>
@@ -53,4 +55,4 @@ namespace ElectronNET.API.Entities {
[DefaultValue(0)]
public long ExpirationDate { get; set; }
}
}
}

View File

@@ -2,12 +2,12 @@
using System.Collections.Generic;
using System.Text;
namespace ElectronNET.API.Entities
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class CookieFilter
public class CookieFilter
{
/// <summary>
/// (optional) - Retrieves cookies which are associated with url.Empty implies retrieving cookies of all URLs.
@@ -38,6 +38,5 @@ namespace ElectronNET.API.Entities
/// (optional) - Filters out session or persistent cookies.
/// </summary>
public bool Session { get; set; }
}
}
}

View File

@@ -9,10 +9,10 @@
/// Path for the pkcs12 file.
/// </summary>
public string Certificate { get; set; }
/// <summary>
/// Passphrase for the certificate.
/// </summary>
public string Password {get; set; }
public string Password { get; set; }
}
}
}

View File

@@ -9,26 +9,32 @@ public enum InputEventType
///
/// </summary>
undefined,
/// <summary>
///
/// </summary>
mouseDown,
/// <summary>
///
/// </summary>
mouseUp,
/// <summary>
///
/// </summary>
mouseMove,
/// <summary>
///
/// </summary>
mouseEnter,
/// <summary>
///
/// </summary>
mouseLeave,
/// <summary>
///
/// </summary>

View File

@@ -21,9 +21,9 @@ namespace ElectronNET.API.Entities
private static readonly Dictionary<string, float> ScaleFactorPairs = new Dictionary<string, float>
{
{"@2x", 2.0f}, {"@3x", 3.0f}, {"@1x", 1.0f}, {"@4x", 4.0f},
{"@5x", 5.0f}, {"@1.25x", 1.25f}, {"@1.33x", 1.33f}, {"@1.4x", 1.4f},
{"@1.5x", 1.5f}, {"@1.8x", 1.8f}, {"@2.5x", 2.5f}
{ "@2x", 2.0f }, { "@3x", 3.0f }, { "@1x", 1.0f }, { "@4x", 4.0f },
{ "@5x", 5.0f }, { "@1.25x", 1.25f }, { "@1.33x", 1.33f }, { "@1.4x", 1.4f },
{ "@1.5x", 1.5f }, { "@1.8x", 1.8f }, { "@2.5x", 2.5f }
};
private static float? ExtractDpiFromFilePath(string filePath)
@@ -34,6 +34,7 @@ namespace ElectronNET.API.Entities
.Select(p => p.Value)
.FirstOrDefault();
}
private static Image BytesToImage(byte[] bytes)
{
var ms = new MemoryStream(bytes);
@@ -83,7 +84,7 @@ namespace ElectronNET.API.Entities
/// <param name="dataUrl">A data URL with a base64 encoded image.</param>
public static NativeImage CreateFromDataURL(string dataUrl)
{
var images = new Dictionary<float,Image>();
var images = new Dictionary<float, Image>();
var parsedDataUrl = Regex.Match(dataUrl, @"data:image/(?<type>.+?),(?<data>.+)");
var actualData = parsedDataUrl.Groups["data"].Value;
var binData = Convert.FromBase64String(actualData);
@@ -101,7 +102,7 @@ namespace ElectronNET.API.Entities
/// <param name="path">The path of the image</param>
public static NativeImage CreateFromPath(string path)
{
var images = new Dictionary<float,Image>();
var images = new Dictionary<float, Image>();
if (Regex.IsMatch(path, "(@.+?x)"))
{
var dpi = ExtractDpiFromFilePath(path);
@@ -164,7 +165,7 @@ namespace ElectronNET.API.Entities
/// </summary>
public NativeImage Crop(Rectangle rect)
{
var images = new Dictionary<float,Image>();
var images = new Dictionary<float, Image>();
foreach (var image in _images)
{
images.Add(image.Key, Crop(rect.X, rect.Y, rect.Width, rect.Height, image.Key));
@@ -196,7 +197,7 @@ namespace ElectronNET.API.Entities
if (options.Buffer.Length > 0)
{
_images[options.ScaleFactor] =
CreateFromBuffer(options.Buffer, new CreateFromBufferOptions {ScaleFactor = options.ScaleFactor})
CreateFromBuffer(options.Buffer, new CreateFromBufferOptions { ScaleFactor = options.ScaleFactor })
.GetScale(options.ScaleFactor);
}
else if (!string.IsNullOrEmpty(options.DataUrl))
@@ -225,7 +226,7 @@ namespace ElectronNET.API.Entities
/// </summary>
public byte[] GetBitmap(BitmapOptions options)
{
return ToBitmap(new ToBitmapOptions{ ScaleFactor = options.ScaleFactor });
return ToBitmap(new ToBitmapOptions { ScaleFactor = options.ScaleFactor });
}
/// <summary>
@@ -419,12 +420,13 @@ namespace ElectronNET.API.Entities
return codec;
}
}
return null;
}
internal Dictionary<float,string> GetAllScaledImages()
internal Dictionary<float, string> GetAllScaledImages()
{
var dict = new Dictionary<float,string>();
var dict = new Dictionary<float, string>();
try
{
foreach (var (scale, image) in _images)
@@ -436,7 +438,7 @@ namespace ElectronNET.API.Entities
{
Console.WriteLine(ex);
}
return dict;
}
@@ -450,4 +452,4 @@ namespace ElectronNET.API.Entities
return null;
}
}
}
}

View File

@@ -26,9 +26,10 @@ namespace ElectronNET.API.Entities
var bytes = Convert.FromBase64String(item.Value);
newDictionary.Add(item.Key, Image.FromStream(new MemoryStream(bytes)));
}
return new NativeImage(newDictionary);
}
public override bool CanConvert(Type objectType) => objectType == typeof(NativeImage);
}
}
}

View File

@@ -67,7 +67,7 @@ namespace ElectronNET.API.Entities
/// true for landscape, false for portrait.
/// </summary>
public bool Landscape { get; set; }
/// <summary>
/// The scale factor of the web page
/// </summary>
@@ -102,6 +102,5 @@ namespace ElectronNET.API.Entities
/// Dpi
/// </summary>
public PrintDpi Dpi { get; set; }
}
}

View File

@@ -14,7 +14,7 @@ namespace ElectronNET.API.Entities
/// Name
/// </summary>
public string Description { get; set; }
/// <summary>
/// Status
/// </summary>
@@ -24,6 +24,5 @@ namespace ElectronNET.API.Entities
/// Is default
/// </summary>
public bool IsDefault { get; set; }
}
}

View File

@@ -8,35 +8,43 @@
/// <summary>
///
/// </summary>
public string Raw { get; set; }
public string Raw { get; set; }
/// <summary>
///
/// </summary>
public bool Loose { get; set; }
/// <summary>
///
/// </summary>
public SemVerOptions Options { get; set; }
/// <summary>
///
/// </summary>
public int Major { get; set; }
/// <summary>
///
/// </summary>
public int Minor { get; set; }
/// <summary>
///
/// </summary>
public int Patch { get; set; }
/// <summary>
///
/// </summary>
public string Version { get; set; }
/// <summary>
///
/// </summary>
public string[] Build { get; set; }
/// <summary>
///
/// </summary>
@@ -46,14 +54,16 @@
/// <summary>
///
/// </summary>
public class SemVerOptions {
public class SemVerOptions
{
/// <summary>
///
/// </summary>
public bool? Loose { get; set; }
/// <summary>
///
/// </summary>
public bool? IncludePrerelease { get; set; }
}
}
}

View File

@@ -15,7 +15,6 @@
/// </summary>
public void Cancel()
{
}
/// <summary>
@@ -23,7 +22,6 @@
/// </summary>
public void Dispose()
{
}
}
}
}

View File

@@ -9,7 +9,7 @@
/// The data is available as a Buffer, in the rawData field.
/// </summary>
public string Type { get; } = "rawData";
/// <summary>
/// The raw bytes of the post data in a Buffer.
/// </summary>