mirror of
https://github.com/soukoku/ntwain.git
synced 2026-02-25 13:04:07 +08:00
Moved wrapped capabilities into its own class to reduce DataSource complexity.
This commit is contained in:
@@ -24,17 +24,17 @@ namespace Tester.WPF
|
||||
|
||||
|
||||
var capName = cap.ToString();
|
||||
var wrapProperty = ds.GetType().GetProperty(capName);
|
||||
var wrapProperty = ds.Capabilities.GetType().GetProperty(capName);
|
||||
if (wrapProperty != null)
|
||||
{
|
||||
_wrapper = wrapProperty.GetGetMethod().Invoke(ds, null);
|
||||
_wrapper = wrapProperty.GetGetMethod().Invoke(ds.Capabilities, null);
|
||||
var wrapperType = _wrapper.GetType();
|
||||
_getMethod = wrapperType.GetMethod("GetValues");
|
||||
_getCurrentMethod = wrapperType.GetMethod("GetCurrent");
|
||||
_setMethod = wrapperType.GetMethods().FirstOrDefault(m => m.Name == "SetValue");
|
||||
}
|
||||
|
||||
var supportTest = ds.CapQuerySupport(cap);
|
||||
var supportTest = ds.Capabilities.QuerySupport(cap);
|
||||
if (supportTest.HasValue)
|
||||
{
|
||||
Supports = supportTest.Value;
|
||||
@@ -55,7 +55,7 @@ namespace Tester.WPF
|
||||
{
|
||||
if (_getMethod == null)
|
||||
{
|
||||
return _ds.CapGet(Cap);
|
||||
return _ds.Capabilities.GetValues(Cap);
|
||||
}
|
||||
return _getMethod.Invoke(_wrapper, null) as IEnumerable;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ namespace Tester.WPF
|
||||
{
|
||||
if (_getMethod == null)
|
||||
{
|
||||
return _ds.CapGetCurrent(Cap);
|
||||
return _ds.Capabilities.GetCurrent(Cap);
|
||||
}
|
||||
return _getCurrentMethod.Invoke(_wrapper, null);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Tester.WPF
|
||||
//rc = DGControl.Status.Get(dsId, ref stat);
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
foreach (var c in DS.CapSupportedCaps.GetValues().Select(o => new CapVM(DS, o)))
|
||||
foreach (var c in DS.Capabilities.CapSupportedCaps.GetValues().Select(o => new CapVM(DS, o)))
|
||||
{
|
||||
Caps.Add(c);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace Tester.WPF
|
||||
}
|
||||
}, () =>
|
||||
{
|
||||
return _session.State == 4 && _session.CurrentSource.CapEnableDSUIOnly.GetCurrent() == BoolType.True;
|
||||
return _session.State == 4 && _session.CurrentSource.Capabilities.CapEnableDSUIOnly.GetCurrent() == BoolType.True;
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -246,9 +246,9 @@ namespace Tester.WPF
|
||||
|
||||
void _session_TransferReady(object sender, TransferReadyEventArgs e)
|
||||
{
|
||||
if (_session.CurrentSource.ICapXferMech.GetCurrent() == XferMech.File)
|
||||
if (_session.CurrentSource.Capabilities.ICapXferMech.GetCurrent() == XferMech.File)
|
||||
{
|
||||
var formats = _session.CurrentSource.ICapImageFileFormat.GetValues();
|
||||
var formats = _session.CurrentSource.Capabilities.ICapImageFileFormat.GetValues();
|
||||
var wantFormat = formats.Contains(FileFormat.Tiff) ? FileFormat.Tiff : FileFormat.Bmp;
|
||||
|
||||
var fileSetup = new TWSetupFileXfer
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace Tester.Winform
|
||||
|
||||
_stopScan = false;
|
||||
|
||||
if (_twain.CurrentSource.CapUIControllable.IsSupported)//.SupportedCaps.Contains(CapabilityId.CapUIControllable))
|
||||
if (_twain.CurrentSource.Capabilities.CapUIControllable.IsSupported)//.SupportedCaps.Contains(CapabilityId.CapUIControllable))
|
||||
{
|
||||
// hide scanner ui if possible
|
||||
if (_twain.CurrentSource.Enable(SourceEnableMode.NoUI, false, this.Handle) == ReturnCode.Success)
|
||||
@@ -301,26 +301,26 @@ namespace Tester.Winform
|
||||
var src = _twain.CurrentSource;
|
||||
_loadingCaps = true;
|
||||
|
||||
var test = src.SupportedCaps;
|
||||
//var test = src.SupportedCaps;
|
||||
|
||||
if (groupDepth.Enabled = src.ICapPixelType.IsSupported)
|
||||
if (groupDepth.Enabled = src.Capabilities.ICapPixelType.IsSupported)
|
||||
{
|
||||
LoadDepth(src.ICapPixelType);
|
||||
LoadDepth(src.Capabilities.ICapPixelType);
|
||||
}
|
||||
if (groupDPI.Enabled = src.ICapXResolution.IsSupported && src.ICapYResolution.IsSupported)
|
||||
if (groupDPI.Enabled = src.Capabilities.ICapXResolution.IsSupported && src.Capabilities.ICapYResolution.IsSupported)
|
||||
{
|
||||
LoadDPI(src.ICapXResolution);
|
||||
LoadDPI(src.Capabilities.ICapXResolution);
|
||||
}
|
||||
// TODO: find out if this is how duplex works or also needs the other option
|
||||
if (groupDuplex.Enabled = src.CapDuplexEnabled.IsSupported)
|
||||
if (groupDuplex.Enabled = src.Capabilities.CapDuplexEnabled.IsSupported)
|
||||
{
|
||||
LoadDuplex(src.CapDuplexEnabled);
|
||||
LoadDuplex(src.Capabilities.CapDuplexEnabled);
|
||||
}
|
||||
if (groupSize.Enabled = src.ICapSupportedSizes.IsSupported)
|
||||
if (groupSize.Enabled = src.Capabilities.ICapSupportedSizes.IsSupported)
|
||||
{
|
||||
LoadPaperSize(src.ICapSupportedSizes);
|
||||
LoadPaperSize(src.Capabilities.ICapSupportedSizes);
|
||||
}
|
||||
btnAllSettings.Enabled = src.CapEnableDSUIOnly.IsSupported;
|
||||
btnAllSettings.Enabled = src.Capabilities.CapEnableDSUIOnly.IsSupported;
|
||||
_loadingCaps = false;
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ namespace Tester.Winform
|
||||
if (!_loadingCaps && _twain.State == 4)
|
||||
{
|
||||
var sel = (SupportedSize)comboSize.SelectedItem;
|
||||
_twain.CurrentSource.ICapSupportedSizes.SetValue(sel);
|
||||
_twain.CurrentSource.Capabilities.ICapSupportedSizes.SetValue(sel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ namespace Tester.Winform
|
||||
if (!_loadingCaps && _twain.State == 4)
|
||||
{
|
||||
var sel = (PixelType)comboDepth.SelectedItem;
|
||||
_twain.CurrentSource.ICapPixelType.SetValue(sel);
|
||||
_twain.CurrentSource.Capabilities.ICapPixelType.SetValue(sel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,8 +398,8 @@ namespace Tester.Winform
|
||||
if (!_loadingCaps && _twain.State == 4)
|
||||
{
|
||||
var sel = (TWFix32)comboDPI.SelectedItem;
|
||||
_twain.CurrentSource.ICapXResolution.SetValue(sel);
|
||||
_twain.CurrentSource.ICapYResolution.SetValue(sel);
|
||||
_twain.CurrentSource.Capabilities.ICapXResolution.SetValue(sel);
|
||||
_twain.CurrentSource.Capabilities.ICapYResolution.SetValue(sel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ namespace Tester.Winform
|
||||
{
|
||||
if (!_loadingCaps && _twain.State == 4)
|
||||
{
|
||||
_twain.CurrentSource.CapDuplexEnabled.SetValue(ckDuplex.Checked ? BoolType.True : BoolType.False);
|
||||
_twain.CurrentSource.Capabilities.CapDuplexEnabled.SetValue(ckDuplex.Checked ? BoolType.True : BoolType.False);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user