mirror of
https://github.com/soukoku/ntwain.git
synced 2026-02-25 13:04:07 +08:00
Renamed TwainSession to TwainAppSession. I love renaming things.
This commit is contained in:
@@ -6,14 +6,14 @@
|
||||
<#@ import namespace="System.Collections.Generic" #>
|
||||
<#@ output extension="dummy" #>
|
||||
<#
|
||||
List<(string className, string dllPath, string identityClass)> outputs = new() {
|
||||
("OSXLegacyDSM", "/System/Library/Frameworks/framework/TWAIN", "TW_IDENTITY_MACOSX"),
|
||||
("OSXNewDSM", "/Library/Frameworks/TWAINDSM.framework/TWAINDSM", "TW_IDENTITY_MACOSX"),
|
||||
("LinuxDSM", "/usr/local/lib/libtwaindsm.so", "TW_IDENTITY_LEGACY"),
|
||||
("Linux64DSM", "/usr/local/lib64/libtwaindsm.so", "TW_IDENTITY_LEGACY"),
|
||||
("LinuxBotched64DSM", "/usr/local/lib/libtwaindsm.so.2.3.2", "TW_IDENTITY"),
|
||||
("WinLegacyDSM", "twain_32.dll", "TW_IDENTITY_LEGACY"),
|
||||
("WinNewDSM", "twaindsm.dll", "TW_IDENTITY_LEGACY")
|
||||
List<(string className, string dllPath, string identityClass, string addlInfo)> outputs = new() {
|
||||
("OSXLegacyDSM", "/System/Library/Frameworks/framework/TWAIN", "TW_IDENTITY_MACOSX", ""),
|
||||
("OSXNewDSM", "/Library/Frameworks/TWAINDSM.framework/TWAINDSM", "TW_IDENTITY_MACOSX", ""),
|
||||
("LinuxDSM", "/usr/local/lib/libtwaindsm.so", "TW_IDENTITY_LEGACY", ""),
|
||||
("Linux64DSM", "/usr/local/lib64/libtwaindsm.so", "TW_IDENTITY_LEGACY", "For versions since 2.4."),
|
||||
("LinuxBotched64DSM", "/usr/local/lib/libtwaindsm.so.2.3.2", "TW_IDENTITY", "For versions before 2.4."),
|
||||
("WinLegacyDSM", "twain_32.dll", "TW_IDENTITY_LEGACY", "For 32bit only."),
|
||||
("WinNewDSM", "twaindsm.dll", "TW_IDENTITY_LEGACY", "")
|
||||
};
|
||||
|
||||
foreach(var file in outputs) {
|
||||
@@ -25,7 +25,7 @@ using System.Runtime.InteropServices;
|
||||
namespace NTwain.DSM
|
||||
{
|
||||
/// <summary>
|
||||
/// Low-level pinvoke methods using <#= file.dllPath #>.
|
||||
/// Low-level pinvoke methods using <#= file.dllPath #>. <#= file.addlInfo #>
|
||||
/// </summary>
|
||||
public static class <#= file.className #>
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
|
||||
namespace NTwain.DSM
|
||||
{
|
||||
/// <summary>
|
||||
/// Low-level pinvoke methods using /usr/local/lib64/libtwaindsm.so.
|
||||
/// Low-level pinvoke methods using /usr/local/lib64/libtwaindsm.so. For versions since 2.4.
|
||||
/// </summary>
|
||||
public static class Linux64DSM
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
|
||||
namespace NTwain.DSM
|
||||
{
|
||||
/// <summary>
|
||||
/// Low-level pinvoke methods using /usr/local/lib/libtwaindsm.so.2.3.2.
|
||||
/// Low-level pinvoke methods using /usr/local/lib/libtwaindsm.so.2.3.2. For versions before 2.4.
|
||||
/// </summary>
|
||||
public static class LinuxBotched64DSM
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
|
||||
namespace NTwain.DSM
|
||||
{
|
||||
/// <summary>
|
||||
/// Low-level pinvoke methods using /usr/local/lib/libtwaindsm.so.
|
||||
/// Low-level pinvoke methods using /usr/local/lib/libtwaindsm.so.
|
||||
/// </summary>
|
||||
public static class LinuxDSM
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
|
||||
namespace NTwain.DSM
|
||||
{
|
||||
/// <summary>
|
||||
/// Low-level pinvoke methods using /System/Library/Frameworks/framework/TWAIN.
|
||||
/// Low-level pinvoke methods using /System/Library/Frameworks/framework/TWAIN.
|
||||
/// </summary>
|
||||
public static class OSXLegacyDSM
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
|
||||
namespace NTwain.DSM
|
||||
{
|
||||
/// <summary>
|
||||
/// Low-level pinvoke methods using /Library/Frameworks/TWAINDSM.framework/TWAINDSM.
|
||||
/// Low-level pinvoke methods using /Library/Frameworks/TWAINDSM.framework/TWAINDSM.
|
||||
/// </summary>
|
||||
public static class OSXNewDSM
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
|
||||
namespace NTwain.DSM
|
||||
{
|
||||
/// <summary>
|
||||
/// Low-level pinvoke methods using twain_32.dll.
|
||||
/// Low-level pinvoke methods using twain_32.dll. For 32bit only.
|
||||
/// </summary>
|
||||
public static class WinLegacyDSM
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
|
||||
namespace NTwain.DSM
|
||||
{
|
||||
/// <summary>
|
||||
/// Low-level pinvoke methods using twaindsm.dll.
|
||||
/// Low-level pinvoke methods using twaindsm.dll.
|
||||
/// </summary>
|
||||
public static class WinNewDSM
|
||||
{
|
||||
|
||||
@@ -724,8 +724,7 @@ namespace NTwain.Data
|
||||
|
||||
//// unsafe method with 1 copy (does it work?)
|
||||
//sbyte* bytes = (sbyte*)locked;
|
||||
//var str = new string(bytes, 0, length, Encoding.UTF8);
|
||||
//return str;
|
||||
//val = new string(bytes, 0, length, Encoding.UTF8);
|
||||
#else
|
||||
val = Marshal.PtrToStringUTF8(locked, (int)Size);
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace NTwain
|
||||
{
|
||||
/// <summary>
|
||||
/// An <see cref="IThreadMarshaller"/> that can be used
|
||||
/// to integrate <see cref="TwainSession"/> with
|
||||
/// to integrate <see cref="TwainAppSession"/> with
|
||||
/// an existing Winforms app.
|
||||
/// </summary>
|
||||
public class WinformMarshaller : IThreadMarshaller
|
||||
@@ -32,7 +32,7 @@ namespace NTwain
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IThreadMarshaller"/> that can be used
|
||||
/// to integrate <see cref="TwainSession"/> with
|
||||
/// to integrate <see cref="TwainAppSession"/> with
|
||||
/// an existing WPF app.
|
||||
/// </summary>
|
||||
public class WpfMarshaller : IThreadMarshaller
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
All TWAIN operations are done through the a combination of
|
||||
Data Group (DG), Data Argument Type (DAT), and Message (MSG)
|
||||
triplets. Rather than dealing with all the combinations
|
||||
directly and risk passing the wrong thing, all valid triplet
|
||||
combinations are simply made available under this namespace.
|
||||
directly in the DSM pinvokes and risk passing the wrong thing,
|
||||
all valid triplet combinations are made available under this namespace.
|
||||
|
||||
Example:
|
||||
To get the status of the DS, just use the
|
||||
"Get" method (represents MSG), in the
|
||||
"Status" property (represnts DAT), in the
|
||||
"DGControl" class (represents DG).
|
||||
To get the status of the DS, the triplet is
|
||||
`DG_Control / DAT_STATUS / MSG_GET` in the documentation.
|
||||
With this wrapper you can use a similar call path:
|
||||
|
||||
or better explained in code:
|
||||
```cs
|
||||
DGControl.Status.Get(...);
|
||||
```
|
||||
|
||||
DGControl.Status.Get(...)
|
||||
Only triplets usable by the application-side are defined here.
|
||||
|
||||
Only triplets usable by the
|
||||
application-side are defined here.
|
||||
|
||||
These are still low-level calls and TwainSession is the higher
|
||||
level abstraction with some state keeping and other checks for ease of use.
|
||||
These are still relatively low-level calls and `TwainAppSession` is the next higher
|
||||
level abstraction with some state keeping and other dotnet-friendly methods
|
||||
and events for regular use.
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace NTwain
|
||||
{
|
||||
// this file contains callback methods
|
||||
|
||||
partial class TwainSession
|
||||
partial class TwainAppSession
|
||||
{
|
||||
|
||||
delegate ushort LegacyIDCallbackDelegate(
|
||||
@@ -7,7 +7,7 @@ namespace NTwain
|
||||
{
|
||||
// this file contains capability mgmt methods
|
||||
|
||||
partial class TwainSession
|
||||
partial class TwainAppSession
|
||||
{
|
||||
///// <summary>
|
||||
///// Gets all the supported caps for the current source.
|
||||
@@ -7,7 +7,7 @@ namespace NTwain
|
||||
{
|
||||
// this file contains memory methods
|
||||
|
||||
partial class TwainSession : IMemoryManager
|
||||
partial class TwainAppSession : IMemoryManager
|
||||
{
|
||||
internal TW_ENTRYPOINT_DELEGATES _entryPoint;
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace NTwain
|
||||
{
|
||||
// this file contains property and event definitions
|
||||
|
||||
partial class TwainSession
|
||||
partial class TwainAppSession
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the app identity.
|
||||
@@ -119,22 +119,22 @@ namespace NTwain
|
||||
/// <summary>
|
||||
/// Fires when <see cref="State"/> changes.
|
||||
/// </summary>
|
||||
public event Action<TwainSession, STATE>? StateChanged;
|
||||
public event Action<TwainAppSession, STATE>? StateChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Fires when <see cref="DefaultSource"/> changes.
|
||||
/// </summary>
|
||||
public event Action<TwainSession, TW_IDENTITY_LEGACY>? DefaultSourceChanged;
|
||||
public event Action<TwainAppSession, TW_IDENTITY_LEGACY>? DefaultSourceChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Fires when <see cref="CurrentSource"/> changes.
|
||||
/// </summary>
|
||||
public event Action<TwainSession, TW_IDENTITY_LEGACY>? CurrentSourceChanged;
|
||||
public event Action<TwainAppSession, TW_IDENTITY_LEGACY>? CurrentSourceChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Fires when the source has some device event happening.
|
||||
/// </summary>
|
||||
public event Action<TwainSession, TW_DEVICEEVENT>? DeviceEvent;
|
||||
public event Action<TwainAppSession, TW_DEVICEEVENT>? DeviceEvent;
|
||||
|
||||
/// <summary>
|
||||
/// Fires when there's an error during transfer.
|
||||
@@ -6,7 +6,7 @@ namespace NTwain
|
||||
{
|
||||
// this file contains data source utilities
|
||||
|
||||
partial class TwainSession
|
||||
partial class TwainAppSession
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all available sources.
|
||||
@@ -15,7 +15,7 @@ namespace NTwain
|
||||
|
||||
// contains parts for winform/wpf message loop integration
|
||||
|
||||
partial class TwainSession : IMessageFilter
|
||||
partial class TwainAppSession : IMessageFilter
|
||||
{
|
||||
HwndSource? _wpfhook;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace NTwain
|
||||
{
|
||||
// this file contains various xfer methods
|
||||
|
||||
partial class TwainSession
|
||||
partial class TwainAppSession
|
||||
{
|
||||
/// <summary>
|
||||
/// Start the transfer loop.
|
||||
@@ -11,7 +11,7 @@ namespace NTwain
|
||||
{
|
||||
// this file contains initialization/cleanup things.
|
||||
|
||||
public partial class TwainSession : IDisposable
|
||||
public partial class TwainAppSession : IDisposable
|
||||
{
|
||||
static bool __encodingRegistered;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace NTwain
|
||||
/// <param name="exeFilePath"></param>
|
||||
/// <param name="appLanguage"></param>
|
||||
/// <param name="appCountry"></param>
|
||||
public TwainSession(IThreadMarshaller uiThreadMarshaller,
|
||||
public TwainAppSession(IThreadMarshaller uiThreadMarshaller,
|
||||
string exeFilePath,
|
||||
TWLG appLanguage = TWLG.ENGLISH_USA, TWCY appCountry = TWCY.USA) :
|
||||
this(uiThreadMarshaller, FileVersionInfo.GetVersionInfo(exeFilePath), appLanguage, appCountry)
|
||||
@@ -34,7 +34,7 @@ namespace NTwain
|
||||
/// <param name="appInfo"></param>
|
||||
/// <param name="appLanguage"></param>
|
||||
/// <param name="appCountry"></param>
|
||||
public TwainSession(IThreadMarshaller uiThreadMarshaller,
|
||||
public TwainAppSession(IThreadMarshaller uiThreadMarshaller,
|
||||
FileVersionInfo appInfo,
|
||||
TWLG appLanguage = TWLG.ENGLISH_USA, TWCY appCountry = TWCY.USA) :
|
||||
this(uiThreadMarshaller,
|
||||
@@ -56,7 +56,7 @@ namespace NTwain
|
||||
/// <param name="appLanguage"></param>
|
||||
/// <param name="appCountry"></param>
|
||||
/// <param name="supportedTypes"></param>
|
||||
public TwainSession(IThreadMarshaller uiThreadMarshaller,
|
||||
public TwainAppSession(IThreadMarshaller uiThreadMarshaller,
|
||||
string companyName, string productFamily, string productName,
|
||||
Version productVersion, string productDescription = "",
|
||||
TWLG appLanguage = TWLG.ENGLISH_USA, TWCY appCountry = TWCY.USA,
|
||||
Reference in New Issue
Block a user