Removed Id from CaptureZone

This commit is contained in:
Darth Affe 2023-09-05 22:43:49 +02:00
parent 946dafe649
commit 18e562508e
3 changed files with 3 additions and 28 deletions

View File

@ -10,7 +10,6 @@ public abstract class AbstractScreenCapture<TColor> : IScreenCapture
#region Properties & Fields
private bool _isDisposed;
private int _indexCounter = 0;
protected HashSet<CaptureZone<TColor>> CaptureZones { get; } = new();
@ -93,7 +92,7 @@ public abstract class AbstractScreenCapture<TColor> : IScreenCapture
int unscaledHeight = height;
(width, height, downscaleLevel) = CalculateScaledSize(unscaledWidth, unscaledHeight, downscaleLevel);
CaptureZone<TColor> captureZone = new(_indexCounter++, Display, x, y, width, height, downscaleLevel, unscaledWidth, unscaledHeight);
CaptureZone<TColor> captureZone = new(Display, x, y, width, height, downscaleLevel, unscaledWidth, unscaledHeight);
CaptureZones.Add(captureZone);
return captureZone;

View File

@ -17,13 +17,8 @@ public sealed class CaptureZone<TColor> : ICaptureZone
private readonly object _lock = new();
/// <summary>
/// Gets the unique id of this <see cref="CaptureZone{T}"/>.
/// </summary>
public int Id { get; }
public Display Display { get; }
public ColorFormat ColorFormat
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@ -133,9 +128,8 @@ public sealed class CaptureZone<TColor> : ICaptureZone
/// <param name="unscaledWidth">The original width of the region.</param>
/// <param name="unscaledHeight">The original height of the region</param>
/// <param name="buffer">The buffer containing the image data.</param>
internal CaptureZone(int id, Display display, int x, int y, int width, int height, int downscaleLevel, int unscaledWidth, int unscaledHeight)
internal CaptureZone(Display display, int x, int y, int width, int height, int downscaleLevel, int unscaledWidth, int unscaledHeight)
{
this.Id = id;
this.Display = display;
this.X = x;
this.Y = y;
@ -195,19 +189,6 @@ public sealed class CaptureZone<TColor> : ICaptureZone
InternalBuffer = new byte[newBufferSize];
}
/// <summary>
/// Determines whether this <see cref="CaptureZone{T}"/> equals the given one.
/// </summary>
/// <param name="other">The <see cref="CaptureZone{T}"/> to compare.</param>
/// <returns><c>true</c> if the specified object is equal to the current object; otherwise, <c>false</c>.</returns>
public bool Equals(CaptureZone<TColor> other) => Id == other.Id;
/// <inheritdoc />
public override bool Equals(object? obj) => obj is CaptureZone<TColor> other && Equals(other);
/// <inheritdoc />
public override int GetHashCode() => Id;
#endregion
private class UnlockDisposable : IDisposable

View File

@ -4,11 +4,6 @@ namespace ScreenCapture.NET;
public interface ICaptureZone
{
/// <summary>
/// Gets the unique id of this <see cref="ICaptureZone"/>.
/// </summary>
int Id { get; }
Display Display { get; }
/// <summary>
/// Gets the x-location of the region on the screen.