mirror of
https://github.com/soukoku/ntwain.git
synced 2025-10-24 10:11:20 +08:00
Some CA changes.
This commit is contained in:
@@ -192,7 +192,7 @@ namespace NTwain
|
||||
public bool IsSupported { get { return SupportedActions > QuerySupports.None; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether <see cref="Get"/> is supported.
|
||||
/// Gets a value indicating whether <see cref="GetValues"/> is supported.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if this capability can get values; otherwise, <c>false</c>.
|
||||
@@ -248,7 +248,7 @@ namespace NTwain
|
||||
public bool CanReset { get { return Supports(QuerySupports.Reset); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether <see cref="Set"/> is supported.
|
||||
/// Gets a value indicating whether <see cref="SetValue"/> is supported.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if this capability can set; otherwise, <c>false</c>.
|
||||
@@ -297,7 +297,7 @@ namespace NTwain
|
||||
/// Gets all the possible values of this capability.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IList<TValue> Get()
|
||||
public IList<TValue> GetValues()
|
||||
{
|
||||
return _source.CapGet(Capability).Select(o => _getConvertRoutine(o)).ToList();
|
||||
}
|
||||
@@ -393,7 +393,7 @@ namespace NTwain
|
||||
/// <param name="value">The value.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="System.InvalidOperationException">Simple Set() is not defined for this capability.</exception>
|
||||
public ReturnCode Set(TValue value)
|
||||
public ReturnCode SetValue(TValue value)
|
||||
{
|
||||
ReturnCode rc = ReturnCode.Failure;
|
||||
|
||||
@@ -420,7 +420,7 @@ namespace NTwain
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <returns></returns>
|
||||
public ReturnCode Set(TWArray value)
|
||||
public ReturnCode SetValue(TWArray value)
|
||||
{
|
||||
ReturnCode rc = ReturnCode.Failure;
|
||||
using (var cap = new TWCapability(Capability, value))
|
||||
@@ -435,7 +435,7 @@ namespace NTwain
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <returns></returns>
|
||||
public ReturnCode Set(TWEnumeration value)
|
||||
public ReturnCode SetValue(TWEnumeration value)
|
||||
{
|
||||
ReturnCode rc = ReturnCode.Failure;
|
||||
using (var cap = new TWCapability(Capability, value))
|
||||
|
||||
@@ -207,6 +207,14 @@ namespace NTwain
|
||||
}
|
||||
break;
|
||||
case ContainerType.Range:
|
||||
PopulateRange(toPopulate);
|
||||
break;
|
||||
}
|
||||
return toPopulate;
|
||||
}
|
||||
|
||||
private void PopulateRange(IList<object> toPopulate)
|
||||
{
|
||||
// horrible cast but should work.
|
||||
// in the for loop we also compare against min in case the step
|
||||
// is parsed as negative number and causes infinite loop.
|
||||
@@ -215,7 +223,6 @@ namespace NTwain
|
||||
case Data.ItemType.Fix32:
|
||||
{
|
||||
var min = (TWFix32)RangeMinValue;
|
||||
var counter = min;
|
||||
var max = (TWFix32)RangeMaxValue;
|
||||
var step = (TWFix32)RangeStepSize;
|
||||
|
||||
@@ -228,7 +235,6 @@ namespace NTwain
|
||||
case Data.ItemType.UInt32:
|
||||
{
|
||||
var min = (uint)RangeMinValue;
|
||||
var counter = min;
|
||||
var max = (uint)RangeMaxValue;
|
||||
var step = (uint)RangeStepSize;
|
||||
|
||||
@@ -241,7 +247,6 @@ namespace NTwain
|
||||
case Data.ItemType.Int32:
|
||||
{
|
||||
var min = (int)RangeMinValue;
|
||||
var counter = min;
|
||||
var max = (int)RangeMaxValue;
|
||||
var step = (int)RangeStepSize;
|
||||
|
||||
@@ -255,7 +260,6 @@ namespace NTwain
|
||||
case Data.ItemType.UInt16:
|
||||
{
|
||||
var min = (ushort)RangeMinValue;
|
||||
var counter = min;
|
||||
var max = (ushort)RangeMaxValue;
|
||||
var step = (ushort)RangeStepSize;
|
||||
|
||||
@@ -268,7 +272,6 @@ namespace NTwain
|
||||
case Data.ItemType.Int16:
|
||||
{
|
||||
var min = (short)RangeMinValue;
|
||||
var counter = min;
|
||||
var max = (short)RangeMaxValue;
|
||||
var step = (short)RangeStepSize;
|
||||
|
||||
@@ -281,7 +284,6 @@ namespace NTwain
|
||||
case Data.ItemType.UInt8:
|
||||
{
|
||||
var min = (byte)RangeMinValue;
|
||||
var counter = min;
|
||||
var max = (byte)RangeMaxValue;
|
||||
var step = (byte)RangeStepSize;
|
||||
|
||||
@@ -294,7 +296,6 @@ namespace NTwain
|
||||
case Data.ItemType.Int8:
|
||||
{
|
||||
var min = (sbyte)RangeMinValue;
|
||||
var counter = min;
|
||||
var max = (sbyte)RangeMaxValue;
|
||||
var step = (sbyte)RangeStepSize;
|
||||
|
||||
@@ -305,9 +306,6 @@ namespace NTwain
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return toPopulate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace NTwain.Data
|
||||
|
||||
// new method:
|
||||
// try to convert to enum's underlying type first then cast to the enum
|
||||
return (TEnum)Convert.ChangeType(value, rawType);
|
||||
return (TEnum)Convert.ChangeType(value, rawType, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (typeof(IConvertible).IsAssignableFrom(returnType))
|
||||
{
|
||||
|
||||
@@ -1576,7 +1576,7 @@ namespace NTwain
|
||||
};
|
||||
|
||||
// this needs to also set undefined size optino
|
||||
rc = ICapUndefinedImageSize.Set(value);
|
||||
rc = ICapUndefinedImageSize.SetValue(value);
|
||||
using (TWCapability capValue = new TWCapability(CapabilityId.ICapAutomaticBorderDetection, one))
|
||||
{
|
||||
rc = _session.DGControl.Capability.Set(capValue);
|
||||
@@ -2002,11 +2002,11 @@ namespace NTwain
|
||||
// for one of them since setting autoscan also sets autofeed
|
||||
if (CapAutoScan.CanSet)
|
||||
{
|
||||
rc = CapAutoScan.Set(value);
|
||||
rc = CapAutoScan.SetValue(value);
|
||||
}
|
||||
else if (CapAutoFeed.CanSet)
|
||||
{
|
||||
rc = CapAutoFeed.Set(value);
|
||||
rc = CapAutoFeed.SetValue(value);
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace NTwain
|
||||
{
|
||||
if (_supportedCapsList == null && _session.State > 3)
|
||||
{
|
||||
_supportedCapsList = CapSupportedCaps.Get();
|
||||
_supportedCapsList = CapSupportedCaps.GetValues();
|
||||
}
|
||||
return _supportedCapsList ?? _emptyCapList;
|
||||
}
|
||||
|
||||
BIN
NTwain/GlobalSuppressions.cs
Normal file
BIN
NTwain/GlobalSuppressions.cs
Normal file
Binary file not shown.
@@ -11,7 +11,7 @@ namespace NTwain
|
||||
public interface IReadOnlyCapWrapper<TValue>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether <see cref="Get"/> is supported.
|
||||
/// Gets a value indicating whether <see cref="GetValues"/> is supported.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if this capability can get values; otherwise, <c>false</c>.
|
||||
@@ -95,7 +95,7 @@ namespace NTwain
|
||||
/// Gets all the possible values of this capability.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IList<TValue> Get();
|
||||
IList<TValue> GetValues();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current value of this capability.
|
||||
@@ -153,20 +153,20 @@ namespace NTwain
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <returns></returns>
|
||||
ReturnCode Set(TValue value);/// <summary>
|
||||
ReturnCode SetValue(TValue value);/// <summary>
|
||||
///
|
||||
/// A version of Set that uses an array.
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <returns></returns>
|
||||
ReturnCode Set(TWArray value);
|
||||
ReturnCode SetValue(TWArray value);
|
||||
|
||||
/// <summary>
|
||||
/// A version of Set that uses an enumeration.
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <returns></returns>
|
||||
ReturnCode Set(TWEnumeration value);
|
||||
ReturnCode SetValue(TWEnumeration value);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the constraint value of this capability.
|
||||
|
||||
@@ -88,7 +88,6 @@ namespace NTwain
|
||||
var headerSize = Marshal.SizeOf(typeof(TIFFHEADER));
|
||||
var tagSize = Marshal.SizeOf(typeof(TIFFTAG));
|
||||
var tiffSize = 0;
|
||||
var header = (TIFFHEADER)Marshal.PtrToStructure(data, typeof(TIFFHEADER));
|
||||
var tagPtr = data.ToInt64() + headerSize;
|
||||
for (int i = 0; i < 999; i++)
|
||||
{
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
<Compile Include="Data\TypeExtensions.cs" />
|
||||
<Compile Include="Data\TwainTypesExtended.cs" />
|
||||
<Compile Include="DeviceEventArgs.cs" />
|
||||
<Compile Include="GlobalSuppressions.cs" />
|
||||
<Compile Include="IDataSource.cs" />
|
||||
<Compile Include="ICapControl.cs" />
|
||||
<Compile Include="Internals\Extensions.cs" />
|
||||
|
||||
@@ -10,6 +10,10 @@ namespace NTwain
|
||||
/// </summary>
|
||||
public enum State
|
||||
{
|
||||
/// <summary>
|
||||
/// Just a default value.
|
||||
/// </summary>
|
||||
Invalid = 0,
|
||||
/// <summary>
|
||||
/// The starting state, corresponds to state 1.
|
||||
/// </summary>
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Tester.WPF
|
||||
//rc = DGControl.Status.Get(dsId, ref stat);
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
foreach (var c in DS.CapSupportedCaps.Get().Select(o => new CapVM(DS, o)))
|
||||
foreach (var c in DS.CapSupportedCaps.GetValues().Select(o => new CapVM(DS, o)))
|
||||
{
|
||||
Caps.Add(c);
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace Tester.WPF
|
||||
{
|
||||
if (_session.CurrentSource.ICapXferMech.GetCurrent() == XferMech.File)
|
||||
{
|
||||
var formats = _session.CurrentSource.ICapImageFileFormat.Get();
|
||||
var formats = _session.CurrentSource.ICapImageFileFormat.GetValues();
|
||||
var wantFormat = formats.Contains(FileFormat.Tiff) ? FileFormat.Tiff : FileFormat.Bmp;
|
||||
|
||||
var fileSetup = new TWSetupFileXfer
|
||||
|
||||
@@ -322,7 +322,7 @@ namespace Tester.Winform
|
||||
|
||||
private void LoadPaperSize(ICapWrapper<SupportedSize> cap)
|
||||
{
|
||||
var list = cap.Get();
|
||||
var list = cap.GetValues();
|
||||
comboSize.DataSource = list;
|
||||
var cur = cap.GetCurrent();
|
||||
if (list.Contains(cur))
|
||||
@@ -346,7 +346,7 @@ namespace Tester.Winform
|
||||
private void LoadDPI(ICapWrapper<TWFix32> cap)
|
||||
{
|
||||
// only allow dpi of certain values for those source that lists everything
|
||||
var list = cap.Get().Where(dpi => (dpi % 50) == 0).ToList();
|
||||
var list = cap.GetValues().Where(dpi => (dpi % 50) == 0).ToList();
|
||||
comboDPI.DataSource = list;
|
||||
var cur = cap.GetCurrent();
|
||||
if (list.Contains(cur))
|
||||
@@ -357,7 +357,7 @@ namespace Tester.Winform
|
||||
|
||||
private void LoadDepth(ICapWrapper<PixelType> cap)
|
||||
{
|
||||
var list = cap.Get();
|
||||
var list = cap.GetValues();
|
||||
comboDepth.DataSource = list;
|
||||
var cur = cap.GetCurrent();
|
||||
if (list.Contains(cur))
|
||||
@@ -376,7 +376,7 @@ namespace Tester.Winform
|
||||
if (!_loadingCaps && _twain.State == 4)
|
||||
{
|
||||
var sel = (SupportedSize)comboSize.SelectedItem;
|
||||
_twain.CurrentSource.ICapSupportedSizes.Set(sel);
|
||||
_twain.CurrentSource.ICapSupportedSizes.SetValue(sel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,7 +385,7 @@ namespace Tester.Winform
|
||||
if (!_loadingCaps && _twain.State == 4)
|
||||
{
|
||||
var sel = (PixelType)comboDepth.SelectedItem;
|
||||
_twain.CurrentSource.ICapPixelType.Set(sel);
|
||||
_twain.CurrentSource.ICapPixelType.SetValue(sel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,8 +394,8 @@ namespace Tester.Winform
|
||||
if (!_loadingCaps && _twain.State == 4)
|
||||
{
|
||||
var sel = (TWFix32)comboDPI.SelectedItem;
|
||||
_twain.CurrentSource.ICapXResolution.Set(sel);
|
||||
_twain.CurrentSource.ICapYResolution.Set(sel);
|
||||
_twain.CurrentSource.ICapXResolution.SetValue(sel);
|
||||
_twain.CurrentSource.ICapYResolution.SetValue(sel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,7 +403,7 @@ namespace Tester.Winform
|
||||
{
|
||||
if (!_loadingCaps && _twain.State == 4)
|
||||
{
|
||||
_twain.CurrentSource.CapDuplexEnabled.Set(ckDuplex.Checked ? BoolType.True : BoolType.False);
|
||||
_twain.CurrentSource.CapDuplexEnabled.SetValue(ckDuplex.Checked ? BoolType.True : BoolType.False);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user