Test idea of wrapping source identity into .net class.

This commit is contained in:
soukoku 2014-05-19 20:48:21 -04:00
parent f17692184f
commit e879c00102
50 changed files with 511 additions and 693 deletions

View File

@ -271,8 +271,11 @@
<Compile Include="..\NTwain\TwainSession.cs">
<Link>TwainSession.cs</Link>
</Compile>
<Compile Include="..\NTwain\TwainSessionExtensions.cs">
<Link>TwainSessionExtensions.cs</Link>
<Compile Include="..\NTwain\TwainSource.Caps.cs">
<Link>TwainSource.Caps.cs</Link>
</Compile>
<Compile Include="..\NTwain\TwainSource.cs">
<Link>TwainSource.cs</Link>
</Compile>
<Compile Include="..\NTwain\TwainStateException.cs">
<Link>TwainStateException.cs</Link>

View File

@ -1,6 +1,7 @@
using NTwain.Internals;
using NTwain.Properties;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
@ -913,6 +914,48 @@ namespace NTwain.Data
Dispose(false);
}
#endregion
/// <summary>
/// A general method that returns the data in a <see cref="TWCapability" />.
/// </summary>
/// <param name="toPopulate">The list to populate if necessary.</param>
/// <returns></returns>
public IList<object> ReadMultiCapValues(IList<object> toPopulate)
{
if (toPopulate == null) { toPopulate = new List<object>(); }
var read = CapabilityReadOut.ReadValue(this);
switch (read.ContainerType)
{
case ContainerType.OneValue:
if (read.OneValue != null)
{
toPopulate.Add(read.OneValue);
}
break;
case ContainerType.Array:
case ContainerType.Enum:
if (read.CollectionValues != null)
{
foreach (var o in read.CollectionValues)
{
toPopulate.Add(o);
}
}
break;
case ContainerType.Range:
for (var i = read.RangeMinValue; i <= read.RangeMaxValue; i += read.RangeStepSize)
{
toPopulate.Add(i);
}
break;
}
return toPopulate;
}
}
/// <summary>

View File

@ -1,6 +1,7 @@
using NTwain.Data;
using NTwain.Triplets;
using System;
using System.Collections.Generic;
namespace NTwain
{
@ -42,38 +43,24 @@ namespace NTwain
/// <returns></returns>
ReturnCode CloseManager();
/// <summary>
/// Loads the specified source into main memory and causes its initialization.
/// Calls to this must be followed by
/// <see cref="CloseSource" /> when not using it anymore.
/// </summary>
/// <param name="sourceProductName">Name of the source.</param>
/// <returns></returns>
ReturnCode OpenSource(string sourceProductName);
/// <summary>
/// When an application is finished with a Source, it must formally close the session between them
/// using this operation. This is necessary in case the Source only supports connection with a single
/// application (many desktop scanners will behave this way). A Source such as this cannot be
/// accessed by other applications until its current session is terminated
/// </summary>
/// <returns></returns>
ReturnCode CloseSource();
/// <summary>
/// Enables the source to start transferring.
/// </summary>
/// <param name="mode">The mode.</param>
/// <param name="modal">if set to <c>true</c> any driver UI will display as modal.</param>
/// <param name="windowHandle">The window handle if modal.</param>
/// <returns></returns>
ReturnCode EnableSource(SourceEnableMode mode, bool modal, IntPtr windowHandle);
/// <summary>
/// Forces the stepping down of an opened source when things gets out of control.
/// Used when session state and source state become out of sync.
/// </summary>
/// <param name="targetState">State of the target.</param>
void ForceStepDown(int targetState);
/// <summary>
/// Gets list of sources available in the system.
/// </summary>
/// <returns></returns>
IList<TwainSource> GetSources();
/// <summary>
/// Gets the manager status. Only call this at state 2 or higher.
/// </summary>
/// <param name="session">The session.</param>
/// <returns></returns>
TWStatus GetStatus();
}
}

View File

@ -13,23 +13,17 @@ namespace NTwain
public interface ITwainSession : INotifyPropertyChanged, ITwainOperation
{
/// <summary>
/// Gets the source id used for the session.
/// Gets the currently open source.
/// </summary>
/// <value>The source id.</value>
TWIdentity SourceId { get; }
/// <value>
/// The current source.
/// </value>
TwainSource Source { get; }
/// <summary>
/// Gets the current state number as defined by the TWAIN spec.
/// </summary>
/// <value>The state.</value>
int State { get; }
/// <summary>
/// Gets the supported caps for the currently open source.
/// </summary>
/// <value>
/// The supported caps.
/// </value>
IList<CapabilityId> SupportedCaps { get; }
}
}

View File

@ -1,4 +1,5 @@
using NTwain.Data;
using System;
using System.Collections.Generic;
namespace NTwain.Internals
@ -34,12 +35,14 @@ namespace NTwain.Internals
/// <returns></returns>
ICommittable GetPendingStateChanger(int newState);
void ChangeSourceId(TWIdentity sourceId);
void ChangeSourceId(TwainSource source);
ReturnCode DisableSource();
void SafeSyncableRaiseEvent(DataTransferredEventArgs e);
void SafeSyncableRaiseEvent(TransferErrorEventArgs e);
void SafeSyncableRaiseEvent(TransferReadyEventArgs e);
ReturnCode EnableSource(SourceEnableMode mode, bool modal, IntPtr windowHandle);
}
}

View File

@ -70,7 +70,7 @@ namespace NTwain.Internals
if (xferGroup == DataGroups.None ||
(xferGroup & DataGroups.Image) == DataGroups.Image)
{
var mech = session.GetCurrentCap(CapabilityId.ICapXferMech).ConvertToEnum<XferMech>();
var mech = session.Source.GetCurrentCap(CapabilityId.ICapXferMech).ConvertToEnum<XferMech>();
switch (mech)
{
case XferMech.Memory:
@ -91,7 +91,7 @@ namespace NTwain.Internals
}
if ((xferGroup & DataGroups.Audio) == DataGroups.Audio)
{
var mech = session.GetCurrentCap(CapabilityId.ACapXferMech).ConvertToEnum<XferMech>();
var mech = session.Source.GetCurrentCap(CapabilityId.ACapXferMech).ConvertToEnum<XferMech>();
switch (mech)
{
case XferMech.File:
@ -136,7 +136,7 @@ namespace NTwain.Internals
}
else
{
session.SafeSyncableRaiseEvent(new TransferErrorEventArgs { ReturnCode = xrc, SourceStatus = session.GetSourceStatus() });
session.SafeSyncableRaiseEvent(new TransferErrorEventArgs { ReturnCode = xrc, SourceStatus = session.Source.GetStatus() });
}
}
catch (Exception ex)
@ -176,7 +176,7 @@ namespace NTwain.Internals
}
else
{
session.SafeSyncableRaiseEvent(new TransferErrorEventArgs { ReturnCode = xrc, SourceStatus = session.GetSourceStatus() });
session.SafeSyncableRaiseEvent(new TransferErrorEventArgs { ReturnCode = xrc, SourceStatus = session.Source.GetStatus() });
}
}
@ -202,7 +202,7 @@ namespace NTwain.Internals
}
else
{
session.SafeSyncableRaiseEvent(new TransferErrorEventArgs { ReturnCode = xrc, SourceStatus = session.GetSourceStatus() });
session.SafeSyncableRaiseEvent(new TransferErrorEventArgs { ReturnCode = xrc, SourceStatus = session.Source.GetStatus() });
}
}
catch (Exception ex)
@ -242,7 +242,7 @@ namespace NTwain.Internals
}
else
{
session.SafeSyncableRaiseEvent(new TransferErrorEventArgs { ReturnCode = xrc, SourceStatus = session.GetSourceStatus() });
session.SafeSyncableRaiseEvent(new TransferErrorEventArgs { ReturnCode = xrc, SourceStatus = session.Source.GetStatus() });
}
}
@ -305,7 +305,7 @@ namespace NTwain.Internals
}
else
{
session.SafeSyncableRaiseEvent(new TransferErrorEventArgs { ReturnCode = xrc, SourceStatus = session.GetSourceStatus() });
session.SafeSyncableRaiseEvent(new TransferErrorEventArgs { ReturnCode = xrc, SourceStatus = session.Source.GetStatus() });
}
}
}
@ -384,7 +384,7 @@ namespace NTwain.Internals
}
else
{
session.SafeSyncableRaiseEvent(new TransferErrorEventArgs { ReturnCode = xrc, SourceStatus = session.GetSourceStatus() });
session.SafeSyncableRaiseEvent(new TransferErrorEventArgs { ReturnCode = xrc, SourceStatus = session.Source.GetStatus() });
}
}
catch (Exception ex)
@ -415,7 +415,7 @@ namespace NTwain.Internals
{
TWImageInfo imgInfo;
TWExtImageInfo extInfo = null;
if (session.SupportedCaps.Contains(CapabilityId.ICapExtImageInfo))
if (session.Source.SupportedCaps.Contains(CapabilityId.ICapExtImageInfo))
{
if (session.DGImage.ExtImageInfo.Get(out extInfo) != ReturnCode.Success)
{

View File

@ -87,8 +87,9 @@
<Compile Include="Triplets\Dsm.Linux.cs" />
<Compile Include="Triplets\Dsm.WinOld.cs" />
<Compile Include="Triplets\Dsm.WinNew.cs" />
<Compile Include="TwainSessionExtensions.cs" />
<Compile Include="TwainSource.Caps.cs" />
<Compile Include="TwainSession.cs" />
<Compile Include="TwainSource.cs" />
<Compile Include="TwainStateException.cs" />
<Compile Include="Data\TwainTypes.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -19,7 +19,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(6, 6, DataGroups.Audio, DataArgumentType.AudioFileXfer, Message.Get);
IntPtr z = IntPtr.Zero;
return Dsm.DsmEntry(Session.AppId, Session.SourceId, DataGroups.Audio, DataArgumentType.AudioFileXfer, Message.Get, ref z);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, DataGroups.Audio, DataArgumentType.AudioFileXfer, Message.Get, ref z);
}
}
}

View File

@ -19,7 +19,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(6, 7, DataGroups.Audio, DataArgumentType.AudioInfo, Message.Get);
info = new TWAudioInfo();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, info);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Get, info);
}
}
}

View File

@ -22,7 +22,7 @@ namespace NTwain.Triplets
public ReturnCode Get(ref IntPtr handle)
{
Session.VerifyState(6, 6, DataGroups.Audio, DataArgumentType.AudioNativeXfer, Message.Get);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, DataGroups.Audio, DataArgumentType.AudioNativeXfer, Message.Get, ref handle);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, DataGroups.Audio, DataArgumentType.AudioNativeXfer, Message.Get, ref handle);
}
}
}

View File

@ -16,7 +16,7 @@ namespace NTwain.Triplets
public ReturnCode RegisterCallback(TWCallback callback)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Callback, Message.RegisterCallback);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.RegisterCallback, callback);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.RegisterCallback, callback);
}
}
}

View File

@ -16,7 +16,7 @@ namespace NTwain.Triplets
public ReturnCode RegisterCallback(TWCallback2 callback)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Callback, Message.RegisterCallback);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.RegisterCallback, callback);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.RegisterCallback, callback);
}
}
}

View File

@ -17,7 +17,7 @@ namespace NTwain.Triplets
public ReturnCode Get(TWCapability capability)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.Get);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, DataArgumentType.Capability, Message.Get, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, DataArgumentType.Capability, Message.Get, capability);
}
/// <summary>
@ -28,7 +28,7 @@ namespace NTwain.Triplets
public ReturnCode GetCurrent(TWCapability capability)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.GetCurrent);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, DataArgumentType.Capability, Message.GetCurrent, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, DataArgumentType.Capability, Message.GetCurrent, capability);
}
/// <summary>
@ -39,7 +39,7 @@ namespace NTwain.Triplets
public ReturnCode GetDefault(TWCapability capability)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.GetDefault);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, DataArgumentType.Capability, Message.GetDefault, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, DataArgumentType.Capability, Message.GetDefault, capability);
}
/// <summary>
@ -51,7 +51,7 @@ namespace NTwain.Triplets
public ReturnCode GetHelp(TWCapability capability)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.GetHelp);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, DataArgumentType.Capability, Message.GetHelp, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, DataArgumentType.Capability, Message.GetHelp, capability);
}
/// <summary>
@ -63,7 +63,7 @@ namespace NTwain.Triplets
public ReturnCode GetLabel(TWCapability capability)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.GetLabel);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, DataArgumentType.Capability, Message.GetLabel, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, DataArgumentType.Capability, Message.GetLabel, capability);
}
/// <summary>
@ -75,7 +75,7 @@ namespace NTwain.Triplets
public ReturnCode GetLabelEnum(TWCapability capability)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.GetLabelEnum);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, DataArgumentType.Capability, Message.GetLabelEnum, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, DataArgumentType.Capability, Message.GetLabelEnum, capability);
}
/// <summary>
@ -86,7 +86,7 @@ namespace NTwain.Triplets
public ReturnCode QuerySupport(TWCapability capability)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.QuerySupport);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, DataArgumentType.Capability, Message.QuerySupport, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, DataArgumentType.Capability, Message.QuerySupport, capability);
}
/// <summary>
@ -98,7 +98,7 @@ namespace NTwain.Triplets
public ReturnCode Reset(TWCapability capability)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.Reset);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, DataArgumentType.Capability, Message.Reset, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, DataArgumentType.Capability, Message.Reset, capability);
}
/// <summary>
@ -110,7 +110,7 @@ namespace NTwain.Triplets
public ReturnCode ResetAll(TWCapability capability)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.ResetAll);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, DataArgumentType.Capability, Message.ResetAll, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, DataArgumentType.Capability, Message.ResetAll, capability);
}
/// <summary>
@ -125,7 +125,7 @@ namespace NTwain.Triplets
public ReturnCode Set(TWCapability capability)
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.Capability, Message.Set);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, DataArgumentType.Capability, Message.Set, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, DataArgumentType.Capability, Message.Set, capability);
}
/// <summary>
@ -139,7 +139,7 @@ namespace NTwain.Triplets
public ReturnCode SetConstraint(TWCapability capability)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.SetConstraint);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, DataArgumentType.Capability, Message.SetConstraint, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, DataArgumentType.Capability, Message.SetConstraint, capability);
}
}
}

View File

@ -19,7 +19,7 @@ namespace NTwain.Triplets
public ReturnCode Get(ushort customDAT, TWCapability capability)
{
Session.VerifyState(4, 7, DataGroups.Control, (DataArgumentType)customDAT, Message.Get);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, (DataArgumentType)customDAT, Message.Get, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, (DataArgumentType)customDAT, Message.Get, capability);
}
/// <summary>
@ -31,7 +31,7 @@ namespace NTwain.Triplets
public ReturnCode GetCurrent(ushort customDAT, TWCapability capability)
{
Session.VerifyState(4, 7, DataGroups.Control, (DataArgumentType)customDAT, Message.GetCurrent);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, (DataArgumentType)customDAT, Message.GetCurrent, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, (DataArgumentType)customDAT, Message.GetCurrent, capability);
}
/// <summary>
@ -43,7 +43,7 @@ namespace NTwain.Triplets
public ReturnCode GetDefault(ushort customDAT, TWCapability capability)
{
Session.VerifyState(4, 7, DataGroups.Control, (DataArgumentType)customDAT, Message.GetDefault);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, (DataArgumentType)customDAT, Message.GetDefault, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, (DataArgumentType)customDAT, Message.GetDefault, capability);
}
/// <summary>
@ -56,7 +56,7 @@ namespace NTwain.Triplets
public ReturnCode GetHelp(ushort customDAT, TWCapability capability)
{
Session.VerifyState(4, 4, DataGroups.Control, (DataArgumentType)customDAT, Message.GetHelp);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, (DataArgumentType)customDAT, Message.GetHelp, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, (DataArgumentType)customDAT, Message.GetHelp, capability);
}
/// <summary>
@ -69,7 +69,7 @@ namespace NTwain.Triplets
public ReturnCode GetLabel(ushort customDAT, TWCapability capability)
{
Session.VerifyState(4, 4, DataGroups.Control, (DataArgumentType)customDAT, Message.GetLabel);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, (DataArgumentType)customDAT, Message.GetLabel, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, (DataArgumentType)customDAT, Message.GetLabel, capability);
}
/// <summary>
@ -82,7 +82,7 @@ namespace NTwain.Triplets
public ReturnCode GetLabelEnum(ushort customDAT, TWCapability capability)
{
Session.VerifyState(4, 4, DataGroups.Control, (DataArgumentType)customDAT, Message.GetLabelEnum);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, (DataArgumentType)customDAT, Message.GetLabelEnum, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, (DataArgumentType)customDAT, Message.GetLabelEnum, capability);
}
/// <summary>
@ -94,7 +94,7 @@ namespace NTwain.Triplets
public ReturnCode QuerySupport(ushort customDAT, TWCapability capability)
{
Session.VerifyState(4, 7, DataGroups.Control, (DataArgumentType)customDAT, Message.QuerySupport);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, (DataArgumentType)customDAT, Message.QuerySupport, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, (DataArgumentType)customDAT, Message.QuerySupport, capability);
}
/// <summary>
@ -107,7 +107,7 @@ namespace NTwain.Triplets
public ReturnCode Reset(ushort customDAT, TWCapability capability)
{
Session.VerifyState(4, 4, DataGroups.Control, (DataArgumentType)customDAT, Message.Reset);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, (DataArgumentType)customDAT, Message.Reset, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, (DataArgumentType)customDAT, Message.Reset, capability);
}
/// <summary>
@ -120,7 +120,7 @@ namespace NTwain.Triplets
public ReturnCode ResetAll(ushort customDAT, TWCapability capability)
{
Session.VerifyState(4, 4, DataGroups.Control, (DataArgumentType)customDAT, Message.ResetAll);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, (DataArgumentType)customDAT, Message.ResetAll, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, (DataArgumentType)customDAT, Message.ResetAll, capability);
}
/// <summary>
@ -136,7 +136,7 @@ namespace NTwain.Triplets
public ReturnCode Set(ushort customDAT, TWCapability capability)
{
Session.VerifyState(4, 6, DataGroups.Control, (DataArgumentType)customDAT, Message.Set);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, (DataArgumentType)customDAT, Message.Set, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, (DataArgumentType)customDAT, Message.Set, capability);
}
/// <summary>
@ -151,7 +151,7 @@ namespace NTwain.Triplets
public ReturnCode SetConstraint(ushort customDAT, TWCapability capability)
{
Session.VerifyState(4, 7, DataGroups.Control, (DataArgumentType)customDAT, Message.SetConstraint);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, (DataArgumentType)customDAT, Message.SetConstraint, capability);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, (DataArgumentType)customDAT, Message.SetConstraint, capability);
}
}
}

View File

@ -21,7 +21,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.CustomDSData, Message.Get);
customData = new TWCustomDSData();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, customData);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Get, customData);
}
/// <summary>
@ -34,7 +34,7 @@ namespace NTwain.Triplets
public ReturnCode Set(TWCustomDSData customData)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.CustomDSData, Message.Set);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Set, customData);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Set, customData);
}
}
}

View File

@ -14,7 +14,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.DeviceEvent, Message.Get);
sourceDeviceEvent = new TWDeviceEvent();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, sourceDeviceEvent);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Get, sourceDeviceEvent);
}
}
}

View File

@ -18,7 +18,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(3, 3, DataGroups.Control, DataArgumentType.EntryPoint, Message.Get);
entryPoint = new TWEntryPoint();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, entryPoint);
return Dsm.DsmEntry(Session.AppId, Message.Get, entryPoint);
}
}
}

View File

@ -22,7 +22,7 @@ namespace NTwain.Triplets
public ReturnCode ProcessEvent(TWEvent theEvent)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Event, Message.ProcessEvent);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.ProcessEvent, theEvent);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.ProcessEvent, theEvent);
}
}
}

View File

@ -21,7 +21,7 @@ namespace NTwain.Triplets
public ReturnCode AutomaticCaptureDirectory(TWFileSystem fileSystem)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.AutomaticCaptureDirectory);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.AutomaticCaptureDirectory, fileSystem);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.AutomaticCaptureDirectory, fileSystem);
}
/// <summary>
@ -36,7 +36,7 @@ namespace NTwain.Triplets
public ReturnCode ChangeDirectory(TWFileSystem fileSystem)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.ChangeDirectory);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.ChangeDirectory, fileSystem);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.ChangeDirectory, fileSystem);
}
/// <summary>
@ -52,7 +52,7 @@ namespace NTwain.Triplets
public ReturnCode Copy(TWFileSystem fileSystem)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.Copy);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Copy, fileSystem);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Copy, fileSystem);
}
/// <summary>
@ -64,7 +64,7 @@ namespace NTwain.Triplets
public ReturnCode CreateDirectory(TWFileSystem fileSystem)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.CreateDirectory);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.CreateDirectory, fileSystem);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.CreateDirectory, fileSystem);
}
/// <summary>
@ -77,7 +77,7 @@ namespace NTwain.Triplets
public ReturnCode Delete(TWFileSystem fileSystem)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.Delete);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Delete, fileSystem);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Delete, fileSystem);
}
/// <summary>
@ -89,7 +89,7 @@ namespace NTwain.Triplets
public ReturnCode FormatMedia(TWFileSystem fileSystem)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.FormatMedia);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.FormatMedia, fileSystem);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.FormatMedia, fileSystem);
}
/// <summary>
@ -102,7 +102,7 @@ namespace NTwain.Triplets
public ReturnCode GetClose(TWFileSystem fileSystem)
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.FileSystem, Message.GetClose);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.GetClose, fileSystem);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.GetClose, fileSystem);
}
/// <summary>
@ -114,7 +114,7 @@ namespace NTwain.Triplets
public ReturnCode GetFirstFile(TWFileSystem fileSystem)
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.FileSystem, Message.GetFirstFile);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.GetFirstFile, fileSystem);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.GetFirstFile, fileSystem);
}
/// <summary>
@ -127,7 +127,7 @@ namespace NTwain.Triplets
public ReturnCode GetInfo(TWFileSystem fileSystem)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.FileSystem, Message.GetInfo);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.GetInfo, fileSystem);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.GetInfo, fileSystem);
}
/// <summary>
@ -139,7 +139,7 @@ namespace NTwain.Triplets
public ReturnCode GetNextFile(TWFileSystem fileSystem)
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.FileSystem, Message.GetNextFile);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.GetNextFile, fileSystem);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.GetNextFile, fileSystem);
}
/// <summary>
@ -155,7 +155,7 @@ namespace NTwain.Triplets
public ReturnCode Rename(TWFileSystem fileSystem)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.Rename);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Rename, fileSystem);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Rename, fileSystem);
}
}
}

View File

@ -19,7 +19,7 @@ namespace NTwain.Triplets
internal ReturnCode CloseDS()
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Identity, Message.CloseDS);
var rc = Dsm.DsmEntry(Session.AppId, Message.CloseDS, Session.SourceId);
var rc = Dsm.DsmEntry(Session.AppId, Message.CloseDS, Session.Source.Identity);
if (rc == ReturnCode.Success)
{
Session.ChangeSourceId(null);
@ -75,10 +75,10 @@ namespace NTwain.Triplets
/// </summary>
/// <param name="source">The source.</param>
/// <returns></returns>
internal ReturnCode OpenDS(TWIdentity source)
internal ReturnCode OpenDS(TwainSource source)
{
Session.VerifyState(3, 3, DataGroups.Control, DataArgumentType.Identity, Message.OpenDS);
var rc = Dsm.DsmEntry(Session.AppId, Message.OpenDS, source);
var rc = Dsm.DsmEntry(Session.AppId, Message.OpenDS, source.Identity);
if (rc == ReturnCode.Success)
{
Session.ChangeSourceId(source);

View File

@ -18,7 +18,7 @@ namespace NTwain.Triplets
public ReturnCode PassThrough(TWPassThru sourcePassThru)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.PassThru, Message.PassThru);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.PassThru, sourcePassThru);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.PassThru, sourcePassThru);
}
}
}

View File

@ -20,7 +20,7 @@ namespace NTwain.Triplets
internal ReturnCode EndXfer(TWPendingXfers pendingXfers)
{
Session.VerifyState(6, 7, DataGroups.Control, DataArgumentType.PendingXfers, Message.EndXfer);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.EndXfer, pendingXfers);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.EndXfer, pendingXfers);
}
/// <summary>
@ -34,7 +34,7 @@ namespace NTwain.Triplets
public ReturnCode Get(TWPendingXfers pendingXfers)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.PendingXfers, Message.Get);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, pendingXfers);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Get, pendingXfers);
}
/// <summary>
@ -45,7 +45,7 @@ namespace NTwain.Triplets
internal ReturnCode Reset(TWPendingXfers pendingXfers)
{
Session.VerifyState(6, 6, DataGroups.Control, DataArgumentType.PendingXfers, Message.Reset);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Reset, pendingXfers);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Reset, pendingXfers);
}
/// <summary>
@ -57,7 +57,7 @@ namespace NTwain.Triplets
public ReturnCode StopFeeder(TWPendingXfers pendingXfers)
{
Session.VerifyState(6, 6, DataGroups.Control, DataArgumentType.PendingXfers, Message.StopFeeder);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.StopFeeder, pendingXfers);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.StopFeeder, pendingXfers);
}
}
}

View File

@ -21,7 +21,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.SetupFileXfer, Message.Get);
setupFileXfer = new TWSetupFileXfer();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, setupFileXfer);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Get, setupFileXfer);
}
/// <summary>
@ -34,7 +34,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.SetupFileXfer, Message.GetDefault);
setupFileXfer = new TWSetupFileXfer();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.GetDefault, setupFileXfer);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.GetDefault, setupFileXfer);
}
/// <summary>
@ -48,7 +48,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.SetupFileXfer, Message.Reset);
setupFileXfer = new TWSetupFileXfer();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Reset, setupFileXfer);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Reset, setupFileXfer);
}
/// <summary>
@ -63,7 +63,7 @@ namespace NTwain.Triplets
public ReturnCode Set(TWSetupFileXfer setupFileXfer)
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.SetupFileXfer, Message.Set);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Set, setupFileXfer);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Set, setupFileXfer);
}
}

View File

@ -21,7 +21,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.SetupMemXfer, Message.Get);
setupMemXfer = new TWSetupMemXfer();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, setupMemXfer);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Get, setupMemXfer);
}
}
}

View File

@ -32,7 +32,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Status, Message.Get);
status = new TWStatus();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, status);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Get, status);
}
}
}

View File

@ -22,7 +22,7 @@ namespace NTwain.Triplets
public ReturnCode DisableDS(TWUserInterface userInterface)
{
Session.VerifyState(5, 5, DataGroups.Control, DataArgumentType.UserInterface, Message.DisableDS);
var rc = Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.DisableDS, userInterface);
var rc = Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.DisableDS, userInterface);
if (rc == ReturnCode.Success)
{
Session.ChangeState(4, true);
@ -40,7 +40,7 @@ namespace NTwain.Triplets
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.UserInterface, Message.EnableDS);
using (var pending = Session.GetPendingStateChanger(5))
{
var rc = Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.EnableDS, userInterface);
var rc = Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.EnableDS, userInterface);
if (rc == ReturnCode.Success ||
(!userInterface.ShowUI && rc == ReturnCode.CheckStatus))
{
@ -62,7 +62,7 @@ namespace NTwain.Triplets
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.UserInterface, Message.EnableDSUIOnly);
using (var pending = Session.GetPendingStateChanger(5))
{
var rc = Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.EnableDSUIOnly, userInterface);
var rc = Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.EnableDSUIOnly, userInterface);
if (rc == ReturnCode.Success)
{
pending.Commit();

View File

@ -20,7 +20,7 @@ namespace NTwain.Triplets
public ReturnCode Get(ref DataGroups value)
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.XferGroup, Message.Get);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, DataGroups.Control, DataArgumentType.XferGroup, Message.Get, ref value);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, DataGroups.Control, DataArgumentType.XferGroup, Message.Get, ref value);
}
/// <summary>
@ -33,7 +33,7 @@ namespace NTwain.Triplets
public ReturnCode Set(DataGroups value)
{
Session.VerifyState(6, 6, DataGroups.Control, DataArgumentType.XferGroup, Message.Set);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, DataGroups.Control, DataArgumentType.XferGroup, Message.Set, ref value);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, DataGroups.Control, DataArgumentType.XferGroup, Message.Set, ref value);
}
}
}

View File

@ -35,7 +35,7 @@ namespace NTwain.Triplets
ref IntPtr data)
{
_session.VerifyState(3, 7, group, dat, message);
return Dsm.DsmEntry(_session.AppId, _session.SourceId, group, dat, message, ref data);
return Dsm.DsmEntry(_session.AppId, _session.Source.Identity, group, dat, message, ref data);
}
// todo: add other data value types?

View File

@ -21,7 +21,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.CieColor, Message.Get);
cieColor = new TWCieColor();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, cieColor);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Get, cieColor);
}
}
}

View File

@ -15,7 +15,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(7, 7, DataGroups.Image, DataArgumentType.ExtImageInfo, Message.Get);
info = new TWExtImageInfo();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, info);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Get, info);
}
}
}

View File

@ -22,7 +22,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.Filter, Message.Get);
filter = new TWFilter();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, filter);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Get, filter);
}
/// <summary>
@ -35,7 +35,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.Filter, Message.GetDefault);
filter = new TWFilter();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.GetDefault, filter);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.GetDefault, filter);
}
/// <summary>
@ -47,7 +47,7 @@ namespace NTwain.Triplets
public ReturnCode Set(TWFilter filter)
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.Filter, Message.Set);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Set, filter);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Set, filter);
}
/// <summary>
@ -60,7 +60,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.Filter, Message.Reset);
filter = new TWFilter();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Reset, filter);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Reset, filter);
}
}
}

View File

@ -21,7 +21,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.GrayResponse, Message.Reset);
response = new TWGrayResponse();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Reset, response);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Reset, response);
}
/// <summary>
@ -33,7 +33,7 @@ namespace NTwain.Triplets
public ReturnCode Set(TWGrayResponse response)
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.GrayResponse, Message.Set);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Set, response);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Set, response);
}
}
}

View File

@ -21,7 +21,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(6, 7, DataGroups.Image, DataArgumentType.IccProfile, Message.Get);
profile = new TWMemory();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, DataArgumentType.IccProfile, Message.Get, ref profile);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, DataArgumentType.IccProfile, Message.Get, ref profile);
}
}
}

View File

@ -20,7 +20,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(6, 6, DataGroups.Image, DataArgumentType.ImageFileXfer, Message.Get);
IntPtr z = IntPtr.Zero;
return Dsm.DsmEntry(Session.AppId, Session.SourceId, DataGroups.Image, DataArgumentType.ImageFileXfer, Message.Get, ref z);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, DataGroups.Image, DataArgumentType.ImageFileXfer, Message.Get, ref z);
}
}
}

View File

@ -15,7 +15,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(6, 7, DataGroups.Image, DataArgumentType.ImageInfo, Message.Get);
info = new TWImageInfo();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, info);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Get, info);
}
}
}

View File

@ -15,7 +15,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.ImageLayout, Message.Get);
layout = new TWImageLayout();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, layout);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Get, layout);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
@ -23,7 +23,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.ImageLayout, Message.GetDefault);
layout = new TWImageLayout();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.GetDefault, layout);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.GetDefault, layout);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
@ -31,13 +31,13 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.ImageLayout, Message.Reset);
layout = new TWImageLayout();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Reset, layout);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Reset, layout);
}
public ReturnCode Set(TWImageLayout layout)
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.ImageLayout, Message.Set);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Set, layout);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Set, layout);
}
}
}

View File

@ -16,7 +16,7 @@ namespace NTwain.Triplets
public ReturnCode Get(TWImageMemXfer xfer)
{
Session.VerifyState(6, 6, DataGroups.Image, DataArgumentType.ImageMemFileXfer, Message.Get);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, xfer);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Get, xfer);
}
}

View File

@ -16,7 +16,7 @@ namespace NTwain.Triplets
public ReturnCode Get(TWImageMemXfer xfer)
{
Session.VerifyState(6, 7, DataGroups.Image, DataArgumentType.ImageMemXfer, Message.Get);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, xfer);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Get, xfer);
}
}
}

View File

@ -20,7 +20,7 @@ namespace NTwain.Triplets
public ReturnCode Get(ref IntPtr handle)
{
Session.VerifyState(6, 6, DataGroups.Image, DataArgumentType.ImageNativeXfer, Message.Get);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, DataGroups.Image, DataArgumentType.ImageNativeXfer, Message.Get, ref handle);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, DataGroups.Image, DataArgumentType.ImageNativeXfer, Message.Get, ref handle);
}
}
}

View File

@ -21,7 +21,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.JpegCompression, Message.Get);
compression = new TWJpegCompression();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, compression);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Get, compression);
}
/// <summary>
@ -35,7 +35,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.JpegCompression, Message.GetDefault);
compression = new TWJpegCompression();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.GetDefault, compression);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.GetDefault, compression);
}
/// <summary>
@ -48,7 +48,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.JpegCompression, Message.Reset);
compression = new TWJpegCompression();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Reset, compression);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Reset, compression);
}
/// <summary>
@ -61,7 +61,7 @@ namespace NTwain.Triplets
public ReturnCode Set(TWJpegCompression compression)
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.JpegCompression, Message.Set);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Set, compression);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Set, compression);
}
}
}

View File

@ -20,7 +20,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.Palette8, Message.Get);
palette = new TWPalette8();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, palette);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Get, palette);
}
/// <summary>
@ -33,7 +33,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.Palette8, Message.GetDefault);
palette = new TWPalette8();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.GetDefault, palette);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.GetDefault, palette);
}
/// <summary>
@ -47,7 +47,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.Palette8, Message.Reset);
palette = new TWPalette8();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Reset, palette);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Reset, palette);
}
/// <summary>
@ -61,7 +61,7 @@ namespace NTwain.Triplets
public ReturnCode Set(TWPalette8 palette)
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.Palette8, Message.Set);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Set, palette);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Set, palette);
}
}
}

View File

@ -22,7 +22,7 @@ namespace NTwain.Triplets
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.RgbResponse, Message.Reset);
response = new TWRgbResponse();
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Reset, response);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Reset, response);
}
/// <summary>
@ -34,7 +34,7 @@ namespace NTwain.Triplets
public ReturnCode Set(TWRgbResponse response)
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.RgbResponse, Message.Set);
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Set, response);
return Dsm.DsmEntry(Session.AppId, Session.Source.Identity, Message.Set, response);
}
}
}

View File

@ -169,18 +169,17 @@ namespace NTwain.Triplets
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWEntryPoint data)
{
if (Platform.IsWin)
{
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); }
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, null, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); }
else { return NativeMethods.DsmWinOld(origin, null, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); }
}
else if (Platform.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data);
return NativeMethods.DsmLinux(origin, null, DataGroups.Control, DataArgumentType.EntryPoint, msg, data);
}
throw new PlatformNotSupportedException();
}

View File

@ -8,6 +8,7 @@ using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
@ -18,6 +19,16 @@ namespace NTwain
/// </summary>
public class TwainSession : ITwainSessionInternal
{
/// <summary>
/// Initializes a new instance of the <see cref="TwainSession"/> class.
/// </summary>
/// <param name="supportedGroups">The supported groups.</param>
public TwainSession(DataGroups supportedGroups)
: this(TWIdentity.CreateFromAssembly(supportedGroups, Assembly.GetEntryAssembly()))
{
}
/// <summary>
/// Initializes a new instance of the <see cref="TwainSession" /> class.
/// </summary>
@ -81,9 +92,9 @@ namespace NTwain
return new TentativeStateCommitable(this, newState);
}
void ITwainSessionInternal.ChangeSourceId(TWIdentity sourceId)
void ITwainSessionInternal.ChangeSourceId(TwainSource source)
{
SourceId = sourceId;
Source = source;
OnPropertyChanged("SourceId");
SafeAsyncSyncableRaiseOnEvent(OnSourceChanged, SourceChanged);
}
@ -106,12 +117,12 @@ namespace NTwain
#region ITwainSession Members
/// <summary>
/// Gets the source id used for the session.
/// Gets the currently open source.
/// </summary>
/// <value>
/// The source id.
/// The current source.
/// </value>
public TWIdentity SourceId { get; private set; }
public TwainSource Source { get; private set; }
int _state;
/// <summary>
@ -135,30 +146,41 @@ namespace NTwain
}
static readonly CapabilityId[] _emptyCapList = new CapabilityId[0];
private IList<CapabilityId> _supportedCaps;
/// <summary>
/// Gets the supported caps for the currently open source.
/// Gets list of sources available in the system.
/// Only call this at state 2 or higher.
/// </summary>
/// <value>
/// The supported caps.
/// </value>
public IList<CapabilityId> SupportedCaps
/// <param name="session">The session.</param>
/// <returns></returns>
public IList<TwainSource> GetSources()
{
get
List<TwainSource> list = new List<TwainSource>();
// now enumerate
TWIdentity srcId;
var rc = DGControl.Identity.GetFirst(out srcId);
if (rc == ReturnCode.Success) { list.Add(new TwainSource(this, srcId)); }
do
{
if (_supportedCaps == null && State > 3)
rc = DGControl.Identity.GetNext(out srcId);
if (rc == ReturnCode.Success)
{
_supportedCaps = this.GetCapabilities();
list.Add(new TwainSource(this, srcId));
}
return _supportedCaps ?? _emptyCapList;
}
private set
{
_supportedCaps = value;
OnPropertyChanged("SupportedCaps");
}
} while (rc == ReturnCode.Success);
return list;
}
/// <summary>
/// Gets the manager status. Only call this at state 2 or higher.
/// </summary>
/// <param name="session">The session.</param>
/// <returns></returns>
public TWStatus GetStatus()
{
TWStatus stat;
DGControl.Status.GetManager(out stat);
return stat;
}
#endregion
@ -315,55 +337,6 @@ namespace NTwain
return rc;
}
/// <summary>
/// Loads the specified source into main memory and causes its initialization.
/// Calls to this must be followed by
/// <see cref="CloseSource" /> when not using it anymore.
/// </summary>
/// <param name="sourceProductName">Name of the source.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentException">sourceProductName</exception>
public ReturnCode OpenSource(string sourceProductName)
{
if (string.IsNullOrEmpty(sourceProductName)) { throw new ArgumentException(Resources.SourceRequired, "sourceProductName"); }
var rc = ReturnCode.Failure;
MessageLoop.Instance.Invoke(() =>
{
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: OpenSource.", Thread.CurrentThread.ManagedThreadId));
var source = new TWIdentity
{
ProductName = sourceProductName
};
rc = DGControl.Identity.OpenDS(source);
});
return rc;
}
/// <summary>
/// When an application is finished with a Source, it must formally close the session between them
/// using this operation. This is necessary in case the Source only supports connection with a single
/// application (many desktop scanners will behave this way). A Source such as this cannot be
/// accessed by other applications until its current session is terminated
/// </summary>
/// <returns></returns>
public ReturnCode CloseSource()
{
var rc = ReturnCode.Failure;
MessageLoop.Instance.Invoke(() =>
{
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: CloseSource.", Thread.CurrentThread.ManagedThreadId));
rc = DGControl.Identity.CloseDS();
if (rc == ReturnCode.Success)
{
SupportedCaps = null;
}
});
return rc;
}
/// <summary>
/// Enables the source to start transferring.
@ -372,7 +345,7 @@ namespace NTwain
/// <param name="modal">if set to <c>true</c> any driver UI will display as modal.</param>
/// <param name="windowHandle">The window handle if modal.</param>
/// <returns></returns>
public ReturnCode EnableSource(SourceEnableMode mode, bool modal, IntPtr windowHandle)
ReturnCode ITwainSessionInternal.EnableSource(SourceEnableMode mode, bool modal, IntPtr windowHandle)
{
var rc = ReturnCode.Failure;
@ -488,7 +461,7 @@ namespace NTwain
}
if (targetState < 4)
{
CloseSource();
Source.Close();
}
if (targetState < 3)
{
@ -507,7 +480,7 @@ namespace NTwain
/// </summary>
public event EventHandler StateChanged;
/// <summary>
/// Occurs when <see cref="SourceId"/> has changed.
/// Occurs when <see cref="Source"/> has changed.
/// </summary>
public event EventHandler SourceChanged;
/// <summary>
@ -608,7 +581,7 @@ namespace NTwain
protected virtual void OnStateChanged() { }
/// <summary>
/// Called when <see cref="SourceId"/> changed.
/// Called when <see cref="Source"/> changed.
/// </summary>
protected virtual void OnSourceChanged() { }
@ -676,7 +649,7 @@ namespace NTwain
ReturnCode HandleCallback(TWIdentity origin, TWIdentity destination, DataGroups dg, DataArgumentType dat, Message msg, IntPtr data)
{
if (origin != null && SourceId != null && origin.Id == SourceId.Id && _state >= 5)
if (origin != null && Source != null && origin.Id == Source.Identity.Id && _state >= 5)
{
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: CallbackHandler at state {1} with MSG={2}.", Thread.CurrentThread.ManagedThreadId, State, msg));
// spec says we must handle this on the thread that enabled the DS.

View File

@ -2,86 +2,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NTwain
{
/// <summary>
/// Defines useful methods on <see cref="TwainSession"/> without having to dive into
/// the raw TWAIN triplet API.
/// </summary>
public static class TwainSessionExtensions
partial class TwainSource
{
/// <summary>
/// Gets the manager status. Only call this at state 2 or higher.
/// </summary>
/// <param name="session">The session.</param>
/// <returns></returns>
public static TWStatus GetManagerStatus(this ITwainOperation session)
{
if (session == null) { throw new ArgumentNullException("session"); }
TWStatus stat;
session.DGControl.Status.GetManager(out stat);
return stat;
}
/// <summary>
/// Gets the source status. Only call this at state 4 or higher.
/// </summary>
/// <param name="session">The session.</param>
/// <returns></returns>
public static TWStatus GetSourceStatus(this ITwainOperation session)
{
if (session == null) { throw new ArgumentNullException("session"); }
TWStatus stat;
session.DGControl.Status.GetSource(out stat);
return stat;
}
/// <summary>
/// Gets list of sources available in the system.
/// Only call this at state 2 or higher.
/// </summary>
/// <param name="session">The session.</param>
/// <returns></returns>
public static IList<TWIdentity> GetSources(this ITwainOperation session)
{
if (session == null) { throw new ArgumentNullException("session"); }
List<TWIdentity> list = new List<TWIdentity>();
// now enumerate
TWIdentity srcId;
var rc = session.DGControl.Identity.GetFirst(out srcId);
if (rc == ReturnCode.Success) { list.Add(srcId); }
do
{
rc = session.DGControl.Identity.GetNext(out srcId);
if (rc == ReturnCode.Success)
{
list.Add(srcId);
}
} while (rc == ReturnCode.Success);
return list;
}
#region caps routines
/// <summary>
/// Gets the actual supported operations for a capability.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="capId">The cap identifier.</param>
/// <returns></returns>
public static QuerySupport GetCapabilitySupport(this ITwainOperation session, CapabilityId capId)
public QuerySupport GetCapabilitySupport(CapabilityId capId)
{
if (session == null) { throw new ArgumentNullException("session"); }
QuerySupport retVal = QuerySupport.None;
using (TWCapability cap = new TWCapability(capId))
{
var rc = session.DGControl.Capability.QuerySupport(cap);
var rc = _session.DGControl.Capability.QuerySupport(cap);
if (rc == ReturnCode.Success)
{
var read = CapabilityReadOut.ReadValue(cap);
@ -98,16 +35,13 @@ namespace NTwain
/// <summary>
/// Gets the current value for a capability.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="capId">The cap id.</param>
/// <returns></returns>
public static object GetCurrentCap(this ITwainOperation session, CapabilityId capId)
public object GetCurrentCap(CapabilityId capId)
{
if (session == null) { throw new ArgumentNullException("session"); }
using (TWCapability cap = new TWCapability(capId))
{
var rc = session.DGControl.Capability.GetCurrent(cap);
var rc = _session.DGControl.Capability.GetCurrent(cap);
if (rc == ReturnCode.Success)
{
var read = CapabilityReadOut.ReadValue(cap);
@ -137,62 +71,18 @@ namespace NTwain
return null;
}
/// <summary>
/// A general method that returns the data in a <see cref="TWCapability" />.
/// </summary>
/// <param name="capability">The capability returned from the source.</param>
/// <param name="toPopulate">The list to populate if necessary.</param>
/// <returns></returns>
public static IList<object> ReadMultiCapValues(this TWCapability capability, IList<object> toPopulate)
{
if (capability == null) { throw new ArgumentNullException("capability"); }
if (toPopulate == null) { toPopulate = new List<object>(); }
var read = CapabilityReadOut.ReadValue(capability);
switch (read.ContainerType)
{
case ContainerType.OneValue:
if (read.OneValue != null)
{
toPopulate.Add(read.OneValue);
}
break;
case ContainerType.Array:
case ContainerType.Enum:
if (read.CollectionValues != null)
{
foreach (var o in read.CollectionValues)
{
toPopulate.Add(o);
}
}
break;
case ContainerType.Range:
for (var i = read.RangeMinValue; i <= read.RangeMaxValue; i += read.RangeStepSize)
{
toPopulate.Add(i);
}
break;
}
return toPopulate;
}
/// <summary>
/// A general method that tries to get capability values from current <see cref="TwainSession" />.
/// A general method that tries to get capability values from current <see cref="TwainSource" />.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="capabilityId">The capability unique identifier.</param>
/// <returns></returns>
public static IList<object> GetCapabilityValues(this ITwainOperation session, CapabilityId capabilityId)
public IList<object> GetCapabilityValues(CapabilityId capabilityId)
{
if (session == null) { throw new ArgumentNullException("session"); }
var list = new List<object>();
using (TWCapability cap = new TWCapability(capabilityId))
{
var rc = session.DGControl.Capability.Get(cap);
var rc = _session.DGControl.Capability.Get(cap);
if (rc == ReturnCode.Success)
{
cap.ReadMultiCapValues(list);
@ -201,32 +91,18 @@ namespace NTwain
return list;
}
/// <summary>
/// Gets list of capabilities supported by current source.
/// Only call this at state 4 or higher.
/// </summary>
/// <param name="session">The session.</param>
/// <returns></returns>
internal static IList<CapabilityId> GetCapabilities(this ITwainOperation session)
{
if (session == null) { throw new ArgumentNullException("session"); }
return session.GetCapabilityValues(CapabilityId.CapSupportedCaps).CastToEnum<CapabilityId>(false);
}
#region xfer mech
/// <summary>
/// Gets the supported image <see cref="XferMech"/> for the current source.
/// Only call this at state 4 or higher.
/// </summary>
/// <param name="session">The session.</param>
/// <returns></returns>
public static IList<XferMech> CapGetImageXferMech(this ITwainOperation session)
public IList<XferMech> CapGetImageXferMech()
{
if (session == null) { throw new ArgumentNullException("session"); }
return session.GetCapabilityValues(CapabilityId.ICapXferMech).CastToEnum<XferMech>(true);
return GetCapabilityValues(CapabilityId.ICapXferMech).CastToEnum<XferMech>(true);
}
#endregion
@ -237,28 +113,22 @@ namespace NTwain
/// Gets the supported <see cref="CompressionType"/> for the current source.
/// Only call this at state 4 or higher.
/// </summary>
/// <param name="session">The session.</param>
/// <returns></returns>
public static IList<CompressionType> CapGetCompression(this ITwainOperation session)
public IList<CompressionType> CapGetCompression()
{
if (session == null) { throw new ArgumentNullException("session"); }
return session.GetCapabilityValues(CapabilityId.ICapCompression).CastToEnum<CompressionType>(true);
return GetCapabilityValues(CapabilityId.ICapCompression).CastToEnum<CompressionType>(true);
}
/// <summary>
/// Change the image compression for the current source.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="compression">The compression.</param>
/// <returns></returns>
public static ReturnCode CapSetImageCompression(this ITwainOperation session, CompressionType compression)
public ReturnCode CapSetImageCompression(CompressionType compression)
{
if (session == null) { throw new ArgumentNullException("session"); }
using (TWCapability compressCap = new TWCapability(CapabilityId.ICapCompression, new TWOneValue { Item = (uint)compression, ItemType = ItemType.UInt16 }))
{
return session.DGControl.Capability.Set(compressCap);
return _session.DGControl.Capability.Set(compressCap);
}
}
@ -270,28 +140,22 @@ namespace NTwain
/// Gets the supported <see cref="FileFormat"/> for the current source.
/// Only call this at state 4 or higher.
/// </summary>
/// <param name="session">The session.</param>
/// <returns></returns>
public static IList<FileFormat> CapGetImageFileFormat(this ITwainOperation session)
public IList<FileFormat> CapGetImageFileFormat()
{
if (session == null) { throw new ArgumentNullException("session"); }
return session.GetCapabilityValues(CapabilityId.ICapImageFileFormat).CastToEnum<FileFormat>(true);
return GetCapabilityValues(CapabilityId.ICapImageFileFormat).CastToEnum<FileFormat>(true);
}
/// <summary>
/// Change the image format for the current source.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="format">The format.</param>
/// <returns></returns>
public static ReturnCode CapSetImageFormat(this ITwainOperation session, FileFormat format)
public ReturnCode CapSetImageFormat(FileFormat format)
{
if (session == null) { throw new ArgumentNullException("session"); }
using (TWCapability formatCap = new TWCapability(CapabilityId.ICapImageFileFormat, new TWOneValue { Item = (uint)format, ItemType = ItemType.UInt16 }))
{
return session.DGControl.Capability.Set(formatCap);
return _session.DGControl.Capability.Set(formatCap);
}
}
@ -303,31 +167,25 @@ namespace NTwain
/// Gets the supported <see cref="PixelType"/> for the current source.
/// Only call this at state 4 or higher.
/// </summary>
/// <param name="session">The session.</param>
/// <returns></returns>
public static IList<PixelType> CapGetPixelTypes(this ITwainOperation session)
public IList<PixelType> CapGetPixelTypes()
{
if (session == null) { throw new ArgumentNullException("session"); }
return session.GetCapabilityValues(CapabilityId.ICapPixelType).CastToEnum<PixelType>(true);
return GetCapabilityValues(CapabilityId.ICapPixelType).CastToEnum<PixelType>(true);
}
/// <summary>
/// Change the pixel type for the current source.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="type">The type.</param>
/// <returns></returns>
public static ReturnCode CapSetPixelType(this ITwainOperation session, PixelType type)
public ReturnCode CapSetPixelType(PixelType type)
{
if (session == null) { throw new ArgumentNullException("session"); }
var one = new TWOneValue();
one.Item = (uint)type;
one.ItemType = ItemType.UInt16;
using (TWCapability dx = new TWCapability(CapabilityId.ICapPixelType, one))
{
return session.DGControl.Capability.Set(dx);
return _session.DGControl.Capability.Set(dx);
}
}
@ -339,63 +197,51 @@ namespace NTwain
/// Gets the supported image <see cref="XferMech"/> for the current source.
/// Only call this at state 4 or higher.
/// </summary>
/// <param name="session">The session.</param>
/// <returns></returns>
public static IList<XferMech> CapGetImageXferMechs(this ITwainOperation session)
public IList<XferMech> CapGetImageXferMechs()
{
if (session == null) { throw new ArgumentNullException("session"); }
return session.GetCapabilityValues(CapabilityId.ICapXferMech).CastToEnum<XferMech>(true);
return GetCapabilityValues(CapabilityId.ICapXferMech).CastToEnum<XferMech>(true);
}
/// <summary>
/// Gets the supported audio <see cref="XferMech"/> for the current source.
/// Only call this at state 4 or higher.
/// </summary>
/// <param name="session">The session.</param>
/// <returns></returns>
public static IList<XferMech> CapGetAudioXferMechs(this ITwainOperation session)
public IList<XferMech> CapGetAudioXferMechs()
{
if (session == null) { throw new ArgumentNullException("session"); }
return session.GetCapabilityValues(CapabilityId.ACapXferMech).CastToEnum<XferMech>(true);
return GetCapabilityValues(CapabilityId.ACapXferMech).CastToEnum<XferMech>(true);
}
/// <summary>
/// Change the image xfer type for the current source.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="type">The type.</param>
/// <returns></returns>
public static ReturnCode CapSetImageXferMech(this ITwainOperation session, XferMech type)
public ReturnCode CapSetImageXferMech(XferMech type)
{
if (session == null) { throw new ArgumentNullException("session"); }
var one = new TWOneValue();
one.Item = (uint)type;
one.ItemType = ItemType.UInt16;
using (TWCapability dx = new TWCapability(CapabilityId.ICapXferMech, one))
{
return session.DGControl.Capability.Set(dx);
return _session.DGControl.Capability.Set(dx);
}
}
/// <summary>
/// Change the audio xfer type for the current source.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="type">The type.</param>
/// <returns></returns>
public static ReturnCode CapSetAudioXferMech(this ITwainOperation session, XferMech type)
public ReturnCode CapSetAudioXferMech(XferMech type)
{
if (session == null) { throw new ArgumentNullException("session"); }
var one = new TWOneValue();
one.Item = (uint)type;
one.ItemType = ItemType.UInt16;
using (TWCapability dx = new TWCapability(CapabilityId.ACapXferMech, one))
{
return session.DGControl.Capability.Set(dx);
return _session.DGControl.Capability.Set(dx);
}
}
@ -407,53 +253,44 @@ namespace NTwain
/// Gets the supported DPI values for the current source.
/// Only call this at state 4 or higher.
/// </summary>
/// <param name="session">The session.</param>
/// <returns></returns>
public static IList<TWFix32> CapGetDPIs(this ITwainOperation session)
public IList<TWFix32> CapGetDPIs()
{
if (session == null) { throw new ArgumentNullException("session"); }
var list = session.GetCapabilityValues(CapabilityId.ICapXResolution);
var list = GetCapabilityValues(CapabilityId.ICapXResolution);
return list.Select(o => o.ConvertToFix32()).ToList();
}
/// <summary>
/// Change the DPI value for the current source.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="dpi">The DPI.</param>
/// <returns></returns>
public static ReturnCode CapSetDPI(this ITwainOperation session, TWFix32 dpi)
public ReturnCode CapSetDPI(TWFix32 dpi)
{
if (session == null) { throw new ArgumentNullException("session"); }
return CapSetDPI(session, dpi, dpi);
return CapSetDPI(dpi, dpi);
}
/// <summary>
/// Change the DPI value for the current source.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="xDPI">The x DPI.</param>
/// <param name="yDPI">The y DPI.</param>
/// <returns></returns>
public static ReturnCode CapSetDPI(this ITwainOperation session, TWFix32 xDPI, TWFix32 yDPI)
public ReturnCode CapSetDPI(TWFix32 xDPI, TWFix32 yDPI)
{
if (session == null) { throw new ArgumentNullException("session"); }
TWOneValue one = new TWOneValue();
one.Item = (uint)xDPI;// ((uint)dpi) << 16;
one.ItemType = ItemType.Fix32;
using (TWCapability xres = new TWCapability(CapabilityId.ICapXResolution, one))
{
var rc = session.DGControl.Capability.Set(xres);
var rc = _session.DGControl.Capability.Set(xres);
if (rc == ReturnCode.Success)
{
one.Item = (uint)yDPI;
using (TWCapability yres = new TWCapability(CapabilityId.ICapYResolution, one))
{
rc = session.DGControl.Capability.Set(yres);
rc = _session.DGControl.Capability.Set(yres);
}
}
return rc;
@ -468,32 +305,26 @@ namespace NTwain
/// Gets the supported <see cref="SupportedSize"/> for the current source.
/// Only call this at state 4 or higher.
/// </summary>
/// <param name="session">The session.</param>
/// <returns></returns>
public static IList<SupportedSize> CapGetSupportedSizes(this ITwainOperation session)
public IList<SupportedSize> CapGetSupportedSizes()
{
if (session == null) { throw new ArgumentNullException("session"); }
return session.GetCapabilityValues(CapabilityId.ICapSupportedSizes).CastToEnum<SupportedSize>(true);
return GetCapabilityValues(CapabilityId.ICapSupportedSizes).CastToEnum<SupportedSize>(true);
}
/// <summary>
/// Change the supported paper size for the current source.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="size">The size.</param>
/// <returns></returns>
public static ReturnCode CapSetSupportedSize(this ITwainOperation session, SupportedSize size)
public ReturnCode CapSetSupportedSize(SupportedSize size)
{
if (session == null) { throw new ArgumentNullException("session"); }
var one = new TWOneValue();
one.Item = (uint)size;
one.ItemType = ItemType.UInt16;
using (TWCapability xres = new TWCapability(CapabilityId.ICapSupportedSizes, one))
{
var rc = session.DGControl.Capability.Set(xres);
var rc = _session.DGControl.Capability.Set(xres);
return rc;
}
}
@ -505,18 +336,15 @@ namespace NTwain
/// <summary>
/// Change the auto deskew flag for the current source.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="useIt">if set to <c>true</c> use it.</param>
/// <returns></returns>
public static ReturnCode CapSetAutoDeskew(this TwainSession session, bool useIt)
public ReturnCode CapSetAutoDeskew(bool useIt)
{
if (session == null) { throw new ArgumentNullException("session"); }
var rc = ReturnCode.Failure;
if (session.SupportedCaps.Contains(CapabilityId.ICapAutomaticDeskew))
if (SupportedCaps.Contains(CapabilityId.ICapAutomaticDeskew))
{
if (session.SourceId.ProtocolMajor >= 2)
if (Identity.ProtocolMajor >= 2)
{
// if using twain 2.0 will need to use enum instead of onevalue (yuck)
TWEnumeration en = new TWEnumeration();
@ -525,7 +353,7 @@ namespace NTwain
using (TWCapability dx = new TWCapability(CapabilityId.ICapAutomaticDeskew, en))
{
rc = session.DGControl.Capability.Set(dx);
rc = _session.DGControl.Capability.Set(dx);
}
}
else
@ -536,7 +364,7 @@ namespace NTwain
using (TWCapability capValue = new TWCapability(CapabilityId.ICapAutomaticDeskew, one))
{
rc = session.DGControl.Capability.Set(capValue);
rc = _session.DGControl.Capability.Set(capValue);
}
}
}
@ -547,17 +375,14 @@ namespace NTwain
/// <summary>
/// Change the auto rotate flag for the current source.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="useIt">if set to <c>true</c> use it.</param>
/// <returns></returns>
public static ReturnCode CapSetAutoRotate(this ITwainSession session, bool useIt)
public ReturnCode CapSetAutoRotate(bool useIt)
{
if (session == null) { throw new ArgumentNullException("session"); }
var rc = ReturnCode.Failure;
if (session.SupportedCaps.Contains(CapabilityId.ICapAutomaticRotate))
if (SupportedCaps.Contains(CapabilityId.ICapAutomaticRotate))
{
if (session.SourceId.ProtocolMajor >= 2)
if (Identity.ProtocolMajor >= 2)
{
// if using twain 2.0 will need to use enum instead of onevalue (yuck)
TWEnumeration en = new TWEnumeration();
@ -566,7 +391,7 @@ namespace NTwain
using (TWCapability dx = new TWCapability(CapabilityId.ICapAutomaticRotate, en))
{
rc = session.DGControl.Capability.Set(dx);
rc = _session.DGControl.Capability.Set(dx);
}
}
else
@ -577,7 +402,7 @@ namespace NTwain
using (TWCapability capValue = new TWCapability(CapabilityId.ICapAutomaticRotate, one))
{
rc = session.DGControl.Capability.Set(capValue);
rc = _session.DGControl.Capability.Set(capValue);
}
}
}
@ -587,19 +412,16 @@ namespace NTwain
/// <summary>
/// Change the auto border detection flag for the current source.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="useIt">if set to <c>true</c> use it.</param>
/// <returns></returns>
public static ReturnCode CapSetBorderDetection(this ITwainSession session, bool useIt)
public ReturnCode CapSetBorderDetection(bool useIt)
{
if (session == null) { throw new ArgumentNullException("session"); }
var rc = ReturnCode.Failure;
if (session.SupportedCaps.Contains(CapabilityId.ICapAutomaticBorderDetection))
if (SupportedCaps.Contains(CapabilityId.ICapAutomaticBorderDetection))
{
// this goes along with undefinedimagesize so that also
// needs to be set
if (session.SourceId.ProtocolMajor >= 2)
if (Identity.ProtocolMajor >= 2)
{
// if using twain 2.0 will need to use enum instead of onevalue (yuck)
TWEnumeration en = new TWEnumeration();
@ -608,11 +430,11 @@ namespace NTwain
using (TWCapability dx = new TWCapability(CapabilityId.ICapUndefinedImageSize, en))
{
rc = session.DGControl.Capability.Set(dx);
rc = _session.DGControl.Capability.Set(dx);
}
using (TWCapability dx = new TWCapability(CapabilityId.ICapAutomaticBorderDetection, en))
{
rc = session.DGControl.Capability.Set(dx);
rc = _session.DGControl.Capability.Set(dx);
}
}
else
@ -623,11 +445,11 @@ namespace NTwain
using (TWCapability capValue = new TWCapability(CapabilityId.ICapUndefinedImageSize, one))
{
rc = session.DGControl.Capability.Set(capValue);
rc = _session.DGControl.Capability.Set(capValue);
}
using (TWCapability capValue = new TWCapability(CapabilityId.ICapAutomaticBorderDetection, one))
{
rc = session.DGControl.Capability.Set(capValue);
rc = _session.DGControl.Capability.Set(capValue);
}
}
}
@ -637,14 +459,11 @@ namespace NTwain
/// <summary>
/// Change the duplex flag for the current source.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="useIt">if set to <c>true</c> to use it.</param>
/// <returns></returns>
public static ReturnCode CapSetDuplex(this ITwainSession session, bool useIt)
public ReturnCode CapSetDuplex(bool useIt)
{
if (session == null) { throw new ArgumentNullException("session"); }
if (session.SourceId.ProtocolMajor >= 2)
if (Identity.ProtocolMajor >= 2)
{
// twain 2 likes to use enum :(
@ -654,7 +473,7 @@ namespace NTwain
using (TWCapability dx = new TWCapability(CapabilityId.CapDuplexEnabled, en))
{
return session.DGControl.Capability.Set(dx);
return _session.DGControl.Capability.Set(dx);
}
}
else
@ -665,7 +484,7 @@ namespace NTwain
using (TWCapability dx = new TWCapability(CapabilityId.CapDuplexEnabled, one))
{
return session.DGControl.Capability.Set(dx);
return _session.DGControl.Capability.Set(dx);
}
}
}
@ -673,17 +492,14 @@ namespace NTwain
/// <summary>
/// Change the use feeder flag for the current source.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="useIt">if set to <c>true</c> use it.</param>
/// <returns></returns>
public static ReturnCode CapSetFeeder(this ITwainSession session, bool useIt)
public ReturnCode CapSetFeeder(bool useIt)
{
if (session == null) { throw new ArgumentNullException("session"); }
var rc = ReturnCode.Failure;
if (session.SupportedCaps.Contains(CapabilityId.CapFeederEnabled))
if (SupportedCaps.Contains(CapabilityId.CapFeederEnabled))
{
if (session.SourceId.ProtocolMajor >= 2)
if (Identity.ProtocolMajor >= 2)
{
// if using twain 2.0 will need to use enum instead of onevalue (yuck)
TWEnumeration en = new TWEnumeration();
@ -698,24 +514,24 @@ namespace NTwain
{
using (TWCapability dx = new TWCapability(CapabilityId.CapFeederEnabled, en))
{
rc = session.DGControl.Capability.Set(dx);
rc = _session.DGControl.Capability.Set(dx);
}
}
// to really use feeder we must also set autofeed or autoscan, but only
// for one of them since setting autoscan also sets autofeed
if (session.SupportedCaps.Contains(CapabilityId.CapAutoScan))
if (SupportedCaps.Contains(CapabilityId.CapAutoScan))
{
using (TWCapability dx = new TWCapability(CapabilityId.CapAutoScan, en))
{
rc = session.DGControl.Capability.Set(dx);
rc = _session.DGControl.Capability.Set(dx);
}
}
else if (session.SupportedCaps.Contains(CapabilityId.CapAutoFeed))
else if (SupportedCaps.Contains(CapabilityId.CapAutoFeed))
{
using (TWCapability dx = new TWCapability(CapabilityId.CapAutoFeed, en))
{
rc = session.DGControl.Capability.Set(dx);
rc = _session.DGControl.Capability.Set(dx);
}
}
}
@ -729,23 +545,23 @@ namespace NTwain
{
using (TWCapability enabled = new TWCapability(CapabilityId.CapFeederEnabled, one))
{
rc = session.DGControl.Capability.Set(enabled);
rc = _session.DGControl.Capability.Set(enabled);
}
}
// to really use feeder we must also set autofeed or autoscan, but only
// for one of them since setting autoscan also sets autofeed
if (session.SupportedCaps.Contains(CapabilityId.CapAutoScan))
if (SupportedCaps.Contains(CapabilityId.CapAutoScan))
{
using (TWCapability autoScan = new TWCapability(CapabilityId.CapAutoScan, one))
{
rc = session.DGControl.Capability.Set(autoScan);
rc = _session.DGControl.Capability.Set(autoScan);
}
}
else if (session.SupportedCaps.Contains(CapabilityId.CapAutoFeed))
else if (SupportedCaps.Contains(CapabilityId.CapAutoFeed))
{
using (TWCapability autoScan = new TWCapability(CapabilityId.CapAutoFeed, one))
{
rc = session.DGControl.Capability.Set(autoScan);
rc = _session.DGControl.Capability.Set(autoScan);
}
}
}
@ -754,7 +570,5 @@ namespace NTwain
}
#endregion
#endregion
}
}

View File

@ -42,7 +42,7 @@ namespace Tester
if (rc == ReturnCode.Success)
{
var hit = twain.GetSources().Where(s => string.Equals(s.ProductName, "TWAIN2 FreeImage Software Scanner")).FirstOrDefault();
var hit = twain.GetSources().Where(s => string.Equals(s.Name, "TWAIN2 FreeImage Software Scanner")).FirstOrDefault();
if (hit == null)
{
Console.WriteLine("The sample source \"TWAIN2 FreeImage Software Scanner\" is not installed.");
@ -50,12 +50,12 @@ namespace Tester
}
else
{
rc = twain.OpenSource(hit.ProductName);
rc = hit.Open();
if (rc == ReturnCode.Success)
{
Console.WriteLine("Start capture from the sample source.");
rc = twain.EnableSource(SourceEnableMode.NoUI, false, IntPtr.Zero);
rc = hit.StartTransfer(SourceEnableMode.NoUI, false, IntPtr.Zero);
}
else
{
@ -72,7 +72,7 @@ namespace Tester
static void twain_SourceDisabled(object sender, EventArgs e)
{
Console.WriteLine("Source disabled on thread {0}.", Thread.CurrentThread.ManagedThreadId);
var rc = twain.CloseSource();
var rc = twain.Source.Close();
rc = twain.CloseManager();
}

View File

@ -56,7 +56,7 @@ namespace Tester.WPF
{
if (_twainVM.State == 4)
{
_twainVM.CloseSource();
_twainVM.Source.Close();
}
base.OnClosed(e);
}
@ -80,20 +80,20 @@ namespace Tester.WPF
{
if (_twainVM.State == 4)
{
_twainVM.CloseSource();
_twainVM.Source.Close();
}
var dsId = SrcList.SelectedItem as DSVM;
if (dsId != null)
{
var rc = _twainVM.OpenSource(dsId.Name);
var rc = dsId.DS.Open();
//rc = DGControl.Status.Get(dsId, ref stat);
if (rc == ReturnCode.Success)
{
var caps = _twainVM.SupportedCaps.Select(o => new CapVM
var caps = dsId.DS.SupportedCaps.Select(o => new CapVM
{
Cap = o,
Supports = _twainVM.GetCapabilitySupport(o)
Supports = dsId.DS.GetCapabilitySupport(o)
}).OrderBy(o => o.Name).ToList();
CapList.ItemsSource = caps;
}
@ -114,505 +114,505 @@ namespace Tester.WPF
switch (cap)
{
case CapabilityId.ACapXferMech:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<XferMech>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<XferMech>();
break;
case CapabilityId.CapAlarms:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<AlarmType>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<AlarmType>();
break;
case CapabilityId.CapAlarmVolume:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapAuthor:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapAutoFeed:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapAutomaticCapture:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapAutomaticSenseMedium:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapAutoScan:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapBatteryMinutes:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapBatteryPercentage:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapCameraEnabled:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapCameraOrder:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapCameraPreviewUI:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapCameraSide:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<CameraSide>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<CameraSide>();
break;
case CapabilityId.CapCaption:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapClearBuffers:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<ClearBuffer>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<ClearBuffer>();
break;
case CapabilityId.CapClearPage:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapCustomDSData:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapCustomInterfaceGuid:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapDeviceEvent:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<DeviceEvent>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<DeviceEvent>();
break;
case CapabilityId.CapDeviceOnline:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapDeviceTimeDate:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapDoubleFeedDetection:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<DoubleFeedDetection>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<DoubleFeedDetection>();
break;
case CapabilityId.CapDoubleFeedDetectionLength:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapDoubleFeedDetectionResponse:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<DoubleFeedDetectionResponse>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<DoubleFeedDetectionResponse>();
break;
case CapabilityId.CapDoubleFeedDetectionSensitivity:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<DoubleFeedDetectionSensitivity>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<DoubleFeedDetectionSensitivity>();
break;
case CapabilityId.CapDuplex:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<Duplex>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<Duplex>();
break;
case CapabilityId.CapDuplexEnabled:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapEnableDSUIOnly:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapEndorser:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapExtendedCaps:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapFeederAlignment:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<FeederAlignment>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<FeederAlignment>();
break;
case CapabilityId.CapFeederEnabled:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapFeederLoaded:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapFeederOrder:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<FeederOrder>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<FeederOrder>();
break;
case CapabilityId.CapFeederPocket:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<FeederPocket>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<FeederPocket>();
break;
case CapabilityId.CapFeederPrep:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapFeedPage:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapIndicators:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapIndicatorsMode:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<IndicatorsMode>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<IndicatorsMode>();
break;
case CapabilityId.CapJobControl:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<JobControl>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<JobControl>();
break;
case CapabilityId.CapLanguage:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<Language>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<Language>();
break;
case CapabilityId.CapMaxBatchBuffers:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapMicrEnabled:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapPaperDetectable:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapPaperHandling:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PaperHandling>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<PaperHandling>();
break;
case CapabilityId.CapPowerSaveTime:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapPowerSupply:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PowerSupply>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<PowerSupply>();
break;
case CapabilityId.CapPrinter:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<Printer>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<Printer>();
break;
case CapabilityId.CapPrinterCharRotation:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapPrinterEnabled:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapPrinterFontStyle:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PrinterFontStyle>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<PrinterFontStyle>();
break;
case CapabilityId.CapPrinterIndex:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapPrinterIndexLeadChar:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapPrinterIndexMaxValue:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapPrinterIndexNumDigits:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapPrinterIndexStep:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapPrinterIndexTrigger:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PrinterIndexTrigger>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<PrinterIndexTrigger>();
break;
case CapabilityId.CapPrinterMode:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PrinterMode>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<PrinterMode>();
break;
case CapabilityId.CapPrinterString:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapPrinterStringPreview:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapPrinterSuffix:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapPrinterVerticalOffset:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapReacquireAllowed:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapRewindPage:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapSegmented:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<Segmented>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<Segmented>();
break;
case CapabilityId.CapSerialNumber:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapSupportedCaps:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<CapabilityId>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<CapabilityId>();
break;
case CapabilityId.CapSupportedCapsSegmentUnique:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapSupportedDATs:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapThumbnailsEnabled:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapTimeBeforeFirstCapture:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapTimeBetweenCaptures:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapTimeDate:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapUIControllable:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CapXferCount:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.CustomBase:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapAutoBright:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapAutoDiscardBlankPages:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapAutomaticBorderDetection:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapAutomaticColorEnabled:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapAutomaticColorNonColorPixelType:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PixelType>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<PixelType>();
break;
case CapabilityId.ICapAutomaticCropUsesFrame:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapAutomaticDeskew:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapAutomaticLengthDetection:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapAutomaticRotate:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapAutoSize:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapBarcodeDetectionEnabled:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapBarcodeMaxRetries:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapBarcodeMaxSearchPriorities:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapBarcodeSearchMode:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapBarcodeSearchPriorities:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapBarcodeTimeout:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapBitDepth:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapBitDepthReduction:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<BitDepthReduction>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<BitDepthReduction>();
break;
case CapabilityId.ICapBitOrder:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<BitOrder>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<BitOrder>();
break;
case CapabilityId.ICapBitOrderCodes:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapBrightness:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapCCITTKFactor:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapColorManagementEnabled:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapCompression:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<CompressionType>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<CompressionType>();
break;
case CapabilityId.ICapContrast:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapCustHalftone:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapExposureTime:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapExtImageInfo:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapFeederType:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<FeederType>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<FeederType>();
break;
case CapabilityId.ICapFilmType:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<FilmType>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<FilmType>();
break;
case CapabilityId.ICapFilter:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<FilterType>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<FilterType>();
break;
case CapabilityId.ICapFlashUsed:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapFlashUsed2:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapFlipRotation:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<FlipRotation>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<FlipRotation>();
break;
case CapabilityId.ICapFrames:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapGamma:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapHalftones:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapHighlight:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapICCProfile:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<IccProfile>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<IccProfile>();
break;
case CapabilityId.ICapImageDataSet:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapImageFileFormat:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<FileFormat>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<FileFormat>();
break;
case CapabilityId.ICapImageFilter:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<ImageFilter>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<ImageFilter>();
break;
case CapabilityId.ICapImageMerge:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<ImageMerge>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<ImageMerge>();
break;
case CapabilityId.ICapImageMergeHeightThreshold:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapJpegPixelType:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PixelType>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<PixelType>();
break;
case CapabilityId.ICapJpegQuality:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<JpegQuality>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<JpegQuality>();
break;
case CapabilityId.ICapJpegSubsampling:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<JpegSubsampling>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<JpegSubsampling>();
break;
case CapabilityId.ICapLampState:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapLightPath:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<LightPath>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<LightPath>();
break;
case CapabilityId.ICapLightSource:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<LightSource>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<LightSource>();
break;
case CapabilityId.ICapMaxFrames:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapMinimumHeight:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapMinimumWidth:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapMirror:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<Mirror>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<Mirror>();
break;
case CapabilityId.ICapNoiseFilter:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<NoiseFilter>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<NoiseFilter>();
break;
case CapabilityId.ICapOrientation:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<OrientationType>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<OrientationType>();
break;
case CapabilityId.ICapOverScan:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<OverScan>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<OverScan>();
break;
case CapabilityId.ICapPatchCodeDetectionEnabled:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapPatchCodeMaxRetries:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapPatchCodeMaxSearchPriorities:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PatchCode>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<PatchCode>();
break;
case CapabilityId.ICapPatchCodeSearchMode:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapPatchCodeSearchPriorities:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapPatchCodeTimeout:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
// TODO phys size are twfix32
case CapabilityId.ICapPhysicalHeight:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapPhysicalWidth:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapPixelFlavor:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PixelFlavor>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<PixelFlavor>();
break;
case CapabilityId.ICapPixelFlavorCodes:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapPixelType:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PixelType>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<PixelType>();
break;
case CapabilityId.ICapPlanarChunky:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PlanarChunky>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<PlanarChunky>();
break;
case CapabilityId.ICapRotation:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<Rotation>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<Rotation>();
break;
case CapabilityId.ICapShadow:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapSupportedBarcodeTypes:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<BarcodeType>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<BarcodeType>();
break;
case CapabilityId.ICapSupportedExtImageInfo:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<ExtendedImageInfo>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<ExtendedImageInfo>();
break;
case CapabilityId.ICapSupportedPatchCodeTypes:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PatchCode>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<PatchCode>();
break;
case CapabilityId.ICapSupportedSizes:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<SupportedSize>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<SupportedSize>();
break;
case CapabilityId.ICapThreshold:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapTiles:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapTimeFill:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapUndefinedImageSize:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapUnits:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<Unit>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<Unit>();
break;
case CapabilityId.ICapXferMech:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<XferMech>();
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap).CastToEnum<XferMech>();
break;
case CapabilityId.ICapXNativeResolution:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapXResolution:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapXScaling:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapYNativeResolution:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapYResolution:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapYScaling:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
case CapabilityId.ICapZoomFactor:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
break;
default:
if (cap > CapabilityId.CustomBase)
{
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
CapDetailList.ItemsSource = _twainVM.Source.GetCapabilityValues(cap);
}
else
{

View File

@ -1,4 +1,5 @@
using NTwain.Data;
using NTwain;
using NTwain.Data;
namespace Tester.WPF
{
@ -7,9 +8,9 @@ namespace Tester.WPF
/// </summary>
class DSVM
{
public TWIdentity DS { get; set; }
public TwainSource DS { get; set; }
public string Name { get { return DS.ProductName; } }
public string Name { get { return DS.Name; } }
public string Version { get { return DS.Version.Info; } }
public string Protocol { get { return string.Format("{0}.{1}", DS.ProtocolMajor, DS.ProtocolMinor); } }
}

View File

@ -68,9 +68,9 @@ namespace Tester.WPF
{
// set it up to use file xfer
if (this.GetCurrentCap(CapabilityId.ICapXferMech).ConvertToEnum<XferMech>() == XferMech.File)
if (this.Source.GetCurrentCap(CapabilityId.ICapXferMech).ConvertToEnum<XferMech>() == XferMech.File)
{
var formats = this.CapGetImageFileFormat();
var formats = this.Source.CapGetImageFileFormat();
var wantFormat = formats.Contains(FileFormat.Tiff) ? FileFormat.Tiff : FileFormat.Bmp;
var fileSetup = new TWSetupFileXfer
@ -110,17 +110,17 @@ namespace Tester.WPF
{
if (State == 4)
{
if (this.CapGetPixelTypes().Contains(PixelType.BlackWhite))
if (this.Source.CapGetPixelTypes().Contains(PixelType.BlackWhite))
{
this.CapSetPixelType(PixelType.BlackWhite);
this.Source.CapSetPixelType(PixelType.BlackWhite);
}
if (this.CapGetImageXferMechs().Contains(XferMech.File))
if (this.Source.CapGetImageXferMechs().Contains(XferMech.File))
{
this.CapSetImageXferMech(XferMech.File);
this.Source.CapSetImageXferMech(XferMech.File);
}
var rc = EnableSource(SourceEnableMode.NoUI, false, hwnd);
var rc = this.Source.StartTransfer(SourceEnableMode.NoUI, false, hwnd);
}
}
}

View File

@ -107,7 +107,7 @@ namespace Tester.Winform
{
if (_twain.State == 4)
{
_twain.CloseSource();
_twain.Source.Close();
}
if (_twain.State == 3)
{
@ -143,7 +143,7 @@ namespace Tester.Winform
// do nothing if source is enabled
if (_twain.State > 4) { return; }
if (_twain.State == 4) { _twain.CloseSource(); }
if (_twain.State == 4) { _twain.Source.Close(); }
foreach (var btn in btnSources.DropDownItems)
{
@ -152,8 +152,8 @@ namespace Tester.Winform
}
var curBtn = (sender as ToolStripMenuItem);
var src = curBtn.Tag as TWIdentity;
if (_twain.OpenSource(src.ProductName) == ReturnCode.Success)
var src = curBtn.Tag as TwainSource;
if (src.Open() == ReturnCode.Success)
{
curBtn.Checked = true;
btnStartCapture.Enabled = true;
@ -167,10 +167,10 @@ namespace Tester.Winform
{
_stopScan = false;
if (_twain.SupportedCaps.Contains(CapabilityId.CapUIControllable))
if (_twain.Source.SupportedCaps.Contains(CapabilityId.CapUIControllable))
{
// hide scanner ui if possible
if (_twain.EnableSource(SourceEnableMode.NoUI, false, this.Handle) == ReturnCode.Success)
if (_twain.Source.StartTransfer(SourceEnableMode.NoUI, false, this.Handle) == ReturnCode.Success)
{
btnStopScan.Enabled = true;
btnStartCapture.Enabled = false;
@ -179,7 +179,7 @@ namespace Tester.Winform
}
else
{
if (_twain.EnableSource(SourceEnableMode.ShowUI, true, this.Handle) == ReturnCode.Success)
if (_twain.Source.StartTransfer(SourceEnableMode.ShowUI, true, this.Handle) == ReturnCode.Success)
{
btnStopScan.Enabled = true;
btnStartCapture.Enabled = false;
@ -252,10 +252,10 @@ namespace Tester.Winform
}
foreach (var src in _twain.GetSources())
{
var srcBtn = new ToolStripMenuItem(src.ProductName);
var srcBtn = new ToolStripMenuItem(src.Name);
srcBtn.Tag = src;
srcBtn.Click += SourceMenuItem_Click;
srcBtn.Checked = _twain.SourceId != null && _twain.SourceId.Id == src.Id;
srcBtn.Checked = _twain.Source != null && _twain.Source.Name == src.Name;
btnSources.DropDownItems.Insert(0, srcBtn);
}
}
@ -267,7 +267,7 @@ namespace Tester.Winform
private void LoadSourceCaps()
{
var caps = _twain.SupportedCaps;
var caps = _twain.Source.SupportedCaps;
_loadingCaps = true;
if (groupDepth.Enabled = caps.Contains(CapabilityId.ICapPixelType))
{
@ -292,9 +292,9 @@ namespace Tester.Winform
private void LoadPaperSize()
{
var list = _twain.CapGetSupportedSizes();
var list = _twain.Source.CapGetSupportedSizes();
comboSize.DataSource = list;
var cur = _twain.GetCurrentCap(CapabilityId.ICapSupportedSizes).ConvertToEnum<SupportedSize>();
var cur = _twain.Source.GetCurrentCap(CapabilityId.ICapSupportedSizes).ConvertToEnum<SupportedSize>();
if (list.Contains(cur))
{
comboSize.SelectedItem = cur;
@ -303,15 +303,15 @@ namespace Tester.Winform
private void LoadDuplex()
{
ckDuplex.Checked = _twain.GetCurrentCap(CapabilityId.CapDuplexEnabled).ConvertToEnum<uint>() != 0;
ckDuplex.Checked = _twain.Source.GetCurrentCap(CapabilityId.CapDuplexEnabled).ConvertToEnum<uint>() != 0;
}
private void LoadDPI()
{
// only allow dpi of certain values for those source that lists everything
var list = _twain.CapGetDPIs().Where(dpi => (dpi % 50) == 0).ToList();
var list = _twain.Source.CapGetDPIs().Where(dpi => (dpi % 50) == 0).ToList();
comboDPI.DataSource = list;
var cur = (TWFix32)_twain.GetCurrentCap(CapabilityId.ICapXResolution);
var cur = (TWFix32)_twain.Source.GetCurrentCap(CapabilityId.ICapXResolution);
if (list.Contains(cur))
{
comboDPI.SelectedItem = cur;
@ -320,9 +320,9 @@ namespace Tester.Winform
private void LoadDepth()
{
var list = _twain.CapGetPixelTypes();
var list = _twain.Source.CapGetPixelTypes();
comboDepth.DataSource = list;
var cur = _twain.GetCurrentCap(CapabilityId.ICapPixelType).ConvertToEnum<PixelType>();
var cur = _twain.Source.GetCurrentCap(CapabilityId.ICapPixelType).ConvertToEnum<PixelType>();
if (list.Contains(cur))
{
comboDepth.SelectedItem = cur;
@ -334,7 +334,7 @@ namespace Tester.Winform
if (!_loadingCaps && _twain.State == 4)
{
var sel = (SupportedSize)comboSize.SelectedItem;
_twain.CapSetSupportedSize(sel);
_twain.Source.CapSetSupportedSize(sel);
}
}
@ -343,7 +343,7 @@ namespace Tester.Winform
if (!_loadingCaps && _twain.State == 4)
{
var sel = (PixelType)comboDepth.SelectedItem;
_twain.CapSetPixelType(sel);
_twain.Source.CapSetPixelType(sel);
}
}
@ -352,7 +352,7 @@ namespace Tester.Winform
if (!_loadingCaps && _twain.State == 4)
{
var sel = (TWFix32)comboDPI.SelectedItem;
_twain.CapSetDPI(sel);
_twain.Source.CapSetDPI(sel);
}
}
@ -360,13 +360,13 @@ namespace Tester.Winform
{
if (!_loadingCaps && _twain.State == 4)
{
_twain.CapSetDuplex(ckDuplex.Checked);
_twain.Source.CapSetDuplex(ckDuplex.Checked);
}
}
private void btnAllSettings_Click(object sender, EventArgs e)
{
_twain.EnableSource(SourceEnableMode.ShowUIOnly, true, this.Handle);
_twain.Source.StartTransfer(SourceEnableMode.ShowUIOnly, true, this.Handle);
}
#endregion