mirror of
https://github.com/soukoku/ntwain.git
synced 2026-02-25 13:04:07 +08:00
Exposed public triplets through twain source class instead.
This commit is contained in:
@@ -37,26 +37,6 @@ namespace NTwain
|
|||||||
/// <value>The state.</value>
|
/// <value>The state.</value>
|
||||||
int State { get; }
|
int State { get; }
|
||||||
|
|
||||||
/// <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>
|
/// <summary>
|
||||||
/// Try to show the built-in source selector dialog and return the selected source.
|
/// Try to show the built-in source selector dialog and return the selected source.
|
||||||
/// This is not recommended and is only included for completeness.
|
/// This is not recommended and is only included for completeness.
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
|
using NTwain.Triplets;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -46,5 +47,25 @@ namespace NTwain.Internals
|
|||||||
|
|
||||||
ReturnCode EnableSource(SourceEnableMode mode, bool modal, IntPtr windowHandle);
|
ReturnCode EnableSource(SourceEnableMode mode, bool modal, IntPtr windowHandle);
|
||||||
SynchronizationContext SynchronizationContext { get; set; }
|
SynchronizationContext SynchronizationContext { get; set; }
|
||||||
|
|
||||||
|
/// <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; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents <see cref="DataGroups.Audio"/>.
|
/// Represents <see cref="DataGroups.Audio"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class DGAudio
|
sealed class DGAudio
|
||||||
{
|
{
|
||||||
ITwainSessionInternal _session;
|
ITwainSessionInternal _session;
|
||||||
internal DGAudio(ITwainSessionInternal session)
|
internal DGAudio(ITwainSessionInternal session)
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ namespace NTwain
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
TWIdentity id;
|
TWIdentity id;
|
||||||
if (DGControl.Identity.GetDefault(out id) == ReturnCode.Success)
|
if (((ITwainSessionInternal)this).DGControl.Identity.GetDefault(out id) == ReturnCode.Success)
|
||||||
{
|
{
|
||||||
return GetSourceInstance(this, id);
|
return GetSourceInstance(this, id);
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ namespace NTwain
|
|||||||
{
|
{
|
||||||
if (value != null)
|
if (value != null)
|
||||||
{
|
{
|
||||||
DGControl.Identity.Set(value.Identity);
|
((ITwainSessionInternal)this).DGControl.Identity.Set(value.Identity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,7 +174,7 @@ namespace NTwain
|
|||||||
public TwainSource ShowSourceSelector()
|
public TwainSource ShowSourceSelector()
|
||||||
{
|
{
|
||||||
TWIdentity id;
|
TWIdentity id;
|
||||||
if (DGControl.Identity.UserSelect(out id) == ReturnCode.Success)
|
if (((ITwainSessionInternal)this).DGControl.Identity.UserSelect(out id) == ReturnCode.Success)
|
||||||
{
|
{
|
||||||
return GetSourceInstance(this, id);
|
return GetSourceInstance(this, id);
|
||||||
}
|
}
|
||||||
@@ -210,7 +210,7 @@ namespace NTwain
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the triplet operations defined for audio data group.
|
/// Gets the triplet operations defined for audio data group.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DGAudio DGAudio
|
DGAudio ITwainSessionInternal.DGAudio
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -220,10 +220,7 @@ namespace NTwain
|
|||||||
}
|
}
|
||||||
|
|
||||||
DGControl _dgControl;
|
DGControl _dgControl;
|
||||||
/// <summary>
|
DGControl ITwainSessionInternal.DGControl
|
||||||
/// Gets the triplet operations defined for control data group.
|
|
||||||
/// </summary>
|
|
||||||
public DGControl DGControl
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -233,10 +230,7 @@ namespace NTwain
|
|||||||
}
|
}
|
||||||
|
|
||||||
DGImage _dgImage;
|
DGImage _dgImage;
|
||||||
/// <summary>
|
DGImage ITwainSessionInternal.DGImage
|
||||||
/// Gets the triplet operations defined for image data group.
|
|
||||||
/// </summary>
|
|
||||||
public DGImage DGImage
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -246,10 +240,7 @@ namespace NTwain
|
|||||||
}
|
}
|
||||||
|
|
||||||
DGCustom _dgCustom;
|
DGCustom _dgCustom;
|
||||||
/// <summary>
|
DGCustom ITwainSessionInternal.DGCustom
|
||||||
/// Gets the direct triplet operation entry for custom values.
|
|
||||||
/// </summary>
|
|
||||||
public DGCustom DGCustom
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -257,6 +248,7 @@ namespace NTwain
|
|||||||
return _dgCustom;
|
return _dgCustom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opens the data source manager. This must be the first method used
|
/// 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.
|
/// before using other TWAIN functions. Calls to this must be followed by <see cref="Close"/> when done with a TWAIN session.
|
||||||
@@ -269,14 +261,14 @@ namespace NTwain
|
|||||||
{
|
{
|
||||||
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: OpenManager.", Thread.CurrentThread.ManagedThreadId));
|
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: OpenManager.", Thread.CurrentThread.ManagedThreadId));
|
||||||
|
|
||||||
rc = DGControl.Parent.OpenDsm(MessageLoop.Instance.LoopHandle);
|
rc = ((ITwainSessionInternal)this).DGControl.Parent.OpenDsm(MessageLoop.Instance.LoopHandle);
|
||||||
if (rc == ReturnCode.Success)
|
if (rc == ReturnCode.Success)
|
||||||
{
|
{
|
||||||
// if twain2 then get memory management functions
|
// if twain2 then get memory management functions
|
||||||
if ((_appId.DataFunctionalities & DataFunctionalities.Dsm2) == DataFunctionalities.Dsm2)
|
if ((_appId.DataFunctionalities & DataFunctionalities.Dsm2) == DataFunctionalities.Dsm2)
|
||||||
{
|
{
|
||||||
TWEntryPoint entry;
|
TWEntryPoint entry;
|
||||||
rc = DGControl.EntryPoint.Get(out entry);
|
rc = ((ITwainSessionInternal)this).DGControl.EntryPoint.Get(out entry);
|
||||||
if (rc == ReturnCode.Success)
|
if (rc == ReturnCode.Success)
|
||||||
{
|
{
|
||||||
Platform.MemoryManager = entry;
|
Platform.MemoryManager = entry;
|
||||||
@@ -303,7 +295,7 @@ namespace NTwain
|
|||||||
{
|
{
|
||||||
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: CloseManager.", Thread.CurrentThread.ManagedThreadId));
|
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: CloseManager.", Thread.CurrentThread.ManagedThreadId));
|
||||||
|
|
||||||
rc = DGControl.Parent.CloseDsm(MessageLoop.Instance.LoopHandle);
|
rc = ((ITwainSessionInternal)this).DGControl.Parent.CloseDsm(MessageLoop.Instance.LoopHandle);
|
||||||
if (rc == ReturnCode.Success)
|
if (rc == ReturnCode.Success)
|
||||||
{
|
{
|
||||||
Platform.MemoryManager = null;
|
Platform.MemoryManager = null;
|
||||||
@@ -321,13 +313,14 @@ namespace NTwain
|
|||||||
public IEnumerable<TwainSource> GetSources()
|
public IEnumerable<TwainSource> GetSources()
|
||||||
{
|
{
|
||||||
TWIdentity srcId;
|
TWIdentity srcId;
|
||||||
var rc = DGControl.Identity.GetFirst(out srcId);
|
var rc = ((ITwainSessionInternal)this).DGControl.Identity.GetFirst(out srcId);
|
||||||
while (rc == ReturnCode.Success)
|
while (rc == ReturnCode.Success)
|
||||||
{
|
{
|
||||||
yield return GetSourceInstance(this, srcId);
|
yield return GetSourceInstance(this, srcId);
|
||||||
rc = DGControl.Identity.GetNext(out srcId);
|
rc = ((ITwainSessionInternal)this).DGControl.Identity.GetNext(out srcId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the manager status. Only call this at state 2 or higher.
|
/// Gets the manager status. Only call this at state 2 or higher.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -335,7 +328,7 @@ namespace NTwain
|
|||||||
public TWStatus GetStatus()
|
public TWStatus GetStatus()
|
||||||
{
|
{
|
||||||
TWStatus stat;
|
TWStatus stat;
|
||||||
DGControl.Status.GetManager(out stat);
|
((ITwainSessionInternal)this).DGControl.Status.GetManager(out stat);
|
||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,7 +339,7 @@ namespace NTwain
|
|||||||
public TWStatusUtf8 GetStatusUtf8()
|
public TWStatusUtf8 GetStatusUtf8()
|
||||||
{
|
{
|
||||||
TWStatusUtf8 stat;
|
TWStatusUtf8 stat;
|
||||||
DGControl.StatusUtf8.GetManager(out stat);
|
((ITwainSessionInternal)this).DGControl.StatusUtf8.GetManager(out stat);
|
||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,7 +407,7 @@ namespace NTwain
|
|||||||
if (_appId.ProtocolMajor >= 2 && _appId.ProtocolMinor >= 2)
|
if (_appId.ProtocolMajor >= 2 && _appId.ProtocolMinor >= 2)
|
||||||
{
|
{
|
||||||
var cb = new TWCallback2(HandleCallback);
|
var cb = new TWCallback2(HandleCallback);
|
||||||
var rc2 = DGControl.Callback2.RegisterCallback(cb);
|
var rc2 = ((ITwainSessionInternal)this).DGControl.Callback2.RegisterCallback(cb);
|
||||||
|
|
||||||
if (rc2 == ReturnCode.Success)
|
if (rc2 == ReturnCode.Success)
|
||||||
{
|
{
|
||||||
@@ -426,7 +419,7 @@ namespace NTwain
|
|||||||
{
|
{
|
||||||
var cb = new TWCallback(HandleCallback);
|
var cb = new TWCallback(HandleCallback);
|
||||||
|
|
||||||
var rc2 = DGControl.Callback.RegisterCallback(cb);
|
var rc2 = ((ITwainSessionInternal)this).DGControl.Callback.RegisterCallback(cb);
|
||||||
|
|
||||||
if (rc2 == ReturnCode.Success)
|
if (rc2 == ReturnCode.Success)
|
||||||
{
|
{
|
||||||
@@ -442,11 +435,11 @@ namespace NTwain
|
|||||||
|
|
||||||
if (mode == SourceEnableMode.ShowUIOnly)
|
if (mode == SourceEnableMode.ShowUIOnly)
|
||||||
{
|
{
|
||||||
rc = DGControl.UserInterface.EnableDSUIOnly(_twui);
|
rc = ((ITwainSessionInternal)this).DGControl.UserInterface.EnableDSUIOnly(_twui);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rc = DGControl.UserInterface.EnableDS(_twui);
|
rc = ((ITwainSessionInternal)this).DGControl.UserInterface.EnableDS(_twui);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc != ReturnCode.Success)
|
if (rc != ReturnCode.Success)
|
||||||
@@ -465,7 +458,7 @@ namespace NTwain
|
|||||||
{
|
{
|
||||||
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: DisableSource.", Thread.CurrentThread.ManagedThreadId));
|
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: DisableSource.", Thread.CurrentThread.ManagedThreadId));
|
||||||
|
|
||||||
rc = DGControl.UserInterface.DisableDS(_twui);
|
rc = ((ITwainSessionInternal)this).DGControl.UserInterface.DisableDS(_twui);
|
||||||
if (rc == ReturnCode.Success)
|
if (rc == ReturnCode.Success)
|
||||||
{
|
{
|
||||||
_callbackObj = null;
|
_callbackObj = null;
|
||||||
@@ -506,11 +499,11 @@ namespace NTwain
|
|||||||
{
|
{
|
||||||
if (targetState < 7)
|
if (targetState < 7)
|
||||||
{
|
{
|
||||||
DGControl.PendingXfers.EndXfer(new TWPendingXfers());
|
((ITwainSessionInternal)this).DGControl.PendingXfers.EndXfer(new TWPendingXfers());
|
||||||
}
|
}
|
||||||
if (targetState < 6)
|
if (targetState < 6)
|
||||||
{
|
{
|
||||||
DGControl.PendingXfers.Reset(new TWPendingXfers());
|
((ITwainSessionInternal)this).DGControl.PendingXfers.Reset(new TWPendingXfers());
|
||||||
}
|
}
|
||||||
if (targetState < 5)
|
if (targetState < 5)
|
||||||
{
|
{
|
||||||
@@ -690,7 +683,7 @@ namespace NTwain
|
|||||||
|
|
||||||
var evt = new TWEvent();
|
var evt = new TWEvent();
|
||||||
evt.pEvent = msgPtr;
|
evt.pEvent = msgPtr;
|
||||||
if (handled = (DGControl.Event.ProcessEvent(evt) == ReturnCode.DSEvent))
|
if (handled = (((ITwainSessionInternal)this).DGControl.Event.ProcessEvent(evt) == ReturnCode.DSEvent))
|
||||||
{
|
{
|
||||||
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: HandleWndProcMessage at state {1} with MSG={2}.", Thread.CurrentThread.ManagedThreadId, State, evt.TWMessage));
|
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: HandleWndProcMessage at state {1} with MSG={2}.", Thread.CurrentThread.ManagedThreadId, State, evt.TWMessage));
|
||||||
|
|
||||||
@@ -735,7 +728,7 @@ namespace NTwain
|
|||||||
break;
|
break;
|
||||||
case Message.DeviceEvent:
|
case Message.DeviceEvent:
|
||||||
TWDeviceEvent de;
|
TWDeviceEvent de;
|
||||||
var rc = DGControl.DeviceEvent.Get(out de);
|
var rc = ((ITwainSessionInternal)this).DGControl.DeviceEvent.Get(out de);
|
||||||
if (rc == ReturnCode.Success)
|
if (rc == ReturnCode.Success)
|
||||||
{
|
{
|
||||||
SafeSyncableRaiseOnEvent(OnDeviceEvent, DeviceEvent, new DeviceEventArgs(de));
|
SafeSyncableRaiseOnEvent(OnDeviceEvent, DeviceEvent, new DeviceEventArgs(de));
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Internals;
|
using NTwain.Internals;
|
||||||
|
using NTwain.Triplets;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@@ -182,6 +183,40 @@ namespace NTwain
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the triplet operations defined for control data group.
|
||||||
|
/// </summary>
|
||||||
|
public DGControl DGControl
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _session.DGControl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the triplet operations defined for image data group.
|
||||||
|
/// </summary>
|
||||||
|
public DGImage DGImage
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _session.DGImage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the direct triplet operation entry for custom values.
|
||||||
|
/// </summary>
|
||||||
|
public DGCustom DGCustom
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _session.DGCustom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region INotifyPropertyChanged Members
|
#region INotifyPropertyChanged Members
|
||||||
|
|||||||
Reference in New Issue
Block a user