-
-
Notifications
You must be signed in to change notification settings - Fork 457
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
236 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,100 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
using PuppeteerSharp.Media; | ||
|
||
namespace PuppeteerSharp | ||
{ | ||
/// <summary> | ||
/// Bounding box data returned by <see cref="IElementHandle.BoundingBoxAsync"/>. | ||
/// </summary> | ||
public record BoundingBox(decimal X, decimal Y, decimal Width, decimal Height) : Point(X, Y) | ||
public class BoundingBox : IEquatable<BoundingBox> | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="BoundingBox"/> class. | ||
/// </summary> | ||
public BoundingBox() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="BoundingBox"/> class. | ||
/// </summary> | ||
/// <param name="x">The x coordinate.</param> | ||
/// <param name="y">The y coordinate.</param> | ||
/// <param name="width">Width.</param> | ||
/// <param name="height">Height.</param> | ||
public BoundingBox(decimal x, decimal y, decimal width, decimal height) | ||
{ | ||
X = x; | ||
Y = y; | ||
Width = width; | ||
Height = height; | ||
} | ||
|
||
/// <summary> | ||
/// The x coordinate of the element in pixels. | ||
/// </summary> | ||
/// <value>The x.</value> | ||
public decimal X { get; set; } | ||
|
||
/// <summary> | ||
/// The y coordinate of the element in pixels. | ||
/// </summary> | ||
/// <value>The y.</value> | ||
public decimal Y { get; set; } | ||
|
||
/// <summary> | ||
/// The width of the element in pixels. | ||
/// </summary> | ||
/// <value>The width.</value> | ||
public decimal Width { get; set; } | ||
|
||
/// <summary> | ||
/// The height of the element in pixels. | ||
/// </summary> | ||
/// <value>The height.</value> | ||
public decimal Height { get; set; } | ||
|
||
/// <inheritdoc/> | ||
public override bool Equals(object obj) | ||
{ | ||
if (obj == null || GetType() != obj.GetType()) | ||
{ | ||
return false; | ||
} | ||
|
||
return Equals((BoundingBox)obj); | ||
} | ||
|
||
/// <summary> | ||
/// Determines whether the specified <see cref="PuppeteerSharp.BoundingBox"/> is equal to the current <see cref="T:PuppeteerSharp.BoundingBox"/>. | ||
/// </summary> | ||
/// <param name="obj">The <see cref="PuppeteerSharp.BoundingBox"/> to compare with the current <see cref="T:PuppeteerSharp.BoundingBox"/>.</param> | ||
/// <returns><c>true</c> if the specified <see cref="PuppeteerSharp.BoundingBox"/> is equal to the current | ||
/// <see cref="T:PuppeteerSharp.BoundingBox"/>; otherwise, <c>false</c>.</returns> | ||
public bool Equals(BoundingBox obj) | ||
=> obj != null && | ||
obj.X == X && | ||
obj.Y == Y && | ||
obj.Height == Height && | ||
obj.Width == Width; | ||
|
||
/// <inheritdoc/> | ||
public override int GetHashCode() | ||
=> X.GetHashCode() * 397 | ||
^ Y.GetHashCode() * 397 | ||
^ Width.GetHashCode() * 397 | ||
^ Height.GetHashCode() * 397; | ||
|
||
internal Clip ToClip() | ||
{ | ||
return new Clip | ||
{ | ||
X = X, | ||
Y = Y, | ||
Width = Width, | ||
Height = Height, | ||
}; | ||
} | ||
} | ||
} |
Oops, something went wrong.