Skip to content

Commit

Permalink
Add xmldoc for ScanCaps
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Aug 8, 2024
1 parent 1e9255c commit 53a1beb
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 0 deletions.
12 changes: 12 additions & 0 deletions NAPS2.Sdk/Scan/BitDepthCaps.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
namespace NAPS2.Scan;

/// <summary>
/// Represents valid values for ScanOptions.BitDepth as part of PerSourceCaps.
/// </summary>
public class BitDepthCaps
{
/// <summary>
/// Whether the scanner supports BitDepth.Color.
/// </summary>
public bool SupportsColor { get; init; }

/// <summary>
/// Whether the scanner supports BitDepth.Grayscale.
/// </summary>
public bool SupportsGrayscale { get; init; }

/// <summary>
/// Whether the scanner supports BitDepth.BlackAndWhite.
/// </summary>
public bool SupportsBlackAndWhite { get; init; }
}
16 changes: 16 additions & 0 deletions NAPS2.Sdk/Scan/DpiCaps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@

namespace NAPS2.Scan;

/// <summary>
/// Represents valid values for ScanOptions.Dpi as part of PerSourceCaps.
/// </summary>
public class DpiCaps
{
private static readonly int[] TargetCommonValues = [0, 100, 150, 200, 300, 400, 600, 800, 1200, 2400, 4800];

/// <summary>
/// Creates an instance of DpiCaps that allows values in the specified range.
/// </summary>
/// <param name="min">The lowest valid DPI value, inclusive.</param>
/// <param name="max">The highest valid DPI value, inclusive.</param>
/// <param name="step">The increment between valid DPI values (must be >0).</param>
/// <returns></returns>
public static DpiCaps ForRange(int min, int max, int step)
{
if (step <= 0) return new DpiCaps();
Expand All @@ -20,8 +30,14 @@ public static DpiCaps ForRange(int min, int max, int step)
};
}

/// <summary>
/// Allowed values for ScanOptions.Dpi.
/// </summary>
public ImmutableList<int>? Values { get; init; }

/// <summary>
/// Recommended values for ScanOptions.Dpi to be presented to the user.
/// </summary>
public ImmutableList<int>? CommonValues
{
get
Expand Down
21 changes: 21 additions & 0 deletions NAPS2.Sdk/Scan/MetadataCaps.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
namespace NAPS2.Scan;

/// <summary>
/// Represents scanner metadata as part of ScanCaps.
/// </summary>
public class MetadataCaps
{
/// <summary>
/// For SANE, this is the backend name.
/// </summary>
public string? DriverSubtype { get; init; }

/// <summary>
/// The device manufacturer.
/// </summary>
public string? Manufacturer { get; init; }

/// <summary>
/// The device model name.
/// </summary>
public string? Model { get; init; }

/// <summary>
/// The device serial number.
/// </summary>
public string? SerialNumber { get; init; }

/// <summary>
/// The location note associated with the device.
/// </summary>
public string? Location { get; init; }

/// <summary>
/// The URI for an icon associated with the device.
/// </summary>
public string? IconUri { get; init; }
}
9 changes: 9 additions & 0 deletions NAPS2.Sdk/Scan/PageSizeCaps.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
namespace NAPS2.Scan;

/// <summary>
/// Represents valid values for ScanOptions.PageSize as part of PerSourceCaps.
/// </summary>
public class PageSizeCaps
{
/// <summary>
/// Gets the size of the full scan area (i.e. maximum page size).
/// </summary>
public PageSize? ScanArea { get; init; }

/// <summary>
/// Determines whether the provided page size fits within the full scan area (with 1% margin of error).
/// </summary>
public bool Fits(PageSize pageSize)
{
if (ScanArea == null)
Expand Down
15 changes: 15 additions & 0 deletions NAPS2.Sdk/Scan/PaperSourceCaps.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
namespace NAPS2.Scan;

/// <summary>
/// Represents valid values for ScanOptions.PaperSource as part of ScanCaps.
/// </summary>
public class PaperSourceCaps
{
/// <summary>
/// Whether the scanner supports PaperSource.Flatbed.
/// </summary>
public bool SupportsFlatbed { get; init; }

/// <summary>
/// Whether the scanner supports PaperSource.Feeder.
/// </summary>
public bool SupportsFeeder { get; init; }

/// <summary>
/// Whether the scanner supports PaperSource.Duplex.
/// </summary>
public bool SupportsDuplex { get; init; }

/// <summary>
/// Whether the scanner has the ability to detect if paper is in the feeder for use with PaperSource.Auto.
/// </summary>
public bool CanCheckIfFeederHasPaper { get; init; }
}
16 changes: 16 additions & 0 deletions NAPS2.Sdk/Scan/PerSourceCaps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

namespace NAPS2.Scan;

/// <summary>
/// Represents capabilities specific to a single PaperSource as part of ScanCaps.
/// </summary>
public class PerSourceCaps
{
/// <summary>
/// Gets an object representing the union of all possible option values allowed by the provided objects.
/// This can be helpful when presenting the user with a single set of possible options for multiple sources.
/// </summary>
public static PerSourceCaps UnionAll(ICollection<PerSourceCaps> caps)
{
DpiCaps? dpiCaps = null;
Expand Down Expand Up @@ -45,9 +52,18 @@ public static PerSourceCaps UnionAll(ICollection<PerSourceCaps> caps)
};
}

/// <summary>
/// Valid values for ScanOptions.Dpi.
/// </summary>
public DpiCaps? DpiCaps { get; init; }

/// <summary>
/// Valid values for ScanOptions.BitDepth.
/// </summary>
public BitDepthCaps? BitDepthCaps { get; init; }

/// <summary>
/// Valid values for ScanOptions.PageSize.
/// </summary>
public PageSizeCaps? PageSizeCaps { get; init; }
}
19 changes: 19 additions & 0 deletions NAPS2.Sdk/Scan/ScanCaps.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
namespace NAPS2.Scan;

/// <summary>
/// Represents scanner capabilities. This includes valid values for scanning options and extra metadata beyond just the
/// device name and id.
/// </summary>
public class ScanCaps
{
/// <summary>
/// Metadata for the device.
/// </summary>
public MetadataCaps? MetadataCaps { get; init; }

/// <summary>
/// Valid values for ScanOptions.PaperSource.
/// </summary>
public PaperSourceCaps? PaperSourceCaps { get; init; }

/// <summary>
/// Capabilities specific to the Flatbed paper source.
/// </summary>
public PerSourceCaps? FlatbedCaps { get; init; }

/// <summary>
/// Capabilities specific to the Feeder paper source.
/// </summary>
public PerSourceCaps? FeederCaps { get; init; }

/// <summary>
/// Capabilities specific to the Duplex paper source.
/// </summary>
public PerSourceCaps? DuplexCaps { get; init; }
}

0 comments on commit 53a1beb

Please sign in to comment.