mirror of
https://github.com/soukoku/ntwain.git
synced 2025-04-05 20:59:23 +08:00
Some refactor ideas
This commit is contained in:
parent
4fa3e77fba
commit
67c6705224
@ -1,7 +1,9 @@
|
||||
using NTwain.Properties;
|
||||
using NTwain.Values;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Permissions;
|
||||
using System.Text;
|
||||
@ -663,7 +665,7 @@ namespace NTwain.Data
|
||||
var value = new TWOneValue();
|
||||
if (_hContainer != IntPtr.Zero)
|
||||
{
|
||||
IntPtr baseAddr = MemoryManager.Global.MemLock(_hContainer);
|
||||
IntPtr baseAddr = MemoryManager.Instance.MemLock(_hContainer);
|
||||
try
|
||||
{
|
||||
int offset = 0;
|
||||
@ -672,7 +674,7 @@ namespace NTwain.Data
|
||||
value.Item = (uint)ReadValue(baseAddr, ref offset, ItemType.UInt32);
|
||||
}
|
||||
catch { }
|
||||
MemoryManager.Global.MemUnlock(_hContainer);
|
||||
MemoryManager.Instance.MemUnlock(_hContainer);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@ -686,7 +688,7 @@ namespace NTwain.Data
|
||||
// since one value can only house UInt32 we will not allow type size > 4
|
||||
if (GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException("Invalid one value type"); }
|
||||
|
||||
_hContainer = MemoryManager.Global.MemAllocate((uint)Marshal.SizeOf(value));
|
||||
_hContainer = MemoryManager.Instance.MemAllocate((uint)Marshal.SizeOf(value));
|
||||
if (_hContainer != IntPtr.Zero)
|
||||
{
|
||||
Marshal.StructureToPtr(value, _hContainer, false);
|
||||
@ -705,7 +707,7 @@ namespace NTwain.Data
|
||||
var value = new TWArray();
|
||||
if (_hContainer != IntPtr.Zero)
|
||||
{
|
||||
IntPtr baseAddr = MemoryManager.Global.MemLock(_hContainer);
|
||||
IntPtr baseAddr = MemoryManager.Instance.MemLock(_hContainer);
|
||||
int offset = 0;
|
||||
value.ItemType = (ItemType)(ushort)Marshal.ReadInt16(baseAddr, offset);
|
||||
offset += 2;
|
||||
@ -719,7 +721,7 @@ namespace NTwain.Data
|
||||
value.ItemList[i] = ReadValue(baseAddr, ref offset, value.ItemType);
|
||||
}
|
||||
}
|
||||
MemoryManager.Global.MemUnlock(_hContainer);
|
||||
MemoryManager.Instance.MemUnlock(_hContainer);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@ -736,7 +738,7 @@ namespace NTwain.Data
|
||||
var value = new TWEnumeration();
|
||||
if (_hContainer != IntPtr.Zero)
|
||||
{
|
||||
IntPtr baseAddr = MemoryManager.Global.MemLock(_hContainer);
|
||||
IntPtr baseAddr = MemoryManager.Instance.MemLock(_hContainer);
|
||||
int offset = 0;
|
||||
value.ItemType = (ItemType)(ushort)Marshal.ReadInt16(baseAddr, offset);
|
||||
offset += 2;
|
||||
@ -754,7 +756,7 @@ namespace NTwain.Data
|
||||
value.ItemList[i] = ReadValue(baseAddr, ref offset, value.ItemType);
|
||||
}
|
||||
}
|
||||
MemoryManager.Global.MemUnlock(_hContainer);
|
||||
MemoryManager.Instance.MemUnlock(_hContainer);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@ -768,8 +770,8 @@ namespace NTwain.Data
|
||||
Int32 valueSize = value.ItemOffset + value.ItemList.Length * GetItemTypeSize(value.ItemType);
|
||||
|
||||
int offset = 0;
|
||||
_hContainer = MemoryManager.Global.MemAllocate((uint)valueSize);
|
||||
IntPtr baseAddr = MemoryManager.Global.MemLock(_hContainer);
|
||||
_hContainer = MemoryManager.Instance.MemAllocate((uint)valueSize);
|
||||
IntPtr baseAddr = MemoryManager.Instance.MemLock(_hContainer);
|
||||
|
||||
// can't safely use StructureToPtr here so write it our own
|
||||
WriteValue(baseAddr, ref offset, ItemType.UInt16, value.ItemType);
|
||||
@ -780,7 +782,7 @@ namespace NTwain.Data
|
||||
{
|
||||
WriteValue(baseAddr, ref offset, value.ItemType, item);
|
||||
}
|
||||
MemoryManager.Global.MemUnlock(_hContainer);
|
||||
MemoryManager.Instance.MemUnlock(_hContainer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -795,7 +797,7 @@ namespace NTwain.Data
|
||||
var value = new TWRange();
|
||||
if (_hContainer != IntPtr.Zero)
|
||||
{
|
||||
IntPtr baseAddr = MemoryManager.Global.MemLock(_hContainer);
|
||||
IntPtr baseAddr = MemoryManager.Instance.MemLock(_hContainer);
|
||||
|
||||
int offset = 0;
|
||||
value.ItemType = (ItemType)(ushort)Marshal.ReadInt16(baseAddr, offset);
|
||||
@ -810,7 +812,7 @@ namespace NTwain.Data
|
||||
offset += 4;
|
||||
value.CurrentValue = (uint)Marshal.ReadInt32(baseAddr, offset);
|
||||
|
||||
MemoryManager.Global.MemUnlock(_hContainer);
|
||||
MemoryManager.Instance.MemUnlock(_hContainer);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@ -823,7 +825,7 @@ namespace NTwain.Data
|
||||
// since range value can only house UInt32 we will not allow type size > 4
|
||||
if (GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException("Invalid range value type"); }
|
||||
|
||||
_hContainer = MemoryManager.Global.MemAllocate((uint)Marshal.SizeOf(value));
|
||||
_hContainer = MemoryManager.Instance.MemAllocate((uint)Marshal.SizeOf(value));
|
||||
if (_hContainer != IntPtr.Zero)
|
||||
{
|
||||
Marshal.StructureToPtr(value, _hContainer, false);
|
||||
@ -1123,7 +1125,7 @@ namespace NTwain.Data
|
||||
{
|
||||
if (_hContainer != IntPtr.Zero)
|
||||
{
|
||||
MemoryManager.Global.MemFree(_hContainer);
|
||||
MemoryManager.Instance.MemFree(_hContainer);
|
||||
_hContainer = IntPtr.Zero;
|
||||
}
|
||||
GC.SuppressFinalize(this);
|
||||
@ -1136,7 +1138,7 @@ namespace NTwain.Data
|
||||
{
|
||||
if (_hContainer != IntPtr.Zero)
|
||||
{
|
||||
MemoryManager.Global.MemFree(_hContainer);
|
||||
MemoryManager.Instance.MemFree(_hContainer);
|
||||
_hContainer = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
@ -1857,12 +1859,24 @@ namespace NTwain.Data
|
||||
/// </summary>
|
||||
public string ProductName { get { return _productName; } set { value.VerifyLengthUnder(TwainConst.String32 - 1); _productName = value; } }
|
||||
|
||||
//public static TWIdentity CreateFromAssembly(DataGroups supportedGroups)
|
||||
//{
|
||||
// return Create(supportedGroups);
|
||||
//}
|
||||
/// <summary>
|
||||
/// Creates a <see cref="TWIdentity"/> specified values.
|
||||
/// Creates a <see cref="TWIdentity"/> from assembly values.
|
||||
/// </summary>
|
||||
/// <param name="supportedGroups">The supported groups.</param>
|
||||
/// <param name="assembly">The assembly.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException">assembly</exception>
|
||||
public static TWIdentity CreateFromAssembly(DataGroups supportedGroups, Assembly assembly)
|
||||
{
|
||||
if (assembly == null) { throw new ArgumentNullException("assembly"); }
|
||||
|
||||
var info = FileVersionInfo.GetVersionInfo(assembly.Location);
|
||||
|
||||
return Create(supportedGroups, assembly.GetName().Version, info.CompanyName, info.ProductName, info.ProductName, info.FileDescription);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="TWIdentity"/> from specified values.
|
||||
/// </summary>
|
||||
/// <param name="supportedGroups">The supported groups.</param>
|
||||
/// <param name="version">The version.</param>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using NTwain.Data;
|
||||
using NTwain.Triplets;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
namespace NTwain
|
||||
@ -6,7 +7,7 @@ namespace NTwain
|
||||
/// <summary>
|
||||
/// Interface for keeping track of current TWAIN state with current app and source ids.
|
||||
/// </summary>
|
||||
public interface ITwainSession : INotifyPropertyChanged
|
||||
public interface ITwainState : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the app id used for the session.
|
||||
@ -27,10 +28,11 @@ namespace NTwain
|
||||
int State { get; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Internal interface for state management.
|
||||
/// </summary>
|
||||
interface ITwainSessionInternal : ITwainSession
|
||||
interface ITwainStateInternal : ITwainState
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether calls to triplets will verify the current twain session state.
|
||||
@ -54,6 +56,8 @@ namespace NTwain
|
||||
/// <param name="newState">The new state.</param>
|
||||
/// <returns></returns>
|
||||
ICommitable GetPendingStateChanger(int newState);
|
||||
|
||||
void ChangeSourceId(TWIdentity sourceId);
|
||||
}
|
||||
|
||||
interface ICommitable : IDisposable
|
@ -9,15 +9,14 @@ namespace NTwain
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides methods for managing memory on data exchanged with twain sources.
|
||||
/// This should only be used after the DSM has been opened in <see cref="TwainSession"/>
|
||||
/// via <see cref="TwainSession.OpenManager"/>.
|
||||
/// This should only be used after the DSM has been opened.
|
||||
/// </summary>
|
||||
public class MemoryManager
|
||||
public class MemoryManager : IMemoryManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the global <see cref="MemoryManager"/> instance.
|
||||
/// Gets the singleton <see cref="MemoryManager"/> instance.
|
||||
/// </summary>
|
||||
public static readonly MemoryManager Global = new MemoryManager();
|
||||
public static readonly MemoryManager Instance = new MemoryManager();
|
||||
|
||||
private MemoryManager() { }
|
||||
|
||||
@ -46,7 +45,7 @@ namespace NTwain
|
||||
else
|
||||
{
|
||||
// 0x0040 is GPTR
|
||||
return GlobalAlloc(0x0040, new UIntPtr(size));
|
||||
return WinGlobalAlloc(0x0040, new UIntPtr(size));
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +61,7 @@ namespace NTwain
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalFree(handle);
|
||||
WinGlobalFree(handle);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +78,7 @@ namespace NTwain
|
||||
}
|
||||
else
|
||||
{
|
||||
return GlobalLock(handle);
|
||||
return WinGlobalLock(handle);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,24 +94,25 @@ namespace NTwain
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalUnlock(handle);
|
||||
WinGlobalUnlock(handle);
|
||||
}
|
||||
}
|
||||
|
||||
#region old mem stuff for twain 1.x
|
||||
|
||||
[DllImport("kernel32", SetLastError = true, ExactSpelling = true)]
|
||||
static extern IntPtr GlobalAlloc(uint uFlags, UIntPtr dwBytes);
|
||||
|
||||
[DllImport("kernel32", SetLastError = true, ExactSpelling = true)]
|
||||
static extern IntPtr GlobalFree(IntPtr hMem);
|
||||
[DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalAlloc")]
|
||||
static extern IntPtr WinGlobalAlloc(uint uFlags, UIntPtr dwBytes);
|
||||
|
||||
[DllImport("kernel32", SetLastError = true, ExactSpelling = true)]
|
||||
static extern IntPtr GlobalLock(IntPtr handle);
|
||||
[DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalFree")]
|
||||
static extern IntPtr WinGlobalFree(IntPtr hMem);
|
||||
|
||||
[DllImport("kernel32", SetLastError = true, ExactSpelling = true)]
|
||||
[DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalLock")]
|
||||
static extern IntPtr WinGlobalLock(IntPtr handle);
|
||||
|
||||
[DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalUnlock")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool GlobalUnlock(IntPtr handle);
|
||||
static extern bool WinGlobalUnlock(IntPtr handle);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
@ -48,9 +48,6 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="WindowsBase" />
|
||||
@ -60,7 +57,9 @@
|
||||
<Compile Include="DeviceEventArgs.cs" />
|
||||
<Compile Include="Extensions.cs" />
|
||||
<Compile Include="DataTransferredEventArgs.cs" />
|
||||
<Compile Include="ITwainSession.cs" />
|
||||
<Compile Include="IMemoryManager.cs" />
|
||||
<Compile Include="ITwainOperation.cs" />
|
||||
<Compile Include="ITwainState.cs" />
|
||||
<Compile Include="MemoryManager.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
@ -68,6 +67,7 @@
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\VersionInfo.cs" />
|
||||
<Compile Include="TentativeStateCommitable.cs" />
|
||||
<Compile Include="TransferReadyEventArgs.cs" />
|
||||
<Compile Include="Triplets\DGControl\DGControl.Callback2.cs" />
|
||||
<Compile Include="Triplets\DGImage\DGImage.Filter.cs" />
|
||||
@ -75,6 +75,7 @@
|
||||
<Compile Include="Triplets\PInvokes.32bit.cs" />
|
||||
<Compile Include="Triplets\PInvokes.64bit.cs" />
|
||||
<Compile Include="TwainSessionExtensions.cs" />
|
||||
<Compile Include="TwainSessionBase.cs" />
|
||||
<Compile Include="TwainStateException.cs" />
|
||||
<Compile Include="Data\Types.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
47
NTwain/TentativeStateCommitable.cs
Normal file
47
NTwain/TentativeStateCommitable.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NTwain
|
||||
{
|
||||
class TentativeStateCommitable : ICommitable
|
||||
{
|
||||
bool _commit;
|
||||
ITwainStateInternal _session;
|
||||
int _origState;
|
||||
int _newState;
|
||||
public TentativeStateCommitable(ITwainStateInternal session, int newState)
|
||||
{
|
||||
_session = session;
|
||||
_origState = session.State;
|
||||
_newState = newState;
|
||||
_session.ChangeState(newState, false);
|
||||
}
|
||||
|
||||
#region ICommitable Members
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
if (_session.State == _newState)
|
||||
{
|
||||
_session.ChangeState(_newState, true);
|
||||
}
|
||||
_commit = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (!_commit && _session.State == _newState)
|
||||
{
|
||||
_session.ChangeState(_origState, false);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
sealed class AudioFileXfer : OpBase
|
||||
{
|
||||
internal AudioFileXfer(ITwainSessionInternal session) : base(session) { }
|
||||
internal AudioFileXfer(ITwainStateInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
/// This operation is used to initiate the transfer of audio from the Source to the application via the
|
||||
/// disk-file transfer mechanism. It causes the transfer to begin.
|
||||
|
@ -8,7 +8,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class AudioInfo : OpBase
|
||||
{
|
||||
internal AudioInfo(ITwainSessionInternal session) : base(session) { }
|
||||
internal AudioInfo(ITwainStateInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
/// Used to get the information of the current audio data ready to transfer.
|
||||
/// </summary>
|
||||
|
@ -8,7 +8,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
sealed class AudioNativeXfer : OpBase
|
||||
{
|
||||
internal AudioNativeXfer(ITwainSessionInternal session) : base(session) { }
|
||||
internal AudioNativeXfer(ITwainStateInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
/// Causes the transfer of an audio data from the Source to the application, via the Native
|
||||
/// transfer mechanism, to begin. The resulting data is stored in main memory in a single block.
|
||||
|
@ -7,8 +7,8 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class DGAudio
|
||||
{
|
||||
ITwainSessionInternal _session;
|
||||
internal DGAudio(ITwainSessionInternal session)
|
||||
ITwainStateInternal _session;
|
||||
internal DGAudio(ITwainStateInternal session)
|
||||
{
|
||||
if (session == null) { throw new ArgumentNullException("session"); }
|
||||
_session = session;
|
||||
|
@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
{
|
||||
sealed class Callback : OpBase
|
||||
{
|
||||
internal Callback(ITwainSessionInternal session) : base(session) { }
|
||||
internal Callback(ITwainStateInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
/// This triplet is sent to the DSM by the Application to register the application’s entry point with
|
||||
/// the DSM, so that the DSM can use callbacks to inform the application of events generated by the
|
||||
|
@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
{
|
||||
sealed class Callback2 : OpBase
|
||||
{
|
||||
internal Callback2(ITwainSessionInternal session) : base(session) { }
|
||||
internal Callback2(ITwainStateInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
/// This triplet is sent to the DSM by the Application to register the application’s entry point with
|
||||
/// the DSM, so that the DSM can use callbacks to inform the application of events generated by the
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class Capability : OpBase
|
||||
{
|
||||
internal Capability(ITwainSessionInternal session) : base(session) { }
|
||||
internal Capability(ITwainStateInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
/// Returns the Source’s Current, Default and Available Values for a specified capability.
|
||||
/// </summary>
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class CustomDSData : OpBase
|
||||
{
|
||||
internal CustomDSData(ITwainSessionInternal session) : base(session) { }
|
||||
internal CustomDSData(ITwainStateInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
/// This operation is used by the application to query the data source for its current settings, e.g.
|
||||
/// DPI, paper size, color format. The actual format of the data is data source dependent and not
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class DeviceEvent : OpBase
|
||||
{
|
||||
internal DeviceEvent(ITwainSessionInternal session) : base(session) { }
|
||||
internal DeviceEvent(ITwainStateInternal session) : base(session) { }
|
||||
public ReturnCode Get(out TWDeviceEvent sourceDeviceEvent)
|
||||
{
|
||||
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.DeviceEvent, Message.Get);
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
sealed class EntryPoint : OpBase
|
||||
{
|
||||
internal EntryPoint(ITwainSessionInternal session) : base(session) { }
|
||||
internal EntryPoint(ITwainStateInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
/// Gets the function entry points for twain 2.0 or higher.
|
||||
/// </summary>
|
||||
|
@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
{
|
||||
sealed class Event : OpBase
|
||||
{
|
||||
internal Event(ITwainSessionInternal session) : base(session) { }
|
||||
internal Event(ITwainStateInternal session) : base(session) { }
|
||||
|
||||
/// <summary>
|
||||
/// This operation supports the distribution of events from the application to Sources so that the
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class FileSystem : OpBase
|
||||
{
|
||||
internal FileSystem(ITwainSessionInternal session) : base(session) { }
|
||||
internal FileSystem(ITwainStateInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
/// This operation selects the destination directory within the Source (camera, storage, etc), where
|
||||
/// images captured using CapAutomaticCapture will be stored. This command only selects
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class Identity : OpBase
|
||||
{
|
||||
internal Identity(ITwainSessionInternal session) : base(session) { }
|
||||
internal Identity(ITwainStateInternal 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
|
||||
@ -23,6 +23,7 @@ namespace NTwain.Triplets
|
||||
var rc = PInvoke.DsmEntry(Session.AppId, Message.CloseDS, Session.SourceId);
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
Session.ChangeSourceId(null);
|
||||
Session.ChangeState(3, true);
|
||||
}
|
||||
return rc;
|
||||
@ -78,6 +79,7 @@ namespace NTwain.Triplets
|
||||
var rc = PInvoke.DsmEntry(Session.AppId, Message.OpenDS, source);
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
Session.ChangeSourceId(source);
|
||||
Session.ChangeState(4, true);
|
||||
}
|
||||
return rc;
|
||||
|
@ -10,7 +10,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
sealed class Parent : OpBase
|
||||
{
|
||||
internal Parent(ITwainSessionInternal session) : base(session) { }
|
||||
internal Parent(ITwainStateInternal session) : base(session) { }
|
||||
|
||||
/// <summary>
|
||||
/// When the application has closed all the Sources it had previously opened, and is finished with
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class PassThru : OpBase
|
||||
{
|
||||
internal PassThru(ITwainSessionInternal session) : base(session) { }
|
||||
internal PassThru(ITwainStateInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
/// PASSTHRU is intended for the use of Source writers writing diagnostic applications. It allows
|
||||
/// raw communication with the currently selected device in the Source.
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
sealed class PendingXfers : OpBase
|
||||
{
|
||||
internal PendingXfers(ITwainSessionInternal session) : base(session) { }
|
||||
internal PendingXfers(ITwainStateInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
/// This triplet is used to cancel or terminate a transfer. Issued in state 6, this triplet cancels the next
|
||||
/// pending transfer, discards the transfer data, and decrements the pending transfers count. In
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class SetupFileXfer : OpBase
|
||||
{
|
||||
internal SetupFileXfer(ITwainSessionInternal session) : base(session) { }
|
||||
internal SetupFileXfer(ITwainStateInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
/// Returns information about the file into which the Source has or will put the acquired image
|
||||
/// or audio data.
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class SetupMemXfer : OpBase
|
||||
{
|
||||
internal SetupMemXfer(ITwainSessionInternal session) : base(session) { }
|
||||
internal SetupMemXfer(ITwainStateInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
/// Returns the Source’s preferred, minimum, and maximum allocation sizes for transfer memory
|
||||
/// buffers.
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class Status : OpBase
|
||||
{
|
||||
internal Status(ITwainSessionInternal session) : base(session) { }
|
||||
internal Status(ITwainStateInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
/// Returns the current Condition Code for the Source Manager.
|
||||
/// </summary>
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class StatusUtf8 : OpBase
|
||||
{
|
||||
internal StatusUtf8(ITwainSessionInternal session) : base(session) { }
|
||||
internal StatusUtf8(ITwainStateInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
/// Translate the contents of a TW_STATUS structure received from a Source into a localized UTF-8
|
||||
/// encoded string.
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
sealed class UserInterface : OpBase
|
||||
{
|
||||
internal UserInterface(ITwainSessionInternal session) : base(session) { }
|
||||
internal UserInterface(ITwainStateInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
/// This operation causes the Source’s user interface, if displayed during the
|
||||
/// EnableDS operation, to be lowered. The Source is returned to
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class XferGroup : OpBase
|
||||
{
|
||||
internal XferGroup(ITwainSessionInternal session) : base(session) { }
|
||||
internal XferGroup(ITwainStateInternal session) : base(session) { }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Data Group (the type of data) for the upcoming transfer. The Source is required to
|
||||
|
@ -7,8 +7,8 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class DGControl
|
||||
{
|
||||
ITwainSessionInternal _session;
|
||||
internal DGControl(ITwainSessionInternal session)
|
||||
ITwainStateInternal _session;
|
||||
internal DGControl(ITwainStateInternal session)
|
||||
{
|
||||
if (session == null) { throw new ArgumentNullException("session"); }
|
||||
_session = session;
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class CieColor : OpBase
|
||||
{
|
||||
internal CieColor(ITwainSessionInternal session) : base(session) { }
|
||||
internal CieColor(ITwainStateInternal session) : base(session) { }
|
||||
|
||||
/// <summary>
|
||||
/// This operation causes the Source to report the currently active parameters to be used in
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class ExtImageInfo : OpBase
|
||||
{
|
||||
internal ExtImageInfo(ITwainSessionInternal session) : base(session) { }
|
||||
internal ExtImageInfo(ITwainStateInternal session) : base(session) { }
|
||||
|
||||
public ReturnCode Get(TWExtImageInfo info)
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class Filter : OpBase
|
||||
{
|
||||
internal Filter(ITwainSessionInternal session) : base(session) { }
|
||||
internal Filter(ITwainStateInternal session) : base(session) { }
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class GrayResponse : OpBase
|
||||
{
|
||||
internal GrayResponse(ITwainSessionInternal session) : base(session) { }
|
||||
internal GrayResponse(ITwainStateInternal session) : base(session) { }
|
||||
|
||||
/// <summary>
|
||||
/// The Reset operation causes the Source to use its "identity response curve." The identity
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class IccProfile : OpBase
|
||||
{
|
||||
internal IccProfile(ITwainSessionInternal session) : base(session) { }
|
||||
internal IccProfile(ITwainStateInternal session) : base(session) { }
|
||||
|
||||
/// <summary>
|
||||
/// This operation provides the application with the ICC profile associated with the image which is
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
sealed class ImageFileXfer : OpBase
|
||||
{
|
||||
internal ImageFileXfer(ITwainSessionInternal session) : base(session) { }
|
||||
internal ImageFileXfer(ITwainStateInternal session) : base(session) { }
|
||||
|
||||
/// <summary>
|
||||
/// This operation is used to initiate the transfer of an image from the Source to the application via
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class ImageInfo : OpBase
|
||||
{
|
||||
internal ImageInfo(ITwainSessionInternal session) : base(session) { }
|
||||
internal ImageInfo(ITwainStateInternal session) : base(session) { }
|
||||
|
||||
public ReturnCode Get(out TWImageInfo info)
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class ImageLayout : OpBase
|
||||
{
|
||||
internal ImageLayout(ITwainSessionInternal session) : base(session) { }
|
||||
internal ImageLayout(ITwainStateInternal session) : base(session) { }
|
||||
|
||||
public ReturnCode Get(out TWImageLayout layout)
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
{
|
||||
sealed class ImageMemFileXfer : OpBase
|
||||
{
|
||||
internal ImageMemFileXfer(ITwainSessionInternal session) : base(session) { }
|
||||
internal ImageMemFileXfer(ITwainStateInternal session) : base(session) { }
|
||||
|
||||
/// <summary>
|
||||
/// This operation is used to initiate the transfer of an image from the Source to the application via
|
||||
|
@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
{
|
||||
sealed class ImageMemXfer : OpBase
|
||||
{
|
||||
internal ImageMemXfer(ITwainSessionInternal session) : base(session) { }
|
||||
internal ImageMemXfer(ITwainStateInternal session) : base(session) { }
|
||||
|
||||
/// <summary>
|
||||
/// This operation is used to initiate the transfer of an image from the Source to the application via
|
||||
|
@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
{
|
||||
sealed class ImageNativeXfer : OpBase
|
||||
{
|
||||
internal ImageNativeXfer(ITwainSessionInternal session) : base(session) { }
|
||||
internal ImageNativeXfer(ITwainStateInternal session) : base(session) { }
|
||||
|
||||
/// <summary>
|
||||
/// Causes the transfer of an image’s data from the Source to the application, via the Native transfer
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class JpegCompression : OpBase
|
||||
{
|
||||
internal JpegCompression(ITwainSessionInternal session) : base(session) { }
|
||||
internal JpegCompression(ITwainStateInternal session) : base(session) { }
|
||||
|
||||
/// <summary>
|
||||
/// Causes the Source to return the parameters that will be used during the compression of data
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class Palette8 : OpBase
|
||||
{
|
||||
internal Palette8(ITwainSessionInternal session) : base(session) { }
|
||||
internal Palette8(ITwainStateInternal session) : base(session) { }
|
||||
|
||||
/// <summary>
|
||||
/// This operation causes the Source to report its current palette information.
|
||||
|
@ -9,7 +9,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class RgbResponse : OpBase
|
||||
{
|
||||
internal RgbResponse(ITwainSessionInternal session) : base(session) { }
|
||||
internal RgbResponse(ITwainStateInternal session) : base(session) { }
|
||||
|
||||
/// <summary>
|
||||
/// Causes the Source to use its "identity" response curves for future RGB transfers. The identity
|
||||
|
@ -7,8 +7,8 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public sealed class DGImage
|
||||
{
|
||||
ITwainSessionInternal _session;
|
||||
internal DGImage(ITwainSessionInternal session)
|
||||
ITwainStateInternal _session;
|
||||
internal DGImage(ITwainStateInternal session)
|
||||
{
|
||||
if (session == null) { throw new ArgumentNullException("session"); }
|
||||
_session = session;
|
||||
|
@ -16,7 +16,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
/// <param name="session">The session.</param>
|
||||
/// <exception cref="System.ArgumentNullException"></exception>
|
||||
internal OpBase(ITwainSessionInternal session)
|
||||
internal OpBase(ITwainStateInternal session)
|
||||
{
|
||||
if (session == null) { throw new ArgumentNullException("session"); }
|
||||
Session = session;
|
||||
@ -28,6 +28,6 @@ namespace NTwain.Triplets
|
||||
/// <value>
|
||||
/// The session.
|
||||
/// </value>
|
||||
internal ITwainSessionInternal Session { get; private set; }
|
||||
internal ITwainStateInternal Session { get; private set; }
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace NTwain
|
||||
/// <summary>
|
||||
/// Provides a session for working with TWAIN api in an application.
|
||||
/// </summary>
|
||||
public class TwainSession : ITwainSessionInternal, IMessageFilter, INotifyPropertyChanged
|
||||
public class TwainSession : ITwainStateInternal, IMessageFilter, INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TwainSession" /> class.
|
||||
@ -29,7 +29,7 @@ namespace NTwain
|
||||
public TwainSession(TWIdentity appId)
|
||||
{
|
||||
if (appId == null) { throw new ArgumentNullException("appId"); }
|
||||
_appId = appId;
|
||||
AppId = appId;
|
||||
State = 1;
|
||||
EnforceState = true;
|
||||
}
|
||||
@ -40,27 +40,17 @@ namespace NTwain
|
||||
SynchronizationContext _syncer;
|
||||
|
||||
|
||||
TWIdentity _appId;
|
||||
/// <summary>
|
||||
/// Gets the app id used for the session.
|
||||
/// </summary>
|
||||
/// <value>The app id.</value>
|
||||
public TWIdentity AppId { get { return _appId; } }
|
||||
public TWIdentity AppId { get; private set; }
|
||||
|
||||
TWIdentity _sourceId;
|
||||
/// <summary>
|
||||
/// Gets the source id used for the session.
|
||||
/// </summary>
|
||||
/// <value>The source id.</value>
|
||||
public TWIdentity SourceId
|
||||
{
|
||||
get { return _sourceId; }
|
||||
private set
|
||||
{
|
||||
_sourceId = value;
|
||||
RaisePropertyChanged("SourceId");
|
||||
}
|
||||
}
|
||||
public TWIdentity SourceId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current state number as defined by the TWAIN spec.
|
||||
@ -157,15 +147,20 @@ namespace NTwain
|
||||
|
||||
#region state transition calls
|
||||
|
||||
void ITwainSessionInternal.ChangeState(int newState, bool notifyChange)
|
||||
void ITwainStateInternal.ChangeState(int newState, bool notifyChange)
|
||||
{
|
||||
Debug.WriteLine("TWAIN State = " + newState);
|
||||
State = newState;
|
||||
if (notifyChange) { RaisePropertyChanged("State"); }
|
||||
}
|
||||
ICommitable ITwainSessionInternal.GetPendingStateChanger(int newState)
|
||||
ICommitable ITwainStateInternal.GetPendingStateChanger(int newState)
|
||||
{
|
||||
return new TentativeStateChanger(this, newState);
|
||||
return new TentativeStateCommitable(this, newState);
|
||||
}
|
||||
void ITwainStateInternal.ChangeSourceId(TWIdentity sourceId)
|
||||
{
|
||||
SourceId = sourceId;
|
||||
RaisePropertyChanged("SourceId");
|
||||
}
|
||||
|
||||
|
||||
@ -193,7 +188,7 @@ namespace NTwain
|
||||
rc = DGControl.EntryPoint.Get(out entry);
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
MemoryManager.Global.UpdateEntryPoint(entry);
|
||||
MemoryManager.Instance.UpdateEntryPoint(entry);
|
||||
Debug.WriteLine("Using TWAIN2 memory functions.");
|
||||
}
|
||||
else
|
||||
@ -218,7 +213,7 @@ namespace NTwain
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
_parentHandle = default(HandleRef);
|
||||
MemoryManager.Global.UpdateEntryPoint(null);
|
||||
MemoryManager.Instance.UpdateEntryPoint(null);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@ -258,7 +253,7 @@ namespace NTwain
|
||||
if (!DisableCallback)
|
||||
{
|
||||
// app v2.2 or higher uses callback2
|
||||
if (_appId.ProtocolMajor >= 2 && _appId.ProtocolMinor >= 2)
|
||||
if (AppId.ProtocolMajor >= 2 && AppId.ProtocolMinor >= 2)
|
||||
{
|
||||
var cb = new TWCallback2(new CallbackDelegate(CallbackHandler));
|
||||
var rc2 = DGControl.Callback2.RegisterCallback(cb);
|
||||
@ -289,7 +284,7 @@ namespace NTwain
|
||||
ReturnCode CallbackHandler(TWIdentity origin, TWIdentity dest,
|
||||
DataGroups dg, DataArgumentType dat, Values.Message msg, IntPtr data)
|
||||
{
|
||||
if (origin != null && _sourceId != null && origin.Id == _sourceId.Id)
|
||||
if (origin != null && SourceId != null && origin.Id == SourceId.Id)
|
||||
{
|
||||
Debug.WriteLine(string.Format("Thread {0}: GOT TWAIN callback for msg {1}.", Thread.CurrentThread.ManagedThreadId, msg));
|
||||
// spec says should handle this on the thread that enabled the DS,
|
||||
@ -509,7 +504,7 @@ namespace NTwain
|
||||
{
|
||||
if (dataPtr != IntPtr.Zero)
|
||||
{
|
||||
lockedPtr = MemoryManager.Global.MemLock(dataPtr);
|
||||
lockedPtr = MemoryManager.Instance.MemLock(dataPtr);
|
||||
}
|
||||
dtHand(this, new DataTransferredEventArgs(lockedPtr, file));
|
||||
}
|
||||
@ -528,7 +523,7 @@ namespace NTwain
|
||||
// var dtHand = DataTransferred;
|
||||
// if (dtHand != null)
|
||||
// {
|
||||
// lockedPtr = MemoryManager.Global.MemLock(dataPtr);
|
||||
// lockedPtr = MemoryManager.Instance.MemLock(dataPtr);
|
||||
// dtHand(this, new DataTransferredEventArgs(lockedPtr));
|
||||
// }
|
||||
// }
|
||||
@ -542,12 +537,12 @@ namespace NTwain
|
||||
// data here is allocated by source so needs to use shared mem calls
|
||||
if (lockedPtr != IntPtr.Zero)
|
||||
{
|
||||
MemoryManager.Global.MemUnlock(lockedPtr);
|
||||
MemoryManager.Instance.MemUnlock(lockedPtr);
|
||||
lockedPtr = IntPtr.Zero;
|
||||
}
|
||||
if (dataPtr != IntPtr.Zero)
|
||||
{
|
||||
MemoryManager.Global.MemFree(dataPtr);
|
||||
MemoryManager.Instance.MemFree(dataPtr);
|
||||
dataPtr = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
@ -723,14 +718,14 @@ namespace NTwain
|
||||
try
|
||||
{
|
||||
// no need to lock for marshal alloc
|
||||
msgPtr = MemoryManager.Global.MemAllocate((uint)Marshal.SizeOf(winmsg));
|
||||
msgPtr = MemoryManager.Instance.MemAllocate((uint)Marshal.SizeOf(winmsg));
|
||||
Marshal.StructureToPtr(winmsg, msgPtr, false);
|
||||
return HandleLoopMsgEvent(ref msgPtr);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (msgPtr != IntPtr.Zero)
|
||||
MemoryManager.Global.MemFree(msgPtr);
|
||||
MemoryManager.Instance.MemFree(msgPtr);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -762,14 +757,14 @@ namespace NTwain
|
||||
try
|
||||
{
|
||||
// no need to lock for marshal alloc
|
||||
msgPtr = MemoryManager.Global.MemAllocate((uint)Marshal.SizeOf(winmsg));
|
||||
msgPtr = MemoryManager.Instance.MemAllocate((uint)Marshal.SizeOf(winmsg));
|
||||
Marshal.StructureToPtr(winmsg, msgPtr, false);
|
||||
handled = HandleLoopMsgEvent(ref msgPtr);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (msgPtr != IntPtr.Zero)
|
||||
MemoryManager.Global.MemFree(msgPtr);
|
||||
MemoryManager.Instance.MemFree(msgPtr);
|
||||
}
|
||||
}
|
||||
return IntPtr.Zero;
|
||||
@ -791,44 +786,5 @@ namespace NTwain
|
||||
|
||||
#endregion
|
||||
|
||||
#region nested stuff
|
||||
|
||||
class TentativeStateChanger : ICommitable
|
||||
{
|
||||
bool _commit;
|
||||
ITwainSessionInternal _session;
|
||||
int _origState;
|
||||
int _newState;
|
||||
public TentativeStateChanger(ITwainSessionInternal session, int newState)
|
||||
{
|
||||
_session = session;
|
||||
_origState = session.State;
|
||||
_newState = newState;
|
||||
_session.ChangeState(newState, false);
|
||||
}
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
if (_session.State == _newState)
|
||||
{
|
||||
_session.ChangeState(_newState, true);
|
||||
}
|
||||
_commit = true;
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (!_commit && _session.State == _newState)
|
||||
{
|
||||
_session.ChangeState(_origState, false);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ namespace NTwain
|
||||
/// <param name="dataArgumentType">The triplet data argument type.</param>
|
||||
/// <param name="message">The triplet message.</param>
|
||||
/// <exception cref="TwainStateException"></exception>
|
||||
internal static void VerifyState(this ITwainSessionInternal session, int allowedMinimum, int allowedMaximum, DataGroups group, DataArgumentType dataArgumentType, NTwain.Values.Message message)
|
||||
internal static void VerifyState(this ITwainStateInternal session, int allowedMinimum, int allowedMaximum, DataGroups group, DataArgumentType dataArgumentType, NTwain.Values.Message message)
|
||||
{
|
||||
if (session.EnforceState && (session.State < allowedMinimum || session.State > allowedMaximum))
|
||||
{
|
||||
|
@ -346,7 +346,7 @@ namespace NTwain.Values
|
||||
/// CapClearBuffers values.
|
||||
/// Corresponds to TWCB_* values.
|
||||
/// </summary>
|
||||
public enum ClearBuffers : ushort
|
||||
public enum ClearBuffer : ushort
|
||||
{
|
||||
Auto = 0,
|
||||
Clear = 1,
|
||||
|
@ -12,7 +12,7 @@ namespace NTwain.Tests
|
||||
[ExpectedException(typeof(TwainStateException), "State check failed to throw.")]
|
||||
public void VerifyState_Throws_When_State_Is_Enforced()
|
||||
{
|
||||
ITwainSessionInternal session = new TwainSession(TWIdentity.Create(DataGroups.Image, new Version(1, 0), "test", "test", "test", "test"));
|
||||
ITwainStateInternal session = new TwainSession(TWIdentity.Create(DataGroups.Image, new Version(1, 0), "test", "test", "test", "test"));
|
||||
session.EnforceState = true;
|
||||
session.ChangeState(4, false);
|
||||
|
||||
@ -22,7 +22,7 @@ namespace NTwain.Tests
|
||||
[TestMethod]
|
||||
public void VerifyState_No_Throws_When_State_Is_Not_Enforced()
|
||||
{
|
||||
ITwainSessionInternal session = new TwainSession(TWIdentity.Create(DataGroups.Image, new Version(1, 0), "test", "test", "test", "test"));
|
||||
ITwainStateInternal session = new TwainSession(TWIdentity.Create(DataGroups.Image, new Version(1, 0), "test", "test", "test", "test"));
|
||||
session.EnforceState = false;
|
||||
session.ChangeState(4, false);
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
@ -40,10 +40,6 @@
|
||||
<HintPath>..\..\packages\CommonWin32.2.0.4\lib\net35-Client\CommonWin32.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
|
Loading…
Reference in New Issue
Block a user