Added workaround for sources that don't support querysupport call.

This commit is contained in:
soukoku
2015-02-13 21:34:12 -05:00
parent 0f4e258970
commit bace6e6323
17 changed files with 418 additions and 144 deletions

View File

@@ -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()

View File

@@ -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);
}

View File

@@ -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;