using Microsoft.Maui.Graphics; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace InABox.Avalonia.Platform.Barcodes; public class BarcodeResult : IEquatable { public required BarcodeTypes BarcodeType { get; init; } public required BarcodeFormats BarcodeFormat { get; init; } public required string DisplayValue { get; init; } public required string RawValue { get; init; } public required byte[] RawBytes { get; init; } public required RectF PreviewBoundingBox { get; init; } public required RectF ImageBoundingBox { get; init; } public bool Equals(BarcodeResult? other) { if (other is null) return false; if (!string.IsNullOrEmpty(RawValue)) { return RawValue == other.RawValue && ImageBoundingBox.IntersectsWith(other.ImageBoundingBox); } else { return DisplayValue == other.DisplayValue && ImageBoundingBox.IntersectsWith(other.ImageBoundingBox); } } public override bool Equals(object? obj) { return obj is BarcodeResult result && Equals(result); } public override int GetHashCode() { return !string.IsNullOrEmpty(RawValue) ? RawValue.GetHashCode() : DisplayValue.GetHashCode(); } }