mirror of
https://github.com/soukoku/ntwain.git
synced 2025-11-08 10:34:47 +08:00
Merged in wrapper-idea (pull request #1)
Wrapped data source functions in .net class
This commit is contained in:
@@ -43,8 +43,8 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\NTwain\CapabilityReadout.cs">
|
||||
<Link>CapabilityReadout.cs</Link>
|
||||
<Compile Include="..\NTwain\CapabilityReader.cs">
|
||||
<Link>CapabilityReader.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\NTwain\DataTransferredEventArgs.cs">
|
||||
<Link>DataTransferredEventArgs.cs</Link>
|
||||
@@ -100,9 +100,6 @@
|
||||
<Compile Include="..\NTwain\Internals\WrappedManualResetEvent.cs">
|
||||
<Link>Internals\WrappedManualResetEvent.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\NTwain\ITwainOperation.cs">
|
||||
<Link>ITwainOperation.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\NTwain\ITwainSession.cs">
|
||||
<Link>ITwainSession.cs</Link>
|
||||
</Compile>
|
||||
@@ -271,8 +268,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>
|
||||
|
||||
@@ -8,10 +8,10 @@ using System.Runtime.InteropServices;
|
||||
namespace NTwain
|
||||
{
|
||||
/// <summary>
|
||||
/// The one-stop class for reading TWAIN cap values.
|
||||
/// The one-stop class for reading raw TWAIN cap values.
|
||||
/// This contains all the properties for the 4 container types.
|
||||
/// </summary>
|
||||
public class CapabilityReadOut
|
||||
public class CapabilityReader
|
||||
{
|
||||
/// <summary>
|
||||
/// Reads the value from a <see cref="TWCapability"/> that was returned
|
||||
@@ -25,7 +25,7 @@ namespace NTwain
|
||||
/// or
|
||||
/// capability
|
||||
/// </exception>
|
||||
public static CapabilityReadOut ReadValue(TWCapability capability)
|
||||
public static CapabilityReader ReadValue(TWCapability capability)
|
||||
{
|
||||
if (capability == null) { throw new ArgumentNullException("capability"); }
|
||||
if (capability.Container == IntPtr.Zero) { throw new ArgumentException(Resources.CapHasNoData, "capability"); }
|
||||
@@ -37,22 +37,22 @@ namespace NTwain
|
||||
switch (capability.ContainerType)
|
||||
{
|
||||
case ContainerType.Array:
|
||||
return new CapabilityReadOut
|
||||
return new CapabilityReader
|
||||
{
|
||||
ContainerType = capability.ContainerType,
|
||||
}.ReadArrayValue(baseAddr);
|
||||
case ContainerType.Enum:
|
||||
return new CapabilityReadOut
|
||||
return new CapabilityReader
|
||||
{
|
||||
ContainerType = capability.ContainerType,
|
||||
}.ReadEnumValue(baseAddr);
|
||||
case ContainerType.OneValue:
|
||||
return new CapabilityReadOut
|
||||
return new CapabilityReader
|
||||
{
|
||||
ContainerType = capability.ContainerType,
|
||||
}.ReadOneValue(baseAddr);
|
||||
case ContainerType.Range:
|
||||
return new CapabilityReadOut
|
||||
return new CapabilityReader
|
||||
{
|
||||
ContainerType = capability.ContainerType,
|
||||
}.ReadRangeValue(baseAddr);
|
||||
@@ -161,7 +161,7 @@ namespace NTwain
|
||||
|
||||
#region reader methods
|
||||
|
||||
CapabilityReadOut ReadOneValue(IntPtr baseAddr)
|
||||
CapabilityReader ReadOneValue(IntPtr baseAddr)
|
||||
{
|
||||
int offset = 0;
|
||||
ItemType = (ItemType)(ushort)Marshal.ReadInt16(baseAddr, offset);
|
||||
@@ -170,7 +170,7 @@ namespace NTwain
|
||||
return this;
|
||||
}
|
||||
|
||||
CapabilityReadOut ReadArrayValue(IntPtr baseAddr)
|
||||
CapabilityReader ReadArrayValue(IntPtr baseAddr)
|
||||
{
|
||||
int offset = 0;
|
||||
ItemType = (ItemType)(ushort)Marshal.ReadInt16(baseAddr, offset);
|
||||
@@ -188,7 +188,7 @@ namespace NTwain
|
||||
return this;
|
||||
}
|
||||
|
||||
CapabilityReadOut ReadEnumValue(IntPtr baseAddr)
|
||||
CapabilityReader ReadEnumValue(IntPtr baseAddr)
|
||||
{
|
||||
int offset = 0;
|
||||
ItemType = (ItemType)(ushort)Marshal.ReadInt16(baseAddr, offset);
|
||||
@@ -210,7 +210,7 @@ namespace NTwain
|
||||
return this;
|
||||
}
|
||||
|
||||
CapabilityReadOut ReadRangeValue(IntPtr baseAddr)
|
||||
CapabilityReader ReadRangeValue(IntPtr baseAddr)
|
||||
{
|
||||
int offset = 0;
|
||||
ItemType = (ItemType)(ushort)Marshal.ReadInt16(baseAddr, offset);
|
||||
@@ -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;
|
||||
@@ -498,12 +499,12 @@ namespace NTwain.Data
|
||||
/// Gets the <see cref="Mix"/> value as matrix.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1814:PreferJaggedArraysOverMultidimensional", MessageId = "Body"),
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1814:PreferJaggedArraysOverMultidimensional", MessageId = "Body"),
|
||||
System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1814:PreferJaggedArraysOverMultidimensional", MessageId = "Return")]
|
||||
public TWFix32[,] GetMixMatrix()
|
||||
{
|
||||
// from http://stackoverflow.com/questions/3845235/convert-array-to-matrix, haven't tested it
|
||||
TWFix32[,] mat = new TWFix32[3, 3];
|
||||
TWFix32[,] mat = new TWFix32[3, 3];
|
||||
Buffer.BlockCopy(_mix, 0, mat, 0, _mix.Length * 4);
|
||||
return mat;
|
||||
}
|
||||
@@ -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 = CapabilityReader.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>
|
||||
@@ -1305,11 +1348,11 @@ namespace NTwain.Data
|
||||
/// <summary>
|
||||
/// Tag identifying an information.
|
||||
/// </summary>
|
||||
public ExtendedImageInfo InfoID { get { return (ExtendedImageInfo)_infoID; } }
|
||||
public ExtendedImageInfo InfoID { get { return (ExtendedImageInfo)_infoID; } set { _infoID = (ushort)value; } }
|
||||
/// <summary>
|
||||
/// Item data type.
|
||||
/// </summary>
|
||||
public ItemType ItemType { get { return (ItemType)_itemType; } }
|
||||
public ItemType ItemType { get { return (ItemType)_itemType; } set { _itemType = (ushort)value; } }
|
||||
/// <summary>
|
||||
/// Number of items.
|
||||
/// </summary>
|
||||
@@ -1345,7 +1388,10 @@ namespace NTwain.Data
|
||||
/// </summary>
|
||||
public sealed partial class TWExtImageInfo : IDisposable
|
||||
{
|
||||
internal TWExtImageInfo() { }
|
||||
internal TWExtImageInfo()
|
||||
{
|
||||
_info = new TWInfo[200];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of information that application is requesting. This is filled by the
|
||||
@@ -1353,7 +1399,7 @@ namespace NTwain.Data
|
||||
/// image information. The application should allocate memory and fill in the
|
||||
/// attribute tag for image information.
|
||||
/// </summary>
|
||||
public uint NumInfos { get { return _numInfos; } }
|
||||
public uint NumInfos { get { return _numInfos; } set { _numInfos = value; } }
|
||||
/// <summary>
|
||||
/// Array of information.
|
||||
/// </summary>
|
||||
|
||||
@@ -17,6 +17,9 @@ namespace NTwain.Data
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")]
|
||||
public enum ContainerType : ushort
|
||||
{
|
||||
/// <summary>
|
||||
/// The default value for this enum.
|
||||
/// </summary>
|
||||
Invalid = 0,
|
||||
/// <summary>
|
||||
/// The container is <see cref="TWArray"/>.
|
||||
@@ -34,6 +37,9 @@ namespace NTwain.Data
|
||||
/// The container is <see cref="TWRange"/>.
|
||||
/// </summary>
|
||||
Range = 6,
|
||||
/// <summary>
|
||||
/// The don't care value.
|
||||
/// </summary>
|
||||
DontCare = TwainConst.DontCare16,
|
||||
}
|
||||
|
||||
|
||||
@@ -45,12 +45,12 @@ namespace NTwain
|
||||
/// </value>
|
||||
public TWImageInfo ImageInfo { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the extended image information if applicable.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The extended image information.
|
||||
/// </value>
|
||||
public TWExtImageInfo ExImageInfo { get; internal set; }
|
||||
///// <summary>
|
||||
///// Gets the extended image information if applicable.
|
||||
///// </summary>
|
||||
///// <value>
|
||||
///// The extended image information.
|
||||
///// </value>
|
||||
//public TWExtImageInfo ExImageInfo { get; internal set; }
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
using NTwain.Data;
|
||||
using NTwain.Triplets;
|
||||
using System;
|
||||
|
||||
namespace NTwain
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for TWAIN triplet operations.
|
||||
/// </summary>
|
||||
public interface ITwainOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the triplet operations defined for audio data group.
|
||||
/// </summary>
|
||||
DGAudio DGAudio { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the triplet operations defined for control data group.
|
||||
/// </summary>
|
||||
DGControl DGControl { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the triplet operations defined for image data group.
|
||||
/// </summary>
|
||||
DGImage DGImage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the direct triplet operation entry for custom values.
|
||||
/// </summary>
|
||||
DGCustom DGCustom { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Opens the data source manager. This must be the first method used
|
||||
/// before using other TWAIN functions. Calls to this must be followed by <see cref="CloseManager"/> when done with a TWAIN session.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
ReturnCode OpenManager();
|
||||
|
||||
/// <summary>
|
||||
/// Closes the data source manager.
|
||||
/// </summary>
|
||||
/// <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);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using NTwain.Data;
|
||||
using NTwain.Triplets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -10,13 +11,25 @@ namespace NTwain
|
||||
/// <summary>
|
||||
/// General interface for a TWAIN session.
|
||||
/// </summary>
|
||||
public interface ITwainSession : INotifyPropertyChanged, ITwainOperation
|
||||
public interface ITwainSession : INotifyPropertyChanged
|
||||
{
|
||||
/// <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 CurrentSource { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default source for this application.
|
||||
/// While this can be get as long as the session is open,
|
||||
/// it can only be set at State 3.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The default source.
|
||||
/// </value>
|
||||
TwainSource DefaultSource { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current state number as defined by the TWAIN spec.
|
||||
@@ -25,11 +38,68 @@ namespace NTwain
|
||||
int State { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the supported caps for the currently open source.
|
||||
/// Gets the triplet operations defined for audio data group.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The supported caps.
|
||||
/// </value>
|
||||
IList<CapabilityId> SupportedCaps { get; }
|
||||
DGAudio DGAudio { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the triplet operations defined for control data group.
|
||||
/// </summary>
|
||||
DGControl DGControl { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the triplet operations defined for image data group.
|
||||
/// </summary>
|
||||
DGImage DGImage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the direct triplet operation entry for custom values.
|
||||
/// </summary>
|
||||
DGCustom DGCustom { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Try to show the built-in source selector dialog and return the selected source.
|
||||
/// This is not recommended and is only included for completeness.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
TwainSource ShowSourceSelector();
|
||||
|
||||
/// <summary>
|
||||
/// Opens the data source manager. This must be the first method used
|
||||
/// before using other TWAIN functions. Calls to this must be followed by <see cref="Close"/> when done with a TWAIN session.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
ReturnCode Open();
|
||||
|
||||
/// <summary>
|
||||
/// Closes the data source manager.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
ReturnCode Close();
|
||||
|
||||
/// <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>
|
||||
IEnumerable<TwainSource> GetSources();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the manager status. Only call this at state 2 or higher.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
TWStatus GetStatus();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the manager status. Only call this at state 3 or higher.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
TWStatusUtf8 GetStatusUtf8();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using NTwain.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
namespace NTwain.Internals
|
||||
{
|
||||
@@ -34,12 +36,15 @@ 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);
|
||||
SynchronizationContext SynchronizationContext { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.CurrentSource.CapGetCurrent(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.CurrentSource.CapGetCurrent(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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.GetStatus() });
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -414,14 +414,14 @@ namespace NTwain.Internals
|
||||
static void DoImageXferredEventRoutine(ITwainSessionInternal session, IntPtr dataPtr, byte[] dataArray, string filePath)
|
||||
{
|
||||
TWImageInfo imgInfo;
|
||||
TWExtImageInfo extInfo = null;
|
||||
if (session.SupportedCaps.Contains(CapabilityId.ICapExtImageInfo))
|
||||
{
|
||||
if (session.DGImage.ExtImageInfo.Get(out extInfo) != ReturnCode.Success)
|
||||
{
|
||||
extInfo = null;
|
||||
}
|
||||
}
|
||||
//TWExtImageInfo extInfo = null;
|
||||
//if (session.CurrentSource.SupportedCaps.Contains(CapabilityId.ICapExtImageInfo))
|
||||
//{
|
||||
// if (session.DGImage.ExtImageInfo.Get(out extInfo) != ReturnCode.Success)
|
||||
// {
|
||||
// extInfo = null;
|
||||
// }
|
||||
//}
|
||||
if (session.DGImage.ImageInfo.Get(out imgInfo) != ReturnCode.Success)
|
||||
{
|
||||
imgInfo = null;
|
||||
@@ -432,9 +432,9 @@ namespace NTwain.Internals
|
||||
MemData = dataArray,
|
||||
FileDataPath = filePath,
|
||||
ImageInfo = imgInfo,
|
||||
ExImageInfo = extInfo
|
||||
//ExImageInfo = extInfo
|
||||
});
|
||||
if (extInfo != null) { extInfo.Dispose(); }
|
||||
//if (extInfo != null) { extInfo.Dispose(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CapabilityReadout.cs" />
|
||||
<Compile Include="CapabilityReader.cs" />
|
||||
<Compile Include="Data\TypeReader.cs" />
|
||||
<Compile Include="Data\TwainTypesExtended.cs" />
|
||||
<Compile Include="DeviceEventArgs.cs" />
|
||||
@@ -64,7 +64,6 @@
|
||||
<Compile Include="Internals\TransferLogic.cs" />
|
||||
<Compile Include="Internals\WindowsHook.cs" />
|
||||
<Compile Include="Internals\WrappedManualResetEvent.cs" />
|
||||
<Compile Include="ITwainOperation.cs" />
|
||||
<Compile Include="ITwainSession.cs" />
|
||||
<Compile Include="Internals\WinMemoryManager.cs" />
|
||||
<Compile Include="Internals\MessageLoop.cs" />
|
||||
@@ -87,8 +86,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" />
|
||||
|
||||
@@ -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.CurrentSource.Identity, DataGroups.Audio, DataArgumentType.AudioFileXfer, Message.Get, ref z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,20 +6,20 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.AudioInfo"/>.
|
||||
/// </summary>
|
||||
public sealed class AudioInfo : OpBase
|
||||
sealed class AudioInfo : OpBase
|
||||
{
|
||||
internal AudioInfo(ITwainSessionInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
|
||||
/// <summary>
|
||||
/// Used to get the information of the current audio data ready to transfer.
|
||||
/// </summary>
|
||||
/// <param name="info">The info.</param>
|
||||
/// <returns></returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
|
||||
public ReturnCode Get(out TWAudioInfo info)
|
||||
{
|
||||
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.CurrentSource.Identity, Message.Get, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.Identity, DataGroups.Audio, DataArgumentType.AudioNativeXfer, Message.Get, ref handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ namespace NTwain.Triplets
|
||||
}
|
||||
|
||||
AudioInfo _audioInfo;
|
||||
public AudioInfo AudioInfo
|
||||
internal AudioInfo AudioInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
@@ -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.CurrentSource.Identity, Message.RegisterCallback, callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.Identity, Message.RegisterCallback, callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.Identity, DataArgumentType.Capability, Message.SetConstraint, capability);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.Identity, (DataArgumentType)customDAT, Message.SetConstraint, capability);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.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.CurrentSource.Identity, Message.Set, customData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,15 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.DeviceEvent"/>.
|
||||
/// </summary>
|
||||
public sealed class DeviceEvent : OpBase
|
||||
sealed class DeviceEvent : OpBase
|
||||
{
|
||||
internal DeviceEvent(ITwainSessionInternal session) : base(session) { }
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
|
||||
|
||||
public ReturnCode Get(out TWDeviceEvent sourceDeviceEvent)
|
||||
{
|
||||
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.CurrentSource.Identity, Message.Get, sourceDeviceEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.Identity, Message.ProcessEvent, theEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.Identity, Message.Rename, fileSystem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,10 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.Identity"/>.
|
||||
/// </summary>
|
||||
public sealed class Identity : OpBase
|
||||
sealed class Identity : OpBase
|
||||
{
|
||||
internal Identity(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
/// <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
|
||||
@@ -16,10 +17,10 @@ namespace NTwain.Triplets
|
||||
/// accessed by other applications until its current session is terminated.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal ReturnCode CloseDS()
|
||||
public 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.CurrentSource.Identity);
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
Session.ChangeSourceId(null);
|
||||
@@ -33,7 +34,6 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
/// <param name="source">The source.</param>
|
||||
/// <returns></returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
|
||||
public ReturnCode GetDefault(out TWIdentity source)
|
||||
{
|
||||
Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.Identity, Message.GetDefault);
|
||||
@@ -48,7 +48,6 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
/// <param name="source">The source.</param>
|
||||
/// <returns></returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
|
||||
public ReturnCode GetFirst(out TWIdentity source)
|
||||
{
|
||||
Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.Identity, Message.GetFirst);
|
||||
@@ -62,7 +61,6 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
/// <param name="source">The source.</param>
|
||||
/// <returns></returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
|
||||
public ReturnCode GetNext(out TWIdentity source)
|
||||
{
|
||||
Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.Identity, Message.GetNext);
|
||||
@@ -75,10 +73,10 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
/// <param name="source">The source.</param>
|
||||
/// <returns></returns>
|
||||
internal ReturnCode OpenDS(TWIdentity source)
|
||||
public 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);
|
||||
|
||||
@@ -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.CurrentSource.Identity, Message.PassThru, sourcePassThru);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.Identity, Message.StopFeeder, pendingXfers);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.Identity, Message.Set, setupFileXfer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.CurrentSource.Identity, Message.Get, setupMemXfer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.Status"/>.
|
||||
/// </summary>
|
||||
public sealed class Status : OpBase
|
||||
sealed class Status : OpBase
|
||||
{
|
||||
internal Status(ITwainSessionInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
@@ -14,7 +14,6 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
/// <param name="status">The status.</param>
|
||||
/// <returns></returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
|
||||
public ReturnCode GetManager(out TWStatus status)
|
||||
{
|
||||
Session.VerifyState(2, 7, DataGroups.Control, DataArgumentType.Status, Message.Get);
|
||||
@@ -27,12 +26,11 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
/// <param name="status">The status.</param>
|
||||
/// <returns></returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
|
||||
public ReturnCode GetSource(out TWStatus status)
|
||||
{
|
||||
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.CurrentSource.Identity, Message.Get, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,19 +6,34 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.StatusUtf8"/>.
|
||||
/// </summary>
|
||||
public sealed class StatusUtf8 : OpBase
|
||||
sealed class StatusUtf8 : OpBase
|
||||
{
|
||||
internal StatusUtf8(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
/// <summary>
|
||||
/// Translate the contents of a TW_STATUS structure received from the manager into a localized UTF-8
|
||||
/// encoded string.
|
||||
/// </summary>
|
||||
/// <param name="status">The status.</param>
|
||||
/// <returns></returns>
|
||||
public ReturnCode GetManager(out TWStatusUtf8 status)
|
||||
{
|
||||
status = new TWStatusUtf8();
|
||||
Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.StatusUtf8, Message.Get);
|
||||
return Dsm.DsmEntry(Session.AppId, null, Message.Get, status);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translate the contents of a TW_STATUS structure received from a Source into a localized UTF-8
|
||||
/// encoded string.
|
||||
/// </summary>
|
||||
/// <param name="status">The status.</param>
|
||||
/// <returns></returns>
|
||||
public ReturnCode Get(TWStatusUtf8 status)
|
||||
public ReturnCode GetSource(out TWStatusUtf8 status)
|
||||
{
|
||||
status = new TWStatusUtf8();
|
||||
Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.StatusUtf8, Message.Get);
|
||||
return Dsm.DsmEntry(Session.AppId, null, Message.Get, status);
|
||||
return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.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.CurrentSource.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.CurrentSource.Identity, Message.EnableDSUIOnly, userInterface);
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
pending.Commit();
|
||||
|
||||
@@ -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.CurrentSource.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.CurrentSource.Identity, DataGroups.Control, DataArgumentType.XferGroup, Message.Set, ref value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,10 @@ namespace NTwain.Triplets
|
||||
return _callback2;
|
||||
}
|
||||
}
|
||||
Capability _capability;
|
||||
Capability _capability;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_CAPABILITY.
|
||||
/// </summary>
|
||||
public Capability Capability
|
||||
{
|
||||
get
|
||||
@@ -44,6 +47,9 @@ namespace NTwain.Triplets
|
||||
}
|
||||
}
|
||||
CapabilityCustom _capabilityCust;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for a custom DAT_* value with capability data.
|
||||
/// </summary>
|
||||
public CapabilityCustom CapabilityCustom
|
||||
{
|
||||
get
|
||||
@@ -52,7 +58,10 @@ namespace NTwain.Triplets
|
||||
return _capabilityCust;
|
||||
}
|
||||
}
|
||||
CustomDSData _customDSData;
|
||||
CustomDSData _customDSData;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_CUSTOMDSDATA.
|
||||
/// </summary>
|
||||
public CustomDSData CustomDSData
|
||||
{
|
||||
get
|
||||
@@ -62,7 +71,7 @@ namespace NTwain.Triplets
|
||||
}
|
||||
}
|
||||
DeviceEvent _deviceEvent;
|
||||
public DeviceEvent DeviceEvent
|
||||
internal DeviceEvent DeviceEvent
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -88,7 +97,10 @@ namespace NTwain.Triplets
|
||||
return _event;
|
||||
}
|
||||
}
|
||||
FileSystem _fileSys;
|
||||
FileSystem _fileSys;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_FILESYSTEM.
|
||||
/// </summary>
|
||||
public FileSystem FileSystem
|
||||
{
|
||||
get
|
||||
@@ -98,7 +110,7 @@ namespace NTwain.Triplets
|
||||
}
|
||||
}
|
||||
Identity _identity;
|
||||
public Identity Identity
|
||||
internal Identity Identity
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -115,7 +127,10 @@ namespace NTwain.Triplets
|
||||
return _parent;
|
||||
}
|
||||
}
|
||||
PassThru _passThru;
|
||||
PassThru _passThru;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_PASSTHRU.
|
||||
/// </summary>
|
||||
public PassThru PassThru
|
||||
{
|
||||
get
|
||||
@@ -133,7 +148,10 @@ namespace NTwain.Triplets
|
||||
return _pendingXfers;
|
||||
}
|
||||
}
|
||||
SetupFileXfer _setupFileXfer;
|
||||
SetupFileXfer _setupFileXfer;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_SETUPFILEXFER.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer")]
|
||||
public SetupFileXfer SetupFileXfer
|
||||
{
|
||||
@@ -143,7 +161,10 @@ namespace NTwain.Triplets
|
||||
return _setupFileXfer;
|
||||
}
|
||||
}
|
||||
SetupMemXfer _setupMemXfer;
|
||||
SetupMemXfer _setupMemXfer;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_SETUPMEMXFER.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mem")]
|
||||
public SetupMemXfer SetupMemXfer
|
||||
{
|
||||
@@ -154,7 +175,7 @@ namespace NTwain.Triplets
|
||||
}
|
||||
}
|
||||
Status _status;
|
||||
public Status Status
|
||||
internal Status Status
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -163,7 +184,7 @@ namespace NTwain.Triplets
|
||||
}
|
||||
}
|
||||
StatusUtf8 _statusUtf8;
|
||||
public StatusUtf8 StatusUtf8
|
||||
internal StatusUtf8 StatusUtf8
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -180,7 +201,10 @@ namespace NTwain.Triplets
|
||||
return _userInterface;
|
||||
}
|
||||
}
|
||||
XferGroup _xferGroup;
|
||||
XferGroup _xferGroup;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_XFERGROUP.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer")]
|
||||
public XferGroup XferGroup
|
||||
{
|
||||
|
||||
@@ -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.CurrentSource.Identity, group, dat, message, ref data);
|
||||
}
|
||||
|
||||
// todo: add other data value types?
|
||||
|
||||
@@ -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.CurrentSource.Identity, Message.Get, cieColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,16 +6,20 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.ExtImageInfo"/>.
|
||||
/// </summary>
|
||||
public sealed class ExtImageInfo : OpBase
|
||||
{
|
||||
internal ExtImageInfo(ITwainSessionInternal session) : base(session) { }
|
||||
public sealed class ExtImageInfo : OpBase
|
||||
{
|
||||
internal ExtImageInfo(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
|
||||
public ReturnCode Get(out TWExtImageInfo info)
|
||||
{
|
||||
Session.VerifyState(7, 7, DataGroups.Image, DataArgumentType.ExtImageInfo, Message.Get);
|
||||
info = new TWExtImageInfo();
|
||||
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, info);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// This operation is used by the application to query the data source for extended image attributes.
|
||||
/// The application is responsible for creating and disiposing the info object.
|
||||
/// </summary>
|
||||
/// <param name="info">The information.</param>
|
||||
/// <returns></returns>
|
||||
public ReturnCode Get(TWExtImageInfo info)
|
||||
{
|
||||
Session.VerifyState(7, 7, DataGroups.Image, DataArgumentType.ExtImageInfo, Message.Get);
|
||||
return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.Identity, Message.Reset, filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.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.CurrentSource.Identity, Message.Set, response);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.Identity, DataArgumentType.IccProfile, Message.Get, ref profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.Identity, DataGroups.Image, DataArgumentType.ImageFileXfer, Message.Get, ref z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,16 +6,15 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.ImageInfo"/>.
|
||||
/// </summary>
|
||||
public sealed class ImageInfo : OpBase
|
||||
{
|
||||
internal ImageInfo(ITwainSessionInternal session) : base(session) { }
|
||||
sealed class ImageInfo : OpBase
|
||||
{
|
||||
internal ImageInfo(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
|
||||
public ReturnCode Get(out TWImageInfo info)
|
||||
{
|
||||
Session.VerifyState(6, 7, DataGroups.Image, DataArgumentType.ImageInfo, Message.Get);
|
||||
info = new TWImageInfo();
|
||||
return Dsm.DsmEntry(Session.AppId, Session.SourceId, Message.Get, info);
|
||||
}
|
||||
}
|
||||
{
|
||||
Session.VerifyState(6, 7, DataGroups.Image, DataArgumentType.ImageInfo, Message.Get);
|
||||
info = new TWImageInfo();
|
||||
return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,34 +10,63 @@ namespace NTwain.Triplets
|
||||
{
|
||||
internal ImageLayout(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
/// <summary>
|
||||
/// Gets both the size and placement of the image on the scanner. The
|
||||
/// coordinates on the scanner and the extents of the image are expressed in the unit of measure
|
||||
/// currently negotiated for ICAP_UNITS (default is inches).
|
||||
/// </summary>
|
||||
/// <param name="layout">The layout.</param>
|
||||
/// <returns></returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
|
||||
public ReturnCode Get(out TWImageLayout layout)
|
||||
{
|
||||
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.CurrentSource.Identity, Message.Get, layout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns the default information on the layout of an image. This is the size and
|
||||
/// position of the image that will be acquired from the Source if the acquisition is started with the
|
||||
/// Source (and the device it is controlling) in its power-on state (for instance, most flatbed scanners
|
||||
/// will capture the entire bed).
|
||||
/// </summary>
|
||||
/// <param name="layout">The layout.</param>
|
||||
/// <returns></returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
|
||||
public ReturnCode GetDefault(out TWImageLayout layout)
|
||||
{
|
||||
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.CurrentSource.Identity, Message.GetDefault, layout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This operation sets the image layout information for the next transfer to its default settings.
|
||||
/// </summary>
|
||||
/// <param name="layout">The layout.</param>
|
||||
/// <returns></returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
|
||||
public ReturnCode Reset(out TWImageLayout layout)
|
||||
{
|
||||
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.CurrentSource.Identity, Message.Reset, layout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This operation sets the layout for the next image transfer. This allows the application to specify
|
||||
/// the physical area to be acquired during the next image transfer (for instance, a frame-based
|
||||
/// application would pass to the Source the size of the frame the user selected within the
|
||||
/// application—the helpful Source would present a selection region already sized to match the
|
||||
/// layout frame size).
|
||||
/// </summary>
|
||||
/// <param name="layout">The layout.</param>
|
||||
/// <returns></returns>
|
||||
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.CurrentSource.Identity, Message.Set, layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.Identity, Message.Get, xfer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.CurrentSource.Identity, Message.Get, xfer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.Identity, DataGroups.Image, DataArgumentType.ImageNativeXfer, Message.Get, ref handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.Identity, Message.Set, compression);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.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.CurrentSource.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.CurrentSource.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.CurrentSource.Identity, Message.Set, palette);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.CurrentSource.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.CurrentSource.Identity, Message.Set, response);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,39 +5,48 @@ namespace NTwain.Triplets
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataGroups.Image"/>.
|
||||
/// </summary>
|
||||
public sealed class DGImage
|
||||
{
|
||||
/// </summary>
|
||||
public sealed class DGImage
|
||||
{
|
||||
ITwainSessionInternal _session;
|
||||
internal DGImage(ITwainSessionInternal session)
|
||||
{
|
||||
if (session == null) { throw new ArgumentNullException("session"); }
|
||||
_session = session;
|
||||
}
|
||||
{
|
||||
if (session == null) { throw new ArgumentNullException("session"); }
|
||||
_session = session;
|
||||
}
|
||||
|
||||
CieColor _cieColor;
|
||||
public CieColor CieColor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cieColor == null) { _cieColor = new CieColor(_session); }
|
||||
return _cieColor;
|
||||
}
|
||||
}
|
||||
CieColor _cieColor;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_CIECOLOR.
|
||||
/// </summary>
|
||||
public CieColor CieColor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cieColor == null) { _cieColor = new CieColor(_session); }
|
||||
return _cieColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ExtImageInfo _extImgInfo;
|
||||
public ExtImageInfo ExtImageInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_extImgInfo == null) { _extImgInfo = new ExtImageInfo(_session); }
|
||||
return _extImgInfo;
|
||||
}
|
||||
ExtImageInfo _extImgInfo;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_EXTIMAGEINFO.
|
||||
/// </summary>
|
||||
public ExtImageInfo ExtImageInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_extImgInfo == null) { _extImgInfo = new ExtImageInfo(_session); }
|
||||
return _extImgInfo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Filter _filter;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_FILTER.
|
||||
/// </summary>
|
||||
public Filter Filter
|
||||
{
|
||||
get
|
||||
@@ -47,117 +56,135 @@ namespace NTwain.Triplets
|
||||
}
|
||||
}
|
||||
|
||||
GrayResponse _grayResponse;
|
||||
public GrayResponse GrayResponse
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_grayResponse == null) { _grayResponse = new GrayResponse(_session); }
|
||||
return _grayResponse;
|
||||
}
|
||||
}
|
||||
GrayResponse _grayResponse;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_GRAYRESPONSE.
|
||||
/// </summary>
|
||||
public GrayResponse GrayResponse
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_grayResponse == null) { _grayResponse = new GrayResponse(_session); }
|
||||
return _grayResponse;
|
||||
}
|
||||
}
|
||||
|
||||
IccProfile _iccProfile;
|
||||
public IccProfile IccProfile
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_iccProfile == null) { _iccProfile = new IccProfile(_session); }
|
||||
return _iccProfile;
|
||||
}
|
||||
}
|
||||
IccProfile _iccProfile;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_ICCPROFILE.
|
||||
/// </summary>
|
||||
public IccProfile IccProfile
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_iccProfile == null) { _iccProfile = new IccProfile(_session); }
|
||||
return _iccProfile;
|
||||
}
|
||||
}
|
||||
|
||||
ImageFileXfer _imgFileXfer;
|
||||
internal ImageFileXfer ImageFileXfer
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_imgFileXfer == null) { _imgFileXfer = new ImageFileXfer(_session); }
|
||||
return _imgFileXfer;
|
||||
}
|
||||
}
|
||||
ImageFileXfer _imgFileXfer;
|
||||
internal ImageFileXfer ImageFileXfer
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_imgFileXfer == null) { _imgFileXfer = new ImageFileXfer(_session); }
|
||||
return _imgFileXfer;
|
||||
}
|
||||
}
|
||||
|
||||
ImageInfo _imgInfo;
|
||||
public ImageInfo ImageInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_imgInfo == null) { _imgInfo = new ImageInfo(_session); }
|
||||
return _imgInfo;
|
||||
}
|
||||
}
|
||||
ImageInfo _imgInfo;
|
||||
internal ImageInfo ImageInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_imgInfo == null) { _imgInfo = new ImageInfo(_session); }
|
||||
return _imgInfo;
|
||||
}
|
||||
}
|
||||
|
||||
ImageLayout _imgLayout;
|
||||
public ImageLayout ImageLayout
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_imgLayout == null) { _imgLayout = new ImageLayout(_session); }
|
||||
return _imgLayout;
|
||||
}
|
||||
}
|
||||
ImageLayout _imgLayout;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_IMAGELAYOUT.
|
||||
/// </summary>
|
||||
public ImageLayout ImageLayout
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_imgLayout == null) { _imgLayout = new ImageLayout(_session); }
|
||||
return _imgLayout;
|
||||
}
|
||||
}
|
||||
|
||||
ImageMemFileXfer _imgMemFileXfer;
|
||||
internal ImageMemFileXfer ImageMemFileXfer
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_imgMemFileXfer == null) { _imgMemFileXfer = new ImageMemFileXfer(_session); }
|
||||
return _imgMemFileXfer;
|
||||
}
|
||||
}
|
||||
ImageMemFileXfer _imgMemFileXfer;
|
||||
internal ImageMemFileXfer ImageMemFileXfer
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_imgMemFileXfer == null) { _imgMemFileXfer = new ImageMemFileXfer(_session); }
|
||||
return _imgMemFileXfer;
|
||||
}
|
||||
}
|
||||
|
||||
ImageMemXfer _imgMemXfer;
|
||||
internal ImageMemXfer ImageMemXfer
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_imgMemXfer == null) { _imgMemXfer = new ImageMemXfer(_session); }
|
||||
return _imgMemXfer;
|
||||
}
|
||||
}
|
||||
ImageMemXfer _imgMemXfer;
|
||||
internal ImageMemXfer ImageMemXfer
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_imgMemXfer == null) { _imgMemXfer = new ImageMemXfer(_session); }
|
||||
return _imgMemXfer;
|
||||
}
|
||||
}
|
||||
|
||||
ImageNativeXfer _imgNativeXfer;
|
||||
internal ImageNativeXfer ImageNativeXfer
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_imgNativeXfer == null) { _imgNativeXfer = new ImageNativeXfer(_session); }
|
||||
return _imgNativeXfer;
|
||||
}
|
||||
}
|
||||
ImageNativeXfer _imgNativeXfer;
|
||||
internal ImageNativeXfer ImageNativeXfer
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_imgNativeXfer == null) { _imgNativeXfer = new ImageNativeXfer(_session); }
|
||||
return _imgNativeXfer;
|
||||
}
|
||||
}
|
||||
|
||||
JpegCompression _jpegComp;
|
||||
public JpegCompression JpegCompression
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_jpegComp == null) { _jpegComp = new JpegCompression(_session); }
|
||||
return _jpegComp;
|
||||
}
|
||||
}
|
||||
JpegCompression _jpegComp;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_JPEGCOMPRESSION.
|
||||
/// </summary>
|
||||
public JpegCompression JpegCompression
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_jpegComp == null) { _jpegComp = new JpegCompression(_session); }
|
||||
return _jpegComp;
|
||||
}
|
||||
}
|
||||
|
||||
Palette8 _palette8;
|
||||
public Palette8 Palette8
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_palette8 == null) { _palette8 = new Palette8(_session); }
|
||||
return _palette8;
|
||||
}
|
||||
}
|
||||
Palette8 _palette8;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_PALETTE8.
|
||||
/// </summary>
|
||||
public Palette8 Palette8
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_palette8 == null) { _palette8 = new Palette8(_session); }
|
||||
return _palette8;
|
||||
}
|
||||
}
|
||||
|
||||
RgbResponse _rgbResp;
|
||||
public RgbResponse RgbResponse
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_rgbResp == null) { _rgbResp = new RgbResponse(_session); }
|
||||
return _rgbResp;
|
||||
}
|
||||
}
|
||||
RgbResponse _rgbResp;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_RGBRESPONSE.
|
||||
/// </summary>
|
||||
public RgbResponse RgbResponse
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_rgbResp == null) { _rgbResp = new RgbResponse(_session); }
|
||||
return _rgbResp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -15,5 +15,9 @@ or better explained in code:
|
||||
|
||||
DGControl.Status.Get(...)
|
||||
|
||||
and that's the triplet at-a-glance. Only triplets used by the
|
||||
application are explicitly defined this way.
|
||||
and that's the triplet at-a-glance. Only triplets usable by the
|
||||
application-side are explicitly defined this way.
|
||||
|
||||
Also some of the operations are marked as internal when there are
|
||||
better wrapped managed version available. Goal is to
|
||||
eventually keep the exposed triplets to a minimum.
|
||||
@@ -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>
|
||||
@@ -39,6 +50,20 @@ namespace NTwain
|
||||
TWIdentity _appId;
|
||||
TWUserInterface _twui;
|
||||
|
||||
static readonly Dictionary<string, TwainSource> __ownedSources = new Dictionary<string, TwainSource>();
|
||||
|
||||
internal static TwainSource GetSourceInstance(ITwainSessionInternal session, TWIdentity sourceId)
|
||||
{
|
||||
var key = string.Format(CultureInfo.InvariantCulture, "{0}|{1}|{2}", sourceId.Manufacturer, sourceId.ProductFamily, sourceId.ProductName);
|
||||
if (__ownedSources.ContainsKey(key))
|
||||
{
|
||||
return __ownedSources[key];
|
||||
}
|
||||
return __ownedSources[key] = new TwainSource(session, sourceId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional synchronization context.
|
||||
/// This allows events to be raised on the thread
|
||||
@@ -81,9 +106,9 @@ namespace NTwain
|
||||
return new TentativeStateCommitable(this, newState);
|
||||
}
|
||||
|
||||
void ITwainSessionInternal.ChangeSourceId(TWIdentity sourceId)
|
||||
void ITwainSessionInternal.ChangeSourceId(TwainSource source)
|
||||
{
|
||||
SourceId = sourceId;
|
||||
CurrentSource = source;
|
||||
OnPropertyChanged("SourceId");
|
||||
SafeAsyncSyncableRaiseOnEvent(OnSourceChanged, SourceChanged);
|
||||
}
|
||||
@@ -106,12 +131,55 @@ 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 CurrentSource { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default source for this application.
|
||||
/// While this can be get as long as the session is open,
|
||||
/// it can only be set at State 3.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The default source.
|
||||
/// </value>
|
||||
public TwainSource DefaultSource
|
||||
{
|
||||
get
|
||||
{
|
||||
TWIdentity id;
|
||||
if (DGControl.Identity.GetDefault(out id) == ReturnCode.Success)
|
||||
{
|
||||
return GetSourceInstance(this, id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
DGControl.Identity.Set(value.Identity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try to show the built-in source selector dialog and return the selected source.
|
||||
/// This is not recommended and is only included for completeness.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public TwainSource ShowSourceSelector()
|
||||
{
|
||||
TWIdentity id;
|
||||
if (DGControl.Identity.UserSelect(out id) == ReturnCode.Success)
|
||||
{
|
||||
return GetSourceInstance(this, id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
int _state;
|
||||
/// <summary>
|
||||
@@ -134,33 +202,6 @@ namespace NTwain
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static readonly CapabilityId[] _emptyCapList = new CapabilityId[0];
|
||||
|
||||
private IList<CapabilityId> _supportedCaps;
|
||||
/// <summary>
|
||||
/// Gets the supported caps for the currently open source.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The supported caps.
|
||||
/// </value>
|
||||
public IList<CapabilityId> SupportedCaps
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_supportedCaps == null && State > 3)
|
||||
{
|
||||
_supportedCaps = this.GetCapabilities();
|
||||
}
|
||||
return _supportedCaps ?? _emptyCapList;
|
||||
}
|
||||
private set
|
||||
{
|
||||
_supportedCaps = value;
|
||||
OnPropertyChanged("SupportedCaps");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ITwainOperation Members
|
||||
@@ -216,6 +257,99 @@ namespace NTwain
|
||||
return _dgCustom;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Opens the data source manager. This must be the first method used
|
||||
/// before using other TWAIN functions. Calls to this must be followed by <see cref="Close"/> when done with a TWAIN session.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ReturnCode Open()
|
||||
{
|
||||
var rc = ReturnCode.Failure;
|
||||
MessageLoop.Instance.Invoke(() =>
|
||||
{
|
||||
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: OpenManager.", Thread.CurrentThread.ManagedThreadId));
|
||||
|
||||
rc = DGControl.Parent.OpenDsm(MessageLoop.Instance.LoopHandle);
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
// if twain2 then get memory management functions
|
||||
if ((_appId.DataFunctionalities & DataFunctionalities.Dsm2) == DataFunctionalities.Dsm2)
|
||||
{
|
||||
TWEntryPoint entry;
|
||||
rc = DGControl.EntryPoint.Get(out entry);
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
Platform.MemoryManager = entry;
|
||||
Debug.WriteLine("Using TWAIN2 memory functions.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return rc;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the data source manager.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ReturnCode Close()
|
||||
{
|
||||
var rc = ReturnCode.Failure;
|
||||
MessageLoop.Instance.Invoke(() =>
|
||||
{
|
||||
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: CloseManager.", Thread.CurrentThread.ManagedThreadId));
|
||||
|
||||
rc = DGControl.Parent.CloseDsm(MessageLoop.Instance.LoopHandle);
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
Platform.MemoryManager = null;
|
||||
}
|
||||
});
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets list of sources available in the system.
|
||||
/// Only call this at state 2 or higher.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<TwainSource> GetSources()
|
||||
{
|
||||
TWIdentity srcId;
|
||||
var rc = DGControl.Identity.GetFirst(out srcId);
|
||||
while (rc == ReturnCode.Success)
|
||||
{
|
||||
yield return GetSourceInstance(this, srcId);
|
||||
rc = DGControl.Identity.GetNext(out srcId);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the manager status. Only call this at state 2 or higher.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public TWStatus GetStatus()
|
||||
{
|
||||
TWStatus stat;
|
||||
DGControl.Status.GetManager(out stat);
|
||||
return stat;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the manager status. Only call this at state 3 or higher.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public TWStatusUtf8 GetStatusUtf8()
|
||||
{
|
||||
TWStatusUtf8 stat;
|
||||
DGControl.StatusUtf8.GetManager(out stat);
|
||||
return stat;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -260,110 +394,6 @@ namespace NTwain
|
||||
|
||||
#region privileged calls that causes state change in TWAIN
|
||||
|
||||
/// <summary>
|
||||
/// Opens the data source manager. This must be the first method used
|
||||
/// before using other TWAIN functions. Calls to this must be followed by <see cref="CloseManager"/> when done with a TWAIN session.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ReturnCode OpenManager()
|
||||
{
|
||||
var rc = ReturnCode.Failure;
|
||||
MessageLoop.Instance.Invoke(() =>
|
||||
{
|
||||
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: OpenManager.", Thread.CurrentThread.ManagedThreadId));
|
||||
|
||||
rc = DGControl.Parent.OpenDsm(MessageLoop.Instance.LoopHandle);
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
// if twain2 then get memory management functions
|
||||
if ((_appId.DataFunctionalities & DataFunctionalities.Dsm2) == DataFunctionalities.Dsm2)
|
||||
{
|
||||
TWEntryPoint entry;
|
||||
rc = DGControl.EntryPoint.Get(out entry);
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
Platform.MemoryManager = entry;
|
||||
Debug.WriteLine("Using TWAIN2 memory functions.");
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return rc;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the data source manager.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ReturnCode CloseManager()
|
||||
{
|
||||
var rc = ReturnCode.Failure;
|
||||
MessageLoop.Instance.Invoke(() =>
|
||||
{
|
||||
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: CloseManager.", Thread.CurrentThread.ManagedThreadId));
|
||||
|
||||
rc = DGControl.Parent.CloseDsm(MessageLoop.Instance.LoopHandle);
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
Platform.MemoryManager = null;
|
||||
}
|
||||
});
|
||||
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 +402,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;
|
||||
|
||||
@@ -486,13 +516,13 @@ namespace NTwain
|
||||
{
|
||||
((ITwainSessionInternal)this).DisableSource();
|
||||
}
|
||||
if (targetState < 4)
|
||||
if (targetState < 4 && CurrentSource != null)
|
||||
{
|
||||
CloseSource();
|
||||
CurrentSource.Close();
|
||||
}
|
||||
if (targetState < 3)
|
||||
{
|
||||
CloseManager();
|
||||
Close();
|
||||
}
|
||||
});
|
||||
EnforceState = origFlag;
|
||||
@@ -507,7 +537,7 @@ namespace NTwain
|
||||
/// </summary>
|
||||
public event EventHandler StateChanged;
|
||||
/// <summary>
|
||||
/// Occurs when <see cref="SourceId"/> has changed.
|
||||
/// Occurs when <see cref="CurrentSource"/> has changed.
|
||||
/// </summary>
|
||||
public event EventHandler SourceChanged;
|
||||
/// <summary>
|
||||
@@ -608,7 +638,7 @@ namespace NTwain
|
||||
protected virtual void OnStateChanged() { }
|
||||
|
||||
/// <summary>
|
||||
/// Called when <see cref="SourceId"/> changed.
|
||||
/// Called when <see cref="CurrentSource"/> changed.
|
||||
/// </summary>
|
||||
protected virtual void OnSourceChanged() { }
|
||||
|
||||
@@ -676,7 +706,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 && CurrentSource != null && origin.Id == CurrentSource.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.
|
||||
|
||||
@@ -2,89 +2,26 @@
|
||||
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 CapQuerySupport(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);
|
||||
var read = CapabilityReader.ReadValue(cap);
|
||||
|
||||
if (read.ContainerType == ContainerType.OneValue)
|
||||
{
|
||||
@@ -98,19 +35,16 @@ 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 CapGetCurrent(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);
|
||||
var read = CapabilityReader.ReadValue(cap);
|
||||
|
||||
switch (read.ContainerType)
|
||||
{
|
||||
@@ -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> CapGetValues(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,16 @@ 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 CapGetValues(CapabilityId.ICapXferMech).CastToEnum<XferMech>(true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -237,28 +111,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 CapGetValues(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 +138,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 CapGetValues(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 +165,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 CapGetValues(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 +195,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 CapGetValues(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 CapGetValues(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 +251,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 = CapGetValues(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 +303,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 CapGetValues(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 +334,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 +351,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 +362,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 +373,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 +389,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 +400,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 +410,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 +428,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 +443,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 +457,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 +471,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 +482,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 +490,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 +512,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 +543,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 +568,5 @@ namespace NTwain
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
226
NTwain/TwainSource.cs
Normal file
226
NTwain/TwainSource.cs
Normal file
@@ -0,0 +1,226 @@
|
||||
using NTwain.Data;
|
||||
using NTwain.Internals;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace NTwain
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a TWAIN data source.
|
||||
/// </summary>
|
||||
public partial class TwainSource : INotifyPropertyChanged
|
||||
{
|
||||
ITwainSessionInternal _session;
|
||||
|
||||
internal TwainSource(ITwainSessionInternal session, TWIdentity sourceId)
|
||||
{
|
||||
_session = session;
|
||||
Identity = sourceId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens the source for capability negotiation.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ReturnCode Open()
|
||||
{
|
||||
var rc = ReturnCode.Failure;
|
||||
MessageLoop.Instance.Invoke(() =>
|
||||
{
|
||||
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: OpenSource.", Thread.CurrentThread.ManagedThreadId));
|
||||
|
||||
rc = _session.DGControl.Identity.OpenDS(this);
|
||||
});
|
||||
return rc;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the source.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ReturnCode Close()
|
||||
{
|
||||
var rc = ReturnCode.Failure;
|
||||
MessageLoop.Instance.Invoke(() =>
|
||||
{
|
||||
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: CloseSource.", Thread.CurrentThread.ManagedThreadId));
|
||||
|
||||
rc = _session.DGControl.Identity.CloseDS();
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
SupportedCaps = null;
|
||||
}
|
||||
});
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/// <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>
|
||||
public ReturnCode StartTransfer(SourceEnableMode mode, bool modal, IntPtr windowHandle)
|
||||
{
|
||||
return _session.EnableSource(mode, modal, windowHandle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the source status. Only call this at state 4 or higher.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public TWStatus GetStatus()
|
||||
{
|
||||
TWStatus stat;
|
||||
_session.DGControl.Status.GetSource(out stat);
|
||||
return stat;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the source status. Only call this at state 4 or higher.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public TWStatusUtf8 GetStatusUtf8()
|
||||
{
|
||||
TWStatusUtf8 stat;
|
||||
_session.DGControl.StatusUtf8.GetSource(out stat);
|
||||
return stat;
|
||||
}
|
||||
|
||||
|
||||
#region properties
|
||||
|
||||
internal TWIdentity Identity { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the source's product name.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The name.
|
||||
/// </value>
|
||||
public string Name { get { return Identity.ProductName; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the source's manufacturer name.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The manufacturer.
|
||||
/// </value>
|
||||
public string Manufacturer { get { return Identity.Manufacturer; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the source's product family.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The product family.
|
||||
/// </value>
|
||||
public string ProductFamily { get { return Identity.ProductFamily; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the version information.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The version.
|
||||
/// </value>
|
||||
public TWVersion Version { get { return Identity.Version; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the supported data group.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The data group.
|
||||
/// </value>
|
||||
public DataGroups DataGroup { get { return Identity.DataGroup; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the supported TWAIN protocol major number.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The protocol major number.
|
||||
/// </value>
|
||||
public int ProtocolMajor { get { return Identity.ProtocolMajor; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the supported TWAIN protocol minor number.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The protocol minor number.
|
||||
/// </value>
|
||||
public int ProtocolMinor { get { return Identity.ProtocolMinor; } }
|
||||
|
||||
|
||||
static readonly CapabilityId[] _emptyCapList = new CapabilityId[0];
|
||||
|
||||
private IList<CapabilityId> _supportedCaps;
|
||||
/// <summary>
|
||||
/// Gets the supported caps for this source.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The supported caps.
|
||||
/// </value>
|
||||
public IList<CapabilityId> SupportedCaps
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_supportedCaps == null && _session.State > 3)
|
||||
{
|
||||
_supportedCaps = CapGetValues(CapabilityId.CapSupportedCaps).CastToEnum<CapabilityId>(false);
|
||||
}
|
||||
return _supportedCaps ?? _emptyCapList;
|
||||
}
|
||||
private set
|
||||
{
|
||||
_supportedCaps = value;
|
||||
OnPropertyChanged("SupportedCaps");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a property value changes.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="PropertyChanged"/> event.
|
||||
/// </summary>
|
||||
/// <param name="propertyName">Name of the property.</param>
|
||||
protected void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
var syncer = _session.SynchronizationContext;
|
||||
if (syncer == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var hand = PropertyChanged;
|
||||
if (hand != null) { hand(this, new PropertyChangedEventArgs(propertyName)); }
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
else
|
||||
{
|
||||
syncer.Post(o =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var hand = PropertyChanged;
|
||||
if (hand != null) { hand(this, new PropertyChangedEventArgs(propertyName)); }
|
||||
}
|
||||
catch { }
|
||||
}, null);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -38,28 +38,28 @@ namespace Tester
|
||||
Console.WriteLine("Getting ready to do twain stuff on thread {0}.", Thread.CurrentThread.ManagedThreadId);
|
||||
Thread.Sleep(1000);
|
||||
|
||||
var rc = twain.OpenManager();
|
||||
var rc = twain.Open();
|
||||
|
||||
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.");
|
||||
twain.CloseManager();
|
||||
twain.Close();
|
||||
}
|
||||
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
|
||||
{
|
||||
twain.CloseManager();
|
||||
twain.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,8 +72,8 @@ namespace Tester
|
||||
static void twain_SourceDisabled(object sender, EventArgs e)
|
||||
{
|
||||
Console.WriteLine("Source disabled on thread {0}.", Thread.CurrentThread.ManagedThreadId);
|
||||
var rc = twain.CloseSource();
|
||||
rc = twain.CloseManager();
|
||||
var rc = twain.CurrentSource.Close();
|
||||
rc = twain.Close();
|
||||
}
|
||||
|
||||
static void twain_TransferReady(object sender, TransferReadyEventArgs e)
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Tester.WPF
|
||||
{
|
||||
if (_twainVM.State == 4)
|
||||
{
|
||||
_twainVM.CloseSource();
|
||||
_twainVM.CurrentSource.Close();
|
||||
}
|
||||
base.OnClosed(e);
|
||||
}
|
||||
@@ -65,7 +65,7 @@ namespace Tester.WPF
|
||||
{
|
||||
base.OnSourceInitialized(e);
|
||||
|
||||
var rc = _twainVM.OpenManager();
|
||||
var rc = _twainVM.Open();
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
SrcList.ItemsSource = _twainVM.GetSources().Select(s => new DSVM { DS = s });
|
||||
@@ -80,20 +80,20 @@ namespace Tester.WPF
|
||||
{
|
||||
if (_twainVM.State == 4)
|
||||
{
|
||||
_twainVM.CloseSource();
|
||||
_twainVM.CurrentSource.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.CapQuerySupport(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.CurrentSource.CapGetValues(cap).CastToEnum<XferMech>();
|
||||
break;
|
||||
case CapabilityId.CapAlarms:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<AlarmType>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<AlarmType>();
|
||||
break;
|
||||
case CapabilityId.CapAlarmVolume:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapAuthor:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapAutoFeed:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapAutomaticCapture:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapAutomaticSenseMedium:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapAutoScan:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapBatteryMinutes:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapBatteryPercentage:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapCameraEnabled:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapCameraOrder:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapCameraPreviewUI:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapCameraSide:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<CameraSide>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<CameraSide>();
|
||||
break;
|
||||
case CapabilityId.CapCaption:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapClearBuffers:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<ClearBuffer>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<ClearBuffer>();
|
||||
break;
|
||||
case CapabilityId.CapClearPage:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapCustomDSData:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapCustomInterfaceGuid:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapDeviceEvent:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<DeviceEvent>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<DeviceEvent>();
|
||||
break;
|
||||
case CapabilityId.CapDeviceOnline:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapDeviceTimeDate:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapDoubleFeedDetection:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<DoubleFeedDetection>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<DoubleFeedDetection>();
|
||||
break;
|
||||
case CapabilityId.CapDoubleFeedDetectionLength:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapDoubleFeedDetectionResponse:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<DoubleFeedDetectionResponse>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<DoubleFeedDetectionResponse>();
|
||||
break;
|
||||
case CapabilityId.CapDoubleFeedDetectionSensitivity:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<DoubleFeedDetectionSensitivity>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<DoubleFeedDetectionSensitivity>();
|
||||
break;
|
||||
case CapabilityId.CapDuplex:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<Duplex>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<Duplex>();
|
||||
break;
|
||||
case CapabilityId.CapDuplexEnabled:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapEnableDSUIOnly:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapEndorser:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapExtendedCaps:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapFeederAlignment:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<FeederAlignment>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<FeederAlignment>();
|
||||
break;
|
||||
case CapabilityId.CapFeederEnabled:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapFeederLoaded:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapFeederOrder:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<FeederOrder>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<FeederOrder>();
|
||||
break;
|
||||
case CapabilityId.CapFeederPocket:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<FeederPocket>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<FeederPocket>();
|
||||
break;
|
||||
case CapabilityId.CapFeederPrep:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapFeedPage:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapIndicators:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapIndicatorsMode:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<IndicatorsMode>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<IndicatorsMode>();
|
||||
break;
|
||||
case CapabilityId.CapJobControl:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<JobControl>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<JobControl>();
|
||||
break;
|
||||
case CapabilityId.CapLanguage:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<Language>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<Language>();
|
||||
break;
|
||||
case CapabilityId.CapMaxBatchBuffers:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapMicrEnabled:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapPaperDetectable:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapPaperHandling:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PaperHandling>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<PaperHandling>();
|
||||
break;
|
||||
case CapabilityId.CapPowerSaveTime:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapPowerSupply:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PowerSupply>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<PowerSupply>();
|
||||
break;
|
||||
case CapabilityId.CapPrinter:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<Printer>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<Printer>();
|
||||
break;
|
||||
case CapabilityId.CapPrinterCharRotation:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapPrinterEnabled:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapPrinterFontStyle:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PrinterFontStyle>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<PrinterFontStyle>();
|
||||
break;
|
||||
case CapabilityId.CapPrinterIndex:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapPrinterIndexLeadChar:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapPrinterIndexMaxValue:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapPrinterIndexNumDigits:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapPrinterIndexStep:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapPrinterIndexTrigger:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PrinterIndexTrigger>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<PrinterIndexTrigger>();
|
||||
break;
|
||||
case CapabilityId.CapPrinterMode:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PrinterMode>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<PrinterMode>();
|
||||
break;
|
||||
case CapabilityId.CapPrinterString:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapPrinterStringPreview:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapPrinterSuffix:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapPrinterVerticalOffset:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapReacquireAllowed:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapRewindPage:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapSegmented:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<Segmented>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<Segmented>();
|
||||
break;
|
||||
case CapabilityId.CapSerialNumber:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapSupportedCaps:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<CapabilityId>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<CapabilityId>();
|
||||
break;
|
||||
case CapabilityId.CapSupportedCapsSegmentUnique:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapSupportedDATs:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapThumbnailsEnabled:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapTimeBeforeFirstCapture:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapTimeBetweenCaptures:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapTimeDate:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapUIControllable:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CapXferCount:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.CustomBase:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapAutoBright:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapAutoDiscardBlankPages:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapAutomaticBorderDetection:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapAutomaticColorEnabled:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapAutomaticColorNonColorPixelType:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PixelType>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<PixelType>();
|
||||
break;
|
||||
case CapabilityId.ICapAutomaticCropUsesFrame:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapAutomaticDeskew:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapAutomaticLengthDetection:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapAutomaticRotate:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapAutoSize:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapBarcodeDetectionEnabled:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapBarcodeMaxRetries:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapBarcodeMaxSearchPriorities:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapBarcodeSearchMode:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapBarcodeSearchPriorities:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapBarcodeTimeout:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapBitDepth:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapBitDepthReduction:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<BitDepthReduction>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<BitDepthReduction>();
|
||||
break;
|
||||
case CapabilityId.ICapBitOrder:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<BitOrder>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<BitOrder>();
|
||||
break;
|
||||
case CapabilityId.ICapBitOrderCodes:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapBrightness:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapCCITTKFactor:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapColorManagementEnabled:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapCompression:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<CompressionType>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<CompressionType>();
|
||||
break;
|
||||
case CapabilityId.ICapContrast:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapCustHalftone:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapExposureTime:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapExtImageInfo:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapFeederType:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<FeederType>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<FeederType>();
|
||||
break;
|
||||
case CapabilityId.ICapFilmType:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<FilmType>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<FilmType>();
|
||||
break;
|
||||
case CapabilityId.ICapFilter:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<FilterType>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<FilterType>();
|
||||
break;
|
||||
case CapabilityId.ICapFlashUsed:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapFlashUsed2:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapFlipRotation:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<FlipRotation>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<FlipRotation>();
|
||||
break;
|
||||
case CapabilityId.ICapFrames:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapGamma:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapHalftones:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapHighlight:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapICCProfile:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<IccProfile>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<IccProfile>();
|
||||
break;
|
||||
case CapabilityId.ICapImageDataSet:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapImageFileFormat:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<FileFormat>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<FileFormat>();
|
||||
break;
|
||||
case CapabilityId.ICapImageFilter:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<ImageFilter>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<ImageFilter>();
|
||||
break;
|
||||
case CapabilityId.ICapImageMerge:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<ImageMerge>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<ImageMerge>();
|
||||
break;
|
||||
case CapabilityId.ICapImageMergeHeightThreshold:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapJpegPixelType:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PixelType>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<PixelType>();
|
||||
break;
|
||||
case CapabilityId.ICapJpegQuality:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<JpegQuality>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<JpegQuality>();
|
||||
break;
|
||||
case CapabilityId.ICapJpegSubsampling:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<JpegSubsampling>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<JpegSubsampling>();
|
||||
break;
|
||||
case CapabilityId.ICapLampState:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapLightPath:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<LightPath>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<LightPath>();
|
||||
break;
|
||||
case CapabilityId.ICapLightSource:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<LightSource>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<LightSource>();
|
||||
break;
|
||||
case CapabilityId.ICapMaxFrames:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapMinimumHeight:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapMinimumWidth:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapMirror:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<Mirror>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<Mirror>();
|
||||
break;
|
||||
case CapabilityId.ICapNoiseFilter:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<NoiseFilter>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<NoiseFilter>();
|
||||
break;
|
||||
case CapabilityId.ICapOrientation:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<OrientationType>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<OrientationType>();
|
||||
break;
|
||||
case CapabilityId.ICapOverScan:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<OverScan>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<OverScan>();
|
||||
break;
|
||||
case CapabilityId.ICapPatchCodeDetectionEnabled:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapPatchCodeMaxRetries:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapPatchCodeMaxSearchPriorities:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PatchCode>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<PatchCode>();
|
||||
break;
|
||||
case CapabilityId.ICapPatchCodeSearchMode:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapPatchCodeSearchPriorities:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapPatchCodeTimeout:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
// TODO phys size are twfix32
|
||||
case CapabilityId.ICapPhysicalHeight:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapPhysicalWidth:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapPixelFlavor:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PixelFlavor>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<PixelFlavor>();
|
||||
break;
|
||||
case CapabilityId.ICapPixelFlavorCodes:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapPixelType:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PixelType>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<PixelType>();
|
||||
break;
|
||||
case CapabilityId.ICapPlanarChunky:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PlanarChunky>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<PlanarChunky>();
|
||||
break;
|
||||
case CapabilityId.ICapRotation:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<Rotation>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<Rotation>();
|
||||
break;
|
||||
case CapabilityId.ICapShadow:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapSupportedBarcodeTypes:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<BarcodeType>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<BarcodeType>();
|
||||
break;
|
||||
case CapabilityId.ICapSupportedExtImageInfo:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<ExtendedImageInfo>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<ExtendedImageInfo>();
|
||||
break;
|
||||
case CapabilityId.ICapSupportedPatchCodeTypes:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<PatchCode>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<PatchCode>();
|
||||
break;
|
||||
case CapabilityId.ICapSupportedSizes:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<SupportedSize>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<SupportedSize>();
|
||||
break;
|
||||
case CapabilityId.ICapThreshold:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapTiles:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapTimeFill:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapUndefinedImageSize:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapUnits:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<Unit>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<Unit>();
|
||||
break;
|
||||
case CapabilityId.ICapXferMech:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<XferMech>();
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap).CastToEnum<XferMech>();
|
||||
break;
|
||||
case CapabilityId.ICapXNativeResolution:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapXResolution:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapXScaling:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapYNativeResolution:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapYResolution:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapYScaling:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
case CapabilityId.ICapZoomFactor:
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
break;
|
||||
default:
|
||||
if (cap > CapabilityId.CustomBase)
|
||||
{
|
||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
|
||||
CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGetValues(cap);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -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); } }
|
||||
}
|
||||
|
||||
@@ -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.CurrentSource.CapGetCurrent(CapabilityId.ICapXferMech).ConvertToEnum<XferMech>() == XferMech.File)
|
||||
{
|
||||
var formats = this.CapGetImageFileFormat();
|
||||
var formats = this.CurrentSource.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.CurrentSource.CapGetPixelTypes().Contains(PixelType.BlackWhite))
|
||||
{
|
||||
this.CapSetPixelType(PixelType.BlackWhite);
|
||||
this.CurrentSource.CapSetPixelType(PixelType.BlackWhite);
|
||||
}
|
||||
|
||||
if (this.CapGetImageXferMechs().Contains(XferMech.File))
|
||||
if (this.CurrentSource.CapGetImageXferMechs().Contains(XferMech.File))
|
||||
{
|
||||
this.CapSetImageXferMech(XferMech.File);
|
||||
this.CurrentSource.CapSetImageXferMech(XferMech.File);
|
||||
}
|
||||
|
||||
var rc = EnableSource(SourceEnableMode.NoUI, false, hwnd);
|
||||
var rc = this.CurrentSource.StartTransfer(SourceEnableMode.NoUI, false, hwnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,11 +107,11 @@ namespace Tester.Winform
|
||||
{
|
||||
if (_twain.State == 4)
|
||||
{
|
||||
_twain.CloseSource();
|
||||
_twain.CurrentSource.Close();
|
||||
}
|
||||
if (_twain.State == 3)
|
||||
{
|
||||
_twain.CloseManager();
|
||||
_twain.Close();
|
||||
}
|
||||
|
||||
if (_twain.State > 2)
|
||||
@@ -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.CurrentSource.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.CurrentSource.SupportedCaps.Contains(CapabilityId.CapUIControllable))
|
||||
{
|
||||
// hide scanner ui if possible
|
||||
if (_twain.EnableSource(SourceEnableMode.NoUI, false, this.Handle) == ReturnCode.Success)
|
||||
if (_twain.CurrentSource.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.CurrentSource.StartTransfer(SourceEnableMode.ShowUI, true, this.Handle) == ReturnCode.Success)
|
||||
{
|
||||
btnStopScan.Enabled = true;
|
||||
btnStartCapture.Enabled = false;
|
||||
@@ -239,7 +239,7 @@ namespace Tester.Winform
|
||||
}
|
||||
if (_twain.State < 3)
|
||||
{
|
||||
_twain.OpenManager();
|
||||
_twain.Open();
|
||||
}
|
||||
|
||||
if (_twain.State >= 3)
|
||||
@@ -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.CurrentSource != null && _twain.CurrentSource.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.CurrentSource.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.CurrentSource.CapGetSupportedSizes();
|
||||
comboSize.DataSource = list;
|
||||
var cur = _twain.GetCurrentCap(CapabilityId.ICapSupportedSizes).ConvertToEnum<SupportedSize>();
|
||||
var cur = _twain.CurrentSource.CapGetCurrent(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.CurrentSource.CapGetCurrent(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.CurrentSource.CapGetDPIs().Where(dpi => (dpi % 50) == 0).ToList();
|
||||
comboDPI.DataSource = list;
|
||||
var cur = (TWFix32)_twain.GetCurrentCap(CapabilityId.ICapXResolution);
|
||||
var cur = (TWFix32)_twain.CurrentSource.CapGetCurrent(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.CurrentSource.CapGetPixelTypes();
|
||||
comboDepth.DataSource = list;
|
||||
var cur = _twain.GetCurrentCap(CapabilityId.ICapPixelType).ConvertToEnum<PixelType>();
|
||||
var cur = _twain.CurrentSource.CapGetCurrent(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.CurrentSource.CapSetSupportedSize(sel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ namespace Tester.Winform
|
||||
if (!_loadingCaps && _twain.State == 4)
|
||||
{
|
||||
var sel = (PixelType)comboDepth.SelectedItem;
|
||||
_twain.CapSetPixelType(sel);
|
||||
_twain.CurrentSource.CapSetPixelType(sel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ namespace Tester.Winform
|
||||
if (!_loadingCaps && _twain.State == 4)
|
||||
{
|
||||
var sel = (TWFix32)comboDPI.SelectedItem;
|
||||
_twain.CapSetDPI(sel);
|
||||
_twain.CurrentSource.CapSetDPI(sel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,13 +360,13 @@ namespace Tester.Winform
|
||||
{
|
||||
if (!_loadingCaps && _twain.State == 4)
|
||||
{
|
||||
_twain.CapSetDuplex(ckDuplex.Checked);
|
||||
_twain.CurrentSource.CapSetDuplex(ckDuplex.Checked);
|
||||
}
|
||||
}
|
||||
|
||||
private void btnAllSettings_Click(object sender, EventArgs e)
|
||||
{
|
||||
_twain.EnableSource(SourceEnableMode.ShowUIOnly, true, this.Handle);
|
||||
_twain.CurrentSource.StartTransfer(SourceEnableMode.ShowUIOnly, true, this.Handle);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user