From 18e562508e7cb2f83faa9352c8caaabcabf927b1 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Tue, 5 Sep 2023 22:43:49 +0200 Subject: [PATCH] Removed Id from CaptureZone --- .../Generic/AbstractScreenCapture.cs | 3 +-- ScreenCapture.NET/Model/CaptureZone.cs | 23 ++----------------- ScreenCapture.NET/Model/ICaptureZone.cs | 5 ---- 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/ScreenCapture.NET/Generic/AbstractScreenCapture.cs b/ScreenCapture.NET/Generic/AbstractScreenCapture.cs index 3eb8c0d..cffd4b4 100644 --- a/ScreenCapture.NET/Generic/AbstractScreenCapture.cs +++ b/ScreenCapture.NET/Generic/AbstractScreenCapture.cs @@ -10,7 +10,6 @@ public abstract class AbstractScreenCapture : IScreenCapture #region Properties & Fields private bool _isDisposed; - private int _indexCounter = 0; protected HashSet> CaptureZones { get; } = new(); @@ -93,7 +92,7 @@ public abstract class AbstractScreenCapture : IScreenCapture int unscaledHeight = height; (width, height, downscaleLevel) = CalculateScaledSize(unscaledWidth, unscaledHeight, downscaleLevel); - CaptureZone captureZone = new(_indexCounter++, Display, x, y, width, height, downscaleLevel, unscaledWidth, unscaledHeight); + CaptureZone captureZone = new(Display, x, y, width, height, downscaleLevel, unscaledWidth, unscaledHeight); CaptureZones.Add(captureZone); return captureZone; diff --git a/ScreenCapture.NET/Model/CaptureZone.cs b/ScreenCapture.NET/Model/CaptureZone.cs index d38e76c..2a30767 100644 --- a/ScreenCapture.NET/Model/CaptureZone.cs +++ b/ScreenCapture.NET/Model/CaptureZone.cs @@ -17,13 +17,8 @@ public sealed class CaptureZone : ICaptureZone private readonly object _lock = new(); - /// - /// Gets the unique id of this . - /// - public int Id { get; } - public Display Display { get; } - + public ColorFormat ColorFormat { [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -133,9 +128,8 @@ public sealed class CaptureZone : ICaptureZone /// The original width of the region. /// The original height of the region /// The buffer containing the image data. - 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 : ICaptureZone InternalBuffer = new byte[newBufferSize]; } - /// - /// Determines whether this equals the given one. - /// - /// The to compare. - /// true if the specified object is equal to the current object; otherwise, false. - public bool Equals(CaptureZone other) => Id == other.Id; - - /// - public override bool Equals(object? obj) => obj is CaptureZone other && Equals(other); - - /// - public override int GetHashCode() => Id; - #endregion private class UnlockDisposable : IDisposable diff --git a/ScreenCapture.NET/Model/ICaptureZone.cs b/ScreenCapture.NET/Model/ICaptureZone.cs index 70cc58c..0379ee6 100644 --- a/ScreenCapture.NET/Model/ICaptureZone.cs +++ b/ScreenCapture.NET/Model/ICaptureZone.cs @@ -4,11 +4,6 @@ namespace ScreenCapture.NET; public interface ICaptureZone { - /// - /// Gets the unique id of this . - /// - int Id { get; } - Display Display { get; } /// /// Gets the x-location of the region on the screen.