Tried to make a cap wrapper property on spec-defined caps.

This commit is contained in:
Eugene Wang 2023-04-12 21:42:30 -04:00
parent 1873ad31a0
commit 6e26b7a009
12 changed files with 934 additions and 89 deletions

View File

@ -35,10 +35,6 @@ been easier to implement them as classes when starting out this lib, but
it's not really ideal anymore. The change also makes them match the twain.h
names and the spec pdf.
* Caps no longer have their own wrapper properties for each type, though common
helpers are provided. This makes calling custom caps possible but you will have to
consult the docs on what containers and values they should be.
* All lower-level TWAIN APIs are public instead of hidden away.
* `TwainAppSession` longer hosts its own internal message pump. Apps will need to hook

View File

@ -302,7 +302,16 @@ namespace WinFormSample
.MakeGenericMethod(enumType);
var args = new object?[] { cap, null };
currentMethod.Invoke(twain, args);
return args[1].ToString();
var values = (System.Collections.IList)args[1]!;
if (values.Count == 1)
{
return values[0]!.ToString()!;
}
else if (values.Count > 1)
{
return string.Join(", ", values);
}
return "";
}
else
{
@ -311,7 +320,16 @@ namespace WinFormSample
.MakeGenericMethod(enumType);
var args = new object?[] { cap, null };
defaultMethod.Invoke(twain, args);
return args[1].ToString();
var values = (System.Collections.IList)args[1]!;
if (values.Count == 1)
{
return values[0]!.ToString()!;
}
else if (values.Count > 1)
{
return string.Join(", ", values);
}
return "";
}
}
@ -320,69 +338,69 @@ namespace WinFormSample
{
case TWTY.UINT8:
sts = forCurrent ?
twain.GetCapCurrent(cap, out byte ubval) :
twain.GetCapCurrent(cap, out List<byte> ubval) :
twain.GetCapDefault(cap, out ubval);
return ubval.ToString();
return ubval.FirstOrDefault().ToString();
case TWTY.INT8:
sts = forCurrent ?
twain.GetCapCurrent(cap, out sbyte sbval) :
twain.GetCapCurrent(cap, out List<sbyte> sbval) :
twain.GetCapDefault(cap, out sbval);
return sbval.ToString();
return sbval.FirstOrDefault().ToString();
case TWTY.UINT16:
sts = forCurrent ?
twain.GetCapCurrent(cap, out ushort usval) :
twain.GetCapCurrent(cap, out List<ushort> usval) :
twain.GetCapDefault(cap, out usval);
return usval.ToString();
return usval.FirstOrDefault().ToString();
case TWTY.INT16:
sts = forCurrent ?
twain.GetCapCurrent(cap, out short ssval) :
twain.GetCapCurrent(cap, out List<short> ssval) :
twain.GetCapDefault(cap, out ssval);
return ssval.ToString();
return ssval.FirstOrDefault().ToString();
case TWTY.UINT32:
sts = forCurrent ?
twain.GetCapCurrent(cap, out uint uival) :
twain.GetCapCurrent(cap, out List<uint> uival) :
twain.GetCapDefault(cap, out uival);
return uival.ToString();
return uival.FirstOrDefault().ToString();
case TWTY.INT32:
sts = forCurrent ?
twain.GetCapCurrent(cap, out int sival) :
twain.GetCapCurrent(cap, out List<int> sival) :
twain.GetCapDefault(cap, out sival);
return sival.ToString();
return sival.FirstOrDefault().ToString();
case TWTY.BOOL:
sts = forCurrent ?
twain.GetCapCurrent(cap, out TW_BOOL tbval) :
twain.GetCapCurrent(cap, out List<TW_BOOL> tbval) :
twain.GetCapDefault(cap, out tbval);
return tbval.ToString();
return tbval.FirstOrDefault().ToString();
case TWTY.FIX32:
sts = forCurrent ?
twain.GetCapCurrent(cap, out TW_FIX32 fxval) :
twain.GetCapCurrent(cap, out List<TW_FIX32> fxval) :
twain.GetCapDefault(cap, out fxval);
return fxval.ToString();
return fxval.FirstOrDefault().ToString();
case TWTY.FRAME:
sts = forCurrent ?
twain.GetCapCurrent(cap, out TW_FRAME frval) :
twain.GetCapCurrent(cap, out List<TW_FRAME> frval) :
twain.GetCapDefault(cap, out frval);
return frval.ToString();
return frval.FirstOrDefault().ToString();
case TWTY.STR32:
sts = forCurrent ?
twain.GetCapCurrent(cap, out TW_STR32 s32val) :
twain.GetCapCurrent(cap, out List<TW_STR32> s32val) :
twain.GetCapDefault(cap, out s32val);
return s32val.ToString();
return s32val.FirstOrDefault().ToString();
case TWTY.STR64:
sts = forCurrent ?
twain.GetCapCurrent(cap, out TW_STR64 s64val) :
twain.GetCapCurrent(cap, out List<TW_STR64> s64val) :
twain.GetCapDefault(cap, out s64val);
return s64val.ToString();
return s64val.FirstOrDefault().ToString();
case TWTY.STR128:
sts = forCurrent ?
twain.GetCapCurrent(cap, out TW_STR128 s128val) :
twain.GetCapCurrent(cap, out List<TW_STR128> s128val) :
twain.GetCapDefault(cap, out s128val);
return s128val.ToString();
return s128val.FirstOrDefault().ToString();
case TWTY.STR255:
sts = forCurrent ?
twain.GetCapCurrent(cap, out TW_STR255 s255val) :
twain.GetCapCurrent(cap, out List<TW_STR255> s255val) :
twain.GetCapDefault(cap, out s255val);
return s255val.ToString();
return s255val.FirstOrDefault().ToString();
case TWTY.HANDLE:
break;
}

View File

@ -3,6 +3,7 @@ using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WinFormSample

View File

@ -4,19 +4,32 @@ using System.Collections.Generic;
namespace NTwain.Caps
{
/// <summary>
///
/// </summary>
/// <typeparam name="TValue"></typeparam>
public class CapReader<TValue> where TValue : struct
{
readonly TwainAppSession _twain;
protected readonly TwainAppSession _twain;
public CapReader(TwainAppSession twain, CAP cap)
public CapReader(TwainAppSession twain, CAP cap, float introducedVersion = 1)
{
_twain = twain;
Cap = cap;
Introduced = introducedVersion;
}
public CAP Cap { get; }
public STS LastSTS { get; private set; }
/// <summary>
/// When this was introduced in TWAIN.
/// </summary>
public float Introduced { get; }
/// <summary>
/// The STS result from the most recent call with this cap wrapper.
/// </summary>
public STS LastSTS { get; protected set; }
TWQC? _qc;
public TWQC Supports
@ -38,24 +51,24 @@ namespace NTwain.Caps
return Array.Empty<TValue>();
}
public TValue GetCurrent()
public IList<TValue> GetCurrent()
{
LastSTS = _twain.GetCapCurrent(Cap, out TValue value);
LastSTS = _twain.GetCapCurrent(Cap, out List<TValue> value);
if (LastSTS.IsSuccess)
{
return value;
};
return default;
return Array.Empty<TValue>();
}
public TValue GetDefault()
public IList<TValue> GetDefault()
{
LastSTS = _twain.GetCapDefault(Cap, out TValue value);
LastSTS = _twain.GetCapDefault(Cap, out List<TValue> value);
if (LastSTS.IsSuccess)
{
return value;
};
return default;
return Array.Empty<TValue>();
}
public string? GetLabel()

View File

@ -1,16 +1,112 @@
using NTwain.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NTwain.Caps
{
public class CapWriter<TValue> : CapReader<TValue> where TValue : struct
{
public CapWriter(TwainAppSession twain, CAP cap) : base(twain, cap)
public CapWriter(TwainAppSession twain, CAP cap, float introducedVersion = 1)
: base(twain, cap, introducedVersion)
{
}
/// <summary>
/// Sets current value using one-value.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public STS Set(TValue value)
{
return LastSTS = _twain.SetCap(Cap, value);
}
/// <summary>
/// Sets current value using array.
/// </summary>
/// <param name="values"></param>
/// <returns></returns>
public STS Set(IList<TValue> values)
{
var twcap = ValueWriter.CreateArrayCap(Cap, _twain, values);
return LastSTS = _twain.SetCap(ref twcap);
}
/// <summary>
/// Sets current value using enumeration.
/// </summary>
/// <param name="values"></param>
/// <returns></returns>
public STS Set(Enumeration<TValue> values)
{
var twcap = ValueWriter.CreateEnumCap(Cap, _twain, values);
return LastSTS = _twain.SetCap(ref twcap);
}
/// <summary>
/// Sets current value using range.
/// </summary>
/// <param name="values"></param>
/// <returns></returns>
public STS Set(Range<TValue> values)
{
var twcap = ValueWriter.CreateRangeCap(Cap, _twain, values);
return LastSTS = _twain.SetCap(ref twcap);
}
/// <summary>
/// Sets constraint using one-value.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public STS SetConstraint(TValue value)
{
var twcap = ValueWriter.CreateOneValueCap(Cap, _twain, value);
return LastSTS = _twain.SetConstraint(ref twcap);
}
/// <summary>
/// Sets constraint using array.
/// </summary>
/// <param name="values"></param>
/// <returns></returns>
public STS SetConstraint(IList<TValue> values)
{
var twcap = ValueWriter.CreateArrayCap(Cap, _twain, values);
return LastSTS = _twain.SetConstraint(ref twcap);
}
/// <summary>
/// Sets constraint using enumeration.
/// </summary>
/// <param name="values"></param>
/// <returns></returns>
public STS SetConstraint(Enumeration<TValue> values)
{
var twcap = ValueWriter.CreateEnumCap(Cap, _twain, values);
return LastSTS = _twain.SetConstraint(ref twcap);
}
/// <summary>
/// Sets constraint using range.
/// </summary>
/// <param name="values"></param>
/// <returns></returns>
public STS SetConstraint(Range<TValue> values)
{
var twcap = ValueWriter.CreateRangeCap(Cap, _twain, values);
return LastSTS = _twain.SetConstraint(ref twcap);
}
/// <summary>
/// Resets this cap to power-on default.
/// </summary>
/// <returns></returns>
public STS Reset()
{
LastSTS = _twain.ResetCap(Cap, out TW_CAPABILITY twcap);
twcap.Free(_twain);
return LastSTS;
}
}
}

View File

@ -10,5 +10,7 @@ namespace NTwain.Caps
partial class KnownCaps
{
CapWriter<TWSX>? _ACAP_XFERMECH;
public CapWriter<TWSX> ACAP_XFERMECH => _ACAP_XFERMECH ??= new(_twain, CAP.ACAP_XFERMECH, 1.8f);
}
}

View File

@ -1,14 +1,392 @@
using NTwain.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NTwain.Caps
{
partial class KnownCaps
{
CapWriter<TWAL>? _cap_alarms;
public CapWriter<TWAL> CAP_ALARMS => _cap_alarms ??= new(_twain, CAP.CAP_ALARMS, 1.8f);
CapWriter<int>? _cap_alarmvolume;
public CapWriter<int> CAP_ALARMVOLUME => _cap_alarmvolume ??= new(_twain, CAP.CAP_ALARMVOLUME, 1.8f);
CapWriter<TW_STR128>? _cap_author;
public CapWriter<TW_STR128> CAP_AUTHOR => _cap_author ??= new(_twain, CAP.CAP_AUTHOR, 1);
CapWriter<TW_BOOL>? _cap_autofeed;
public CapWriter<TW_BOOL> CAP_AUTOFEED => _cap_autofeed ??= new(_twain, CAP.CAP_AUTOFEED, 1);
CapWriter<int>? _cap_automaticcapture;
public CapWriter<int> CAP_AUTOMATICCAPTURE => _cap_automaticcapture ??= new(_twain, CAP.CAP_AUTOMATICCAPTURE, 1.8f);
CapWriter<TW_BOOL>? _cap_automaticsensemedium;
public CapWriter<TW_BOOL> CAP_AUTOMATICSENSEMEDIUM => _cap_automaticsensemedium ??= new(_twain, CAP.CAP_AUTOMATICSENSEMEDIUM, 2.1f);
CapWriter<TW_BOOL>? _cap_autoscan;
public CapWriter<TW_BOOL> CAP_AUTOSCAN => _cap_autoscan ??= new(_twain, CAP.CAP_AUTOSCAN, 1.6f);
CapReader<int>? _cap_batteryminutes;
public CapReader<int> CAP_BATTERYMINUTES => _cap_batteryminutes ??= new(_twain, CAP.CAP_BATTERYMINUTES, 1.8f);
CapReader<short>? _cap_batterypercentage;
public CapReader<short> CAP_BATTERYPERCENTAGE => _cap_batterypercentage ??= new(_twain, CAP.CAP_BATTERYPERCENTAGE, 1.8f);
CapWriter<TW_BOOL>? _cap_cameraenabled;
public CapWriter<TW_BOOL> CAP_CAMERAENABLED => _cap_cameraenabled ??= new(_twain, CAP.CAP_CAMERAENABLED, 2);
CapWriter<ushort>? _cap_cameraorder;
public CapWriter<ushort> CAP_CAMERAORDER => _cap_cameraorder ??= new(_twain, CAP.CAP_CAMERAORDER, 2);
CapReader<TW_BOOL>? _cap_camerapreviewui;
public CapReader<TW_BOOL> CAP_CAMERAPREVIEWUI => _cap_camerapreviewui ??= new(_twain, CAP.CAP_CAMERAPREVIEWUI, 1.8f);
CapWriter<TWCS>? _cap_cameraside;
public CapWriter<TWCS> CAP_CAMERASIDE => _cap_cameraside ??= new(_twain, CAP.CAP_CAMERASIDE, 1.91f);
CapWriter<TW_STR255>? _cap_caption;
public CapWriter<TW_STR255> CAP_CAPTION => _cap_caption ??= new(_twain, CAP.CAP_CAPTION, 1);
CapWriter<TW_BOOL>? _cap_clearpage;
public CapWriter<TW_BOOL> CAP_CLEARPAGE => _cap_clearpage ??= new(_twain, CAP.CAP_CLEARPAGE, 1);
CapReader<TW_BOOL>? _cap_customdsdata;
public CapReader<TW_BOOL> CAP_CUSTOMDSDATA => _cap_customdsdata ??= new(_twain, CAP.CAP_CUSTOMDSDATA, 1.7f);
CapReader<TW_STR255>? _cap_custominterfaceguid;
public CapReader<TW_STR255> CAP_CUSTOMINTERFACEGUID => _cap_custominterfaceguid ??= new(_twain, CAP.CAP_CUSTOMINTERFACEGUID, 2.1f);
CapWriter<TWDE>? _cap_deviceevent;
public CapWriter<TWDE> CAP_DEVICEEVENT => _cap_deviceevent ??= new(_twain, CAP.CAP_DEVICEEVENT, 1.8f);
CapReader<TW_BOOL>? _cap_deviceonline;
public CapReader<TW_BOOL> CAP_DEVICEONLINE => _cap_deviceonline ??= new(_twain, CAP.CAP_DEVICEONLINE, 1.6f);
CapWriter<TW_STR32>? _cap_devicetimedate;
public CapWriter<TW_STR32> CAP_DEVICETIMEDATE => _cap_devicetimedate ??= new(_twain, CAP.CAP_DEVICETIMEDATE, 1.8f);
CapWriter<TWDF>? _cap_doublefeeddetection;
public CapWriter<TWDF> CAP_DOUBLEFEEDDETECTION => _cap_doublefeeddetection ??= new(_twain, CAP.CAP_DOUBLEFEEDDETECTION, 2.2f);
CapWriter<TW_FIX32>? _cap_doublefeeddetectionlength;
public CapWriter<TW_FIX32> CAP_DOUBLEFEEDDETECTIONLENGTH => _cap_doublefeeddetectionlength ??= new(_twain, CAP.CAP_DOUBLEFEEDDETECTIONLENGTH, 2.2f);
CapWriter<TWDP>? _cap_doublefeeddetectionresponse;
public CapWriter<TWDP> CAP_DOUBLEFEEDDETECTIONRESPONSE => _cap_doublefeeddetectionresponse ??= new(_twain, CAP.CAP_DOUBLEFEEDDETECTIONRESPONSE, 2.2f);
CapWriter<TWUS>? _cap_doublefeeddetectionsensitivity;
public CapWriter<TWUS> CAP_DOUBLEFEEDDETECTIONSENSITIVITY => _cap_doublefeeddetectionsensitivity ??= new(_twain, CAP.CAP_DOUBLEFEEDDETECTIONSENSITIVITY, 2.2f);
CapReader<TWDX>? _cap_duplex;
public CapReader<TWDX> CAP_DUPLEX => _cap_duplex ??= new(_twain, CAP.CAP_DUPLEX, 1.7f);
CapWriter<TW_BOOL>? _cap_duplexenabled;
public CapWriter<TW_BOOL> CAP_DUPLEXENABLED => _cap_duplexenabled ??= new(_twain, CAP.CAP_DUPLEXENABLED, 1.7f);
CapReader<TW_BOOL>? _cap_enabledsuionly;
public CapReader<TW_BOOL> CAP_ENABLEDSUIONLY => _cap_enabledsuionly ??= new(_twain, CAP.CAP_ENABLEDSUIONLY, 1.7f);
CapWriter<uint>? _cap_endorser;
public CapWriter<uint> CAP_ENDORSER => _cap_endorser ??= new(_twain, CAP.CAP_ENDORSER, 1.7f);
CapWriter<CAP>? _cap_extendedcaps;
public CapWriter<CAP> CAP_EXTENDEDCAPS => _cap_extendedcaps ??= new(_twain, CAP.CAP_EXTENDEDCAPS, 1);
CapWriter<TWFA>? _cap_feederalignment;
public CapWriter<TWFA> CAP_FEEDERALIGNMENT => _cap_feederalignment ??= new(_twain, CAP.CAP_FEEDERALIGNMENT, 1.8f);
CapWriter<TW_BOOL>? _cap_feederenabled;
public CapWriter<TW_BOOL> CAP_FEEDERENABLED => _cap_feederenabled ??= new(_twain, CAP.CAP_FEEDERENABLED, 1);
CapReader<TW_BOOL>? _cap_feederloaded;
public CapReader<TW_BOOL> CAP_FEEDERLOADED => _cap_feederloaded ??= new(_twain, CAP.CAP_FEEDERLOADED, 1);
CapWriter<TWFO>? _cap_feederorder;
public CapWriter<TWFO> CAP_FEEDERORDER => _cap_feederorder ??= new(_twain, CAP.CAP_FEEDERORDER, 1.8f);
CapWriter<TWFP>? _cap_feederpocket;
public CapWriter<TWFP> CAP_FEEDERPOCKET => _cap_feederpocket ??= new(_twain, CAP.CAP_FEEDERPOCKET, 2);
CapWriter<TW_BOOL>? _cap_feederprep;
public CapWriter<TW_BOOL> CAP_FEEDERPREP => _cap_feederprep ??= new(_twain, CAP.CAP_FEEDERPREP, 2);
CapWriter<TW_BOOL>? _cap_feedpage;
public CapWriter<TW_BOOL> CAP_FEEDPAGE => _cap_feedpage ??= new(_twain, CAP.CAP_FEEDPAGE, 1);
CapReader<TW_STR32>? _cap_iafielda_lastpage;
public CapReader<TW_STR32> CAP_IAFIELDA_LASTPAGE => _cap_iafielda_lastpage ??= new(_twain, CAP.CAP_IAFIELDA_LASTPAGE, 2.5f);
CapWriter<TWIA>? _cap_iafielda_level;
public CapWriter<TWIA> CAP_IAFIELDA_LEVEL => _cap_iafielda_level ??= new(_twain, CAP.CAP_IAFIELDA_LEVEL, 2.5f);
CapWriter<TW_STR32>? _cap_iafielda_printformat;
public CapWriter<TW_STR32> CAP_IAFIELDA_PRINTFORMAT => _cap_iafielda_printformat ??= new(_twain, CAP.CAP_IAFIELDA_PRINTFORMAT, 2.5f);
CapWriter<TW_STR32>? _cap_iafielda_value;
public CapWriter<TW_STR32> CAP_IAFIELDA_VALUE => _cap_iafielda_value ??= new(_twain, CAP.CAP_IAFIELDA_VALUE, 2.5f);
CapReader<TW_STR32>? _cap_iafieldb_lastpage;
public CapReader<TW_STR32> CAP_IAFIELDB_LASTPAGE => _cap_iafieldb_lastpage ??= new(_twain, CAP.CAP_IAFIELDB_LASTPAGE, 2.5f);
CapWriter<TWIA>? _cap_iafieldb_level;
public CapWriter<TWIA> CAP_IAFIELDB_LEVEL => _cap_iafieldb_level ??= new(_twain, CAP.CAP_IAFIELDB_LEVEL, 2.5f);
CapWriter<TW_STR32>? _cap_iafieldb_printformat;
public CapWriter<TW_STR32> CAP_IAFIELDB_PRINTFORMAT => _cap_iafieldb_printformat ??= new(_twain, CAP.CAP_IAFIELDB_PRINTFORMAT, 2.5f);
CapWriter<TW_STR32>? _cap_iafieldb_value;
public CapWriter<TW_STR32> CAP_IAFIELDB_VALUE => _cap_iafieldb_value ??= new(_twain, CAP.CAP_IAFIELDB_VALUE, 2.5f);
CapReader<TW_STR32>? _cap_iafieldc_lastpage;
public CapReader<TW_STR32> CAP_IAFIELDC_LASTPAGE => _cap_iafieldc_lastpage ??= new(_twain, CAP.CAP_IAFIELDC_LASTPAGE, 2.5f);
CapWriter<TWIA>? _cap_iafieldc_level;
public CapWriter<TWIA> CAP_IAFIELDC_LEVEL => _cap_iafieldc_level ??= new(_twain, CAP.CAP_IAFIELDC_LEVEL, 2.5f);
CapWriter<TW_STR32>? _cap_iafieldc_printformat;
public CapWriter<TW_STR32> CAP_IAFIELDC_PRINTFORMAT => _cap_iafieldc_printformat ??= new(_twain, CAP.CAP_IAFIELDC_PRINTFORMAT, 2.5f);
CapWriter<TW_STR32>? _cap_iafieldc_value;
public CapWriter<TW_STR32> CAP_IAFIELDC_VALUE => _cap_iafieldc_value ??= new(_twain, CAP.CAP_IAFIELDC_VALUE, 2.5f);
CapReader<TW_STR32>? _cap_iafieldd_lastpage;
public CapReader<TW_STR32> CAP_IAFIELDD_LASTPAGE => _cap_iafieldd_lastpage ??= new(_twain, CAP.CAP_IAFIELDD_LASTPAGE, 2.5f);
CapWriter<TWIA>? _cap_iafieldd_level;
public CapWriter<TWIA> CAP_IAFIELDD_LEVEL => _cap_iafieldd_level ??= new(_twain, CAP.CAP_IAFIELDD_LEVEL, 2.5f);
CapWriter<TW_STR32>? _cap_iafieldd_printformat;
public CapWriter<TW_STR32> CAP_IAFIELDD_PRINTFORMAT => _cap_iafieldd_printformat ??= new(_twain, CAP.CAP_IAFIELDD_PRINTFORMAT, 2.5f);
CapWriter<TW_STR32>? _cap_iafieldd_value;
public CapWriter<TW_STR32> CAP_IAFIELDD_VALUE => _cap_iafieldd_value ??= new(_twain, CAP.CAP_IAFIELDD_VALUE, 2.5f);
CapReader<TW_STR32>? _cap_iafielde_lastpage;
public CapReader<TW_STR32> CAP_IAFIELDE_LASTPAGE => _cap_iafielde_lastpage ??= new(_twain, CAP.CAP_IAFIELDE_LASTPAGE, 2.5f);
CapWriter<TWIA>? _cap_iafielde_level;
public CapWriter<TWIA> CAP_IAFIELDE_LEVEL => _cap_iafielde_level ??= new(_twain, CAP.CAP_IAFIELDE_LEVEL, 2.5f);
CapWriter<TW_STR32>? _cap_iafielde_printformat;
public CapWriter<TW_STR32> CAP_IAFIELDE_PRINTFORMAT => _cap_iafielde_printformat ??= new(_twain, CAP.CAP_IAFIELDE_PRINTFORMAT, 2.5f);
CapWriter<TW_STR32>? _cap_iafielde_value;
public CapWriter<TW_STR32> CAP_IAFIELDE_VALUE => _cap_iafielde_value ??= new(_twain, CAP.CAP_IAFIELDE_VALUE, 2.5f);
CapWriter<TW_BOOL>? _cap_imageaddressenabled;
public CapWriter<TW_BOOL> CAP_IMAGEADDRESSENABLED => _cap_imageaddressenabled ??= new(_twain, CAP.CAP_IMAGEADDRESSENABLED, 2.5f);
CapWriter<TW_BOOL>? _cap_indicators;
public CapWriter<TW_BOOL> CAP_INDICATORS => _cap_indicators ??= new(_twain, CAP.CAP_INDICATORS, 1.1f);
CapWriter<TWCI>? _cap_indicatorsmode;
public CapWriter<TWCI> CAP_INDICATORSMODE => _cap_indicatorsmode ??= new(_twain, CAP.CAP_INDICATORSMODE, 2.2f);
CapWriter<TWJC>? _cap_jobcontrol;
public CapWriter<TWJC> CAP_JOBCONTROL => _cap_jobcontrol ??= new(_twain, CAP.CAP_JOBCONTROL, 1.7f);
CapWriter<TWLG>? _cap_language;
public CapWriter<TWLG> CAP_LANGUAGE => _cap_language ??= new(_twain, CAP.CAP_LANGUAGE, 1.8f);
CapWriter<uint>? _cap_maxbatchbuffers;
public CapWriter<uint> CAP_MAXBATCHBUFFERS => _cap_maxbatchbuffers ??= new(_twain, CAP.CAP_MAXBATCHBUFFERS, 1.8f);
CapWriter<TW_BOOL>? _cap_micrenabled;
public CapWriter<TW_BOOL> CAP_MICRENABLED => _cap_micrenabled ??= new(_twain, CAP.CAP_MICRENABLED, 2);
CapReader<TW_BOOL>? _cap_paperdetectable;
public CapReader<TW_BOOL> CAP_PAPERDETECTABLE => _cap_paperdetectable ??= new(_twain, CAP.CAP_PAPERDETECTABLE, 1.6f);
CapWriter<TWPH>? _cap_paperhandling;
public CapWriter<TWPH> CAP_PAPERHANDLING => _cap_paperhandling ??= new(_twain, CAP.CAP_PAPERHANDLING, 2.2f);
CapWriter<int>? _cap_powersavetime;
public CapWriter<int> CAP_POWERSAVETIME => _cap_powersavetime ??= new(_twain, CAP.CAP_POWERSAVETIME, 1.8f);
CapReader<TWPS>? _cap_powersupply;
public CapReader<TWPS> CAP_POWERSUPPLY => _cap_powersupply ??= new(_twain, CAP.CAP_POWERSUPPLY, 1.8f);
CapWriter<TWPR>? _cap_printer;
public CapWriter<TWPR> CAP_PRINTER => _cap_printer ??= new(_twain, CAP.CAP_PRINTER, 1.8f);
CapWriter<uint>? _cap_printercharrotation;
public CapWriter<uint> CAP_PRINTERCHARROTATION => _cap_printercharrotation ??= new(_twain, CAP.CAP_PRINTERCHARROTATION, 2.2f);
CapWriter<TW_BOOL>? _cap_printerenabled;
public CapWriter<TW_BOOL> CAP_PRINTERENABLED => _cap_printerenabled ??= new(_twain, CAP.CAP_PRINTERENABLED, 1.8f);
CapWriter<TWPFS>? _cap_printerfontstyle;
public CapWriter<TWPFS> CAP_PRINTERFONTSTYLE => _cap_printerfontstyle ??= new(_twain, CAP.CAP_PRINTERFONTSTYLE, 2.3f);
CapWriter<uint>? _cap_printerindex;
public CapWriter<uint> CAP_PRINTERINDEX => _cap_printerindex ??= new(_twain, CAP.CAP_PRINTERINDEX, 1.8f);
CapWriter<TW_STR32>? _cap_printerindexleadchar;
public CapWriter<TW_STR32> CAP_PRINTERINDEXLEADCHAR => _cap_printerindexleadchar ??= new(_twain, CAP.CAP_PRINTERINDEXLEADCHAR, 2.3f);
CapWriter<uint>? _cap_printerindexmaxvalue;
public CapWriter<uint> CAP_PRINTERINDEXMAXVALUE => _cap_printerindexmaxvalue ??= new(_twain, CAP.CAP_PRINTERINDEXMAXVALUE, 2.3f);
CapWriter<uint>? _cap_printerindexnumdigits;
public CapWriter<uint> CAP_PRINTERINDEXNUMDIGITS => _cap_printerindexnumdigits ??= new(_twain, CAP.CAP_PRINTERINDEXNUMDIGITS, 2.3f);
CapWriter<uint>? _cap_printerindexstep;
public CapWriter<uint> CAP_PRINTERINDEXSTEP => _cap_printerindexstep ??= new(_twain, CAP.CAP_PRINTERINDEXSTEP, 2.3f);
CapWriter<TWCT>? _cap_printerindextrigger;
public CapWriter<TWCT> CAP_PRINTERINDEXTRIGGER => _cap_printerindextrigger ??= new(_twain, CAP.CAP_PRINTERINDEXTRIGGER, 2.3f);
CapWriter<TWPM>? _cap_printermode;
public CapWriter<TWPM> CAP_PRINTERMODE => _cap_printermode ??= new(_twain, CAP.CAP_PRINTERMODE, 1.8f);
CapWriter<TW_STR255>? _cap_printerstring;
public CapWriter<TW_STR255> CAP_PRINTERSTRING => _cap_printerstring ??= new(_twain, CAP.CAP_PRINTERSTRING, 1.8f);
CapReader<TW_STR255>? _cap_printerstringpreview;
public CapReader<TW_STR255> CAP_PRINTERSTRINGPREVIEW => _cap_printerstringpreview ??= new(_twain, CAP.CAP_PRINTERSTRINGPREVIEW, 2.3f);
CapWriter<TW_STR255>? _cap_printersuffix;
public CapWriter<TW_STR255> CAP_PRINTERSUFFIX => _cap_printersuffix ??= new(_twain, CAP.CAP_PRINTERSUFFIX, 1.8f);
CapWriter<TW_FIX32>? _cap_printerverticaloffset;
public CapWriter<TW_FIX32> CAP_PRINTERVERTICALOFFSET => _cap_printerverticaloffset ??= new(_twain, CAP.CAP_PRINTERVERTICALOFFSET, 2.2f);
CapReader<TW_BOOL>? _cap_reacquireallowed;
public CapReader<TW_BOOL> CAP_REACQUIREALLOWED => _cap_reacquireallowed ??= new(_twain, CAP.CAP_REACQUIREALLOWED, 1.8f);
CapWriter<TW_BOOL>? _cap_rewindpage;
public CapWriter<TW_BOOL> CAP_REWINDPAGE => _cap_rewindpage ??= new(_twain, CAP.CAP_REWINDPAGE, 1);
CapWriter<TWSG>? _cap_segmented;
public CapWriter<TWSG> CAP_SEGMENTED => _cap_segmented ??= new(_twain, CAP.CAP_SEGMENTED, 1.91f);
CapReader<TW_STR255>? _cap_serialnumber;
public CapReader<TW_STR255> CAP_SERIALNUMBER => _cap_serialnumber ??= new(_twain, CAP.CAP_SERIALNUMBER, 1.8f);
CapWriter<uint>? _cap_sheetcount;
public CapWriter<uint> CAP_SHEETCOUNT => _cap_sheetcount ??= new(_twain, CAP.CAP_SHEETCOUNT, 2.4f);
CapReader<CAP>? _cap_supportedcaps;
public CapReader<CAP> CAP_SUPPORTEDCAPS => _cap_supportedcaps ??= new(_twain, CAP.CAP_SUPPORTEDCAPS, 1);
CapReader<CAP>? _cap_supportedcapssegmentunique;
public CapReader<CAP> CAP_SUPPORTEDCAPSSEGMENTUNIQUE => _cap_supportedcapssegmentunique ??= new(_twain, CAP.CAP_SUPPORTEDCAPSSEGMENTUNIQUE, 2.2f);
CapReader<DAT>? _cap_supporteddats;
public CapReader<DAT> CAP_SUPPORTEDDATS => _cap_supporteddats ??= new(_twain, CAP.CAP_SUPPORTEDDATS, 2.2f);
CapWriter<TW_BOOL>? _cap_thumbnailsenabled;
public CapWriter<TW_BOOL> CAP_THUMBNAILSENABLED => _cap_thumbnailsenabled ??= new(_twain, CAP.CAP_THUMBNAILSENABLED, 1.7f);
CapWriter<int>? _cap_timebeforefirstcapture;
public CapWriter<int> CAP_TIMEBEFOREFIRSTCAPTURE => _cap_timebeforefirstcapture ??= new(_twain, CAP.CAP_TIMEBEFOREFIRSTCAPTURE, 1.8f);
CapWriter<int>? _cap_timebetweencaptures;
public CapWriter<int> CAP_TIMEBETWEENCAPTURES => _cap_timebetweencaptures ??= new(_twain, CAP.CAP_TIMEBETWEENCAPTURES, 1.8f);
CapReader<TW_STR32>? _cap_timedate;
public CapReader<TW_STR32> CAP_TIMEDATE => _cap_timedate ??= new(_twain, CAP.CAP_TIMEDATE, 1);
CapReader<TW_BOOL>? _cap_uicontrollable;
public CapReader<TW_BOOL> CAP_UICONTROLLABLE => _cap_uicontrollable ??= new(_twain, CAP.CAP_UICONTROLLABLE, 1.6f);
CapWriter<short>? _cap_xfercount;
public CapWriter<short> CAP_XFERCOUNT => _cap_xfercount ??= new(_twain, CAP.CAP_XFERCOUNT, 1);
}
}

View File

@ -1,14 +1,360 @@
using NTwain.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NTwain.Caps
{
partial class KnownCaps
{
CapWriter<TW_BOOL>? _icap_autobright;
public CapWriter<TW_BOOL> ICAP_AUTOBRIGHT => _icap_autobright ??= new(_twain, CAP.ICAP_AUTOBRIGHT, 1);
CapWriter<TW_BOOL>? _icap_autodiscardblankpages;
public CapWriter<TW_BOOL> ICAP_AUTODISCARDBLANKPAGES => _icap_autodiscardblankpages ??= new(_twain, CAP.ICAP_AUTODISCARDBLANKPAGES, 2);
CapWriter<TW_BOOL>? _icap_automaticborderdetection;
public CapWriter<TW_BOOL> ICAP_AUTOMATICBORDERDETECTION => _icap_automaticborderdetection ??= new(_twain, CAP.ICAP_AUTOMATICBORDERDETECTION, 1.8f);
CapWriter<TW_BOOL>? _icap_automaticcolorenabled;
public CapWriter<TW_BOOL> ICAP_AUTOMATICCOLORENABLED => _icap_automaticcolorenabled ??= new(_twain, CAP.ICAP_AUTOMATICCOLORENABLED, 2.1f);
CapWriter<TWPT>? _icap_automaticcolornoncolorpixeltype;
public CapWriter<TWPT> ICAP_AUTOMATICCOLORNONCOLORPIXELTYPE => _icap_automaticcolornoncolorpixeltype ??= new(_twain, CAP.ICAP_AUTOMATICCOLORNONCOLORPIXELTYPE, 2.1f);
CapReader<TW_BOOL>? _icap_automaticcropusesframe;
public CapReader<TW_BOOL> ICAP_AUTOMATICCROPUSESFRAME => _icap_automaticcropusesframe ??= new(_twain, CAP.ICAP_AUTOMATICCROPUSESFRAME, 2.1f);
CapWriter<TW_BOOL>? _icap_automaticdeskew;
public CapWriter<TW_BOOL> ICAP_AUTOMATICDESKEW => _icap_automaticdeskew ??= new(_twain, CAP.ICAP_AUTOMATICDESKEW, 1.8f);
CapWriter<TW_BOOL>? _icap_automaticlengthdetection;
public CapWriter<TW_BOOL> ICAP_AUTOMATICLENGTHDETECTION => _icap_automaticlengthdetection ??= new(_twain, CAP.ICAP_AUTOMATICLENGTHDETECTION, 2.1f);
CapWriter<TW_BOOL>? _icap_automaticrotate;
public CapWriter<TW_BOOL> ICAP_AUTOMATICROTATE => _icap_automaticrotate ??= new(_twain, CAP.ICAP_AUTOMATICROTATE, 1.8f);
CapWriter<TW_BOOL>? _icap_autosize;
public CapWriter<TW_BOOL> ICAP_AUTOSIZE => _icap_autosize ??= new(_twain, CAP.ICAP_AUTOSIZE, 2);
CapWriter<TW_BOOL>? _icap_barcodedetectionenabled;
public CapWriter<TW_BOOL> ICAP_BARCODEDETECTIONENABLED => _icap_barcodedetectionenabled ??= new(_twain, CAP.ICAP_BARCODEDETECTIONENABLED, 1.8f);
CapWriter<uint>? _icap_barcodemaxretries;
public CapWriter<uint> ICAP_BARCODEMAXRETRIES => _icap_barcodemaxretries ??= new(_twain, CAP.ICAP_BARCODEMAXRETRIES, 1.8f);
CapWriter<uint>? _icap_barcodemaxsearchpriorities;
public CapWriter<uint> ICAP_BARCODEMAXSEARCHPRIORITIES => _icap_barcodemaxsearchpriorities ??= new(_twain, CAP.ICAP_BARCODEMAXSEARCHPRIORITIES, 1.8f);
CapWriter<TWBD>? _icap_barcodesearchmode;
public CapWriter<TWBD> ICAP_BARCODESEARCHMODE => _icap_barcodesearchmode ??= new(_twain, CAP.ICAP_BARCODESEARCHMODE, 1.8f);
CapWriter<TWBT>? _icap_barcodesearchpriorities;
public CapWriter<TWBT> ICAP_BARCODESEARCHPRIORITIES => _icap_barcodesearchpriorities ??= new(_twain, CAP.ICAP_BARCODESEARCHPRIORITIES, 1.8f);
CapWriter<uint>? _icap_barcodetimeout;
public CapWriter<uint> ICAP_BARCODETIMEOUT => _icap_barcodetimeout ??= new(_twain, CAP.ICAP_BARCODETIMEOUT, 1.8f);
CapWriter<ushort>? _icap_bitdepth;
public CapWriter<ushort> ICAP_BITDEPTH => _icap_bitdepth ??= new(_twain, CAP.ICAP_BITDEPTH, 1);
CapWriter<TWBR>? _icap_bitdepthreduction;
public CapWriter<TWBR> ICAP_BITDEPTHREDUCTION => _icap_bitdepthreduction ??= new(_twain, CAP.ICAP_BITDEPTHREDUCTION, 1.5f);
CapWriter<TWBO>? _icap_bitorder;
public CapWriter<TWBO> ICAP_BITORDER => _icap_bitorder ??= new(_twain, CAP.ICAP_BITORDER, 1);
CapWriter<TWBO>? _icap_bitordercodes;
public CapWriter<TWBO> ICAP_BITORDERCODES => _icap_bitordercodes ??= new(_twain, CAP.ICAP_BITORDERCODES, 1);
CapWriter<TW_FIX32>? _icap_brightness;
public CapWriter<TW_FIX32> ICAP_BRIGHTNESS => _icap_brightness ??= new(_twain, CAP.ICAP_BRIGHTNESS, 1);
CapWriter<ushort>? _icap_ccittkfactor;
public CapWriter<ushort> ICAP_CCITTKFACTOR => _icap_ccittkfactor ??= new(_twain, CAP.ICAP_CCITTKFACTOR, 1);
CapWriter<TW_BOOL>? _icap_colormanagementenabled;
public CapWriter<TW_BOOL> ICAP_COLORMANAGEMENTENABLED => _icap_colormanagementenabled ??= new(_twain, CAP.ICAP_COLORMANAGEMENTENABLED, 2.1f);
CapWriter<TWCP>? _icap_compression;
public CapWriter<TWCP> ICAP_COMPRESSION => _icap_compression ??= new(_twain, CAP.ICAP_COMPRESSION, 1);
CapWriter<TW_FIX32>? _icap_contrast;
public CapWriter<TW_FIX32> ICAP_CONTRAST => _icap_contrast ??= new(_twain, CAP.ICAP_CONTRAST, 1);
CapWriter<byte>? _icap_custhalftone;
public CapWriter<byte> ICAP_CUSTHALFTONE => _icap_custhalftone ??= new(_twain, CAP.ICAP_CUSTHALFTONE, 1);
CapWriter<TW_FIX32>? _icap_exposuretime;
public CapWriter<TW_FIX32> ICAP_EXPOSURETIME => _icap_exposuretime ??= new(_twain, CAP.ICAP_EXPOSURETIME, 1);
CapWriter<TW_BOOL>? _icap_extimageinfo;
public CapWriter<TW_BOOL> ICAP_EXTIMAGEINFO => _icap_extimageinfo ??= new(_twain, CAP.ICAP_EXTIMAGEINFO, 1.7f);
CapWriter<TWFE>? _icap_feedertype;
public CapWriter<TWFE> ICAP_FEEDERTYPE => _icap_feedertype ??= new(_twain, CAP.ICAP_FEEDERTYPE, 1.91f);
CapWriter<TWFM>? _icap_filmtype;
public CapWriter<TWFM> ICAP_FILMTYPE => _icap_filmtype ??= new(_twain, CAP.ICAP_FILMTYPE, 2.2f);
CapWriter<TWFT>? _icap_filter;
public CapWriter<TWFT> ICAP_FILTER => _icap_filter ??= new(_twain, CAP.ICAP_FILTER, 1);
//CapWriter<TWFL>? _icap_flashused;
//public CapWriter<TWFL> ICAP_FLASHUSED => _icap_flashused ??= new(_twain, CAP.ICAP_FLASHUSED, 1);
CapWriter<TWFL>? _icap_flashused2;
public CapWriter<TWFL> ICAP_FLASHUSED2 => _icap_flashused2 ??= new(_twain, CAP.ICAP_FLASHUSED2, 1.8f);
CapWriter<TWFR>? _icap_fliprotation;
public CapWriter<TWFR> ICAP_FLIPROTATION => _icap_fliprotation ??= new(_twain, CAP.ICAP_FLIPROTATION, 1.8f);
CapWriter<TW_FRAME>? _icap_frames;
public CapWriter<TW_FRAME> ICAP_FRAMES => _icap_frames ??= new(_twain, CAP.ICAP_FRAMES, 1);
CapWriter<TW_FIX32>? _icap_gamma;
public CapWriter<TW_FIX32> ICAP_GAMMA => _icap_gamma ??= new(_twain, CAP.ICAP_GAMMA, 1);
CapWriter<TW_STR32>? _icap_halftones;
public CapWriter<TW_STR32> ICAP_HALFTONES => _icap_halftones ??= new(_twain, CAP.ICAP_HALFTONES, 1);
CapWriter<TW_FIX32>? _icap_highlight;
public CapWriter<TW_FIX32> ICAP_HIGHLIGHT => _icap_highlight ??= new(_twain, CAP.ICAP_HIGHLIGHT, 1);
CapWriter<TWIC>? _icap_iccprofile;
public CapWriter<TWIC> ICAP_ICCPROFILE => _icap_iccprofile ??= new(_twain, CAP.ICAP_ICCPROFILE, 1.91f);
CapWriter<uint>? _icap_imagedataset;
public CapWriter<uint> ICAP_IMAGEDATASET => _icap_imagedataset ??= new(_twain, CAP.ICAP_IMAGEDATASET, 1.7f);
CapWriter<TWFF>? _icap_imagefileformat;
public CapWriter<TWFF> ICAP_IMAGEFILEFORMAT => _icap_imagefileformat ??= new(_twain, CAP.ICAP_IMAGEFILEFORMAT, 1);
CapWriter<TWIF>? _icap_imagefilter;
public CapWriter<TWIF> ICAP_IMAGEFILTER => _icap_imagefilter ??= new(_twain, CAP.ICAP_IMAGEFILTER, 1.8f);
CapWriter<TWIM>? _icap_imagemerge;
public CapWriter<TWIM> ICAP_IMAGEMERGE => _icap_imagemerge ??= new(_twain, CAP.ICAP_IMAGEMERGE, 2.1f);
CapWriter<TW_FIX32>? _icap_imagemergeheightthreshold;
public CapWriter<TW_FIX32> ICAP_IMAGEMERGEHEIGHTTHRESHOLD => _icap_imagemergeheightthreshold ??= new(_twain, CAP.ICAP_IMAGEMERGEHEIGHTTHRESHOLD, 2.1f);
CapWriter<TWPT>? _icap_jpegpixeltype;
public CapWriter<TWPT> ICAP_JPEGPIXELTYPE => _icap_jpegpixeltype ??= new(_twain, CAP.ICAP_JPEGPIXELTYPE, 1);
CapWriter<TWJQ>? _icap_jpegquality;
public CapWriter<TWJQ> ICAP_JPEGQUALITY => _icap_jpegquality ??= new(_twain, CAP.ICAP_JPEGQUALITY, 1.9f);
CapWriter<TWJS>? _icap_jpegsubsampling;
public CapWriter<TWJS> ICAP_JPEGSUBSAMPLING => _icap_jpegsubsampling ??= new(_twain, CAP.ICAP_JPEGSUBSAMPLING, 2.2f);
CapWriter<TW_BOOL>? _icap_lampstate;
public CapWriter<TW_BOOL> ICAP_LAMPSTATE => _icap_lampstate ??= new(_twain, CAP.ICAP_LAMPSTATE, 1);
CapWriter<TWLP>? _icap_lightpath;
public CapWriter<TWLP> ICAP_LIGHTPATH => _icap_lightpath ??= new(_twain, CAP.ICAP_LIGHTPATH, 1);
CapWriter<TWLS>? _icap_lightsource;
public CapWriter<TWLS> ICAP_LIGHTSOURCE => _icap_lightsource ??= new(_twain, CAP.ICAP_LIGHTSOURCE, 1);
CapWriter<ushort>? _icap_maxframes;
public CapWriter<ushort> ICAP_MAXFRAMES => _icap_maxframes ??= new(_twain, CAP.ICAP_MAXFRAMES, 1);
CapReader<TW_FIX32>? _icap_minimumheight;
public CapReader<TW_FIX32> ICAP_MINIMUMHEIGHT => _icap_minimumheight ??= new(_twain, CAP.ICAP_MINIMUMHEIGHT, 1.7f);
CapReader<TW_FIX32>? _icap_minimumwidth;
public CapReader<TW_FIX32> ICAP_MINIMUMWIDTH => _icap_minimumwidth ??= new(_twain, CAP.ICAP_MINIMUMWIDTH, 1.7f);
CapWriter<TWMR>? _icap_mirror;
public CapWriter<TWMR> ICAP_MIRROR => _icap_mirror ??= new(_twain, CAP.ICAP_MIRROR, 2.2f);
CapWriter<TWNF>? _icap_noisefilter;
public CapWriter<TWNF> ICAP_NOISEFILTER => _icap_noisefilter ??= new(_twain, CAP.ICAP_NOISEFILTER, 1.8f);
CapWriter<TWOR>? _icap_orientation;
public CapWriter<TWOR> ICAP_ORIENTATION => _icap_orientation ??= new(_twain, CAP.ICAP_ORIENTATION, 1);
CapWriter<TWOV>? _icap_overscan;
public CapWriter<TWOV> ICAP_OVERSCAN => _icap_overscan ??= new(_twain, CAP.ICAP_OVERSCAN, 1.8f);
CapWriter<TW_BOOL>? _icap_patchcodedetectionenabled;
public CapWriter<TW_BOOL> ICAP_PATCHCODEDETECTIONENABLED => _icap_patchcodedetectionenabled ??= new(_twain, CAP.ICAP_PATCHCODEDETECTIONENABLED, 1.8f);
CapWriter<uint>? _icap_patchcodemaxretries;
public CapWriter<uint> ICAP_PATCHCODEMAXRETRIES => _icap_patchcodemaxretries ??= new(_twain, CAP.ICAP_PATCHCODEMAXRETRIES, 1.8f);
CapWriter<uint>? _icap_patchcodemaxsearchpriorities;
public CapWriter<uint> ICAP_PATCHCODEMAXSEARCHPRIORITIES => _icap_patchcodemaxsearchpriorities ??= new(_twain, CAP.ICAP_PATCHCODEMAXSEARCHPRIORITIES, 1.8f);
CapWriter<TWBD>? _icap_patchcodesearchmode;
public CapWriter<TWBD> ICAP_PATCHCODESEARCHMODE => _icap_patchcodesearchmode ??= new(_twain, CAP.ICAP_PATCHCODESEARCHMODE, 1.8f);
CapWriter<TWPCH>? _icap_patchcodesearchpriorities;
public CapWriter<TWPCH> ICAP_PATCHCODESEARCHPRIORITIES => _icap_patchcodesearchpriorities ??= new(_twain, CAP.ICAP_PATCHCODESEARCHPRIORITIES, 1.8f);
CapWriter<uint>? _icap_patchcodetimeout;
public CapWriter<uint> ICAP_PATCHCODETIMEOUT => _icap_patchcodetimeout ??= new(_twain, CAP.ICAP_PATCHCODETIMEOUT, 1.8f);
CapReader<TW_FIX32>? _icap_physicalheight;
public CapReader<TW_FIX32> ICAP_PHYSICALHEIGHT => _icap_physicalheight ??= new(_twain, CAP.ICAP_PHYSICALHEIGHT, 1);
CapReader<TW_FIX32>? _icap_physicalwidth;
public CapReader<TW_FIX32> ICAP_PHYSICALWIDTH => _icap_physicalwidth ??= new(_twain, CAP.ICAP_PHYSICALWIDTH, 1);
CapWriter<TWPF>? _icap_pixelflavor;
public CapWriter<TWPF> ICAP_PIXELFLAVOR => _icap_pixelflavor ??= new(_twain, CAP.ICAP_PIXELFLAVOR, 1);
CapWriter<TWPF>? _icap_pixelflavorcodes;
public CapWriter<TWPF> ICAP_PIXELFLAVORCODES => _icap_pixelflavorcodes ??= new(_twain, CAP.ICAP_PIXELFLAVORCODES, 1);
CapWriter<TWPT>? _icap_pixeltype;
public CapWriter<TWPT> ICAP_PIXELTYPE => _icap_pixeltype ??= new(_twain, CAP.ICAP_PIXELTYPE, 1);
CapWriter<TWPC>? _icap_planarchunky;
public CapWriter<TWPC> ICAP_PLANARCHUNKY => _icap_planarchunky ??= new(_twain, CAP.ICAP_PLANARCHUNKY, 1);
CapWriter<TW_FIX32>? _icap_rotation;
public CapWriter<TW_FIX32> ICAP_ROTATION => _icap_rotation ??= new(_twain, CAP.ICAP_ROTATION, 1);
CapWriter<TW_FIX32>? _icap_shadow;
public CapWriter<TW_FIX32> ICAP_SHADOW => _icap_shadow ??= new(_twain, CAP.ICAP_SHADOW, 1);
CapReader<TWBT>? _icap_supportedbarcodetypes;
public CapReader<TWBT> ICAP_SUPPORTEDBARCODETYPES => _icap_supportedbarcodetypes ??= new(_twain, CAP.ICAP_SUPPORTEDBARCODETYPES, 1.8f);
CapReader<TWEI>? _icap_supportedextimageinfo;
public CapReader<TWEI> ICAP_SUPPORTEDEXTIMAGEINFO => _icap_supportedextimageinfo ??= new(_twain, CAP.ICAP_SUPPORTEDEXTIMAGEINFO, 2.1f);
CapReader<TWPCH>? _icap_supportedpatchcodetypes;
public CapReader<TWPCH> ICAP_SUPPORTEDPATCHCODETYPES => _icap_supportedpatchcodetypes ??= new(_twain, CAP.ICAP_SUPPORTEDPATCHCODETYPES, 1.8f);
CapWriter<TWSS>? _icap_supportedsizes;
public CapWriter<TWSS> ICAP_SUPPORTEDSIZES => _icap_supportedsizes ??= new(_twain, CAP.ICAP_SUPPORTEDSIZES, 1);
CapWriter<TW_FIX32>? _icap_threshold;
public CapWriter<TW_FIX32> ICAP_THRESHOLD => _icap_threshold ??= new(_twain, CAP.ICAP_THRESHOLD, 1);
CapWriter<TW_BOOL>? _icap_tiles;
public CapWriter<TW_BOOL> ICAP_TILES => _icap_tiles ??= new(_twain, CAP.ICAP_TILES, 1);
CapWriter<ushort>? _icap_timefill;
public CapWriter<ushort> ICAP_TIMEFILL => _icap_timefill ??= new(_twain, CAP.ICAP_TIMEFILL, 1);
CapWriter<TW_BOOL>? _icap_undefinedimagesize;
public CapWriter<TW_BOOL> ICAP_UNDEFINEDIMAGESIZE => _icap_undefinedimagesize ??= new(_twain, CAP.ICAP_UNDEFINEDIMAGESIZE, 1.6f);
CapWriter<TWUN>? _icap_units;
public CapWriter<TWUN> ICAP_UNITS => _icap_units ??= new(_twain, CAP.ICAP_UNITS, 1);
CapWriter<TWSX>? _icap_xfermech;
public CapWriter<TWSX> ICAP_XFERMECH => _icap_xfermech ??= new(_twain, CAP.ICAP_XFERMECH, 1);
CapReader<TW_FIX32>? _icap_xnativeresolution;
public CapReader<TW_FIX32> ICAP_XNATIVERESOLUTION => _icap_xnativeresolution ??= new(_twain, CAP.ICAP_XNATIVERESOLUTION, 1);
CapWriter<TW_FIX32>? _icap_xresolution;
public CapWriter<TW_FIX32> ICAP_XRESOLUTION => _icap_xresolution ??= new(_twain, CAP.ICAP_XRESOLUTION, 1);
CapWriter<TW_FIX32>? _icap_xscaling;
public CapWriter<TW_FIX32> ICAP_XSCALING => _icap_xscaling ??= new(_twain, CAP.ICAP_XSCALING, 1);
CapReader<TW_FIX32>? _icap_ynativeresolution;
public CapReader<TW_FIX32> ICAP_YNATIVERESOLUTION => _icap_ynativeresolution ??= new(_twain, CAP.ICAP_YNATIVERESOLUTION, 1);
CapWriter<TW_FIX32>? _icap_yresolution;
public CapWriter<TW_FIX32> ICAP_YRESOLUTION => _icap_yresolution ??= new(_twain, CAP.ICAP_YRESOLUTION, 1);
CapWriter<TW_FIX32>? _icap_yscaling;
public CapWriter<TW_FIX32> ICAP_YSCALING => _icap_yscaling ??= new(_twain, CAP.ICAP_YSCALING, 1);
CapWriter<short>? _icap_zoomfactor;
public CapWriter<short> ICAP_ZOOMFACTOR => _icap_zoomfactor ??= new(_twain, CAP.ICAP_ZOOMFACTOR, 1.8f);
}
}

View File

@ -1,9 +1,4 @@
using NTwain.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NTwain.Caps
{
@ -12,7 +7,7 @@ namespace NTwain.Caps
/// </summary>
public partial class KnownCaps
{
private readonly TwainAppSession _twain;
protected readonly TwainAppSession _twain;
public KnownCaps(TwainAppSession twain)
{

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
@ -100,7 +101,7 @@ namespace NTwain.Data
/// <param name="memMgr"></param>
/// <param name="values"></param>
/// <returns></returns>
public static TW_CAPABILITY CreateArrayCap<TValue>(this CAP cap, IMemoryManager memMgr, params TValue[] values) where TValue : struct
public static TW_CAPABILITY CreateArrayCap<TValue>(this CAP cap, IMemoryManager memMgr, IList<TValue> values) where TValue : struct
{
if (values == null) throw new ArgumentNullException(nameof(values));
@ -117,13 +118,13 @@ namespace NTwain.Data
if (TWPlatform.IsMacOSX)
{
// Allocate...
twCap.hContainer = memMgr.Alloc((uint)(Marshal.SizeOf(default(TW_ARRAY_MACOSX)) + ((values.Length + 1) * Marshal.SizeOf(default(TW_STR255)))));
twCap.hContainer = memMgr.Alloc((uint)(Marshal.SizeOf(default(TW_ARRAY_MACOSX)) + ((values.Count + 1) * Marshal.SizeOf(default(TW_STR255)))));
lockedPtr = memMgr.Lock(twCap.hContainer);
// Set the meta data...
TW_ARRAY_MACOSX twarraymacosx = default;
twarraymacosx.ItemType = (uint)itemType;
twarraymacosx.NumItems = (uint)values.Length;
twarraymacosx.NumItems = (uint)values.Count;
Marshal.StructureToPtr(twarraymacosx, lockedPtr, false);
// Get the pointer to the ItemList...
@ -132,13 +133,13 @@ namespace NTwain.Data
else
{
// Allocate...
twCap.hContainer = memMgr.Alloc((uint)(Marshal.SizeOf(default(TW_ARRAY)) + ((values.Length + 1) * Marshal.SizeOf(default(TW_STR255)))));
twCap.hContainer = memMgr.Alloc((uint)(Marshal.SizeOf(default(TW_ARRAY)) + ((values.Count + 1) * Marshal.SizeOf(default(TW_STR255)))));
lockedPtr = memMgr.Lock(twCap.hContainer);
// Set the meta data...
TW_ARRAY twarray = default;
twarray.ItemType = itemType;
twarray.NumItems = (uint)values.Length;
twarray.NumItems = (uint)values.Count;
Marshal.StructureToPtr(twarray, lockedPtr, false);
// Get the pointer to the ItemList...
@ -146,7 +147,7 @@ namespace NTwain.Data
}
// Set the ItemList...
for (var i = 0; i < values.Length; i++)
for (var i = 0; i < values.Count; i++)
{
WriteContainerData(lockedPtr, itemType, values[i], i);
}

View File

@ -60,31 +60,30 @@ namespace NTwain
/// <param name="cap"></param>
/// <param name="value"></param>
/// <returns></returns>
public STS GetCapCurrent<TValue>(CAP cap, out TValue value) where TValue : struct
public STS GetCapCurrent<TValue>(CAP cap, out List<TValue> value) where TValue : struct
{
value = default;
value = new List<TValue>();
var sts = GetCapCurrent(cap, out TW_CAPABILITY twcap);
if (sts.RC == TWRC.SUCCESS)
{
switch (twcap.ConType)
{
case TWON.ONEVALUE:
value = twcap.ReadOneValue<TValue>(this);
value.Add(twcap.ReadOneValue<TValue>(this));
break;
case TWON.ENUMERATION:
var twenum = twcap.ReadEnumeration<TValue>(this);
if (twenum.Items != null && twenum.CurrentIndex < twenum.Items.Length)
{
value = twenum.Items[twenum.CurrentIndex];
value.Add(twenum.Items[twenum.CurrentIndex]);
}
break;
case TWON.RANGE:
value = twcap.ReadRange<TValue>(this).CurrentValue;
value.Add(twcap.ReadRange<TValue>(this).CurrentValue);
break;
case TWON.ARRAY:
// no source should ever return an array but anyway
var twarr = twcap.ReadArray<TValue>(this);
if (twarr != null && twarr.Count > 0) value = twarr[0];
if (twarr != null && twarr.Count > 0) value.AddRange(twarr);
break;
default:
twcap.Free(this); break;
@ -115,31 +114,30 @@ namespace NTwain
/// <param name="cap"></param>
/// <param name="value"></param>
/// <returns></returns>
public STS GetCapDefault<TValue>(CAP cap, out TValue value) where TValue : struct
public STS GetCapDefault<TValue>(CAP cap, out List<TValue> value) where TValue : struct
{
value = default;
value = new List<TValue>();
var sts = GetCapDefault(cap, out TW_CAPABILITY twcap);
if (sts.RC == TWRC.SUCCESS)
{
switch (twcap.ConType)
{
case TWON.ONEVALUE:
value = twcap.ReadOneValue<TValue>(this);
value.Add(twcap.ReadOneValue<TValue>(this));
break;
case TWON.ENUMERATION:
var twenum = twcap.ReadEnumeration<TValue>(this);
if (twenum.Items != null && twenum.DefaultIndex < twenum.Items.Length)
{
value = twenum.Items[twenum.DefaultIndex];
value.Add(twenum.Items[twenum.DefaultIndex]);
}
break;
case TWON.RANGE:
value = twcap.ReadRange<TValue>(this).DefaultValue;
value.Add(twcap.ReadRange<TValue>(this).DefaultValue);
break;
case TWON.ARRAY:
// no source should ever return an array but anyway
var twarr = twcap.ReadArray<TValue>(this);
if (twarr != null && twarr.Count > 0) value = twarr[0];
if (twarr != null && twarr.Count > 0) value.AddRange(twarr);
break;
default:
twcap.Free(this); break;
@ -394,10 +392,10 @@ namespace NTwain
private void RefreshCapLanguage()
{
var rc2 = GetCapCurrent(CAP.CAP_LANGUAGE, out TWLG lang);
if (rc2.RC == TWRC.SUCCESS)
var rc2 = GetCapCurrent(CAP.CAP_LANGUAGE, out List<TWLG> lang);
if (rc2.RC == TWRC.SUCCESS && lang.Count > 0)
{
Language.Set(lang);
Language.Set(lang.First());
}
}
}

View File

@ -4,6 +4,7 @@ using NTwain.Triplets;
using System;
using System.Buffers;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
namespace NTwain
@ -57,8 +58,8 @@ namespace NTwain
var imgXferMech = TWSX.NATIVE;
var audXferMech = TWSX.NATIVE;
if (xferImage) GetCapCurrent(CAP.ICAP_XFERMECH, out imgXferMech);
else if (xferAudio) GetCapCurrent(CAP.ACAP_XFERMECH, out audXferMech);
if (xferImage) imgXferMech = Caps.ICAP_XFERMECH.GetCurrent().FirstOrDefault();
else if (xferAudio) audXferMech = Caps.ACAP_XFERMECH.GetCurrent().FirstOrDefault();
TW_PENDINGXFERS pending = default;
var sts = WrapInSTS(DGControl.PendingXfers.Get(ref _appIdentity, ref _currentDS, ref pending));
@ -209,8 +210,8 @@ namespace NTwain
DGControl.PendingXfers.EndXfer(ref _appIdentity, ref _currentDS, ref pending);
break;
case TWCC.OPERATIONERROR:
GetCapCurrent(CAP.CAP_INDICATORS, out TW_BOOL showIndicator);
if (_userInterface.ShowUI == 0 && showIndicator == TW_BOOL.False)
var indicators = Caps.CAP_INDICATORS.GetCurrent().FirstOrDefault();
if (_userInterface.ShowUI == 0 && indicators == TW_BOOL.False)
{
// todo: alert user and drop to S4
}