mirror of
https://github.com/soukoku/ntwain.git
synced 2025-10-24 18:29:04 +08:00
Added workaround for sources that don't support querysupport call.
This commit is contained in:
@@ -21,7 +21,7 @@ namespace Tester.WPF
|
||||
{
|
||||
_ds = ds;
|
||||
Cap = cap;
|
||||
Supports = ds.CapQuerySupport(cap);
|
||||
|
||||
|
||||
var capName = cap.ToString();
|
||||
var wrapProperty = ds.GetType().GetProperty(capName);
|
||||
@@ -33,6 +33,22 @@ namespace Tester.WPF
|
||||
_getCurrentMethod = wrapperType.GetMethod("GetCurrent");
|
||||
_setMethod = wrapperType.GetMethods().FirstOrDefault(m => m.Name == "Set");
|
||||
}
|
||||
|
||||
var supportTest = ds.CapQuerySupport(cap);
|
||||
if (supportTest.HasValue)
|
||||
{
|
||||
Supports = supportTest.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_wrapper != null)
|
||||
{
|
||||
var wrapperType = _wrapper.GetType();
|
||||
QuerySupports? supports = (QuerySupports?)wrapperType.GetProperty("SupportedActions").GetGetMethod().Invoke(_wrapper, null);
|
||||
Supports = supports.GetValueOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IEnumerable Get()
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Tester.WPF
|
||||
//rc = DGControl.Status.Get(dsId, ref stat);
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
foreach (var c in DS.SupportedCaps.Select(o => new CapVM(DS, o)))
|
||||
foreach (var c in DS.CapSupportedCaps.Get().Select(o => new CapVM(DS, o)))
|
||||
{
|
||||
Caps.Add(c);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace Tester.WPF
|
||||
_session.TransferReady += _session_TransferReady;
|
||||
_session.DataTransferred += _session_DataTransferred;
|
||||
_session.SourceDisabled += _session_SourceDisabled;
|
||||
_session.StateChanged += (s, e) => { RaisePropertyChanged(() => State); };
|
||||
}
|
||||
|
||||
TwainSession _session;
|
||||
|
||||
Reference in New Issue
Block a user