diff --git a/LICENSE.txt b/LICENSE.txt
index cbedf08..b787503 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -2,7 +2,7 @@
The MIT License (MIT)
-Copyright (c) 2012 - 2023 Eugene Wang
+Copyright (c) 2012 - 2026 Eugene Wang
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
diff --git a/NTwain4.sln b/NTwain4.sln
deleted file mode 100644
index 7cfaa23..0000000
--- a/NTwain4.sln
+++ /dev/null
@@ -1,160 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.1.32414.318
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_common", "_common", "{4CE0B9ED-2CD1-440F-B4EC-35ECA6D61EFE}"
- ProjectSection(SolutionItems) = preProject
- .gitignore = .gitignore
- Build.cmd = Build.cmd
- src\Directory.Build.props = src\Directory.Build.props
- LICENSE.txt = LICENSE.txt
- README.md = README.md
- EndProjectSection
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{707B4313-8EF8-4D0F-A95E-590783422187}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_twain-doc", "_twain-doc", "{0C94E5AD-E226-4A30-92B4-C28FE5B7FC23}"
- ProjectSection(SolutionItems) = preProject
- twain-doc\TWAIN-2.5-Features.pdf = twain-doc\TWAIN-2.5-Features.pdf
- twain-doc\TWAIN-2.5-Specification.pdf = twain-doc\TWAIN-2.5-Specification.pdf
- twain-doc\twain2.5.h = twain-doc\twain2.5.h
- EndProjectSection
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NTwain", "src\NTwain\NTwain.csproj", "{3C8A3CF9-A60D-4F21-B866-D291A7AABD4A}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinForm32", "samples\WinForm32\WinForm32.csproj", "{7792A94E-D0B4-440D-8BD5-CA1CA548782C}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinForm64", "samples\WinForm64\WinForm64.csproj", "{C9666CB2-C9A6-48C8-AB51-D616A48058A7}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "csizes", "csizes\csizes.vcxproj", "{1AABD2DC-3F81-4301-938B-3EC2EDEF38D4}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinConsole32", "samples\WinConsole32\WinConsole32.csproj", "{4E2417E7-FDC3-46D7-B976-84A97B500B74}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScannerTester", "samples\ScannerTester\ScannerTester.csproj", "{EEFDA89D-7E11-7609-5383-FA1ADEA88CF4}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Debug|ARM64 = Debug|ARM64
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|Any CPU = Release|Any CPU
- Release|ARM64 = Release|ARM64
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {3C8A3CF9-A60D-4F21-B866-D291A7AABD4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {3C8A3CF9-A60D-4F21-B866-D291A7AABD4A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {3C8A3CF9-A60D-4F21-B866-D291A7AABD4A}.Debug|ARM64.ActiveCfg = Debug|Any CPU
- {3C8A3CF9-A60D-4F21-B866-D291A7AABD4A}.Debug|ARM64.Build.0 = Debug|Any CPU
- {3C8A3CF9-A60D-4F21-B866-D291A7AABD4A}.Debug|x64.ActiveCfg = Debug|Any CPU
- {3C8A3CF9-A60D-4F21-B866-D291A7AABD4A}.Debug|x64.Build.0 = Debug|Any CPU
- {3C8A3CF9-A60D-4F21-B866-D291A7AABD4A}.Debug|x86.ActiveCfg = Debug|Any CPU
- {3C8A3CF9-A60D-4F21-B866-D291A7AABD4A}.Debug|x86.Build.0 = Debug|Any CPU
- {3C8A3CF9-A60D-4F21-B866-D291A7AABD4A}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {3C8A3CF9-A60D-4F21-B866-D291A7AABD4A}.Release|Any CPU.Build.0 = Release|Any CPU
- {3C8A3CF9-A60D-4F21-B866-D291A7AABD4A}.Release|ARM64.ActiveCfg = Release|Any CPU
- {3C8A3CF9-A60D-4F21-B866-D291A7AABD4A}.Release|ARM64.Build.0 = Release|Any CPU
- {3C8A3CF9-A60D-4F21-B866-D291A7AABD4A}.Release|x64.ActiveCfg = Release|Any CPU
- {3C8A3CF9-A60D-4F21-B866-D291A7AABD4A}.Release|x64.Build.0 = Release|Any CPU
- {3C8A3CF9-A60D-4F21-B866-D291A7AABD4A}.Release|x86.ActiveCfg = Release|Any CPU
- {3C8A3CF9-A60D-4F21-B866-D291A7AABD4A}.Release|x86.Build.0 = Release|Any CPU
- {7792A94E-D0B4-440D-8BD5-CA1CA548782C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7792A94E-D0B4-440D-8BD5-CA1CA548782C}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7792A94E-D0B4-440D-8BD5-CA1CA548782C}.Debug|ARM64.ActiveCfg = Debug|Any CPU
- {7792A94E-D0B4-440D-8BD5-CA1CA548782C}.Debug|ARM64.Build.0 = Debug|Any CPU
- {7792A94E-D0B4-440D-8BD5-CA1CA548782C}.Debug|x64.ActiveCfg = Debug|Any CPU
- {7792A94E-D0B4-440D-8BD5-CA1CA548782C}.Debug|x64.Build.0 = Debug|Any CPU
- {7792A94E-D0B4-440D-8BD5-CA1CA548782C}.Debug|x86.ActiveCfg = Debug|Any CPU
- {7792A94E-D0B4-440D-8BD5-CA1CA548782C}.Debug|x86.Build.0 = Debug|Any CPU
- {7792A94E-D0B4-440D-8BD5-CA1CA548782C}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7792A94E-D0B4-440D-8BD5-CA1CA548782C}.Release|Any CPU.Build.0 = Release|Any CPU
- {7792A94E-D0B4-440D-8BD5-CA1CA548782C}.Release|ARM64.ActiveCfg = Release|Any CPU
- {7792A94E-D0B4-440D-8BD5-CA1CA548782C}.Release|ARM64.Build.0 = Release|Any CPU
- {7792A94E-D0B4-440D-8BD5-CA1CA548782C}.Release|x64.ActiveCfg = Release|Any CPU
- {7792A94E-D0B4-440D-8BD5-CA1CA548782C}.Release|x64.Build.0 = Release|Any CPU
- {7792A94E-D0B4-440D-8BD5-CA1CA548782C}.Release|x86.ActiveCfg = Release|Any CPU
- {7792A94E-D0B4-440D-8BD5-CA1CA548782C}.Release|x86.Build.0 = Release|Any CPU
- {C9666CB2-C9A6-48C8-AB51-D616A48058A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {C9666CB2-C9A6-48C8-AB51-D616A48058A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {C9666CB2-C9A6-48C8-AB51-D616A48058A7}.Debug|ARM64.ActiveCfg = Debug|Any CPU
- {C9666CB2-C9A6-48C8-AB51-D616A48058A7}.Debug|ARM64.Build.0 = Debug|Any CPU
- {C9666CB2-C9A6-48C8-AB51-D616A48058A7}.Debug|x64.ActiveCfg = Debug|Any CPU
- {C9666CB2-C9A6-48C8-AB51-D616A48058A7}.Debug|x64.Build.0 = Debug|Any CPU
- {C9666CB2-C9A6-48C8-AB51-D616A48058A7}.Debug|x86.ActiveCfg = Debug|Any CPU
- {C9666CB2-C9A6-48C8-AB51-D616A48058A7}.Debug|x86.Build.0 = Debug|Any CPU
- {C9666CB2-C9A6-48C8-AB51-D616A48058A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {C9666CB2-C9A6-48C8-AB51-D616A48058A7}.Release|Any CPU.Build.0 = Release|Any CPU
- {C9666CB2-C9A6-48C8-AB51-D616A48058A7}.Release|ARM64.ActiveCfg = Release|Any CPU
- {C9666CB2-C9A6-48C8-AB51-D616A48058A7}.Release|ARM64.Build.0 = Release|Any CPU
- {C9666CB2-C9A6-48C8-AB51-D616A48058A7}.Release|x64.ActiveCfg = Release|Any CPU
- {C9666CB2-C9A6-48C8-AB51-D616A48058A7}.Release|x64.Build.0 = Release|Any CPU
- {C9666CB2-C9A6-48C8-AB51-D616A48058A7}.Release|x86.ActiveCfg = Release|Any CPU
- {C9666CB2-C9A6-48C8-AB51-D616A48058A7}.Release|x86.Build.0 = Release|Any CPU
- {1AABD2DC-3F81-4301-938B-3EC2EDEF38D4}.Debug|Any CPU.ActiveCfg = Debug|x64
- {1AABD2DC-3F81-4301-938B-3EC2EDEF38D4}.Debug|Any CPU.Build.0 = Debug|x64
- {1AABD2DC-3F81-4301-938B-3EC2EDEF38D4}.Debug|ARM64.ActiveCfg = Debug|x64
- {1AABD2DC-3F81-4301-938B-3EC2EDEF38D4}.Debug|ARM64.Build.0 = Debug|x64
- {1AABD2DC-3F81-4301-938B-3EC2EDEF38D4}.Debug|x64.ActiveCfg = Debug|x64
- {1AABD2DC-3F81-4301-938B-3EC2EDEF38D4}.Debug|x64.Build.0 = Debug|x64
- {1AABD2DC-3F81-4301-938B-3EC2EDEF38D4}.Debug|x86.ActiveCfg = Debug|Win32
- {1AABD2DC-3F81-4301-938B-3EC2EDEF38D4}.Debug|x86.Build.0 = Debug|Win32
- {1AABD2DC-3F81-4301-938B-3EC2EDEF38D4}.Release|Any CPU.ActiveCfg = Release|x64
- {1AABD2DC-3F81-4301-938B-3EC2EDEF38D4}.Release|Any CPU.Build.0 = Release|x64
- {1AABD2DC-3F81-4301-938B-3EC2EDEF38D4}.Release|ARM64.ActiveCfg = Release|x64
- {1AABD2DC-3F81-4301-938B-3EC2EDEF38D4}.Release|ARM64.Build.0 = Release|x64
- {1AABD2DC-3F81-4301-938B-3EC2EDEF38D4}.Release|x64.ActiveCfg = Release|x64
- {1AABD2DC-3F81-4301-938B-3EC2EDEF38D4}.Release|x64.Build.0 = Release|x64
- {1AABD2DC-3F81-4301-938B-3EC2EDEF38D4}.Release|x86.ActiveCfg = Release|Win32
- {1AABD2DC-3F81-4301-938B-3EC2EDEF38D4}.Release|x86.Build.0 = Release|Win32
- {4E2417E7-FDC3-46D7-B976-84A97B500B74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {4E2417E7-FDC3-46D7-B976-84A97B500B74}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {4E2417E7-FDC3-46D7-B976-84A97B500B74}.Debug|ARM64.ActiveCfg = Debug|Any CPU
- {4E2417E7-FDC3-46D7-B976-84A97B500B74}.Debug|ARM64.Build.0 = Debug|Any CPU
- {4E2417E7-FDC3-46D7-B976-84A97B500B74}.Debug|x64.ActiveCfg = Debug|Any CPU
- {4E2417E7-FDC3-46D7-B976-84A97B500B74}.Debug|x64.Build.0 = Debug|Any CPU
- {4E2417E7-FDC3-46D7-B976-84A97B500B74}.Debug|x86.ActiveCfg = Debug|Any CPU
- {4E2417E7-FDC3-46D7-B976-84A97B500B74}.Debug|x86.Build.0 = Debug|Any CPU
- {4E2417E7-FDC3-46D7-B976-84A97B500B74}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {4E2417E7-FDC3-46D7-B976-84A97B500B74}.Release|Any CPU.Build.0 = Release|Any CPU
- {4E2417E7-FDC3-46D7-B976-84A97B500B74}.Release|ARM64.ActiveCfg = Release|Any CPU
- {4E2417E7-FDC3-46D7-B976-84A97B500B74}.Release|ARM64.Build.0 = Release|Any CPU
- {4E2417E7-FDC3-46D7-B976-84A97B500B74}.Release|x64.ActiveCfg = Release|Any CPU
- {4E2417E7-FDC3-46D7-B976-84A97B500B74}.Release|x64.Build.0 = Release|Any CPU
- {4E2417E7-FDC3-46D7-B976-84A97B500B74}.Release|x86.ActiveCfg = Release|Any CPU
- {4E2417E7-FDC3-46D7-B976-84A97B500B74}.Release|x86.Build.0 = Release|Any CPU
- {EEFDA89D-7E11-7609-5383-FA1ADEA88CF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {EEFDA89D-7E11-7609-5383-FA1ADEA88CF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {EEFDA89D-7E11-7609-5383-FA1ADEA88CF4}.Debug|ARM64.ActiveCfg = Debug|Any CPU
- {EEFDA89D-7E11-7609-5383-FA1ADEA88CF4}.Debug|ARM64.Build.0 = Debug|Any CPU
- {EEFDA89D-7E11-7609-5383-FA1ADEA88CF4}.Debug|x64.ActiveCfg = Debug|Any CPU
- {EEFDA89D-7E11-7609-5383-FA1ADEA88CF4}.Debug|x64.Build.0 = Debug|Any CPU
- {EEFDA89D-7E11-7609-5383-FA1ADEA88CF4}.Debug|x86.ActiveCfg = Debug|Any CPU
- {EEFDA89D-7E11-7609-5383-FA1ADEA88CF4}.Debug|x86.Build.0 = Debug|Any CPU
- {EEFDA89D-7E11-7609-5383-FA1ADEA88CF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {EEFDA89D-7E11-7609-5383-FA1ADEA88CF4}.Release|Any CPU.Build.0 = Release|Any CPU
- {EEFDA89D-7E11-7609-5383-FA1ADEA88CF4}.Release|ARM64.ActiveCfg = Release|Any CPU
- {EEFDA89D-7E11-7609-5383-FA1ADEA88CF4}.Release|ARM64.Build.0 = Release|Any CPU
- {EEFDA89D-7E11-7609-5383-FA1ADEA88CF4}.Release|x64.ActiveCfg = Release|Any CPU
- {EEFDA89D-7E11-7609-5383-FA1ADEA88CF4}.Release|x64.Build.0 = Release|Any CPU
- {EEFDA89D-7E11-7609-5383-FA1ADEA88CF4}.Release|x86.ActiveCfg = Release|Any CPU
- {EEFDA89D-7E11-7609-5383-FA1ADEA88CF4}.Release|x86.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(NestedProjects) = preSolution
- {7792A94E-D0B4-440D-8BD5-CA1CA548782C} = {707B4313-8EF8-4D0F-A95E-590783422187}
- {C9666CB2-C9A6-48C8-AB51-D616A48058A7} = {707B4313-8EF8-4D0F-A95E-590783422187}
- {4E2417E7-FDC3-46D7-B976-84A97B500B74} = {707B4313-8EF8-4D0F-A95E-590783422187}
- {EEFDA89D-7E11-7609-5383-FA1ADEA88CF4} = {707B4313-8EF8-4D0F-A95E-590783422187}
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {7459323B-44F6-4E07-8574-E1B4B525086B}
- EndGlobalSection
- GlobalSection(TestCaseManagementSettings) = postSolution
- CategoryFile = NTwain.vsmdi
- EndGlobalSection
-EndGlobal
diff --git a/NTwain4.slnx b/NTwain4.slnx
new file mode 100644
index 0000000..98ffbab
--- /dev/null
+++ b/NTwain4.slnx
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/README.md b/README.md
index ce7b487..354230d 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ the TWAIN Working Group.
V4 of this lib has these features:
* Targets TWAIN version 2.5.
-* Runs under supported framework (4.6.2+) and netcore variants (6.0+).
+* Runs under supported framework (4.6.2+) and netcore variants (8.0+).
* Easier to use than the low-level C API with many dotnet niceties.
* Attempt at reducing heap allocations compared to previous versions.
@@ -23,17 +23,8 @@ V4 of this lib has these features:
These are not implemented yet in this early version:
-* Image memory transfer (DAT_IMAGEMEMXFER).
-* Audio native transfer (probably never will).
-
-As with previous versions, only Windows has been tested on and thus
-supported really. Other changes include
-
* All TWAIN data types are now struct instead of class (and they come
-from [twaincs](https://github.com/twain/twain-cs) for correctness. It may have
-been easier to implement them as classes when starting out this lib, but
-it's not really ideal anymore. The change also makes them match the twain.h
-names and the spec pdf.
+from [twaincs](https://github.com/twain/twain-cs) for correctness.
* All lower-level TWAIN APIs are public instead of hidden away.
diff --git a/csizes/WM_Constants.txt b/csizes/WM_Constants.txt
new file mode 100644
index 0000000..81bbe4d
--- /dev/null
+++ b/csizes/WM_Constants.txt
@@ -0,0 +1,372 @@
+Windows Message (WM_) Constants and Values
+===========================================
+Comprehensive list of Windows Message constants from WinUser.h (Windows SDK)
+
+========================================
+BASIC WINDOW MESSAGES
+========================================
+#define WM_NULL 0x0000
+#define WM_CREATE 0x0001
+#define WM_DESTROY 0x0002
+#define WM_MOVE 0x0003
+#define WM_SIZE 0x0005
+#define WM_ACTIVATE 0x0006
+#define WM_SETFOCUS 0x0007
+#define WM_KILLFOCUS 0x0008
+#define WM_ENABLE 0x000A
+#define WM_SETREDRAW 0x000B
+#define WM_SETTEXT 0x000C
+#define WM_GETTEXT 0x000D
+#define WM_GETTEXTLENGTH 0x000E
+#define WM_PAINT 0x000F
+#define WM_CLOSE 0x0010
+#define WM_QUERYENDSESSION 0x0011
+#define WM_QUIT 0x0012
+#define WM_QUERYOPEN 0x0013
+#define WM_ERASEBKGND 0x0014
+#define WM_SYSCOLORCHANGE 0x0015
+#define WM_ENDSESSION 0x0016
+#define WM_SHOWWINDOW 0x0018
+#define WM_WININICHANGE 0x001A
+#define WM_SETTINGCHANGE 0x001A /* Same as WM_WININICHANGE */
+#define WM_DEVMODECHANGE 0x001B
+#define WM_ACTIVATEAPP 0x001C
+#define WM_FONTCHANGE 0x001D
+#define WM_TIMECHANGE 0x001E
+#define WM_CANCELMODE 0x001F
+#define WM_SETCURSOR 0x0020
+#define WM_MOUSEACTIVATE 0x0021
+#define WM_CHILDACTIVATE 0x0022
+#define WM_QUEUESYNC 0x0023
+#define WM_GETMINMAXINFO 0x0024
+#define WM_PAINTICON 0x0026
+#define WM_ICONERASEBKGND 0x0027
+#define WM_NEXTDLGCTL 0x0028
+#define WM_SPOOLERSTATUS 0x002A
+#define WM_DRAWITEM 0x002B
+#define WM_MEASUREITEM 0x002C
+#define WM_DELETEITEM 0x002D
+#define WM_VKEYTOITEM 0x002E
+#define WM_CHARTOITEM 0x002F
+#define WM_SETFONT 0x0030
+#define WM_GETFONT 0x0031
+#define WM_SETHOTKEY 0x0032
+#define WM_GETHOTKEY 0x0033
+#define WM_QUERYDRAGICON 0x0037
+#define WM_COMPAREITEM 0x0039
+#define WM_GETOBJECT 0x003D
+#define WM_COMPACTING 0x0041
+#define WM_COMMNOTIFY 0x0044 /* No longer supported */
+#define WM_WINDOWPOSCHANGING 0x0046
+#define WM_WINDOWPOSCHANGED 0x0047
+#define WM_POWER 0x0048
+#define WM_COPYDATA 0x004A
+#define WM_CANCELJOURNAL 0x004B
+#define WM_NOTIFY 0x004E
+#define WM_INPUTLANGCHANGEREQUEST 0x0050
+#define WM_INPUTLANGCHANGE 0x0051
+#define WM_TCARD 0x0052
+#define WM_HELP 0x0053
+#define WM_USERCHANGED 0x0054
+#define WM_NOTIFYFORMAT 0x0055
+
+========================================
+NONCLIENT MESSAGES
+========================================
+#define WM_CONTEXTMENU 0x007B
+#define WM_STYLECHANGING 0x007C
+#define WM_STYLECHANGED 0x007D
+#define WM_DISPLAYCHANGE 0x007E
+#define WM_GETICON 0x007F
+#define WM_SETICON 0x0080
+#define WM_NCCREATE 0x0081
+#define WM_NCDESTROY 0x0082
+#define WM_NCCALCSIZE 0x0083
+#define WM_NCHITTEST 0x0084
+#define WM_NCPAINT 0x0085
+#define WM_NCACTIVATE 0x0086
+#define WM_GETDLGCODE 0x0087
+#define WM_SYNCPAINT 0x0088
+#define WM_NCMOUSEMOVE 0x00A0
+#define WM_NCLBUTTONDOWN 0x00A1
+#define WM_NCLBUTTONUP 0x00A2
+#define WM_NCLBUTTONDBLCLK 0x00A3
+#define WM_NCRBUTTONDOWN 0x00A4
+#define WM_NCRBUTTONUP 0x00A5
+#define WM_NCRBUTTONDBLCLK 0x00A6
+#define WM_NCMBUTTONDOWN 0x00A7
+#define WM_NCMBUTTONUP 0x00A8
+#define WM_NCMBUTTONDBLCLK 0x00A9
+#define WM_NCXBUTTONDOWN 0x00AB
+#define WM_NCXBUTTONUP 0x00AC
+#define WM_NCXBUTTONDBLCLK 0x00AD
+
+========================================
+INPUT MESSAGES
+========================================
+#define WM_INPUT_DEVICE_CHANGE 0x00FE
+#define WM_INPUT 0x00FF
+
+========================================
+KEYBOARD MESSAGES
+========================================
+#define WM_KEYFIRST 0x0100
+#define WM_KEYDOWN 0x0100 /* Same as WM_KEYFIRST */
+#define WM_KEYUP 0x0101
+#define WM_CHAR 0x0102
+#define WM_DEADCHAR 0x0103
+#define WM_SYSKEYDOWN 0x0104
+#define WM_SYSKEYUP 0x0105
+#define WM_SYSCHAR 0x0106
+#define WM_SYSDEADCHAR 0x0107
+#define WM_UNICHAR 0x0109
+#define WM_KEYLAST 0x0109 /* Same as WM_UNICHAR */
+
+========================================
+IME MESSAGES
+========================================
+#define WM_IME_STARTCOMPOSITION 0x010D
+#define WM_IME_ENDCOMPOSITION 0x010E
+#define WM_IME_COMPOSITION 0x010F
+#define WM_IME_KEYLAST 0x010F
+
+========================================
+DIALOG & COMMAND MESSAGES
+========================================
+#define WM_INITDIALOG 0x0110
+#define WM_COMMAND 0x0111
+#define WM_SYSCOMMAND 0x0112
+#define WM_TIMER 0x0113
+#define WM_HSCROLL 0x0114
+#define WM_VSCROLL 0x0115
+#define WM_INITMENU 0x0116
+#define WM_INITMENUPOPUP 0x0117
+#define WM_GESTURE 0x0119
+#define WM_GESTURENOTIFY 0x011A
+#define WM_MENUSELECT 0x011F
+#define WM_MENUCHAR 0x0120
+#define WM_ENTERIDLE 0x0121
+#define WM_MENURBUTTONUP 0x0122
+#define WM_MENUDRAG 0x0123
+#define WM_MENUGETOBJECT 0x0124
+#define WM_UNINITMENUPOPUP 0x0125
+#define WM_MENUCOMMAND 0x0126
+#define WM_CHANGEUISTATE 0x0127
+#define WM_UPDATEUISTATE 0x0128
+#define WM_QUERYUISTATE 0x0129
+
+========================================
+CONTROL COLOR MESSAGES
+========================================
+#define WM_CTLCOLORMSGBOX 0x0132
+#define WM_CTLCOLOREDIT 0x0133
+#define WM_CTLCOLORLISTBOX 0x0134
+#define WM_CTLCOLORBTN 0x0135
+#define WM_CTLCOLORDLG 0x0136
+#define WM_CTLCOLORSCROLLBAR 0x0137
+#define WM_CTLCOLORSTATIC 0x0138
+
+========================================
+MENU MESSAGES
+========================================
+#define MN_GETHMENU 0x01E1
+
+========================================
+MOUSE MESSAGES
+========================================
+#define WM_MOUSEFIRST 0x0200
+#define WM_MOUSEMOVE 0x0200 /* Same as WM_MOUSEFIRST */
+#define WM_LBUTTONDOWN 0x0201
+#define WM_LBUTTONUP 0x0202
+#define WM_LBUTTONDBLCLK 0x0203
+#define WM_RBUTTONDOWN 0x0204
+#define WM_RBUTTONUP 0x0205
+#define WM_RBUTTONDBLCLK 0x0206
+#define WM_MBUTTONDOWN 0x0207
+#define WM_MBUTTONUP 0x0208
+#define WM_MBUTTONDBLCLK 0x0209
+#define WM_MOUSEWHEEL 0x020A
+#define WM_XBUTTONDOWN 0x020B
+#define WM_XBUTTONUP 0x020C
+#define WM_XBUTTONDBLCLK 0x020D
+#define WM_MOUSEHWHEEL 0x020E
+#define WM_MOUSELAST 0x020E /* Same as WM_MOUSEHWHEEL */
+
+========================================
+PARENT NOTIFICATION & MENU LOOP
+========================================
+#define WM_PARENTNOTIFY 0x0210
+#define WM_ENTERMENULOOP 0x0211
+#define WM_EXITMENULOOP 0x0212
+#define WM_NEXTMENU 0x0213
+#define WM_SIZING 0x0214
+#define WM_CAPTURECHANGED 0x0215
+#define WM_MOVING 0x0216
+#define WM_POWERBROADCAST 0x0218
+#define WM_DEVICECHANGE 0x0219
+
+========================================
+MDI MESSAGES
+========================================
+#define WM_MDICREATE 0x0220
+#define WM_MDIDESTROY 0x0221
+#define WM_MDIACTIVATE 0x0222
+#define WM_MDIRESTORE 0x0223
+#define WM_MDINEXT 0x0224
+#define WM_MDIMAXIMIZE 0x0225
+#define WM_MDITILE 0x0226
+#define WM_MDICASCADE 0x0227
+#define WM_MDIICONARRANGE 0x0228
+#define WM_MDIGETACTIVE 0x0229
+#define WM_MDISETMENU 0x0230
+#define WM_ENTERSIZEMOVE 0x0231
+#define WM_EXITSIZEMOVE 0x0232
+#define WM_DROPFILES 0x0233
+#define WM_MDIREFRESHMENU 0x0234
+
+========================================
+TOUCH & POINTER MESSAGES
+========================================
+#define WM_POINTERDEVICECHANGE 0x0238
+#define WM_POINTERDEVICEINRANGE 0x0239
+#define WM_POINTERDEVICEOUTOFRANGE 0x023A
+#define WM_TOUCH 0x0240
+#define WM_NCPOINTERUPDATE 0x0241
+#define WM_NCPOINTERDOWN 0x0242
+#define WM_NCPOINTERUP 0x0243
+#define WM_POINTERUPDATE 0x0245
+#define WM_POINTERDOWN 0x0246
+#define WM_POINTERUP 0x0247
+#define WM_POINTERENTER 0x0249
+#define WM_POINTERLEAVE 0x024A
+#define WM_POINTERACTIVATE 0x024B
+#define WM_POINTERCAPTURECHANGED 0x024C
+#define WM_TOUCHHITTESTING 0x024D
+#define WM_POINTERWHEEL 0x024E
+#define WM_POINTERHWHEEL 0x024F
+#define DM_POINTERHITTEST 0x0250
+#define WM_POINTERROUTEDTO 0x0251
+#define WM_POINTERROUTEDAWAY 0x0252
+#define WM_POINTERROUTEDRELEASED 0x0253
+
+========================================
+IME MESSAGES (EXTENDED)
+========================================
+#define WM_IME_SETCONTEXT 0x0281
+#define WM_IME_NOTIFY 0x0282
+#define WM_IME_CONTROL 0x0283
+#define WM_IME_COMPOSITIONFULL 0x0284
+#define WM_IME_SELECT 0x0285
+#define WM_IME_CHAR 0x0286
+#define WM_IME_REQUEST 0x0288
+#define WM_IME_KEYDOWN 0x0290
+#define WM_IME_KEYUP 0x0291
+
+========================================
+MOUSE HOVER/LEAVE MESSAGES
+========================================
+#define WM_NCMOUSEHOVER 0x02A0
+#define WM_MOUSEHOVER 0x02A1
+#define WM_NCMOUSELEAVE 0x02A2
+#define WM_MOUSELEAVE 0x02A3
+
+========================================
+TERMINAL SERVICES
+========================================
+#define WM_WTSSESSION_CHANGE 0x02B1
+
+========================================
+TABLET MESSAGES
+========================================
+#define WM_TABLET_FIRST 0x02C0
+#define WM_TABLET_LAST 0x02DF
+
+========================================
+DPI MESSAGES
+========================================
+#define WM_DPICHANGED 0x02E0
+#define WM_DPICHANGED_BEFOREPARENT 0x02E2
+#define WM_DPICHANGED_AFTERPARENT 0x02E3
+#define WM_GETDPISCALEDSIZE 0x02E4
+
+========================================
+CLIPBOARD MESSAGES
+========================================
+#define WM_CUT 0x0300
+#define WM_COPY 0x0301
+#define WM_PASTE 0x0302
+#define WM_CLEAR 0x0303
+#define WM_UNDO 0x0304
+#define WM_RENDERFORMAT 0x0305
+#define WM_RENDERALLFORMATS 0x0306
+#define WM_DESTROYCLIPBOARD 0x0307
+#define WM_DRAWCLIPBOARD 0x0308
+#define WM_PAINTCLIPBOARD 0x0309
+#define WM_VSCROLLCLIPBOARD 0x030A
+#define WM_SIZECLIPBOARD 0x030B
+#define WM_ASKCBFORMATNAME 0x030C
+#define WM_CHANGECBCHAIN 0x030D
+#define WM_HSCROLLCLIPBOARD 0x030E
+#define WM_QUERYNEWPALETTE 0x030F
+#define WM_PALETTEISCHANGING 0x0310
+#define WM_PALETTECHANGED 0x0311
+#define WM_HOTKEY 0x0312
+#define WM_PRINT 0x0317
+#define WM_PRINTCLIENT 0x0318
+#define WM_APPCOMMAND 0x0319
+#define WM_THEMECHANGED 0x031A
+#define WM_CLIPBOARDUPDATE 0x031D
+
+========================================
+DWM (DESKTOP WINDOW MANAGER) MESSAGES
+========================================
+#define WM_DWMCOMPOSITIONCHANGED 0x031E
+#define WM_DWMNCRENDERINGCHANGED 0x031F
+#define WM_DWMCOLORIZATIONCOLORCHANGED 0x0320
+#define WM_DWMWINDOWMAXIMIZEDCHANGE 0x0321
+#define WM_DWMSENDICONICTHUMBNAIL 0x0323
+#define WM_DWMSENDICONICLIVEPREVIEWBITMAP 0x0326
+
+========================================
+MISCELLANEOUS MESSAGES
+========================================
+#define WM_GETTITLEBARINFOEX 0x033F
+
+========================================
+HANDHELD/DEVICE MESSAGES
+========================================
+#define WM_HANDHELDFIRST 0x0358
+#define WM_HANDHELDLAST 0x035F
+
+========================================
+APPLICATION FRAMEWORK MESSAGES
+========================================
+#define WM_AFXFIRST 0x0360
+#define WM_AFXLAST 0x037F
+
+========================================
+PEN WINDOWS MESSAGES
+========================================
+#define WM_PENWINFIRST 0x0380
+#define WM_PENWINLAST 0x038F
+
+========================================
+USER-DEFINED MESSAGES
+========================================
+#define WM_APP 0x8000
+#define WM_USER 0x0400
+
+====================================================
+NOTES:
+====================================================
+- WM_SETTINGCHANGE is an alias for WM_WININICHANGE (0x001A)
+- WM_KEYFIRST and WM_KEYDOWN both have the value 0x0100
+- WM_KEYLAST and WM_UNICHAR both have the value 0x0109
+- WM_MOUSEFIRST and WM_MOUSEMOVE both have the value 0x0200
+- WM_MOUSELAST and WM_MOUSEHWHEEL both have the value 0x020E
+- Values are in hexadecimal format
+- WM_USER (0x0400) through 0x7FFF: Integer messages for use by private window classes
+- WM_APP (0x8000) through 0xBFFF: Messages available for use by applications
+- 0xC000 through 0xFFFF: String messages for use by applications (RegisterWindowMessage)
+- Generated from WinUser.h (Windows SDK)
+====================================================
diff --git a/samples/ConsoleSample/ConsoleSample.csproj b/samples/ConsoleSample/ConsoleSample.csproj
new file mode 100644
index 0000000..7202b70
--- /dev/null
+++ b/samples/ConsoleSample/ConsoleSample.csproj
@@ -0,0 +1,20 @@
+
+
+
+ Exe
+ net10.0
+ enable
+ enable
+ x86;x64
+ app.manifest
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/ConsoleSample/Program.cs b/samples/ConsoleSample/Program.cs
new file mode 100644
index 0000000..ba5e6b1
--- /dev/null
+++ b/samples/ConsoleSample/Program.cs
@@ -0,0 +1,146 @@
+using NTwain;
+using NTwain.Data;
+using NTwain.Events;
+using System.Diagnostics;
+
+namespace ConsoleSample;
+
+internal class Program
+{
+ static void Main(string[] args)
+ {
+ Console.WriteLine($"[{(Environment.Is64BitProcess ? "64bit" : "32bit")}] Creating TwainAppSession instance...");
+
+ bool sourceDisabledEventFired = false;
+
+ using var twain = new NTwain.TwainAppSession();
+ twain.SourceDisabled += (s, e) =>
+ {
+ sourceDisabledEventFired = true;
+ Console.WriteLine($"Source disabled: {e.ProductName}");
+ };
+ twain.Transferred += OnTransferred;
+
+ Console.WriteLine("Opening DSM...");
+ var sts = twain.OpenDsm();
+ Console.WriteLine($"OpenDsm returned: {sts}");
+
+ if (sts.IsSuccess)
+ {
+ while (true)
+ {
+ var sources = twain.GetSources();
+ Console.WriteLine($"Found {sources.Count} sources.");
+ Console.WriteLine(" Source 0: [Choose by old dialog]");
+ for (var i = 0; i < sources.Count; i++)
+ {
+ var src = sources[i];
+ Console.WriteLine($" Source {i + 1}: {src.ProductName}");
+ }
+
+ Console.WriteLine("Choose a source index to open (or just press Enter to skip): ");
+ var input = Console.ReadLine();
+ TWIdentityWrapper? selectedSource = null;
+ var validInput = int.TryParse(input, out int index);
+ if (validInput && index > 0 && index <= sources.Count)
+ {
+ selectedSource = sources[index - 1];
+ }
+ else if (validInput && index == 0)
+ {
+ Console.WriteLine("Showing user select dialog...");
+ sts = twain.ShowUserSelect();
+ Console.WriteLine($"OpenSource returned: {sts}");
+
+ if (sts.IsSuccess)
+ {
+ selectedSource = twain.DefaultSource;
+ }
+ }
+
+ if (selectedSource == null)
+ {
+ break;
+ }
+
+
+ Console.WriteLine($"Opening source: {selectedSource.ProductName}");
+ sts = twain.OpenSource(selectedSource);
+ Console.WriteLine($"OpenSource returned: {sts}");
+
+ if (sts.IsSuccess)
+ {
+ sourceDisabledEventFired = false;
+ xferCount = 0;
+ watch.Restart();
+ if (twain.EnableSource(NTwain.SourceEnableOption.ShowUI).IsSuccess)
+ {
+ while(!sourceDisabledEventFired)
+ {
+ Thread.Sleep(500);
+ }
+ }
+ else
+ {
+ Console.WriteLine("Failed to enable source.");
+ }
+
+
+ Console.WriteLine($"Closing source: {selectedSource.ProductName}");
+ sts = twain.CloseSource();
+ Console.WriteLine($"CloseSource returned: {sts}");
+ }
+ }
+
+ Thread.Sleep(1000);
+
+ Console.WriteLine("Closing DSM...");
+ sts = twain.CloseDsm();
+ Console.WriteLine($"CloseDsm returned: {sts}");
+ }
+
+
+ Console.WriteLine("Press Enter to quit...");
+ Console.ReadLine();
+ }
+
+ static int xferCount = 0;
+ static Stopwatch watch = new Stopwatch();
+ private static void OnTransferred(TwainAppSession sender, TransferredEventArgs e)
+ {
+ if (e.Data != null)
+ {
+ var saveFile = Path.Combine(Environment.CurrentDirectory, $"twain_{DateTime.Now:yyyyMMdd_HHmmss}_{xferCount}");
+
+ using (var img = new ImageMagick.MagickImage(e.Data.AsStream()))
+ {
+ var format = ImageMagick.MagickFormat.Png;
+ if (img.ColorType == ImageMagick.ColorType.Palette)
+ {
+ // bw or gray
+ saveFile += ".png";
+ }
+ else
+ {
+ // color
+ saveFile += ".jpg";
+ format = ImageMagick.MagickFormat.Jpeg;
+ img.Settings.Compression = ImageMagick.CompressionMethod.JPEG;
+ img.Quality = (uint)85;
+ }
+ img.Write(saveFile, format);
+ Console.WriteLine($"SUCCESS! Got twain memory data #{++xferCount} on thread {Environment.CurrentManagedThreadId}, saving to {saveFile}.");
+ }
+ }
+ else if (e.FileInfo != null)
+ {
+ var fi = e.FileInfo.Value;
+ Console.WriteLine($"SUCCESS! Got twain file data #{++xferCount} on thread {Environment.CurrentManagedThreadId} as {fi.FileName}.");
+ }
+ else
+ {
+ Console.WriteLine($"BUMMER! No twain data #{++xferCount} on thread {Environment.CurrentManagedThreadId}.");
+ }
+ e.Dispose();
+ }
+}
diff --git a/samples/ConsoleSample/app.manifest b/samples/ConsoleSample/app.manifest
new file mode 100644
index 0000000..b42362a
--- /dev/null
+++ b/samples/ConsoleSample/app.manifest
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ PerMonitorV2
+ true
+ UTF-8
+ SegmentHeap
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/ScannerTester/ScannerTester.csproj b/samples/KodakTester/KodakTester.csproj
similarity index 89%
rename from samples/ScannerTester/ScannerTester.csproj
rename to samples/KodakTester/KodakTester.csproj
index 66b5c42..6dd355a 100644
--- a/samples/ScannerTester/ScannerTester.csproj
+++ b/samples/KodakTester/KodakTester.csproj
@@ -2,7 +2,7 @@
WinExe
- net10.0-windows7.0
+ net10.0-windows
enable
true
enable
diff --git a/samples/ScannerTester/MainForm.Designer.cs b/samples/KodakTester/MainForm.Designer.cs
similarity index 71%
rename from samples/ScannerTester/MainForm.Designer.cs
rename to samples/KodakTester/MainForm.Designer.cs
index 3cb6c3b..4d23482 100644
--- a/samples/ScannerTester/MainForm.Designer.cs
+++ b/samples/KodakTester/MainForm.Designer.cs
@@ -1,4 +1,4 @@
-namespace ScannerTester
+namespace KodakTester
{
partial class MainForm
{
@@ -59,17 +59,19 @@
// label1
//
label1.AutoSize = true;
- label1.Location = new Point(12, 9);
+ label1.Location = new Point(10, 7);
+ label1.Margin = new Padding(2, 0, 2, 0);
label1.Name = "label1";
- label1.Size = new Size(612, 25);
+ label1.Size = new Size(418, 20);
label1.TabIndex = 0;
- label1.Text = "Use this tool to see if the scanner can be used with the ScanCloud Scan App";
+ label1.Text = "Use this tool to test special features with Kodak ixxxx scanners";
//
// btnSelectScanner
//
- btnSelectScanner.Location = new Point(12, 46);
+ btnSelectScanner.Location = new Point(10, 37);
+ btnSelectScanner.Margin = new Padding(2, 2, 2, 2);
btnSelectScanner.Name = "btnSelectScanner";
- btnSelectScanner.Size = new Size(238, 34);
+ btnSelectScanner.Size = new Size(190, 27);
btnSelectScanner.TabIndex = 1;
btnSelectScanner.Text = "Choose Scanner...";
btnSelectScanner.UseVisualStyleBackColor = true;
@@ -90,9 +92,11 @@
groupSettings.Controls.Add(label4);
groupSettings.Controls.Add(listDpi);
groupSettings.Controls.Add(label3);
- groupSettings.Location = new Point(12, 99);
+ groupSettings.Location = new Point(10, 79);
+ groupSettings.Margin = new Padding(2, 2, 2, 2);
groupSettings.Name = "groupSettings";
- groupSettings.Size = new Size(742, 932);
+ groupSettings.Padding = new Padding(2, 2, 2, 2);
+ groupSettings.Size = new Size(594, 746);
groupSettings.TabIndex = 2;
groupSettings.TabStop = false;
groupSettings.Text = "Settings";
@@ -101,42 +105,47 @@
//
listFormat.DropDownStyle = ComboBoxStyle.DropDownList;
listFormat.FormattingEnabled = true;
- listFormat.Location = new Point(157, 243);
+ listFormat.Location = new Point(126, 194);
+ listFormat.Margin = new Padding(2, 2, 2, 2);
listFormat.Name = "listFormat";
- listFormat.Size = new Size(182, 33);
+ listFormat.Size = new Size(146, 28);
listFormat.TabIndex = 10;
//
// label7
//
label7.AutoSize = true;
- label7.Location = new Point(47, 246);
+ label7.Location = new Point(38, 197);
+ label7.Margin = new Padding(2, 0, 2, 0);
label7.Name = "label7";
- label7.Size = new Size(100, 25);
+ label7.Size = new Size(83, 20);
label7.TabIndex = 9;
label7.Text = "File Format";
//
// boxNamePrefix
//
- boxNamePrefix.Location = new Point(157, 207);
+ boxNamePrefix.Location = new Point(126, 166);
+ boxNamePrefix.Margin = new Padding(2, 2, 2, 2);
boxNamePrefix.Name = "boxNamePrefix";
- boxNamePrefix.Size = new Size(182, 31);
+ boxNamePrefix.Size = new Size(146, 27);
boxNamePrefix.TabIndex = 8;
boxNamePrefix.Text = "Capture_";
//
// label6
//
label6.AutoSize = true;
- label6.Location = new Point(13, 210);
+ label6.Location = new Point(10, 168);
+ label6.Margin = new Padding(2, 0, 2, 0);
label6.Name = "label6";
- label6.Size = new Size(138, 25);
+ label6.Size = new Size(117, 20);
label6.TabIndex = 7;
label6.Text = "File Name Prefix";
//
// btnOpenFolder
//
- btnOpenFolder.Location = new Point(275, 167);
+ btnOpenFolder.Location = new Point(220, 134);
+ btnOpenFolder.Margin = new Padding(2, 2, 2, 2);
btnOpenFolder.Name = "btnOpenFolder";
- btnOpenFolder.Size = new Size(112, 34);
+ btnOpenFolder.Size = new Size(90, 27);
btnOpenFolder.TabIndex = 6;
btnOpenFolder.Text = "Open";
btnOpenFolder.UseVisualStyleBackColor = true;
@@ -144,9 +153,10 @@
//
// btnBrowseFolder
//
- btnBrowseFolder.Location = new Point(157, 167);
+ btnBrowseFolder.Location = new Point(126, 134);
+ btnBrowseFolder.Margin = new Padding(2, 2, 2, 2);
btnBrowseFolder.Name = "btnBrowseFolder";
- btnBrowseFolder.Size = new Size(112, 34);
+ btnBrowseFolder.Size = new Size(90, 27);
btnBrowseFolder.TabIndex = 6;
btnBrowseFolder.Text = "Browse...";
btnBrowseFolder.UseVisualStyleBackColor = true;
@@ -155,36 +165,40 @@
// boxFolder
//
boxFolder.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- boxFolder.Location = new Point(157, 130);
+ boxFolder.Location = new Point(126, 104);
+ boxFolder.Margin = new Padding(2, 2, 2, 2);
boxFolder.Name = "boxFolder";
- boxFolder.Size = new Size(556, 31);
+ boxFolder.Size = new Size(446, 27);
boxFolder.TabIndex = 5;
boxFolder.Text = "Images";
//
// label5
//
label5.AutoSize = true;
- label5.Location = new Point(47, 133);
+ label5.Location = new Point(38, 106);
+ label5.Margin = new Padding(2, 0, 2, 0);
label5.Name = "label5";
- label5.Size = new Size(104, 25);
+ label5.Size = new Size(86, 20);
label5.TabIndex = 4;
label5.Text = "Save Folder";
//
// boxLimit
//
- boxLimit.Location = new Point(157, 93);
+ boxLimit.Location = new Point(126, 74);
+ boxLimit.Margin = new Padding(2, 2, 2, 2);
boxLimit.Minimum = new decimal(new int[] { 1, 0, 0, int.MinValue });
boxLimit.Name = "boxLimit";
- boxLimit.Size = new Size(182, 31);
+ boxLimit.Size = new Size(146, 27);
boxLimit.TabIndex = 3;
boxLimit.Value = new decimal(new int[] { 1, 0, 0, int.MinValue });
//
// label4
//
label4.AutoSize = true;
- label4.Location = new Point(35, 95);
+ label4.Location = new Point(28, 76);
+ label4.Margin = new Padding(2, 0, 2, 0);
label4.Name = "label4";
- label4.Size = new Size(116, 25);
+ label4.Size = new Size(98, 20);
label4.TabIndex = 2;
label4.Text = "Transfer Limit";
//
@@ -192,26 +206,29 @@
//
listDpi.DropDownStyle = ComboBoxStyle.DropDownList;
listDpi.FormattingEnabled = true;
- listDpi.Location = new Point(157, 54);
+ listDpi.Location = new Point(126, 43);
+ listDpi.Margin = new Padding(2, 2, 2, 2);
listDpi.Name = "listDpi";
- listDpi.Size = new Size(182, 33);
+ listDpi.Size = new Size(146, 28);
listDpi.TabIndex = 1;
//
// label3
//
label3.AutoSize = true;
- label3.Location = new Point(111, 57);
+ label3.Location = new Point(89, 46);
+ label3.Margin = new Padding(2, 0, 2, 0);
label3.Name = "label3";
- label3.Size = new Size(40, 25);
+ label3.Size = new Size(32, 20);
label3.TabIndex = 0;
label3.Text = "DPI";
//
// lblCurScanner
//
lblCurScanner.AutoSize = true;
- lblCurScanner.Location = new Point(256, 51);
+ lblCurScanner.Location = new Point(205, 41);
+ lblCurScanner.Margin = new Padding(2, 0, 2, 0);
lblCurScanner.Name = "lblCurScanner";
- lblCurScanner.Size = new Size(124, 25);
+ lblCurScanner.Size = new Size(104, 20);
lblCurScanner.TabIndex = 3;
lblCurScanner.Text = "None selected";
//
@@ -224,9 +241,11 @@
groupTest.Controls.Add(btnStop);
groupTest.Controls.Add(btnTransfer);
groupTest.Controls.Add(btnDriverOnly);
- groupTest.Location = new Point(760, 99);
+ groupTest.Location = new Point(608, 79);
+ groupTest.Margin = new Padding(2, 2, 2, 2);
groupTest.Name = "groupTest";
- groupTest.Size = new Size(1038, 932);
+ groupTest.Padding = new Padding(2, 2, 2, 2);
+ groupTest.Size = new Size(830, 746);
groupTest.TabIndex = 4;
groupTest.TabStop = false;
groupTest.Text = "Test";
@@ -234,27 +253,30 @@
// boxLog
//
boxLog.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
- boxLog.Location = new Point(22, 118);
+ boxLog.Location = new Point(18, 94);
+ boxLog.Margin = new Padding(2, 2, 2, 2);
boxLog.Name = "boxLog";
- boxLog.Size = new Size(999, 796);
+ boxLog.Size = new Size(800, 638);
boxLog.TabIndex = 4;
boxLog.Text = "";
//
// label2
//
label2.AutoSize = true;
- label2.Location = new Point(22, 90);
+ label2.Location = new Point(18, 72);
+ label2.Margin = new Padding(2, 0, 2, 0);
label2.Name = "label2";
- label2.Size = new Size(50, 25);
+ label2.Size = new Size(40, 20);
label2.TabIndex = 3;
label2.Text = "Logs";
//
// ckShowUI
//
ckShowUI.AutoSize = true;
- ckShowUI.Location = new Point(451, 43);
+ ckShowUI.Location = new Point(361, 34);
+ ckShowUI.Margin = new Padding(2, 2, 2, 2);
ckShowUI.Name = "ckShowUI";
- ckShowUI.Size = new Size(253, 29);
+ ckShowUI.Size = new Size(210, 24);
ckShowUI.TabIndex = 2;
ckShowUI.Text = "Show driver during capture";
ckShowUI.UseVisualStyleBackColor = true;
@@ -262,9 +284,10 @@
// btnStop
//
btnStop.Anchor = AnchorStyles.Top | AnchorStyles.Right;
- btnStop.Location = new Point(897, 39);
+ btnStop.Location = new Point(718, 31);
+ btnStop.Margin = new Padding(2, 2, 2, 2);
btnStop.Name = "btnStop";
- btnStop.Size = new Size(124, 34);
+ btnStop.Size = new Size(99, 27);
btnStop.TabIndex = 2;
btnStop.Text = "Stop";
btnStop.UseVisualStyleBackColor = true;
@@ -272,9 +295,10 @@
//
// btnTransfer
//
- btnTransfer.Location = new Point(239, 39);
+ btnTransfer.Location = new Point(191, 31);
+ btnTransfer.Margin = new Padding(2, 2, 2, 2);
btnTransfer.Name = "btnTransfer";
- btnTransfer.Size = new Size(206, 34);
+ btnTransfer.Size = new Size(165, 27);
btnTransfer.TabIndex = 1;
btnTransfer.Text = "Start Capture";
btnTransfer.UseVisualStyleBackColor = true;
@@ -282,9 +306,10 @@
//
// btnDriverOnly
//
- btnDriverOnly.Location = new Point(22, 39);
+ btnDriverOnly.Location = new Point(18, 31);
+ btnDriverOnly.Margin = new Padding(2, 2, 2, 2);
btnDriverOnly.Name = "btnDriverOnly";
- btnDriverOnly.Size = new Size(206, 34);
+ btnDriverOnly.Size = new Size(165, 27);
btnDriverOnly.TabIndex = 0;
btnDriverOnly.Text = "Open Driver UI";
btnDriverOnly.UseVisualStyleBackColor = true;
@@ -292,17 +317,18 @@
//
// MainForm
//
- AutoScaleDimensions = new SizeF(10F, 25F);
+ AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(1810, 1043);
+ ClientSize = new Size(1448, 834);
Controls.Add(groupTest);
Controls.Add(lblCurScanner);
Controls.Add(groupSettings);
Controls.Add(btnSelectScanner);
Controls.Add(label1);
+ Margin = new Padding(2, 2, 2, 2);
Name = "MainForm";
SizeGripStyle = SizeGripStyle.Show;
- Text = "Scanner Tester Utility";
+ Text = "Kodak Tester Utility";
groupSettings.ResumeLayout(false);
groupSettings.PerformLayout();
((System.ComponentModel.ISupportInitialize)boxLimit).EndInit();
diff --git a/samples/KodakTester/MainForm.cs b/samples/KodakTester/MainForm.cs
new file mode 100644
index 0000000..0df0413
--- /dev/null
+++ b/samples/KodakTester/MainForm.cs
@@ -0,0 +1,586 @@
+using NTwain;
+using NTwain.Data;
+using NTwain.Data.Kds;
+using NTwain.Events;
+using NTwain.Triplets;
+using System.Diagnostics;
+using System.Text;
+
+namespace KodakTester;
+
+public partial class MainForm : Form
+{
+ TwainAppSession _twain;
+ private bool _stopTransfer;
+
+ public MainForm()
+ {
+ InitializeComponent();
+
+ _twain = new TwainAppSession(appThreadContext: SynchronizationContext.Current);
+ _twain.TransferReady += _twain_TransferReady;
+ _twain.Transferred += _twain_Transferred;
+ _twain.SourceDisabled += _twain_SourceDisabled;
+ }
+
+ private void _twain_SourceDisabled(TwainAppSession sender, TWIdentityWrapper e)
+ {
+
+ }
+
+ protected override void OnLoad(EventArgs e)
+ {
+ base.OnLoad(e);
+ _twain.OpenDsm();
+ //_ = _twain.OpenDSMAsync();
+ }
+
+ protected override void OnFormClosed(FormClosedEventArgs e)
+ {
+ _twain.CloseDsm();
+ //_ = _twain.CloseDSMAsync();
+ base.OnFormClosed(e);
+ }
+
+ private void _twain_Transferred(TwainAppSession sender, TransferredEventArgs e)
+ {
+ TW_EXTIMAGEINFO extInfo = TW_EXTIMAGEINFO.CreateRequest(TWEI.CAMERA);
+ e.GetExtendedImageInfo(ref extInfo);
+ string? camera = null;
+ foreach (var ei in extInfo.AsInfos())
+ {
+ if (ei.ReturnCode == TWRC.SUCCESS)
+ {
+ switch (ei.InfoId)
+ {
+ //case (TWEI)KDS_TWEI.HDR_PAGENUMBER:
+ // LogIt($"TWEI_HDR_PAGENUMBER Value = {ei.ReadNonPointerData()}");
+ // break;
+ case TWEI.CAMERA:
+ camera = ei.ReadHandleString(_twain.MemoryManager);
+ LogIt($"{ei.InfoId} Value = {camera}");
+ break;
+ }
+ }
+ else
+ {
+ LogIt($"{ei.InfoId} RC = {ei.ReturnCode}");
+ }
+ }
+ extInfo.Free(_twain.MemoryManager);
+
+ if (e.Data != null)
+ {
+ LogIt($"Received {e.ImageInfo.PixelType} in {e.ImageInfo.Compression} compressed memory image.");
+ var folder = boxFolder.Text;
+ if (string.IsNullOrWhiteSpace(folder))
+ {
+ folder = "Images";
+ Directory.CreateDirectory(folder);
+ boxFolder.Text = folder;
+ }
+ var prefix = boxNamePrefix.Text;
+ if (string.IsNullOrWhiteSpace(prefix))
+ {
+ prefix = "Capture_";
+ boxNamePrefix.Text = prefix;
+ }
+
+ using (var img = System.Drawing.Image.FromStream(e.Data.AsStream()))
+ {
+ //var saveFile = img.SaveToSmallestFormat(folder, prefix, lossless: false).ToString();
+ //LogIt($"File saved to {saveFile}");
+ }
+ }
+ else if (e.FileInfo != null)
+ {
+ var info = e.FileInfo.Value;
+ var path = info.FileName.ToString();
+ LogIt($"Received {e.ImageInfo.PixelType} {info.Format} in {e.ImageInfo.Compression} compressed file {path}");
+ }
+ e.Dispose();
+ LogIt("");
+ }
+
+ int _xferCount = 0;
+ private void _twain_TransferReady(TwainAppSession sender, TransferReadyEventArgs e)
+ {
+ if (_stopTransfer)
+ {
+ e.Cancel = CancelType.EndNow;
+ return;
+ }
+
+ _xferCount++;
+ LogIt($"Got pending transfer with mode = {e.ImgXferMech}");
+ if (e.ImgXferMech == TWSX.FILE)
+ {
+ var folder = boxFolder.Text;
+ if (string.IsNullOrWhiteSpace(folder))
+ {
+ folder = "Images";
+ Directory.CreateDirectory(folder);
+ boxFolder.Text = folder;
+ }
+ var prefix = boxNamePrefix.Text;
+ if (string.IsNullOrWhiteSpace(prefix))
+ {
+ prefix = "Capture_";
+ boxNamePrefix.Text = prefix;
+ }
+
+ TWCP comp = TWCP.NONE;
+ TW_EXTIMAGEINFO extInfo = TW_EXTIMAGEINFO.CreateRequest((TWEI)KDS_TWEI.HDR_COMPRESSION);
+ e.GetExtendedImageInfo(ref extInfo);
+ foreach (var ei in extInfo.AsInfos())
+ {
+ if (ei.ReturnCode == TWRC.SUCCESS)
+ {
+ switch (ei.InfoId)
+ {
+ case (TWEI)KDS_TWEI.HDR_COMPRESSION:
+ comp = ei.ReadNonPointerData();
+ LogIt($"{ei.InfoId} Value = {comp}");
+ break;
+ }
+ }
+ else
+ {
+ LogIt($"{ei.InfoId} RC = {ei.ReturnCode}");
+ }
+ }
+ extInfo.Free(_twain.MemoryManager);
+
+ LogIt($"Compression at ready step = {comp}");
+ string? targetName = $"{prefix}_{_xferCount:D4}";
+ TWFF format = TWFF.TIFF;
+ switch (comp)
+ {
+ case TWCP.JPEG:
+ targetName = $"{prefix}_{_xferCount:D4}.jpg";
+ format = TWFF.JFIF;
+ break;
+ case TWCP.NONE:
+ targetName = $"{prefix}_{_xferCount:D4}.bmp";
+ format = TWFF.BMP;
+ break;
+ case TWCP.GROUP4:
+ default:
+ targetName = $"{prefix}_{_xferCount:D4}.tif";
+ break;
+ }
+ TW_SETUPFILEXFER setup = new()
+ {
+ FileName = Path.Combine(folder, targetName),
+ Format = format
+ };
+
+ var sts = e.SetupFileTransfer(ref setup);
+
+ LogIt($"Want to save image as {setup.Format} {setup.FileName}.", sts);
+
+ // verify it again
+ var appId = _twain.AppIdentity;
+ var srcId = _twain.CurrentSource!;
+
+ sts = _twain.WrapInSTS(DGControl.SetupFileXfer.Get(appId, srcId, out setup));
+
+ LogIt($"Checked actual file settings as {setup.Format} {setup.FileName}.", sts);
+
+ }
+ LogIt("");
+ }
+
+ protected override void OnFormClosing(FormClosingEventArgs e)
+ {
+ if (_twain.State > STATE.S5)
+ {
+ e.Cancel = true;
+ }
+ _twain.TryStepdown(STATE.S2);
+ base.OnFormClosing(e);
+ }
+
+ private void btnSelectScanner_Click(object sender, EventArgs e)
+ {
+ var sts = _twain.ShowUserSelect();
+ if (sts.IsSuccess && _twain.DefaultSource.Id > 0)
+ {
+ if (_twain.State > STATE.S3)
+ {
+ _twain.TryStepdown(STATE.S3);
+ }
+ sts = _twain.OpenSource(_twain.DefaultSource);
+ LogIt("Open scanner", sts);
+ if (sts.IsSuccess)
+ {
+ var src = _twain.CurrentSource;
+ lblCurScanner.Text = $"{src.ProductName} | v{src.Version} | protocol: {src.ProtocolMajor}.{src.ProtocolMinor}";
+ LoadSettings();
+ return;
+ }
+ }
+
+ lblCurScanner.Text = "None selected";
+ }
+
+ private void LogIt(string msg)
+ {
+ boxLog.AppendText($"{msg}\n");
+ }
+ private void LogIt(string msg, STS sts)
+ {
+ if (sts.IsSuccess)
+ {
+ boxLog.AppendText($"{msg} result = {sts.RC}\n");
+ }
+ else
+ {
+ boxLog.AppendText($"{msg} result = {sts.RC} - {sts.ConditionCode}\n");
+ }
+ }
+
+ private void LoadSettings()
+ {
+ var mechs = _twain.Caps.ICAP_XFERMECH.Get().GetValues();
+
+ if (!mechs.Contains(TWSX.FILE))
+ {
+ LogIt("File transfer is not supported.");
+ }
+
+ var sts = _twain.Caps.ICAP_XFERMECH.Set(TWSX.FILE);
+ LogIt("Use file transfer", sts);
+
+ if (_twain.Caps.ICAP_UNITS.GetCurrent().FirstOrDefault() != TWUN.INCHES)
+ {
+ sts = _twain.Caps.ICAP_UNITS.Set(TWUN.INCHES);
+ LogIt("Set unit to inches", sts);
+ }
+
+ var dpis = _twain.Caps.ICAP_XRESOLUTION.Get().GetValues();
+ listDpi.Items.Clear();
+ if (dpis.Contains(200))
+ {
+ listDpi.Items.Add(200);
+ listDpi.SelectedItem = 200;
+ }
+ else
+ {
+ LogIt("200 DPI doesn't appear to be supported.");
+ }
+ if (dpis.Contains(300))
+ {
+ listDpi.Items.Add(300);
+ listDpi.SelectedItem = 300;
+ }
+ else
+ {
+ LogIt("300 DPI doesn't appear to be supported.");
+ }
+
+ var formats = _twain.Caps.ICAP_IMAGEFILEFORMAT.Get().GetValues();
+ listFormat.Items.Clear();
+ foreach (var format in formats)
+ {
+ listFormat.Items.Add(format);
+ }
+ listFormat.SelectedItem = _twain.Caps.ICAP_IMAGEFILEFORMAT.GetCurrent().FirstOrDefault();
+
+ LogIt("");
+ }
+
+ private void btnDriverOnly_Click(object sender, EventArgs e)
+ {
+ if (_twain.State != STATE.S4) return;
+
+ var sts = _twain.EnableSource(SourceEnableOption.UIOnly);
+ LogIt("Show drivers", sts);
+ LogIt("");
+ }
+
+ private void btnTransfer_Click(object sender, EventArgs e)
+ {
+ if (_twain.State != STATE.S4 || !EnsureBoxFolder()) return;
+
+
+ var _isIndustrialKodak = _twain.CurrentSource!.ProductName.ToString().StartsWith("KODAK Scanner: i");
+
+ if (_isIndustrialKodak)
+ {
+ CaptureAsKodakSDMI();
+ }
+ else
+ {
+ CaptureAsStandardScanner();
+ }
+
+ _stopTransfer = false;
+ _xferCount = 0;
+ var sts = _twain.EnableSource(ckShowUI.Checked ? SourceEnableOption.ShowUI : SourceEnableOption.NoUI);
+ LogIt("Start capture", sts);
+ LogIt("");
+ }
+
+ private void CaptureAsKodakSDMI()
+ {
+ LogIt("Attempting Kodak SDMI mode");
+
+ LogIt($"Resolution supports {FlattenFlag(_twain.Caps.ICAP_XRESOLUTION.Supports)}");
+ LogIt($"File format supports {FlattenFlag(_twain.Caps.ICAP_IMAGEFILEFORMAT.Supports)}");
+ LogIt($"Compression supports {FlattenFlag(_twain.Caps.ICAP_COMPRESSION.Supports)}");
+ LogIt($"EXTINFO supports {FlattenFlag(_twain.Caps.ICAP_EXTIMAGEINFO.Supports)}");
+
+ LogIt("");
+
+ var limit = (short)boxLimit.Value;
+ if (limit > 0) limit *= 2;
+ var sts = _twain.Caps.CAP_XFERCOUNT.Set(limit);
+ LogIt($"Set transfer limit {limit}", sts);
+
+ sts = _twain.Caps.ICAP_EXTIMAGEINFO.Set(TW_BOOL.True);
+ LogIt($"Set extimageinfo enabled", sts);
+
+ var format = (TWFF)listFormat.SelectedItem!;
+ sts = _twain.Caps.ICAP_IMAGEFILEFORMAT.Set(format);
+ LogIt($"Set {format} format.", sts);
+
+ if (!sts.IsSuccess)
+ {
+ return;
+ }
+
+ LogIt("");
+
+ var appId = _twain.AppIdentity;
+ var srcId = _twain.CurrentSource!;
+
+
+ TW_FILESYSTEM fs = new() { InputName = "/Camera_Bitonal_Both" };
+ sts = _twain.WrapInSTS(DGControl.FileSystem.ChangeDirectory(appId, srcId, ref fs));
+ LogIt("Change to bw cameras", sts);
+ if (sts.IsSuccess)
+ {
+ sts = _twain.Caps.CAP_CAMERAENABLED.Set(TW_BOOL.True);
+ LogIt("Set camera enabled", sts);
+
+ var dpi = listDpi.SelectedValue == null ? 300 : Convert.ToInt32(listDpi.SelectedValue);
+ sts = _twain.Caps.ICAP_XRESOLUTION.Set(dpi);
+ LogIt("Set x-resolution", sts);
+ sts = _twain.Caps.ICAP_YRESOLUTION.Set(dpi);
+ LogIt("Set y-resolution", sts);
+
+
+ if (format != TWFF.BMP)
+ {
+ LogIt($"Current format={_twain.Caps.ICAP_IMAGEFILEFORMAT.GetCurrent().First()}");
+ LogIt($"Current compression={_twain.Caps.ICAP_COMPRESSION.GetCurrent().First()}");
+ if (_twain.Caps.ICAP_COMPRESSION.Supports.HasFlag(TWQC.SET))
+ {
+ sts = _twain.Caps.ICAP_COMPRESSION.Set(TWCP.GROUP4);
+ LogIt("Set compression to group4", sts);
+ }
+ }
+ }
+ LogIt("");
+
+
+ fs = new() { FileType = (int)TWFY.CAMERA, InputName = "/Camera_Color_Both" };
+ sts = _twain.WrapInSTS(DGControl.FileSystem.ChangeDirectory(appId, srcId, ref fs));
+ LogIt("Change to color cameras", sts);
+ if (sts.IsSuccess)
+ {
+ sts = _twain.Caps.CAP_CAMERAENABLED.Set(TW_BOOL.True);
+ LogIt("Set camera enabled", sts);
+
+
+ var dpi = listDpi.SelectedValue == null ? 300 : Convert.ToInt32(listDpi.SelectedValue);
+ sts = _twain.Caps.ICAP_XRESOLUTION.Set(dpi);
+ LogIt("Set x-resolution", sts);
+ sts = _twain.Caps.ICAP_YRESOLUTION.Set(dpi);
+ LogIt("Set y-resolution", sts);
+
+
+ if (format != TWFF.BMP)
+ {
+ LogIt($"Current format={_twain.Caps.ICAP_IMAGEFILEFORMAT.GetCurrent().First()}");
+ LogIt($"Current compression={_twain.Caps.ICAP_COMPRESSION.GetCurrent().First()}");
+ if (_twain.Caps.ICAP_COMPRESSION.Supports.HasFlag(TWQC.SET))
+ {
+ sts = _twain.Caps.ICAP_COMPRESSION.Set(TWCP.JPEG);
+ LogIt("Set compression to jpg", sts);
+ if (sts.IsSuccess)
+ {
+ LogIt($"jpeg quality supports {FlattenFlag(_twain.Caps.ICAP_JPEGQUALITY.Supports)}");
+
+ short quality = 90;
+ sts = _twain.Caps.ICAP_JPEGQUALITY.Set((TWJQ)quality);
+ LogIt($"Set jpg quality to {quality}", sts);
+ if (!sts.IsSuccess)
+ {
+ quality = 85;
+ sts = _twain.Caps.ICAP_JPEGQUALITY.Set((TWJQ)quality);
+ LogIt($"Set jpg quality to {quality}", sts);
+
+ if (!sts.IsSuccess)
+ {
+ sts = _twain.Caps.ICAP_JPEGQUALITY.Set(TWJQ.HIGH);
+ LogIt($"Set jpg quality to {TWJQ.HIGH}", sts);
+ }
+ }
+ }
+ }
+ }
+ }
+ LogIt("");
+ }
+
+ const ushort TWQC_MACHINE = 0x1000;// applies to entire session/machine
+ const ushort TWQC_BITONAL = 0x2000; // applies to Bitonal "cameras"
+ const ushort TWQC_COLOR = 0x4000; // applies to Color "cameras"
+ [Flags]
+ public enum TWQC2 : ushort
+ {
+ MACHINE = 0x1000,
+ BITONAL = 0x2000,
+ COLOR = 0x4000
+ }
+
+ private string FlattenFlag(TWQC val)
+ {
+ StringBuilder sb = new();
+
+ foreach (var type in Enum.GetValues(typeof(TWQC)))
+ {
+ if (((ushort)val & (ushort)type) > 0)
+ {
+ sb.Append(type).Append(", ");
+ }
+ }
+ foreach (var type in Enum.GetValues(typeof(TWQC2)))
+ {
+ if (((ushort)val & (ushort)type) > 0)
+ {
+ sb.Append(type).Append(", ");
+ }
+ }
+ if (sb.Length > 0)
+ {
+ sb.Length = sb.Length - 2;
+ }
+ return sb.ToString();
+ }
+
+ private void CaptureAsStandardScanner()
+ {
+ LogIt("Attempting Standard Scanner mode");
+
+ var sts = _twain.Caps.ICAP_PIXELTYPE.Set(TWPT.RGB);
+ LogIt("Set rgb pixel type", sts);
+
+ if (_twain.Caps.CAP_DUPLEXENABLED.Supports.HasFlag(TWQC.SET))
+ {
+ sts = _twain.Caps.CAP_DUPLEXENABLED.Set(TW_BOOL.True);
+ LogIt("Set duplex enabled", sts);
+ }
+
+ var dpi = listDpi.SelectedValue == null ? 300 : Convert.ToInt32(listDpi.SelectedValue);
+ sts = _twain.Caps.ICAP_XRESOLUTION.Set(dpi);
+ LogIt("Set x-resolution", sts);
+ sts = _twain.Caps.ICAP_YRESOLUTION.Set(dpi);
+ LogIt("Set y-resolution", sts);
+
+ if (listFormat.SelectedItem != null)
+ {
+ var format = (TWFF)listFormat.SelectedItem;
+
+ sts = _twain.Caps.ICAP_IMAGEFILEFORMAT.Set(format);
+ LogIt($"Set {format} format.", sts);
+
+ if (!sts.IsSuccess)
+ {
+ return;
+ }
+
+ if (format != TWFF.BMP)
+ {
+ if (_twain.Caps.ICAP_COMPRESSION.Supports.HasFlag(TWQC.SET))
+ {
+ sts = _twain.Caps.ICAP_COMPRESSION.Set(TWCP.JPEG);
+ LogIt("Set compression to jpg", sts);
+ if (sts.IsSuccess)
+ {
+ short quality = 90;
+ sts = _twain.Caps.ICAP_JPEGQUALITY.Set((TWJQ)quality);
+ LogIt($"Set jpg quality to {quality}", sts);
+ if (!sts.IsSuccess)
+ {
+ quality = 85;
+ sts = _twain.Caps.ICAP_JPEGQUALITY.Set((TWJQ)quality);
+ LogIt($"Set jpg quality to {quality}", sts);
+
+ if (!sts.IsSuccess)
+ {
+ sts = _twain.Caps.ICAP_JPEGQUALITY.Set(TWJQ.HIGH);
+ LogIt($"Set jpg quality to {TWJQ.HIGH}", sts);
+ }
+ }
+ }
+ }
+ }
+ }
+ var limit = (short)boxLimit.Value;
+ sts = _twain.Caps.CAP_XFERCOUNT.Set(limit);
+ LogIt($"Set transfer limit {boxLimit.Value}", sts);
+ }
+
+ private void btnStop_Click(object sender, EventArgs e)
+ {
+ _stopTransfer = true;
+ }
+
+ private void btnBrowseFolder_Click(object sender, EventArgs e)
+ {
+ using FolderBrowserDialog dialog = new();
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ boxFolder.Text = dialog.SelectedPath;
+ }
+ }
+
+ private void btnOpenFolder_Click(object sender, EventArgs e)
+ {
+ if (EnsureBoxFolder())
+ {
+ try
+ {
+ using var p = Process.Start("explorer.exe", boxFolder.Text);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private bool EnsureBoxFolder()
+ {
+ if (!string.IsNullOrEmpty(boxFolder.Text))
+ {
+ if (!Directory.Exists(boxFolder.Text))
+ {
+ try
+ {
+ Directory.CreateDirectory(boxFolder.Text);
+ }
+ catch (Exception ex)
+ {
+ LogIt($"Failed to ensure save folder: {ex.Message}");
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/samples/ScannerTester/MainForm.resx b/samples/KodakTester/MainForm.resx
similarity index 100%
rename from samples/ScannerTester/MainForm.resx
rename to samples/KodakTester/MainForm.resx
diff --git a/samples/KodakTester/Program.cs b/samples/KodakTester/Program.cs
new file mode 100644
index 0000000..2acb038
--- /dev/null
+++ b/samples/KodakTester/Program.cs
@@ -0,0 +1,16 @@
+namespace KodakTester;
+
+internal static class Program
+{
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ // To customize application configuration such as set high DPI settings or default font,
+ // see https://aka.ms/applicationconfiguration.
+ ApplicationConfiguration.Initialize();
+ Application.Run(new MainForm());
+ }
+}
\ No newline at end of file
diff --git a/samples/ScannerTester/MainForm.cs b/samples/ScannerTester/MainForm.cs
deleted file mode 100644
index 16cae77..0000000
--- a/samples/ScannerTester/MainForm.cs
+++ /dev/null
@@ -1,591 +0,0 @@
-using NTwain;
-using NTwain.Data;
-using NTwain.Data.Kds;
-using NTwain.Triplets;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Text;
-
-namespace ScannerTester
-{
- public partial class MainForm : Form
- {
- TwainAppSession _twain;
- private bool _stopTransfer;
-
- public MainForm()
- {
- InitializeComponent();
-
- _twain = new TwainAppSession();
- _twain.TransferReady += _twain_TransferReady;
- _twain.Transferred += _twain_Transferred;
- _twain.SourceDisabled += _twain_SourceDisabled;
- _twain.AddWinformFilter();
- }
-
- private void _twain_SourceDisabled(TwainAppSession sender, TW_IDENTITY_LEGACY e)
- {
-
- }
-
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad(e);
- _twain.OpenDSM(Handle, SynchronizationContext.Current!);
- //_ = _twain.OpenDSMAsync();
- }
-
- protected override void OnFormClosed(FormClosedEventArgs e)
- {
- _twain.CloseDSM();
- //_ = _twain.CloseDSMAsync();
- base.OnFormClosed(e);
- }
-
- private void _twain_Transferred(TwainAppSession sender, TransferredEventArgs e)
- {
- Invoke(() =>
- {
- TW_EXTIMAGEINFO extInfo = TW_EXTIMAGEINFO.CreateRequest(TWEI.CAMERA);
- e.GetExtendedImageInfo(ref extInfo);
- string? camera = null;
- foreach (var ei in extInfo.AsInfos())
- {
- if (ei.ReturnCode == TWRC.SUCCESS)
- {
- switch (ei.InfoId)
- {
- //case (TWEI)KDS_TWEI.HDR_PAGENUMBER:
- // LogIt($"TWEI_HDR_PAGENUMBER Value = {ei.ReadNonPointerData()}");
- // break;
- case TWEI.CAMERA:
- camera = ei.ReadHandleString(_twain);
- LogIt($"{ei.InfoId} Value = {camera}");
- break;
- }
- }
- else
- {
- LogIt($"{ei.InfoId} RC = {ei.ReturnCode}");
- }
- }
- extInfo.Free(_twain);
-
- if (e.Data != null)
- {
- LogIt($"Received {e.ImageInfo.PixelType} in {e.ImageInfo.Compression} compressed memory image.");
- var folder = boxFolder.Text;
- if (string.IsNullOrWhiteSpace(folder))
- {
- folder = "Images";
- Directory.CreateDirectory(folder);
- boxFolder.Text = folder;
- }
- var prefix = boxNamePrefix.Text;
- if (string.IsNullOrWhiteSpace(prefix))
- {
- prefix = "Capture_";
- boxNamePrefix.Text = prefix;
- }
-
- using (var img = System.Drawing.Image.FromStream(e.Data.AsStream()))
- {
- //var saveFile = img.SaveToSmallestFormat(folder, prefix, lossless: false).ToString();
- //LogIt($"File saved to {saveFile}");
- }
- }
- else if (e.FileInfo != null)
- {
- var info = e.FileInfo.Value;
- var path = info.FileName.ToString();
- LogIt($"Received {e.ImageInfo.PixelType} {info.Format} in {e.ImageInfo.Compression} compressed file {path}");
- }
- e.Dispose();
- LogIt("");
- });
- }
-
- int _xferCount = 0;
- private void _twain_TransferReady(TwainAppSession sender, TransferReadyEventArgs e)
- {
- Invoke(() =>
- {
- if (_stopTransfer)
- {
- e.Cancel = CancelType.EndNow;
- return;
- }
-
- _xferCount++;
- LogIt($"Got pending transfer with mode = {e.ImgXferMech}");
- if (e.ImgXferMech == TWSX.FILE)
- {
- var folder = boxFolder.Text;
- if (string.IsNullOrWhiteSpace(folder))
- {
- folder = "Images";
- Directory.CreateDirectory(folder);
- boxFolder.Text = folder;
- }
- var prefix = boxNamePrefix.Text;
- if (string.IsNullOrWhiteSpace(prefix))
- {
- prefix = "Capture_";
- boxNamePrefix.Text = prefix;
- }
-
- TWCP comp = TWCP.NONE;
- TW_EXTIMAGEINFO extInfo = TW_EXTIMAGEINFO.CreateRequest((TWEI)KDS_TWEI.HDR_COMPRESSION);
- e.GetExtendedImageInfo(ref extInfo);
- foreach (var ei in extInfo.AsInfos())
- {
- if (ei.ReturnCode == TWRC.SUCCESS)
- {
- switch (ei.InfoId)
- {
- case (TWEI)KDS_TWEI.HDR_COMPRESSION:
- comp = ei.ReadNonPointerData();
- LogIt($"{ei.InfoId} Value = {comp}");
- break;
- }
- }
- else
- {
- LogIt($"{ei.InfoId} RC = {ei.ReturnCode}");
- }
- }
- extInfo.Free(_twain);
-
- LogIt($"Compression at ready step = {comp}");
- string? targetName = $"{prefix}_{_xferCount:D4}";
- TWFF format = TWFF.TIFF;
- switch (comp)
- {
- case TWCP.JPEG:
- targetName = $"{prefix}_{_xferCount:D4}.jpg";
- format = TWFF.JFIF;
- break;
- case TWCP.NONE:
- targetName = $"{prefix}_{_xferCount:D4}.bmp";
- format = TWFF.BMP;
- break;
- case TWCP.GROUP4:
- default:
- targetName = $"{prefix}_{_xferCount:D4}.tif";
- break;
- }
- TW_SETUPFILEXFER setup = new()
- {
- FileName = Path.Combine(folder, targetName),
- Format = format
- };
-
- var sts = e.SetupFileTransfer(ref setup);
-
- LogIt($"Want to save image as {setup.Format} {setup.FileName}.", sts);
-
- var appId = _twain.AppIdentity;
- var srcId = _twain.CurrentSource;
- sts = _twain.WrapInSTS(DGControl.SetupFileXfer.Get(ref appId, ref srcId, out setup));
-
- LogIt($"Checked actual file settings as {setup.Format} {setup.FileName}.", sts);
-
- }
- LogIt("");
- });
- }
-
- protected override void OnFormClosing(FormClosingEventArgs e)
- {
- if (_twain.State > STATE.S5)
- {
- e.Cancel = true;
- }
- _twain.TryStepdown(STATE.S2);
- base.OnFormClosing(e);
- }
-
- private void btnSelectScanner_Click(object sender, EventArgs e)
- {
- var sts = _twain.ShowUserSelect();
- if (sts.IsSuccess && _twain.DefaultSource.Id > 0)
- {
- if (_twain.State > STATE.S3)
- {
- _twain.TryStepdown(STATE.S3);
- }
- sts = _twain.OpenSource(_twain.DefaultSource);
- LogIt("Open scanner", sts);
- if (sts.IsSuccess)
- {
- var src = _twain.CurrentSource;
- lblCurScanner.Text = $"{src.ProductName} | v{src.Version} | protocol: {src.ProtocolMajor}.{src.ProtocolMinor}";
- LoadSettings();
- return;
- }
- }
-
- lblCurScanner.Text = "None selected";
- }
-
- private void LogIt(string msg)
- {
- boxLog.AppendText($"{msg}\n");
- }
- private void LogIt(string msg, STS sts)
- {
- if (sts.IsSuccess)
- {
- boxLog.AppendText($"{msg} result = {sts.RC}\n");
- }
- else
- {
- boxLog.AppendText($"{msg} result = {sts.RC} - {sts.ConditionCode}\n");
- }
- }
-
- private void LoadSettings()
- {
- var mechs = _twain.Caps.ICAP_XFERMECH.Get().GetValues();
-
- if (!mechs.Contains(TWSX.FILE))
- {
- LogIt("File transfer is not supported.");
- }
-
- var sts = _twain.Caps.ICAP_XFERMECH.Set(TWSX.FILE);
- LogIt("Use file transfer", sts);
-
- if (_twain.Caps.ICAP_UNITS.GetCurrent().FirstOrDefault() != TWUN.INCHES)
- {
- sts = _twain.Caps.ICAP_UNITS.Set(TWUN.INCHES);
- LogIt("Set unit to inches", sts);
- }
-
- var dpis = _twain.Caps.ICAP_XRESOLUTION.Get().GetValues();
- listDpi.Items.Clear();
- if (dpis.Contains(200))
- {
- listDpi.Items.Add(200);
- listDpi.SelectedItem = 200;
- }
- else
- {
- LogIt("200 DPI doesn't appear to be supported.");
- }
- if (dpis.Contains(300))
- {
- listDpi.Items.Add(300);
- listDpi.SelectedItem = 300;
- }
- else
- {
- LogIt("300 DPI doesn't appear to be supported.");
- }
-
- var formats = _twain.Caps.ICAP_IMAGEFILEFORMAT.Get().GetValues();
- listFormat.Items.Clear();
- foreach (var format in formats)
- {
- listFormat.Items.Add(format);
- }
- listFormat.SelectedItem = _twain.Caps.ICAP_IMAGEFILEFORMAT.GetCurrent().FirstOrDefault();
-
- LogIt("");
- }
-
- private void btnDriverOnly_Click(object sender, EventArgs e)
- {
- if (_twain.State != STATE.S4) return;
-
- var sts = _twain.EnableSource(true, true);
- LogIt("Show drivers", sts);
- LogIt("");
- }
-
- private void btnTransfer_Click(object sender, EventArgs e)
- {
- if (_twain.State != STATE.S4 || !EnsureBoxFolder()) return;
-
-
- var _isIndustrialKodak = _twain.CurrentSource.ProductName.ToString().StartsWith("KODAK Scanner: i");
-
- if (_isIndustrialKodak)
- {
- CaptureAsKodakSDMI();
- }
- else
- {
- CaptureAsStandardScanner();
- }
-
- _stopTransfer = false;
- _xferCount = 0;
- var sts = _twain.EnableSource(ckShowUI.Checked, false);
- LogIt("Start capture", sts);
- LogIt("");
- }
-
- private void CaptureAsKodakSDMI()
- {
- LogIt("Attempting Kodak SDMI mode");
-
- LogIt($"Resolution supports {FlattenFlag(_twain.Caps.ICAP_XRESOLUTION.Supports)}");
- LogIt($"File format supports {FlattenFlag(_twain.Caps.ICAP_IMAGEFILEFORMAT.Supports)}");
- LogIt($"Compression supports {FlattenFlag(_twain.Caps.ICAP_COMPRESSION.Supports)}");
- LogIt($"EXTINFO supports {FlattenFlag(_twain.Caps.ICAP_EXTIMAGEINFO.Supports)}");
-
- LogIt("");
-
- var limit = (short)boxLimit.Value;
- if (limit > 0) limit *= 2;
- var sts = _twain.Caps.CAP_XFERCOUNT.Set(limit);
- LogIt($"Set transfer limit {limit}", sts);
-
- sts = _twain.Caps.ICAP_EXTIMAGEINFO.Set(TW_BOOL.True);
- LogIt($"Set extimageinfo enabled", sts);
-
- var format = (TWFF)listFormat.SelectedItem!;
- sts = _twain.Caps.ICAP_IMAGEFILEFORMAT.Set(format);
- LogIt($"Set {format} format.", sts);
-
- if (!sts.IsSuccess)
- {
- return;
- }
-
- LogIt("");
-
- var appId = _twain.AppIdentity;
- var srcId = _twain.CurrentSource;
-
-
- TW_FILESYSTEM fs = new() { InputName = "/Camera_Bitonal_Both" };
- sts = _twain.WrapInSTS(DGControl.FileSystem.ChangeDirectory(ref appId, ref srcId, ref fs));
- LogIt("Change to bw cameras", sts);
- if (sts.IsSuccess)
- {
- sts = _twain.Caps.CAP_CAMERAENABLED.Set(TW_BOOL.True);
- LogIt("Set camera enabled", sts);
-
- var dpi = listDpi.SelectedValue == null ? 300 : Convert.ToInt32(listDpi.SelectedValue);
- sts = _twain.Caps.ICAP_XRESOLUTION.Set(dpi);
- LogIt("Set x-resolution", sts);
- sts = _twain.Caps.ICAP_YRESOLUTION.Set(dpi);
- LogIt("Set y-resolution", sts);
-
-
- if (format != TWFF.BMP)
- {
- LogIt($"Current format={_twain.Caps.ICAP_IMAGEFILEFORMAT.GetCurrent().First()}");
- LogIt($"Current compression={_twain.Caps.ICAP_COMPRESSION.GetCurrent().First()}");
- if (_twain.Caps.ICAP_COMPRESSION.Supports.HasFlag(TWQC.SET))
- {
- sts = _twain.Caps.ICAP_COMPRESSION.Set(TWCP.GROUP4);
- LogIt("Set compression to group4", sts);
- }
- }
- }
- LogIt("");
-
-
- fs = new() { FileType = (int)TWFY.CAMERA, InputName = "/Camera_Color_Both" }; sts = _twain.WrapInSTS(DGControl.FileSystem.ChangeDirectory(ref appId, ref srcId, ref fs));
- LogIt("Change to color cameras", sts);
- if (sts.IsSuccess)
- {
- sts = _twain.Caps.CAP_CAMERAENABLED.Set(TW_BOOL.True);
- LogIt("Set camera enabled", sts);
-
-
- var dpi = listDpi.SelectedValue == null ? 300 : Convert.ToInt32(listDpi.SelectedValue);
- sts = _twain.Caps.ICAP_XRESOLUTION.Set(dpi);
- LogIt("Set x-resolution", sts);
- sts = _twain.Caps.ICAP_YRESOLUTION.Set(dpi);
- LogIt("Set y-resolution", sts);
-
-
- if (format != TWFF.BMP)
- {
- LogIt($"Current format={_twain.Caps.ICAP_IMAGEFILEFORMAT.GetCurrent().First()}");
- LogIt($"Current compression={_twain.Caps.ICAP_COMPRESSION.GetCurrent().First()}");
- if (_twain.Caps.ICAP_COMPRESSION.Supports.HasFlag(TWQC.SET))
- {
- sts = _twain.Caps.ICAP_COMPRESSION.Set(TWCP.JPEG);
- LogIt("Set compression to jpg", sts);
- if (sts.IsSuccess)
- {
- LogIt($"jpeg quality supports {FlattenFlag(_twain.Caps.ICAP_JPEGQUALITY.Supports)}");
-
- short quality = 90;
- sts = _twain.Caps.ICAP_JPEGQUALITY.Set((TWJQ)quality);
- LogIt($"Set jpg quality to {quality}", sts);
- if (!sts.IsSuccess)
- {
- quality = 85;
- sts = _twain.Caps.ICAP_JPEGQUALITY.Set((TWJQ)quality);
- LogIt($"Set jpg quality to {quality}", sts);
-
- if (!sts.IsSuccess)
- {
- sts = _twain.Caps.ICAP_JPEGQUALITY.Set(TWJQ.HIGH);
- LogIt($"Set jpg quality to {TWJQ.HIGH}", sts);
- }
- }
- }
- }
- }
- }
- LogIt("");
- }
-
- const ushort TWQC_MACHINE = 0x1000;// applies to entire session/machine
- const ushort TWQC_BITONAL = 0x2000; // applies to Bitonal "cameras"
- const ushort TWQC_COLOR = 0x4000; // applies to Color "cameras"
- [Flags]
- public enum TWQC2 : ushort
- {
- MACHINE = 0x1000,
- BITONAL = 0x2000,
- COLOR = 0x4000
- }
-
- private string FlattenFlag(TWQC val)
- {
- StringBuilder sb = new();
-
- foreach (var type in Enum.GetValues(typeof(TWQC)))
- {
- if (((ushort)val & (ushort)type) > 0)
- {
- sb.Append(type).Append(", ");
- }
- }
- foreach (var type in Enum.GetValues(typeof(TWQC2)))
- {
- if (((ushort)val & (ushort)type) > 0)
- {
- sb.Append(type).Append(", ");
- }
- }
- if (sb.Length > 0)
- {
- sb.Length = sb.Length - 2;
- }
- return sb.ToString();
- }
-
- private void CaptureAsStandardScanner()
- {
- LogIt("Attempting Standard Scanner mode");
-
- var sts = _twain.Caps.ICAP_PIXELTYPE.Set(TWPT.RGB);
- LogIt("Set rgb pixel type", sts);
-
- if (_twain.Caps.CAP_DUPLEXENABLED.Supports.HasFlag(TWQC.SET))
- {
- sts = _twain.Caps.CAP_DUPLEXENABLED.Set(TW_BOOL.True);
- LogIt("Set duplex enabled", sts);
- }
-
- var dpi = listDpi.SelectedValue == null ? 300 : Convert.ToInt32(listDpi.SelectedValue);
- sts = _twain.Caps.ICAP_XRESOLUTION.Set(dpi);
- LogIt("Set x-resolution", sts);
- sts = _twain.Caps.ICAP_YRESOLUTION.Set(dpi);
- LogIt("Set y-resolution", sts);
-
- if (listFormat.SelectedItem != null)
- {
- var format = (TWFF)listFormat.SelectedItem;
-
- sts = _twain.Caps.ICAP_IMAGEFILEFORMAT.Set(format);
- LogIt($"Set {format} format.", sts);
-
- if (!sts.IsSuccess)
- {
- return;
- }
-
- if (format != TWFF.BMP)
- {
- if (_twain.Caps.ICAP_COMPRESSION.Supports.HasFlag(TWQC.SET))
- {
- sts = _twain.Caps.ICAP_COMPRESSION.Set(TWCP.JPEG);
- LogIt("Set compression to jpg", sts);
- if (sts.IsSuccess)
- {
- short quality = 90;
- sts = _twain.Caps.ICAP_JPEGQUALITY.Set((TWJQ)quality);
- LogIt($"Set jpg quality to {quality}", sts);
- if (!sts.IsSuccess)
- {
- quality = 85;
- sts = _twain.Caps.ICAP_JPEGQUALITY.Set((TWJQ)quality);
- LogIt($"Set jpg quality to {quality}", sts);
-
- if (!sts.IsSuccess)
- {
- sts = _twain.Caps.ICAP_JPEGQUALITY.Set(TWJQ.HIGH);
- LogIt($"Set jpg quality to {TWJQ.HIGH}", sts);
- }
- }
- }
- }
- }
- }
- var limit = (short)boxLimit.Value;
- sts = _twain.Caps.CAP_XFERCOUNT.Set(limit);
- LogIt($"Set transfer limit {boxLimit.Value}", sts);
- }
-
- private void btnStop_Click(object sender, EventArgs e)
- {
- _stopTransfer = true;
- }
-
- private void btnBrowseFolder_Click(object sender, EventArgs e)
- {
- using FolderBrowserDialog dialog = new();
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- boxFolder.Text = dialog.SelectedPath;
- }
- }
-
- private void btnOpenFolder_Click(object sender, EventArgs e)
- {
- if (EnsureBoxFolder())
- {
- try
- {
- using var p = Process.Start("explorer.exe", boxFolder.Text);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
-
- private bool EnsureBoxFolder()
- {
- if (!string.IsNullOrEmpty(boxFolder.Text))
- {
- if (!Directory.Exists(boxFolder.Text))
- {
- try
- {
- Directory.CreateDirectory(boxFolder.Text);
- }
- catch (Exception ex)
- {
- LogIt($"Failed to ensure save folder: {ex.Message}");
- return false;
- }
- }
- return true;
- }
- return false;
- }
- }
-}
diff --git a/samples/ScannerTester/Program.cs b/samples/ScannerTester/Program.cs
deleted file mode 100644
index 6888a6e..0000000
--- a/samples/ScannerTester/Program.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace ScannerTester
-{
- internal static class Program
- {
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- static void Main()
- {
- // To customize application configuration such as set high DPI settings or default font,
- // see https://aka.ms/applicationconfiguration.
- ApplicationConfiguration.Initialize();
- Application.Run(new MainForm());
- }
- }
-}
\ No newline at end of file
diff --git a/samples/WinConsole32/Program.cs b/samples/WinConsole32/Program.cs
deleted file mode 100644
index 4f76e2c..0000000
--- a/samples/WinConsole32/Program.cs
+++ /dev/null
@@ -1,243 +0,0 @@
-using NTwain;
-using NTwain.Data;
-using NTwain.Data.Kds;
-using System.Diagnostics;
-
-namespace WinConsole32
-{
- internal class Program
- {
- static async Task Main(string[] args)
- {
- var libVer = FileVersionInfo.GetVersionInfo(typeof(TwainAppSession).Assembly.Location).ProductVersion;
- Console.WriteLine($"Console sample {(TWPlatform.Is32bit ? " 32bit" : " 64bit")} on NTwain {libVer}");
-
- TwainAppSession twain = new TwainAppSession();
-
- twain.StateChanged += Session_StateChanged;
- twain.SourceDisabled += Session_SourceDisabled;
- twain.TransferReady += Session_TransferReady;
- twain.Transferred += Session_Transferred;
-
- var sts = await twain.OpenDSMAsync();
-
- if (sts.IsSuccess)
- {
- Console.WriteLine("Available data sources:");
-
- TW_IDENTITY_LEGACY firstSrc = default;
- foreach (var src in twain.GetSources())
- {
- if (!firstSrc.HasValue) firstSrc = src;
- Console.WriteLine($"\t{src}");
- }
- Console.WriteLine();
-
- var defaultSrc = twain.DefaultSource;
- Console.WriteLine($"Default data source = {defaultSrc}");
- Console.WriteLine();
-
- sts = twain.ShowUserSelect();
- if (sts.IsSuccess)
- {
- Console.WriteLine($"Selected data source = {twain.DefaultSource}");
- Console.WriteLine();
-
- var targetSrc = defaultSrc.HasValue ? defaultSrc : firstSrc;
-
- if (targetSrc.HasValue)
- {
- TestThisSource(twain, targetSrc);
- }
- else
- {
- Console.WriteLine("No data source to test.");
- Console.WriteLine();
- }
-
- Console.WriteLine("---------------------------------------------");
- Console.WriteLine("Test in progress, press Enter to stop testing");
- Console.WriteLine("---------------------------------------------");
- Console.ReadLine();
- twain.TryStepdown(STATE.S1);
- }
- }
- else
- {
- Console.WriteLine("Failed to attach: " + sts);
- }
-
- Console.WriteLine("-------------------");
- Console.WriteLine("Press Enter to exit");
- Console.WriteLine("-------------------");
- Console.ReadLine();
- }
-
- private static void Session_TransferReady(TwainAppSession twain, TransferReadyEventArgs e)
- {
- if (e.ImgXferMech == TWSX.FILE)
- {
- var req = TW_EXTIMAGEINFO.CreateRequest(TWEI.CAMERA, (TWEI)KDS_TWEI.HDR_PAGENUMBER, (TWEI)KDS_TWEI.HDR_COMPRESSION);
- e.GetExtendedImageInfo(ref req);
-
- string? camera = null;
- TWCP comp = TWCP.NONE;
- int pageNum = 0;
-
- foreach (var ei in req.AsInfos())
- {
- switch (ei.InfoId)
- {
- case TWEI.CAMERA:
- camera = ei.ReadHandleString(twain);
- break;
- case (TWEI)KDS_TWEI.HDR_PAGENUMBER:
- pageNum = ei.ReadNonPointerData();
- break;
- case (TWEI)KDS_TWEI.HDR_COMPRESSION:
- comp = ei.ReadNonPointerData();
- break;
- }
- }
-
- string? targetName = null;
- TWFF format = TWFF.TIFF;
- switch (comp)
- {
- case TWCP.JPEG:
- targetName = $"twain_{DateTime.Now:yyyyMMdd_HHmmss}_{xferCount:D4}.jpg";
- format = TWFF.JFIF;
- break;
- case TWCP.NONE:
- targetName = $"twain_{DateTime.Now:yyyyMMdd_HHmmss}_{xferCount:D4}.bmp";
- format = TWFF.BMP;
- break;
- default:
- targetName = $"twain_{DateTime.Now:yyyyMMdd_HHmmss}_{xferCount:D4}.tif";
- break;
- }
-
- TW_SETUPFILEXFER setup = new()
- {
- FileName = Path.Combine("Images", targetName),
- Format = format,
- };
- e.SetupFileTransfer(ref setup);
- }
- }
-
- static int xferCount = 0;
- static Stopwatch watch = new Stopwatch();
- private static void Session_Transferred(TwainAppSession twain, TransferredEventArgs e)
- {
- if (e.Data != null)
- {
- var saveFile = $"twain_{DateTime.Now:yyyyMMdd_HHmmss}_{xferCount}";
- Console.WriteLine($"SUCCESS! Got twain memory data #{++xferCount} on thread {Environment.CurrentManagedThreadId}, saving to {saveFile}.");
-
- using (var img = new ImageMagick.MagickImage(e.Data.AsStream()))
- {
- var format = ImageMagick.MagickFormat.Png;
- if (img.ColorType == ImageMagick.ColorType.Palette)
- {
- // bw or gray
- saveFile += ".png";
- }
- else
- {
- // color
- saveFile += ".jpg";
- format = ImageMagick.MagickFormat.Jpeg;
- img.Settings.Compression = ImageMagick.CompressionMethod.JPEG;
- img.Quality = (uint)85;
- }
- img.Write(saveFile, format);
- }
- }
- else if (e.FileInfo != null)
- {
- var fi = e.FileInfo.Value;
- Console.WriteLine($"SUCCESS! Got twain file data #{++xferCount} on thread {Environment.CurrentManagedThreadId} as {fi.FileName}.");
- }
- else
- {
- Console.WriteLine($"BUMMER! No twain data #{++xferCount} on thread {Environment.CurrentManagedThreadId}.");
- }
- e.Dispose();
- }
-
- private static void Session_StateChanged(TwainAppSession twain, STATE e)
- {
- Console.WriteLine($"Session state changed to {twain.State}");
- }
-
- private static void Session_SourceDisabled(TwainAppSession twain, TW_IDENTITY_LEGACY e)
- {
- watch.Stop();
- var elapsed = watch.Elapsed;
- Console.WriteLine($"Session source disabled, took {elapsed}, will retest in 3 sec...");
-
- Thread.Sleep(3000);
- if (twain.State > STATE.S3)
- TestThisSource(twain, e);
- }
-
- private static void TestThisSource(TwainAppSession twain, TW_IDENTITY_LEGACY source)
- {
- Console.WriteLine($"Testing data source {source}");
- Console.WriteLine();
-
- if (twain.State == STATE.S3) twain.OpenSource(source);
-
- if (source.ProductName.ToString().StartsWith("KODAK Scanner:"))
- {
- TryKodakSDMI(twain);
- }
- else
- {
- twain.Caps.ICAP_XFERMECH.Set(TWSX.NATIVE);
- twain.Caps.ICAP_PIXELTYPE.Set(TWPT.RGB);
- twain.Caps.ICAP_XRESOLUTION.Set(300f);
- twain.Caps.ICAP_YRESOLUTION.Set(300f);
- twain.Caps.CAP_XFERCOUNT.Set(4);
-
- xferCount = 0;
- watch.Restart();
- var rc = twain.EnableSource(true, false);
- }
- }
-
- private static void TryKodakSDMI(TwainAppSession twain)
- {
- twain.Caps.ICAP_XFERMECH.Set(TWSX.FILE);
-
- twain.Caps.ICAP_EXTIMAGEINFO.Set(TW_BOOL.True);
- //twain.Caps.ICAP_IMAGEFILEFORMAT.Set(TWFF.TIFF);
-
- var orders = twain.Caps.CAP_CAMERAORDER.GetCurrent().Cast().ToList();
-
-
- if (twain.ChangeFileSystemDirectory(TWFY.CAMERA, "/Camera_Bitonal_Both").IsSuccess)
- {
- twain.Caps.CAP_CAMERAENABLED.Set(TW_BOOL.True);
- twain.Caps.ICAP_XRESOLUTION.Set(300f);
- twain.Caps.ICAP_YRESOLUTION.Set(300f);
- twain.Caps.ICAP_COMPRESSION.Set(TWCP.GROUP4);
- }
-
- if (twain.ChangeFileSystemDirectory(TWFY.CAMERA, "/Camera_Color_Both").IsSuccess)
- {
- twain.Caps.CAP_CAMERAENABLED.Set(TW_BOOL.True);
- twain.Caps.ICAP_XRESOLUTION.Set(300f);
- twain.Caps.ICAP_YRESOLUTION.Set(300f);
- twain.Caps.ICAP_COMPRESSION.Set(TWCP.JPEG);
- twain.Caps.ICAP_JPEGQUALITY.Set(TWJQ.HIGH);
- }
- twain.Caps.CAP_XFERCOUNT.Set(4);
-
- xferCount = 0;
- watch = Stopwatch.StartNew();
- var rc = twain.EnableSource(false, false);
- }
- }
-}
\ No newline at end of file
diff --git a/samples/WinConsole32/WinConsole32.csproj b/samples/WinConsole32/WinConsole32.csproj
deleted file mode 100644
index 6299f13..0000000
--- a/samples/WinConsole32/WinConsole32.csproj
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
- Exe
- net472
- enable
- x86
- enable
- 12
- true
-
-
-
-
-
-
-
-
-
-
-
diff --git a/samples/WinForm32/ControlExtensions.cs b/samples/WinForm32/ControlExtensions.cs
index ee36178..bafb9a7 100644
--- a/samples/WinForm32/ControlExtensions.cs
+++ b/samples/WinForm32/ControlExtensions.cs
@@ -6,15 +6,14 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
-namespace WinFormSample
+namespace WinFormSample;
+
+static class ControlExtensions
{
- static class ControlExtensions
- {
public static void SetDoubleBufferedAsNeeded(this Control control)
{
- var dbprop = control.GetType().GetProperty("DoubleBuffered", BindingFlags.NonPublic | BindingFlags.Instance);
- dbprop!.SetValue(control, !SystemInformation.TerminalServerSession);
+ var dbprop = control.GetType().GetProperty("DoubleBuffered", BindingFlags.NonPublic | BindingFlags.Instance);
+ dbprop!.SetValue(control, !SystemInformation.TerminalServerSession);
}
- }
}
diff --git a/samples/WinForm32/Form1.cs b/samples/WinForm32/Form1.cs
index cc9de27..eeebfb9 100644
--- a/samples/WinForm32/Form1.cs
+++ b/samples/WinForm32/Form1.cs
@@ -2,6 +2,7 @@ using Microsoft.Win32;
using NTwain;
using NTwain.Caps;
using NTwain.Data;
+using NTwain.Events;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -38,7 +39,7 @@ public partial class Form1 : Form
TWPlatform.PreferLegacyDSM = false;
- twain = new TwainAppSession();
+ twain = new TwainAppSession(appThreadContext: SynchronizationContext.Current);
twain.StateChanged += Twain_StateChanged;
twain.DefaultSourceChanged += Twain_DefaultSourceChanged;
twain.CurrentSourceChanged += Twain_CurrentSourceChanged;
@@ -62,16 +63,13 @@ public partial class Form1 : Form
_jpegEncoder = ImageCodecInfo.GetImageEncoders().First(enc => enc.FormatID == ImageFormat.Jpeg.Guid);
}
- private void Twain_SourceDisabled(TwainAppSession sender, TW_IDENTITY_LEGACY e)
+ private void Twain_SourceDisabled(TwainAppSession sender, TWIdentityWrapper e)
{
- BeginInvoke(() =>
+ if (watch.IsRunning)
{
- if (watch.IsRunning)
- {
- watch.Stop();
- MessageBox.Show($"Took {watch.Elapsed} to finish that transfer.");
- }
- });
+ watch.Stop();
+ MessageBox.Show($"Took {watch.Elapsed} to finish that transfer.");
+ }
}
private void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
@@ -86,29 +84,18 @@ public partial class Form1 : Form
}
}
- protected override async void OnHandleCreated(EventArgs e)
+ protected override void OnLoad(EventArgs e)
{
- base.OnHandleCreated(e);
+ base.OnLoad(e);
- if (useDiyPump)
- {
- var sts = await twain.OpenDSMAsync();
- Debug.WriteLine($"OpenDSMAsync={sts}");
- }
- else
- {
- var hwnd = this.Handle;
- var sts = twain.OpenDSM(hwnd, SynchronizationContext.Current!);
- twain.AddWinformFilter();
- Debug.WriteLine($"OpenDSM={sts}");
- }
+ var sts = twain.OpenDsm();
+ Debug.WriteLine($"OpenDSMAsync={sts}");
}
protected override void OnFormClosing(FormClosingEventArgs e)
{
var finalState = twain.TryStepdown(STATE.S2);
Debug.WriteLine($"Stepdown result state={finalState}");
- twain.RemoveWinformFilter();
base.OnFormClosing(e);
}
@@ -224,44 +211,41 @@ public partial class Form1 : Form
Debug.WriteLine($"[thread {Environment.CurrentManagedThreadId}] transfer ready.");
}
- private void Twain_DefaultSourceChanged(TwainAppSession sender, TW_IDENTITY_LEGACY ds)
+ private void Twain_DefaultSourceChanged(TwainAppSession sender, TWIdentityWrapper? ds)
{
- BeginInvoke(() => lblDefault.Text = ds.ProductName);
+ lblDefault.Text = ds?.ProductName;
}
private void Twain_StateChanged(TwainAppSession sender, STATE state)
{
- BeginInvoke(() => lblState.Text = state.ToString());
+ lblState.Text = state.ToString();
}
- private void Twain_CurrentSourceChanged(TwainAppSession sender, TW_IDENTITY_LEGACY ds)
+ private void Twain_CurrentSourceChanged(TwainAppSession sender, TWIdentityWrapper? ds)
{
- BeginInvoke(() =>
+ lblCurrent.Text = ds?.ToString();
+ if (twain.State == STATE.S4)
{
- lblCurrent.Text = ds.ToString();
- if (twain.State == STATE.S4)
- {
- LoadCapInfoList();
+ LoadCapInfoList();
- // never seen a driver support these but here it is to test it
- if (twain.GetCapLabel(CAP.ICAP_SUPPORTEDSIZES, out string? test).RC == TWRC.SUCCESS)
- {
- Debug.WriteLine($"Supported sizes label from ds = {test}");
- }
- if (twain.GetCapHelp(CAP.ICAP_SUPPORTEDSIZES, out string? test2).RC == TWRC.SUCCESS)
- {
- Debug.WriteLine($"Supported sizes help from ds = {test2}");
- }
- if (twain.GetCapLabelEnum(CAP.ICAP_SUPPORTEDSIZES, out IList? test3).RC == TWRC.SUCCESS && test3 != null)
- {
- Debug.WriteLine($"Supported sizes label enum from ds = {string.Join(Environment.NewLine, test3)}");
- }
- }
- else
+ // never seen a driver support these but here it is to test it
+ if (twain.GetCapLabel(CAP.ICAP_SUPPORTEDSIZES, out string? test).RC == TWRC.SUCCESS)
{
- capListView.Items.Clear();
+ Debug.WriteLine($"Supported sizes label from ds = {test}");
}
- });
+ if (twain.GetCapHelp(CAP.ICAP_SUPPORTEDSIZES, out string? test2).RC == TWRC.SUCCESS)
+ {
+ Debug.WriteLine($"Supported sizes help from ds = {test2}");
+ }
+ if (twain.GetCapLabelEnum(CAP.ICAP_SUPPORTEDSIZES, out IList? test3).RC == TWRC.SUCCESS && test3 != null)
+ {
+ Debug.WriteLine($"Supported sizes label enum from ds = {string.Join(Environment.NewLine, test3)}");
+ }
+ }
+ else
+ {
+ capListView.Items.Clear();
+ }
}
private void LoadCapInfoList()
@@ -277,7 +261,7 @@ public partial class Form1 : Form
if (twain.GetCapCurrent(c, out TW_CAPABILITY twcap).RC == TWRC.SUCCESS)
{
var enumType = SizeAndConversionUtils.GetEnumType(c);
- var realType = twcap.DetermineValueType(twain);
+ var realType = twcap.DetermineValueType(twain.MemoryManager);
it.SubItems.Add(enumType?.Name.ToString() ?? realType.ToString());
it.SubItems.Add(ReadTypedValue(c, enumType, realType, forCurrent: true));
it.SubItems.Add(ReadTypedValue(c, enumType, realType, forCurrent: false));
@@ -441,7 +425,7 @@ public partial class Form1 : Form
private void btnSetDef_Click(object sender, EventArgs e)
{
- if (listSources.SelectedItem is TW_IDENTITY_LEGACY ds)
+ if (listSources.SelectedItem is TWIdentityWrapper ds)
{
twain.SetDefaultSource(ds);
}
@@ -449,7 +433,7 @@ public partial class Form1 : Form
private void btnOpen_Click(object sender, EventArgs e)
{
- if (listSources.SelectedItem is TW_IDENTITY_LEGACY ds)
+ if (listSources.SelectedItem is TWIdentityWrapper ds)
{
twain.TryStepdown(STATE.S3);
@@ -466,17 +450,22 @@ public partial class Form1 : Form
{
twain.TryStepdown(STATE.S3);
+ if (twain.DefaultSource == null)
+ {
+ MessageBox.Show("No default source set.");
+ return;
+ }
twain.OpenSource(twain.DefaultSource);
}
private void btnShowSettings_Click(object sender, EventArgs e)
{
- twain.EnableSource(true, true);
+ twain.EnableSource(SourceEnableOption.UIOnly);
}
private void btnStart_Click(object sender, EventArgs e)
{
- if (twain.EnableSource(ckShowUI.Checked, false).IsSuccess)
+ if (twain.EnableSource(ckShowUI.Checked ? SourceEnableOption.ShowUI : SourceEnableOption.NoUI).IsSuccess)
{
_useThreadForImag = ckBgImageHandling.Checked;
_useSystemDrawing = ckSystemDrawing.Checked;
diff --git a/samples/WinForm32/NoOpStream.cs b/samples/WinForm32/NoOpStream.cs
index 9e72ca6..d14011c 100644
--- a/samples/WinForm32/NoOpStream.cs
+++ b/samples/WinForm32/NoOpStream.cs
@@ -5,10 +5,10 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace WinFormSample
+namespace WinFormSample;
+
+internal class NoOpStream : Stream
{
- internal class NoOpStream : Stream
- {
public override bool CanRead => false;
public override bool CanSeek => false;
@@ -25,12 +25,12 @@ namespace WinFormSample
public override int Read(byte[] buffer, int offset, int count)
{
- throw new NotImplementedException();
+ throw new NotImplementedException();
}
public override long Seek(long offset, SeekOrigin origin)
{
- throw new NotImplementedException();
+ throw new NotImplementedException();
}
public override void SetLength(long value)
@@ -40,5 +40,4 @@ namespace WinFormSample
public override void Write(byte[] buffer, int offset, int count)
{
}
- }
}
diff --git a/samples/WinForm32/Program.cs b/samples/WinForm32/Program.cs
index d22ac4d..c9ebae1 100644
--- a/samples/WinForm32/Program.cs
+++ b/samples/WinForm32/Program.cs
@@ -7,39 +7,38 @@ using System.Runtime.ExceptionServices;
using System.Text;
using System.Windows.Forms;
-namespace WinFormSample
-{
- internal static class Program
- {
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- [HandleProcessCorruptedStateExceptions]
- static void Main()
- {
- //if (DsmLoader.TryUseCustomDSM())
- //{
- // Debug.WriteLine("Using our own dsm now :)");
- //}
- //else
- //{
- // Debug.WriteLine("Will attempt to use default dsm :(");
- //}
+namespace WinFormSample;
- // To customize application configuration such as set high DPI settings or default font,
- // see https://aka.ms/applicationconfiguration.
- try
- {
- ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
- }
- catch (Exception ex)
- {
- if (!Debugger.IsAttached) Debugger.Launch();
- Debugger.Break();
- Debug.WriteLine("Unhandled exception: " + ex.ToString());
- }
+internal static class Program
+{
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ //[HandleProcessCorruptedStateExceptions]
+ static void Main()
+ {
+ //if (DsmLoader.TryUseCustomDSM())
+ //{
+ // Debug.WriteLine("Using our own dsm now :)");
+ //}
+ //else
+ //{
+ // Debug.WriteLine("Will attempt to use default dsm :(");
+ //}
+
+ // To customize application configuration such as set high DPI settings or default font,
+ // see https://aka.ms/applicationconfiguration.
+ try
+ {
+ ApplicationConfiguration.Initialize();
+ Application.Run(new Form1());
+ }
+ catch (Exception ex)
+ {
+ if (!Debugger.IsAttached) Debugger.Launch();
+ Debugger.Break();
+ Debug.WriteLine("Unhandled exception: " + ex.ToString());
}
}
}
\ No newline at end of file
diff --git a/samples/WinForm32/WinForm32.csproj b/samples/WinForm32/WinForm32.csproj
index 1e9b1ae..8113a01 100644
--- a/samples/WinForm32/WinForm32.csproj
+++ b/samples/WinForm32/WinForm32.csproj
@@ -2,7 +2,7 @@
WinExe
- net10.0-windows7.0
+ net10.0-windows
enable
true
x86
@@ -23,6 +23,9 @@
PreserveNewest
+
+ PreserveNewest
+
\ No newline at end of file
diff --git a/samples/WinForm32/runtimes/win-x86/native/TWAINDSM.dll b/samples/WinForm32/runtimes/win-x86/native/TWAINDSM.dll
new file mode 100644
index 0000000..7f38f2f
Binary files /dev/null and b/samples/WinForm32/runtimes/win-x86/native/TWAINDSM.dll differ
diff --git a/samples/WinForm64/WinForm64.csproj b/samples/WinForm64/WinForm64.csproj
index cedc41b..bfb8b80 100644
--- a/samples/WinForm64/WinForm64.csproj
+++ b/samples/WinForm64/WinForm64.csproj
@@ -2,7 +2,7 @@
WinExe
- net10.0-windows7.0
+ net10.0-windows
enable
true
x64
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 0d5130b..1661bbc 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -2,21 +2,21 @@
4.0.0.0
- alpha.31
+ beta.1
4.0.0.0
$(VersionPrefix)
- https://github.com/soukoku/ntwain
+ https://github.com/soukoku/ntwain5
twain scan
MIT
Scanner-Icon.png
- https://github.com/soukoku/ntwain
+ https://github.com/soukoku/ntwain5
GIT
en-US
- Eugene Wang 2012-2025
+ Eugene Wang 2012-2026
Eugene Wang
12
@@ -26,7 +26,6 @@
true
- true
true
true
$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
diff --git a/src/NTwain/DSM/DSMGenerator.tt b/src/NTwain/DSM/DSMGenerator.tt
index be99d7b..6d9c440 100644
--- a/src/NTwain/DSM/DSMGenerator.tt
+++ b/src/NTwain/DSM/DSMGenerator.tt
@@ -22,13 +22,13 @@ using NTwain.Data;
using System;
using System.Runtime.InteropServices;
-namespace NTwain.DSM
+namespace NTwain.DSM;
+
+///
+/// Low-level pinvoke methods using <#= file.dllPath #>. <#= file.addlInfo #>
+///
+public static partial class <#= file.className #>
{
- ///
- /// Low-level pinvoke methods using <#= file.dllPath #>. <#= file.addlInfo #>
- ///
- public static partial class <#= file.className #>
- {
const string DsmName = "<#= file.dllPath #>";
#if NET7_0_OR_GREATER
@@ -399,8 +399,8 @@ namespace NTwain.DSM
ref <#= file.identityClass #> origin, ref <#= file.identityClass #> dest,
DG dg, DAT dat, MSG msg, ref TW_RGBRESPONSE resp
);
- }
}
+
<#
SaveOutput(file.className + ".cs");
}#>
diff --git a/src/NTwain/DSM/DsmLoader.cs b/src/NTwain/DSM/DsmLoader.cs
index ce03e34..deaaf60 100644
--- a/src/NTwain/DSM/DsmLoader.cs
+++ b/src/NTwain/DSM/DsmLoader.cs
@@ -1,63 +1,58 @@
-using Microsoft.Extensions.Logging;
-using NTwain.Data;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
+//using Microsoft.Extensions.Logging;
+//using NTwain.Data;
+//using System;
+//using System.Diagnostics;
+//using System.IO;
+//using System.Reflection;
+//using System.Runtime.InteropServices;
-namespace NTwain.DSM
-{
- ///
- /// For demoing loading dsm from custom path in case
- /// it's not installed on system and don't want to be
- /// placed besides the exe.
- ///
- static class DsmLoader
- {
- static IntPtr __dllPtr;
+//namespace NTwain.DSM;
- public static bool TryLoadCustomDSM(ILogger logger)
- {
- if (__dllPtr == IntPtr.Zero)
- {
-#if NETFRAMEWORK
- var curFile = Assembly.GetExecutingAssembly().Location;
- if (string.IsNullOrEmpty(curFile))
- {
- using var proc = Process.GetCurrentProcess();
- curFile = proc.MainModule.FileName;
- }
- var folder = Path.GetDirectoryName(curFile);
-#else
- var folder = AppContext.BaseDirectory;
-#endif
- if (!string.IsNullOrEmpty(folder))
- {
- var dll = Path.Combine(
- folder,
- $@"runtimes\win-{(TWPlatform.Is32bit ? "x86" : "x64")}\native\TWAINDSM.dll");
+/////
+///// For demoing loading dsm from custom path in case
+///// it's not installed on system and don't want to be
+///// placed besides the exe.
+/////
+//static class DsmLoader
+//{
+// static IntPtr __dllPtr;
- __dllPtr = LoadLibraryW(dll);
- }
+// public static bool TryLoadCustomDSM(ILogger logger)
+// {
+// if (__dllPtr == IntPtr.Zero)
+// {
+//#if NETFRAMEWORK
+// var curFile = Assembly.GetExecutingAssembly().Location;
+// if (string.IsNullOrEmpty(curFile))
+// {
+// using var proc = Process.GetCurrentProcess();
+// curFile = proc.MainModule.FileName;
+// }
+// var folder = Path.GetDirectoryName(curFile);
+//#else
+// var folder = AppContext.BaseDirectory;
+//#endif
+// if (!string.IsNullOrEmpty(folder))
+// {
+// var dll = Path.Combine(
+// folder,
+// $@"runtimes\win-{(TWPlatform.Is32bit ? "x86" : "x64")}\native\TWAINDSM.dll");
- if (__dllPtr != IntPtr.Zero)
- {
- logger.LogTrace("Using our own dsm now :)");
- }
- else
- {
- logger.LogTrace("Will attempt to use default dsm :(");
- }
- }
- return __dllPtr != IntPtr.Zero;
- }
+// __dllPtr = LoadLibraryW(dll);
+// }
- [DllImport("kernel32", SetLastError = true)]
- static extern IntPtr LoadLibraryW([MarshalAs(UnmanagedType.LPWStr)] string lpFileName);
- }
-}
+// if (__dllPtr != IntPtr.Zero)
+// {
+// logger.LogTrace("Using our own dsm now :)");
+// }
+// else
+// {
+// logger.LogTrace("Will attempt to use default dsm :(");
+// }
+// }
+// return __dllPtr != IntPtr.Zero;
+// }
+
+// [DllImport("kernel32", SetLastError = true)]
+// static extern IntPtr LoadLibraryW([MarshalAs(UnmanagedType.LPWStr)] string lpFileName);
+//}
diff --git a/src/NTwain/DSM/Linux64DSM.cs b/src/NTwain/DSM/Linux64DSM.cs
index 24183e4..b93a824 100644
--- a/src/NTwain/DSM/Linux64DSM.cs
+++ b/src/NTwain/DSM/Linux64DSM.cs
@@ -2,13 +2,13 @@ using NTwain.Data;
using System;
using System.Runtime.InteropServices;
-namespace NTwain.DSM
+namespace NTwain.DSM;
+
+///
+/// Low-level pinvoke methods using /usr/local/lib64/libtwaindsm.so. For versions since 2.4.
+///
+public static partial class Linux64DSM
{
- ///
- /// Low-level pinvoke methods using /usr/local/lib64/libtwaindsm.so. For versions since 2.4.
- ///
- public static partial class Linux64DSM
- {
const string DsmName = "/usr/local/lib64/libtwaindsm.so";
#if NET7_0_OR_GREATER
@@ -367,5 +367,5 @@ namespace NTwain.DSM
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
DG dg, DAT dat, MSG msg, ref TW_RGBRESPONSE resp
);
- }
}
+
diff --git a/src/NTwain/DSM/LinuxBotched64DSM.cs b/src/NTwain/DSM/LinuxBotched64DSM.cs
index 763424c..524aad2 100644
--- a/src/NTwain/DSM/LinuxBotched64DSM.cs
+++ b/src/NTwain/DSM/LinuxBotched64DSM.cs
@@ -2,13 +2,13 @@ using NTwain.Data;
using System;
using System.Runtime.InteropServices;
-namespace NTwain.DSM
+namespace NTwain.DSM;
+
+///
+/// Low-level pinvoke methods using /usr/local/lib/libtwaindsm.so.2.3.2. For versions before 2.4.
+///
+public static partial class LinuxBotched64DSM
{
- ///
- /// Low-level pinvoke methods using /usr/local/lib/libtwaindsm.so.2.3.2. For versions before 2.4.
- ///
- public static partial class LinuxBotched64DSM
- {
const string DsmName = "/usr/local/lib/libtwaindsm.so.2.3.2";
#if NET7_0_OR_GREATER
@@ -367,5 +367,5 @@ namespace NTwain.DSM
ref TW_IDENTITY origin, ref TW_IDENTITY dest,
DG dg, DAT dat, MSG msg, ref TW_RGBRESPONSE resp
);
- }
}
+
diff --git a/src/NTwain/DSM/LinuxDSM.cs b/src/NTwain/DSM/LinuxDSM.cs
index d3cd359..0737c1a 100644
--- a/src/NTwain/DSM/LinuxDSM.cs
+++ b/src/NTwain/DSM/LinuxDSM.cs
@@ -2,13 +2,13 @@ using NTwain.Data;
using System;
using System.Runtime.InteropServices;
-namespace NTwain.DSM
+namespace NTwain.DSM;
+
+///
+/// Low-level pinvoke methods using /usr/local/lib/libtwaindsm.so.
+///
+public static partial class LinuxDSM
{
- ///
- /// Low-level pinvoke methods using /usr/local/lib/libtwaindsm.so.
- ///
- public static partial class LinuxDSM
- {
const string DsmName = "/usr/local/lib/libtwaindsm.so";
#if NET7_0_OR_GREATER
@@ -367,5 +367,5 @@ namespace NTwain.DSM
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
DG dg, DAT dat, MSG msg, ref TW_RGBRESPONSE resp
);
- }
}
+
diff --git a/src/NTwain/DSM/OSXLegacyDSM.cs b/src/NTwain/DSM/OSXLegacyDSM.cs
index 60eb798..f2f9b90 100644
--- a/src/NTwain/DSM/OSXLegacyDSM.cs
+++ b/src/NTwain/DSM/OSXLegacyDSM.cs
@@ -2,13 +2,13 @@ using NTwain.Data;
using System;
using System.Runtime.InteropServices;
-namespace NTwain.DSM
+namespace NTwain.DSM;
+
+///
+/// Low-level pinvoke methods using /System/Library/Frameworks/framework/TWAIN.
+///
+public static partial class OSXLegacyDSM
{
- ///
- /// Low-level pinvoke methods using /System/Library/Frameworks/framework/TWAIN.
- ///
- public static partial class OSXLegacyDSM
- {
const string DsmName = "/System/Library/Frameworks/framework/TWAIN";
#if NET7_0_OR_GREATER
@@ -367,5 +367,5 @@ namespace NTwain.DSM
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
DG dg, DAT dat, MSG msg, ref TW_RGBRESPONSE resp
);
- }
}
+
diff --git a/src/NTwain/DSM/OSXNewDSM.cs b/src/NTwain/DSM/OSXNewDSM.cs
index 72b46fd..3b856c6 100644
--- a/src/NTwain/DSM/OSXNewDSM.cs
+++ b/src/NTwain/DSM/OSXNewDSM.cs
@@ -2,13 +2,13 @@ using NTwain.Data;
using System;
using System.Runtime.InteropServices;
-namespace NTwain.DSM
+namespace NTwain.DSM;
+
+///
+/// Low-level pinvoke methods using /Library/Frameworks/TWAINDSM.framework/TWAINDSM.
+///
+public static partial class OSXNewDSM
{
- ///
- /// Low-level pinvoke methods using /Library/Frameworks/TWAINDSM.framework/TWAINDSM.
- ///
- public static partial class OSXNewDSM
- {
const string DsmName = "/Library/Frameworks/TWAINDSM.framework/TWAINDSM";
#if NET7_0_OR_GREATER
@@ -367,5 +367,5 @@ namespace NTwain.DSM
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
DG dg, DAT dat, MSG msg, ref TW_RGBRESPONSE resp
);
- }
}
+
diff --git a/src/NTwain/DSM/WinLegacyDSM.cs b/src/NTwain/DSM/WinLegacyDSM.cs
index aa77407..779544d 100644
--- a/src/NTwain/DSM/WinLegacyDSM.cs
+++ b/src/NTwain/DSM/WinLegacyDSM.cs
@@ -2,13 +2,13 @@ using NTwain.Data;
using System;
using System.Runtime.InteropServices;
-namespace NTwain.DSM
+namespace NTwain.DSM;
+
+///
+/// Low-level pinvoke methods using twain_32.dll. For 32bit only.
+///
+public static partial class WinLegacyDSM
{
- ///
- /// Low-level pinvoke methods using twain_32.dll. For 32bit only.
- ///
- public static partial class WinLegacyDSM
- {
const string DsmName = "twain_32.dll";
#if NET7_0_OR_GREATER
@@ -367,5 +367,5 @@ namespace NTwain.DSM
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
DG dg, DAT dat, MSG msg, ref TW_RGBRESPONSE resp
);
- }
}
+
diff --git a/src/NTwain/DSM/WinNewDSM.cs b/src/NTwain/DSM/WinNewDSM.cs
index 88c6587..4fc7d9d 100644
--- a/src/NTwain/DSM/WinNewDSM.cs
+++ b/src/NTwain/DSM/WinNewDSM.cs
@@ -2,13 +2,13 @@ using NTwain.Data;
using System;
using System.Runtime.InteropServices;
-namespace NTwain.DSM
+namespace NTwain.DSM;
+
+///
+/// Low-level pinvoke methods using twaindsm.dll.
+///
+public static partial class WinNewDSM
{
- ///
- /// Low-level pinvoke methods using twaindsm.dll.
- ///
- public static partial class WinNewDSM
- {
const string DsmName = "twaindsm.dll";
#if NET7_0_OR_GREATER
@@ -367,5 +367,5 @@ namespace NTwain.DSM
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
DG dg, DAT dat, MSG msg, ref TW_RGBRESPONSE resp
);
- }
}
+
diff --git a/src/NTwain/Data/BufferedData.cs b/src/NTwain/Data/BufferedData.cs
index 047d36c..12fd072 100644
--- a/src/NTwain/Data/BufferedData.cs
+++ b/src/NTwain/Data/BufferedData.cs
@@ -2,13 +2,13 @@
using System.Buffers;
using System.IO;
-namespace NTwain.Data
+namespace NTwain.Data;
+
+///
+/// Simple thing with shared bytes buffer and the valid data length.
+///
+public class BufferedData : IDisposable
{
- ///
- /// Simple thing with shared bytes buffer and the valid data length.
- ///
- public class BufferedData : IDisposable
- {
// experiment using array pool for things transferred in memory.
// this can pool up to a "normal" max of legal size paper in 24 bit at 300 dpi (~31MB)
// so the array max is made with 32 MB. Typical usage should be a lot less.
@@ -16,16 +16,16 @@ namespace NTwain.Data
internal BufferedData(int size)
{
- _buffer = MemPool.Rent(size);
- _length = size;
- _fromPool = true;
+ _buffer = MemPool.Rent(size);
+ _length = size;
+ _fromPool = true;
}
internal BufferedData(byte[] data, int size, bool fromPool)
{
- _buffer = data;
- _length = size;
- _fromPool = fromPool;
+ _buffer = data;
+ _length = size;
+ _fromPool = fromPool;
}
bool _disposed;
@@ -49,8 +49,8 @@ namespace NTwain.Data
///
public ReadOnlySpan AsSpan()
{
- if (_disposed) throw new ObjectDisposedException(GetType().FullName);
- return _buffer.AsSpan(0, _length);
+ if (_disposed) throw new ObjectDisposedException(GetType().FullName);
+ return _buffer.AsSpan(0, _length);
}
///
@@ -60,8 +60,8 @@ namespace NTwain.Data
///
public ReadOnlyMemory AsMemory()
{
- if (_disposed) throw new ObjectDisposedException(GetType().FullName);
- return _buffer.AsMemory(0, _length);
+ if (_disposed) throw new ObjectDisposedException(GetType().FullName);
+ return _buffer.AsMemory(0, _length);
}
///
@@ -71,22 +71,21 @@ namespace NTwain.Data
///
public Stream AsStream()
{
- if (_disposed) throw new ObjectDisposedException(GetType().FullName);
- return new MemoryStream(_buffer, 0, _length, false);
+ if (_disposed) throw new ObjectDisposedException(GetType().FullName);
+ return new MemoryStream(_buffer, 0, _length, false);
}
public void Dispose()
{
- if (_fromPool && _disposed)
- {
- MemPool.Return(_buffer);
- _disposed = true;
- }
+ if (_fromPool && _disposed)
+ {
+ MemPool.Return(_buffer);
+ _disposed = true;
+ }
}
public static implicit operator ReadOnlySpan(BufferedData value) => value.AsSpan();
public static implicit operator ReadOnlyMemory(BufferedData value) => value.AsMemory();
public static implicit operator Stream(BufferedData value) => value.AsStream();
- }
}
diff --git a/src/NTwain/Data/README.md b/src/NTwain/Data/README.md
deleted file mode 100644
index daaeb52..0000000
--- a/src/NTwain/Data/README.md
+++ /dev/null
@@ -1,11 +0,0 @@
-This namespace contains types and utilities that were modified
-from the [twaincs project](https://github.com/twain/twain-cs).
-
-Version initially used is 2.5.0.0.
-
-I just couldn't trust myself with making correct struct definitions
-so used those instead.
-
-The `TWAINH.cs` file are minimally modified so they could be updated
-easily should I need to. Most modifications are added in
-`TWAINH_EXTRAS.cs.`
diff --git a/src/NTwain/Data/SizeAndConversionUtils.cs b/src/NTwain/Data/SizeAndConversionUtils.cs
index c47be72..50a5efa 100644
--- a/src/NTwain/Data/SizeAndConversionUtils.cs
+++ b/src/NTwain/Data/SizeAndConversionUtils.cs
@@ -1,11 +1,10 @@
using System;
using System.Collections.Generic;
-namespace NTwain.Data
-{
+namespace NTwain.Data;
- public static class SizeAndConversionUtils
- {
+public static class SizeAndConversionUtils
+{
///
/// Maps id with its enum
/// value type when applicable
@@ -15,10 +14,10 @@ namespace NTwain.Data
///
public static Type? GetEnumType(CAP cap)
{
- if (__map.ContainsKey(cap)) return __map[cap];
- return null;
+ if (__map.ContainsKey(cap)) return __map[cap];
+ return null;
}
- static readonly Dictionary __map = new()
+ static readonly Dictionary __map = new()
{
{ CAP.ACAP_XFERMECH, typeof(TWSX) },
{ CAP.CAP_ALARMS, typeof(TWAL) },
@@ -162,11 +161,11 @@ namespace NTwain.Data
///
public static int GetItemTypeSize(this TWTY type)
{
- if (__sizes.TryGetValue(type, out int size))
- {
- return size;
- }
- return 0;
+ if (__sizes.TryGetValue(type, out int size))
+ {
+ return size;
+ }
+ return 0;
}
static readonly IDictionary __sizes = new Dictionary
{
@@ -186,5 +185,4 @@ namespace NTwain.Data
// is it fixed 4 bytes or intptr size?
{TWTY.HANDLE, IntPtr.Size},
};
- }
}
diff --git a/src/NTwain/Data/TWAINH.cs b/src/NTwain/Data/TWAINH.cs
index 99fe53e..7ca2b9a 100644
--- a/src/NTwain/Data/TWAINH.cs
+++ b/src/NTwain/Data/TWAINH.cs
@@ -46,422 +46,237 @@ using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Text;
-namespace NTwain.Data
+namespace NTwain.Data;
+
+/////
+///// This file contains content gleaned from version 2.4 of the C/C++ H
+///// header file released by the TWAIN Working Group. It's organized like that
+///// file to make it easier to maintain.
+/////
+///// Please do not add any code to this module, save for the minimum needed to
+///// maintain a particular definition (such as TW_STR32)...
+/////
+//public partial class TWAIN
+//{
+///////////////////////////////////////////////////////////////////////////////
+// TWAIN Version...
+///////////////////////////////////////////////////////////////////////////////
+#region Protocol Version...
+public enum TWON_PROTOCOL
{
- /////
- ///// This file contains content gleaned from version 2.4 of the C/C++ H
- ///// header file released by the TWAIN Working Group. It's organized like that
- ///// file to make it easier to maintain.
- /////
- ///// Please do not add any code to this module, save for the minimum needed to
- ///// maintain a particular definition (such as TW_STR32)...
- /////
- //public partial class TWAIN
- //{
- ///////////////////////////////////////////////////////////////////////////////
- // TWAIN Version...
- ///////////////////////////////////////////////////////////////////////////////
- #region Protocol Version...
- public enum TWON_PROTOCOL
- {
- MAJOR = 2,
- MINOR = 5 // Changed for Version 2.5
- };
- #endregion
+ MAJOR = 2,
+ MINOR = 5 // Changed for Version 2.5
+};
+#endregion
- ///////////////////////////////////////////////////////////////////////////////
- // Type Definitions...
- ///////////////////////////////////////////////////////////////////////////////
- #region Type Definitions...
+///////////////////////////////////////////////////////////////////////////////
+// Type Definitions...
+///////////////////////////////////////////////////////////////////////////////
+#region Type Definitions...
- // Follow these rules
- /******************************************************************************
+// Follow these rules
+/******************************************************************************
- TW_HANDLE...............IntPtr
- TW_MEMREF...............IntPtr
- TW_UINTPTR..............UIntPtr
+TW_HANDLE...............IntPtr
+TW_MEMREF...............IntPtr
+TW_UINTPTR..............UIntPtr
- TW_INT8.................char
- TW_INT16................short
- TW_INT32................int (was long on Linux 64-bit)
+TW_INT8.................char
+TW_INT16................short
+TW_INT32................int (was long on Linux 64-bit)
- TW_UINT8................byte
- TW_UINT16...............ushort
- TW_UINT32...............uint (was ulong on Linux 64-bit)
- TW_BOOL.................ushort
+TW_UINT8................byte
+TW_UINT16...............ushort
+TW_UINT32...............uint (was ulong on Linux 64-bit)
+TW_BOOL.................ushort
- ******************************************************************************/
+******************************************************************************/
+
+///
+/// Our supported platforms...
+///
+public enum Platform
+{
+ UNKNOWN,
+ WINDOWS,
+ LINUX,
+ MACOSX
+};
+
+///
+/// Our supported processors...
+///
+public enum Processor
+{
+ UNKNOWN,
+ X86,
+ X86_64,
+ MIPS64EL
+};
+
+///
+/// Used for strings that go up to 32-bytes...
+///
+[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
+public partial struct TW_STR32
+{
+ ///
+ /// We're stuck with this, because marshalling with packed alignment
+ /// can't handle arrays...
+ ///
+ private byte byItem000; private byte byItem001; private byte byItem002; private byte byItem003;
+ private byte byItem004; private byte byItem005; private byte byItem006; private byte byItem007;
+ private byte byItem008; private byte byItem009; private byte byItem010; private byte byItem011;
+ private byte byItem012; private byte byItem013; private byte byItem014; private byte byItem015;
+ private byte byItem016; private byte byItem017; private byte byItem018; private byte byItem019;
+ private byte byItem020; private byte byItem021; private byte byItem022; private byte byItem023;
+ private byte byItem024; private byte byItem025; private byte byItem026; private byte byItem027;
+ private byte byItem028; private byte byItem029; private byte byItem030; private byte byItem031;
+ private byte byItem032; private byte byItem033;
///
- /// Our supported platforms...
+ /// The normal get...
///
- public enum Platform
+ ///
+ ///
+ public string Get(Encoding? encoding = null)
{
- UNKNOWN,
- WINDOWS,
- LINUX,
- MACOSX
- };
-
- ///
- /// Our supported processors...
- ///
- public enum Processor
- {
- UNKNOWN,
- X86,
- X86_64,
- MIPS64EL
- };
-
- ///
- /// Used for strings that go up to 32-bytes...
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
- public partial struct TW_STR32
- {
- ///
- /// We're stuck with this, because marshalling with packed alignment
- /// can't handle arrays...
- ///
- private byte byItem000; private byte byItem001; private byte byItem002; private byte byItem003;
- private byte byItem004; private byte byItem005; private byte byItem006; private byte byItem007;
- private byte byItem008; private byte byItem009; private byte byItem010; private byte byItem011;
- private byte byItem012; private byte byItem013; private byte byItem014; private byte byItem015;
- private byte byItem016; private byte byItem017; private byte byItem018; private byte byItem019;
- private byte byItem020; private byte byItem021; private byte byItem022; private byte byItem023;
- private byte byItem024; private byte byItem025; private byte byItem026; private byte byItem027;
- private byte byItem028; private byte byItem029; private byte byItem030; private byte byItem031;
- private byte byItem032; private byte byItem033;
-
- ///
- /// The normal get...
- ///
- ///
- ///
- public string Get(Encoding? encoding = null)
- {
- return (GetValue(true, encoding));
- }
-
- ///
- /// Use this on Mac OS X if you have a call that uses a string
- /// that doesn't include the prefix byte...
- ///
- ///
- ///
- public string GetNoPrefix(Encoding? encoding = null)
- {
- return (GetValue(false, encoding));
- }
-
- ///
- /// Get our value...
- ///
- ///
- ///
- ///
- private string GetValue(bool a_blMayHavePrefix, Encoding? encoding = null)
- {
- // convert what we have into a byte array
- byte[] abyItem = new byte[34];
- abyItem[0] = byItem000; abyItem[1] = byItem001; abyItem[2] = byItem002; abyItem[3] = byItem003;
- abyItem[4] = byItem004; abyItem[5] = byItem005; abyItem[6] = byItem006; abyItem[7] = byItem007;
- abyItem[8] = byItem008; abyItem[9] = byItem009; abyItem[10] = byItem010; abyItem[11] = byItem011;
- abyItem[12] = byItem012; abyItem[13] = byItem013; abyItem[14] = byItem014; abyItem[15] = byItem015;
- abyItem[16] = byItem016; abyItem[17] = byItem017; abyItem[18] = byItem018; abyItem[19] = byItem019;
- abyItem[20] = byItem020; abyItem[21] = byItem021; abyItem[22] = byItem022; abyItem[23] = byItem023;
- abyItem[24] = byItem024; abyItem[25] = byItem025; abyItem[26] = byItem026; abyItem[27] = byItem027;
- abyItem[28] = byItem028; abyItem[29] = byItem029; abyItem[30] = byItem030; abyItem[31] = byItem031;
- abyItem[32] = byItem032; abyItem[33] = byItem033;
-
- // Zero anything after the NUL...
- bool blNul = false;
- for (int ii = 0; ii < abyItem.Length; ii++)
- {
- if (!blNul && (abyItem[ii] == 0))
- {
- blNul = true;
- }
- else if (blNul)
- {
- abyItem[ii] = 0;
- }
- }
-
- // change encoding of byte array, then convert the bytes array to a string
- string sz = Encoding.Unicode.GetString(Encoding.Convert(encoding ?? Language.GetEncoding(), Encoding.Unicode, abyItem));
-
- // If the first character is a NUL, then return the empty string...
- while ((sz.Length > 0) && (sz[0] == '\0'))
- {
- sz = sz.Remove(0, 1);
- }
-
- // We have an emptry string...
- if (sz.Length == 0)
- {
- return ("");
- }
-
- // If we're running on a Mac, take off the prefix 'byte'...
- if (a_blMayHavePrefix && TWPlatform.IsMacOSX)
- {
- sz = sz.Remove(0, 1);
- }
-
- // If we detect a NUL, then split around it...
- if (sz.IndexOf('\0') >= 0)
- {
- sz = sz.Split(new char[] { '\0' })[0];
- }
-
- // All done...
- return (sz);
- }
-
- ///
- /// The normal set...
- ///
- ///
- ///
- ///
- public void Set(string a_sz, Encoding? encoding = null)
- {
- SetValue(a_sz, true, encoding);
- }
-
- ///
- /// Use this on Mac OS X if you have a call that uses a string
- /// that doesn't include the prefix byte...
- ///
- ///
- ///
- ///
- public void SetNoPrefix(string a_sz, Encoding? encoding = null)
- {
- SetValue(a_sz, false, encoding);
- }
-
- ///
- /// Set our value...
- ///
- ///
- ///
- ///
- private void SetValue(string a_sz, bool a_blMayHavePrefix, Encoding? encoding = null)
- {
- // If we're running on a Mac, tack on the prefix 'byte'...
- if (a_sz == null)
- {
- a_sz = "";
- }
- else if (a_blMayHavePrefix && TWPlatform.IsMacOSX)
- {
- a_sz = (char)a_sz.Length + a_sz;
- }
-
- // Make sure that we're NUL padded...
- string sz = a_sz +
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
- "\0\0";
- if (sz.Length > 34)
- {
- sz = sz.Remove(34);
- }
-
- // convert string to byte array, then change the encoding of the byte array
- byte[] abyItem = Encoding.Convert(Encoding.Unicode, encoding ?? Language.GetEncoding(), Encoding.Unicode.GetBytes(sz));
-
- // convert byte array to bytes
- if (abyItem.Length > 0)
- {
- byItem000 = abyItem[0]; byItem001 = abyItem[1]; byItem002 = abyItem[2]; byItem003 = abyItem[3];
- byItem004 = abyItem[4]; byItem005 = abyItem[5]; byItem006 = abyItem[6]; byItem007 = abyItem[7];
- byItem008 = abyItem[8]; byItem009 = abyItem[9]; byItem010 = abyItem[10]; byItem011 = abyItem[11];
- byItem012 = abyItem[12]; byItem013 = abyItem[13]; byItem014 = abyItem[14]; byItem015 = abyItem[15];
- byItem016 = abyItem[16]; byItem017 = abyItem[17]; byItem018 = abyItem[18]; byItem019 = abyItem[19];
- byItem020 = abyItem[20]; byItem021 = abyItem[21]; byItem022 = abyItem[22]; byItem023 = abyItem[23];
- byItem024 = abyItem[24]; byItem025 = abyItem[25]; byItem026 = abyItem[26]; byItem027 = abyItem[27];
- byItem028 = abyItem[28]; byItem029 = abyItem[29]; byItem030 = abyItem[30]; byItem031 = abyItem[31];
- byItem032 = abyItem[32]; byItem033 = abyItem[33];
- }
- }
+ return (GetValue(true, encoding));
}
///
- /// Used for strings that go up to 64-bytes...
+ /// Use this on Mac OS X if you have a call that uses a string
+ /// that doesn't include the prefix byte...
///
- [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
- public partial struct TW_STR64
+ ///
+ ///
+ public string GetNoPrefix(Encoding? encoding = null)
{
- ///
- /// We're stuck with this, because marshalling with packed alignment
- /// can't handle arrays...
- ///
- private byte byItem000; private byte byItem001; private byte byItem002; private byte byItem003;
- private byte byItem004; private byte byItem005; private byte byItem006; private byte byItem007;
- private byte byItem008; private byte byItem009; private byte byItem010; private byte byItem011;
- private byte byItem012; private byte byItem013; private byte byItem014; private byte byItem015;
- private byte byItem016; private byte byItem017; private byte byItem018; private byte byItem019;
- private byte byItem020; private byte byItem021; private byte byItem022; private byte byItem023;
- private byte byItem024; private byte byItem025; private byte byItem026; private byte byItem027;
- private byte byItem028; private byte byItem029; private byte byItem030; private byte byItem031;
- private byte byItem032; private byte byItem033; private byte byItem034; private byte byItem035;
- private byte byItem036; private byte byItem037; private byte byItem038; private byte byItem039;
- private byte byItem040; private byte byItem041; private byte byItem042; private byte byItem043;
- private byte byItem044; private byte byItem045; private byte byItem046; private byte byItem047;
- private byte byItem048; private byte byItem049; private byte byItem050; private byte byItem051;
- private byte byItem052; private byte byItem053; private byte byItem054; private byte byItem055;
- private byte byItem056; private byte byItem057; private byte byItem058; private byte byItem059;
- private byte byItem060; private byte byItem061; private byte byItem062; private byte byItem063;
- private byte byItem064; private byte byItem065;
+ return (GetValue(false, encoding));
+ }
- ///
- /// The normal get...
- ///
- ///
- ///
- public string Get(Encoding? encoding = null)
+ ///
+ /// Get our value...
+ ///
+ ///
+ ///
+ ///
+ private string GetValue(bool a_blMayHavePrefix, Encoding? encoding = null)
+ {
+ // convert what we have into a byte array
+ byte[] abyItem = new byte[34];
+ abyItem[0] = byItem000; abyItem[1] = byItem001; abyItem[2] = byItem002; abyItem[3] = byItem003;
+ abyItem[4] = byItem004; abyItem[5] = byItem005; abyItem[6] = byItem006; abyItem[7] = byItem007;
+ abyItem[8] = byItem008; abyItem[9] = byItem009; abyItem[10] = byItem010; abyItem[11] = byItem011;
+ abyItem[12] = byItem012; abyItem[13] = byItem013; abyItem[14] = byItem014; abyItem[15] = byItem015;
+ abyItem[16] = byItem016; abyItem[17] = byItem017; abyItem[18] = byItem018; abyItem[19] = byItem019;
+ abyItem[20] = byItem020; abyItem[21] = byItem021; abyItem[22] = byItem022; abyItem[23] = byItem023;
+ abyItem[24] = byItem024; abyItem[25] = byItem025; abyItem[26] = byItem026; abyItem[27] = byItem027;
+ abyItem[28] = byItem028; abyItem[29] = byItem029; abyItem[30] = byItem030; abyItem[31] = byItem031;
+ abyItem[32] = byItem032; abyItem[33] = byItem033;
+
+ // Zero anything after the NUL...
+ bool blNul = false;
+ for (int ii = 0; ii < abyItem.Length; ii++)
{
- return (GetValue(true, encoding));
+ if (!blNul && (abyItem[ii] == 0))
+ {
+ blNul = true;
+ }
+ else if (blNul)
+ {
+ abyItem[ii] = 0;
+ }
}
- ///
- /// Use this on Mac OS X if you have a call that uses a string
- /// that doesn't include the prefix byte...
- ///
- ///
- ///
- public string GetNoPrefix(Encoding? encoding = null)
+ // change encoding of byte array, then convert the bytes array to a string
+ string sz = Encoding.Unicode.GetString(Encoding.Convert(encoding ?? Language.GetEncoding(), Encoding.Unicode, abyItem));
+
+ // If the first character is a NUL, then return the empty string...
+ while ((sz.Length > 0) && (sz[0] == '\0'))
{
- return (GetValue(false, encoding));
+ sz = sz.Remove(0, 1);
}
- ///
- /// Get our value...
- ///
- ///
- ///
- ///
- private string GetValue(bool a_blMayHavePrefix, Encoding? encoding = null)
+ // We have an emptry string...
+ if (sz.Length == 0)
{
- // convert what we have into a byte array
- byte[] abyItem = new byte[66];
- abyItem[0] = byItem000; abyItem[1] = byItem001; abyItem[2] = byItem002; abyItem[3] = byItem003;
- abyItem[4] = byItem004; abyItem[5] = byItem005; abyItem[6] = byItem006; abyItem[7] = byItem007;
- abyItem[8] = byItem008; abyItem[9] = byItem009; abyItem[10] = byItem010; abyItem[11] = byItem011;
- abyItem[12] = byItem012; abyItem[13] = byItem013; abyItem[14] = byItem014; abyItem[15] = byItem015;
- abyItem[16] = byItem016; abyItem[17] = byItem017; abyItem[18] = byItem018; abyItem[19] = byItem019;
- abyItem[20] = byItem020; abyItem[21] = byItem021; abyItem[22] = byItem022; abyItem[23] = byItem023;
- abyItem[24] = byItem024; abyItem[25] = byItem025; abyItem[26] = byItem026; abyItem[27] = byItem027;
- abyItem[28] = byItem028; abyItem[29] = byItem029; abyItem[30] = byItem030; abyItem[31] = byItem031;
- abyItem[32] = byItem032; abyItem[33] = byItem033; abyItem[34] = byItem034; abyItem[35] = byItem035;
- abyItem[36] = byItem036; abyItem[37] = byItem037; abyItem[38] = byItem038; abyItem[39] = byItem039;
- abyItem[40] = byItem040; abyItem[41] = byItem041; abyItem[42] = byItem042; abyItem[43] = byItem043;
- abyItem[44] = byItem044; abyItem[45] = byItem045; abyItem[46] = byItem046; abyItem[47] = byItem047;
- abyItem[48] = byItem048; abyItem[49] = byItem049; abyItem[50] = byItem050; abyItem[51] = byItem051;
- abyItem[52] = byItem052; abyItem[53] = byItem053; abyItem[54] = byItem054; abyItem[55] = byItem055;
- abyItem[56] = byItem056; abyItem[57] = byItem057; abyItem[58] = byItem058; abyItem[59] = byItem059;
- abyItem[60] = byItem060; abyItem[61] = byItem061; abyItem[62] = byItem062; abyItem[63] = byItem063;
- abyItem[64] = byItem064; abyItem[65] = byItem065;
-
- // Zero anything after the NUL...
- bool blNul = false;
- for (int ii = 0; ii < abyItem.Length; ii++)
- {
- if (!blNul && (abyItem[ii] == 0))
- {
- blNul = true;
- }
- else if (blNul)
- {
- abyItem[ii] = 0;
- }
- }
-
- // change encoding of byte array, then convert the bytes array to a string
- string sz = Encoding.Unicode.GetString(Encoding.Convert(encoding ?? Language.GetEncoding(), Encoding.Unicode, abyItem));
-
- // If the first character is a NUL, then return the empty string...
- if (sz[0] == '\0')
- {
- return ("");
- }
-
- // If we're running on a Mac, take off the prefix 'byte'...
- if (a_blMayHavePrefix && TWPlatform.IsMacOSX)
- {
- sz = sz.Remove(0, 1);
- }
-
- // If we detect a NUL, then split around it...
- if (sz.IndexOf('\0') >= 0)
- {
- sz = sz.Split(new char[] { '\0' })[0];
- }
-
- // All done...
- return (sz);
+ return ("");
}
- ///
- /// The normal set...
- ///
- ///
- ///
- ///
- public void Set(string a_sz, Encoding? encoding = null)
+ // If we're running on a Mac, take off the prefix 'byte'...
+ if (a_blMayHavePrefix && TWPlatform.IsMacOSX)
{
- SetValue(a_sz, true, encoding);
+ sz = sz.Remove(0, 1);
}
- ///
- /// Use this on Mac OS X if you have a call that uses a string
- /// that doesn't include the prefix byte...
- ///
- ///
- ///
- ///
- public void SetNoPrefix(string a_sz, Encoding? encoding = null)
+ // If we detect a NUL, then split around it...
+ if (sz.IndexOf('\0') >= 0)
{
- SetValue(a_sz, false, encoding);
+ sz = sz.Split(new char[] { '\0' })[0];
}
- ///
- /// Set our value...
- ///
- ///
- ///
- ///
- private void SetValue(string a_sz, bool a_blMayHavePrefix, Encoding? encoding = null)
+ // All done...
+ return (sz);
+ }
+
+ ///
+ /// The normal set...
+ ///
+ ///
+ ///
+ ///
+ public void Set(string a_sz, Encoding? encoding = null)
+ {
+ SetValue(a_sz, true, encoding);
+ }
+
+ ///
+ /// Use this on Mac OS X if you have a call that uses a string
+ /// that doesn't include the prefix byte...
+ ///
+ ///
+ ///
+ ///
+ public void SetNoPrefix(string a_sz, Encoding? encoding = null)
+ {
+ SetValue(a_sz, false, encoding);
+ }
+
+ ///
+ /// Set our value...
+ ///
+ ///
+ ///
+ ///
+ private void SetValue(string a_sz, bool a_blMayHavePrefix, Encoding? encoding = null)
+ {
+ // If we're running on a Mac, tack on the prefix 'byte'...
+ if (a_sz == null)
{
- // If we're running on a Mac, tack on the prefix 'byte'...
- if (a_sz == null)
- {
- a_sz = "";
- }
- else if (a_blMayHavePrefix && TWPlatform.IsMacOSX)
- {
- a_sz = (char)a_sz.Length + a_sz;
- }
+ a_sz = "";
+ }
+ else if (a_blMayHavePrefix && TWPlatform.IsMacOSX)
+ {
+ a_sz = (char)a_sz.Length + a_sz;
+ }
- // Make sure that we're NUL padded...
- string sz =
- a_sz +
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
- "\0\0";
- if (sz.Length > 66)
- {
- sz = sz.Remove(66);
- }
+ // Make sure that we're NUL padded...
+ string sz = a_sz +
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
+ "\0\0";
+ if (sz.Length > 34)
+ {
+ sz = sz.Remove(34);
+ }
- // convert string to byte array, then change the encoding of the byte array
- byte[] abyItem = Encoding.Convert(Encoding.Unicode, encoding ?? Language.GetEncoding(), Encoding.Unicode.GetBytes(sz));
+ // convert string to byte array, then change the encoding of the byte array
+ byte[] abyItem = Encoding.Convert(Encoding.Unicode, encoding ?? Language.GetEncoding(), Encoding.Unicode.GetBytes(sz));
- // concert byte array to bytes
+ // convert byte array to bytes
+ if (abyItem.Length > 0)
+ {
byItem000 = abyItem[0]; byItem001 = abyItem[1]; byItem002 = abyItem[2]; byItem003 = abyItem[3];
byItem004 = abyItem[4]; byItem005 = abyItem[5]; byItem006 = abyItem[6]; byItem007 = abyItem[7];
byItem008 = abyItem[8]; byItem009 = abyItem[9]; byItem010 = abyItem[10]; byItem011 = abyItem[11];
@@ -470,4167 +285,4351 @@ namespace NTwain.Data
byItem020 = abyItem[20]; byItem021 = abyItem[21]; byItem022 = abyItem[22]; byItem023 = abyItem[23];
byItem024 = abyItem[24]; byItem025 = abyItem[25]; byItem026 = abyItem[26]; byItem027 = abyItem[27];
byItem028 = abyItem[28]; byItem029 = abyItem[29]; byItem030 = abyItem[30]; byItem031 = abyItem[31];
- byItem032 = abyItem[32]; byItem033 = abyItem[33]; byItem034 = abyItem[34]; byItem035 = abyItem[35];
- byItem036 = abyItem[36]; byItem037 = abyItem[37]; byItem038 = abyItem[38]; byItem039 = abyItem[39];
- byItem040 = abyItem[40]; byItem041 = abyItem[41]; byItem042 = abyItem[42]; byItem043 = abyItem[43];
- byItem044 = abyItem[44]; byItem045 = abyItem[45]; byItem046 = abyItem[46]; byItem047 = abyItem[47];
- byItem048 = abyItem[48]; byItem049 = abyItem[49]; byItem050 = abyItem[50]; byItem051 = abyItem[51];
- byItem052 = abyItem[52]; byItem053 = abyItem[53]; byItem054 = abyItem[54]; byItem055 = abyItem[55];
- byItem056 = abyItem[56]; byItem057 = abyItem[57]; byItem058 = abyItem[58]; byItem059 = abyItem[59];
- byItem060 = abyItem[60]; byItem061 = abyItem[61]; byItem062 = abyItem[62]; byItem063 = abyItem[63];
- byItem064 = abyItem[64]; byItem065 = abyItem[65];
+ byItem032 = abyItem[32]; byItem033 = abyItem[33];
}
}
-
- ///
- /// Used for strings that go up to 128-bytes...
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
- public partial struct TW_STR128
- {
- ///
- /// We're stuck with this, because marshalling with packed alignment
- /// can't handle arrays...
- ///
- private byte byItem000; private byte byItem001; private byte byItem002; private byte byItem003;
- private byte byItem004; private byte byItem005; private byte byItem006; private byte byItem007;
- private byte byItem008; private byte byItem009; private byte byItem010; private byte byItem011;
- private byte byItem012; private byte byItem013; private byte byItem014; private byte byItem015;
- private byte byItem016; private byte byItem017; private byte byItem018; private byte byItem019;
- private byte byItem020; private byte byItem021; private byte byItem022; private byte byItem023;
- private byte byItem024; private byte byItem025; private byte byItem026; private byte byItem027;
- private byte byItem028; private byte byItem029; private byte byItem030; private byte byItem031;
- private byte byItem032; private byte byItem033; private byte byItem034; private byte byItem035;
- private byte byItem036; private byte byItem037; private byte byItem038; private byte byItem039;
- private byte byItem040; private byte byItem041; private byte byItem042; private byte byItem043;
- private byte byItem044; private byte byItem045; private byte byItem046; private byte byItem047;
- private byte byItem048; private byte byItem049; private byte byItem050; private byte byItem051;
- private byte byItem052; private byte byItem053; private byte byItem054; private byte byItem055;
- private byte byItem056; private byte byItem057; private byte byItem058; private byte byItem059;
- private byte byItem060; private byte byItem061; private byte byItem062; private byte byItem063;
- private byte byItem064; private byte byItem065; private byte byItem066; private byte byItem067;
- private byte byItem068; private byte byItem069; private byte byItem070; private byte byItem071;
- private byte byItem072; private byte byItem073; private byte byItem074; private byte byItem075;
- private byte byItem076; private byte byItem077; private byte byItem078; private byte byItem079;
- private byte byItem080; private byte byItem081; private byte byItem082; private byte byItem083;
- private byte byItem084; private byte byItem085; private byte byItem086; private byte byItem087;
- private byte byItem088; private byte byItem089; private byte byItem090; private byte byItem091;
- private byte byItem092; private byte byItem093; private byte byItem094; private byte byItem095;
- private byte byItem096; private byte byItem097; private byte byItem098; private byte byItem099;
- private byte byItem100; private byte byItem101; private byte byItem102; private byte byItem103;
- private byte byItem104; private byte byItem105; private byte byItem106; private byte byItem107;
- private byte byItem108; private byte byItem109; private byte byItem110; private byte byItem111;
- private byte byItem112; private byte byItem113; private byte byItem114; private byte byItem115;
- private byte byItem116; private byte byItem117; private byte byItem118; private byte byItem119;
- private byte byItem120; private byte byItem121; private byte byItem122; private byte byItem123;
- private byte byItem124; private byte byItem125; private byte byItem126; private byte byItem127;
- private byte byItem128; private byte byItem129;
-
- ///
- /// The normal get...
- ///
- ///
- ///
- public string Get(Encoding? encoding = null)
- {
- return (GetValue(true, encoding));
- }
-
- ///
- /// Use this on Mac OS X if you have a call that uses a string
- /// that doesn't include the prefix byte...
- ///
- ///
- ///
- public string GetNoPrefix(Encoding? encoding = null)
- {
- return (GetValue(false, encoding));
- }
-
- ///
- /// Get our value...
- ///
- ///
- ///
- ///
- private string GetValue(bool a_blMayHavePrefix, Encoding? encoding = null)
- {
- // convert what we have into a byte array
- byte[] abyItem = new byte[130];
- abyItem[0] = byItem000; abyItem[1] = byItem001; abyItem[2] = byItem002; abyItem[3] = byItem003;
- abyItem[4] = byItem004; abyItem[5] = byItem005; abyItem[6] = byItem006; abyItem[7] = byItem007;
- abyItem[8] = byItem008; abyItem[9] = byItem009; abyItem[10] = byItem010; abyItem[11] = byItem011;
- abyItem[12] = byItem012; abyItem[13] = byItem013; abyItem[14] = byItem014; abyItem[15] = byItem015;
- abyItem[16] = byItem016; abyItem[17] = byItem017; abyItem[18] = byItem018; abyItem[19] = byItem019;
- abyItem[20] = byItem020; abyItem[21] = byItem021; abyItem[22] = byItem022; abyItem[23] = byItem023;
- abyItem[24] = byItem024; abyItem[25] = byItem025; abyItem[26] = byItem026; abyItem[27] = byItem027;
- abyItem[28] = byItem028; abyItem[29] = byItem029; abyItem[30] = byItem030; abyItem[31] = byItem031;
- abyItem[32] = byItem032; abyItem[33] = byItem033; abyItem[34] = byItem034; abyItem[35] = byItem035;
- abyItem[36] = byItem036; abyItem[37] = byItem037; abyItem[38] = byItem038; abyItem[39] = byItem039;
- abyItem[40] = byItem040; abyItem[41] = byItem041; abyItem[42] = byItem042; abyItem[43] = byItem043;
- abyItem[44] = byItem044; abyItem[45] = byItem045; abyItem[46] = byItem046; abyItem[47] = byItem047;
- abyItem[48] = byItem048; abyItem[49] = byItem049; abyItem[50] = byItem050; abyItem[51] = byItem051;
- abyItem[52] = byItem052; abyItem[53] = byItem053; abyItem[54] = byItem054; abyItem[55] = byItem055;
- abyItem[56] = byItem056; abyItem[57] = byItem057; abyItem[58] = byItem058; abyItem[59] = byItem059;
- abyItem[60] = byItem060; abyItem[61] = byItem061; abyItem[62] = byItem062; abyItem[63] = byItem063;
- abyItem[64] = byItem064; abyItem[65] = byItem065; abyItem[66] = byItem066; abyItem[67] = byItem067;
- abyItem[68] = byItem068; abyItem[69] = byItem069; abyItem[70] = byItem070; abyItem[71] = byItem071;
- abyItem[72] = byItem072; abyItem[73] = byItem073; abyItem[74] = byItem074; abyItem[75] = byItem075;
- abyItem[76] = byItem076; abyItem[77] = byItem077; abyItem[78] = byItem078; abyItem[79] = byItem079;
- abyItem[80] = byItem080; abyItem[81] = byItem081; abyItem[82] = byItem082; abyItem[83] = byItem083;
- abyItem[84] = byItem084; abyItem[85] = byItem085; abyItem[86] = byItem086; abyItem[87] = byItem087;
- abyItem[88] = byItem088; abyItem[89] = byItem089; abyItem[90] = byItem090; abyItem[91] = byItem091;
- abyItem[92] = byItem092; abyItem[93] = byItem093; abyItem[94] = byItem094; abyItem[95] = byItem095;
- abyItem[96] = byItem096; abyItem[97] = byItem097; abyItem[98] = byItem098; abyItem[99] = byItem099;
- abyItem[100] = byItem100; abyItem[101] = byItem101; abyItem[102] = byItem102; abyItem[103] = byItem103;
- abyItem[104] = byItem104; abyItem[105] = byItem105; abyItem[106] = byItem106; abyItem[107] = byItem107;
- abyItem[108] = byItem108; abyItem[109] = byItem109; abyItem[110] = byItem110; abyItem[111] = byItem111;
- abyItem[112] = byItem112; abyItem[113] = byItem113; abyItem[114] = byItem114; abyItem[115] = byItem115;
- abyItem[116] = byItem116; abyItem[117] = byItem117; abyItem[118] = byItem118; abyItem[119] = byItem119;
- abyItem[120] = byItem120; abyItem[121] = byItem121; abyItem[122] = byItem122; abyItem[123] = byItem123;
- abyItem[124] = byItem124; abyItem[125] = byItem125; abyItem[126] = byItem126; abyItem[127] = byItem127;
- abyItem[128] = byItem128; abyItem[129] = byItem129;
-
- // Zero anything after the NUL...
- bool blNul = false;
- for (int ii = 0; ii < abyItem.Length; ii++)
- {
- if (!blNul && (abyItem[ii] == 0))
- {
- blNul = true;
- }
- else if (blNul)
- {
- abyItem[ii] = 0;
- }
- }
-
- // change encoding of byte array, then convert the bytes array to a string
- string sz = Encoding.Unicode.GetString(Encoding.Convert(encoding ?? Language.GetEncoding(), Encoding.Unicode, abyItem));
-
- // If the first character is a NUL, then return the empty string...
- if (sz[0] == '\0')
- {
- return ("");
- }
-
- // If we're running on a Mac, take off the prefix 'byte'...
- if (a_blMayHavePrefix && TWPlatform.IsMacOSX)
- {
- sz = sz.Remove(0, 1);
- }
-
- // If we detect a NUL, then split around it...
- if (sz.IndexOf('\0') >= 0)
- {
- sz = sz.Split(new char[] { '\0' })[0];
- }
-
- // All done...
- return (sz);
- }
-
- ///
- /// The normal set...
- ///
- ///
- ///
- ///
- public void Set(string a_sz, Encoding? encoding = null)
- {
- SetValue(a_sz, true, encoding);
- }
-
- ///
- /// Use this on Mac OS X if you have a call that uses a string
- /// that doesn't include the prefix byte...
- ///
- ///
- ///
- ///
- public void SetNoPrefix(string a_sz, Encoding? encoding = null)
- {
- SetValue(a_sz, false, encoding);
- }
-
- ///
- /// Set our value...
- ///
- ///
- ///
- ///
- private void SetValue(string a_sz, bool a_blMayHavePrefix, Encoding? encoding = null)
- {
- // If we're running on a Mac, tack on the prefix 'byte'...
- if (a_sz == null)
- {
- a_sz = "";
- }
- else if (a_blMayHavePrefix && TWPlatform.IsMacOSX)
- {
- a_sz = (char)a_sz.Length + a_sz;
- }
-
- // Make sure that we're NUL padded...
- string sz =
- a_sz +
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
- "\0\0";
- if (sz.Length > 130)
- {
- sz = sz.Remove(130);
- }
-
- // convert string to byte array, then change the encoding of the byte array
- byte[] abyItem = Encoding.Convert(Encoding.Unicode, encoding ?? Language.GetEncoding(), Encoding.Unicode.GetBytes(sz));
-
- // concert byte array to bytes
- byItem000 = abyItem[0]; byItem001 = abyItem[1]; byItem002 = abyItem[2]; byItem003 = abyItem[3];
- byItem004 = abyItem[4]; byItem005 = abyItem[5]; byItem006 = abyItem[6]; byItem007 = abyItem[7];
- byItem008 = abyItem[8]; byItem009 = abyItem[9]; byItem010 = abyItem[10]; byItem011 = abyItem[11];
- byItem012 = abyItem[12]; byItem013 = abyItem[13]; byItem014 = abyItem[14]; byItem015 = abyItem[15];
- byItem016 = abyItem[16]; byItem017 = abyItem[17]; byItem018 = abyItem[18]; byItem019 = abyItem[19];
- byItem020 = abyItem[20]; byItem021 = abyItem[21]; byItem022 = abyItem[22]; byItem023 = abyItem[23];
- byItem024 = abyItem[24]; byItem025 = abyItem[25]; byItem026 = abyItem[26]; byItem027 = abyItem[27];
- byItem028 = abyItem[28]; byItem029 = abyItem[29]; byItem030 = abyItem[30]; byItem031 = abyItem[31];
- byItem032 = abyItem[32]; byItem033 = abyItem[33]; byItem034 = abyItem[34]; byItem035 = abyItem[35];
- byItem036 = abyItem[36]; byItem037 = abyItem[37]; byItem038 = abyItem[38]; byItem039 = abyItem[39];
- byItem040 = abyItem[40]; byItem041 = abyItem[41]; byItem042 = abyItem[42]; byItem043 = abyItem[43];
- byItem044 = abyItem[44]; byItem045 = abyItem[45]; byItem046 = abyItem[46]; byItem047 = abyItem[47];
- byItem048 = abyItem[48]; byItem049 = abyItem[49]; byItem050 = abyItem[50]; byItem051 = abyItem[51];
- byItem052 = abyItem[52]; byItem053 = abyItem[53]; byItem054 = abyItem[54]; byItem055 = abyItem[55];
- byItem056 = abyItem[56]; byItem057 = abyItem[57]; byItem058 = abyItem[58]; byItem059 = abyItem[59];
- byItem060 = abyItem[60]; byItem061 = abyItem[61]; byItem062 = abyItem[62]; byItem063 = abyItem[63];
- byItem064 = abyItem[64]; byItem065 = abyItem[65]; byItem066 = abyItem[66]; byItem067 = abyItem[67];
- byItem068 = abyItem[68]; byItem069 = abyItem[69]; byItem070 = abyItem[70]; byItem071 = abyItem[71];
- byItem072 = abyItem[72]; byItem073 = abyItem[73]; byItem074 = abyItem[74]; byItem075 = abyItem[75];
- byItem076 = abyItem[76]; byItem077 = abyItem[77]; byItem078 = abyItem[78]; byItem079 = abyItem[79];
- byItem080 = abyItem[80]; byItem081 = abyItem[81]; byItem082 = abyItem[82]; byItem083 = abyItem[83];
- byItem084 = abyItem[84]; byItem085 = abyItem[85]; byItem086 = abyItem[86]; byItem087 = abyItem[87];
- byItem088 = abyItem[88]; byItem089 = abyItem[89]; byItem090 = abyItem[90]; byItem091 = abyItem[91];
- byItem092 = abyItem[92]; byItem093 = abyItem[93]; byItem094 = abyItem[94]; byItem095 = abyItem[95];
- byItem096 = abyItem[96]; byItem097 = abyItem[97]; byItem098 = abyItem[98]; byItem099 = abyItem[99];
- byItem100 = abyItem[100]; byItem101 = abyItem[101]; byItem102 = abyItem[102]; byItem103 = abyItem[103];
- byItem104 = abyItem[104]; byItem105 = abyItem[105]; byItem106 = abyItem[106]; byItem107 = abyItem[107];
- byItem108 = abyItem[108]; byItem109 = abyItem[109]; byItem110 = abyItem[110]; byItem111 = abyItem[111];
- byItem112 = abyItem[112]; byItem113 = abyItem[113]; byItem114 = abyItem[114]; byItem115 = abyItem[115];
- byItem116 = abyItem[116]; byItem117 = abyItem[117]; byItem118 = abyItem[118]; byItem119 = abyItem[119];
- byItem120 = abyItem[120]; byItem121 = abyItem[121]; byItem122 = abyItem[122]; byItem123 = abyItem[123];
- byItem124 = abyItem[124]; byItem125 = abyItem[125]; byItem126 = abyItem[126]; byItem127 = abyItem[127];
- byItem128 = abyItem[128]; byItem129 = abyItem[129];
- }
- }
-
- ///
- /// Used for strings that go up to 256-bytes...
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
- public partial struct TW_STR255
- {
- ///
- /// We're stuck with this, because marshalling with packed alignment
- /// can't handle arrays...
- ///
- private byte byItem000; private byte byItem001; private byte byItem002; private byte byItem003;
- private byte byItem004; private byte byItem005; private byte byItem006; private byte byItem007;
- private byte byItem008; private byte byItem009; private byte byItem010; private byte byItem011;
- private byte byItem012; private byte byItem013; private byte byItem014; private byte byItem015;
- private byte byItem016; private byte byItem017; private byte byItem018; private byte byItem019;
- private byte byItem020; private byte byItem021; private byte byItem022; private byte byItem023;
- private byte byItem024; private byte byItem025; private byte byItem026; private byte byItem027;
- private byte byItem028; private byte byItem029; private byte byItem030; private byte byItem031;
- private byte byItem032; private byte byItem033; private byte byItem034; private byte byItem035;
- private byte byItem036; private byte byItem037; private byte byItem038; private byte byItem039;
- private byte byItem040; private byte byItem041; private byte byItem042; private byte byItem043;
- private byte byItem044; private byte byItem045; private byte byItem046; private byte byItem047;
- private byte byItem048; private byte byItem049; private byte byItem050; private byte byItem051;
- private byte byItem052; private byte byItem053; private byte byItem054; private byte byItem055;
- private byte byItem056; private byte byItem057; private byte byItem058; private byte byItem059;
- private byte byItem060; private byte byItem061; private byte byItem062; private byte byItem063;
- private byte byItem064; private byte byItem065; private byte byItem066; private byte byItem067;
- private byte byItem068; private byte byItem069; private byte byItem070; private byte byItem071;
- private byte byItem072; private byte byItem073; private byte byItem074; private byte byItem075;
- private byte byItem076; private byte byItem077; private byte byItem078; private byte byItem079;
- private byte byItem080; private byte byItem081; private byte byItem082; private byte byItem083;
- private byte byItem084; private byte byItem085; private byte byItem086; private byte byItem087;
- private byte byItem088; private byte byItem089; private byte byItem090; private byte byItem091;
- private byte byItem092; private byte byItem093; private byte byItem094; private byte byItem095;
- private byte byItem096; private byte byItem097; private byte byItem098; private byte byItem099;
- private byte byItem100; private byte byItem101; private byte byItem102; private byte byItem103;
- private byte byItem104; private byte byItem105; private byte byItem106; private byte byItem107;
- private byte byItem108; private byte byItem109; private byte byItem110; private byte byItem111;
- private byte byItem112; private byte byItem113; private byte byItem114; private byte byItem115;
- private byte byItem116; private byte byItem117; private byte byItem118; private byte byItem119;
- private byte byItem120; private byte byItem121; private byte byItem122; private byte byItem123;
- private byte byItem124; private byte byItem125; private byte byItem126; private byte byItem127;
- private byte byItem128; private byte byItem129; private byte byItem130; private byte byItem131;
- private byte byItem132; private byte byItem133; private byte byItem134; private byte byItem135;
- private byte byItem136; private byte byItem137; private byte byItem138; private byte byItem139;
- private byte byItem140; private byte byItem141; private byte byItem142; private byte byItem143;
- private byte byItem144; private byte byItem145; private byte byItem146; private byte byItem147;
- private byte byItem148; private byte byItem149; private byte byItem150; private byte byItem151;
- private byte byItem152; private byte byItem153; private byte byItem154; private byte byItem155;
- private byte byItem156; private byte byItem157; private byte byItem158; private byte byItem159;
- private byte byItem160; private byte byItem161; private byte byItem162; private byte byItem163;
- private byte byItem164; private byte byItem165; private byte byItem166; private byte byItem167;
- private byte byItem168; private byte byItem169; private byte byItem170; private byte byItem171;
- private byte byItem172; private byte byItem173; private byte byItem174; private byte byItem175;
- private byte byItem176; private byte byItem177; private byte byItem178; private byte byItem179;
- private byte byItem180; private byte byItem181; private byte byItem182; private byte byItem183;
- private byte byItem184; private byte byItem185; private byte byItem186; private byte byItem187;
- private byte byItem188; private byte byItem189; private byte byItem190; private byte byItem191;
- private byte byItem192; private byte byItem193; private byte byItem194; private byte byItem195;
- private byte byItem196; private byte byItem197; private byte byItem198; private byte byItem199;
- private byte byItem200; private byte byItem201; private byte byItem202; private byte byItem203;
- private byte byItem204; private byte byItem205; private byte byItem206; private byte byItem207;
- private byte byItem208; private byte byItem209; private byte byItem210; private byte byItem211;
- private byte byItem212; private byte byItem213; private byte byItem214; private byte byItem215;
- private byte byItem216; private byte byItem217; private byte byItem218; private byte byItem219;
- private byte byItem220; private byte byItem221; private byte byItem222; private byte byItem223;
- private byte byItem224; private byte byItem225; private byte byItem226; private byte byItem227;
- private byte byItem228; private byte byItem229; private byte byItem230; private byte byItem231;
- private byte byItem232; private byte byItem233; private byte byItem234; private byte byItem235;
- private byte byItem236; private byte byItem237; private byte byItem238; private byte byItem239;
- private byte byItem240; private byte byItem241; private byte byItem242; private byte byItem243;
- private byte byItem244; private byte byItem245; private byte byItem246; private byte byItem247;
- private byte byItem248; private byte byItem249; private byte byItem250; private byte byItem251;
- private byte byItem252; private byte byItem253; private byte byItem254; private byte byItem255;
-
- ///
- /// The normal get...
- ///
- ///
- ///
- public string Get(Encoding? encoding = null)
- {
- return (GetValue(true, encoding));
- }
-
- ///
- /// Use this on Mac OS X if you have a call that uses a string
- /// that doesn't include the prefix byte...
- ///
- ///
- ///
- public string GetNoPrefix(Encoding? encoding = null)
- {
- return (GetValue(false, encoding));
- }
-
- ///
- /// Get our value...
- ///
- ///
- ///
- ///
- private string GetValue(bool a_blMayHavePrefix, Encoding? encoding = null)
- {
- // convert what we have into a byte array
- byte[] abyItem = new byte[256];
- abyItem[0] = byItem000; abyItem[1] = byItem001; abyItem[2] = byItem002; abyItem[3] = byItem003;
- abyItem[4] = byItem004; abyItem[5] = byItem005; abyItem[6] = byItem006; abyItem[7] = byItem007;
- abyItem[8] = byItem008; abyItem[9] = byItem009; abyItem[10] = byItem010; abyItem[11] = byItem011;
- abyItem[12] = byItem012; abyItem[13] = byItem013; abyItem[14] = byItem014; abyItem[15] = byItem015;
- abyItem[16] = byItem016; abyItem[17] = byItem017; abyItem[18] = byItem018; abyItem[19] = byItem019;
- abyItem[20] = byItem020; abyItem[21] = byItem021; abyItem[22] = byItem022; abyItem[23] = byItem023;
- abyItem[24] = byItem024; abyItem[25] = byItem025; abyItem[26] = byItem026; abyItem[27] = byItem027;
- abyItem[28] = byItem028; abyItem[29] = byItem029; abyItem[30] = byItem030; abyItem[31] = byItem031;
- abyItem[32] = byItem032; abyItem[33] = byItem033; abyItem[34] = byItem034; abyItem[35] = byItem035;
- abyItem[36] = byItem036; abyItem[37] = byItem037; abyItem[38] = byItem038; abyItem[39] = byItem039;
- abyItem[40] = byItem040; abyItem[41] = byItem041; abyItem[42] = byItem042; abyItem[43] = byItem043;
- abyItem[44] = byItem044; abyItem[45] = byItem045; abyItem[46] = byItem046; abyItem[47] = byItem047;
- abyItem[48] = byItem048; abyItem[49] = byItem049; abyItem[50] = byItem050; abyItem[51] = byItem051;
- abyItem[52] = byItem052; abyItem[53] = byItem053; abyItem[54] = byItem054; abyItem[55] = byItem055;
- abyItem[56] = byItem056; abyItem[57] = byItem057; abyItem[58] = byItem058; abyItem[59] = byItem059;
- abyItem[60] = byItem060; abyItem[61] = byItem061; abyItem[62] = byItem062; abyItem[63] = byItem063;
- abyItem[64] = byItem064; abyItem[65] = byItem065; abyItem[66] = byItem066; abyItem[67] = byItem067;
- abyItem[68] = byItem068; abyItem[69] = byItem069; abyItem[70] = byItem070; abyItem[71] = byItem071;
- abyItem[72] = byItem072; abyItem[73] = byItem073; abyItem[74] = byItem074; abyItem[75] = byItem075;
- abyItem[76] = byItem076; abyItem[77] = byItem077; abyItem[78] = byItem078; abyItem[79] = byItem079;
- abyItem[80] = byItem080; abyItem[81] = byItem081; abyItem[82] = byItem082; abyItem[83] = byItem083;
- abyItem[84] = byItem084; abyItem[85] = byItem085; abyItem[86] = byItem086; abyItem[87] = byItem087;
- abyItem[88] = byItem088; abyItem[89] = byItem089; abyItem[90] = byItem090; abyItem[91] = byItem091;
- abyItem[92] = byItem092; abyItem[93] = byItem093; abyItem[94] = byItem094; abyItem[95] = byItem095;
- abyItem[96] = byItem096; abyItem[97] = byItem097; abyItem[98] = byItem098; abyItem[99] = byItem099;
- abyItem[100] = byItem100; abyItem[101] = byItem101; abyItem[102] = byItem102; abyItem[103] = byItem103;
- abyItem[104] = byItem104; abyItem[105] = byItem105; abyItem[106] = byItem106; abyItem[107] = byItem107;
- abyItem[108] = byItem108; abyItem[109] = byItem109; abyItem[110] = byItem110; abyItem[111] = byItem111;
- abyItem[112] = byItem112; abyItem[113] = byItem113; abyItem[114] = byItem114; abyItem[115] = byItem115;
- abyItem[116] = byItem116; abyItem[117] = byItem117; abyItem[118] = byItem118; abyItem[119] = byItem119;
- abyItem[120] = byItem120; abyItem[121] = byItem121; abyItem[122] = byItem122; abyItem[123] = byItem123;
- abyItem[124] = byItem124; abyItem[125] = byItem125; abyItem[126] = byItem126; abyItem[127] = byItem127;
- abyItem[128] = byItem128; abyItem[129] = byItem129; abyItem[130] = byItem130; abyItem[131] = byItem131;
- abyItem[132] = byItem132; abyItem[133] = byItem133; abyItem[134] = byItem134; abyItem[135] = byItem135;
- abyItem[136] = byItem136; abyItem[137] = byItem137; abyItem[138] = byItem138; abyItem[139] = byItem139;
- abyItem[140] = byItem140; abyItem[141] = byItem141; abyItem[142] = byItem142; abyItem[143] = byItem143;
- abyItem[144] = byItem144; abyItem[145] = byItem145; abyItem[146] = byItem146; abyItem[147] = byItem147;
- abyItem[148] = byItem148; abyItem[149] = byItem149; abyItem[150] = byItem150; abyItem[151] = byItem151;
- abyItem[152] = byItem152; abyItem[153] = byItem153; abyItem[154] = byItem154; abyItem[155] = byItem155;
- abyItem[156] = byItem156; abyItem[157] = byItem157; abyItem[158] = byItem158; abyItem[159] = byItem159;
- abyItem[160] = byItem160; abyItem[161] = byItem161; abyItem[162] = byItem162; abyItem[163] = byItem163;
- abyItem[164] = byItem164; abyItem[165] = byItem165; abyItem[166] = byItem166; abyItem[167] = byItem167;
- abyItem[168] = byItem168; abyItem[169] = byItem169; abyItem[170] = byItem170; abyItem[171] = byItem171;
- abyItem[172] = byItem172; abyItem[173] = byItem173; abyItem[174] = byItem174; abyItem[175] = byItem175;
- abyItem[176] = byItem176; abyItem[177] = byItem177; abyItem[178] = byItem178; abyItem[179] = byItem179;
- abyItem[180] = byItem180; abyItem[181] = byItem181; abyItem[182] = byItem182; abyItem[183] = byItem183;
- abyItem[184] = byItem184; abyItem[185] = byItem185; abyItem[186] = byItem186; abyItem[187] = byItem187;
- abyItem[188] = byItem188; abyItem[189] = byItem189; abyItem[190] = byItem190; abyItem[191] = byItem191;
- abyItem[192] = byItem192; abyItem[193] = byItem193; abyItem[194] = byItem194; abyItem[195] = byItem195;
- abyItem[196] = byItem196; abyItem[197] = byItem197; abyItem[198] = byItem198; abyItem[199] = byItem199;
- abyItem[200] = byItem200; abyItem[201] = byItem201; abyItem[202] = byItem202; abyItem[203] = byItem203;
- abyItem[204] = byItem204; abyItem[205] = byItem205; abyItem[206] = byItem206; abyItem[207] = byItem207;
- abyItem[208] = byItem208; abyItem[209] = byItem209; abyItem[210] = byItem210; abyItem[211] = byItem211;
- abyItem[212] = byItem212; abyItem[213] = byItem213; abyItem[214] = byItem214; abyItem[215] = byItem215;
- abyItem[216] = byItem216; abyItem[217] = byItem217; abyItem[218] = byItem218; abyItem[219] = byItem219;
- abyItem[220] = byItem220; abyItem[221] = byItem221; abyItem[222] = byItem222; abyItem[223] = byItem223;
- abyItem[224] = byItem224; abyItem[225] = byItem225; abyItem[226] = byItem226; abyItem[227] = byItem227;
- abyItem[228] = byItem228; abyItem[229] = byItem229; abyItem[230] = byItem230; abyItem[231] = byItem231;
- abyItem[232] = byItem232; abyItem[233] = byItem233; abyItem[234] = byItem234; abyItem[235] = byItem235;
- abyItem[236] = byItem236; abyItem[237] = byItem237; abyItem[238] = byItem238; abyItem[239] = byItem239;
- abyItem[240] = byItem240; abyItem[241] = byItem241; abyItem[242] = byItem242; abyItem[243] = byItem243;
- abyItem[244] = byItem244; abyItem[245] = byItem245; abyItem[246] = byItem246; abyItem[247] = byItem247;
- abyItem[248] = byItem248; abyItem[249] = byItem249; abyItem[250] = byItem250; abyItem[251] = byItem251;
- abyItem[252] = byItem252; abyItem[253] = byItem253; abyItem[254] = byItem254; abyItem[255] = byItem255;
-
- // Zero anything after the NUL...
- bool blNul = false;
- for (int ii = 0; ii < abyItem.Length; ii++)
- {
- if (!blNul && (abyItem[ii] == 0))
- {
- blNul = true;
- }
- else if (blNul)
- {
- abyItem[ii] = 0;
- }
- }
-
- // change encoding of byte array, then convert the bytes array to a string
- string sz = Encoding.Unicode.GetString(Encoding.Convert(encoding ?? Language.GetEncoding(), Encoding.Unicode, abyItem));
-
- // If the first character is a NUL, then return the empty string...
- if (sz[0] == '\0')
- {
- return ("");
- }
-
- // If we're running on a Mac, take off the prefix 'byte'...
- if (a_blMayHavePrefix && TWPlatform.IsMacOSX)
- {
- sz = sz.Remove(0, 1);
- }
-
- // If we detect a NUL, then split around it...
- if (sz.IndexOf('\0') >= 0)
- {
- sz = sz.Split(new char[] { '\0' })[0];
- }
-
- // All done...
- return (sz);
- }
-
- ///
- /// The normal set...
- ///
- ///
- ///
- ///
- public void Set(string a_sz, Encoding? encoding = null)
- {
- SetValue(a_sz, true, encoding);
- }
-
- ///
- /// Use this on Mac OS X if you have a call that uses a string
- /// that doesn't include the prefix byte...
- ///
- ///
- ///
- ///
- public void SetNoPrefix(string a_sz, Encoding? encoding = null)
- {
- SetValue(a_sz, false, encoding);
- }
-
- ///
- /// Set our value...
- ///
- ///
- ///
- ///
- private void SetValue(string a_sz, bool a_blMayHavePrefix, Encoding? encoding = null)
- {
- // If we're running on a Mac, tack on the prefix 'byte'...
- if (a_sz == null)
- {
- a_sz = "";
- }
- else if (a_blMayHavePrefix && TWPlatform.IsMacOSX)
- {
- a_sz = (char)a_sz.Length + a_sz;
- }
-
- // Make sure that we're NUL padded...
- string sz =
- a_sz +
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
- if (sz.Length > 256)
- {
- sz = sz.Remove(256);
- }
-
- // convert string to byte array, then change the encoding of the byte array
- byte[] abyItem = Encoding.Convert(Encoding.Unicode, encoding ?? Language.GetEncoding(), Encoding.Unicode.GetBytes(sz));
-
- // concert byte array to bytes
- byItem000 = abyItem[0]; byItem001 = abyItem[1]; byItem002 = abyItem[2]; byItem003 = abyItem[3];
- byItem004 = abyItem[4]; byItem005 = abyItem[5]; byItem006 = abyItem[6]; byItem007 = abyItem[7];
- byItem008 = abyItem[8]; byItem009 = abyItem[9]; byItem010 = abyItem[10]; byItem011 = abyItem[11];
- byItem012 = abyItem[12]; byItem013 = abyItem[13]; byItem014 = abyItem[14]; byItem015 = abyItem[15];
- byItem016 = abyItem[16]; byItem017 = abyItem[17]; byItem018 = abyItem[18]; byItem019 = abyItem[19];
- byItem020 = abyItem[20]; byItem021 = abyItem[21]; byItem022 = abyItem[22]; byItem023 = abyItem[23];
- byItem024 = abyItem[24]; byItem025 = abyItem[25]; byItem026 = abyItem[26]; byItem027 = abyItem[27];
- byItem028 = abyItem[28]; byItem029 = abyItem[29]; byItem030 = abyItem[30]; byItem031 = abyItem[31];
- byItem032 = abyItem[32]; byItem033 = abyItem[33]; byItem034 = abyItem[34]; byItem035 = abyItem[35];
- byItem036 = abyItem[36]; byItem037 = abyItem[37]; byItem038 = abyItem[38]; byItem039 = abyItem[39];
- byItem040 = abyItem[40]; byItem041 = abyItem[41]; byItem042 = abyItem[42]; byItem043 = abyItem[43];
- byItem044 = abyItem[44]; byItem045 = abyItem[45]; byItem046 = abyItem[46]; byItem047 = abyItem[47];
- byItem048 = abyItem[48]; byItem049 = abyItem[49]; byItem050 = abyItem[50]; byItem051 = abyItem[51];
- byItem052 = abyItem[52]; byItem053 = abyItem[53]; byItem054 = abyItem[54]; byItem055 = abyItem[55];
- byItem056 = abyItem[56]; byItem057 = abyItem[57]; byItem058 = abyItem[58]; byItem059 = abyItem[59];
- byItem060 = abyItem[60]; byItem061 = abyItem[61]; byItem062 = abyItem[62]; byItem063 = abyItem[63];
- byItem064 = abyItem[64]; byItem065 = abyItem[65]; byItem066 = abyItem[66]; byItem067 = abyItem[67];
- byItem068 = abyItem[68]; byItem069 = abyItem[69]; byItem070 = abyItem[70]; byItem071 = abyItem[71];
- byItem072 = abyItem[72]; byItem073 = abyItem[73]; byItem074 = abyItem[74]; byItem075 = abyItem[75];
- byItem076 = abyItem[76]; byItem077 = abyItem[77]; byItem078 = abyItem[78]; byItem079 = abyItem[79];
- byItem080 = abyItem[80]; byItem081 = abyItem[81]; byItem082 = abyItem[82]; byItem083 = abyItem[83];
- byItem084 = abyItem[84]; byItem085 = abyItem[85]; byItem086 = abyItem[86]; byItem087 = abyItem[87];
- byItem088 = abyItem[88]; byItem089 = abyItem[89]; byItem090 = abyItem[90]; byItem091 = abyItem[91];
- byItem092 = abyItem[92]; byItem093 = abyItem[93]; byItem094 = abyItem[94]; byItem095 = abyItem[95];
- byItem096 = abyItem[96]; byItem097 = abyItem[97]; byItem098 = abyItem[98]; byItem099 = abyItem[99];
- byItem100 = abyItem[100]; byItem101 = abyItem[101]; byItem102 = abyItem[102]; byItem103 = abyItem[103];
- byItem104 = abyItem[104]; byItem105 = abyItem[105]; byItem106 = abyItem[106]; byItem107 = abyItem[107];
- byItem108 = abyItem[108]; byItem109 = abyItem[109]; byItem110 = abyItem[110]; byItem111 = abyItem[111];
- byItem112 = abyItem[112]; byItem113 = abyItem[113]; byItem114 = abyItem[114]; byItem115 = abyItem[115];
- byItem116 = abyItem[116]; byItem117 = abyItem[117]; byItem118 = abyItem[118]; byItem119 = abyItem[119];
- byItem120 = abyItem[120]; byItem121 = abyItem[121]; byItem122 = abyItem[122]; byItem123 = abyItem[123];
- byItem124 = abyItem[124]; byItem125 = abyItem[125]; byItem126 = abyItem[126]; byItem127 = abyItem[127];
- byItem128 = abyItem[128]; byItem129 = abyItem[129]; byItem130 = abyItem[130]; byItem131 = abyItem[131];
- byItem132 = abyItem[132]; byItem133 = abyItem[133]; byItem134 = abyItem[134]; byItem135 = abyItem[135];
- byItem136 = abyItem[136]; byItem137 = abyItem[137]; byItem138 = abyItem[138]; byItem139 = abyItem[139];
- byItem140 = abyItem[140]; byItem141 = abyItem[141]; byItem142 = abyItem[142]; byItem143 = abyItem[143];
- byItem144 = abyItem[144]; byItem145 = abyItem[145]; byItem146 = abyItem[146]; byItem147 = abyItem[147];
- byItem148 = abyItem[148]; byItem149 = abyItem[149]; byItem150 = abyItem[150]; byItem151 = abyItem[151];
- byItem152 = abyItem[152]; byItem153 = abyItem[153]; byItem154 = abyItem[154]; byItem155 = abyItem[155];
- byItem156 = abyItem[156]; byItem157 = abyItem[157]; byItem158 = abyItem[158]; byItem159 = abyItem[159];
- byItem160 = abyItem[160]; byItem161 = abyItem[161]; byItem162 = abyItem[162]; byItem163 = abyItem[163];
- byItem164 = abyItem[164]; byItem165 = abyItem[165]; byItem166 = abyItem[166]; byItem167 = abyItem[167];
- byItem168 = abyItem[168]; byItem169 = abyItem[169]; byItem170 = abyItem[170]; byItem171 = abyItem[171];
- byItem172 = abyItem[172]; byItem173 = abyItem[173]; byItem174 = abyItem[174]; byItem175 = abyItem[175];
- byItem176 = abyItem[176]; byItem177 = abyItem[177]; byItem178 = abyItem[178]; byItem179 = abyItem[179];
- byItem180 = abyItem[180]; byItem181 = abyItem[181]; byItem182 = abyItem[182]; byItem183 = abyItem[183];
- byItem184 = abyItem[184]; byItem185 = abyItem[185]; byItem186 = abyItem[186]; byItem187 = abyItem[187];
- byItem188 = abyItem[188]; byItem189 = abyItem[189]; byItem190 = abyItem[190]; byItem191 = abyItem[191];
- byItem192 = abyItem[192]; byItem193 = abyItem[193]; byItem194 = abyItem[194]; byItem195 = abyItem[195];
- byItem196 = abyItem[196]; byItem197 = abyItem[197]; byItem198 = abyItem[198]; byItem199 = abyItem[199];
- byItem200 = abyItem[200]; byItem201 = abyItem[201]; byItem202 = abyItem[202]; byItem203 = abyItem[203];
- byItem204 = abyItem[204]; byItem205 = abyItem[205]; byItem206 = abyItem[206]; byItem207 = abyItem[207];
- byItem208 = abyItem[208]; byItem209 = abyItem[209]; byItem210 = abyItem[210]; byItem211 = abyItem[211];
- byItem212 = abyItem[212]; byItem213 = abyItem[213]; byItem214 = abyItem[214]; byItem215 = abyItem[215];
- byItem216 = abyItem[216]; byItem217 = abyItem[217]; byItem218 = abyItem[218]; byItem219 = abyItem[219];
- byItem220 = abyItem[220]; byItem221 = abyItem[221]; byItem222 = abyItem[222]; byItem223 = abyItem[223];
- byItem224 = abyItem[224]; byItem225 = abyItem[225]; byItem226 = abyItem[226]; byItem227 = abyItem[227];
- byItem228 = abyItem[228]; byItem229 = abyItem[229]; byItem230 = abyItem[230]; byItem231 = abyItem[231];
- byItem232 = abyItem[232]; byItem233 = abyItem[233]; byItem234 = abyItem[234]; byItem235 = abyItem[235];
- byItem236 = abyItem[236]; byItem237 = abyItem[237]; byItem238 = abyItem[238]; byItem239 = abyItem[239];
- byItem240 = abyItem[240]; byItem241 = abyItem[241]; byItem242 = abyItem[242]; byItem243 = abyItem[243];
- byItem244 = abyItem[244]; byItem245 = abyItem[245]; byItem246 = abyItem[246]; byItem247 = abyItem[247];
- byItem248 = abyItem[248]; byItem249 = abyItem[249]; byItem250 = abyItem[250]; byItem251 = abyItem[251];
- byItem252 = abyItem[252]; byItem253 = abyItem[253]; byItem254 = abyItem[254]; byItem255 = abyItem[255];
- }
- }
-
- #endregion
-
-
- ///////////////////////////////////////////////////////////////////////////////
- // Structure Definitions...
- ///////////////////////////////////////////////////////////////////////////////
- #region Structure Definitions..
-
- ///
- /// Fixed point structure type.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public partial struct TW_FIX32
- {
- public short Whole;
- public ushort Frac;
- }
-
- ///
- /// Defines a frame rectangle in ICAP_UNITS coordinates.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public partial struct TW_FRAME
- {
- public TW_FIX32 Left;
- public TW_FIX32 Top;
- public TW_FIX32 Right;
- public TW_FIX32 Bottom;
- }
-
- ///
- /// Defines the parameters used for channel-specific transformation.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_DECODEFUNCTION
- {
- public TW_FIX32 StartIn;
- public TW_FIX32 BreakIn;
- public TW_FIX32 EndIn;
- public TW_FIX32 StartOut;
- public TW_FIX32 BreakOut;
- public TW_FIX32 EndOut;
- public TW_FIX32 Gamma;
- public TW_FIX32 SampleCount;
- }
-
- ///
- /// Stores a Fixed point number in two parts, a whole and a fractional part.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_TRANSFORMSTAGE
- {
- public TW_DECODEFUNCTION Decode_0;
- public TW_DECODEFUNCTION Decode_1;
- public TW_DECODEFUNCTION Decode_2;
- public TW_FIX32 Mix_0_0;
- public TW_FIX32 Mix_0_1;
- public TW_FIX32 Mix_0_2;
- public TW_FIX32 Mix_1_0;
- public TW_FIX32 Mix_1_1;
- public TW_FIX32 Mix_1_2;
- public TW_FIX32 Mix_2_0;
- public TW_FIX32 Mix_2_1;
- public TW_FIX32 Mix_2_2;
- }
-
- ///
- /// Stores a list of values for a capability, the ItemList is commented
- /// out so that the caller can collect information about it with a
- /// marshalling call...
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_ARRAY
- {
- public TWTY ItemType;
- public uint NumItems;
- //public byte[] ItemList;
- }
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_ARRAY_MACOSX
- {
- public uint ItemType;
- public uint NumItems;
- //public byte[] ItemList;
- }
-
- ///
- /// Information about audio data.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_AUDIOINFO
- {
- public TW_STR255 Name;
- public uint Reserved;
- }
-
- ///
- /// Used to register callbacks.
- ///
- [SuppressMessage("Microsoft.Design", "CA1049:TypesThatOwnNativeResourcesShouldBeDisposable")]
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_CALLBACK
- {
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr CallBackProc;
- public uint RefCon;
- public ushort Message;
- }
-
- ///
- /// Used to register callbacks.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_CALLBACK2
- {
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr CallBackProc;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public UIntPtr RefCon;
- public ushort Message;
- }
-
- ///
- /// Used by application to get/set capability from/in a data source.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
- public partial struct TW_CAPABILITY
- {
- public CAP Cap;
- public TWON ConType;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr hContainer;
- }
-
- ///
- /// Defines a CIE XYZ space tri-stimulus value.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_CIEPOINT
- {
- public TW_FIX32 X;
- public TW_FIX32 Y;
- public TW_FIX32 Z;
- }
-
- ///
- /// Defines the mapping from an RGB color space device into CIE 1931 (XYZ) color space.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_CIECOLOR
- {
- public ushort ColorSpace;
- public short LowEndian;
- public short DeviceDependent;
- public int VersionNumber;
- public TW_TRANSFORMSTAGE StageABC;
- public TW_TRANSFORMSTAGE StageLNM;
- public TW_CIEPOINT WhitePoint;
- public TW_CIEPOINT BlackPoint;
- public TW_CIEPOINT WhitePaper;
- public TW_CIEPOINT BlackInk;
- public TW_FIX32 Samples;
- }
-
- ///
- /// Allows for a data source and application to pass custom data to each other.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_CUSTOMDSDATA
- {
- public uint InfoLength;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr hData;
- }
-
- ///
- /// Provides information about the Event that was raised by the Source.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public partial struct TW_DEVICEEVENT
- {
- private uint _Event;
- public TW_STR255 DeviceName;
- public uint BatteryMinutes;
- public short BatteryPercentage;
- public int PowerSupply;
- public TW_FIX32 XResolution;
- public TW_FIX32 YResolution;
- private uint _FlashUsed2;
- public uint AutomaticCapture;
- public uint TimeBeforeFirstCapture;
- public uint TimeBetweenCaptures;
- }
-
- ///
- /// This structure holds the tri-stimulus color palette information for TW_PALETTE8 structures.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_ELEMENT8
- {
- public byte Index;
- public byte Channel1;
- public byte Channel2;
- public byte Channel3;
- }
-
- ///
- /// DAT_ENTRYPOINT. returns essential entry points.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_ENTRYPOINT
- {
- public UInt32 Size;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr DSM_Entry;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr DSM_MemAllocate;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr DSM_MemFree;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr DSM_MemLock;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr DSM_MemUnlock;
- }
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_ENTRYPOINT_LINUX64
- {
- public long Size;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr DSM_Entry;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr DSM_MemAllocate;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr DSM_MemFree;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr DSM_MemLock;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr DSM_MemUnlock;
- }
- public struct TW_ENTRYPOINT_DELEGATES
- {
- public UInt32 Size;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr DSM_Entry;
- public DSM_MEMALLOC DSM_MemAllocate;
- public DSM_MEMFREE DSM_MemFree;
- public DSM_MEMLOCK DSM_MemLock;
- public DSM_MEMUNLOCK DSM_MemUnlock;
- }
- public delegate IntPtr DSM_MEMALLOC(uint size);
- public delegate void DSM_MEMFREE(IntPtr handle);
- public delegate IntPtr DSM_MEMLOCK(IntPtr handle);
- public delegate void DSM_MEMUNLOCK(IntPtr handle);
-
- ///
- /// Stores a group of enumerated values for a capability, the ItemList is
- /// commented out so that the caller can collect information about it with
- /// a marshalling call...
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_ENUMERATION
- {
- public TWTY ItemType;
- public uint NumItems;
- public uint CurrentIndex;
- public uint DefaultIndex;
- //public byte[] ItemList;
- }
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_ENUMERATION_LINUX64
- {
- public TWTY ItemType;
- public ulong NumItems;
- public ulong CurrentIndex;
- public ulong DefaultIndex;
- //public byte[] ItemList;
- }
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- public struct TW_ENUMERATION_MACOSX
- {
- public uint ItemType;
- public uint NumItems;
- public uint CurrentIndex;
- public uint DefaultIndex;
- //public byte[] ItemList;
- }
-
- ///
- /// Used to pass application events/messages from the application to the Source.
- ///
- [SuppressMessage("Microsoft.Design", "CA1049:TypesThatOwnNativeResourcesShouldBeDisposable")]
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_EVENT
- {
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr pEvent;
- public ushort TWMessage;
- }
-
- ///
- /// DAT_FILTER...
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_FILTER_DESCRIPTOR
- {
- public UInt32 Size;
- public UInt32 HueStart;
- public UInt32 HueEnd;
- public UInt32 SaturationStart;
- public UInt32 SaturationEnd;
- public UInt32 ValueStart;
- public UInt32 ValueEnd;
- public UInt32 Replacement;
- }
-
- ///
- /// DAT_FILTER...
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_FILTER
- {
- public UInt32 Size;
- public UInt32 DescriptorCount;
- public UInt32 MaxDescriptorCount;
- public UInt32 Condition;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr hDescriptors;
- }
-
- ///
- /// This structure is used to pass specific information between the data source and the application.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public partial struct TW_INFO
- {
- public TWEI InfoId;
- public TWTY ItemType;
- public ushort NumItems;
- public TWRC ReturnCode;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public UIntPtr Item;
- }
-
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public partial struct TW_EXTIMAGEINFO
- {
- private uint NumInfos;
- private TW_INFO Info_000;
- private TW_INFO Info_001;
- private TW_INFO Info_002;
- private TW_INFO Info_003;
- private TW_INFO Info_004;
- private TW_INFO Info_005;
- private TW_INFO Info_006;
- private TW_INFO Info_007;
- private TW_INFO Info_008;
- private TW_INFO Info_009;
- private TW_INFO Info_010;
- private TW_INFO Info_011;
- private TW_INFO Info_012;
- private TW_INFO Info_013;
- private TW_INFO Info_014;
- private TW_INFO Info_015;
- private TW_INFO Info_016;
- private TW_INFO Info_017;
- private TW_INFO Info_018;
- private TW_INFO Info_019;
- private TW_INFO Info_020;
- private TW_INFO Info_021;
- private TW_INFO Info_022;
- private TW_INFO Info_023;
- private TW_INFO Info_024;
- private TW_INFO Info_025;
- private TW_INFO Info_026;
- private TW_INFO Info_027;
- private TW_INFO Info_028;
- private TW_INFO Info_029;
- private TW_INFO Info_030;
- private TW_INFO Info_031;
- private TW_INFO Info_032;
- private TW_INFO Info_033;
- private TW_INFO Info_034;
- private TW_INFO Info_035;
- private TW_INFO Info_036;
- private TW_INFO Info_037;
- private TW_INFO Info_038;
- private TW_INFO Info_039;
- private TW_INFO Info_040;
- private TW_INFO Info_041;
- private TW_INFO Info_042;
- private TW_INFO Info_043;
- private TW_INFO Info_044;
- private TW_INFO Info_045;
- private TW_INFO Info_046;
- private TW_INFO Info_047;
- private TW_INFO Info_048;
- private TW_INFO Info_049;
- private TW_INFO Info_050;
- private TW_INFO Info_051;
- private TW_INFO Info_052;
- private TW_INFO Info_053;
- private TW_INFO Info_054;
- private TW_INFO Info_055;
- private TW_INFO Info_056;
- private TW_INFO Info_057;
- private TW_INFO Info_058;
- private TW_INFO Info_059;
- private TW_INFO Info_060;
- private TW_INFO Info_061;
- private TW_INFO Info_062;
- private TW_INFO Info_063;
- private TW_INFO Info_064;
- private TW_INFO Info_065;
- private TW_INFO Info_066;
- private TW_INFO Info_067;
- private TW_INFO Info_068;
- private TW_INFO Info_069;
- private TW_INFO Info_070;
- private TW_INFO Info_071;
- private TW_INFO Info_072;
- private TW_INFO Info_073;
- private TW_INFO Info_074;
- private TW_INFO Info_075;
- private TW_INFO Info_076;
- private TW_INFO Info_077;
- private TW_INFO Info_078;
- private TW_INFO Info_079;
- private TW_INFO Info_080;
- private TW_INFO Info_081;
- private TW_INFO Info_082;
- private TW_INFO Info_083;
- private TW_INFO Info_084;
- private TW_INFO Info_085;
- private TW_INFO Info_086;
- private TW_INFO Info_087;
- private TW_INFO Info_088;
- private TW_INFO Info_089;
- private TW_INFO Info_090;
- private TW_INFO Info_091;
- private TW_INFO Info_092;
- private TW_INFO Info_093;
- private TW_INFO Info_094;
- private TW_INFO Info_095;
- private TW_INFO Info_096;
- private TW_INFO Info_097;
- private TW_INFO Info_098;
- private TW_INFO Info_099;
-
- // 200 seems overkill for anyone to request
- // at once so I cut it down in half
-
- //private TW_INFO Info_100;
- //private TW_INFO Info_101;
- //private TW_INFO Info_102;
- //private TW_INFO Info_103;
- //private TW_INFO Info_104;
- //private TW_INFO Info_105;
- //private TW_INFO Info_106;
- //private TW_INFO Info_107;
- //private TW_INFO Info_108;
- //private TW_INFO Info_109;
- //private TW_INFO Info_110;
- //private TW_INFO Info_111;
- //private TW_INFO Info_112;
- //private TW_INFO Info_113;
- //private TW_INFO Info_114;
- //private TW_INFO Info_115;
- //private TW_INFO Info_116;
- //private TW_INFO Info_117;
- //private TW_INFO Info_118;
- //private TW_INFO Info_119;
- //private TW_INFO Info_120;
- //private TW_INFO Info_121;
- //private TW_INFO Info_122;
- //private TW_INFO Info_123;
- //private TW_INFO Info_124;
- //private TW_INFO Info_125;
- //private TW_INFO Info_126;
- //private TW_INFO Info_127;
- //private TW_INFO Info_128;
- //private TW_INFO Info_129;
- //private TW_INFO Info_130;
- //private TW_INFO Info_131;
- //private TW_INFO Info_132;
- //private TW_INFO Info_133;
- //private TW_INFO Info_134;
- //private TW_INFO Info_135;
- //private TW_INFO Info_136;
- //private TW_INFO Info_137;
- //private TW_INFO Info_138;
- //private TW_INFO Info_139;
- //private TW_INFO Info_140;
- //private TW_INFO Info_141;
- //private TW_INFO Info_142;
- //private TW_INFO Info_143;
- //private TW_INFO Info_144;
- //private TW_INFO Info_145;
- //private TW_INFO Info_146;
- //private TW_INFO Info_147;
- //private TW_INFO Info_148;
- //private TW_INFO Info_149;
- //private TW_INFO Info_150;
- //private TW_INFO Info_151;
- //private TW_INFO Info_152;
- //private TW_INFO Info_153;
- //private TW_INFO Info_154;
- //private TW_INFO Info_155;
- //private TW_INFO Info_156;
- //private TW_INFO Info_157;
- //private TW_INFO Info_158;
- //private TW_INFO Info_159;
- //private TW_INFO Info_160;
- //private TW_INFO Info_161;
- //private TW_INFO Info_162;
- //private TW_INFO Info_163;
- //private TW_INFO Info_164;
- //private TW_INFO Info_165;
- //private TW_INFO Info_166;
- //private TW_INFO Info_167;
- //private TW_INFO Info_168;
- //private TW_INFO Info_169;
- //private TW_INFO Info_170;
- //private TW_INFO Info_171;
- //private TW_INFO Info_172;
- //private TW_INFO Info_173;
- //private TW_INFO Info_174;
- //private TW_INFO Info_175;
- //private TW_INFO Info_176;
- //private TW_INFO Info_177;
- //private TW_INFO Info_178;
- //private TW_INFO Info_179;
- //private TW_INFO Info_180;
- //private TW_INFO Info_181;
- //private TW_INFO Info_182;
- //private TW_INFO Info_183;
- //private TW_INFO Info_184;
- //private TW_INFO Info_185;
- //private TW_INFO Info_186;
- //private TW_INFO Info_187;
- //private TW_INFO Info_188;
- //private TW_INFO Info_189;
- //private TW_INFO Info_190;
- //private TW_INFO Info_191;
- //private TW_INFO Info_192;
- //private TW_INFO Info_193;
- //private TW_INFO Info_194;
- //private TW_INFO Info_195;
- //private TW_INFO Info_196;
- //private TW_INFO Info_197;
- //private TW_INFO Info_198;
- //private TW_INFO Info_199;
-
- public void Get(int a_uIndex, ref TW_INFO a_twinfo)
- {
- switch (a_uIndex)
- {
- default: return;
- case 0: a_twinfo = Info_000; return;
- case 1: a_twinfo = Info_001; return;
- case 2: a_twinfo = Info_002; return;
- case 3: a_twinfo = Info_003; return;
- case 4: a_twinfo = Info_004; return;
- case 5: a_twinfo = Info_005; return;
- case 6: a_twinfo = Info_006; return;
- case 7: a_twinfo = Info_007; return;
- case 8: a_twinfo = Info_008; return;
- case 9: a_twinfo = Info_009; return;
- case 10: a_twinfo = Info_010; return;
- case 11: a_twinfo = Info_011; return;
- case 12: a_twinfo = Info_012; return;
- case 13: a_twinfo = Info_013; return;
- case 14: a_twinfo = Info_014; return;
- case 15: a_twinfo = Info_015; return;
- case 16: a_twinfo = Info_016; return;
- case 17: a_twinfo = Info_017; return;
- case 18: a_twinfo = Info_018; return;
- case 19: a_twinfo = Info_019; return;
- case 20: a_twinfo = Info_020; return;
- case 21: a_twinfo = Info_021; return;
- case 22: a_twinfo = Info_022; return;
- case 23: a_twinfo = Info_023; return;
- case 24: a_twinfo = Info_024; return;
- case 25: a_twinfo = Info_025; return;
- case 26: a_twinfo = Info_026; return;
- case 27: a_twinfo = Info_027; return;
- case 28: a_twinfo = Info_028; return;
- case 29: a_twinfo = Info_029; return;
- case 30: a_twinfo = Info_030; return;
- case 31: a_twinfo = Info_031; return;
- case 32: a_twinfo = Info_032; return;
- case 33: a_twinfo = Info_033; return;
- case 34: a_twinfo = Info_034; return;
- case 35: a_twinfo = Info_035; return;
- case 36: a_twinfo = Info_036; return;
- case 37: a_twinfo = Info_037; return;
- case 38: a_twinfo = Info_038; return;
- case 39: a_twinfo = Info_039; return;
- case 40: a_twinfo = Info_040; return;
- case 41: a_twinfo = Info_041; return;
- case 42: a_twinfo = Info_042; return;
- case 43: a_twinfo = Info_043; return;
- case 44: a_twinfo = Info_044; return;
- case 45: a_twinfo = Info_045; return;
- case 46: a_twinfo = Info_046; return;
- case 47: a_twinfo = Info_047; return;
- case 48: a_twinfo = Info_048; return;
- case 49: a_twinfo = Info_049; return;
- case 50: a_twinfo = Info_050; return;
- case 51: a_twinfo = Info_051; return;
- case 52: a_twinfo = Info_052; return;
- case 53: a_twinfo = Info_053; return;
- case 54: a_twinfo = Info_054; return;
- case 55: a_twinfo = Info_055; return;
- case 56: a_twinfo = Info_056; return;
- case 57: a_twinfo = Info_057; return;
- case 58: a_twinfo = Info_058; return;
- case 59: a_twinfo = Info_059; return;
- case 60: a_twinfo = Info_060; return;
- case 61: a_twinfo = Info_061; return;
- case 62: a_twinfo = Info_062; return;
- case 63: a_twinfo = Info_063; return;
- case 64: a_twinfo = Info_064; return;
- case 65: a_twinfo = Info_065; return;
- case 66: a_twinfo = Info_066; return;
- case 67: a_twinfo = Info_067; return;
- case 68: a_twinfo = Info_068; return;
- case 69: a_twinfo = Info_069; return;
- case 70: a_twinfo = Info_070; return;
- case 71: a_twinfo = Info_071; return;
- case 72: a_twinfo = Info_072; return;
- case 73: a_twinfo = Info_073; return;
- case 74: a_twinfo = Info_074; return;
- case 75: a_twinfo = Info_075; return;
- case 76: a_twinfo = Info_076; return;
- case 77: a_twinfo = Info_077; return;
- case 78: a_twinfo = Info_078; return;
- case 79: a_twinfo = Info_079; return;
- case 80: a_twinfo = Info_080; return;
- case 81: a_twinfo = Info_081; return;
- case 82: a_twinfo = Info_082; return;
- case 83: a_twinfo = Info_083; return;
- case 84: a_twinfo = Info_084; return;
- case 85: a_twinfo = Info_085; return;
- case 86: a_twinfo = Info_086; return;
- case 87: a_twinfo = Info_087; return;
- case 88: a_twinfo = Info_088; return;
- case 89: a_twinfo = Info_089; return;
- case 90: a_twinfo = Info_090; return;
- case 91: a_twinfo = Info_091; return;
- case 92: a_twinfo = Info_092; return;
- case 93: a_twinfo = Info_093; return;
- case 94: a_twinfo = Info_094; return;
- case 95: a_twinfo = Info_095; return;
- case 96: a_twinfo = Info_096; return;
- case 97: a_twinfo = Info_097; return;
- case 98: a_twinfo = Info_098; return;
- case 99: a_twinfo = Info_099; return;
- //case 100: a_twinfo = Info_100; return;
- //case 101: a_twinfo = Info_101; return;
- //case 102: a_twinfo = Info_102; return;
- //case 103: a_twinfo = Info_103; return;
- //case 104: a_twinfo = Info_104; return;
- //case 105: a_twinfo = Info_105; return;
- //case 106: a_twinfo = Info_106; return;
- //case 107: a_twinfo = Info_107; return;
- //case 108: a_twinfo = Info_108; return;
- //case 109: a_twinfo = Info_109; return;
- //case 110: a_twinfo = Info_110; return;
- //case 111: a_twinfo = Info_111; return;
- //case 112: a_twinfo = Info_112; return;
- //case 113: a_twinfo = Info_113; return;
- //case 114: a_twinfo = Info_114; return;
- //case 115: a_twinfo = Info_115; return;
- //case 116: a_twinfo = Info_116; return;
- //case 117: a_twinfo = Info_117; return;
- //case 118: a_twinfo = Info_118; return;
- //case 119: a_twinfo = Info_119; return;
- //case 120: a_twinfo = Info_120; return;
- //case 121: a_twinfo = Info_121; return;
- //case 122: a_twinfo = Info_122; return;
- //case 123: a_twinfo = Info_123; return;
- //case 124: a_twinfo = Info_124; return;
- //case 125: a_twinfo = Info_125; return;
- //case 126: a_twinfo = Info_126; return;
- //case 127: a_twinfo = Info_127; return;
- //case 128: a_twinfo = Info_128; return;
- //case 129: a_twinfo = Info_129; return;
- //case 130: a_twinfo = Info_130; return;
- //case 131: a_twinfo = Info_131; return;
- //case 132: a_twinfo = Info_132; return;
- //case 133: a_twinfo = Info_133; return;
- //case 134: a_twinfo = Info_134; return;
- //case 135: a_twinfo = Info_135; return;
- //case 136: a_twinfo = Info_136; return;
- //case 137: a_twinfo = Info_137; return;
- //case 138: a_twinfo = Info_138; return;
- //case 139: a_twinfo = Info_139; return;
- //case 140: a_twinfo = Info_140; return;
- //case 141: a_twinfo = Info_141; return;
- //case 142: a_twinfo = Info_142; return;
- //case 143: a_twinfo = Info_143; return;
- //case 144: a_twinfo = Info_144; return;
- //case 145: a_twinfo = Info_145; return;
- //case 146: a_twinfo = Info_146; return;
- //case 147: a_twinfo = Info_147; return;
- //case 148: a_twinfo = Info_148; return;
- //case 149: a_twinfo = Info_149; return;
- //case 150: a_twinfo = Info_150; return;
- //case 151: a_twinfo = Info_151; return;
- //case 152: a_twinfo = Info_152; return;
- //case 153: a_twinfo = Info_153; return;
- //case 154: a_twinfo = Info_154; return;
- //case 155: a_twinfo = Info_155; return;
- //case 156: a_twinfo = Info_156; return;
- //case 157: a_twinfo = Info_157; return;
- //case 158: a_twinfo = Info_158; return;
- //case 159: a_twinfo = Info_159; return;
- //case 160: a_twinfo = Info_160; return;
- //case 161: a_twinfo = Info_161; return;
- //case 162: a_twinfo = Info_162; return;
- //case 163: a_twinfo = Info_163; return;
- //case 164: a_twinfo = Info_164; return;
- //case 165: a_twinfo = Info_165; return;
- //case 166: a_twinfo = Info_166; return;
- //case 167: a_twinfo = Info_167; return;
- //case 168: a_twinfo = Info_168; return;
- //case 169: a_twinfo = Info_169; return;
- //case 170: a_twinfo = Info_170; return;
- //case 171: a_twinfo = Info_171; return;
- //case 172: a_twinfo = Info_172; return;
- //case 173: a_twinfo = Info_173; return;
- //case 174: a_twinfo = Info_174; return;
- //case 175: a_twinfo = Info_175; return;
- //case 176: a_twinfo = Info_176; return;
- //case 177: a_twinfo = Info_177; return;
- //case 178: a_twinfo = Info_178; return;
- //case 179: a_twinfo = Info_179; return;
- //case 180: a_twinfo = Info_180; return;
- //case 181: a_twinfo = Info_181; return;
- //case 182: a_twinfo = Info_182; return;
- //case 183: a_twinfo = Info_183; return;
- //case 184: a_twinfo = Info_184; return;
- //case 185: a_twinfo = Info_185; return;
- //case 186: a_twinfo = Info_186; return;
- //case 187: a_twinfo = Info_187; return;
- //case 188: a_twinfo = Info_188; return;
- //case 189: a_twinfo = Info_189; return;
- //case 190: a_twinfo = Info_190; return;
- //case 191: a_twinfo = Info_191; return;
- //case 192: a_twinfo = Info_192; return;
- //case 193: a_twinfo = Info_193; return;
- //case 194: a_twinfo = Info_194; return;
- //case 195: a_twinfo = Info_195; return;
- //case 196: a_twinfo = Info_196; return;
- //case 197: a_twinfo = Info_197; return;
- //case 198: a_twinfo = Info_198; return;
- //case 199: a_twinfo = Info_199; return;
- }
- }
-
- public void Set(int a_uIndex, ref TW_INFO a_twinfo)
- {
- switch (a_uIndex)
- {
- default: return;
- case 0: Info_000 = a_twinfo; return;
- case 1: Info_001 = a_twinfo; return;
- case 2: Info_002 = a_twinfo; return;
- case 3: Info_003 = a_twinfo; return;
- case 4: Info_004 = a_twinfo; return;
- case 5: Info_005 = a_twinfo; return;
- case 6: Info_006 = a_twinfo; return;
- case 7: Info_007 = a_twinfo; return;
- case 8: Info_008 = a_twinfo; return;
- case 9: Info_009 = a_twinfo; return;
- case 10: Info_010 = a_twinfo; return;
- case 11: Info_011 = a_twinfo; return;
- case 12: Info_012 = a_twinfo; return;
- case 13: Info_013 = a_twinfo; return;
- case 14: Info_014 = a_twinfo; return;
- case 15: Info_015 = a_twinfo; return;
- case 16: Info_016 = a_twinfo; return;
- case 17: Info_017 = a_twinfo; return;
- case 18: Info_018 = a_twinfo; return;
- case 19: Info_019 = a_twinfo; return;
- case 20: Info_020 = a_twinfo; return;
- case 21: Info_021 = a_twinfo; return;
- case 22: Info_022 = a_twinfo; return;
- case 23: Info_023 = a_twinfo; return;
- case 24: Info_024 = a_twinfo; return;
- case 25: Info_025 = a_twinfo; return;
- case 26: Info_026 = a_twinfo; return;
- case 27: Info_027 = a_twinfo; return;
- case 28: Info_028 = a_twinfo; return;
- case 29: Info_029 = a_twinfo; return;
- case 30: Info_030 = a_twinfo; return;
- case 31: Info_031 = a_twinfo; return;
- case 32: Info_032 = a_twinfo; return;
- case 33: Info_033 = a_twinfo; return;
- case 34: Info_034 = a_twinfo; return;
- case 35: Info_035 = a_twinfo; return;
- case 36: Info_036 = a_twinfo; return;
- case 37: Info_037 = a_twinfo; return;
- case 38: Info_038 = a_twinfo; return;
- case 39: Info_039 = a_twinfo; return;
- case 40: Info_040 = a_twinfo; return;
- case 41: Info_041 = a_twinfo; return;
- case 42: Info_042 = a_twinfo; return;
- case 43: Info_043 = a_twinfo; return;
- case 44: Info_044 = a_twinfo; return;
- case 45: Info_045 = a_twinfo; return;
- case 46: Info_046 = a_twinfo; return;
- case 47: Info_047 = a_twinfo; return;
- case 48: Info_048 = a_twinfo; return;
- case 49: Info_049 = a_twinfo; return;
- case 50: Info_050 = a_twinfo; return;
- case 51: Info_051 = a_twinfo; return;
- case 52: Info_052 = a_twinfo; return;
- case 53: Info_053 = a_twinfo; return;
- case 54: Info_054 = a_twinfo; return;
- case 55: Info_055 = a_twinfo; return;
- case 56: Info_056 = a_twinfo; return;
- case 57: Info_057 = a_twinfo; return;
- case 58: Info_058 = a_twinfo; return;
- case 59: Info_059 = a_twinfo; return;
- case 60: Info_060 = a_twinfo; return;
- case 61: Info_061 = a_twinfo; return;
- case 62: Info_062 = a_twinfo; return;
- case 63: Info_063 = a_twinfo; return;
- case 64: Info_064 = a_twinfo; return;
- case 65: Info_065 = a_twinfo; return;
- case 66: Info_066 = a_twinfo; return;
- case 67: Info_067 = a_twinfo; return;
- case 68: Info_068 = a_twinfo; return;
- case 69: Info_069 = a_twinfo; return;
- case 70: Info_070 = a_twinfo; return;
- case 71: Info_071 = a_twinfo; return;
- case 72: Info_072 = a_twinfo; return;
- case 73: Info_073 = a_twinfo; return;
- case 74: Info_074 = a_twinfo; return;
- case 75: Info_075 = a_twinfo; return;
- case 76: Info_076 = a_twinfo; return;
- case 77: Info_077 = a_twinfo; return;
- case 78: Info_078 = a_twinfo; return;
- case 79: Info_079 = a_twinfo; return;
- case 80: Info_080 = a_twinfo; return;
- case 81: Info_081 = a_twinfo; return;
- case 82: Info_082 = a_twinfo; return;
- case 83: Info_083 = a_twinfo; return;
- case 84: Info_084 = a_twinfo; return;
- case 85: Info_085 = a_twinfo; return;
- case 86: Info_086 = a_twinfo; return;
- case 87: Info_087 = a_twinfo; return;
- case 88: Info_088 = a_twinfo; return;
- case 89: Info_089 = a_twinfo; return;
- case 90: Info_090 = a_twinfo; return;
- case 91: Info_091 = a_twinfo; return;
- case 92: Info_092 = a_twinfo; return;
- case 93: Info_093 = a_twinfo; return;
- case 94: Info_094 = a_twinfo; return;
- case 95: Info_095 = a_twinfo; return;
- case 96: Info_096 = a_twinfo; return;
- case 97: Info_097 = a_twinfo; return;
- case 98: Info_098 = a_twinfo; return;
- case 99: Info_099 = a_twinfo; return;
- //case 100: Info_100 = a_twinfo; return;
- //case 101: Info_101 = a_twinfo; return;
- //case 102: Info_102 = a_twinfo; return;
- //case 103: Info_103 = a_twinfo; return;
- //case 104: Info_104 = a_twinfo; return;
- //case 105: Info_105 = a_twinfo; return;
- //case 106: Info_106 = a_twinfo; return;
- //case 107: Info_107 = a_twinfo; return;
- //case 108: Info_108 = a_twinfo; return;
- //case 109: Info_109 = a_twinfo; return;
- //case 110: Info_110 = a_twinfo; return;
- //case 111: Info_111 = a_twinfo; return;
- //case 112: Info_112 = a_twinfo; return;
- //case 113: Info_113 = a_twinfo; return;
- //case 114: Info_114 = a_twinfo; return;
- //case 115: Info_115 = a_twinfo; return;
- //case 116: Info_116 = a_twinfo; return;
- //case 117: Info_117 = a_twinfo; return;
- //case 118: Info_118 = a_twinfo; return;
- //case 119: Info_119 = a_twinfo; return;
- //case 120: Info_120 = a_twinfo; return;
- //case 121: Info_121 = a_twinfo; return;
- //case 122: Info_122 = a_twinfo; return;
- //case 123: Info_123 = a_twinfo; return;
- //case 124: Info_124 = a_twinfo; return;
- //case 125: Info_125 = a_twinfo; return;
- //case 126: Info_126 = a_twinfo; return;
- //case 127: Info_127 = a_twinfo; return;
- //case 128: Info_128 = a_twinfo; return;
- //case 129: Info_129 = a_twinfo; return;
- //case 130: Info_130 = a_twinfo; return;
- //case 131: Info_131 = a_twinfo; return;
- //case 132: Info_132 = a_twinfo; return;
- //case 133: Info_133 = a_twinfo; return;
- //case 134: Info_134 = a_twinfo; return;
- //case 135: Info_135 = a_twinfo; return;
- //case 136: Info_136 = a_twinfo; return;
- //case 137: Info_137 = a_twinfo; return;
- //case 138: Info_138 = a_twinfo; return;
- //case 139: Info_139 = a_twinfo; return;
- //case 140: Info_140 = a_twinfo; return;
- //case 141: Info_141 = a_twinfo; return;
- //case 142: Info_142 = a_twinfo; return;
- //case 143: Info_143 = a_twinfo; return;
- //case 144: Info_144 = a_twinfo; return;
- //case 145: Info_145 = a_twinfo; return;
- //case 146: Info_146 = a_twinfo; return;
- //case 147: Info_147 = a_twinfo; return;
- //case 148: Info_148 = a_twinfo; return;
- //case 149: Info_149 = a_twinfo; return;
- //case 150: Info_150 = a_twinfo; return;
- //case 151: Info_151 = a_twinfo; return;
- //case 152: Info_152 = a_twinfo; return;
- //case 153: Info_153 = a_twinfo; return;
- //case 154: Info_154 = a_twinfo; return;
- //case 155: Info_155 = a_twinfo; return;
- //case 156: Info_156 = a_twinfo; return;
- //case 157: Info_157 = a_twinfo; return;
- //case 158: Info_158 = a_twinfo; return;
- //case 159: Info_159 = a_twinfo; return;
- //case 160: Info_160 = a_twinfo; return;
- //case 161: Info_161 = a_twinfo; return;
- //case 162: Info_162 = a_twinfo; return;
- //case 163: Info_163 = a_twinfo; return;
- //case 164: Info_164 = a_twinfo; return;
- //case 165: Info_165 = a_twinfo; return;
- //case 166: Info_166 = a_twinfo; return;
- //case 167: Info_167 = a_twinfo; return;
- //case 168: Info_168 = a_twinfo; return;
- //case 169: Info_169 = a_twinfo; return;
- //case 170: Info_170 = a_twinfo; return;
- //case 171: Info_171 = a_twinfo; return;
- //case 172: Info_172 = a_twinfo; return;
- //case 173: Info_173 = a_twinfo; return;
- //case 174: Info_174 = a_twinfo; return;
- //case 175: Info_175 = a_twinfo; return;
- //case 176: Info_176 = a_twinfo; return;
- //case 177: Info_177 = a_twinfo; return;
- //case 178: Info_178 = a_twinfo; return;
- //case 179: Info_179 = a_twinfo; return;
- //case 180: Info_180 = a_twinfo; return;
- //case 181: Info_181 = a_twinfo; return;
- //case 182: Info_182 = a_twinfo; return;
- //case 183: Info_183 = a_twinfo; return;
- //case 184: Info_184 = a_twinfo; return;
- //case 185: Info_185 = a_twinfo; return;
- //case 186: Info_186 = a_twinfo; return;
- //case 187: Info_187 = a_twinfo; return;
- //case 188: Info_188 = a_twinfo; return;
- //case 189: Info_189 = a_twinfo; return;
- //case 190: Info_190 = a_twinfo; return;
- //case 191: Info_191 = a_twinfo; return;
- //case 192: Info_192 = a_twinfo; return;
- //case 193: Info_193 = a_twinfo; return;
- //case 194: Info_194 = a_twinfo; return;
- //case 195: Info_195 = a_twinfo; return;
- //case 196: Info_196 = a_twinfo; return;
- //case 197: Info_197 = a_twinfo; return;
- //case 198: Info_198 = a_twinfo; return;
- //case 199: Info_199 = a_twinfo; return;
- }
- }
- }
-
- ///
- /// Provides information about the currently selected device.
- /// TBD -- need a 32/64 bit solution for this mess
- ///
- [SuppressMessage("Microsoft.Portability", "CA1900:ValueTypeFieldsShouldBePortable", MessageId = "ModifiedTimeDate")]
- [SuppressMessage("Microsoft.Portability", "CA1900:ValueTypeFieldsShouldBePortable", MessageId = "CreateTimeDate")]
- [StructLayout(LayoutKind.Explicit, Pack = 2)]
- public struct TW_FILESYSTEM
- {
- [FieldOffset(0)]
- public TW_STR255 InputName;
-
- [FieldOffset(256)]
- public TW_STR255 OutputName;
-
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- [FieldOffset(512)]
- public IntPtr Context;
-
- [FieldOffset(520)]
- public Int32 Recursive;
- [FieldOffset(520)]
- public UInt16 Subdirectories;
-
- [FieldOffset(524)]
- public Int32 FileType;
- [FieldOffset(524)]
- public UInt32 FileSystemType;
-
- [FieldOffset(528)]
- public UInt32 Size;
-
- [FieldOffset(532)]
- public TW_STR32 CreateTimeDate;
-
- [FieldOffset(566)]
- public TW_STR32 ModifiedTimeDate;
-
- [FieldOffset(600)]
- public UInt32 FreeSpace;
-
- [FieldOffset(604)]
- public UInt32 NewImageSize;
-
- [FieldOffset(608)]
- public UInt32 NumberOfFiles;
-
- [FieldOffset(612)]
- public UInt32 NumberOfSnippets;
-
- [FieldOffset(616)]
- public UInt32 DeviceGroupMask;
-
- [FieldOffset(620)]
- public byte Reserved;
-
- [FieldOffset(1127)] // 620 + 508 - 1
- private byte ReservedEnd;
- }
- [SuppressMessage("Microsoft.Portability", "CA1900:ValueTypeFieldsShouldBePortable", MessageId = "ModifiedTimeDate")]
- [StructLayout(LayoutKind.Explicit, Pack = 2)]
- public struct TW_FILESYSTEM_LEGACY
- {
- [FieldOffset(0)]
- public TW_STR255 InputName;
-
- [FieldOffset(256)]
- public TW_STR255 OutputName;
-
- [FieldOffset(512)]
- public UInt32 Context;
-
- [FieldOffset(516)]
- public Int32 Recursive;
- [FieldOffset(516)]
- public UInt16 Subdirectories;
-
- [FieldOffset(520)]
- public Int32 FileType;
- [FieldOffset(520)]
- public UInt32 FileSystemType;
-
- [FieldOffset(524)]
- public UInt32 Size;
-
- [FieldOffset(528)]
- public TW_STR32 CreateTimeDate;
-
- [FieldOffset(562)]
- public TW_STR32 ModifiedTimeDate;
-
- [FieldOffset(596)]
- public UInt32 FreeSpace;
-
- [FieldOffset(600)]
- public UInt32 NewImageSize;
-
- [FieldOffset(604)]
- public UInt32 NumberOfFiles;
-
- [FieldOffset(608)]
- public UInt32 NumberOfSnippets;
-
- [FieldOffset(612)]
- public UInt32 DeviceGroupMask;
-
- [FieldOffset(616)]
- public byte Reserved;
-
- [FieldOffset(1123)] // 616 + 508 - 1
- private byte ReservedEnd;
- }
-
- ///
- /// This structure is used by the application to specify a set of mapping values to be applied to grayscale data.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_GRAYRESPONSE
- {
- public TW_ELEMENT8 Response_00;
- }
-
- ///
- /// A general way to describe the version of software that is running.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
- public partial struct TW_VERSION
- {
- public ushort MajorNum;
- public ushort MinorNum;
- public TWLG Language;
- public TWCY Country;
- public TW_STR32 Info;
- }
-
- ///
- /// Provides identification information about a TWAIN entity.
- /// The use of Padding is there to allow us to use the structure
- /// with Linux 64-bit systems where the TW_INT32 and TW_UINT32
- /// types were long, and therefore 64-bits in size. This should
- /// have no impact with well-behaved systems that have these types
- /// as 32-bit, but should prevent memory corruption in all other
- /// situations...
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
- public partial struct TW_IDENTITY
- {
- public ulong Id;
- public TW_VERSION Version;
- public ushort ProtocolMajor;
- public ushort ProtocolMinor;
- public uint SupportedGroups;
- public TW_STR32 Manufacturer;
- public TW_STR32 ProductFamily;
- public TW_STR32 ProductName;
- }
- [StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
- public partial struct TW_IDENTITY_LEGACY
- {
- public uint Id;
- public TW_VERSION Version;
- public ushort ProtocolMajor;
- public ushort ProtocolMinor;
- public uint SupportedGroups;
- public TW_STR32 Manufacturer;
- public TW_STR32 ProductFamily;
- public TW_STR32 ProductName;
- private UInt64 Padding; // accounts for Id and SupportedGroups
- }
- [StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
- public struct TW_IDENTITY_LINUX64
- {
- public ulong Id;
- public TW_VERSION Version;
- public ushort ProtocolMajor;
- public ushort ProtocolMinor;
- public ulong SupportedGroups;
- public TW_STR32 Manufacturer;
- public TW_STR32 ProductFamily;
- public TW_STR32 ProductName;
- }
- [StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
- public partial struct TW_IDENTITY_MACOSX
- {
- public uint Id;
- public TW_VERSION Version;
- public ushort ProtocolMajor;
- public ushort ProtocolMinor;
- private ushort padding;
- public uint SupportedGroups;
- public TW_STR32 Manufacturer;
- public TW_STR32 ProductFamily;
- public TW_STR32 ProductName;
- }
-
- ///
- /// Describes the “real” image data, that is, the complete image being transferred between the Source and application.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public partial struct TW_IMAGEINFO
- {
- public TW_FIX32 XResolution;
- public TW_FIX32 YResolution;
- public int ImageWidth;
- public int ImageLength;
- public short SamplesPerPixel;
- public short BitsPerSample_0;
- public short BitsPerSample_1;
- public short BitsPerSample_2;
- public short BitsPerSample_3;
- public short BitsPerSample_4;
- public short BitsPerSample_5;
- public short BitsPerSample_6;
- public short BitsPerSample_7;
- public short BitsPerPixel;
- public TW_BOOL Planar;
- public TWPT PixelType;
- public TWCP Compression;
- }
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_IMAGEINFO_LINUX64
- {
- public TW_FIX32 XResolution;
- public TW_FIX32 YResolution;
- public int ImageWidth;
- public int ImageLength;
- public short SamplesPerPixel;
- public short BitsPerSample_0;
- public short BitsPerSample_1;
- public short BitsPerSample_2;
- public short BitsPerSample_3;
- public short BitsPerSample_4;
- public short BitsPerSample_5;
- public short BitsPerSample_6;
- public short BitsPerSample_7;
- public short BitsPerPixel;
- public TW_BOOL Planar;
- public TWPT PixelType;
- public TWCP Compression;
- }
-
- ///
- /// Involves information about the original size of the acquired image.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_IMAGELAYOUT
- {
- public TW_FRAME Frame;
- public uint DocumentNumber;
- public uint PageNumber;
- public uint FrameNumber;
- }
-
- ///
- /// Provides information for managing memory buffers.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_MEMORY
- {
- public uint Flags;
- public uint Length;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr TheMem;
- }
-
- ///
- /// Describes the form of the acquired data being passed from the Source to the application.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public partial struct TW_IMAGEMEMXFER
- {
- public ushort Compression;
- public uint BytesPerRow;
- public uint Columns;
- public uint Rows;
- public uint XOffset;
- public uint YOffset;
- public uint BytesWritten;
- public TW_MEMORY Memory;
- }
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public partial struct TW_IMAGEMEMXFER_LINUX64
- {
- public ushort Compression;
- public UInt64 BytesPerRow;
- public UInt64 Columns;
- public UInt64 Rows;
- public UInt64 XOffset;
- public UInt64 YOffset;
- public UInt64 BytesWritten;
- public UInt64 MemoryFlags;
- public UInt64 MemoryLength;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr MemoryTheMem;
- }
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public partial struct TW_IMAGEMEMXFER_MACOSX
- {
- public uint Compression;
- public uint BytesPerRow;
- public uint Columns;
- public uint Rows;
- public uint XOffset;
- public uint YOffset;
- public uint BytesWritten;
- public TW_MEMORY Memory;
- }
-
- ///
- /// Describes the information necessary to transfer a JPEG-compressed image.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_JPEGCOMPRESSION
- {
- public ushort ColorSpace;
- public uint SubSampling;
- public ushort NumComponents;
- public ushort QuantMap_0;
- public ushort QuantMap_1;
- public ushort QuantMap_2;
- public ushort QuantMap_3;
- public TW_MEMORY QuantTable_0;
- public TW_MEMORY QuantTable_1;
- public TW_MEMORY QuantTable_2;
- public TW_MEMORY QuantTable_3;
- public ushort HuffmanMap_0;
- public ushort HuffmanMap_1;
- public ushort HuffmanMap_2;
- public ushort HuffmanMap_3;
- public TW_MEMORY HuffmanDC_0;
- public TW_MEMORY HuffmanDC_1;
- public TW_MEMORY HuffmanAC_0;
- public TW_MEMORY HuffmanAC_2;
- }
-
- ///
- /// Collects scanning metrics after returning to state 4
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_METRICS
- {
- public uint SizeOf;
- public uint ImageCount;
- public uint SheetCount;
- }
-
- ///
- /// Stores a single value (item) which describes a capability.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_ONEVALUE
- {
- public TWTY ItemType;
- // public uint Item;
- }
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- public struct TW_ONEVALUE_MACOSX
- {
- public uint ItemType;
- // public uint Item;
- }
-
- ///
- /// This structure holds the color palette information.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_PALETTE8
- {
- public ushort Flags;
- public ushort Length;
- public TW_ELEMENT8 Colors_000;
- }
-
- ///
- /// Used to bypass the TWAIN protocol when communicating with a device.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_PASSTHRU
- {
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr pCommand;
- public uint CommandBytes;
- public int Direction;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr pData;
- public uint DataBytes;
- public uint DataBytesXfered;
- }
-
- ///
- /// This structure tells the application how many more complete transfers the Source currently has available.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_PENDINGXFERS
- {
- public static TW_PENDINGXFERS DONTCARE()
- {
- return new TW_PENDINGXFERS { Count = -1 };
- }
-
- public short Count;
- public uint EOJ;
- }
-
- ///
- /// Stores a range of individual values describing a capability.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_RANGE
- {
- public TWTY ItemType;
- public uint MinValue;
- public uint MaxValue;
- public uint StepSize;
- public uint DefaultValue;
- public uint CurrentValue;
- }
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_RANGE_LINUX64
- {
- public TWTY ItemType;
- public ulong MinValue;
- public ulong MaxValue;
- public ulong StepSize;
- public ulong DefaultValue;
- public ulong CurrentValue;
- }
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- public struct TW_RANGE_MACOSX
- {
- public uint ItemType;
- public uint MinValue;
- public uint MaxValue;
- public uint StepSize;
- public uint DefaultValue;
- public uint CurrentValue;
- }
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_RANGE_FIX32
- {
- public TWTY ItemType;
- public TW_FIX32 MinValue;
- public TW_FIX32 MaxValue;
- public TW_FIX32 StepSize;
- public TW_FIX32 DefaultValue;
- public TW_FIX32 CurrentValue;
- }
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- public struct TW_RANGE_FIX32_MACOSX
- {
- public uint ItemType;
- public TW_FIX32 MinValue;
- public TW_FIX32 MaxValue;
- public TW_FIX32 StepSize;
- public TW_FIX32 DefaultValue;
- public TW_FIX32 CurrentValue;
- }
-
- ///
- /// This structure is used by the application to specify a set of mapping values to be applied to RGB color data.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_RGBRESPONSE
- {
- public TW_ELEMENT8 Response_00;
- }
-
- ///
- /// Describes the file format and file specification information for a transfer through a disk file.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct TW_SETUPFILEXFER
- {
- public TW_STR255 FileName;
- public TWFF Format;
- public short VRefNum;
- }
-
- ///
- /// Provides the application information about the Source’s requirements and preferences regarding allocation of transfer buffer(s).
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public partial struct TW_SETUPMEMXFER
- {
- public uint MinBufSize;
- public uint MaxBufSize;
- public uint Preferred;
- }
-
- ///
- /// Describes the status of a source.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public partial struct TW_STATUS
- {
- public TWCC ConditionCode;
- public ushort Data;
- }
-
- ///
- /// Translates the contents of Status into a localized UTF8string.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public partial struct TW_STATUSUTF8
- {
- public TW_STATUS Status;
- public uint Size;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr UTF8string;
- }
-
- ///
- /// Passthru for TWAIN Direct tasks.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
- public struct TW_TWAINDIRECT
- {
- public uint SizeOf;
- public ushort CommunicationManager;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr Send;
- public uint SendSize;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr Receive;
- public uint ReceiveSize;
- }
-
- ///
- /// This structure is used to handle the user interface coordination between an application and a Source.
- ///
- [StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
- public struct TW_USERINTERFACE
- {
- public ushort ShowUI;
- public ushort ModalUI;
- [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
- public IntPtr hParent;
- }
-
- #endregion
-
-
- ///////////////////////////////////////////////////////////////////////////////
- // Generic Constants...
- ///////////////////////////////////////////////////////////////////////////////
- #region Generic Constants...
-
- ///
- /// Container Types...
- ///
- public enum TWON : ushort
- {
- ARRAY = 3,
- ENUMERATION = 4,
- ONEVALUE = 5,
- RANGE = 6,
-
- ICONID = 962,
- DSMID = 461,
- DSMCODEID = 63,
-
- DONTCARE = 0xffff
- }
-
- /////
- ///// Don't care values...
- /////
- //public const byte TWON_DONTCARE8 = 0xff;
- //public const ushort TWON_DONTCARE16 = 0xff;
- //public const uint TWON_DONTCARE32 = 0xffffffff;
-
- ///
- /// Flags used in TW_MEMORY structure.
- ///
- [Flags]
- public enum TWMF : ushort
- {
- APPOWNS = 0x0001,
- DSMOWNS = 0x0002,
- DSOWNS = 0x0004,
- POINTER = 0x0008,
- HANDLE = 0x0010
- }
-
- ///
- /// Type values...
- ///
- public enum TWTY : ushort
- {
- Invalid = 0xffff,
-
- INT8 = 0x0000,
- INT16 = 0x0001,
- INT32 = 0x0002,
-
- UINT8 = 0x0003,
- UINT16 = 0x0004,
- UINT32 = 0x0005,
-
- BOOL = 0x0006,
-
- FIX32 = 0x0007,
-
- FRAME = 0x0008,
-
- STR32 = 0x0009,
- STR64 = 0x000a,
- STR128 = 0x000b,
- STR255 = 0x000c,
- HANDLE = 0x000f
- }
-
- #endregion
-
-
- ///////////////////////////////////////////////////////////////////////////////
- // Capability Constants...
- ///////////////////////////////////////////////////////////////////////////////
- #region Capability Constants...
-
- ///
- /// CAP_ALARMS values
- ///
- public enum TWAL : ushort
- {
- ALARM = 0,
- FEEDERERROR = 1,
- FEEDERWARNING = 2,
- BARCODE = 3,
- DOUBLEFEED = 4,
- JAM = 5,
- PATCHCODE = 6,
- POWER = 7,
- SKEW = 8
- }
-
- ///
- /// ICAP_AUTOSIZE values
- ///
- public enum TWAS : ushort
- {
- NONE = 0,
- AUTO = 1,
- CURRENT = 2
- }
-
- ///
- /// TWEI_BARCODEROTATION values
- ///
- public enum TWBCOR : ushort
- {
- ROT0 = 0,
- ROT90 = 1,
- ROT180 = 2,
- ROT270 = 3,
- ROTX = 4
- }
-
- ///
- /// ICAP_BARCODESEARCHMODE values
- ///
- public enum TWBD : ushort
- {
- HORZ = 0,
- VERT = 1,
- HORZVERT = 2,
- VERTHORZ = 3
- }
-
- ///
- /// ICAP_BITORDER values
- ///
- public enum TWBO : ushort
- {
- LSBFIRST = 0,
- MSBFIRST = 1
- }
-
- ///
- /// ICAP_AUTODISCARDBLANKPAGES values
- ///
- public enum TWBP : short
- {
- DISABLE = -2,
- AUTO = -1
- }
-
- ///
- /// ICAP_BITDEPTHREDUCTION values
- ///
- public enum TWBR : ushort
- {
- THRESHOLD = 0,
- HALFTONE = 1,
- CUSTHALFTONE = 2,
- DIFFUSION = 3,
- DYNAMICTHRESHOLD = 4
- }
-
- ///
- /// ICAP_SUPPORTEDBARCODETYPES and TWEI_BARCODETYPE values
- ///
- public enum TWBT : ushort
- {
- X3OF9 = 0, // 3OF9 in H
- X2OF5INTERLEAVED = 1, // 2OF5INTERLEAVED in H
- X2OF5NONINTERLEAVED = 2, // 2OF5NONINTERLEAVED in H
- CODE93 = 3,
- CODE128 = 4,
- UCC128 = 5,
- CODABAR = 6,
- UPCA = 7,
- UPCE = 8,
- EAN8 = 9,
- EAN13 = 10,
- POSTNET = 11,
- PDF417 = 12,
- X2OF5INDUSTRIAL = 13, // 2OF5INDUSTRIAL in H
- X2OF5MATRIX = 14, // 2OF5MATRIX in H
- X2OF5DATALOGIC = 15, // 2OF5DATALOGIC in H
- X2OF5IATA = 16, // 2OF5IATA in H
- X3OF9FULLASCII = 17, // 3OF9FULLASCII in H
- CODABARWITHSTARTSTOP = 18,
- MAXICODE = 19,
- QRCODE = 20
- }
-
- ///
- /// ICAP_COMPRESSION values
- ///
- public enum TWCP : ushort
- {
- NONE = 0,
- PACKBITS = 1,
- GROUP31D = 2,
- GROUP31DEOL = 3,
- GROUP32D = 4,
- GROUP4 = 5,
- JPEG = 6,
- LZW = 7,
- JBIG = 8,
- PNG = 9,
- RLE4 = 10,
- RLE8 = 11,
- BITFIELDS = 12,
- ZIP = 13,
- JPEG2000 = 14
- }
-
- ///
- /// CAP_CAMERASIDE and TWEI_PAGESIDE values
- ///
- public enum TWCS : ushort
- {
- BOTH = 0,
- TOP = 1,
- BOTTOM = 2
- }
-
- ///
- /// CAP_CLEARBUFFERS values
- ///
- public enum TWCB : ushort
- {
- AUTO = 0,
- CLEAR = 1,
- NOCLEAR = 2
- }
-
- ///
- /// CAP_DEVICEEVENT values
- ///
- public enum TWDE : ushort
- {
- CUSTOMEVENTS = 0x8000,
- CHECKAUTOMATICCAPTURE = 0,
- CHECKBATTERY = 1,
- CHECKDEVICEONLINE = 2,
- CHECKFLASH = 3,
- CHECKPOWERSUPPLY = 4,
- CHECKRESOLUTION = 5,
- DEVICEADDED = 6,
- DEVICEOFFLINE = 7,
- DEVICEREADY = 8,
- DEVICEREMOVED = 9,
- IMAGECAPTURED = 10,
- IMAGEDELETED = 11,
- PAPERDOUBLEFEED = 12,
- PAPERJAM = 13,
- LAMPFAILURE = 14,
- POWERSAVE = 15,
- POWERSAVENOTIFY = 16
- }
-
- ///
- /// TW_PASSTHRU.Direction values
- ///
- public enum TWDR : ushort
- {
- GET = 1,
- SET = 2
- }
-
- ///
- /// TWEI_DESKEWSTATUS values
- ///
- public enum TWDSK : ushort
- {
- SUCCESS = 0,
- REPORTONLY = 1,
- FAIL = 2,
- DISABLED = 3
- }
-
- ///
- /// CAP_DUPLEX values
- ///
- public enum TWDX : ushort
- {
- NONE = 0,
- X1PASSDUPLEX = 1, // 1PASSDUPLEX in H
- X2PASSDUPLEX = 2 // 2PASSDUPLEX in H
- }
-
- ///
- /// CAP_FEEDERALIGNMENT values
- ///
- public enum TWFA : ushort
- {
- NONE = 0,
- LEFT = 1,
- CENTER = 2,
- RIGHT = 3
- }
-
- ///
- /// ICAP_FEEDERTYPE values
- ///
- public enum TWFE : ushort
- {
- GENERAL = 0,
- PHOTO = 1
- }
-
- ///
- /// ICAP_IMAGEFILEFORMAT values
- ///
- public enum TWFF : ushort
- {
- TIFF = 0,
- PICT = 1,
- BMP = 2,
- XBM = 3,
- JFIF = 4,
- FPX = 5,
- TIFFMULTI = 6,
- PNG = 7,
- SPIFF = 8,
- EXIF = 9,
- PDF = 10,
- JP2 = 11,
- JPX = 13,
- DEJAVU = 14,
- PDFA = 15,
- PDFA2 = 16,
- PDFRASTER = 17,
-
- // KODAK
- RAW = 0x8001,
- RAWBMP = 0x8002
- }
-
- ///
- /// ICAP_FLASHUSED2 values
- ///
- public enum TWFL : ushort
- {
- NONE = 0,
- OFF = 1,
- ON = 2,
- AUTO = 3,
- REDEYE = 4
- }
-
- ///
- /// CAP_FEEDERORDER values
- ///
- public enum TWFO : ushort
- {
- FIRSTPAGEFIRST = 0,
- LASTPAGEFIRST = 1
- }
-
- ///
- /// CAP_FEEDERPOCKET values
- ///
- public enum TWFP : ushort
- {
- POCKETERROR = 0,
- POCKET1 = 1,
- POCKET2 = 2,
- POCKET3 = 3,
- POCKET4 = 4,
- POCKET5 = 5,
- POCKET6 = 6,
- POCKET7 = 7,
- POCKET8 = 8,
- POCKET9 = 9,
- POCKET10 = 10,
- POCKET11 = 11,
- POCKET12 = 12,
- POCKET13 = 13,
- POCKET14 = 14,
- POCKET15 = 15,
- POCKET16 = 16
- }
-
- ///
- /// ICAP_FLIPROTATION values
- ///
- public enum TWFR : ushort
- {
- BOOK = 0,
- FANFOLD = 1
- }
-
- ///
- /// ICAP_FILTER values
- ///
- public enum TWFT : ushort
- {
- RED = 0,
- GREEN = 1,
- BLUE = 2,
- NONE = 3,
- WHITE = 4,
- CYAN = 5,
- MAGENTA = 6,
- YELLOW = 7,
- BLACK = 8
- }
-
- ///
- /// TW_FILESYSTEM.FileType values
- ///
- public enum TWFY : ushort
- {
- CAMERA = 0,
- CAMERATOP = 1,
- CAMERABOTTOM = 2,
- CAMERAPREVIEW = 3,
- DOMAIN = 4,
- HOST = 5,
- DIRECTORY = 6,
- IMAGE = 7,
- UNKNOWN = 8
- }
-
- ///
- /// CAP_IAFIELD*_LEVEL values
- ///
- public enum TWIA : ushort
- {
- UNUSED = 0,
- FIXED = 1,
- LEVEL1 = 2,
- LEVEL2 = 3,
- LEVEL3 = 4,
- LEVEL4 = 5
- }
-
- ///
- /// ICAP_ICCPROFILE values
- ///
- public enum TWIC : ushort
- {
- NONE = 0,
- LINK = 1,
- EMBED = 2
- }
-
- ///
- /// ICAP_IMAGEFILTER values
- ///
- public enum TWIF : ushort
- {
- NONE = 0,
- AUTO = 1,
- LOWPASS = 2,
- BANDPASS = 3,
- HIGHPASS = 4,
- TEXT = BANDPASS,
- FINELINE = HIGHPASS
- }
-
- ///
- /// ICAP_IMAGEMERGE values
- ///
- public enum TWIM : ushort
- {
- NONE = 0,
- FRONTONTOP = 1,
- FRONTONBOTTOM = 2,
- FRONTONLEFT = 3,
- FRONTONRIGHT = 4
- }
-
- ///
- /// CAP_JOBCONTROL values
- ///
- public enum TWJC : ushort
- {
- NONE = 0,
- JSIC = 1,
- JSIS = 2,
- JSXC = 3,
- JSXS = 4
- }
-
- ///
- /// ICAP_JPEGQUALITY values
- ///
- public enum TWJQ : short
- {
- UNKNOWN = -4,
- LOW = -3,
- MEDIUM = -2,
- HIGH = -1
- }
-
- ///
- /// ICAP_LIGHTPATH values
- ///
- public enum TWLP : ushort
- {
- REFLECTIVE = 0,
- TRANSMISSIVE = 1
- }
-
- ///
- /// ICAP_LIGHTSOURCE values
- ///
- public enum TWLS : ushort
- {
- RED = 0,
- GREEN = 1,
- BLUE = 2,
- NONE = 3,
- WHITE = 4,
- UV = 5,
- IR = 6
- }
-
- ///
- /// TWEI_MAGTYPE values
- ///
- public enum TWMD : ushort
- {
- MICR = 0,
- RAW = 1,
- INVALID = 2
- }
-
- ///
- /// ICAP_NOISEFILTER values
- ///
- public enum TWNF : ushort
- {
- NONE = 0,
- AUTO = 1,
- LONEPIXEL = 2,
- MAJORITYRULE = 3
- }
-
- ///
- /// ICAP_ORIENTATION values
- ///
- public enum TWOR : ushort
- {
- ROT0 = 0,
- ROT90 = 1,
- ROT180 = 2,
- ROT270 = 3,
- PORTRAIT = ROT0,
- LANDSCAPE = ROT270,
- AUTO = 4,
- AUTOTEXT = 5,
- AUTOPICTURE = 6
- }
-
- ///
- /// ICAP_OVERSCAN values
- ///
- public enum TWOV : ushort
- {
- NONE = 0,
- AUTO = 1,
- TOPBOTTOM = 2,
- LEFTRIGHT = 3,
- ALL = 4
- }
-
- ///
- /// Palette types for TW_PALETTE8
- ///
- public enum TWPA : ushort
- {
- RGB = 0,
- GRAY = 1,
- CMY = 2
- }
-
- ///
- /// ICAP_PLANARCHUNKY values
- ///
- public enum TWPC : ushort
- {
- CHUNKY = 0,
- PLANAR = 1
- }
-
- ///
- /// TWEI_PATCHCODE values
- ///
- public enum TWPCH : ushort
- {
- PATCH1 = 0,
- PATCH2 = 1,
- PATCH3 = 2,
- PATCH4 = 3,
- PATCH6 = 4,
- PATCHT = 5
- }
-
- ///
- /// ICAP_PIXELFLAVOR values
- ///
- public enum TWPF : ushort
- {
- CHOCOLATE = 0,
- VANILLA = 1
- }
-
- ///
- /// CAP_PRINTERMODE values
- ///
- public enum TWPM : ushort
- {
- SINGLESTRING = 0,
- MULTISTRING = 1,
- COMPOUNDSTRING = 2,
- IMAGEADDRESSSTRING = 3
- }
-
- ///
- /// CAP_PRINTER values
- ///
- public enum TWPR : ushort
- {
- IMPRINTERTOPBEFORE = 0,
- IMPRINTERTOPAFTER = 1,
- IMPRINTERBOTTOMBEFORE = 2,
- IMPRINTERBOTTOMAFTER = 3,
- ENDORSERTOPBEFORE = 4,
- ENDORSERTOPAFTER = 5,
- ENDORSERBOTTOMBEFORE = 6,
- ENDORSERBOTTOMAFTER = 7
- }
-
- ///
- /// CAP_PRINTERFONTSTYLE Added 2.3 (TWPF in H)
- ///
- public enum TWPFS : ushort
- {
- NORMAL = 0,
- BOLD = 1,
- ITALIC = 2,
- LARGESIZE = 3,
- SMALLSIZE = 4
- }
-
- ///
- /// CAP_PRINTERINDEXTRIGGER Added 2.3
- ///
- public enum TWCT : ushort
- {
- PAGE = 0,
- PATCH1 = 1,
- PATCH2 = 2,
- PATCH3 = 3,
- PATCH4 = 4,
- PATCHT = 5,
- PATCH6 = 6
- }
-
- ///
- /// CAP_POWERSUPPLY values
- ///
- public enum TWPS : ushort
- {
- EXTERNAL = 0,
- BATTERY = 1
- }
-
- ///
- /// ICAP_PIXELTYPE values (PT_ means Pixel Type)
- ///
- public enum TWPT : ushort
- {
- BW = 0,
- GRAY = 1,
- RGB = 2,
- PALETTE = 3,
- CMY = 4,
- CMYK = 5,
- YUV = 6,
- YUVK = 7,
- CIEXYZ = 8,
- LAB = 9,
- SRGB = 10,
- SCRGB = 11,
- INFRARED = 16
- }
-
- ///
- /// CAP_SEGMENTED values
- ///
- public enum TWSG : ushort
- {
- NONE = 0,
- AUTO = 1,
- MANUAL = 2
- }
-
- ///
- /// ICAP_FILMTYPE values
- ///
- public enum TWFM : ushort
- {
- POSITIVE = 0,
- NEGATIVE = 1
- }
-
- ///
- /// CAP_DOUBLEFEEDDETECTION values
- ///
- public enum TWDF : ushort
- {
- ULTRASONIC = 0,
- BYLENGTH = 1,
- INFRARED = 2
- }
-
- ///
- /// CAP_DOUBLEFEEDDETECTIONSENSITIVITY values
- ///
- public enum TWUS : ushort
- {
- LOW = 0,
- MEDIUM = 1,
- HIGH = 2
- }
-
- ///
- /// CAP_DOUBLEFEEDDETECTIONRESPONSE values
- ///
- public enum TWDP : ushort
- {
- STOP = 0,
- STOPANDWAIT = 1,
- SOUND = 2,
- DONOTIMPRINT = 3
- }
-
- ///
- /// ICAP_MIRROR values
- ///
- public enum TWMR : ushort
- {
- NONE = 0,
- VERTICAL = 1,
- HORIZONTAL = 2
- }
-
- ///
- /// ICAP_JPEGSUBSAMPLING values
- ///
- public enum TWJS : ushort
- {
- X444YCBCR = 0, // 444YCBCR in H
- X444RGB = 1, // 444RGB in H
- X422 = 2, // 422 in H
- X421 = 3, // 421 in H
- X411 = 4, // 411 in H
- X420 = 5, // 420 in H
- X410 = 6, // 410 in H
- X311 = 7 // 311 in H
- }
-
- ///
- /// CAP_PAPERHANDLING values
- ///
- public enum TWPH : ushort
- {
- NORMAL = 0,
- FRAGILE = 1,
- THICK = 2,
- TRIFOLD = 3,
- PHOTOGRAPH = 4
- }
-
- ///
- /// CAP_INDICATORSMODE values
- ///
- public enum TWCI : ushort
- {
- INFO = 0,
- WARNING = 1,
- ERROR = 2,
- WARMUP = 3
- }
-
- ///
- /// ICAP_SUPPORTEDSIZES values (SS_ means Supported Sizes)
- ///
- public enum TWSS : ushort
- {
- NONE = 0,
- A4 = 1,
- JISB5 = 2,
- USLETTER = 3,
- USLEGAL = 4,
- A5 = 5,
- ISOB4 = 6,
- ISOB6 = 7,
- USLEDGER = 9,
- USEXECUTIVE = 10,
- A3 = 11,
- ISOB3 = 12,
- A6 = 13,
- C4 = 14,
- C5 = 15,
- C6 = 16,
- X4A0 = 17, // 4A0 in H
- X2A0 = 18, // 2A0 in H
- A0 = 19,
- A1 = 20,
- A2 = 21,
- A7 = 22,
- A8 = 23,
- A9 = 24,
- A10 = 25,
- ISOB0 = 26,
- ISOB1 = 27,
- ISOB2 = 28,
- ISOB5 = 29,
- ISOB7 = 30,
- ISOB8 = 31,
- ISOB9 = 32,
- ISOB10 = 33,
- JISB0 = 34,
- JISB1 = 35,
- JISB2 = 36,
- JISB3 = 37,
- JISB4 = 38,
- JISB6 = 39,
- JISB7 = 40,
- JISB8 = 41,
- JISB9 = 42,
- JISB10 = 43,
- C0 = 44,
- C1 = 45,
- C2 = 46,
- C3 = 47,
- C7 = 48,
- C8 = 49,
- C9 = 50,
- C10 = 51,
- USSTATEMENT = 52,
- BUSINESSCARD = 53,
- MAXSIZE = 54
- }
-
- ///
- /// ICAP_XFERMECH values (SX_ means Setup XFer)
- ///
- public enum TWSX : ushort
- {
- NATIVE = 0,
- FILE = 1,
- MEMORY = 2,
- MEMFILE = 4
- }
-
- ///
- /// ICAP_UNITS values (UN_ means UNits)
- ///
- public enum TWUN : ushort
- {
- INCHES = 0,
- CENTIMETERS = 1,
- PICAS = 2,
- POINTS = 3,
- TWIPS = 4,
- PIXELS = 5,
- MILLIMETERS = 6
- }
-
- ///
- /// Country Constants
- ///
- public enum TWCY : ushort
- {
- AFGHANISTAN = 1001,
- ALGERIA = 213,
- AMERICANSAMOA = 684,
- ANDORRA = 33,
- ANGOLA = 1002,
- ANGUILLA = 8090,
- ANTIGUA = 8091,
- ARGENTINA = 54,
- ARUBA = 297,
- ASCENSIONI = 247,
- AUSTRALIA = 61,
- AUSTRIA = 43,
- BAHAMAS = 8092,
- BAHRAIN = 973,
- BANGLADESH = 880,
- BARBADOS = 8093,
- BELGIUM = 32,
- BELIZE = 501,
- BENIN = 229,
- BERMUDA = 8094,
- BHUTAN = 1003,
- BOLIVIA = 591,
- BOTSWANA = 267,
- BRITAIN = 6,
- BRITVIRGINIS = 8095,
- BRAZIL = 55,
- BRUNEI = 673,
- BULGARIA = 359,
- BURKINAFASO = 1004,
- BURMA = 1005,
- BURUNDI = 1006,
- CAMAROON = 237,
- CANADA = 2,
- CAPEVERDEIS = 238,
- CAYMANIS = 8096,
- CENTRALAFREP = 1007,
- CHAD = 1008,
- CHILE = 56,
- CHINA = 86,
- CHRISTMASIS = 1009,
- COCOSIS = 1009,
- COLOMBIA = 57,
- COMOROS = 1010,
- CONGO = 1011,
- COOKIS = 1012,
- COSTARICA = 506,
- CUBA = 5,
- CYPRUS = 357,
- CZECHOSLOVAKIA = 42,
- DENMARK = 45,
- DJIBOUTI = 1013,
- DOMINICA = 8097,
- DOMINCANREP = 8098,
- EASTERIS = 1014,
- ECUADOR = 593,
- EGYPT = 20,
- ELSALVADOR = 503,
- EQGUINEA = 1015,
- ETHIOPIA = 251,
- FALKLANDIS = 1016,
- FAEROEIS = 298,
- FIJIISLANDS = 679,
- FINLAND = 358,
- FRANCE = 33,
- FRANTILLES = 596,
- FRGUIANA = 594,
- FRPOLYNEISA = 689,
- FUTANAIS = 1043,
- GABON = 241,
- GAMBIA = 220,
- GERMANY = 49,
- GHANA = 233,
- GIBRALTER = 350,
- GREECE = 30,
- GREENLAND = 299,
- GRENADA = 8099,
- GRENEDINES = 8015,
- GUADELOUPE = 590,
- GUAM = 671,
- GUANTANAMOBAY = 5399,
- GUATEMALA = 502,
- GUINEA = 224,
- GUINEABISSAU = 1017,
- GUYANA = 592,
- HAITI = 509,
- HONDURAS = 504,
- HONGKONG = 852,
- HUNGARY = 36,
- ICELAND = 354,
- INDIA = 91,
- INDONESIA = 62,
- IRAN = 98,
- IRAQ = 964,
- IRELAND = 353,
- ISRAEL = 972,
- ITALY = 39,
- IVORYCOAST = 225,
- JAMAICA = 8010,
- JAPAN = 81,
- JORDAN = 962,
- KENYA = 254,
- KIRIBATI = 1018,
- KOREA = 82,
- KUWAIT = 965,
- LAOS = 1019,
- LEBANON = 1020,
- LIBERIA = 231,
- LIBYA = 218,
- LIECHTENSTEIN = 41,
- LUXENBOURG = 352,
- MACAO = 853,
- MADAGASCAR = 1021,
- MALAWI = 265,
- MALAYSIA = 60,
- MALDIVES = 960,
- MALI = 1022,
- MALTA = 356,
- MARSHALLIS = 692,
- MAURITANIA = 1023,
- MAURITIUS = 230,
- MEXICO = 3,
- MICRONESIA = 691,
- MIQUELON = 508,
- MONACO = 33,
- MONGOLIA = 1024,
- MONTSERRAT = 8011,
- MOROCCO = 212,
- MOZAMBIQUE = 1025,
- NAMIBIA = 264,
- NAURU = 1026,
- NEPAL = 977,
- NETHERLANDS = 31,
- NETHANTILLES = 599,
- NEVIS = 8012,
- NEWCALEDONIA = 687,
- NEWZEALAND = 64,
- NICARAGUA = 505,
- NIGER = 227,
- NIGERIA = 234,
- NIUE = 1027,
- NORFOLKI = 1028,
- NORWAY = 47,
- OMAN = 968,
- PAKISTAN = 92,
- PALAU = 1029,
- PANAMA = 507,
- PARAGUAY = 595,
- PERU = 51,
- PHILLIPPINES = 63,
- PITCAIRNIS = 1030,
- PNEWGUINEA = 675,
- POLAND = 48,
- PORTUGAL = 351,
- QATAR = 974,
- REUNIONI = 1031,
- ROMANIA = 40,
- RWANDA = 250,
- SAIPAN = 670,
- SANMARINO = 39,
- SAOTOME = 1033,
- SAUDIARABIA = 966,
- SENEGAL = 221,
- SEYCHELLESIS = 1034,
- SIERRALEONE = 1035,
- SINGAPORE = 65,
- SOLOMONIS = 1036,
- SOMALI = 1037,
- SOUTHAFRICA = 27,
- SPAIN = 34,
- SRILANKA = 94,
- STHELENA = 1032,
- STKITTS = 8013,
- STLUCIA = 8014,
- STPIERRE = 508,
- STVINCENT = 8015,
- SUDAN = 1038,
- SURINAME = 597,
- SWAZILAND = 268,
- SWEDEN = 46,
- SWITZERLAND = 41,
- SYRIA = 1039,
- TAIWAN = 886,
- TANZANIA = 255,
- THAILAND = 66,
- TOBAGO = 8016,
- TOGO = 228,
- TONGAIS = 676,
- TRINIDAD = 8016,
- TUNISIA = 216,
- TURKEY = 90,
- TURKSCAICOS = 8017,
- TUVALU = 1040,
- UGANDA = 256,
- USSR = 7,
- UAEMIRATES = 971,
- UNITEDKINGDOM = 44,
- USA = 1,
- URUGUAY = 598,
- VANUATU = 1041,
- VATICANCITY = 39,
- VENEZUELA = 58,
- WAKE = 1042,
- WALLISIS = 1043,
- WESTERNSAHARA = 1044,
- WESTERNSAMOA = 1045,
- YEMEN = 1046,
- YUGOSLAVIA = 38,
- ZAIRE = 243,
- ZAMBIA = 260,
- ZIMBABWE = 263,
- ALBANIA = 355,
- ARMENIA = 374,
- AZERBAIJAN = 994,
- BELARUS = 375,
- BOSNIAHERZGO = 387,
- CAMBODIA = 855,
- CROATIA = 385,
- CZECHREPUBLIC = 420,
- DIEGOGARCIA = 246,
- ERITREA = 291,
- ESTONIA = 372,
- GEORGIA = 995,
- LATVIA = 371,
- LESOTHO = 266,
- LITHUANIA = 370,
- MACEDONIA = 389,
- MAYOTTEIS = 269,
- MOLDOVA = 373,
- MYANMAR = 95,
- NORTHKOREA = 850,
- PUERTORICO = 787,
- RUSSIA = 7,
- SERBIA = 381,
- SLOVAKIA = 421,
- SLOVENIA = 386,
- SOUTHKOREA = 82,
- UKRAINE = 380,
- USVIRGINIS = 340,
- VIETNAM = 84
- }
-
- ///
- /// Language Constants
- ///
- public enum TWLG : short
- {
- USERLOCALE = -1,
- DAN = 0,
- DUT = 1,
- ENG = 2,
- FCF = 3,
- FIN = 4,
- FRN = 5,
- GER = 6,
- ICE = 7,
- ITN = 8,
- NOR = 9,
- POR = 10,
- SPA = 11,
- SWE = 12,
- USA = 13,
- AFRIKAANS = 14,
- ALBANIA = 15,
- ARABIC = 16,
- ARABIC_ALGERIA = 17,
- ARABIC_BAHRAIN = 18,
- ARABIC_EGYPT = 19,
- ARABIC_IRAQ = 20,
- ARABIC_JORDAN = 21,
- ARABIC_KUWAIT = 22,
- ARABIC_LEBANON = 23,
- ARABIC_LIBYA = 24,
- ARABIC_MOROCCO = 25,
- ARABIC_OMAN = 26,
- ARABIC_QATAR = 27,
- ARABIC_SAUDIARABIA = 28,
- ARABIC_SYRIA = 29,
- ARABIC_TUNISIA = 30,
- ARABIC_UAE = 31,
- ARABIC_YEMEN = 32,
- BASQUE = 33,
- BYELORUSSIAN = 34,
- BULGARIAN = 35,
- CATALAN = 36,
- CHINESE = 37,
- CHINESE_HONGKONG = 38,
- CHINESE_PRC = 39,
- CHINESE_SINGAPORE = 40,
- CHINESE_SIMPLIFIED = 41,
- CHINESE_TAIWAN = 42,
- CHINESE_TRADITIONAL = 43,
- CROATIA = 44,
- CZECH = 45,
- DANISH = DAN,
- DUTCH = DUT,
- DUTCH_BELGIAN = 46,
- ENGLISH = ENG,
- ENGLISH_AUSTRALIAN = 47,
- ENGLISH_CANADIAN = 48,
- ENGLISH_IRELAND = 49,
- ENGLISH_NEWZEALAND = 50,
- ENGLISH_SOUTHAFRICA = 51,
- ENGLISH_UK = 52,
- ENGLISH_USA = USA,
- ESTONIAN = 53,
- FAEROESE = 54,
- FARSI = 55,
- FINNISH = FIN,
- FRENCH = FRN,
- FRENCH_BELGIAN = 56,
- FRENCH_CANADIAN = FCF,
- FRENCH_LUXEMBOURG = 57,
- FRENCH_SWISS = 58,
- GERMAN = GER,
- GERMAN_AUSTRIAN = 59,
- GERMAN_LUXEMBOURG = 60,
- GERMAN_LIECHTENSTEIN = 61,
- GERMAN_SWISS = 62,
- GREEK = 63,
- HEBREW = 64,
- HUNGARIAN = 65,
- ICELANDIC = ICE,
- INDONESIAN = 66,
- ITALIAN = ITN,
- ITALIAN_SWISS = 67,
- JAPANESE = 68,
- KOREAN = 69,
- KOREAN_JOHAB = 70,
- LATVIAN = 71,
- LITHUANIAN = 72,
- NORWEGIAN = NOR,
- NORWEGIAN_BOKMAL = 73,
- NORWEGIAN_NYNORSK = 74,
- POLISH = 75,
- PORTUGUESE = POR,
- PORTUGUESE_BRAZIL = 76,
- ROMANIAN = 77,
- RUSSIAN = 78,
- SERBIAN_LATIN = 79,
- SLOVAK = 80,
- SLOVENIAN = 81,
- SPANISH = TWLG.SPA,
- SPANISH_MEXICAN = 82,
- SPANISH_MODERN = 83,
- SWEDISH = TWLG.SWE,
- THAI = 84,
- TURKISH = 85,
- UKRANIAN = 86,
- ASSAMESE = 87,
- BENGALI = 88,
- BIHARI = 89,
- BODO = 90,
- DOGRI = 91,
- GUJARATI = 92,
- HARYANVI = 93,
- HINDI = 94,
- KANNADA = 95,
- KASHMIRI = 96,
- MALAYALAM = 97,
- MARATHI = 98,
- MARWARI = 99,
- MEGHALAYAN = 100,
- MIZO = 101,
- NAGA = 102,
- ORISSI = 103,
- PUNJABI = 104,
- PUSHTU = 105,
- SERBIAN_CYRILLIC = 106,
- SIKKIMI = 107,
- SWEDISH_FINLAND = 108,
- TAMIL = 109,
- TELUGU = 110,
- TRIPURI = 111,
- URDU = 112,
- VIETNAMESE = 113
- //NOTE: when adding to this list, also update Language->Set()
- }
-
- #endregion
-
-
- ///////////////////////////////////////////////////////////////////////////////
- // Data Groups...
- ///////////////////////////////////////////////////////////////////////////////
- #region Data Groups...
-
- ///
- /// Data Groups...
- ///
- [Flags]
- public enum DG : uint
- {
- CONTROL = 0x1,
- IMAGE = 0x2,
- AUDIO = 0x4,
-
- // More Data Functionality may be added in the future.
- // These are for items that need to be determined before DS is opened.
- // NOTE: Supported Functionality constants must be powers of 2 as they are
- // used as bitflags when Application asks DSM to present a list of DSs.
- // to support backward capability the App and DS will not use the fields
- DSM2 = 0x10000000,
- APP2 = 0x20000000,
- DS2 = 0x40000000,
- MASK = 0xFFFF
- }
-
- #endregion
-
-
- ///////////////////////////////////////////////////////////////////////////////
- // Data Argument Types...
- ///////////////////////////////////////////////////////////////////////////////
- #region Data Argument Types...
-
- ///
- /// Data Argument Types...
- ///
- public enum DAT : ushort
- {
- // NULL and Custom Base...
- NULL = 0x0,
- CUSTOM = 0x8000,
-
- // Data Argument Types for the DG_CONTROL Data Group.
- CAPABILITY = 0x1,
- EVENT = 0x2,
- IDENTITY = 0x3,
- PARENT = 0x4,
- PENDINGXFERS = 0x5,
- SETUPMEMXFER = 0x6,
- SETUPFILEXFER = 0x7,
- STATUS = 0x8,
- USERINTERFACE = 0x9,
- XFERGROUP = 0xa,
- CUSTOMDSDATA = 0xc,
- DEVICEEVENT = 0xd,
- FILESYSTEM = 0xe,
- PASSTHRU = 0xf,
- CALLBACK = 0x10,
- STATUSUTF8 = 0x11,
- CALLBACK2 = 0x12,
- METRICS = 0x13,
- TWAINDIRECT = 0x14,
-
- // Data Argument Types for the DG_IMAGE Data Group.
- IMAGEINFO = 0x0101,
- IMAGELAYOUT = 0x0102,
- IMAGEMEMXFER = 0x0103,
- IMAGENATIVEXFER = 0x0104,
- IMAGEFILEXFER = 0x105,
- CIECOLOR = 0x106,
- GRAYRESPONSE = 0x107,
- RGBRESPONSE = 0x108,
- JPEGCOMPRESSION = 0x109,
- PALETTE8 = 0x10a,
- EXTIMAGEINFO = 0x10b,
- FILTER = 0x10c,
-
- /* Data Argument Types for the DG_AUDIO Data Group. */
- AUDIOFILEXFER = 0x201,
- AUDIOINFO = 0x202,
- AUDIONATIVEXFER = 0x203,
-
- /* misplaced */
- ICCPROFILE = 0x401,
- IMAGEMEMFILEXFER = 0x402,
- ENTRYPOINT = 0x403
- }
-
- #endregion
-
-
- ///////////////////////////////////////////////////////////////////////////////
- // Messages...
- ///////////////////////////////////////////////////////////////////////////////
- #region Messages...
-
- ///
- /// All message constants are unique.
- /// Messages are grouped according to which DATs they are used with.
- ///
- public enum MSG : ushort
- {
- // Only used to clear fields...
- NULL = 0x0,
-
- // Generic messages may be used with any of several DATs.
- GET = 0x1,
- GETCURRENT = 0x2,
- GETDEFAULT = 0x3,
- GETFIRST = 0x4,
- GETNEXT = 0x5,
- SET = 0x6,
- RESET = 0x7,
- QUERYSUPPORT = 0x8,
- GETHELP = 0x9,
- GETLABEL = 0xa,
- GETLABELENUM = 0xb,
- SETCONSTRAINT = 0xc,
-
- // Messages used with DAT_NULL.
- XFERREADY = 0x101,
- CLOSEDSREQ = 0x102,
- CLOSEDSOK = 0x103,
- DEVICEEVENT = 0x104,
-
- // Messages used with a pointer to DAT_PARENT data.
- OPENDSM = 0x301,
- CLOSEDSM = 0x302,
-
- // Messages used with a pointer to a DAT_IDENTITY structure.
- OPENDS = 0x401,
- CLOSEDS = 0x402,
- USERSELECT = 0x403,
-
- // Messages used with a pointer to a DAT_USERINTERFACE structure.
- DISABLEDS = 0x501,
- ENABLEDS = 0x502,
- ENABLEDSUIONLY = 0x503,
-
- // Messages used with a pointer to a DAT_EVENT structure.
- PROCESSEVENT = 0x601,
-
- // Messages used with a pointer to a DAT_PENDINGXFERS structure
- ENDXFER = 0x701,
- STOPFEEDER = 0x702,
-
- // Messages used with a pointer to a DAT_FILESYSTEM structure
- CHANGEDIRECTORY = 0x0801,
- CREATEDIRECTORY = 0x0802,
- DELETE = 0x0803,
- FORMATMEDIA = 0x0804,
- GETCLOSE = 0x0805,
- GETFIRSTFILE = 0x0806,
- GETINFO = 0x0807,
- GETNEXTFILE = 0x0808,
- RENAME = 0x0809,
- COPY = 0x080A,
- AUTOMATICCAPTUREDIRECTORY = 0x080B,
-
- // Messages used with a pointer to a DAT_PASSTHRU structure
- PASSTHRU = 0x0901,
-
- // used with DAT_CALLBACK
- REGISTER_CALLBACK = 0x0902,
-
- // used with DAT_CAPABILITY
- RESETALL = 0x0A01,
-
- // used with DAT_TWAINDIRECT
- SETTASK = 0x0B01,
- }
-
- #endregion
-
-
- ///////////////////////////////////////////////////////////////////////////////
- // Capabilities...
- ///////////////////////////////////////////////////////////////////////////////
- #region Capabilities...
-
- ///
- /// The naming convention is a little awkward, but it allows us to
- /// achieve a unified capability type...
- ///
- public enum CAP : ushort
- {
- // Base of custom capabilities.
- CAP_CUSTOMBASE = 0x8000,
-
- /* all data sources are REQUIRED to support these caps */
- CAP_XFERCOUNT = 0x0001,
-
- /* image data sources are REQUIRED to support these caps */
- ICAP_COMPRESSION = 0x0100,
- ICAP_PIXELTYPE = 0x0101,
- ICAP_UNITS = 0x0102,
- ICAP_XFERMECH = 0x0103,
-
- // all data sources MAY support these caps.
- CAP_AUTHOR = 0x1000,
- CAP_CAPTION = 0x1001,
- CAP_FEEDERENABLED = 0x1002,
- CAP_FEEDERLOADED = 0x1003,
- CAP_TIMEDATE = 0x1004,
- CAP_SUPPORTEDCAPS = 0x1005,
- CAP_EXTENDEDCAPS = 0x1006,
- CAP_AUTOFEED = 0x1007,
- CAP_CLEARPAGE = 0x1008,
- CAP_FEEDPAGE = 0x1009,
- CAP_REWINDPAGE = 0x100a,
- CAP_INDICATORS = 0x100b,
- CAP_PAPERDETECTABLE = 0x100d,
- CAP_UICONTROLLABLE = 0x100e,
- CAP_DEVICEONLINE = 0x100f,
- CAP_AUTOSCAN = 0x1010,
- CAP_THUMBNAILSENABLED = 0x1011,
- CAP_DUPLEX = 0x1012,
- CAP_DUPLEXENABLED = 0x1013,
- CAP_ENABLEDSUIONLY = 0x1014,
- CAP_CUSTOMDSDATA = 0x1015,
- CAP_ENDORSER = 0x1016,
- CAP_JOBCONTROL = 0x1017,
- CAP_ALARMS = 0x1018,
- CAP_ALARMVOLUME = 0x1019,
- CAP_AUTOMATICCAPTURE = 0x101a,
- CAP_TIMEBEFOREFIRSTCAPTURE = 0x101b,
- CAP_TIMEBETWEENCAPTURES = 0x101c,
- CAP_CLEARBUFFERS = 0x101d,
- CAP_MAXBATCHBUFFERS = 0x101e,
- CAP_DEVICETIMEDATE = 0x101f,
- CAP_POWERSUPPLY = 0x1020,
- CAP_CAMERAPREVIEWUI = 0x1021,
- CAP_DEVICEEVENT = 0x1022,
- CAP_SERIALNUMBER = 0x1024,
- CAP_PRINTER = 0x1026,
- CAP_PRINTERENABLED = 0x1027,
- CAP_PRINTERINDEX = 0x1028,
- CAP_PRINTERMODE = 0x1029,
- CAP_PRINTERSTRING = 0x102a,
- CAP_PRINTERSUFFIX = 0x102b,
- CAP_LANGUAGE = 0x102c,
- CAP_FEEDERALIGNMENT = 0x102d,
- CAP_FEEDERORDER = 0x102e,
- CAP_REACQUIREALLOWED = 0x1030,
- CAP_BATTERYMINUTES = 0x1032,
- CAP_BATTERYPERCENTAGE = 0x1033,
- CAP_CAMERASIDE = 0x1034,
- CAP_SEGMENTED = 0x1035,
- CAP_CAMERAENABLED = 0x1036,
- CAP_CAMERAORDER = 0x1037,
- CAP_MICRENABLED = 0x1038,
- CAP_FEEDERPREP = 0x1039,
- CAP_FEEDERPOCKET = 0x103a,
- CAP_AUTOMATICSENSEMEDIUM = 0x103b,
- CAP_CUSTOMINTERFACEGUID = 0x103c,
- CAP_SUPPORTEDCAPSSEGMENTUNIQUE = 0x103d,
- CAP_SUPPORTEDDATS = 0x103e,
- CAP_DOUBLEFEEDDETECTION = 0x103f,
- CAP_DOUBLEFEEDDETECTIONLENGTH = 0x1040,
- CAP_DOUBLEFEEDDETECTIONSENSITIVITY = 0x1041,
- CAP_DOUBLEFEEDDETECTIONRESPONSE = 0x1042,
- CAP_PAPERHANDLING = 0x1043,
- CAP_INDICATORSMODE = 0x1044,
- CAP_PRINTERVERTICALOFFSET = 0x1045,
- CAP_POWERSAVETIME = 0x1046,
- CAP_PRINTERCHARROTATION = 0x1047,
- CAP_PRINTERFONTSTYLE = 0x1048,
- CAP_PRINTERINDEXLEADCHAR = 0x1049,
- CAP_PRINTERINDEXMAXVALUE = 0x104A,
- CAP_PRINTERINDEXNUMDIGITS = 0x104B,
- CAP_PRINTERINDEXSTEP = 0x104C,
- CAP_PRINTERINDEXTRIGGER = 0x104D,
- CAP_PRINTERSTRINGPREVIEW = 0x104E,
- CAP_SHEETCOUNT = 0x104F,
- CAP_IMAGEADDRESSENABLED = 0x1050,
- CAP_IAFIELDA_LEVEL = 0x1051,
- CAP_IAFIELDB_LEVEL = 0x1052,
- CAP_IAFIELDC_LEVEL = 0x1053,
- CAP_IAFIELDD_LEVEL = 0x1054,
- CAP_IAFIELDE_LEVEL = 0x1055,
- CAP_IAFIELDA_PRINTFORMAT = 0x1056,
- CAP_IAFIELDB_PRINTFORMAT = 0x1057,
- CAP_IAFIELDC_PRINTFORMAT = 0x1058,
- CAP_IAFIELDD_PRINTFORMAT = 0x1059,
- CAP_IAFIELDE_PRINTFORMAT = 0x105A,
- CAP_IAFIELDA_VALUE = 0x105B,
- CAP_IAFIELDB_VALUE = 0x105C,
- CAP_IAFIELDC_VALUE = 0x105D,
- CAP_IAFIELDD_VALUE = 0x105E,
- CAP_IAFIELDE_VALUE = 0x105F,
- CAP_IAFIELDA_LASTPAGE = 0x1060,
- CAP_IAFIELDB_LASTPAGE = 0x1061,
- CAP_IAFIELDC_LASTPAGE = 0x1062,
- CAP_IAFIELDD_LASTPAGE = 0x1063,
- CAP_IAFIELDE_LASTPAGE = 0x1064,
-
- // image data sources MAY support these caps.
- ICAP_AUTOBRIGHT = 0x1100,
- ICAP_BRIGHTNESS = 0x1101,
- ICAP_CONTRAST = 0x1103,
- ICAP_CUSTHALFTONE = 0x1104,
- ICAP_EXPOSURETIME = 0x1105,
- ICAP_FILTER = 0x1106,
- ICAP_FLASHUSED = 0x1107,
- ICAP_GAMMA = 0x1108,
- ICAP_HALFTONES = 0x1109,
- ICAP_HIGHLIGHT = 0x110a,
- ICAP_IMAGEFILEFORMAT = 0x110c,
- ICAP_LAMPSTATE = 0x110d,
- ICAP_LIGHTSOURCE = 0x110e,
- ICAP_ORIENTATION = 0x1110,
- ICAP_PHYSICALWIDTH = 0x1111,
- ICAP_PHYSICALHEIGHT = 0x1112,
- ICAP_SHADOW = 0x1113,
- ICAP_FRAMES = 0x1114,
- ICAP_XNATIVERESOLUTION = 0x1116,
- ICAP_YNATIVERESOLUTION = 0x1117,
- ICAP_XRESOLUTION = 0x1118,
- ICAP_YRESOLUTION = 0x1119,
- ICAP_MAXFRAMES = 0x111a,
- ICAP_TILES = 0x111b,
- ICAP_BITORDER = 0x111c,
- ICAP_CCITTKFACTOR = 0x111d,
- ICAP_LIGHTPATH = 0x111e,
- ICAP_PIXELFLAVOR = 0x111f,
- ICAP_PLANARCHUNKY = 0x1120,
- ICAP_ROTATION = 0x1121,
- ICAP_SUPPORTEDSIZES = 0x1122,
- ICAP_THRESHOLD = 0x1123,
- ICAP_XSCALING = 0x1124,
- ICAP_YSCALING = 0x1125,
- ICAP_BITORDERCODES = 0x1126,
- ICAP_PIXELFLAVORCODES = 0x1127,
- ICAP_JPEGPIXELTYPE = 0x1128,
- ICAP_TIMEFILL = 0x112a,
- ICAP_BITDEPTH = 0x112b,
- ICAP_BITDEPTHREDUCTION = 0x112c,
- ICAP_UNDEFINEDIMAGESIZE = 0x112d,
- ICAP_IMAGEDATASET = 0x112e,
- ICAP_EXTIMAGEINFO = 0x112f,
- ICAP_MINIMUMHEIGHT = 0x1130,
- ICAP_MINIMUMWIDTH = 0x1131,
- ICAP_AUTODISCARDBLANKPAGES = 0x1134,
- ICAP_FLIPROTATION = 0x1136,
- ICAP_BARCODEDETECTIONENABLED = 0x1137,
- ICAP_SUPPORTEDBARCODETYPES = 0x1138,
- ICAP_BARCODEMAXSEARCHPRIORITIES = 0x1139,
- ICAP_BARCODESEARCHPRIORITIES = 0x113a,
- ICAP_BARCODESEARCHMODE = 0x113b,
- ICAP_BARCODEMAXRETRIES = 0x113c,
- ICAP_BARCODETIMEOUT = 0x113d,
- ICAP_ZOOMFACTOR = 0x113e,
- ICAP_PATCHCODEDETECTIONENABLED = 0x113f,
- ICAP_SUPPORTEDPATCHCODETYPES = 0x1140,
- ICAP_PATCHCODEMAXSEARCHPRIORITIES = 0x1141,
- ICAP_PATCHCODESEARCHPRIORITIES = 0x1142,
- ICAP_PATCHCODESEARCHMODE = 0x1143,
- ICAP_PATCHCODEMAXRETRIES = 0x1144,
- ICAP_PATCHCODETIMEOUT = 0x1145,
- ICAP_FLASHUSED2 = 0x1146,
- ICAP_IMAGEFILTER = 0x1147,
- ICAP_NOISEFILTER = 0x1148,
- ICAP_OVERSCAN = 0x1149,
- ICAP_AUTOMATICBORDERDETECTION = 0x1150,
- ICAP_AUTOMATICDESKEW = 0x1151,
- ICAP_AUTOMATICROTATE = 0x1152,
- ICAP_JPEGQUALITY = 0x1153,
- ICAP_FEEDERTYPE = 0x1154,
- ICAP_ICCPROFILE = 0x1155,
- ICAP_AUTOSIZE = 0x1156,
- ICAP_AUTOMATICCROPUSESFRAME = 0x1157,
- ICAP_AUTOMATICLENGTHDETECTION = 0x1158,
- ICAP_AUTOMATICCOLORENABLED = 0x1159,
- ICAP_AUTOMATICCOLORNONCOLORPIXELTYPE = 0x115a,
- ICAP_COLORMANAGEMENTENABLED = 0x115b,
- ICAP_IMAGEMERGE = 0x115c,
- ICAP_IMAGEMERGEHEIGHTTHRESHOLD = 0x115d,
- ICAP_SUPPORTEDEXTIMAGEINFO = 0x115e,
- ICAP_FILMTYPE = 0x115f,
- ICAP_MIRROR = 0x1160,
- ICAP_JPEGSUBSAMPLING = 0x1161,
-
- // image data sources MAY support these audio caps.
- ACAP_XFERMECH = 0x1202
- }
-
- #endregion
-
-
- ///////////////////////////////////////////////////////////////////////////////
- // Extended Image Info Attributes section Added 1.7...
- ///////////////////////////////////////////////////////////////////////////////
- #region Extended Image Info Attributes section Added 1.7...
-
- ///
- /// Extended Image Info Attributes...
- ///
- public enum TWEI : ushort
- {
- BARCODEX = 0x1200,
- BARCODEY = 0x1201,
- BARCODETEXT = 0x1202,
- BARCODETYPE = 0x1203,
- DESHADETOP = 0x1204,
- DESHADELEFT = 0x1205,
- DESHADEHEIGHT = 0x1206,
- DESHADEWIDTH = 0x1207,
- DESHADESIZE = 0x1208,
- SPECKLESREMOVED = 0x1209,
- HORZLINEXCOORD = 0x120A,
- HORZLINEYCOORD = 0x120B,
- HORZLINELENGTH = 0x120C,
- HORZLINETHICKNESS = 0x120D,
- VERTLINEXCOORD = 0x120E,
- VERTLINEYCOORD = 0x120F,
- VERTLINELENGTH = 0x1210,
- VERTLINETHICKNESS = 0x1211,
- PATCHCODE = 0x1212,
- ENDORSEDTEXT = 0x1213,
- FORMCONFIDENCE = 0x1214,
- FORMTEMPLATEMATCH = 0x1215,
- FORMTEMPLATEPAGEMATCH = 0x1216,
- FORMHORZDOCOFFSET = 0x1217,
- FORMVERTDOCOFFSET = 0x1218,
- BARCODECOUNT = 0x1219,
- BARCODECONFIDENCE = 0x121A,
- BARCODEROTATION = 0x121B,
- BARCODETEXTLENGTH = 0x121C,
- DESHADECOUNT = 0x121D,
- DESHADEBLACKCOUNTOLD = 0x121E,
- DESHADEBLACKCOUNTNEW = 0x121F,
- DESHADEBLACKRLMIN = 0x1220,
- DESHADEBLACKRLMAX = 0x1221,
- DESHADEWHITECOUNTOLD = 0x1222,
- DESHADEWHITECOUNTNEW = 0x1223,
- DESHADEWHITERLMIN = 0x1224,
- DESHADEWHITERLAVE = 0x1225,
- DESHADEWHITERLMAX = 0x1226,
- BLACKSPECKLESREMOVED = 0x1227,
- WHITESPECKLESREMOVED = 0x1228,
- HORZLINECOUNT = 0x1229,
- VERTLINECOUNT = 0x122A,
- DESKEWSTATUS = 0x122B,
- SKEWORIGINALANGLE = 0x122C,
- SKEWFINALANGLE = 0x122D,
- SKEWCONFIDENCE = 0x122E,
- SKEWWINDOWX1 = 0x122F,
- SKEWWINDOWY1 = 0x1230,
- SKEWWINDOWX2 = 0x1231,
- SKEWWINDOWY2 = 0x1232,
- SKEWWINDOWX3 = 0x1233,
- SKEWWINDOWY3 = 0x1234,
- SKEWWINDOWX4 = 0x1235,
- SKEWWINDOWY4 = 0x1236,
- BOOKNAME = 0x1238,
- CHAPTERNUMBER = 0x1239,
- DOCUMENTNUMBER = 0x123A,
- PAGENUMBER = 0x123B,
- CAMERA = 0x123C,
- FRAMENUMBER = 0x123D,
- FRAME = 0x123E,
- PIXELFLAVOR = 0x123F,
- ICCPROFILE = 0x1240,
- LASTSEGMENT = 0x1241,
- SEGMENTNUMBER = 0x1242,
- MAGDATA = 0x1243,
- MAGTYPE = 0x1244,
- PAGESIDE = 0x1245,
- FILESYSTEMSOURCE = 0x1246,
- IMAGEMERGED = 0x1247,
- MAGDATALENGTH = 0x1248,
- PAPERCOUNT = 0x1249,
- PRINTERTEXT = 0x124A,
- TWAINDIRECTMETADATA = 0x124B,
- IAFIELDA_VALUE = 0x124C,
- IAFIELDB_VALUE = 0x124D,
- IAFIELDC_VALUE = 0x124E,
- IAFIELDD_VALUE = 0x124F,
- IAFIELDE_VALUE = 0x1250,
- IALEVEL = 0x1251,
- PRINTER = 0x1252,
- BARCODETEXT2 = 0x1253,
- }
-
- public enum TWEJ : ushort
- {
- NONE = 0x0000,
- MIDSEPARATOR = 0x0001,
- PATCH1 = 0x0002,
- PATCH2 = 0x0003,
- PATCH3 = 0x0004,
- PATCH4 = 0x0005,
- PATCH6 = 0x0006,
- PATCHT = 0x0007
- }
-
- #endregion
-
-
- ///////////////////////////////////////////////////////////////////////////////
- // Return Codes and Condition Codes section...
- ///////////////////////////////////////////////////////////////////////////////
- #region Return Codes and Condition Codes section...
-
- //public enum STS
- //{
- // // Custom base (same for TWRC and TWCC)...
- // CUSTOMBASE = 0x8000,
-
- // // Return codes...
- // SUCCESS = 0,
- // FAILURE = 1,
- // CHECKSTATUS = 2,
- // CANCEL = 3,
- // DSEVENT = 4,
- // NOTDSEVENT = 5,
- // XFERDONE = 6,
- // ENDOFLIST = 7,
- // INFONOTSUPPORTED = 8,
- // DATANOTAVAILABLE = 9,
- // BUSY = 10,
- // SCANNERLOCKED = 11,
-
- // // Condition codes (always associated with TWRC_FAILURE)...
- // BUMMER = TwainConst.STSCC + 1,
- // LOWMEMORY = TwainConst.STSCC + 2,
- // NODS = TwainConst.STSCC + 3,
- // MAXCONNECTIONS = TwainConst.STSCC + 4,
- // OPERATIONERROR = TwainConst.STSCC + 5,
- // BADCAP = TwainConst.STSCC + 6,
- // BADPROTOCOL = TwainConst.STSCC + 9,
- // BADVALUE = TwainConst.STSCC + 10,
- // SEQERROR = TwainConst.STSCC + 11,
- // BADDEST = TwainConst.STSCC + 12,
- // CAPUNSUPPORTED = TwainConst.STSCC + 13,
- // CAPBADOPERATION = TwainConst.STSCC + 14,
- // CAPSEQERROR = TwainConst.STSCC + 15,
- // DENIED = TwainConst.STSCC + 16,
- // FILEEXISTS = TwainConst.STSCC + 17,
- // FILENOTFOUND = TwainConst.STSCC + 18,
- // NOTEMPTY = TwainConst.STSCC + 19,
- // PAPERJAM = TwainConst.STSCC + 20,
- // PAPERDOUBLEFEED = TwainConst.STSCC + 21,
- // FILEWRITEERROR = TwainConst.STSCC + 22,
- // CHECKDEVICEONLINE = TwainConst.STSCC + 23,
- // INTERLOCK = TwainConst.STSCC + 24,
- // DAMAGEDCORNER = TwainConst.STSCC + 25,
- // FOCUSERROR = TwainConst.STSCC + 26,
- // DOCTOOLIGHT = TwainConst.STSCC + 27,
- // DOCTOODARK = TwainConst.STSCC + 28,
- // NOMEDIA = TwainConst.STSCC + 29
- //}
-
- ///
- /// bit patterns: for query the operation that are supported by the data source on a capability
- /// Application gets these through DG_CONTROL/DAT_CAPABILITY/MSG_QUERYSUPPORT
- ///
- [Flags]
- public enum TWQC : ushort
- {
- Unknown = 0,
- GET = 0x0001,
- SET = 0x0002,
- GETDEFAULT = 0x0004,
- GETCURRENT = 0x0008,
- RESET = 0x0010,
- SETCONSTRAINT = 0x0020,
- CONSTRAINABLE = 0x0040,
- // KODAK additions
- ///
- /// KODAK ONLY: applies to entire session/machine
- ///
- MACHINE = 0x1000,
- ///
- /// KODAK ONLY: applies to Bitonal "cameras"
- ///
- BITONAL = 0x2000,
- ///
- /// KODAK ONLY: applies to Color "cameras"
- ///
- COLOR = 0x3000
- }
-
- ///
- /// The TWAIN States...
- ///
- public enum STATE
- {
- S1 = 1, // Nothing loaded or open
- S2 = 2, // DSM loaded
- S3 = 3, // DSM open
- S4 = 4, // Data Source open, programmatic mode (no GUI)
- S5 = 5, // GUI up or waiting to transfer first image
- S6 = 6, // ready to start transferring image
- S7 = 7 // transferring image or transfer done
- }
-
- #endregion
-
-
- ///////////////////////////////////////////////////////////////////////////////
- // Language section...
- ///////////////////////////////////////////////////////////////////////////////
- #region Language section...
-
- ///
- /// Handle encoding between C# and what the DS is currently set to.
- /// NOTE: this is static for users of this object do not have to track
- /// the encoding (i.e. let cs deal with all of this). This
- /// means there is one language for all open DSes, so the last one wins.
- ///
- public static class Language
- {
- ///
- /// The encoding to use for strings to/from the DS
- ///
- ///
- public static Encoding GetEncoding()
- {
- return (m_encoding);
- }
-
- ///
- /// The current language of the DS
- ///
- ///
- public static void Set(TWLG a_twlg)
- {
- switch (a_twlg)
- {
- default:
- // NOTE: can only get here if a TWLG was added, but it wasn't added here
- m_encoding = Encoding.GetEncoding(1252);
- break;
-
- case TWLG.USERLOCALE:
- // NOTE: this should never come back from the DS. only here for completeness
- m_encoding = Encoding.GetEncoding(1252);
- break;
-
- case TWLG.THAI:
- m_encoding = Encoding.GetEncoding(874);
- break;
-
- case TWLG.JAPANESE:
- m_encoding = Encoding.GetEncoding(932);
- break;
-
- case TWLG.CHINESE:
- case TWLG.CHINESE_PRC:
- case TWLG.CHINESE_SINGAPORE:
- case TWLG.CHINESE_SIMPLIFIED:
- m_encoding = Encoding.GetEncoding(936);
- break;
-
- case TWLG.KOREAN:
- case TWLG.KOREAN_JOHAB:
- m_encoding = Encoding.GetEncoding(949);
- break;
-
- case TWLG.CHINESE_HONGKONG:
- case TWLG.CHINESE_TAIWAN:
- case TWLG.CHINESE_TRADITIONAL:
- m_encoding = Encoding.GetEncoding(950);
- break;
-
- case TWLG.ALBANIA:
- case TWLG.CROATIA:
- case TWLG.CZECH:
- case TWLG.HUNGARIAN:
- case TWLG.POLISH:
- case TWLG.ROMANIAN:
- case TWLG.SERBIAN_LATIN:
- case TWLG.SLOVAK:
- case TWLG.SLOVENIAN:
- m_encoding = Encoding.GetEncoding(1250);
- break;
-
- case TWLG.BYELORUSSIAN:
- case TWLG.BULGARIAN:
- case TWLG.RUSSIAN:
- case TWLG.SERBIAN_CYRILLIC:
- case TWLG.UKRANIAN:
- m_encoding = Encoding.GetEncoding(1251);
- break;
-
- case TWLG.AFRIKAANS:
- case TWLG.BASQUE:
- case TWLG.CATALAN:
- case TWLG.DAN: // DANISH
- case TWLG.DUT: // DUTCH
- case TWLG.DUTCH_BELGIAN:
- case TWLG.ENG: // ENGLISH
- case TWLG.ENGLISH_AUSTRALIAN:
- case TWLG.ENGLISH_CANADIAN:
- case TWLG.ENGLISH_IRELAND:
- case TWLG.ENGLISH_NEWZEALAND:
- case TWLG.ENGLISH_SOUTHAFRICA:
- case TWLG.ENGLISH_UK:
- case TWLG.USA:
- case TWLG.FAEROESE:
- case TWLG.FIN: // FINNISH
- case TWLG.FRN: // FRENCH
- case TWLG.FRENCH_BELGIAN:
- case TWLG.FCF: // FRENCH_CANADIAN
- case TWLG.FRENCH_LUXEMBOURG:
- case TWLG.FRENCH_SWISS:
- case TWLG.GER: // GERMAN
- case TWLG.GERMAN_AUSTRIAN:
- case TWLG.GERMAN_LIECHTENSTEIN:
- case TWLG.GERMAN_LUXEMBOURG:
- case TWLG.GERMAN_SWISS:
- case TWLG.ICE: // ICELANDIC
- case TWLG.INDONESIAN:
- case TWLG.ITN: // ITALIAN
- case TWLG.ITALIAN_SWISS:
- case TWLG.NOR: // NORWEGIAN
- case TWLG.NORWEGIAN_BOKMAL:
- case TWLG.NORWEGIAN_NYNORSK:
- case TWLG.POR: // PORTUGUESE
- case TWLG.PORTUGUESE_BRAZIL:
- case TWLG.SPA: // SPANISH
- case TWLG.SPANISH_MEXICAN:
- case TWLG.SPANISH_MODERN:
- case TWLG.SWE: // SWEDISH
- case TWLG.SWEDISH_FINLAND:
- m_encoding = Encoding.GetEncoding(1252);
- break;
-
- case TWLG.GREEK:
- m_encoding = Encoding.GetEncoding(1253);
- break;
-
- case TWLG.TURKISH:
- m_encoding = Encoding.GetEncoding(1254);
- break;
-
- case TWLG.HEBREW:
- m_encoding = Encoding.GetEncoding(1255);
- break;
-
- case TWLG.ARABIC:
- case TWLG.ARABIC_ALGERIA:
- case TWLG.ARABIC_BAHRAIN:
- case TWLG.ARABIC_EGYPT:
- case TWLG.ARABIC_IRAQ:
- case TWLG.ARABIC_JORDAN:
- case TWLG.ARABIC_KUWAIT:
- case TWLG.ARABIC_LEBANON:
- case TWLG.ARABIC_LIBYA:
- case TWLG.ARABIC_MOROCCO:
- case TWLG.ARABIC_OMAN:
- case TWLG.ARABIC_QATAR:
- case TWLG.ARABIC_SAUDIARABIA:
- case TWLG.ARABIC_SYRIA:
- case TWLG.ARABIC_TUNISIA:
- case TWLG.ARABIC_UAE:
- case TWLG.ARABIC_YEMEN:
- case TWLG.FARSI:
- case TWLG.URDU:
- m_encoding = Encoding.GetEncoding(1256);
- break;
-
- case TWLG.ESTONIAN:
- case TWLG.LATVIAN:
- case TWLG.LITHUANIAN:
- m_encoding = Encoding.GetEncoding(1257);
- break;
-
- case TWLG.VIETNAMESE:
- m_encoding = Encoding.GetEncoding(1258);
- break;
-
- case TWLG.ASSAMESE:
- case TWLG.BENGALI:
- case TWLG.BIHARI:
- case TWLG.BODO:
- case TWLG.DOGRI:
- case TWLG.GUJARATI:
- case TWLG.HARYANVI:
- case TWLG.HINDI:
- case TWLG.KANNADA:
- case TWLG.KASHMIRI:
- case TWLG.MALAYALAM:
- case TWLG.MARATHI:
- case TWLG.MARWARI:
- case TWLG.MEGHALAYAN:
- case TWLG.MIZO:
- case TWLG.NAGA:
- case TWLG.ORISSI:
- case TWLG.PUNJABI:
- case TWLG.PUSHTU:
- case TWLG.SIKKIMI:
- case TWLG.TAMIL:
- case TWLG.TELUGU:
- case TWLG.TRIPURI:
- // NOTE: there are no known code pages for these, so we will use English
- m_encoding = Encoding.GetEncoding(1252);
- break;
- }
- }
-
- private static Encoding m_encoding = Encoding.GetEncoding(1252);
- }
-
- #endregion
-
}
+
+///
+/// Used for strings that go up to 64-bytes...
+///
+[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
+public partial struct TW_STR64
+{
+ ///
+ /// We're stuck with this, because marshalling with packed alignment
+ /// can't handle arrays...
+ ///
+ private byte byItem000; private byte byItem001; private byte byItem002; private byte byItem003;
+ private byte byItem004; private byte byItem005; private byte byItem006; private byte byItem007;
+ private byte byItem008; private byte byItem009; private byte byItem010; private byte byItem011;
+ private byte byItem012; private byte byItem013; private byte byItem014; private byte byItem015;
+ private byte byItem016; private byte byItem017; private byte byItem018; private byte byItem019;
+ private byte byItem020; private byte byItem021; private byte byItem022; private byte byItem023;
+ private byte byItem024; private byte byItem025; private byte byItem026; private byte byItem027;
+ private byte byItem028; private byte byItem029; private byte byItem030; private byte byItem031;
+ private byte byItem032; private byte byItem033; private byte byItem034; private byte byItem035;
+ private byte byItem036; private byte byItem037; private byte byItem038; private byte byItem039;
+ private byte byItem040; private byte byItem041; private byte byItem042; private byte byItem043;
+ private byte byItem044; private byte byItem045; private byte byItem046; private byte byItem047;
+ private byte byItem048; private byte byItem049; private byte byItem050; private byte byItem051;
+ private byte byItem052; private byte byItem053; private byte byItem054; private byte byItem055;
+ private byte byItem056; private byte byItem057; private byte byItem058; private byte byItem059;
+ private byte byItem060; private byte byItem061; private byte byItem062; private byte byItem063;
+ private byte byItem064; private byte byItem065;
+
+ ///
+ /// The normal get...
+ ///
+ ///
+ ///
+ public string Get(Encoding? encoding = null)
+ {
+ return (GetValue(true, encoding));
+ }
+
+ ///
+ /// Use this on Mac OS X if you have a call that uses a string
+ /// that doesn't include the prefix byte...
+ ///
+ ///
+ ///
+ public string GetNoPrefix(Encoding? encoding = null)
+ {
+ return (GetValue(false, encoding));
+ }
+
+ ///
+ /// Get our value...
+ ///
+ ///
+ ///
+ ///
+ private string GetValue(bool a_blMayHavePrefix, Encoding? encoding = null)
+ {
+ // convert what we have into a byte array
+ byte[] abyItem = new byte[66];
+ abyItem[0] = byItem000; abyItem[1] = byItem001; abyItem[2] = byItem002; abyItem[3] = byItem003;
+ abyItem[4] = byItem004; abyItem[5] = byItem005; abyItem[6] = byItem006; abyItem[7] = byItem007;
+ abyItem[8] = byItem008; abyItem[9] = byItem009; abyItem[10] = byItem010; abyItem[11] = byItem011;
+ abyItem[12] = byItem012; abyItem[13] = byItem013; abyItem[14] = byItem014; abyItem[15] = byItem015;
+ abyItem[16] = byItem016; abyItem[17] = byItem017; abyItem[18] = byItem018; abyItem[19] = byItem019;
+ abyItem[20] = byItem020; abyItem[21] = byItem021; abyItem[22] = byItem022; abyItem[23] = byItem023;
+ abyItem[24] = byItem024; abyItem[25] = byItem025; abyItem[26] = byItem026; abyItem[27] = byItem027;
+ abyItem[28] = byItem028; abyItem[29] = byItem029; abyItem[30] = byItem030; abyItem[31] = byItem031;
+ abyItem[32] = byItem032; abyItem[33] = byItem033; abyItem[34] = byItem034; abyItem[35] = byItem035;
+ abyItem[36] = byItem036; abyItem[37] = byItem037; abyItem[38] = byItem038; abyItem[39] = byItem039;
+ abyItem[40] = byItem040; abyItem[41] = byItem041; abyItem[42] = byItem042; abyItem[43] = byItem043;
+ abyItem[44] = byItem044; abyItem[45] = byItem045; abyItem[46] = byItem046; abyItem[47] = byItem047;
+ abyItem[48] = byItem048; abyItem[49] = byItem049; abyItem[50] = byItem050; abyItem[51] = byItem051;
+ abyItem[52] = byItem052; abyItem[53] = byItem053; abyItem[54] = byItem054; abyItem[55] = byItem055;
+ abyItem[56] = byItem056; abyItem[57] = byItem057; abyItem[58] = byItem058; abyItem[59] = byItem059;
+ abyItem[60] = byItem060; abyItem[61] = byItem061; abyItem[62] = byItem062; abyItem[63] = byItem063;
+ abyItem[64] = byItem064; abyItem[65] = byItem065;
+
+ // Zero anything after the NUL...
+ bool blNul = false;
+ for (int ii = 0; ii < abyItem.Length; ii++)
+ {
+ if (!blNul && (abyItem[ii] == 0))
+ {
+ blNul = true;
+ }
+ else if (blNul)
+ {
+ abyItem[ii] = 0;
+ }
+ }
+
+ // change encoding of byte array, then convert the bytes array to a string
+ string sz = Encoding.Unicode.GetString(Encoding.Convert(encoding ?? Language.GetEncoding(), Encoding.Unicode, abyItem));
+
+ // If the first character is a NUL, then return the empty string...
+ if (sz[0] == '\0')
+ {
+ return ("");
+ }
+
+ // If we're running on a Mac, take off the prefix 'byte'...
+ if (a_blMayHavePrefix && TWPlatform.IsMacOSX)
+ {
+ sz = sz.Remove(0, 1);
+ }
+
+ // If we detect a NUL, then split around it...
+ if (sz.IndexOf('\0') >= 0)
+ {
+ sz = sz.Split(new char[] { '\0' })[0];
+ }
+
+ // All done...
+ return (sz);
+ }
+
+ ///
+ /// The normal set...
+ ///
+ ///
+ ///
+ ///
+ public void Set(string a_sz, Encoding? encoding = null)
+ {
+ SetValue(a_sz, true, encoding);
+ }
+
+ ///
+ /// Use this on Mac OS X if you have a call that uses a string
+ /// that doesn't include the prefix byte...
+ ///
+ ///
+ ///
+ ///
+ public void SetNoPrefix(string a_sz, Encoding? encoding = null)
+ {
+ SetValue(a_sz, false, encoding);
+ }
+
+ ///
+ /// Set our value...
+ ///
+ ///
+ ///
+ ///
+ private void SetValue(string a_sz, bool a_blMayHavePrefix, Encoding? encoding = null)
+ {
+ // If we're running on a Mac, tack on the prefix 'byte'...
+ if (a_sz == null)
+ {
+ a_sz = "";
+ }
+ else if (a_blMayHavePrefix && TWPlatform.IsMacOSX)
+ {
+ a_sz = (char)a_sz.Length + a_sz;
+ }
+
+ // Make sure that we're NUL padded...
+ string sz =
+ a_sz +
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
+ "\0\0";
+ if (sz.Length > 66)
+ {
+ sz = sz.Remove(66);
+ }
+
+ // convert string to byte array, then change the encoding of the byte array
+ byte[] abyItem = Encoding.Convert(Encoding.Unicode, encoding ?? Language.GetEncoding(), Encoding.Unicode.GetBytes(sz));
+
+ // concert byte array to bytes
+ byItem000 = abyItem[0]; byItem001 = abyItem[1]; byItem002 = abyItem[2]; byItem003 = abyItem[3];
+ byItem004 = abyItem[4]; byItem005 = abyItem[5]; byItem006 = abyItem[6]; byItem007 = abyItem[7];
+ byItem008 = abyItem[8]; byItem009 = abyItem[9]; byItem010 = abyItem[10]; byItem011 = abyItem[11];
+ byItem012 = abyItem[12]; byItem013 = abyItem[13]; byItem014 = abyItem[14]; byItem015 = abyItem[15];
+ byItem016 = abyItem[16]; byItem017 = abyItem[17]; byItem018 = abyItem[18]; byItem019 = abyItem[19];
+ byItem020 = abyItem[20]; byItem021 = abyItem[21]; byItem022 = abyItem[22]; byItem023 = abyItem[23];
+ byItem024 = abyItem[24]; byItem025 = abyItem[25]; byItem026 = abyItem[26]; byItem027 = abyItem[27];
+ byItem028 = abyItem[28]; byItem029 = abyItem[29]; byItem030 = abyItem[30]; byItem031 = abyItem[31];
+ byItem032 = abyItem[32]; byItem033 = abyItem[33]; byItem034 = abyItem[34]; byItem035 = abyItem[35];
+ byItem036 = abyItem[36]; byItem037 = abyItem[37]; byItem038 = abyItem[38]; byItem039 = abyItem[39];
+ byItem040 = abyItem[40]; byItem041 = abyItem[41]; byItem042 = abyItem[42]; byItem043 = abyItem[43];
+ byItem044 = abyItem[44]; byItem045 = abyItem[45]; byItem046 = abyItem[46]; byItem047 = abyItem[47];
+ byItem048 = abyItem[48]; byItem049 = abyItem[49]; byItem050 = abyItem[50]; byItem051 = abyItem[51];
+ byItem052 = abyItem[52]; byItem053 = abyItem[53]; byItem054 = abyItem[54]; byItem055 = abyItem[55];
+ byItem056 = abyItem[56]; byItem057 = abyItem[57]; byItem058 = abyItem[58]; byItem059 = abyItem[59];
+ byItem060 = abyItem[60]; byItem061 = abyItem[61]; byItem062 = abyItem[62]; byItem063 = abyItem[63];
+ byItem064 = abyItem[64]; byItem065 = abyItem[65];
+ }
+}
+
+///
+/// Used for strings that go up to 128-bytes...
+///
+[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
+public partial struct TW_STR128
+{
+ ///
+ /// We're stuck with this, because marshalling with packed alignment
+ /// can't handle arrays...
+ ///
+ private byte byItem000; private byte byItem001; private byte byItem002; private byte byItem003;
+ private byte byItem004; private byte byItem005; private byte byItem006; private byte byItem007;
+ private byte byItem008; private byte byItem009; private byte byItem010; private byte byItem011;
+ private byte byItem012; private byte byItem013; private byte byItem014; private byte byItem015;
+ private byte byItem016; private byte byItem017; private byte byItem018; private byte byItem019;
+ private byte byItem020; private byte byItem021; private byte byItem022; private byte byItem023;
+ private byte byItem024; private byte byItem025; private byte byItem026; private byte byItem027;
+ private byte byItem028; private byte byItem029; private byte byItem030; private byte byItem031;
+ private byte byItem032; private byte byItem033; private byte byItem034; private byte byItem035;
+ private byte byItem036; private byte byItem037; private byte byItem038; private byte byItem039;
+ private byte byItem040; private byte byItem041; private byte byItem042; private byte byItem043;
+ private byte byItem044; private byte byItem045; private byte byItem046; private byte byItem047;
+ private byte byItem048; private byte byItem049; private byte byItem050; private byte byItem051;
+ private byte byItem052; private byte byItem053; private byte byItem054; private byte byItem055;
+ private byte byItem056; private byte byItem057; private byte byItem058; private byte byItem059;
+ private byte byItem060; private byte byItem061; private byte byItem062; private byte byItem063;
+ private byte byItem064; private byte byItem065; private byte byItem066; private byte byItem067;
+ private byte byItem068; private byte byItem069; private byte byItem070; private byte byItem071;
+ private byte byItem072; private byte byItem073; private byte byItem074; private byte byItem075;
+ private byte byItem076; private byte byItem077; private byte byItem078; private byte byItem079;
+ private byte byItem080; private byte byItem081; private byte byItem082; private byte byItem083;
+ private byte byItem084; private byte byItem085; private byte byItem086; private byte byItem087;
+ private byte byItem088; private byte byItem089; private byte byItem090; private byte byItem091;
+ private byte byItem092; private byte byItem093; private byte byItem094; private byte byItem095;
+ private byte byItem096; private byte byItem097; private byte byItem098; private byte byItem099;
+ private byte byItem100; private byte byItem101; private byte byItem102; private byte byItem103;
+ private byte byItem104; private byte byItem105; private byte byItem106; private byte byItem107;
+ private byte byItem108; private byte byItem109; private byte byItem110; private byte byItem111;
+ private byte byItem112; private byte byItem113; private byte byItem114; private byte byItem115;
+ private byte byItem116; private byte byItem117; private byte byItem118; private byte byItem119;
+ private byte byItem120; private byte byItem121; private byte byItem122; private byte byItem123;
+ private byte byItem124; private byte byItem125; private byte byItem126; private byte byItem127;
+ private byte byItem128; private byte byItem129;
+
+ ///
+ /// The normal get...
+ ///
+ ///
+ ///
+ public string Get(Encoding? encoding = null)
+ {
+ return (GetValue(true, encoding));
+ }
+
+ ///
+ /// Use this on Mac OS X if you have a call that uses a string
+ /// that doesn't include the prefix byte...
+ ///
+ ///
+ ///
+ public string GetNoPrefix(Encoding? encoding = null)
+ {
+ return (GetValue(false, encoding));
+ }
+
+ ///
+ /// Get our value...
+ ///
+ ///
+ ///
+ ///
+ private string GetValue(bool a_blMayHavePrefix, Encoding? encoding = null)
+ {
+ // convert what we have into a byte array
+ byte[] abyItem = new byte[130];
+ abyItem[0] = byItem000; abyItem[1] = byItem001; abyItem[2] = byItem002; abyItem[3] = byItem003;
+ abyItem[4] = byItem004; abyItem[5] = byItem005; abyItem[6] = byItem006; abyItem[7] = byItem007;
+ abyItem[8] = byItem008; abyItem[9] = byItem009; abyItem[10] = byItem010; abyItem[11] = byItem011;
+ abyItem[12] = byItem012; abyItem[13] = byItem013; abyItem[14] = byItem014; abyItem[15] = byItem015;
+ abyItem[16] = byItem016; abyItem[17] = byItem017; abyItem[18] = byItem018; abyItem[19] = byItem019;
+ abyItem[20] = byItem020; abyItem[21] = byItem021; abyItem[22] = byItem022; abyItem[23] = byItem023;
+ abyItem[24] = byItem024; abyItem[25] = byItem025; abyItem[26] = byItem026; abyItem[27] = byItem027;
+ abyItem[28] = byItem028; abyItem[29] = byItem029; abyItem[30] = byItem030; abyItem[31] = byItem031;
+ abyItem[32] = byItem032; abyItem[33] = byItem033; abyItem[34] = byItem034; abyItem[35] = byItem035;
+ abyItem[36] = byItem036; abyItem[37] = byItem037; abyItem[38] = byItem038; abyItem[39] = byItem039;
+ abyItem[40] = byItem040; abyItem[41] = byItem041; abyItem[42] = byItem042; abyItem[43] = byItem043;
+ abyItem[44] = byItem044; abyItem[45] = byItem045; abyItem[46] = byItem046; abyItem[47] = byItem047;
+ abyItem[48] = byItem048; abyItem[49] = byItem049; abyItem[50] = byItem050; abyItem[51] = byItem051;
+ abyItem[52] = byItem052; abyItem[53] = byItem053; abyItem[54] = byItem054; abyItem[55] = byItem055;
+ abyItem[56] = byItem056; abyItem[57] = byItem057; abyItem[58] = byItem058; abyItem[59] = byItem059;
+ abyItem[60] = byItem060; abyItem[61] = byItem061; abyItem[62] = byItem062; abyItem[63] = byItem063;
+ abyItem[64] = byItem064; abyItem[65] = byItem065; abyItem[66] = byItem066; abyItem[67] = byItem067;
+ abyItem[68] = byItem068; abyItem[69] = byItem069; abyItem[70] = byItem070; abyItem[71] = byItem071;
+ abyItem[72] = byItem072; abyItem[73] = byItem073; abyItem[74] = byItem074; abyItem[75] = byItem075;
+ abyItem[76] = byItem076; abyItem[77] = byItem077; abyItem[78] = byItem078; abyItem[79] = byItem079;
+ abyItem[80] = byItem080; abyItem[81] = byItem081; abyItem[82] = byItem082; abyItem[83] = byItem083;
+ abyItem[84] = byItem084; abyItem[85] = byItem085; abyItem[86] = byItem086; abyItem[87] = byItem087;
+ abyItem[88] = byItem088; abyItem[89] = byItem089; abyItem[90] = byItem090; abyItem[91] = byItem091;
+ abyItem[92] = byItem092; abyItem[93] = byItem093; abyItem[94] = byItem094; abyItem[95] = byItem095;
+ abyItem[96] = byItem096; abyItem[97] = byItem097; abyItem[98] = byItem098; abyItem[99] = byItem099;
+ abyItem[100] = byItem100; abyItem[101] = byItem101; abyItem[102] = byItem102; abyItem[103] = byItem103;
+ abyItem[104] = byItem104; abyItem[105] = byItem105; abyItem[106] = byItem106; abyItem[107] = byItem107;
+ abyItem[108] = byItem108; abyItem[109] = byItem109; abyItem[110] = byItem110; abyItem[111] = byItem111;
+ abyItem[112] = byItem112; abyItem[113] = byItem113; abyItem[114] = byItem114; abyItem[115] = byItem115;
+ abyItem[116] = byItem116; abyItem[117] = byItem117; abyItem[118] = byItem118; abyItem[119] = byItem119;
+ abyItem[120] = byItem120; abyItem[121] = byItem121; abyItem[122] = byItem122; abyItem[123] = byItem123;
+ abyItem[124] = byItem124; abyItem[125] = byItem125; abyItem[126] = byItem126; abyItem[127] = byItem127;
+ abyItem[128] = byItem128; abyItem[129] = byItem129;
+
+ // Zero anything after the NUL...
+ bool blNul = false;
+ for (int ii = 0; ii < abyItem.Length; ii++)
+ {
+ if (!blNul && (abyItem[ii] == 0))
+ {
+ blNul = true;
+ }
+ else if (blNul)
+ {
+ abyItem[ii] = 0;
+ }
+ }
+
+ // change encoding of byte array, then convert the bytes array to a string
+ string sz = Encoding.Unicode.GetString(Encoding.Convert(encoding ?? Language.GetEncoding(), Encoding.Unicode, abyItem));
+
+ // If the first character is a NUL, then return the empty string...
+ if (sz[0] == '\0')
+ {
+ return ("");
+ }
+
+ // If we're running on a Mac, take off the prefix 'byte'...
+ if (a_blMayHavePrefix && TWPlatform.IsMacOSX)
+ {
+ sz = sz.Remove(0, 1);
+ }
+
+ // If we detect a NUL, then split around it...
+ if (sz.IndexOf('\0') >= 0)
+ {
+ sz = sz.Split(new char[] { '\0' })[0];
+ }
+
+ // All done...
+ return (sz);
+ }
+
+ ///
+ /// The normal set...
+ ///
+ ///
+ ///
+ ///
+ public void Set(string a_sz, Encoding? encoding = null)
+ {
+ SetValue(a_sz, true, encoding);
+ }
+
+ ///
+ /// Use this on Mac OS X if you have a call that uses a string
+ /// that doesn't include the prefix byte...
+ ///
+ ///
+ ///
+ ///
+ public void SetNoPrefix(string a_sz, Encoding? encoding = null)
+ {
+ SetValue(a_sz, false, encoding);
+ }
+
+ ///
+ /// Set our value...
+ ///
+ ///
+ ///
+ ///
+ private void SetValue(string a_sz, bool a_blMayHavePrefix, Encoding? encoding = null)
+ {
+ // If we're running on a Mac, tack on the prefix 'byte'...
+ if (a_sz == null)
+ {
+ a_sz = "";
+ }
+ else if (a_blMayHavePrefix && TWPlatform.IsMacOSX)
+ {
+ a_sz = (char)a_sz.Length + a_sz;
+ }
+
+ // Make sure that we're NUL padded...
+ string sz =
+ a_sz +
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
+ "\0\0";
+ if (sz.Length > 130)
+ {
+ sz = sz.Remove(130);
+ }
+
+ // convert string to byte array, then change the encoding of the byte array
+ byte[] abyItem = Encoding.Convert(Encoding.Unicode, encoding ?? Language.GetEncoding(), Encoding.Unicode.GetBytes(sz));
+
+ // concert byte array to bytes
+ byItem000 = abyItem[0]; byItem001 = abyItem[1]; byItem002 = abyItem[2]; byItem003 = abyItem[3];
+ byItem004 = abyItem[4]; byItem005 = abyItem[5]; byItem006 = abyItem[6]; byItem007 = abyItem[7];
+ byItem008 = abyItem[8]; byItem009 = abyItem[9]; byItem010 = abyItem[10]; byItem011 = abyItem[11];
+ byItem012 = abyItem[12]; byItem013 = abyItem[13]; byItem014 = abyItem[14]; byItem015 = abyItem[15];
+ byItem016 = abyItem[16]; byItem017 = abyItem[17]; byItem018 = abyItem[18]; byItem019 = abyItem[19];
+ byItem020 = abyItem[20]; byItem021 = abyItem[21]; byItem022 = abyItem[22]; byItem023 = abyItem[23];
+ byItem024 = abyItem[24]; byItem025 = abyItem[25]; byItem026 = abyItem[26]; byItem027 = abyItem[27];
+ byItem028 = abyItem[28]; byItem029 = abyItem[29]; byItem030 = abyItem[30]; byItem031 = abyItem[31];
+ byItem032 = abyItem[32]; byItem033 = abyItem[33]; byItem034 = abyItem[34]; byItem035 = abyItem[35];
+ byItem036 = abyItem[36]; byItem037 = abyItem[37]; byItem038 = abyItem[38]; byItem039 = abyItem[39];
+ byItem040 = abyItem[40]; byItem041 = abyItem[41]; byItem042 = abyItem[42]; byItem043 = abyItem[43];
+ byItem044 = abyItem[44]; byItem045 = abyItem[45]; byItem046 = abyItem[46]; byItem047 = abyItem[47];
+ byItem048 = abyItem[48]; byItem049 = abyItem[49]; byItem050 = abyItem[50]; byItem051 = abyItem[51];
+ byItem052 = abyItem[52]; byItem053 = abyItem[53]; byItem054 = abyItem[54]; byItem055 = abyItem[55];
+ byItem056 = abyItem[56]; byItem057 = abyItem[57]; byItem058 = abyItem[58]; byItem059 = abyItem[59];
+ byItem060 = abyItem[60]; byItem061 = abyItem[61]; byItem062 = abyItem[62]; byItem063 = abyItem[63];
+ byItem064 = abyItem[64]; byItem065 = abyItem[65]; byItem066 = abyItem[66]; byItem067 = abyItem[67];
+ byItem068 = abyItem[68]; byItem069 = abyItem[69]; byItem070 = abyItem[70]; byItem071 = abyItem[71];
+ byItem072 = abyItem[72]; byItem073 = abyItem[73]; byItem074 = abyItem[74]; byItem075 = abyItem[75];
+ byItem076 = abyItem[76]; byItem077 = abyItem[77]; byItem078 = abyItem[78]; byItem079 = abyItem[79];
+ byItem080 = abyItem[80]; byItem081 = abyItem[81]; byItem082 = abyItem[82]; byItem083 = abyItem[83];
+ byItem084 = abyItem[84]; byItem085 = abyItem[85]; byItem086 = abyItem[86]; byItem087 = abyItem[87];
+ byItem088 = abyItem[88]; byItem089 = abyItem[89]; byItem090 = abyItem[90]; byItem091 = abyItem[91];
+ byItem092 = abyItem[92]; byItem093 = abyItem[93]; byItem094 = abyItem[94]; byItem095 = abyItem[95];
+ byItem096 = abyItem[96]; byItem097 = abyItem[97]; byItem098 = abyItem[98]; byItem099 = abyItem[99];
+ byItem100 = abyItem[100]; byItem101 = abyItem[101]; byItem102 = abyItem[102]; byItem103 = abyItem[103];
+ byItem104 = abyItem[104]; byItem105 = abyItem[105]; byItem106 = abyItem[106]; byItem107 = abyItem[107];
+ byItem108 = abyItem[108]; byItem109 = abyItem[109]; byItem110 = abyItem[110]; byItem111 = abyItem[111];
+ byItem112 = abyItem[112]; byItem113 = abyItem[113]; byItem114 = abyItem[114]; byItem115 = abyItem[115];
+ byItem116 = abyItem[116]; byItem117 = abyItem[117]; byItem118 = abyItem[118]; byItem119 = abyItem[119];
+ byItem120 = abyItem[120]; byItem121 = abyItem[121]; byItem122 = abyItem[122]; byItem123 = abyItem[123];
+ byItem124 = abyItem[124]; byItem125 = abyItem[125]; byItem126 = abyItem[126]; byItem127 = abyItem[127];
+ byItem128 = abyItem[128]; byItem129 = abyItem[129];
+ }
+}
+
+///
+/// Used for strings that go up to 256-bytes...
+///
+[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
+public partial struct TW_STR255
+{
+ ///
+ /// We're stuck with this, because marshalling with packed alignment
+ /// can't handle arrays...
+ ///
+ private byte byItem000; private byte byItem001; private byte byItem002; private byte byItem003;
+ private byte byItem004; private byte byItem005; private byte byItem006; private byte byItem007;
+ private byte byItem008; private byte byItem009; private byte byItem010; private byte byItem011;
+ private byte byItem012; private byte byItem013; private byte byItem014; private byte byItem015;
+ private byte byItem016; private byte byItem017; private byte byItem018; private byte byItem019;
+ private byte byItem020; private byte byItem021; private byte byItem022; private byte byItem023;
+ private byte byItem024; private byte byItem025; private byte byItem026; private byte byItem027;
+ private byte byItem028; private byte byItem029; private byte byItem030; private byte byItem031;
+ private byte byItem032; private byte byItem033; private byte byItem034; private byte byItem035;
+ private byte byItem036; private byte byItem037; private byte byItem038; private byte byItem039;
+ private byte byItem040; private byte byItem041; private byte byItem042; private byte byItem043;
+ private byte byItem044; private byte byItem045; private byte byItem046; private byte byItem047;
+ private byte byItem048; private byte byItem049; private byte byItem050; private byte byItem051;
+ private byte byItem052; private byte byItem053; private byte byItem054; private byte byItem055;
+ private byte byItem056; private byte byItem057; private byte byItem058; private byte byItem059;
+ private byte byItem060; private byte byItem061; private byte byItem062; private byte byItem063;
+ private byte byItem064; private byte byItem065; private byte byItem066; private byte byItem067;
+ private byte byItem068; private byte byItem069; private byte byItem070; private byte byItem071;
+ private byte byItem072; private byte byItem073; private byte byItem074; private byte byItem075;
+ private byte byItem076; private byte byItem077; private byte byItem078; private byte byItem079;
+ private byte byItem080; private byte byItem081; private byte byItem082; private byte byItem083;
+ private byte byItem084; private byte byItem085; private byte byItem086; private byte byItem087;
+ private byte byItem088; private byte byItem089; private byte byItem090; private byte byItem091;
+ private byte byItem092; private byte byItem093; private byte byItem094; private byte byItem095;
+ private byte byItem096; private byte byItem097; private byte byItem098; private byte byItem099;
+ private byte byItem100; private byte byItem101; private byte byItem102; private byte byItem103;
+ private byte byItem104; private byte byItem105; private byte byItem106; private byte byItem107;
+ private byte byItem108; private byte byItem109; private byte byItem110; private byte byItem111;
+ private byte byItem112; private byte byItem113; private byte byItem114; private byte byItem115;
+ private byte byItem116; private byte byItem117; private byte byItem118; private byte byItem119;
+ private byte byItem120; private byte byItem121; private byte byItem122; private byte byItem123;
+ private byte byItem124; private byte byItem125; private byte byItem126; private byte byItem127;
+ private byte byItem128; private byte byItem129; private byte byItem130; private byte byItem131;
+ private byte byItem132; private byte byItem133; private byte byItem134; private byte byItem135;
+ private byte byItem136; private byte byItem137; private byte byItem138; private byte byItem139;
+ private byte byItem140; private byte byItem141; private byte byItem142; private byte byItem143;
+ private byte byItem144; private byte byItem145; private byte byItem146; private byte byItem147;
+ private byte byItem148; private byte byItem149; private byte byItem150; private byte byItem151;
+ private byte byItem152; private byte byItem153; private byte byItem154; private byte byItem155;
+ private byte byItem156; private byte byItem157; private byte byItem158; private byte byItem159;
+ private byte byItem160; private byte byItem161; private byte byItem162; private byte byItem163;
+ private byte byItem164; private byte byItem165; private byte byItem166; private byte byItem167;
+ private byte byItem168; private byte byItem169; private byte byItem170; private byte byItem171;
+ private byte byItem172; private byte byItem173; private byte byItem174; private byte byItem175;
+ private byte byItem176; private byte byItem177; private byte byItem178; private byte byItem179;
+ private byte byItem180; private byte byItem181; private byte byItem182; private byte byItem183;
+ private byte byItem184; private byte byItem185; private byte byItem186; private byte byItem187;
+ private byte byItem188; private byte byItem189; private byte byItem190; private byte byItem191;
+ private byte byItem192; private byte byItem193; private byte byItem194; private byte byItem195;
+ private byte byItem196; private byte byItem197; private byte byItem198; private byte byItem199;
+ private byte byItem200; private byte byItem201; private byte byItem202; private byte byItem203;
+ private byte byItem204; private byte byItem205; private byte byItem206; private byte byItem207;
+ private byte byItem208; private byte byItem209; private byte byItem210; private byte byItem211;
+ private byte byItem212; private byte byItem213; private byte byItem214; private byte byItem215;
+ private byte byItem216; private byte byItem217; private byte byItem218; private byte byItem219;
+ private byte byItem220; private byte byItem221; private byte byItem222; private byte byItem223;
+ private byte byItem224; private byte byItem225; private byte byItem226; private byte byItem227;
+ private byte byItem228; private byte byItem229; private byte byItem230; private byte byItem231;
+ private byte byItem232; private byte byItem233; private byte byItem234; private byte byItem235;
+ private byte byItem236; private byte byItem237; private byte byItem238; private byte byItem239;
+ private byte byItem240; private byte byItem241; private byte byItem242; private byte byItem243;
+ private byte byItem244; private byte byItem245; private byte byItem246; private byte byItem247;
+ private byte byItem248; private byte byItem249; private byte byItem250; private byte byItem251;
+ private byte byItem252; private byte byItem253; private byte byItem254; private byte byItem255;
+
+ ///
+ /// The normal get...
+ ///
+ ///
+ ///
+ public string Get(Encoding? encoding = null)
+ {
+ return (GetValue(true, encoding));
+ }
+
+ ///
+ /// Use this on Mac OS X if you have a call that uses a string
+ /// that doesn't include the prefix byte...
+ ///
+ ///
+ ///
+ public string GetNoPrefix(Encoding? encoding = null)
+ {
+ return (GetValue(false, encoding));
+ }
+
+ ///
+ /// Get our value...
+ ///
+ ///
+ ///
+ ///
+ private string GetValue(bool a_blMayHavePrefix, Encoding? encoding = null)
+ {
+ // convert what we have into a byte array
+ byte[] abyItem = new byte[256];
+ abyItem[0] = byItem000; abyItem[1] = byItem001; abyItem[2] = byItem002; abyItem[3] = byItem003;
+ abyItem[4] = byItem004; abyItem[5] = byItem005; abyItem[6] = byItem006; abyItem[7] = byItem007;
+ abyItem[8] = byItem008; abyItem[9] = byItem009; abyItem[10] = byItem010; abyItem[11] = byItem011;
+ abyItem[12] = byItem012; abyItem[13] = byItem013; abyItem[14] = byItem014; abyItem[15] = byItem015;
+ abyItem[16] = byItem016; abyItem[17] = byItem017; abyItem[18] = byItem018; abyItem[19] = byItem019;
+ abyItem[20] = byItem020; abyItem[21] = byItem021; abyItem[22] = byItem022; abyItem[23] = byItem023;
+ abyItem[24] = byItem024; abyItem[25] = byItem025; abyItem[26] = byItem026; abyItem[27] = byItem027;
+ abyItem[28] = byItem028; abyItem[29] = byItem029; abyItem[30] = byItem030; abyItem[31] = byItem031;
+ abyItem[32] = byItem032; abyItem[33] = byItem033; abyItem[34] = byItem034; abyItem[35] = byItem035;
+ abyItem[36] = byItem036; abyItem[37] = byItem037; abyItem[38] = byItem038; abyItem[39] = byItem039;
+ abyItem[40] = byItem040; abyItem[41] = byItem041; abyItem[42] = byItem042; abyItem[43] = byItem043;
+ abyItem[44] = byItem044; abyItem[45] = byItem045; abyItem[46] = byItem046; abyItem[47] = byItem047;
+ abyItem[48] = byItem048; abyItem[49] = byItem049; abyItem[50] = byItem050; abyItem[51] = byItem051;
+ abyItem[52] = byItem052; abyItem[53] = byItem053; abyItem[54] = byItem054; abyItem[55] = byItem055;
+ abyItem[56] = byItem056; abyItem[57] = byItem057; abyItem[58] = byItem058; abyItem[59] = byItem059;
+ abyItem[60] = byItem060; abyItem[61] = byItem061; abyItem[62] = byItem062; abyItem[63] = byItem063;
+ abyItem[64] = byItem064; abyItem[65] = byItem065; abyItem[66] = byItem066; abyItem[67] = byItem067;
+ abyItem[68] = byItem068; abyItem[69] = byItem069; abyItem[70] = byItem070; abyItem[71] = byItem071;
+ abyItem[72] = byItem072; abyItem[73] = byItem073; abyItem[74] = byItem074; abyItem[75] = byItem075;
+ abyItem[76] = byItem076; abyItem[77] = byItem077; abyItem[78] = byItem078; abyItem[79] = byItem079;
+ abyItem[80] = byItem080; abyItem[81] = byItem081; abyItem[82] = byItem082; abyItem[83] = byItem083;
+ abyItem[84] = byItem084; abyItem[85] = byItem085; abyItem[86] = byItem086; abyItem[87] = byItem087;
+ abyItem[88] = byItem088; abyItem[89] = byItem089; abyItem[90] = byItem090; abyItem[91] = byItem091;
+ abyItem[92] = byItem092; abyItem[93] = byItem093; abyItem[94] = byItem094; abyItem[95] = byItem095;
+ abyItem[96] = byItem096; abyItem[97] = byItem097; abyItem[98] = byItem098; abyItem[99] = byItem099;
+ abyItem[100] = byItem100; abyItem[101] = byItem101; abyItem[102] = byItem102; abyItem[103] = byItem103;
+ abyItem[104] = byItem104; abyItem[105] = byItem105; abyItem[106] = byItem106; abyItem[107] = byItem107;
+ abyItem[108] = byItem108; abyItem[109] = byItem109; abyItem[110] = byItem110; abyItem[111] = byItem111;
+ abyItem[112] = byItem112; abyItem[113] = byItem113; abyItem[114] = byItem114; abyItem[115] = byItem115;
+ abyItem[116] = byItem116; abyItem[117] = byItem117; abyItem[118] = byItem118; abyItem[119] = byItem119;
+ abyItem[120] = byItem120; abyItem[121] = byItem121; abyItem[122] = byItem122; abyItem[123] = byItem123;
+ abyItem[124] = byItem124; abyItem[125] = byItem125; abyItem[126] = byItem126; abyItem[127] = byItem127;
+ abyItem[128] = byItem128; abyItem[129] = byItem129; abyItem[130] = byItem130; abyItem[131] = byItem131;
+ abyItem[132] = byItem132; abyItem[133] = byItem133; abyItem[134] = byItem134; abyItem[135] = byItem135;
+ abyItem[136] = byItem136; abyItem[137] = byItem137; abyItem[138] = byItem138; abyItem[139] = byItem139;
+ abyItem[140] = byItem140; abyItem[141] = byItem141; abyItem[142] = byItem142; abyItem[143] = byItem143;
+ abyItem[144] = byItem144; abyItem[145] = byItem145; abyItem[146] = byItem146; abyItem[147] = byItem147;
+ abyItem[148] = byItem148; abyItem[149] = byItem149; abyItem[150] = byItem150; abyItem[151] = byItem151;
+ abyItem[152] = byItem152; abyItem[153] = byItem153; abyItem[154] = byItem154; abyItem[155] = byItem155;
+ abyItem[156] = byItem156; abyItem[157] = byItem157; abyItem[158] = byItem158; abyItem[159] = byItem159;
+ abyItem[160] = byItem160; abyItem[161] = byItem161; abyItem[162] = byItem162; abyItem[163] = byItem163;
+ abyItem[164] = byItem164; abyItem[165] = byItem165; abyItem[166] = byItem166; abyItem[167] = byItem167;
+ abyItem[168] = byItem168; abyItem[169] = byItem169; abyItem[170] = byItem170; abyItem[171] = byItem171;
+ abyItem[172] = byItem172; abyItem[173] = byItem173; abyItem[174] = byItem174; abyItem[175] = byItem175;
+ abyItem[176] = byItem176; abyItem[177] = byItem177; abyItem[178] = byItem178; abyItem[179] = byItem179;
+ abyItem[180] = byItem180; abyItem[181] = byItem181; abyItem[182] = byItem182; abyItem[183] = byItem183;
+ abyItem[184] = byItem184; abyItem[185] = byItem185; abyItem[186] = byItem186; abyItem[187] = byItem187;
+ abyItem[188] = byItem188; abyItem[189] = byItem189; abyItem[190] = byItem190; abyItem[191] = byItem191;
+ abyItem[192] = byItem192; abyItem[193] = byItem193; abyItem[194] = byItem194; abyItem[195] = byItem195;
+ abyItem[196] = byItem196; abyItem[197] = byItem197; abyItem[198] = byItem198; abyItem[199] = byItem199;
+ abyItem[200] = byItem200; abyItem[201] = byItem201; abyItem[202] = byItem202; abyItem[203] = byItem203;
+ abyItem[204] = byItem204; abyItem[205] = byItem205; abyItem[206] = byItem206; abyItem[207] = byItem207;
+ abyItem[208] = byItem208; abyItem[209] = byItem209; abyItem[210] = byItem210; abyItem[211] = byItem211;
+ abyItem[212] = byItem212; abyItem[213] = byItem213; abyItem[214] = byItem214; abyItem[215] = byItem215;
+ abyItem[216] = byItem216; abyItem[217] = byItem217; abyItem[218] = byItem218; abyItem[219] = byItem219;
+ abyItem[220] = byItem220; abyItem[221] = byItem221; abyItem[222] = byItem222; abyItem[223] = byItem223;
+ abyItem[224] = byItem224; abyItem[225] = byItem225; abyItem[226] = byItem226; abyItem[227] = byItem227;
+ abyItem[228] = byItem228; abyItem[229] = byItem229; abyItem[230] = byItem230; abyItem[231] = byItem231;
+ abyItem[232] = byItem232; abyItem[233] = byItem233; abyItem[234] = byItem234; abyItem[235] = byItem235;
+ abyItem[236] = byItem236; abyItem[237] = byItem237; abyItem[238] = byItem238; abyItem[239] = byItem239;
+ abyItem[240] = byItem240; abyItem[241] = byItem241; abyItem[242] = byItem242; abyItem[243] = byItem243;
+ abyItem[244] = byItem244; abyItem[245] = byItem245; abyItem[246] = byItem246; abyItem[247] = byItem247;
+ abyItem[248] = byItem248; abyItem[249] = byItem249; abyItem[250] = byItem250; abyItem[251] = byItem251;
+ abyItem[252] = byItem252; abyItem[253] = byItem253; abyItem[254] = byItem254; abyItem[255] = byItem255;
+
+ // Zero anything after the NUL...
+ bool blNul = false;
+ for (int ii = 0; ii < abyItem.Length; ii++)
+ {
+ if (!blNul && (abyItem[ii] == 0))
+ {
+ blNul = true;
+ }
+ else if (blNul)
+ {
+ abyItem[ii] = 0;
+ }
+ }
+
+ // change encoding of byte array, then convert the bytes array to a string
+ string sz = Encoding.Unicode.GetString(Encoding.Convert(encoding ?? Language.GetEncoding(), Encoding.Unicode, abyItem));
+
+ // If the first character is a NUL, then return the empty string...
+ if (sz[0] == '\0')
+ {
+ return ("");
+ }
+
+ // If we're running on a Mac, take off the prefix 'byte'...
+ if (a_blMayHavePrefix && TWPlatform.IsMacOSX)
+ {
+ sz = sz.Remove(0, 1);
+ }
+
+ // If we detect a NUL, then split around it...
+ if (sz.IndexOf('\0') >= 0)
+ {
+ sz = sz.Split(new char[] { '\0' })[0];
+ }
+
+ // All done...
+ return (sz);
+ }
+
+ ///
+ /// The normal set...
+ ///
+ ///
+ ///
+ ///
+ public void Set(string a_sz, Encoding? encoding = null)
+ {
+ SetValue(a_sz, true, encoding);
+ }
+
+ ///
+ /// Use this on Mac OS X if you have a call that uses a string
+ /// that doesn't include the prefix byte...
+ ///
+ ///
+ ///
+ ///
+ public void SetNoPrefix(string a_sz, Encoding? encoding = null)
+ {
+ SetValue(a_sz, false, encoding);
+ }
+
+ ///
+ /// Set our value...
+ ///
+ ///
+ ///
+ ///
+ private void SetValue(string a_sz, bool a_blMayHavePrefix, Encoding? encoding = null)
+ {
+ // If we're running on a Mac, tack on the prefix 'byte'...
+ if (a_sz == null)
+ {
+ a_sz = "";
+ }
+ else if (a_blMayHavePrefix && TWPlatform.IsMacOSX)
+ {
+ a_sz = (char)a_sz.Length + a_sz;
+ }
+
+ // Make sure that we're NUL padded...
+ string sz =
+ a_sz +
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" +
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
+ if (sz.Length > 256)
+ {
+ sz = sz.Remove(256);
+ }
+
+ // convert string to byte array, then change the encoding of the byte array
+ byte[] abyItem = Encoding.Convert(Encoding.Unicode, encoding ?? Language.GetEncoding(), Encoding.Unicode.GetBytes(sz));
+
+ // concert byte array to bytes
+ byItem000 = abyItem[0]; byItem001 = abyItem[1]; byItem002 = abyItem[2]; byItem003 = abyItem[3];
+ byItem004 = abyItem[4]; byItem005 = abyItem[5]; byItem006 = abyItem[6]; byItem007 = abyItem[7];
+ byItem008 = abyItem[8]; byItem009 = abyItem[9]; byItem010 = abyItem[10]; byItem011 = abyItem[11];
+ byItem012 = abyItem[12]; byItem013 = abyItem[13]; byItem014 = abyItem[14]; byItem015 = abyItem[15];
+ byItem016 = abyItem[16]; byItem017 = abyItem[17]; byItem018 = abyItem[18]; byItem019 = abyItem[19];
+ byItem020 = abyItem[20]; byItem021 = abyItem[21]; byItem022 = abyItem[22]; byItem023 = abyItem[23];
+ byItem024 = abyItem[24]; byItem025 = abyItem[25]; byItem026 = abyItem[26]; byItem027 = abyItem[27];
+ byItem028 = abyItem[28]; byItem029 = abyItem[29]; byItem030 = abyItem[30]; byItem031 = abyItem[31];
+ byItem032 = abyItem[32]; byItem033 = abyItem[33]; byItem034 = abyItem[34]; byItem035 = abyItem[35];
+ byItem036 = abyItem[36]; byItem037 = abyItem[37]; byItem038 = abyItem[38]; byItem039 = abyItem[39];
+ byItem040 = abyItem[40]; byItem041 = abyItem[41]; byItem042 = abyItem[42]; byItem043 = abyItem[43];
+ byItem044 = abyItem[44]; byItem045 = abyItem[45]; byItem046 = abyItem[46]; byItem047 = abyItem[47];
+ byItem048 = abyItem[48]; byItem049 = abyItem[49]; byItem050 = abyItem[50]; byItem051 = abyItem[51];
+ byItem052 = abyItem[52]; byItem053 = abyItem[53]; byItem054 = abyItem[54]; byItem055 = abyItem[55];
+ byItem056 = abyItem[56]; byItem057 = abyItem[57]; byItem058 = abyItem[58]; byItem059 = abyItem[59];
+ byItem060 = abyItem[60]; byItem061 = abyItem[61]; byItem062 = abyItem[62]; byItem063 = abyItem[63];
+ byItem064 = abyItem[64]; byItem065 = abyItem[65]; byItem066 = abyItem[66]; byItem067 = abyItem[67];
+ byItem068 = abyItem[68]; byItem069 = abyItem[69]; byItem070 = abyItem[70]; byItem071 = abyItem[71];
+ byItem072 = abyItem[72]; byItem073 = abyItem[73]; byItem074 = abyItem[74]; byItem075 = abyItem[75];
+ byItem076 = abyItem[76]; byItem077 = abyItem[77]; byItem078 = abyItem[78]; byItem079 = abyItem[79];
+ byItem080 = abyItem[80]; byItem081 = abyItem[81]; byItem082 = abyItem[82]; byItem083 = abyItem[83];
+ byItem084 = abyItem[84]; byItem085 = abyItem[85]; byItem086 = abyItem[86]; byItem087 = abyItem[87];
+ byItem088 = abyItem[88]; byItem089 = abyItem[89]; byItem090 = abyItem[90]; byItem091 = abyItem[91];
+ byItem092 = abyItem[92]; byItem093 = abyItem[93]; byItem094 = abyItem[94]; byItem095 = abyItem[95];
+ byItem096 = abyItem[96]; byItem097 = abyItem[97]; byItem098 = abyItem[98]; byItem099 = abyItem[99];
+ byItem100 = abyItem[100]; byItem101 = abyItem[101]; byItem102 = abyItem[102]; byItem103 = abyItem[103];
+ byItem104 = abyItem[104]; byItem105 = abyItem[105]; byItem106 = abyItem[106]; byItem107 = abyItem[107];
+ byItem108 = abyItem[108]; byItem109 = abyItem[109]; byItem110 = abyItem[110]; byItem111 = abyItem[111];
+ byItem112 = abyItem[112]; byItem113 = abyItem[113]; byItem114 = abyItem[114]; byItem115 = abyItem[115];
+ byItem116 = abyItem[116]; byItem117 = abyItem[117]; byItem118 = abyItem[118]; byItem119 = abyItem[119];
+ byItem120 = abyItem[120]; byItem121 = abyItem[121]; byItem122 = abyItem[122]; byItem123 = abyItem[123];
+ byItem124 = abyItem[124]; byItem125 = abyItem[125]; byItem126 = abyItem[126]; byItem127 = abyItem[127];
+ byItem128 = abyItem[128]; byItem129 = abyItem[129]; byItem130 = abyItem[130]; byItem131 = abyItem[131];
+ byItem132 = abyItem[132]; byItem133 = abyItem[133]; byItem134 = abyItem[134]; byItem135 = abyItem[135];
+ byItem136 = abyItem[136]; byItem137 = abyItem[137]; byItem138 = abyItem[138]; byItem139 = abyItem[139];
+ byItem140 = abyItem[140]; byItem141 = abyItem[141]; byItem142 = abyItem[142]; byItem143 = abyItem[143];
+ byItem144 = abyItem[144]; byItem145 = abyItem[145]; byItem146 = abyItem[146]; byItem147 = abyItem[147];
+ byItem148 = abyItem[148]; byItem149 = abyItem[149]; byItem150 = abyItem[150]; byItem151 = abyItem[151];
+ byItem152 = abyItem[152]; byItem153 = abyItem[153]; byItem154 = abyItem[154]; byItem155 = abyItem[155];
+ byItem156 = abyItem[156]; byItem157 = abyItem[157]; byItem158 = abyItem[158]; byItem159 = abyItem[159];
+ byItem160 = abyItem[160]; byItem161 = abyItem[161]; byItem162 = abyItem[162]; byItem163 = abyItem[163];
+ byItem164 = abyItem[164]; byItem165 = abyItem[165]; byItem166 = abyItem[166]; byItem167 = abyItem[167];
+ byItem168 = abyItem[168]; byItem169 = abyItem[169]; byItem170 = abyItem[170]; byItem171 = abyItem[171];
+ byItem172 = abyItem[172]; byItem173 = abyItem[173]; byItem174 = abyItem[174]; byItem175 = abyItem[175];
+ byItem176 = abyItem[176]; byItem177 = abyItem[177]; byItem178 = abyItem[178]; byItem179 = abyItem[179];
+ byItem180 = abyItem[180]; byItem181 = abyItem[181]; byItem182 = abyItem[182]; byItem183 = abyItem[183];
+ byItem184 = abyItem[184]; byItem185 = abyItem[185]; byItem186 = abyItem[186]; byItem187 = abyItem[187];
+ byItem188 = abyItem[188]; byItem189 = abyItem[189]; byItem190 = abyItem[190]; byItem191 = abyItem[191];
+ byItem192 = abyItem[192]; byItem193 = abyItem[193]; byItem194 = abyItem[194]; byItem195 = abyItem[195];
+ byItem196 = abyItem[196]; byItem197 = abyItem[197]; byItem198 = abyItem[198]; byItem199 = abyItem[199];
+ byItem200 = abyItem[200]; byItem201 = abyItem[201]; byItem202 = abyItem[202]; byItem203 = abyItem[203];
+ byItem204 = abyItem[204]; byItem205 = abyItem[205]; byItem206 = abyItem[206]; byItem207 = abyItem[207];
+ byItem208 = abyItem[208]; byItem209 = abyItem[209]; byItem210 = abyItem[210]; byItem211 = abyItem[211];
+ byItem212 = abyItem[212]; byItem213 = abyItem[213]; byItem214 = abyItem[214]; byItem215 = abyItem[215];
+ byItem216 = abyItem[216]; byItem217 = abyItem[217]; byItem218 = abyItem[218]; byItem219 = abyItem[219];
+ byItem220 = abyItem[220]; byItem221 = abyItem[221]; byItem222 = abyItem[222]; byItem223 = abyItem[223];
+ byItem224 = abyItem[224]; byItem225 = abyItem[225]; byItem226 = abyItem[226]; byItem227 = abyItem[227];
+ byItem228 = abyItem[228]; byItem229 = abyItem[229]; byItem230 = abyItem[230]; byItem231 = abyItem[231];
+ byItem232 = abyItem[232]; byItem233 = abyItem[233]; byItem234 = abyItem[234]; byItem235 = abyItem[235];
+ byItem236 = abyItem[236]; byItem237 = abyItem[237]; byItem238 = abyItem[238]; byItem239 = abyItem[239];
+ byItem240 = abyItem[240]; byItem241 = abyItem[241]; byItem242 = abyItem[242]; byItem243 = abyItem[243];
+ byItem244 = abyItem[244]; byItem245 = abyItem[245]; byItem246 = abyItem[246]; byItem247 = abyItem[247];
+ byItem248 = abyItem[248]; byItem249 = abyItem[249]; byItem250 = abyItem[250]; byItem251 = abyItem[251];
+ byItem252 = abyItem[252]; byItem253 = abyItem[253]; byItem254 = abyItem[254]; byItem255 = abyItem[255];
+ }
+}
+
+#endregion
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Structure Definitions...
+///////////////////////////////////////////////////////////////////////////////
+#region Structure Definitions..
+
+///
+/// Fixed point structure type.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public partial struct TW_FIX32
+{
+ public short Whole;
+ public ushort Frac;
+}
+
+///
+/// Defines a frame rectangle in ICAP_UNITS coordinates.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public partial struct TW_FRAME
+{
+ public TW_FIX32 Left;
+ public TW_FIX32 Top;
+ public TW_FIX32 Right;
+ public TW_FIX32 Bottom;
+}
+
+///
+/// Defines the parameters used for channel-specific transformation.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_DECODEFUNCTION
+{
+ public TW_FIX32 StartIn;
+ public TW_FIX32 BreakIn;
+ public TW_FIX32 EndIn;
+ public TW_FIX32 StartOut;
+ public TW_FIX32 BreakOut;
+ public TW_FIX32 EndOut;
+ public TW_FIX32 Gamma;
+ public TW_FIX32 SampleCount;
+}
+
+///
+/// Stores a Fixed point number in two parts, a whole and a fractional part.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_TRANSFORMSTAGE
+{
+ public TW_DECODEFUNCTION Decode_0;
+ public TW_DECODEFUNCTION Decode_1;
+ public TW_DECODEFUNCTION Decode_2;
+ public TW_FIX32 Mix_0_0;
+ public TW_FIX32 Mix_0_1;
+ public TW_FIX32 Mix_0_2;
+ public TW_FIX32 Mix_1_0;
+ public TW_FIX32 Mix_1_1;
+ public TW_FIX32 Mix_1_2;
+ public TW_FIX32 Mix_2_0;
+ public TW_FIX32 Mix_2_1;
+ public TW_FIX32 Mix_2_2;
+}
+
+///
+/// Stores a list of values for a capability, the ItemList is commented
+/// out so that the caller can collect information about it with a
+/// marshalling call...
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_ARRAY
+{
+ public TWTY ItemType;
+ public uint NumItems;
+ //public byte[] ItemList;
+}
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_ARRAY_MACOSX
+{
+ public uint ItemType;
+ public uint NumItems;
+ //public byte[] ItemList;
+}
+
+///
+/// Information about audio data.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_AUDIOINFO
+{
+ public TW_STR255 Name;
+ public uint Reserved;
+}
+
+///
+/// Used to register callbacks.
+///
+[SuppressMessage("Microsoft.Design", "CA1049:TypesThatOwnNativeResourcesShouldBeDisposable")]
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_CALLBACK
+{
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr CallBackProc;
+ public uint RefCon;
+ public ushort Message;
+}
+
+///
+/// Used to register callbacks.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_CALLBACK2
+{
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr CallBackProc;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public UIntPtr RefCon;
+ public ushort Message;
+}
+
+///
+/// Used by application to get/set capability from/in a data source.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
+public partial struct TW_CAPABILITY
+{
+ public CAP Cap;
+ public TWON ConType;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr hContainer;
+}
+
+///
+/// Defines a CIE XYZ space tri-stimulus value.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_CIEPOINT
+{
+ public TW_FIX32 X;
+ public TW_FIX32 Y;
+ public TW_FIX32 Z;
+}
+
+///
+/// Defines the mapping from an RGB color space device into CIE 1931 (XYZ) color space.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_CIECOLOR
+{
+ public ushort ColorSpace;
+ public short LowEndian;
+ public short DeviceDependent;
+ public int VersionNumber;
+ public TW_TRANSFORMSTAGE StageABC;
+ public TW_TRANSFORMSTAGE StageLNM;
+ public TW_CIEPOINT WhitePoint;
+ public TW_CIEPOINT BlackPoint;
+ public TW_CIEPOINT WhitePaper;
+ public TW_CIEPOINT BlackInk;
+ public TW_FIX32 Samples;
+}
+
+///
+/// Allows for a data source and application to pass custom data to each other.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_CUSTOMDSDATA
+{
+ public uint InfoLength;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr hData;
+}
+
+///
+/// Provides information about the Event that was raised by the Source.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public partial struct TW_DEVICEEVENT
+{
+ private uint _Event;
+ public TW_STR255 DeviceName;
+ public uint BatteryMinutes;
+ public short BatteryPercentage;
+ public int PowerSupply;
+ public TW_FIX32 XResolution;
+ public TW_FIX32 YResolution;
+ private uint _FlashUsed2;
+ public uint AutomaticCapture;
+ public uint TimeBeforeFirstCapture;
+ public uint TimeBetweenCaptures;
+}
+
+///
+/// This structure holds the tri-stimulus color palette information for TW_PALETTE8 structures.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_ELEMENT8
+{
+ public byte Index;
+ public byte Channel1;
+ public byte Channel2;
+ public byte Channel3;
+}
+
+///
+/// DAT_ENTRYPOINT. returns essential entry points.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_ENTRYPOINT
+{
+ public UInt32 Size;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr DSM_Entry;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr DSM_MemAllocate;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr DSM_MemFree;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr DSM_MemLock;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr DSM_MemUnlock;
+}
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_ENTRYPOINT_LINUX64
+{
+ public long Size;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr DSM_Entry;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr DSM_MemAllocate;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr DSM_MemFree;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr DSM_MemLock;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr DSM_MemUnlock;
+}
+public partial struct TW_ENTRYPOINT_DELEGATES
+{
+ public UInt32 Size;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr DSM_Entry;
+ public DSM_MEMALLOC DSM_MemAllocate;
+ public DSM_MEMFREE DSM_MemFree;
+ public DSM_MEMLOCK DSM_MemLock;
+ public DSM_MEMUNLOCK DSM_MemUnlock;
+}
+public delegate IntPtr DSM_MEMALLOC(uint size);
+public delegate void DSM_MEMFREE(IntPtr handle);
+public delegate IntPtr DSM_MEMLOCK(IntPtr handle);
+public delegate void DSM_MEMUNLOCK(IntPtr handle);
+
+///
+/// Stores a group of enumerated values for a capability, the ItemList is
+/// commented out so that the caller can collect information about it with
+/// a marshalling call...
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_ENUMERATION
+{
+ public TWTY ItemType;
+ public uint NumItems;
+ public uint CurrentIndex;
+ public uint DefaultIndex;
+ //public byte[] ItemList;
+}
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_ENUMERATION_LINUX64
+{
+ public TWTY ItemType;
+ public ulong NumItems;
+ public ulong CurrentIndex;
+ public ulong DefaultIndex;
+ //public byte[] ItemList;
+}
+[StructLayout(LayoutKind.Sequential, Pack = 4)]
+public struct TW_ENUMERATION_MACOSX
+{
+ public uint ItemType;
+ public uint NumItems;
+ public uint CurrentIndex;
+ public uint DefaultIndex;
+ //public byte[] ItemList;
+}
+
+///
+/// Used to pass application events/messages from the application to the Source.
+///
+[SuppressMessage("Microsoft.Design", "CA1049:TypesThatOwnNativeResourcesShouldBeDisposable")]
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_EVENT
+{
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr pEvent;
+ //public ushort TWMessage;
+ public MSG TWMessage;
+}
+
+///
+/// DAT_FILTER...
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_FILTER_DESCRIPTOR
+{
+ public UInt32 Size;
+ public UInt32 HueStart;
+ public UInt32 HueEnd;
+ public UInt32 SaturationStart;
+ public UInt32 SaturationEnd;
+ public UInt32 ValueStart;
+ public UInt32 ValueEnd;
+ public UInt32 Replacement;
+}
+
+///
+/// DAT_FILTER...
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_FILTER
+{
+ public UInt32 Size;
+ public UInt32 DescriptorCount;
+ public UInt32 MaxDescriptorCount;
+ public UInt32 Condition;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr hDescriptors;
+}
+
+///
+/// This structure is used to pass specific information between the data source and the application.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public partial struct TW_INFO
+{
+ public TWEI InfoId;
+ public TWTY ItemType;
+ public ushort NumItems;
+ public TWRC ReturnCode;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public UIntPtr Item;
+}
+
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public partial struct TW_EXTIMAGEINFO
+{
+ private uint NumInfos;
+ private TW_INFO Info_000;
+ private TW_INFO Info_001;
+ private TW_INFO Info_002;
+ private TW_INFO Info_003;
+ private TW_INFO Info_004;
+ private TW_INFO Info_005;
+ private TW_INFO Info_006;
+ private TW_INFO Info_007;
+ private TW_INFO Info_008;
+ private TW_INFO Info_009;
+ private TW_INFO Info_010;
+ private TW_INFO Info_011;
+ private TW_INFO Info_012;
+ private TW_INFO Info_013;
+ private TW_INFO Info_014;
+ private TW_INFO Info_015;
+ private TW_INFO Info_016;
+ private TW_INFO Info_017;
+ private TW_INFO Info_018;
+ private TW_INFO Info_019;
+ private TW_INFO Info_020;
+ private TW_INFO Info_021;
+ private TW_INFO Info_022;
+ private TW_INFO Info_023;
+ private TW_INFO Info_024;
+ private TW_INFO Info_025;
+ private TW_INFO Info_026;
+ private TW_INFO Info_027;
+ private TW_INFO Info_028;
+ private TW_INFO Info_029;
+ private TW_INFO Info_030;
+ private TW_INFO Info_031;
+ private TW_INFO Info_032;
+ private TW_INFO Info_033;
+ private TW_INFO Info_034;
+ private TW_INFO Info_035;
+ private TW_INFO Info_036;
+ private TW_INFO Info_037;
+ private TW_INFO Info_038;
+ private TW_INFO Info_039;
+ private TW_INFO Info_040;
+ private TW_INFO Info_041;
+ private TW_INFO Info_042;
+ private TW_INFO Info_043;
+ private TW_INFO Info_044;
+ private TW_INFO Info_045;
+ private TW_INFO Info_046;
+ private TW_INFO Info_047;
+ private TW_INFO Info_048;
+ private TW_INFO Info_049;
+ private TW_INFO Info_050;
+ private TW_INFO Info_051;
+ private TW_INFO Info_052;
+ private TW_INFO Info_053;
+ private TW_INFO Info_054;
+ private TW_INFO Info_055;
+ private TW_INFO Info_056;
+ private TW_INFO Info_057;
+ private TW_INFO Info_058;
+ private TW_INFO Info_059;
+ private TW_INFO Info_060;
+ private TW_INFO Info_061;
+ private TW_INFO Info_062;
+ private TW_INFO Info_063;
+ private TW_INFO Info_064;
+ private TW_INFO Info_065;
+ private TW_INFO Info_066;
+ private TW_INFO Info_067;
+ private TW_INFO Info_068;
+ private TW_INFO Info_069;
+ private TW_INFO Info_070;
+ private TW_INFO Info_071;
+ private TW_INFO Info_072;
+ private TW_INFO Info_073;
+ private TW_INFO Info_074;
+ private TW_INFO Info_075;
+ private TW_INFO Info_076;
+ private TW_INFO Info_077;
+ private TW_INFO Info_078;
+ private TW_INFO Info_079;
+ private TW_INFO Info_080;
+ private TW_INFO Info_081;
+ private TW_INFO Info_082;
+ private TW_INFO Info_083;
+ private TW_INFO Info_084;
+ private TW_INFO Info_085;
+ private TW_INFO Info_086;
+ private TW_INFO Info_087;
+ private TW_INFO Info_088;
+ private TW_INFO Info_089;
+ private TW_INFO Info_090;
+ private TW_INFO Info_091;
+ private TW_INFO Info_092;
+ private TW_INFO Info_093;
+ private TW_INFO Info_094;
+ private TW_INFO Info_095;
+ private TW_INFO Info_096;
+ private TW_INFO Info_097;
+ private TW_INFO Info_098;
+ private TW_INFO Info_099;
+
+ // 200 seems overkill for anyone to request
+ // at once so I cut it down in half
+
+ //private TW_INFO Info_100;
+ //private TW_INFO Info_101;
+ //private TW_INFO Info_102;
+ //private TW_INFO Info_103;
+ //private TW_INFO Info_104;
+ //private TW_INFO Info_105;
+ //private TW_INFO Info_106;
+ //private TW_INFO Info_107;
+ //private TW_INFO Info_108;
+ //private TW_INFO Info_109;
+ //private TW_INFO Info_110;
+ //private TW_INFO Info_111;
+ //private TW_INFO Info_112;
+ //private TW_INFO Info_113;
+ //private TW_INFO Info_114;
+ //private TW_INFO Info_115;
+ //private TW_INFO Info_116;
+ //private TW_INFO Info_117;
+ //private TW_INFO Info_118;
+ //private TW_INFO Info_119;
+ //private TW_INFO Info_120;
+ //private TW_INFO Info_121;
+ //private TW_INFO Info_122;
+ //private TW_INFO Info_123;
+ //private TW_INFO Info_124;
+ //private TW_INFO Info_125;
+ //private TW_INFO Info_126;
+ //private TW_INFO Info_127;
+ //private TW_INFO Info_128;
+ //private TW_INFO Info_129;
+ //private TW_INFO Info_130;
+ //private TW_INFO Info_131;
+ //private TW_INFO Info_132;
+ //private TW_INFO Info_133;
+ //private TW_INFO Info_134;
+ //private TW_INFO Info_135;
+ //private TW_INFO Info_136;
+ //private TW_INFO Info_137;
+ //private TW_INFO Info_138;
+ //private TW_INFO Info_139;
+ //private TW_INFO Info_140;
+ //private TW_INFO Info_141;
+ //private TW_INFO Info_142;
+ //private TW_INFO Info_143;
+ //private TW_INFO Info_144;
+ //private TW_INFO Info_145;
+ //private TW_INFO Info_146;
+ //private TW_INFO Info_147;
+ //private TW_INFO Info_148;
+ //private TW_INFO Info_149;
+ //private TW_INFO Info_150;
+ //private TW_INFO Info_151;
+ //private TW_INFO Info_152;
+ //private TW_INFO Info_153;
+ //private TW_INFO Info_154;
+ //private TW_INFO Info_155;
+ //private TW_INFO Info_156;
+ //private TW_INFO Info_157;
+ //private TW_INFO Info_158;
+ //private TW_INFO Info_159;
+ //private TW_INFO Info_160;
+ //private TW_INFO Info_161;
+ //private TW_INFO Info_162;
+ //private TW_INFO Info_163;
+ //private TW_INFO Info_164;
+ //private TW_INFO Info_165;
+ //private TW_INFO Info_166;
+ //private TW_INFO Info_167;
+ //private TW_INFO Info_168;
+ //private TW_INFO Info_169;
+ //private TW_INFO Info_170;
+ //private TW_INFO Info_171;
+ //private TW_INFO Info_172;
+ //private TW_INFO Info_173;
+ //private TW_INFO Info_174;
+ //private TW_INFO Info_175;
+ //private TW_INFO Info_176;
+ //private TW_INFO Info_177;
+ //private TW_INFO Info_178;
+ //private TW_INFO Info_179;
+ //private TW_INFO Info_180;
+ //private TW_INFO Info_181;
+ //private TW_INFO Info_182;
+ //private TW_INFO Info_183;
+ //private TW_INFO Info_184;
+ //private TW_INFO Info_185;
+ //private TW_INFO Info_186;
+ //private TW_INFO Info_187;
+ //private TW_INFO Info_188;
+ //private TW_INFO Info_189;
+ //private TW_INFO Info_190;
+ //private TW_INFO Info_191;
+ //private TW_INFO Info_192;
+ //private TW_INFO Info_193;
+ //private TW_INFO Info_194;
+ //private TW_INFO Info_195;
+ //private TW_INFO Info_196;
+ //private TW_INFO Info_197;
+ //private TW_INFO Info_198;
+ //private TW_INFO Info_199;
+
+ public void Get(int a_uIndex, ref TW_INFO a_twinfo)
+ {
+ switch (a_uIndex)
+ {
+ default: return;
+ case 0: a_twinfo = Info_000; return;
+ case 1: a_twinfo = Info_001; return;
+ case 2: a_twinfo = Info_002; return;
+ case 3: a_twinfo = Info_003; return;
+ case 4: a_twinfo = Info_004; return;
+ case 5: a_twinfo = Info_005; return;
+ case 6: a_twinfo = Info_006; return;
+ case 7: a_twinfo = Info_007; return;
+ case 8: a_twinfo = Info_008; return;
+ case 9: a_twinfo = Info_009; return;
+ case 10: a_twinfo = Info_010; return;
+ case 11: a_twinfo = Info_011; return;
+ case 12: a_twinfo = Info_012; return;
+ case 13: a_twinfo = Info_013; return;
+ case 14: a_twinfo = Info_014; return;
+ case 15: a_twinfo = Info_015; return;
+ case 16: a_twinfo = Info_016; return;
+ case 17: a_twinfo = Info_017; return;
+ case 18: a_twinfo = Info_018; return;
+ case 19: a_twinfo = Info_019; return;
+ case 20: a_twinfo = Info_020; return;
+ case 21: a_twinfo = Info_021; return;
+ case 22: a_twinfo = Info_022; return;
+ case 23: a_twinfo = Info_023; return;
+ case 24: a_twinfo = Info_024; return;
+ case 25: a_twinfo = Info_025; return;
+ case 26: a_twinfo = Info_026; return;
+ case 27: a_twinfo = Info_027; return;
+ case 28: a_twinfo = Info_028; return;
+ case 29: a_twinfo = Info_029; return;
+ case 30: a_twinfo = Info_030; return;
+ case 31: a_twinfo = Info_031; return;
+ case 32: a_twinfo = Info_032; return;
+ case 33: a_twinfo = Info_033; return;
+ case 34: a_twinfo = Info_034; return;
+ case 35: a_twinfo = Info_035; return;
+ case 36: a_twinfo = Info_036; return;
+ case 37: a_twinfo = Info_037; return;
+ case 38: a_twinfo = Info_038; return;
+ case 39: a_twinfo = Info_039; return;
+ case 40: a_twinfo = Info_040; return;
+ case 41: a_twinfo = Info_041; return;
+ case 42: a_twinfo = Info_042; return;
+ case 43: a_twinfo = Info_043; return;
+ case 44: a_twinfo = Info_044; return;
+ case 45: a_twinfo = Info_045; return;
+ case 46: a_twinfo = Info_046; return;
+ case 47: a_twinfo = Info_047; return;
+ case 48: a_twinfo = Info_048; return;
+ case 49: a_twinfo = Info_049; return;
+ case 50: a_twinfo = Info_050; return;
+ case 51: a_twinfo = Info_051; return;
+ case 52: a_twinfo = Info_052; return;
+ case 53: a_twinfo = Info_053; return;
+ case 54: a_twinfo = Info_054; return;
+ case 55: a_twinfo = Info_055; return;
+ case 56: a_twinfo = Info_056; return;
+ case 57: a_twinfo = Info_057; return;
+ case 58: a_twinfo = Info_058; return;
+ case 59: a_twinfo = Info_059; return;
+ case 60: a_twinfo = Info_060; return;
+ case 61: a_twinfo = Info_061; return;
+ case 62: a_twinfo = Info_062; return;
+ case 63: a_twinfo = Info_063; return;
+ case 64: a_twinfo = Info_064; return;
+ case 65: a_twinfo = Info_065; return;
+ case 66: a_twinfo = Info_066; return;
+ case 67: a_twinfo = Info_067; return;
+ case 68: a_twinfo = Info_068; return;
+ case 69: a_twinfo = Info_069; return;
+ case 70: a_twinfo = Info_070; return;
+ case 71: a_twinfo = Info_071; return;
+ case 72: a_twinfo = Info_072; return;
+ case 73: a_twinfo = Info_073; return;
+ case 74: a_twinfo = Info_074; return;
+ case 75: a_twinfo = Info_075; return;
+ case 76: a_twinfo = Info_076; return;
+ case 77: a_twinfo = Info_077; return;
+ case 78: a_twinfo = Info_078; return;
+ case 79: a_twinfo = Info_079; return;
+ case 80: a_twinfo = Info_080; return;
+ case 81: a_twinfo = Info_081; return;
+ case 82: a_twinfo = Info_082; return;
+ case 83: a_twinfo = Info_083; return;
+ case 84: a_twinfo = Info_084; return;
+ case 85: a_twinfo = Info_085; return;
+ case 86: a_twinfo = Info_086; return;
+ case 87: a_twinfo = Info_087; return;
+ case 88: a_twinfo = Info_088; return;
+ case 89: a_twinfo = Info_089; return;
+ case 90: a_twinfo = Info_090; return;
+ case 91: a_twinfo = Info_091; return;
+ case 92: a_twinfo = Info_092; return;
+ case 93: a_twinfo = Info_093; return;
+ case 94: a_twinfo = Info_094; return;
+ case 95: a_twinfo = Info_095; return;
+ case 96: a_twinfo = Info_096; return;
+ case 97: a_twinfo = Info_097; return;
+ case 98: a_twinfo = Info_098; return;
+ case 99: a_twinfo = Info_099; return;
+ //case 100: a_twinfo = Info_100; return;
+ //case 101: a_twinfo = Info_101; return;
+ //case 102: a_twinfo = Info_102; return;
+ //case 103: a_twinfo = Info_103; return;
+ //case 104: a_twinfo = Info_104; return;
+ //case 105: a_twinfo = Info_105; return;
+ //case 106: a_twinfo = Info_106; return;
+ //case 107: a_twinfo = Info_107; return;
+ //case 108: a_twinfo = Info_108; return;
+ //case 109: a_twinfo = Info_109; return;
+ //case 110: a_twinfo = Info_110; return;
+ //case 111: a_twinfo = Info_111; return;
+ //case 112: a_twinfo = Info_112; return;
+ //case 113: a_twinfo = Info_113; return;
+ //case 114: a_twinfo = Info_114; return;
+ //case 115: a_twinfo = Info_115; return;
+ //case 116: a_twinfo = Info_116; return;
+ //case 117: a_twinfo = Info_117; return;
+ //case 118: a_twinfo = Info_118; return;
+ //case 119: a_twinfo = Info_119; return;
+ //case 120: a_twinfo = Info_120; return;
+ //case 121: a_twinfo = Info_121; return;
+ //case 122: a_twinfo = Info_122; return;
+ //case 123: a_twinfo = Info_123; return;
+ //case 124: a_twinfo = Info_124; return;
+ //case 125: a_twinfo = Info_125; return;
+ //case 126: a_twinfo = Info_126; return;
+ //case 127: a_twinfo = Info_127; return;
+ //case 128: a_twinfo = Info_128; return;
+ //case 129: a_twinfo = Info_129; return;
+ //case 130: a_twinfo = Info_130; return;
+ //case 131: a_twinfo = Info_131; return;
+ //case 132: a_twinfo = Info_132; return;
+ //case 133: a_twinfo = Info_133; return;
+ //case 134: a_twinfo = Info_134; return;
+ //case 135: a_twinfo = Info_135; return;
+ //case 136: a_twinfo = Info_136; return;
+ //case 137: a_twinfo = Info_137; return;
+ //case 138: a_twinfo = Info_138; return;
+ //case 139: a_twinfo = Info_139; return;
+ //case 140: a_twinfo = Info_140; return;
+ //case 141: a_twinfo = Info_141; return;
+ //case 142: a_twinfo = Info_142; return;
+ //case 143: a_twinfo = Info_143; return;
+ //case 144: a_twinfo = Info_144; return;
+ //case 145: a_twinfo = Info_145; return;
+ //case 146: a_twinfo = Info_146; return;
+ //case 147: a_twinfo = Info_147; return;
+ //case 148: a_twinfo = Info_148; return;
+ //case 149: a_twinfo = Info_149; return;
+ //case 150: a_twinfo = Info_150; return;
+ //case 151: a_twinfo = Info_151; return;
+ //case 152: a_twinfo = Info_152; return;
+ //case 153: a_twinfo = Info_153; return;
+ //case 154: a_twinfo = Info_154; return;
+ //case 155: a_twinfo = Info_155; return;
+ //case 156: a_twinfo = Info_156; return;
+ //case 157: a_twinfo = Info_157; return;
+ //case 158: a_twinfo = Info_158; return;
+ //case 159: a_twinfo = Info_159; return;
+ //case 160: a_twinfo = Info_160; return;
+ //case 161: a_twinfo = Info_161; return;
+ //case 162: a_twinfo = Info_162; return;
+ //case 163: a_twinfo = Info_163; return;
+ //case 164: a_twinfo = Info_164; return;
+ //case 165: a_twinfo = Info_165; return;
+ //case 166: a_twinfo = Info_166; return;
+ //case 167: a_twinfo = Info_167; return;
+ //case 168: a_twinfo = Info_168; return;
+ //case 169: a_twinfo = Info_169; return;
+ //case 170: a_twinfo = Info_170; return;
+ //case 171: a_twinfo = Info_171; return;
+ //case 172: a_twinfo = Info_172; return;
+ //case 173: a_twinfo = Info_173; return;
+ //case 174: a_twinfo = Info_174; return;
+ //case 175: a_twinfo = Info_175; return;
+ //case 176: a_twinfo = Info_176; return;
+ //case 177: a_twinfo = Info_177; return;
+ //case 178: a_twinfo = Info_178; return;
+ //case 179: a_twinfo = Info_179; return;
+ //case 180: a_twinfo = Info_180; return;
+ //case 181: a_twinfo = Info_181; return;
+ //case 182: a_twinfo = Info_182; return;
+ //case 183: a_twinfo = Info_183; return;
+ //case 184: a_twinfo = Info_184; return;
+ //case 185: a_twinfo = Info_185; return;
+ //case 186: a_twinfo = Info_186; return;
+ //case 187: a_twinfo = Info_187; return;
+ //case 188: a_twinfo = Info_188; return;
+ //case 189: a_twinfo = Info_189; return;
+ //case 190: a_twinfo = Info_190; return;
+ //case 191: a_twinfo = Info_191; return;
+ //case 192: a_twinfo = Info_192; return;
+ //case 193: a_twinfo = Info_193; return;
+ //case 194: a_twinfo = Info_194; return;
+ //case 195: a_twinfo = Info_195; return;
+ //case 196: a_twinfo = Info_196; return;
+ //case 197: a_twinfo = Info_197; return;
+ //case 198: a_twinfo = Info_198; return;
+ //case 199: a_twinfo = Info_199; return;
+ }
+ }
+
+ public void Set(int a_uIndex, ref TW_INFO a_twinfo)
+ {
+ switch (a_uIndex)
+ {
+ default: return;
+ case 0: Info_000 = a_twinfo; return;
+ case 1: Info_001 = a_twinfo; return;
+ case 2: Info_002 = a_twinfo; return;
+ case 3: Info_003 = a_twinfo; return;
+ case 4: Info_004 = a_twinfo; return;
+ case 5: Info_005 = a_twinfo; return;
+ case 6: Info_006 = a_twinfo; return;
+ case 7: Info_007 = a_twinfo; return;
+ case 8: Info_008 = a_twinfo; return;
+ case 9: Info_009 = a_twinfo; return;
+ case 10: Info_010 = a_twinfo; return;
+ case 11: Info_011 = a_twinfo; return;
+ case 12: Info_012 = a_twinfo; return;
+ case 13: Info_013 = a_twinfo; return;
+ case 14: Info_014 = a_twinfo; return;
+ case 15: Info_015 = a_twinfo; return;
+ case 16: Info_016 = a_twinfo; return;
+ case 17: Info_017 = a_twinfo; return;
+ case 18: Info_018 = a_twinfo; return;
+ case 19: Info_019 = a_twinfo; return;
+ case 20: Info_020 = a_twinfo; return;
+ case 21: Info_021 = a_twinfo; return;
+ case 22: Info_022 = a_twinfo; return;
+ case 23: Info_023 = a_twinfo; return;
+ case 24: Info_024 = a_twinfo; return;
+ case 25: Info_025 = a_twinfo; return;
+ case 26: Info_026 = a_twinfo; return;
+ case 27: Info_027 = a_twinfo; return;
+ case 28: Info_028 = a_twinfo; return;
+ case 29: Info_029 = a_twinfo; return;
+ case 30: Info_030 = a_twinfo; return;
+ case 31: Info_031 = a_twinfo; return;
+ case 32: Info_032 = a_twinfo; return;
+ case 33: Info_033 = a_twinfo; return;
+ case 34: Info_034 = a_twinfo; return;
+ case 35: Info_035 = a_twinfo; return;
+ case 36: Info_036 = a_twinfo; return;
+ case 37: Info_037 = a_twinfo; return;
+ case 38: Info_038 = a_twinfo; return;
+ case 39: Info_039 = a_twinfo; return;
+ case 40: Info_040 = a_twinfo; return;
+ case 41: Info_041 = a_twinfo; return;
+ case 42: Info_042 = a_twinfo; return;
+ case 43: Info_043 = a_twinfo; return;
+ case 44: Info_044 = a_twinfo; return;
+ case 45: Info_045 = a_twinfo; return;
+ case 46: Info_046 = a_twinfo; return;
+ case 47: Info_047 = a_twinfo; return;
+ case 48: Info_048 = a_twinfo; return;
+ case 49: Info_049 = a_twinfo; return;
+ case 50: Info_050 = a_twinfo; return;
+ case 51: Info_051 = a_twinfo; return;
+ case 52: Info_052 = a_twinfo; return;
+ case 53: Info_053 = a_twinfo; return;
+ case 54: Info_054 = a_twinfo; return;
+ case 55: Info_055 = a_twinfo; return;
+ case 56: Info_056 = a_twinfo; return;
+ case 57: Info_057 = a_twinfo; return;
+ case 58: Info_058 = a_twinfo; return;
+ case 59: Info_059 = a_twinfo; return;
+ case 60: Info_060 = a_twinfo; return;
+ case 61: Info_061 = a_twinfo; return;
+ case 62: Info_062 = a_twinfo; return;
+ case 63: Info_063 = a_twinfo; return;
+ case 64: Info_064 = a_twinfo; return;
+ case 65: Info_065 = a_twinfo; return;
+ case 66: Info_066 = a_twinfo; return;
+ case 67: Info_067 = a_twinfo; return;
+ case 68: Info_068 = a_twinfo; return;
+ case 69: Info_069 = a_twinfo; return;
+ case 70: Info_070 = a_twinfo; return;
+ case 71: Info_071 = a_twinfo; return;
+ case 72: Info_072 = a_twinfo; return;
+ case 73: Info_073 = a_twinfo; return;
+ case 74: Info_074 = a_twinfo; return;
+ case 75: Info_075 = a_twinfo; return;
+ case 76: Info_076 = a_twinfo; return;
+ case 77: Info_077 = a_twinfo; return;
+ case 78: Info_078 = a_twinfo; return;
+ case 79: Info_079 = a_twinfo; return;
+ case 80: Info_080 = a_twinfo; return;
+ case 81: Info_081 = a_twinfo; return;
+ case 82: Info_082 = a_twinfo; return;
+ case 83: Info_083 = a_twinfo; return;
+ case 84: Info_084 = a_twinfo; return;
+ case 85: Info_085 = a_twinfo; return;
+ case 86: Info_086 = a_twinfo; return;
+ case 87: Info_087 = a_twinfo; return;
+ case 88: Info_088 = a_twinfo; return;
+ case 89: Info_089 = a_twinfo; return;
+ case 90: Info_090 = a_twinfo; return;
+ case 91: Info_091 = a_twinfo; return;
+ case 92: Info_092 = a_twinfo; return;
+ case 93: Info_093 = a_twinfo; return;
+ case 94: Info_094 = a_twinfo; return;
+ case 95: Info_095 = a_twinfo; return;
+ case 96: Info_096 = a_twinfo; return;
+ case 97: Info_097 = a_twinfo; return;
+ case 98: Info_098 = a_twinfo; return;
+ case 99: Info_099 = a_twinfo; return;
+ //case 100: Info_100 = a_twinfo; return;
+ //case 101: Info_101 = a_twinfo; return;
+ //case 102: Info_102 = a_twinfo; return;
+ //case 103: Info_103 = a_twinfo; return;
+ //case 104: Info_104 = a_twinfo; return;
+ //case 105: Info_105 = a_twinfo; return;
+ //case 106: Info_106 = a_twinfo; return;
+ //case 107: Info_107 = a_twinfo; return;
+ //case 108: Info_108 = a_twinfo; return;
+ //case 109: Info_109 = a_twinfo; return;
+ //case 110: Info_110 = a_twinfo; return;
+ //case 111: Info_111 = a_twinfo; return;
+ //case 112: Info_112 = a_twinfo; return;
+ //case 113: Info_113 = a_twinfo; return;
+ //case 114: Info_114 = a_twinfo; return;
+ //case 115: Info_115 = a_twinfo; return;
+ //case 116: Info_116 = a_twinfo; return;
+ //case 117: Info_117 = a_twinfo; return;
+ //case 118: Info_118 = a_twinfo; return;
+ //case 119: Info_119 = a_twinfo; return;
+ //case 120: Info_120 = a_twinfo; return;
+ //case 121: Info_121 = a_twinfo; return;
+ //case 122: Info_122 = a_twinfo; return;
+ //case 123: Info_123 = a_twinfo; return;
+ //case 124: Info_124 = a_twinfo; return;
+ //case 125: Info_125 = a_twinfo; return;
+ //case 126: Info_126 = a_twinfo; return;
+ //case 127: Info_127 = a_twinfo; return;
+ //case 128: Info_128 = a_twinfo; return;
+ //case 129: Info_129 = a_twinfo; return;
+ //case 130: Info_130 = a_twinfo; return;
+ //case 131: Info_131 = a_twinfo; return;
+ //case 132: Info_132 = a_twinfo; return;
+ //case 133: Info_133 = a_twinfo; return;
+ //case 134: Info_134 = a_twinfo; return;
+ //case 135: Info_135 = a_twinfo; return;
+ //case 136: Info_136 = a_twinfo; return;
+ //case 137: Info_137 = a_twinfo; return;
+ //case 138: Info_138 = a_twinfo; return;
+ //case 139: Info_139 = a_twinfo; return;
+ //case 140: Info_140 = a_twinfo; return;
+ //case 141: Info_141 = a_twinfo; return;
+ //case 142: Info_142 = a_twinfo; return;
+ //case 143: Info_143 = a_twinfo; return;
+ //case 144: Info_144 = a_twinfo; return;
+ //case 145: Info_145 = a_twinfo; return;
+ //case 146: Info_146 = a_twinfo; return;
+ //case 147: Info_147 = a_twinfo; return;
+ //case 148: Info_148 = a_twinfo; return;
+ //case 149: Info_149 = a_twinfo; return;
+ //case 150: Info_150 = a_twinfo; return;
+ //case 151: Info_151 = a_twinfo; return;
+ //case 152: Info_152 = a_twinfo; return;
+ //case 153: Info_153 = a_twinfo; return;
+ //case 154: Info_154 = a_twinfo; return;
+ //case 155: Info_155 = a_twinfo; return;
+ //case 156: Info_156 = a_twinfo; return;
+ //case 157: Info_157 = a_twinfo; return;
+ //case 158: Info_158 = a_twinfo; return;
+ //case 159: Info_159 = a_twinfo; return;
+ //case 160: Info_160 = a_twinfo; return;
+ //case 161: Info_161 = a_twinfo; return;
+ //case 162: Info_162 = a_twinfo; return;
+ //case 163: Info_163 = a_twinfo; return;
+ //case 164: Info_164 = a_twinfo; return;
+ //case 165: Info_165 = a_twinfo; return;
+ //case 166: Info_166 = a_twinfo; return;
+ //case 167: Info_167 = a_twinfo; return;
+ //case 168: Info_168 = a_twinfo; return;
+ //case 169: Info_169 = a_twinfo; return;
+ //case 170: Info_170 = a_twinfo; return;
+ //case 171: Info_171 = a_twinfo; return;
+ //case 172: Info_172 = a_twinfo; return;
+ //case 173: Info_173 = a_twinfo; return;
+ //case 174: Info_174 = a_twinfo; return;
+ //case 175: Info_175 = a_twinfo; return;
+ //case 176: Info_176 = a_twinfo; return;
+ //case 177: Info_177 = a_twinfo; return;
+ //case 178: Info_178 = a_twinfo; return;
+ //case 179: Info_179 = a_twinfo; return;
+ //case 180: Info_180 = a_twinfo; return;
+ //case 181: Info_181 = a_twinfo; return;
+ //case 182: Info_182 = a_twinfo; return;
+ //case 183: Info_183 = a_twinfo; return;
+ //case 184: Info_184 = a_twinfo; return;
+ //case 185: Info_185 = a_twinfo; return;
+ //case 186: Info_186 = a_twinfo; return;
+ //case 187: Info_187 = a_twinfo; return;
+ //case 188: Info_188 = a_twinfo; return;
+ //case 189: Info_189 = a_twinfo; return;
+ //case 190: Info_190 = a_twinfo; return;
+ //case 191: Info_191 = a_twinfo; return;
+ //case 192: Info_192 = a_twinfo; return;
+ //case 193: Info_193 = a_twinfo; return;
+ //case 194: Info_194 = a_twinfo; return;
+ //case 195: Info_195 = a_twinfo; return;
+ //case 196: Info_196 = a_twinfo; return;
+ //case 197: Info_197 = a_twinfo; return;
+ //case 198: Info_198 = a_twinfo; return;
+ //case 199: Info_199 = a_twinfo; return;
+ }
+ }
+}
+
+///
+/// Provides information about the currently selected device.
+/// TBD -- need a 32/64 bit solution for this mess
+///
+[SuppressMessage("Microsoft.Portability", "CA1900:ValueTypeFieldsShouldBePortable", MessageId = "ModifiedTimeDate")]
+[SuppressMessage("Microsoft.Portability", "CA1900:ValueTypeFieldsShouldBePortable", MessageId = "CreateTimeDate")]
+[StructLayout(LayoutKind.Explicit, Pack = 2)]
+public struct TW_FILESYSTEM
+{
+ [FieldOffset(0)]
+ public TW_STR255 InputName;
+
+ [FieldOffset(256)]
+ public TW_STR255 OutputName;
+
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ [FieldOffset(512)]
+ public IntPtr Context;
+
+ [FieldOffset(520)]
+ public Int32 Recursive;
+ [FieldOffset(520)]
+ public UInt16 Subdirectories;
+
+ [FieldOffset(524)]
+ public Int32 FileType;
+ [FieldOffset(524)]
+ public UInt32 FileSystemType;
+
+ [FieldOffset(528)]
+ public UInt32 Size;
+
+ [FieldOffset(532)]
+ public TW_STR32 CreateTimeDate;
+
+ [FieldOffset(566)]
+ public TW_STR32 ModifiedTimeDate;
+
+ [FieldOffset(600)]
+ public UInt32 FreeSpace;
+
+ [FieldOffset(604)]
+ public UInt32 NewImageSize;
+
+ [FieldOffset(608)]
+ public UInt32 NumberOfFiles;
+
+ [FieldOffset(612)]
+ public UInt32 NumberOfSnippets;
+
+ [FieldOffset(616)]
+ public UInt32 DeviceGroupMask;
+
+ [FieldOffset(620)]
+ public byte Reserved;
+
+ [FieldOffset(1127)] // 620 + 508 - 1
+ private byte ReservedEnd;
+}
+[SuppressMessage("Microsoft.Portability", "CA1900:ValueTypeFieldsShouldBePortable", MessageId = "ModifiedTimeDate")]
+[StructLayout(LayoutKind.Explicit, Pack = 2)]
+public struct TW_FILESYSTEM_LEGACY
+{
+ [FieldOffset(0)]
+ public TW_STR255 InputName;
+
+ [FieldOffset(256)]
+ public TW_STR255 OutputName;
+
+ [FieldOffset(512)]
+ public UInt32 Context;
+
+ [FieldOffset(516)]
+ public Int32 Recursive;
+ [FieldOffset(516)]
+ public UInt16 Subdirectories;
+
+ [FieldOffset(520)]
+ public Int32 FileType;
+ [FieldOffset(520)]
+ public UInt32 FileSystemType;
+
+ [FieldOffset(524)]
+ public UInt32 Size;
+
+ [FieldOffset(528)]
+ public TW_STR32 CreateTimeDate;
+
+ [FieldOffset(562)]
+ public TW_STR32 ModifiedTimeDate;
+
+ [FieldOffset(596)]
+ public UInt32 FreeSpace;
+
+ [FieldOffset(600)]
+ public UInt32 NewImageSize;
+
+ [FieldOffset(604)]
+ public UInt32 NumberOfFiles;
+
+ [FieldOffset(608)]
+ public UInt32 NumberOfSnippets;
+
+ [FieldOffset(612)]
+ public UInt32 DeviceGroupMask;
+
+ [FieldOffset(616)]
+ public byte Reserved;
+
+ [FieldOffset(1123)] // 616 + 508 - 1
+ private byte ReservedEnd;
+}
+
+///
+/// This structure is used by the application to specify a set of mapping values to be applied to grayscale data.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_GRAYRESPONSE
+{
+ public TW_ELEMENT8 Response_00;
+}
+
+///
+/// A general way to describe the version of software that is running.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
+public partial struct TW_VERSION
+{
+ public ushort MajorNum;
+ public ushort MinorNum;
+ public TWLG Language;
+ public TWCY Country;
+ public TW_STR32 Info;
+}
+
+///
+/// Provides identification information about a TWAIN entity.
+/// The use of Padding is there to allow us to use the structure
+/// with Linux 64-bit systems where the TW_INT32 and TW_UINT32
+/// types were long, and therefore 64-bits in size. This should
+/// have no impact with well-behaved systems that have these types
+/// as 32-bit, but should prevent memory corruption in all other
+/// situations...
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
+public partial struct TW_IDENTITY
+{
+ public ulong Id;
+ public TW_VERSION Version;
+ public ushort ProtocolMajor;
+ public ushort ProtocolMinor;
+ public uint SupportedGroups;
+ public TW_STR32 Manufacturer;
+ public TW_STR32 ProductFamily;
+ public TW_STR32 ProductName;
+}
+[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
+public partial struct TW_IDENTITY_LEGACY
+{
+ public uint Id;
+ public TW_VERSION Version;
+ public ushort ProtocolMajor;
+ public ushort ProtocolMinor;
+ public uint SupportedGroups;
+ public TW_STR32 Manufacturer;
+ public TW_STR32 ProductFamily;
+ public TW_STR32 ProductName;
+ private UInt64 Padding; // accounts for Id and SupportedGroups
+}
+[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
+public partial struct TW_IDENTITY_LINUX64
+{
+ public ulong Id;
+ public TW_VERSION Version;
+ public ushort ProtocolMajor;
+ public ushort ProtocolMinor;
+ public ulong SupportedGroups;
+ public TW_STR32 Manufacturer;
+ public TW_STR32 ProductFamily;
+ public TW_STR32 ProductName;
+}
+[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
+public partial struct TW_IDENTITY_MACOSX
+{
+ public uint Id;
+ public TW_VERSION Version;
+ public ushort ProtocolMajor;
+ public ushort ProtocolMinor;
+ private ushort padding;
+ public uint SupportedGroups;
+ public TW_STR32 Manufacturer;
+ public TW_STR32 ProductFamily;
+ public TW_STR32 ProductName;
+}
+
+///
+/// Describes the “real” image data, that is, the complete image being transferred between the Source and application.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public partial struct TW_IMAGEINFO
+{
+ public TW_FIX32 XResolution;
+ public TW_FIX32 YResolution;
+ public int ImageWidth;
+ public int ImageLength;
+ public short SamplesPerPixel;
+ public short BitsPerSample_0;
+ public short BitsPerSample_1;
+ public short BitsPerSample_2;
+ public short BitsPerSample_3;
+ public short BitsPerSample_4;
+ public short BitsPerSample_5;
+ public short BitsPerSample_6;
+ public short BitsPerSample_7;
+ public short BitsPerPixel;
+ public TW_BOOL Planar;
+ public TWPT PixelType;
+ public TWCP Compression;
+}
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_IMAGEINFO_LINUX64
+{
+ public TW_FIX32 XResolution;
+ public TW_FIX32 YResolution;
+ public int ImageWidth;
+ public int ImageLength;
+ public short SamplesPerPixel;
+ public short BitsPerSample_0;
+ public short BitsPerSample_1;
+ public short BitsPerSample_2;
+ public short BitsPerSample_3;
+ public short BitsPerSample_4;
+ public short BitsPerSample_5;
+ public short BitsPerSample_6;
+ public short BitsPerSample_7;
+ public short BitsPerPixel;
+ public TW_BOOL Planar;
+ public TWPT PixelType;
+ public TWCP Compression;
+}
+
+///
+/// Involves information about the original size of the acquired image.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_IMAGELAYOUT
+{
+ public TW_FRAME Frame;
+ public uint DocumentNumber;
+ public uint PageNumber;
+ public uint FrameNumber;
+}
+
+///
+/// Provides information for managing memory buffers.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_MEMORY
+{
+ public uint Flags;
+ public uint Length;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr TheMem;
+}
+
+///
+/// Describes the form of the acquired data being passed from the Source to the application.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public partial struct TW_IMAGEMEMXFER
+{
+ public ushort Compression;
+ public uint BytesPerRow;
+ public uint Columns;
+ public uint Rows;
+ public uint XOffset;
+ public uint YOffset;
+ public uint BytesWritten;
+ public TW_MEMORY Memory;
+}
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public partial struct TW_IMAGEMEMXFER_LINUX64
+{
+ public ushort Compression;
+ public UInt64 BytesPerRow;
+ public UInt64 Columns;
+ public UInt64 Rows;
+ public UInt64 XOffset;
+ public UInt64 YOffset;
+ public UInt64 BytesWritten;
+ public UInt64 MemoryFlags;
+ public UInt64 MemoryLength;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr MemoryTheMem;
+}
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public partial struct TW_IMAGEMEMXFER_MACOSX
+{
+ public uint Compression;
+ public uint BytesPerRow;
+ public uint Columns;
+ public uint Rows;
+ public uint XOffset;
+ public uint YOffset;
+ public uint BytesWritten;
+ public TW_MEMORY Memory;
+}
+
+///
+/// Describes the information necessary to transfer a JPEG-compressed image.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_JPEGCOMPRESSION
+{
+ public ushort ColorSpace;
+ public uint SubSampling;
+ public ushort NumComponents;
+ public ushort QuantMap_0;
+ public ushort QuantMap_1;
+ public ushort QuantMap_2;
+ public ushort QuantMap_3;
+ public TW_MEMORY QuantTable_0;
+ public TW_MEMORY QuantTable_1;
+ public TW_MEMORY QuantTable_2;
+ public TW_MEMORY QuantTable_3;
+ public ushort HuffmanMap_0;
+ public ushort HuffmanMap_1;
+ public ushort HuffmanMap_2;
+ public ushort HuffmanMap_3;
+ public TW_MEMORY HuffmanDC_0;
+ public TW_MEMORY HuffmanDC_1;
+ public TW_MEMORY HuffmanAC_0;
+ public TW_MEMORY HuffmanAC_2;
+}
+
+///
+/// Collects scanning metrics after returning to state 4
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_METRICS
+{
+ public uint SizeOf;
+ public uint ImageCount;
+ public uint SheetCount;
+}
+
+///
+/// Stores a single value (item) which describes a capability.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_ONEVALUE
+{
+ public TWTY ItemType;
+ // public uint Item;
+}
+[StructLayout(LayoutKind.Sequential, Pack = 4)]
+public struct TW_ONEVALUE_MACOSX
+{
+ public uint ItemType;
+ // public uint Item;
+}
+
+///
+/// This structure holds the color palette information.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_PALETTE8
+{
+ public ushort Flags;
+ public ushort Length;
+ public TW_ELEMENT8 Colors_000;
+}
+
+///
+/// Used to bypass the TWAIN protocol when communicating with a device.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_PASSTHRU
+{
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr pCommand;
+ public uint CommandBytes;
+ public int Direction;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr pData;
+ public uint DataBytes;
+ public uint DataBytesXfered;
+}
+
+///
+/// This structure tells the application how many more complete transfers the Source currently has available.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_PENDINGXFERS
+{
+ public static TW_PENDINGXFERS DONTCARE()
+ {
+ return new TW_PENDINGXFERS { Count = -1 };
+ }
+
+ public short Count;
+ public uint EOJ;
+}
+
+///
+/// Stores a range of individual values describing a capability.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_RANGE
+{
+ public TWTY ItemType;
+ public uint MinValue;
+ public uint MaxValue;
+ public uint StepSize;
+ public uint DefaultValue;
+ public uint CurrentValue;
+}
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_RANGE_LINUX64
+{
+ public TWTY ItemType;
+ public ulong MinValue;
+ public ulong MaxValue;
+ public ulong StepSize;
+ public ulong DefaultValue;
+ public ulong CurrentValue;
+}
+[StructLayout(LayoutKind.Sequential, Pack = 4)]
+public struct TW_RANGE_MACOSX
+{
+ public uint ItemType;
+ public uint MinValue;
+ public uint MaxValue;
+ public uint StepSize;
+ public uint DefaultValue;
+ public uint CurrentValue;
+}
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_RANGE_FIX32
+{
+ public TWTY ItemType;
+ public TW_FIX32 MinValue;
+ public TW_FIX32 MaxValue;
+ public TW_FIX32 StepSize;
+ public TW_FIX32 DefaultValue;
+ public TW_FIX32 CurrentValue;
+}
+[StructLayout(LayoutKind.Sequential, Pack = 4)]
+public struct TW_RANGE_FIX32_MACOSX
+{
+ public uint ItemType;
+ public TW_FIX32 MinValue;
+ public TW_FIX32 MaxValue;
+ public TW_FIX32 StepSize;
+ public TW_FIX32 DefaultValue;
+ public TW_FIX32 CurrentValue;
+}
+
+///
+/// This structure is used by the application to specify a set of mapping values to be applied to RGB color data.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_RGBRESPONSE
+{
+ public TW_ELEMENT8 Response_00;
+}
+
+///
+/// Describes the file format and file specification information for a transfer through a disk file.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public struct TW_SETUPFILEXFER
+{
+ public TW_STR255 FileName;
+ public TWFF Format;
+ public short VRefNum;
+}
+
+///
+/// Provides the application information about the Source’s requirements and preferences regarding allocation of transfer buffer(s).
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public partial struct TW_SETUPMEMXFER
+{
+ public uint MinBufSize;
+ public uint MaxBufSize;
+ public uint Preferred;
+}
+
+///
+/// Describes the status of a source.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public partial struct TW_STATUS
+{
+ public TWCC ConditionCode;
+ public ushort Data;
+}
+
+///
+/// Translates the contents of Status into a localized UTF8string.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2)]
+public partial struct TW_STATUSUTF8
+{
+ public TW_STATUS Status;
+ public uint Size;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr UTF8string;
+}
+
+///
+/// Passthru for TWAIN Direct tasks.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
+public struct TW_TWAINDIRECT
+{
+ public uint SizeOf;
+ public ushort CommunicationManager;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr Send;
+ public uint SendSize;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr Receive;
+ public uint ReceiveSize;
+}
+
+///
+/// This structure is used to handle the user interface coordination between an application and a Source.
+///
+[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
+public struct TW_USERINTERFACE
+{
+ public ushort ShowUI;
+ public ushort ModalUI;
+ [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")]
+ public IntPtr hParent;
+}
+
+#endregion
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Generic Constants...
+///////////////////////////////////////////////////////////////////////////////
+#region Generic Constants...
+
+///
+/// Container Types...
+///
+public enum TWON : ushort
+{
+ ARRAY = 3,
+ ENUMERATION = 4,
+ ONEVALUE = 5,
+ RANGE = 6,
+
+ ICONID = 962,
+ DSMID = 461,
+ DSMCODEID = 63,
+
+ DONTCARE = 0xffff
+}
+
+/////
+///// Don't care values...
+/////
+//public const byte TWON_DONTCARE8 = 0xff;
+//public const ushort TWON_DONTCARE16 = 0xff;
+//public const uint TWON_DONTCARE32 = 0xffffffff;
+
+///
+/// Flags used in TW_MEMORY structure.
+///
+[Flags]
+public enum TWMF : ushort
+{
+ APPOWNS = 0x0001,
+ DSMOWNS = 0x0002,
+ DSOWNS = 0x0004,
+ POINTER = 0x0008,
+ HANDLE = 0x0010
+}
+
+///
+/// Type values...
+///
+public enum TWTY : ushort
+{
+ Invalid = 0xffff,
+
+ INT8 = 0x0000,
+ INT16 = 0x0001,
+ INT32 = 0x0002,
+
+ UINT8 = 0x0003,
+ UINT16 = 0x0004,
+ UINT32 = 0x0005,
+
+ BOOL = 0x0006,
+
+ FIX32 = 0x0007,
+
+ FRAME = 0x0008,
+
+ STR32 = 0x0009,
+ STR64 = 0x000a,
+ STR128 = 0x000b,
+ STR255 = 0x000c,
+ HANDLE = 0x000f
+}
+
+#endregion
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Capability Constants...
+///////////////////////////////////////////////////////////////////////////////
+#region Capability Constants...
+
+///
+/// CAP_ALARMS values
+///
+public enum TWAL : ushort
+{
+ ALARM = 0,
+ FEEDERERROR = 1,
+ FEEDERWARNING = 2,
+ BARCODE = 3,
+ DOUBLEFEED = 4,
+ JAM = 5,
+ PATCHCODE = 6,
+ POWER = 7,
+ SKEW = 8
+}
+
+///
+/// ICAP_AUTOSIZE values
+///
+public enum TWAS : ushort
+{
+ NONE = 0,
+ AUTO = 1,
+ CURRENT = 2
+}
+
+///
+/// TWEI_BARCODEROTATION values
+///
+public enum TWBCOR : ushort
+{
+ ROT0 = 0,
+ ROT90 = 1,
+ ROT180 = 2,
+ ROT270 = 3,
+ ROTX = 4
+}
+
+///
+/// ICAP_BARCODESEARCHMODE values
+///
+public enum TWBD : ushort
+{
+ HORZ = 0,
+ VERT = 1,
+ HORZVERT = 2,
+ VERTHORZ = 3
+}
+
+///
+/// ICAP_BITORDER values
+///
+public enum TWBO : ushort
+{
+ LSBFIRST = 0,
+ MSBFIRST = 1
+}
+
+///
+/// ICAP_AUTODISCARDBLANKPAGES values
+///
+public enum TWBP : short
+{
+ DISABLE = -2,
+ AUTO = -1
+}
+
+///
+/// ICAP_BITDEPTHREDUCTION values
+///
+public enum TWBR : ushort
+{
+ THRESHOLD = 0,
+ HALFTONE = 1,
+ CUSTHALFTONE = 2,
+ DIFFUSION = 3,
+ DYNAMICTHRESHOLD = 4
+}
+
+///
+/// ICAP_SUPPORTEDBARCODETYPES and TWEI_BARCODETYPE values
+///
+public enum TWBT : ushort
+{
+ X3OF9 = 0, // 3OF9 in H
+ X2OF5INTERLEAVED = 1, // 2OF5INTERLEAVED in H
+ X2OF5NONINTERLEAVED = 2, // 2OF5NONINTERLEAVED in H
+ CODE93 = 3,
+ CODE128 = 4,
+ UCC128 = 5,
+ CODABAR = 6,
+ UPCA = 7,
+ UPCE = 8,
+ EAN8 = 9,
+ EAN13 = 10,
+ POSTNET = 11,
+ PDF417 = 12,
+ X2OF5INDUSTRIAL = 13, // 2OF5INDUSTRIAL in H
+ X2OF5MATRIX = 14, // 2OF5MATRIX in H
+ X2OF5DATALOGIC = 15, // 2OF5DATALOGIC in H
+ X2OF5IATA = 16, // 2OF5IATA in H
+ X3OF9FULLASCII = 17, // 3OF9FULLASCII in H
+ CODABARWITHSTARTSTOP = 18,
+ MAXICODE = 19,
+ QRCODE = 20
+}
+
+///
+/// ICAP_COMPRESSION values
+///
+public enum TWCP : ushort
+{
+ NONE = 0,
+ PACKBITS = 1,
+ GROUP31D = 2,
+ GROUP31DEOL = 3,
+ GROUP32D = 4,
+ GROUP4 = 5,
+ JPEG = 6,
+ LZW = 7,
+ JBIG = 8,
+ PNG = 9,
+ RLE4 = 10,
+ RLE8 = 11,
+ BITFIELDS = 12,
+ ZIP = 13,
+ JPEG2000 = 14
+}
+
+///
+/// CAP_CAMERASIDE and TWEI_PAGESIDE values
+///
+public enum TWCS : ushort
+{
+ BOTH = 0,
+ TOP = 1,
+ BOTTOM = 2
+}
+
+///
+/// CAP_CLEARBUFFERS values
+///
+public enum TWCB : ushort
+{
+ AUTO = 0,
+ CLEAR = 1,
+ NOCLEAR = 2
+}
+
+///
+/// CAP_DEVICEEVENT values
+///
+public enum TWDE : ushort
+{
+ CUSTOMEVENTS = 0x8000,
+ CHECKAUTOMATICCAPTURE = 0,
+ CHECKBATTERY = 1,
+ CHECKDEVICEONLINE = 2,
+ CHECKFLASH = 3,
+ CHECKPOWERSUPPLY = 4,
+ CHECKRESOLUTION = 5,
+ DEVICEADDED = 6,
+ DEVICEOFFLINE = 7,
+ DEVICEREADY = 8,
+ DEVICEREMOVED = 9,
+ IMAGECAPTURED = 10,
+ IMAGEDELETED = 11,
+ PAPERDOUBLEFEED = 12,
+ PAPERJAM = 13,
+ LAMPFAILURE = 14,
+ POWERSAVE = 15,
+ POWERSAVENOTIFY = 16
+}
+
+///
+/// TW_PASSTHRU.Direction values
+///
+public enum TWDR : ushort
+{
+ GET = 1,
+ SET = 2
+}
+
+///
+/// TWEI_DESKEWSTATUS values
+///
+public enum TWDSK : ushort
+{
+ SUCCESS = 0,
+ REPORTONLY = 1,
+ FAIL = 2,
+ DISABLED = 3
+}
+
+///
+/// CAP_DUPLEX values
+///
+public enum TWDX : ushort
+{
+ NONE = 0,
+ X1PASSDUPLEX = 1, // 1PASSDUPLEX in H
+ X2PASSDUPLEX = 2 // 2PASSDUPLEX in H
+}
+
+///
+/// CAP_FEEDERALIGNMENT values
+///
+public enum TWFA : ushort
+{
+ NONE = 0,
+ LEFT = 1,
+ CENTER = 2,
+ RIGHT = 3
+}
+
+///
+/// ICAP_FEEDERTYPE values
+///
+public enum TWFE : ushort
+{
+ GENERAL = 0,
+ PHOTO = 1
+}
+
+///
+/// ICAP_IMAGEFILEFORMAT values
+///
+public enum TWFF : ushort
+{
+ TIFF = 0,
+ PICT = 1,
+ BMP = 2,
+ XBM = 3,
+ JFIF = 4,
+ FPX = 5,
+ TIFFMULTI = 6,
+ PNG = 7,
+ SPIFF = 8,
+ EXIF = 9,
+ PDF = 10,
+ JP2 = 11,
+ JPX = 13,
+ DEJAVU = 14,
+ PDFA = 15,
+ PDFA2 = 16,
+ PDFRASTER = 17,
+
+ // KODAK
+ RAW = 0x8001,
+ RAWBMP = 0x8002
+}
+
+///
+/// ICAP_FLASHUSED2 values
+///
+public enum TWFL : ushort
+{
+ NONE = 0,
+ OFF = 1,
+ ON = 2,
+ AUTO = 3,
+ REDEYE = 4
+}
+
+///
+/// CAP_FEEDERORDER values
+///
+public enum TWFO : ushort
+{
+ FIRSTPAGEFIRST = 0,
+ LASTPAGEFIRST = 1
+}
+
+///
+/// CAP_FEEDERPOCKET values
+///
+public enum TWFP : ushort
+{
+ POCKETERROR = 0,
+ POCKET1 = 1,
+ POCKET2 = 2,
+ POCKET3 = 3,
+ POCKET4 = 4,
+ POCKET5 = 5,
+ POCKET6 = 6,
+ POCKET7 = 7,
+ POCKET8 = 8,
+ POCKET9 = 9,
+ POCKET10 = 10,
+ POCKET11 = 11,
+ POCKET12 = 12,
+ POCKET13 = 13,
+ POCKET14 = 14,
+ POCKET15 = 15,
+ POCKET16 = 16
+}
+
+///
+/// ICAP_FLIPROTATION values
+///
+public enum TWFR : ushort
+{
+ BOOK = 0,
+ FANFOLD = 1
+}
+
+///
+/// ICAP_FILTER values
+///
+public enum TWFT : ushort
+{
+ RED = 0,
+ GREEN = 1,
+ BLUE = 2,
+ NONE = 3,
+ WHITE = 4,
+ CYAN = 5,
+ MAGENTA = 6,
+ YELLOW = 7,
+ BLACK = 8
+}
+
+///
+/// TW_FILESYSTEM.FileType values
+///
+public enum TWFY : ushort
+{
+ CAMERA = 0,
+ CAMERATOP = 1,
+ CAMERABOTTOM = 2,
+ CAMERAPREVIEW = 3,
+ DOMAIN = 4,
+ HOST = 5,
+ DIRECTORY = 6,
+ IMAGE = 7,
+ UNKNOWN = 8
+}
+
+///
+/// CAP_IAFIELD*_LEVEL values
+///
+public enum TWIA : ushort
+{
+ UNUSED = 0,
+ FIXED = 1,
+ LEVEL1 = 2,
+ LEVEL2 = 3,
+ LEVEL3 = 4,
+ LEVEL4 = 5
+}
+
+///
+/// ICAP_ICCPROFILE values
+///
+public enum TWIC : ushort
+{
+ NONE = 0,
+ LINK = 1,
+ EMBED = 2
+}
+
+///
+/// ICAP_IMAGEFILTER values
+///
+public enum TWIF : ushort
+{
+ NONE = 0,
+ AUTO = 1,
+ LOWPASS = 2,
+ BANDPASS = 3,
+ HIGHPASS = 4,
+ TEXT = BANDPASS,
+ FINELINE = HIGHPASS
+}
+
+///
+/// ICAP_IMAGEMERGE values
+///
+public enum TWIM : ushort
+{
+ NONE = 0,
+ FRONTONTOP = 1,
+ FRONTONBOTTOM = 2,
+ FRONTONLEFT = 3,
+ FRONTONRIGHT = 4
+}
+
+///
+/// CAP_JOBCONTROL values
+///
+public enum TWJC : ushort
+{
+ NONE = 0,
+ JSIC = 1,
+ JSIS = 2,
+ JSXC = 3,
+ JSXS = 4
+}
+
+///
+/// ICAP_JPEGQUALITY values
+///
+public enum TWJQ : short
+{
+ UNKNOWN = -4,
+ LOW = -3,
+ MEDIUM = -2,
+ HIGH = -1
+}
+
+///
+/// ICAP_LIGHTPATH values
+///
+public enum TWLP : ushort
+{
+ REFLECTIVE = 0,
+ TRANSMISSIVE = 1
+}
+
+///
+/// ICAP_LIGHTSOURCE values
+///
+public enum TWLS : ushort
+{
+ RED = 0,
+ GREEN = 1,
+ BLUE = 2,
+ NONE = 3,
+ WHITE = 4,
+ UV = 5,
+ IR = 6
+}
+
+///
+/// TWEI_MAGTYPE values
+///
+public enum TWMD : ushort
+{
+ MICR = 0,
+ RAW = 1,
+ INVALID = 2
+}
+
+///
+/// ICAP_NOISEFILTER values
+///
+public enum TWNF : ushort
+{
+ NONE = 0,
+ AUTO = 1,
+ LONEPIXEL = 2,
+ MAJORITYRULE = 3
+}
+
+///
+/// ICAP_ORIENTATION values
+///
+public enum TWOR : ushort
+{
+ ROT0 = 0,
+ ROT90 = 1,
+ ROT180 = 2,
+ ROT270 = 3,
+ PORTRAIT = ROT0,
+ LANDSCAPE = ROT270,
+ AUTO = 4,
+ AUTOTEXT = 5,
+ AUTOPICTURE = 6
+}
+
+///
+/// ICAP_OVERSCAN values
+///
+public enum TWOV : ushort
+{
+ NONE = 0,
+ AUTO = 1,
+ TOPBOTTOM = 2,
+ LEFTRIGHT = 3,
+ ALL = 4
+}
+
+///
+/// Palette types for TW_PALETTE8
+///
+public enum TWPA : ushort
+{
+ RGB = 0,
+ GRAY = 1,
+ CMY = 2
+}
+
+///
+/// ICAP_PLANARCHUNKY values
+///
+public enum TWPC : ushort
+{
+ CHUNKY = 0,
+ PLANAR = 1
+}
+
+///
+/// TWEI_PATCHCODE values
+///
+public enum TWPCH : ushort
+{
+ PATCH1 = 0,
+ PATCH2 = 1,
+ PATCH3 = 2,
+ PATCH4 = 3,
+ PATCH6 = 4,
+ PATCHT = 5
+}
+
+///
+/// ICAP_PIXELFLAVOR values
+///
+public enum TWPF : ushort
+{
+ CHOCOLATE = 0,
+ VANILLA = 1
+}
+
+///
+/// CAP_PRINTERMODE values
+///
+public enum TWPM : ushort
+{
+ SINGLESTRING = 0,
+ MULTISTRING = 1,
+ COMPOUNDSTRING = 2,
+ IMAGEADDRESSSTRING = 3
+}
+
+///
+/// CAP_PRINTER values
+///
+public enum TWPR : ushort
+{
+ IMPRINTERTOPBEFORE = 0,
+ IMPRINTERTOPAFTER = 1,
+ IMPRINTERBOTTOMBEFORE = 2,
+ IMPRINTERBOTTOMAFTER = 3,
+ ENDORSERTOPBEFORE = 4,
+ ENDORSERTOPAFTER = 5,
+ ENDORSERBOTTOMBEFORE = 6,
+ ENDORSERBOTTOMAFTER = 7
+}
+
+///
+/// CAP_PRINTERFONTSTYLE Added 2.3 (TWPF in H)
+///
+public enum TWPFS : ushort
+{
+ NORMAL = 0,
+ BOLD = 1,
+ ITALIC = 2,
+ LARGESIZE = 3,
+ SMALLSIZE = 4
+}
+
+///
+/// CAP_PRINTERINDEXTRIGGER Added 2.3
+///
+public enum TWCT : ushort
+{
+ PAGE = 0,
+ PATCH1 = 1,
+ PATCH2 = 2,
+ PATCH3 = 3,
+ PATCH4 = 4,
+ PATCHT = 5,
+ PATCH6 = 6
+}
+
+///
+/// CAP_POWERSUPPLY values
+///
+public enum TWPS : ushort
+{
+ EXTERNAL = 0,
+ BATTERY = 1
+}
+
+///
+/// ICAP_PIXELTYPE values (PT_ means Pixel Type)
+///
+public enum TWPT : ushort
+{
+ BW = 0,
+ GRAY = 1,
+ RGB = 2,
+ PALETTE = 3,
+ CMY = 4,
+ CMYK = 5,
+ YUV = 6,
+ YUVK = 7,
+ CIEXYZ = 8,
+ LAB = 9,
+ SRGB = 10,
+ SCRGB = 11,
+ INFRARED = 16
+}
+
+///
+/// CAP_SEGMENTED values
+///
+public enum TWSG : ushort
+{
+ NONE = 0,
+ AUTO = 1,
+ MANUAL = 2
+}
+
+///
+/// ICAP_FILMTYPE values
+///
+public enum TWFM : ushort
+{
+ POSITIVE = 0,
+ NEGATIVE = 1
+}
+
+///
+/// CAP_DOUBLEFEEDDETECTION values
+///
+public enum TWDF : ushort
+{
+ ULTRASONIC = 0,
+ BYLENGTH = 1,
+ INFRARED = 2
+}
+
+///
+/// CAP_DOUBLEFEEDDETECTIONSENSITIVITY values
+///
+public enum TWUS : ushort
+{
+ LOW = 0,
+ MEDIUM = 1,
+ HIGH = 2
+}
+
+///
+/// CAP_DOUBLEFEEDDETECTIONRESPONSE values
+///
+public enum TWDP : ushort
+{
+ STOP = 0,
+ STOPANDWAIT = 1,
+ SOUND = 2,
+ DONOTIMPRINT = 3
+}
+
+///
+/// ICAP_MIRROR values
+///
+public enum TWMR : ushort
+{
+ NONE = 0,
+ VERTICAL = 1,
+ HORIZONTAL = 2
+}
+
+///
+/// ICAP_JPEGSUBSAMPLING values
+///
+public enum TWJS : ushort
+{
+ X444YCBCR = 0, // 444YCBCR in H
+ X444RGB = 1, // 444RGB in H
+ X422 = 2, // 422 in H
+ X421 = 3, // 421 in H
+ X411 = 4, // 411 in H
+ X420 = 5, // 420 in H
+ X410 = 6, // 410 in H
+ X311 = 7 // 311 in H
+}
+
+///
+/// CAP_PAPERHANDLING values
+///
+public enum TWPH : ushort
+{
+ NORMAL = 0,
+ FRAGILE = 1,
+ THICK = 2,
+ TRIFOLD = 3,
+ PHOTOGRAPH = 4
+}
+
+///
+/// CAP_INDICATORSMODE values
+///
+public enum TWCI : ushort
+{
+ INFO = 0,
+ WARNING = 1,
+ ERROR = 2,
+ WARMUP = 3
+}
+
+///
+/// ICAP_SUPPORTEDSIZES values (SS_ means Supported Sizes)
+///
+public enum TWSS : ushort
+{
+ NONE = 0,
+ A4 = 1,
+ JISB5 = 2,
+ USLETTER = 3,
+ USLEGAL = 4,
+ A5 = 5,
+ ISOB4 = 6,
+ ISOB6 = 7,
+ USLEDGER = 9,
+ USEXECUTIVE = 10,
+ A3 = 11,
+ ISOB3 = 12,
+ A6 = 13,
+ C4 = 14,
+ C5 = 15,
+ C6 = 16,
+ X4A0 = 17, // 4A0 in H
+ X2A0 = 18, // 2A0 in H
+ A0 = 19,
+ A1 = 20,
+ A2 = 21,
+ A7 = 22,
+ A8 = 23,
+ A9 = 24,
+ A10 = 25,
+ ISOB0 = 26,
+ ISOB1 = 27,
+ ISOB2 = 28,
+ ISOB5 = 29,
+ ISOB7 = 30,
+ ISOB8 = 31,
+ ISOB9 = 32,
+ ISOB10 = 33,
+ JISB0 = 34,
+ JISB1 = 35,
+ JISB2 = 36,
+ JISB3 = 37,
+ JISB4 = 38,
+ JISB6 = 39,
+ JISB7 = 40,
+ JISB8 = 41,
+ JISB9 = 42,
+ JISB10 = 43,
+ C0 = 44,
+ C1 = 45,
+ C2 = 46,
+ C3 = 47,
+ C7 = 48,
+ C8 = 49,
+ C9 = 50,
+ C10 = 51,
+ USSTATEMENT = 52,
+ BUSINESSCARD = 53,
+ MAXSIZE = 54
+}
+
+///
+/// ICAP_XFERMECH values (SX_ means Setup XFer)
+///
+public enum TWSX : ushort
+{
+ NATIVE = 0,
+ FILE = 1,
+ MEMORY = 2,
+ MEMFILE = 4
+}
+
+///
+/// ICAP_UNITS values (UN_ means UNits)
+///
+public enum TWUN : ushort
+{
+ INCHES = 0,
+ CENTIMETERS = 1,
+ PICAS = 2,
+ POINTS = 3,
+ TWIPS = 4,
+ PIXELS = 5,
+ MILLIMETERS = 6
+}
+
+///
+/// Country Constants
+///
+public enum TWCY : ushort
+{
+ AFGHANISTAN = 1001,
+ ALGERIA = 213,
+ AMERICANSAMOA = 684,
+ ANDORRA = 33,
+ ANGOLA = 1002,
+ ANGUILLA = 8090,
+ ANTIGUA = 8091,
+ ARGENTINA = 54,
+ ARUBA = 297,
+ ASCENSIONI = 247,
+ AUSTRALIA = 61,
+ AUSTRIA = 43,
+ BAHAMAS = 8092,
+ BAHRAIN = 973,
+ BANGLADESH = 880,
+ BARBADOS = 8093,
+ BELGIUM = 32,
+ BELIZE = 501,
+ BENIN = 229,
+ BERMUDA = 8094,
+ BHUTAN = 1003,
+ BOLIVIA = 591,
+ BOTSWANA = 267,
+ BRITAIN = 6,
+ BRITVIRGINIS = 8095,
+ BRAZIL = 55,
+ BRUNEI = 673,
+ BULGARIA = 359,
+ BURKINAFASO = 1004,
+ BURMA = 1005,
+ BURUNDI = 1006,
+ CAMAROON = 237,
+ CANADA = 2,
+ CAPEVERDEIS = 238,
+ CAYMANIS = 8096,
+ CENTRALAFREP = 1007,
+ CHAD = 1008,
+ CHILE = 56,
+ CHINA = 86,
+ CHRISTMASIS = 1009,
+ COCOSIS = 1009,
+ COLOMBIA = 57,
+ COMOROS = 1010,
+ CONGO = 1011,
+ COOKIS = 1012,
+ COSTARICA = 506,
+ CUBA = 5,
+ CYPRUS = 357,
+ CZECHOSLOVAKIA = 42,
+ DENMARK = 45,
+ DJIBOUTI = 1013,
+ DOMINICA = 8097,
+ DOMINCANREP = 8098,
+ EASTERIS = 1014,
+ ECUADOR = 593,
+ EGYPT = 20,
+ ELSALVADOR = 503,
+ EQGUINEA = 1015,
+ ETHIOPIA = 251,
+ FALKLANDIS = 1016,
+ FAEROEIS = 298,
+ FIJIISLANDS = 679,
+ FINLAND = 358,
+ FRANCE = 33,
+ FRANTILLES = 596,
+ FRGUIANA = 594,
+ FRPOLYNEISA = 689,
+ FUTANAIS = 1043,
+ GABON = 241,
+ GAMBIA = 220,
+ GERMANY = 49,
+ GHANA = 233,
+ GIBRALTER = 350,
+ GREECE = 30,
+ GREENLAND = 299,
+ GRENADA = 8099,
+ GRENEDINES = 8015,
+ GUADELOUPE = 590,
+ GUAM = 671,
+ GUANTANAMOBAY = 5399,
+ GUATEMALA = 502,
+ GUINEA = 224,
+ GUINEABISSAU = 1017,
+ GUYANA = 592,
+ HAITI = 509,
+ HONDURAS = 504,
+ HONGKONG = 852,
+ HUNGARY = 36,
+ ICELAND = 354,
+ INDIA = 91,
+ INDONESIA = 62,
+ IRAN = 98,
+ IRAQ = 964,
+ IRELAND = 353,
+ ISRAEL = 972,
+ ITALY = 39,
+ IVORYCOAST = 225,
+ JAMAICA = 8010,
+ JAPAN = 81,
+ JORDAN = 962,
+ KENYA = 254,
+ KIRIBATI = 1018,
+ KOREA = 82,
+ KUWAIT = 965,
+ LAOS = 1019,
+ LEBANON = 1020,
+ LIBERIA = 231,
+ LIBYA = 218,
+ LIECHTENSTEIN = 41,
+ LUXENBOURG = 352,
+ MACAO = 853,
+ MADAGASCAR = 1021,
+ MALAWI = 265,
+ MALAYSIA = 60,
+ MALDIVES = 960,
+ MALI = 1022,
+ MALTA = 356,
+ MARSHALLIS = 692,
+ MAURITANIA = 1023,
+ MAURITIUS = 230,
+ MEXICO = 3,
+ MICRONESIA = 691,
+ MIQUELON = 508,
+ MONACO = 33,
+ MONGOLIA = 1024,
+ MONTSERRAT = 8011,
+ MOROCCO = 212,
+ MOZAMBIQUE = 1025,
+ NAMIBIA = 264,
+ NAURU = 1026,
+ NEPAL = 977,
+ NETHERLANDS = 31,
+ NETHANTILLES = 599,
+ NEVIS = 8012,
+ NEWCALEDONIA = 687,
+ NEWZEALAND = 64,
+ NICARAGUA = 505,
+ NIGER = 227,
+ NIGERIA = 234,
+ NIUE = 1027,
+ NORFOLKI = 1028,
+ NORWAY = 47,
+ OMAN = 968,
+ PAKISTAN = 92,
+ PALAU = 1029,
+ PANAMA = 507,
+ PARAGUAY = 595,
+ PERU = 51,
+ PHILLIPPINES = 63,
+ PITCAIRNIS = 1030,
+ PNEWGUINEA = 675,
+ POLAND = 48,
+ PORTUGAL = 351,
+ QATAR = 974,
+ REUNIONI = 1031,
+ ROMANIA = 40,
+ RWANDA = 250,
+ SAIPAN = 670,
+ SANMARINO = 39,
+ SAOTOME = 1033,
+ SAUDIARABIA = 966,
+ SENEGAL = 221,
+ SEYCHELLESIS = 1034,
+ SIERRALEONE = 1035,
+ SINGAPORE = 65,
+ SOLOMONIS = 1036,
+ SOMALI = 1037,
+ SOUTHAFRICA = 27,
+ SPAIN = 34,
+ SRILANKA = 94,
+ STHELENA = 1032,
+ STKITTS = 8013,
+ STLUCIA = 8014,
+ STPIERRE = 508,
+ STVINCENT = 8015,
+ SUDAN = 1038,
+ SURINAME = 597,
+ SWAZILAND = 268,
+ SWEDEN = 46,
+ SWITZERLAND = 41,
+ SYRIA = 1039,
+ TAIWAN = 886,
+ TANZANIA = 255,
+ THAILAND = 66,
+ TOBAGO = 8016,
+ TOGO = 228,
+ TONGAIS = 676,
+ TRINIDAD = 8016,
+ TUNISIA = 216,
+ TURKEY = 90,
+ TURKSCAICOS = 8017,
+ TUVALU = 1040,
+ UGANDA = 256,
+ USSR = 7,
+ UAEMIRATES = 971,
+ UNITEDKINGDOM = 44,
+ USA = 1,
+ URUGUAY = 598,
+ VANUATU = 1041,
+ VATICANCITY = 39,
+ VENEZUELA = 58,
+ WAKE = 1042,
+ WALLISIS = 1043,
+ WESTERNSAHARA = 1044,
+ WESTERNSAMOA = 1045,
+ YEMEN = 1046,
+ YUGOSLAVIA = 38,
+ ZAIRE = 243,
+ ZAMBIA = 260,
+ ZIMBABWE = 263,
+ ALBANIA = 355,
+ ARMENIA = 374,
+ AZERBAIJAN = 994,
+ BELARUS = 375,
+ BOSNIAHERZGO = 387,
+ CAMBODIA = 855,
+ CROATIA = 385,
+ CZECHREPUBLIC = 420,
+ DIEGOGARCIA = 246,
+ ERITREA = 291,
+ ESTONIA = 372,
+ GEORGIA = 995,
+ LATVIA = 371,
+ LESOTHO = 266,
+ LITHUANIA = 370,
+ MACEDONIA = 389,
+ MAYOTTEIS = 269,
+ MOLDOVA = 373,
+ MYANMAR = 95,
+ NORTHKOREA = 850,
+ PUERTORICO = 787,
+ RUSSIA = 7,
+ SERBIA = 381,
+ SLOVAKIA = 421,
+ SLOVENIA = 386,
+ SOUTHKOREA = 82,
+ UKRAINE = 380,
+ USVIRGINIS = 340,
+ VIETNAM = 84
+}
+
+///
+/// Language Constants
+///
+public enum TWLG : short
+{
+ USERLOCALE = -1,
+ DAN = 0,
+ DUT = 1,
+ ENG = 2,
+ FCF = 3,
+ FIN = 4,
+ FRN = 5,
+ GER = 6,
+ ICE = 7,
+ ITN = 8,
+ NOR = 9,
+ POR = 10,
+ SPA = 11,
+ SWE = 12,
+ USA = 13,
+ AFRIKAANS = 14,
+ ALBANIA = 15,
+ ARABIC = 16,
+ ARABIC_ALGERIA = 17,
+ ARABIC_BAHRAIN = 18,
+ ARABIC_EGYPT = 19,
+ ARABIC_IRAQ = 20,
+ ARABIC_JORDAN = 21,
+ ARABIC_KUWAIT = 22,
+ ARABIC_LEBANON = 23,
+ ARABIC_LIBYA = 24,
+ ARABIC_MOROCCO = 25,
+ ARABIC_OMAN = 26,
+ ARABIC_QATAR = 27,
+ ARABIC_SAUDIARABIA = 28,
+ ARABIC_SYRIA = 29,
+ ARABIC_TUNISIA = 30,
+ ARABIC_UAE = 31,
+ ARABIC_YEMEN = 32,
+ BASQUE = 33,
+ BYELORUSSIAN = 34,
+ BULGARIAN = 35,
+ CATALAN = 36,
+ CHINESE = 37,
+ CHINESE_HONGKONG = 38,
+ CHINESE_PRC = 39,
+ CHINESE_SINGAPORE = 40,
+ CHINESE_SIMPLIFIED = 41,
+ CHINESE_TAIWAN = 42,
+ CHINESE_TRADITIONAL = 43,
+ CROATIA = 44,
+ CZECH = 45,
+ DANISH = DAN,
+ DUTCH = DUT,
+ DUTCH_BELGIAN = 46,
+ ENGLISH = ENG,
+ ENGLISH_AUSTRALIAN = 47,
+ ENGLISH_CANADIAN = 48,
+ ENGLISH_IRELAND = 49,
+ ENGLISH_NEWZEALAND = 50,
+ ENGLISH_SOUTHAFRICA = 51,
+ ENGLISH_UK = 52,
+ ENGLISH_USA = USA,
+ ESTONIAN = 53,
+ FAEROESE = 54,
+ FARSI = 55,
+ FINNISH = FIN,
+ FRENCH = FRN,
+ FRENCH_BELGIAN = 56,
+ FRENCH_CANADIAN = FCF,
+ FRENCH_LUXEMBOURG = 57,
+ FRENCH_SWISS = 58,
+ GERMAN = GER,
+ GERMAN_AUSTRIAN = 59,
+ GERMAN_LUXEMBOURG = 60,
+ GERMAN_LIECHTENSTEIN = 61,
+ GERMAN_SWISS = 62,
+ GREEK = 63,
+ HEBREW = 64,
+ HUNGARIAN = 65,
+ ICELANDIC = ICE,
+ INDONESIAN = 66,
+ ITALIAN = ITN,
+ ITALIAN_SWISS = 67,
+ JAPANESE = 68,
+ KOREAN = 69,
+ KOREAN_JOHAB = 70,
+ LATVIAN = 71,
+ LITHUANIAN = 72,
+ NORWEGIAN = NOR,
+ NORWEGIAN_BOKMAL = 73,
+ NORWEGIAN_NYNORSK = 74,
+ POLISH = 75,
+ PORTUGUESE = POR,
+ PORTUGUESE_BRAZIL = 76,
+ ROMANIAN = 77,
+ RUSSIAN = 78,
+ SERBIAN_LATIN = 79,
+ SLOVAK = 80,
+ SLOVENIAN = 81,
+ SPANISH = TWLG.SPA,
+ SPANISH_MEXICAN = 82,
+ SPANISH_MODERN = 83,
+ SWEDISH = TWLG.SWE,
+ THAI = 84,
+ TURKISH = 85,
+ UKRANIAN = 86,
+ ASSAMESE = 87,
+ BENGALI = 88,
+ BIHARI = 89,
+ BODO = 90,
+ DOGRI = 91,
+ GUJARATI = 92,
+ HARYANVI = 93,
+ HINDI = 94,
+ KANNADA = 95,
+ KASHMIRI = 96,
+ MALAYALAM = 97,
+ MARATHI = 98,
+ MARWARI = 99,
+ MEGHALAYAN = 100,
+ MIZO = 101,
+ NAGA = 102,
+ ORISSI = 103,
+ PUNJABI = 104,
+ PUSHTU = 105,
+ SERBIAN_CYRILLIC = 106,
+ SIKKIMI = 107,
+ SWEDISH_FINLAND = 108,
+ TAMIL = 109,
+ TELUGU = 110,
+ TRIPURI = 111,
+ URDU = 112,
+ VIETNAMESE = 113
+ //NOTE: when adding to this list, also update Language->Set()
+}
+
+#endregion
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Data Groups...
+///////////////////////////////////////////////////////////////////////////////
+#region Data Groups...
+
+///
+/// Data Groups...
+///
+[Flags]
+public enum DG : uint
+{
+ CONTROL = 0x1,
+ IMAGE = 0x2,
+ AUDIO = 0x4,
+
+ // More Data Functionality may be added in the future.
+ // These are for items that need to be determined before DS is opened.
+ // NOTE: Supported Functionality constants must be powers of 2 as they are
+ // used as bitflags when Application asks DSM to present a list of DSs.
+ // to support backward capability the App and DS will not use the fields
+ DSM2 = 0x10000000,
+ APP2 = 0x20000000,
+ DS2 = 0x40000000,
+ MASK = 0xFFFF
+}
+
+#endregion
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Data Argument Types...
+///////////////////////////////////////////////////////////////////////////////
+#region Data Argument Types...
+
+///
+/// Data Argument Types...
+///
+public enum DAT : ushort
+{
+ // NULL and Custom Base...
+ NULL = 0x0,
+ CUSTOM = 0x8000,
+
+ // Data Argument Types for the DG_CONTROL Data Group.
+ CAPABILITY = 0x1,
+ EVENT = 0x2,
+ IDENTITY = 0x3,
+ PARENT = 0x4,
+ PENDINGXFERS = 0x5,
+ SETUPMEMXFER = 0x6,
+ SETUPFILEXFER = 0x7,
+ STATUS = 0x8,
+ USERINTERFACE = 0x9,
+ XFERGROUP = 0xa,
+ CUSTOMDSDATA = 0xc,
+ DEVICEEVENT = 0xd,
+ FILESYSTEM = 0xe,
+ PASSTHRU = 0xf,
+ CALLBACK = 0x10,
+ STATUSUTF8 = 0x11,
+ CALLBACK2 = 0x12,
+ METRICS = 0x13,
+ TWAINDIRECT = 0x14,
+
+ // Data Argument Types for the DG_IMAGE Data Group.
+ IMAGEINFO = 0x0101,
+ IMAGELAYOUT = 0x0102,
+ IMAGEMEMXFER = 0x0103,
+ IMAGENATIVEXFER = 0x0104,
+ IMAGEFILEXFER = 0x105,
+ CIECOLOR = 0x106,
+ GRAYRESPONSE = 0x107,
+ RGBRESPONSE = 0x108,
+ JPEGCOMPRESSION = 0x109,
+ PALETTE8 = 0x10a,
+ EXTIMAGEINFO = 0x10b,
+ FILTER = 0x10c,
+
+ /* Data Argument Types for the DG_AUDIO Data Group. */
+ AUDIOFILEXFER = 0x201,
+ AUDIOINFO = 0x202,
+ AUDIONATIVEXFER = 0x203,
+
+ /* misplaced */
+ ICCPROFILE = 0x401,
+ IMAGEMEMFILEXFER = 0x402,
+ ENTRYPOINT = 0x403
+}
+
+#endregion
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Messages...
+///////////////////////////////////////////////////////////////////////////////
+#region Messages...
+
+///
+/// All message constants are unique.
+/// Messages are grouped according to which DATs they are used with.
+///
+public enum MSG : ushort
+{
+ // Only used to clear fields...
+ NULL = 0x0,
+
+ // Generic messages may be used with any of several DATs.
+ GET = 0x1,
+ GETCURRENT = 0x2,
+ GETDEFAULT = 0x3,
+ GETFIRST = 0x4,
+ GETNEXT = 0x5,
+ SET = 0x6,
+ RESET = 0x7,
+ QUERYSUPPORT = 0x8,
+ GETHELP = 0x9,
+ GETLABEL = 0xa,
+ GETLABELENUM = 0xb,
+ SETCONSTRAINT = 0xc,
+
+ // Messages used with DAT_NULL.
+ XFERREADY = 0x101,
+ CLOSEDSREQ = 0x102,
+ CLOSEDSOK = 0x103,
+ DEVICEEVENT = 0x104,
+
+ // Messages used with a pointer to DAT_PARENT data.
+ OPENDSM = 0x301,
+ CLOSEDSM = 0x302,
+
+ // Messages used with a pointer to a DAT_IDENTITY structure.
+ OPENDS = 0x401,
+ CLOSEDS = 0x402,
+ USERSELECT = 0x403,
+
+ // Messages used with a pointer to a DAT_USERINTERFACE structure.
+ DISABLEDS = 0x501,
+ ENABLEDS = 0x502,
+ ENABLEDSUIONLY = 0x503,
+
+ // Messages used with a pointer to a DAT_EVENT structure.
+ PROCESSEVENT = 0x601,
+
+ // Messages used with a pointer to a DAT_PENDINGXFERS structure
+ ENDXFER = 0x701,
+ STOPFEEDER = 0x702,
+
+ // Messages used with a pointer to a DAT_FILESYSTEM structure
+ CHANGEDIRECTORY = 0x0801,
+ CREATEDIRECTORY = 0x0802,
+ DELETE = 0x0803,
+ FORMATMEDIA = 0x0804,
+ GETCLOSE = 0x0805,
+ GETFIRSTFILE = 0x0806,
+ GETINFO = 0x0807,
+ GETNEXTFILE = 0x0808,
+ RENAME = 0x0809,
+ COPY = 0x080A,
+ AUTOMATICCAPTUREDIRECTORY = 0x080B,
+
+ // Messages used with a pointer to a DAT_PASSTHRU structure
+ PASSTHRU = 0x0901,
+
+ // used with DAT_CALLBACK
+ REGISTER_CALLBACK = 0x0902,
+
+ // used with DAT_CAPABILITY
+ RESETALL = 0x0A01,
+
+ // used with DAT_TWAINDIRECT
+ SETTASK = 0x0B01,
+}
+
+#endregion
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Capabilities...
+///////////////////////////////////////////////////////////////////////////////
+#region Capabilities...
+
+///
+/// The naming convention is a little awkward, but it allows us to
+/// achieve a unified capability type...
+///
+public enum CAP : ushort
+{
+ // Base of custom capabilities.
+ CAP_CUSTOMBASE = 0x8000,
+
+ /* all data sources are REQUIRED to support these caps */
+ CAP_XFERCOUNT = 0x0001,
+
+ /* image data sources are REQUIRED to support these caps */
+ ICAP_COMPRESSION = 0x0100,
+ ICAP_PIXELTYPE = 0x0101,
+ ICAP_UNITS = 0x0102,
+ ICAP_XFERMECH = 0x0103,
+
+ // all data sources MAY support these caps.
+ CAP_AUTHOR = 0x1000,
+ CAP_CAPTION = 0x1001,
+ CAP_FEEDERENABLED = 0x1002,
+ CAP_FEEDERLOADED = 0x1003,
+ CAP_TIMEDATE = 0x1004,
+ CAP_SUPPORTEDCAPS = 0x1005,
+ CAP_EXTENDEDCAPS = 0x1006,
+ CAP_AUTOFEED = 0x1007,
+ CAP_CLEARPAGE = 0x1008,
+ CAP_FEEDPAGE = 0x1009,
+ CAP_REWINDPAGE = 0x100a,
+ CAP_INDICATORS = 0x100b,
+ CAP_PAPERDETECTABLE = 0x100d,
+ CAP_UICONTROLLABLE = 0x100e,
+ CAP_DEVICEONLINE = 0x100f,
+ CAP_AUTOSCAN = 0x1010,
+ CAP_THUMBNAILSENABLED = 0x1011,
+ CAP_DUPLEX = 0x1012,
+ CAP_DUPLEXENABLED = 0x1013,
+ CAP_ENABLEDSUIONLY = 0x1014,
+ CAP_CUSTOMDSDATA = 0x1015,
+ CAP_ENDORSER = 0x1016,
+ CAP_JOBCONTROL = 0x1017,
+ CAP_ALARMS = 0x1018,
+ CAP_ALARMVOLUME = 0x1019,
+ CAP_AUTOMATICCAPTURE = 0x101a,
+ CAP_TIMEBEFOREFIRSTCAPTURE = 0x101b,
+ CAP_TIMEBETWEENCAPTURES = 0x101c,
+ CAP_CLEARBUFFERS = 0x101d,
+ CAP_MAXBATCHBUFFERS = 0x101e,
+ CAP_DEVICETIMEDATE = 0x101f,
+ CAP_POWERSUPPLY = 0x1020,
+ CAP_CAMERAPREVIEWUI = 0x1021,
+ CAP_DEVICEEVENT = 0x1022,
+ CAP_SERIALNUMBER = 0x1024,
+ CAP_PRINTER = 0x1026,
+ CAP_PRINTERENABLED = 0x1027,
+ CAP_PRINTERINDEX = 0x1028,
+ CAP_PRINTERMODE = 0x1029,
+ CAP_PRINTERSTRING = 0x102a,
+ CAP_PRINTERSUFFIX = 0x102b,
+ CAP_LANGUAGE = 0x102c,
+ CAP_FEEDERALIGNMENT = 0x102d,
+ CAP_FEEDERORDER = 0x102e,
+ CAP_REACQUIREALLOWED = 0x1030,
+ CAP_BATTERYMINUTES = 0x1032,
+ CAP_BATTERYPERCENTAGE = 0x1033,
+ CAP_CAMERASIDE = 0x1034,
+ CAP_SEGMENTED = 0x1035,
+ CAP_CAMERAENABLED = 0x1036,
+ CAP_CAMERAORDER = 0x1037,
+ CAP_MICRENABLED = 0x1038,
+ CAP_FEEDERPREP = 0x1039,
+ CAP_FEEDERPOCKET = 0x103a,
+ CAP_AUTOMATICSENSEMEDIUM = 0x103b,
+ CAP_CUSTOMINTERFACEGUID = 0x103c,
+ CAP_SUPPORTEDCAPSSEGMENTUNIQUE = 0x103d,
+ CAP_SUPPORTEDDATS = 0x103e,
+ CAP_DOUBLEFEEDDETECTION = 0x103f,
+ CAP_DOUBLEFEEDDETECTIONLENGTH = 0x1040,
+ CAP_DOUBLEFEEDDETECTIONSENSITIVITY = 0x1041,
+ CAP_DOUBLEFEEDDETECTIONRESPONSE = 0x1042,
+ CAP_PAPERHANDLING = 0x1043,
+ CAP_INDICATORSMODE = 0x1044,
+ CAP_PRINTERVERTICALOFFSET = 0x1045,
+ CAP_POWERSAVETIME = 0x1046,
+ CAP_PRINTERCHARROTATION = 0x1047,
+ CAP_PRINTERFONTSTYLE = 0x1048,
+ CAP_PRINTERINDEXLEADCHAR = 0x1049,
+ CAP_PRINTERINDEXMAXVALUE = 0x104A,
+ CAP_PRINTERINDEXNUMDIGITS = 0x104B,
+ CAP_PRINTERINDEXSTEP = 0x104C,
+ CAP_PRINTERINDEXTRIGGER = 0x104D,
+ CAP_PRINTERSTRINGPREVIEW = 0x104E,
+ CAP_SHEETCOUNT = 0x104F,
+ CAP_IMAGEADDRESSENABLED = 0x1050,
+ CAP_IAFIELDA_LEVEL = 0x1051,
+ CAP_IAFIELDB_LEVEL = 0x1052,
+ CAP_IAFIELDC_LEVEL = 0x1053,
+ CAP_IAFIELDD_LEVEL = 0x1054,
+ CAP_IAFIELDE_LEVEL = 0x1055,
+ CAP_IAFIELDA_PRINTFORMAT = 0x1056,
+ CAP_IAFIELDB_PRINTFORMAT = 0x1057,
+ CAP_IAFIELDC_PRINTFORMAT = 0x1058,
+ CAP_IAFIELDD_PRINTFORMAT = 0x1059,
+ CAP_IAFIELDE_PRINTFORMAT = 0x105A,
+ CAP_IAFIELDA_VALUE = 0x105B,
+ CAP_IAFIELDB_VALUE = 0x105C,
+ CAP_IAFIELDC_VALUE = 0x105D,
+ CAP_IAFIELDD_VALUE = 0x105E,
+ CAP_IAFIELDE_VALUE = 0x105F,
+ CAP_IAFIELDA_LASTPAGE = 0x1060,
+ CAP_IAFIELDB_LASTPAGE = 0x1061,
+ CAP_IAFIELDC_LASTPAGE = 0x1062,
+ CAP_IAFIELDD_LASTPAGE = 0x1063,
+ CAP_IAFIELDE_LASTPAGE = 0x1064,
+
+ // image data sources MAY support these caps.
+ ICAP_AUTOBRIGHT = 0x1100,
+ ICAP_BRIGHTNESS = 0x1101,
+ ICAP_CONTRAST = 0x1103,
+ ICAP_CUSTHALFTONE = 0x1104,
+ ICAP_EXPOSURETIME = 0x1105,
+ ICAP_FILTER = 0x1106,
+ ICAP_FLASHUSED = 0x1107,
+ ICAP_GAMMA = 0x1108,
+ ICAP_HALFTONES = 0x1109,
+ ICAP_HIGHLIGHT = 0x110a,
+ ICAP_IMAGEFILEFORMAT = 0x110c,
+ ICAP_LAMPSTATE = 0x110d,
+ ICAP_LIGHTSOURCE = 0x110e,
+ ICAP_ORIENTATION = 0x1110,
+ ICAP_PHYSICALWIDTH = 0x1111,
+ ICAP_PHYSICALHEIGHT = 0x1112,
+ ICAP_SHADOW = 0x1113,
+ ICAP_FRAMES = 0x1114,
+ ICAP_XNATIVERESOLUTION = 0x1116,
+ ICAP_YNATIVERESOLUTION = 0x1117,
+ ICAP_XRESOLUTION = 0x1118,
+ ICAP_YRESOLUTION = 0x1119,
+ ICAP_MAXFRAMES = 0x111a,
+ ICAP_TILES = 0x111b,
+ ICAP_BITORDER = 0x111c,
+ ICAP_CCITTKFACTOR = 0x111d,
+ ICAP_LIGHTPATH = 0x111e,
+ ICAP_PIXELFLAVOR = 0x111f,
+ ICAP_PLANARCHUNKY = 0x1120,
+ ICAP_ROTATION = 0x1121,
+ ICAP_SUPPORTEDSIZES = 0x1122,
+ ICAP_THRESHOLD = 0x1123,
+ ICAP_XSCALING = 0x1124,
+ ICAP_YSCALING = 0x1125,
+ ICAP_BITORDERCODES = 0x1126,
+ ICAP_PIXELFLAVORCODES = 0x1127,
+ ICAP_JPEGPIXELTYPE = 0x1128,
+ ICAP_TIMEFILL = 0x112a,
+ ICAP_BITDEPTH = 0x112b,
+ ICAP_BITDEPTHREDUCTION = 0x112c,
+ ICAP_UNDEFINEDIMAGESIZE = 0x112d,
+ ICAP_IMAGEDATASET = 0x112e,
+ ICAP_EXTIMAGEINFO = 0x112f,
+ ICAP_MINIMUMHEIGHT = 0x1130,
+ ICAP_MINIMUMWIDTH = 0x1131,
+ ICAP_AUTODISCARDBLANKPAGES = 0x1134,
+ ICAP_FLIPROTATION = 0x1136,
+ ICAP_BARCODEDETECTIONENABLED = 0x1137,
+ ICAP_SUPPORTEDBARCODETYPES = 0x1138,
+ ICAP_BARCODEMAXSEARCHPRIORITIES = 0x1139,
+ ICAP_BARCODESEARCHPRIORITIES = 0x113a,
+ ICAP_BARCODESEARCHMODE = 0x113b,
+ ICAP_BARCODEMAXRETRIES = 0x113c,
+ ICAP_BARCODETIMEOUT = 0x113d,
+ ICAP_ZOOMFACTOR = 0x113e,
+ ICAP_PATCHCODEDETECTIONENABLED = 0x113f,
+ ICAP_SUPPORTEDPATCHCODETYPES = 0x1140,
+ ICAP_PATCHCODEMAXSEARCHPRIORITIES = 0x1141,
+ ICAP_PATCHCODESEARCHPRIORITIES = 0x1142,
+ ICAP_PATCHCODESEARCHMODE = 0x1143,
+ ICAP_PATCHCODEMAXRETRIES = 0x1144,
+ ICAP_PATCHCODETIMEOUT = 0x1145,
+ ICAP_FLASHUSED2 = 0x1146,
+ ICAP_IMAGEFILTER = 0x1147,
+ ICAP_NOISEFILTER = 0x1148,
+ ICAP_OVERSCAN = 0x1149,
+ ICAP_AUTOMATICBORDERDETECTION = 0x1150,
+ ICAP_AUTOMATICDESKEW = 0x1151,
+ ICAP_AUTOMATICROTATE = 0x1152,
+ ICAP_JPEGQUALITY = 0x1153,
+ ICAP_FEEDERTYPE = 0x1154,
+ ICAP_ICCPROFILE = 0x1155,
+ ICAP_AUTOSIZE = 0x1156,
+ ICAP_AUTOMATICCROPUSESFRAME = 0x1157,
+ ICAP_AUTOMATICLENGTHDETECTION = 0x1158,
+ ICAP_AUTOMATICCOLORENABLED = 0x1159,
+ ICAP_AUTOMATICCOLORNONCOLORPIXELTYPE = 0x115a,
+ ICAP_COLORMANAGEMENTENABLED = 0x115b,
+ ICAP_IMAGEMERGE = 0x115c,
+ ICAP_IMAGEMERGEHEIGHTTHRESHOLD = 0x115d,
+ ICAP_SUPPORTEDEXTIMAGEINFO = 0x115e,
+ ICAP_FILMTYPE = 0x115f,
+ ICAP_MIRROR = 0x1160,
+ ICAP_JPEGSUBSAMPLING = 0x1161,
+
+ // image data sources MAY support these audio caps.
+ ACAP_XFERMECH = 0x1202
+}
+
+#endregion
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Extended Image Info Attributes section Added 1.7...
+///////////////////////////////////////////////////////////////////////////////
+#region Extended Image Info Attributes section Added 1.7...
+
+///
+/// Extended Image Info Attributes...
+///
+public enum TWEI : ushort
+{
+ BARCODEX = 0x1200,
+ BARCODEY = 0x1201,
+ BARCODETEXT = 0x1202,
+ BARCODETYPE = 0x1203,
+ DESHADETOP = 0x1204,
+ DESHADELEFT = 0x1205,
+ DESHADEHEIGHT = 0x1206,
+ DESHADEWIDTH = 0x1207,
+ DESHADESIZE = 0x1208,
+ SPECKLESREMOVED = 0x1209,
+ HORZLINEXCOORD = 0x120A,
+ HORZLINEYCOORD = 0x120B,
+ HORZLINELENGTH = 0x120C,
+ HORZLINETHICKNESS = 0x120D,
+ VERTLINEXCOORD = 0x120E,
+ VERTLINEYCOORD = 0x120F,
+ VERTLINELENGTH = 0x1210,
+ VERTLINETHICKNESS = 0x1211,
+ PATCHCODE = 0x1212,
+ ENDORSEDTEXT = 0x1213,
+ FORMCONFIDENCE = 0x1214,
+ FORMTEMPLATEMATCH = 0x1215,
+ FORMTEMPLATEPAGEMATCH = 0x1216,
+ FORMHORZDOCOFFSET = 0x1217,
+ FORMVERTDOCOFFSET = 0x1218,
+ BARCODECOUNT = 0x1219,
+ BARCODECONFIDENCE = 0x121A,
+ BARCODEROTATION = 0x121B,
+ BARCODETEXTLENGTH = 0x121C,
+ DESHADECOUNT = 0x121D,
+ DESHADEBLACKCOUNTOLD = 0x121E,
+ DESHADEBLACKCOUNTNEW = 0x121F,
+ DESHADEBLACKRLMIN = 0x1220,
+ DESHADEBLACKRLMAX = 0x1221,
+ DESHADEWHITECOUNTOLD = 0x1222,
+ DESHADEWHITECOUNTNEW = 0x1223,
+ DESHADEWHITERLMIN = 0x1224,
+ DESHADEWHITERLAVE = 0x1225,
+ DESHADEWHITERLMAX = 0x1226,
+ BLACKSPECKLESREMOVED = 0x1227,
+ WHITESPECKLESREMOVED = 0x1228,
+ HORZLINECOUNT = 0x1229,
+ VERTLINECOUNT = 0x122A,
+ DESKEWSTATUS = 0x122B,
+ SKEWORIGINALANGLE = 0x122C,
+ SKEWFINALANGLE = 0x122D,
+ SKEWCONFIDENCE = 0x122E,
+ SKEWWINDOWX1 = 0x122F,
+ SKEWWINDOWY1 = 0x1230,
+ SKEWWINDOWX2 = 0x1231,
+ SKEWWINDOWY2 = 0x1232,
+ SKEWWINDOWX3 = 0x1233,
+ SKEWWINDOWY3 = 0x1234,
+ SKEWWINDOWX4 = 0x1235,
+ SKEWWINDOWY4 = 0x1236,
+ BOOKNAME = 0x1238,
+ CHAPTERNUMBER = 0x1239,
+ DOCUMENTNUMBER = 0x123A,
+ PAGENUMBER = 0x123B,
+ CAMERA = 0x123C,
+ FRAMENUMBER = 0x123D,
+ FRAME = 0x123E,
+ PIXELFLAVOR = 0x123F,
+ ICCPROFILE = 0x1240,
+ LASTSEGMENT = 0x1241,
+ SEGMENTNUMBER = 0x1242,
+ MAGDATA = 0x1243,
+ MAGTYPE = 0x1244,
+ PAGESIDE = 0x1245,
+ FILESYSTEMSOURCE = 0x1246,
+ IMAGEMERGED = 0x1247,
+ MAGDATALENGTH = 0x1248,
+ PAPERCOUNT = 0x1249,
+ PRINTERTEXT = 0x124A,
+ TWAINDIRECTMETADATA = 0x124B,
+ IAFIELDA_VALUE = 0x124C,
+ IAFIELDB_VALUE = 0x124D,
+ IAFIELDC_VALUE = 0x124E,
+ IAFIELDD_VALUE = 0x124F,
+ IAFIELDE_VALUE = 0x1250,
+ IALEVEL = 0x1251,
+ PRINTER = 0x1252,
+ BARCODETEXT2 = 0x1253,
+}
+
+public enum TWEJ : ushort
+{
+ NONE = 0x0000,
+ MIDSEPARATOR = 0x0001,
+ PATCH1 = 0x0002,
+ PATCH2 = 0x0003,
+ PATCH3 = 0x0004,
+ PATCH4 = 0x0005,
+ PATCH6 = 0x0006,
+ PATCHT = 0x0007
+}
+
+#endregion
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Return Codes and Condition Codes section...
+///////////////////////////////////////////////////////////////////////////////
+#region Return Codes and Condition Codes section...
+
+//public enum STS
+//{
+// // Custom base (same for TWRC and TWCC)...
+// CUSTOMBASE = 0x8000,
+
+// // Return codes...
+// SUCCESS = 0,
+// FAILURE = 1,
+// CHECKSTATUS = 2,
+// CANCEL = 3,
+// DSEVENT = 4,
+// NOTDSEVENT = 5,
+// XFERDONE = 6,
+// ENDOFLIST = 7,
+// INFONOTSUPPORTED = 8,
+// DATANOTAVAILABLE = 9,
+// BUSY = 10,
+// SCANNERLOCKED = 11,
+
+// // Condition codes (always associated with TWRC_FAILURE)...
+// BUMMER = TwainConst.STSCC + 1,
+// LOWMEMORY = TwainConst.STSCC + 2,
+// NODS = TwainConst.STSCC + 3,
+// MAXCONNECTIONS = TwainConst.STSCC + 4,
+// OPERATIONERROR = TwainConst.STSCC + 5,
+// BADCAP = TwainConst.STSCC + 6,
+// BADPROTOCOL = TwainConst.STSCC + 9,
+// BADVALUE = TwainConst.STSCC + 10,
+// SEQERROR = TwainConst.STSCC + 11,
+// BADDEST = TwainConst.STSCC + 12,
+// CAPUNSUPPORTED = TwainConst.STSCC + 13,
+// CAPBADOPERATION = TwainConst.STSCC + 14,
+// CAPSEQERROR = TwainConst.STSCC + 15,
+// DENIED = TwainConst.STSCC + 16,
+// FILEEXISTS = TwainConst.STSCC + 17,
+// FILENOTFOUND = TwainConst.STSCC + 18,
+// NOTEMPTY = TwainConst.STSCC + 19,
+// PAPERJAM = TwainConst.STSCC + 20,
+// PAPERDOUBLEFEED = TwainConst.STSCC + 21,
+// FILEWRITEERROR = TwainConst.STSCC + 22,
+// CHECKDEVICEONLINE = TwainConst.STSCC + 23,
+// INTERLOCK = TwainConst.STSCC + 24,
+// DAMAGEDCORNER = TwainConst.STSCC + 25,
+// FOCUSERROR = TwainConst.STSCC + 26,
+// DOCTOOLIGHT = TwainConst.STSCC + 27,
+// DOCTOODARK = TwainConst.STSCC + 28,
+// NOMEDIA = TwainConst.STSCC + 29
+//}
+
+///
+/// bit patterns: for query the operation that are supported by the data source on a capability
+/// Application gets these through DG_CONTROL/DAT_CAPABILITY/MSG_QUERYSUPPORT
+///
+[Flags]
+public enum TWQC : ushort
+{
+ Unknown = 0,
+ GET = 0x0001,
+ SET = 0x0002,
+ GETDEFAULT = 0x0004,
+ GETCURRENT = 0x0008,
+ RESET = 0x0010,
+ SETCONSTRAINT = 0x0020,
+ CONSTRAINABLE = 0x0040,
+ // KODAK additions
+ ///
+ /// KODAK ONLY: applies to entire session/machine
+ ///
+ MACHINE = 0x1000,
+ ///
+ /// KODAK ONLY: applies to Bitonal "cameras"
+ ///
+ BITONAL = 0x2000,
+ ///
+ /// KODAK ONLY: applies to Color "cameras"
+ ///
+ COLOR = 0x3000
+}
+
+///
+/// The TWAIN States...
+///
+public enum STATE
+{
+ S1 = 1, // Nothing loaded or open
+ S2 = 2, // DSM loaded
+ S3 = 3, // DSM open
+ S4 = 4, // Data Source open, programmatic mode (no GUI)
+ S5 = 5, // GUI up or waiting to transfer first image
+ S6 = 6, // ready to start transferring image
+ S7 = 7 // transferring image or transfer done
+}
+
+#endregion
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Language section...
+///////////////////////////////////////////////////////////////////////////////
+#region Language section...
+
+///
+/// Handle encoding between C# and what the DS is currently set to.
+/// NOTE: this is static for users of this object do not have to track
+/// the encoding (i.e. let cs deal with all of this). This
+/// means there is one language for all open DSes, so the last one wins.
+///
+public static class Language
+{
+ ///
+ /// The encoding to use for strings to/from the DS
+ ///
+ ///
+ public static Encoding GetEncoding()
+ {
+ return (m_encoding);
+ }
+
+ ///
+ /// The current language of the DS
+ ///
+ ///
+ public static void Set(TWLG a_twlg)
+ {
+ switch (a_twlg)
+ {
+ default:
+ // NOTE: can only get here if a TWLG was added, but it wasn't added here
+ m_encoding = Encoding.GetEncoding(1252);
+ break;
+
+ case TWLG.USERLOCALE:
+ // NOTE: this should never come back from the DS. only here for completeness
+ m_encoding = Encoding.GetEncoding(1252);
+ break;
+
+ case TWLG.THAI:
+ m_encoding = Encoding.GetEncoding(874);
+ break;
+
+ case TWLG.JAPANESE:
+ m_encoding = Encoding.GetEncoding(932);
+ break;
+
+ case TWLG.CHINESE:
+ case TWLG.CHINESE_PRC:
+ case TWLG.CHINESE_SINGAPORE:
+ case TWLG.CHINESE_SIMPLIFIED:
+ m_encoding = Encoding.GetEncoding(936);
+ break;
+
+ case TWLG.KOREAN:
+ case TWLG.KOREAN_JOHAB:
+ m_encoding = Encoding.GetEncoding(949);
+ break;
+
+ case TWLG.CHINESE_HONGKONG:
+ case TWLG.CHINESE_TAIWAN:
+ case TWLG.CHINESE_TRADITIONAL:
+ m_encoding = Encoding.GetEncoding(950);
+ break;
+
+ case TWLG.ALBANIA:
+ case TWLG.CROATIA:
+ case TWLG.CZECH:
+ case TWLG.HUNGARIAN:
+ case TWLG.POLISH:
+ case TWLG.ROMANIAN:
+ case TWLG.SERBIAN_LATIN:
+ case TWLG.SLOVAK:
+ case TWLG.SLOVENIAN:
+ m_encoding = Encoding.GetEncoding(1250);
+ break;
+
+ case TWLG.BYELORUSSIAN:
+ case TWLG.BULGARIAN:
+ case TWLG.RUSSIAN:
+ case TWLG.SERBIAN_CYRILLIC:
+ case TWLG.UKRANIAN:
+ m_encoding = Encoding.GetEncoding(1251);
+ break;
+
+ case TWLG.AFRIKAANS:
+ case TWLG.BASQUE:
+ case TWLG.CATALAN:
+ case TWLG.DAN: // DANISH
+ case TWLG.DUT: // DUTCH
+ case TWLG.DUTCH_BELGIAN:
+ case TWLG.ENG: // ENGLISH
+ case TWLG.ENGLISH_AUSTRALIAN:
+ case TWLG.ENGLISH_CANADIAN:
+ case TWLG.ENGLISH_IRELAND:
+ case TWLG.ENGLISH_NEWZEALAND:
+ case TWLG.ENGLISH_SOUTHAFRICA:
+ case TWLG.ENGLISH_UK:
+ case TWLG.USA:
+ case TWLG.FAEROESE:
+ case TWLG.FIN: // FINNISH
+ case TWLG.FRN: // FRENCH
+ case TWLG.FRENCH_BELGIAN:
+ case TWLG.FCF: // FRENCH_CANADIAN
+ case TWLG.FRENCH_LUXEMBOURG:
+ case TWLG.FRENCH_SWISS:
+ case TWLG.GER: // GERMAN
+ case TWLG.GERMAN_AUSTRIAN:
+ case TWLG.GERMAN_LIECHTENSTEIN:
+ case TWLG.GERMAN_LUXEMBOURG:
+ case TWLG.GERMAN_SWISS:
+ case TWLG.ICE: // ICELANDIC
+ case TWLG.INDONESIAN:
+ case TWLG.ITN: // ITALIAN
+ case TWLG.ITALIAN_SWISS:
+ case TWLG.NOR: // NORWEGIAN
+ case TWLG.NORWEGIAN_BOKMAL:
+ case TWLG.NORWEGIAN_NYNORSK:
+ case TWLG.POR: // PORTUGUESE
+ case TWLG.PORTUGUESE_BRAZIL:
+ case TWLG.SPA: // SPANISH
+ case TWLG.SPANISH_MEXICAN:
+ case TWLG.SPANISH_MODERN:
+ case TWLG.SWE: // SWEDISH
+ case TWLG.SWEDISH_FINLAND:
+ m_encoding = Encoding.GetEncoding(1252);
+ break;
+
+ case TWLG.GREEK:
+ m_encoding = Encoding.GetEncoding(1253);
+ break;
+
+ case TWLG.TURKISH:
+ m_encoding = Encoding.GetEncoding(1254);
+ break;
+
+ case TWLG.HEBREW:
+ m_encoding = Encoding.GetEncoding(1255);
+ break;
+
+ case TWLG.ARABIC:
+ case TWLG.ARABIC_ALGERIA:
+ case TWLG.ARABIC_BAHRAIN:
+ case TWLG.ARABIC_EGYPT:
+ case TWLG.ARABIC_IRAQ:
+ case TWLG.ARABIC_JORDAN:
+ case TWLG.ARABIC_KUWAIT:
+ case TWLG.ARABIC_LEBANON:
+ case TWLG.ARABIC_LIBYA:
+ case TWLG.ARABIC_MOROCCO:
+ case TWLG.ARABIC_OMAN:
+ case TWLG.ARABIC_QATAR:
+ case TWLG.ARABIC_SAUDIARABIA:
+ case TWLG.ARABIC_SYRIA:
+ case TWLG.ARABIC_TUNISIA:
+ case TWLG.ARABIC_UAE:
+ case TWLG.ARABIC_YEMEN:
+ case TWLG.FARSI:
+ case TWLG.URDU:
+ m_encoding = Encoding.GetEncoding(1256);
+ break;
+
+ case TWLG.ESTONIAN:
+ case TWLG.LATVIAN:
+ case TWLG.LITHUANIAN:
+ m_encoding = Encoding.GetEncoding(1257);
+ break;
+
+ case TWLG.VIETNAMESE:
+ m_encoding = Encoding.GetEncoding(1258);
+ break;
+
+ case TWLG.ASSAMESE:
+ case TWLG.BENGALI:
+ case TWLG.BIHARI:
+ case TWLG.BODO:
+ case TWLG.DOGRI:
+ case TWLG.GUJARATI:
+ case TWLG.HARYANVI:
+ case TWLG.HINDI:
+ case TWLG.KANNADA:
+ case TWLG.KASHMIRI:
+ case TWLG.MALAYALAM:
+ case TWLG.MARATHI:
+ case TWLG.MARWARI:
+ case TWLG.MEGHALAYAN:
+ case TWLG.MIZO:
+ case TWLG.NAGA:
+ case TWLG.ORISSI:
+ case TWLG.PUNJABI:
+ case TWLG.PUSHTU:
+ case TWLG.SIKKIMI:
+ case TWLG.TAMIL:
+ case TWLG.TELUGU:
+ case TWLG.TRIPURI:
+ // NOTE: there are no known code pages for these, so we will use English
+ m_encoding = Encoding.GetEncoding(1252);
+ break;
+ }
+ }
+
+ private static Encoding m_encoding = Encoding.GetEncoding(1252);
+}
+
+#endregion
diff --git a/src/NTwain/Data/TWAINH_EXTRAS.cs b/src/NTwain/Data/TWAINH_EXTRAS.cs
index f449900..982637e 100644
--- a/src/NTwain/Data/TWAINH_EXTRAS.cs
+++ b/src/NTwain/Data/TWAINH_EXTRAS.cs
@@ -1,710 +1,735 @@
using System;
-using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
-using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
-namespace NTwain.Data
+namespace NTwain.Data;
+
+// this contains my additions
+// that makes some twain types easier to work with.
+
+///
+/// Contains platform info for twain use.
+///
+public static class TWPlatform
{
- // this contains my additions
- // that makes some twain types easier to work with.
-
- ///
- /// Contains platform info for twain use.
- ///
- public static class TWPlatform
+ static TWPlatform()
{
- static TWPlatform()
- {
- Is32bit = IntPtr.Size == 4;
-
+ Is32bit = IntPtr.Size == 4;
#if NETFRAMEWORK
- if (Environment.OSVersion.Platform == PlatformID.Win32NT)
- {
- IsWindows = true;
- }
- else if (System.IO.Directory.Exists("/Library/Application Support"))
- {
- IsMacOSX = true;
- }
- else if (Environment.OSVersion.Platform == PlatformID.Unix)
- {
- IsLinux = true;
- }
+ if (Environment.OSVersion.Platform == PlatformID.Win32NT)
+ {
+ IsWindows = true;
+ }
+ else if (System.IO.Directory.Exists("/Library/Application Support"))
+ {
+ IsMacOSX = true;
+ }
+ else if (Environment.OSVersion.Platform == PlatformID.Unix)
+ {
+ IsLinux = true;
+ }
#else
- Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
- {
- IsWindows = true;
- }
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
- {
- IsMacOSX = true;
- }
- else
- {
- IsLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
- }
+ if (OperatingSystem.IsWindows())
+ {
+ IsWindows = true;
+ }
+ else if (OperatingSystem.IsMacCatalyst() || OperatingSystem.IsMacOS())
+ {
+ IsMacOSX = true;
+ }
+ else
+ {
+ IsLinux = OperatingSystem.IsLinux();
+ }
+#endif
+#if !NETFRAMEWORK
+ Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
#endif
- }
-
- ///
- /// Whether the code is running under Linux.
- ///
- public static bool IsLinux { get; }
-
- ///
- /// Whether the code is running under MacOSX.
- ///
- public static bool IsMacOSX { get; }
-
- ///
- /// Whether the code is running under Windows.
- ///
- public static bool IsWindows { get; }
-
- ///
- /// Whether the code is running in 64bit or 32bit.
- ///
- public static bool Is32bit { get; }
-
- ///
- /// Whether to use the older DSM lib on Windows and Mac.
- /// On Windows it only takes effect when running in 32bit.
- /// Defaults to false.
- ///
- public static bool PreferLegacyDSM { get; set; }
}
///
- /// Contains value that don't fit into enums nicely.
+ /// Whether the code is running under Linux.
///
- public static class TWConst
- {
- ///
- /// Don't care values...
- ///
- public const byte TWON_DONTCARE8 = 0xff;
- public const ushort TWON_DONTCARE16 = 0xffff;
- public const uint TWON_DONTCARE32 = 0xffffffff;
- }
+ public static bool IsLinux { get; }
///
- /// TWAIN's boolean values.
+ /// Whether the code is running under MacOSX.
///
- public enum TW_BOOL : ushort
- {
- ///
- /// The false value (0).
- ///
- False = 0,
- ///
- /// The true value (1).
- ///
- True = 1
- }
-
- /////
- ///// A more dotnet-friendly representation of .
- /////
- //public struct Metrics
- //{
- // ///
- // /// Return code of querying the metrics.
- // ///
- // public STS ReturnCode;
-
- // ///
- // /// The number of sheets of paper processed by the scanner.
- // ///
- // public int Sheets;
-
- // ///
- // /// The number of images made available for transfer by the driver. This is not
- // /// necessarily the same as the number of images actually transferred, since the
- // /// application may opt to skip transfers or to end without transferring all images.
- // ///
- // public int Images;
- //}
+ public static bool IsMacOSX { get; }
///
- /// More dotnet friendly return type for twaindirect set result.
+ /// Whether the code is running under Windows.
///
- public struct TwainDirectTaskResult
- {
- ///
- /// Return code of task.
- ///
- public TWRC ReturnCode;
-
- ///
- /// Status if code is failure.
- ///
- public TW_STATUS Status;
-
- ///
- /// The response of the task in JSON if successful.
- ///
- public string? ResponseJson;
- }
-
- public enum TWRC : ushort
- {
- // Custom base (same for TWRC and TWCC)...
- CUSTOMBASE = 0x8000,
-
- // Return codes...
- SUCCESS = 0,
- FAILURE = 1,
- CHECKSTATUS = 2,
- CANCEL = 3,
- DSEVENT = 4,
- NOTDSEVENT = 5,
- XFERDONE = 6,
- ENDOFLIST = 7,
- INFONOTSUPPORTED = 8,
- DATANOTAVAILABLE = 9,
- BUSY = 10,
- SCANNERLOCKED = 11,
- }
- public enum TWCC : ushort
- {
- // Condition codes (always associated with TWRC_FAILURE)...
- CUSTOMBASE = 0x8000,
- None = 0,
- BUMMER = 1,
- LOWMEMORY = 2,
- NODS = 3,
- MAXCONNECTIONS = 4,
- OPERATIONERROR = 5,
- BADCAP = 6,
- BADPROTOCOL = 9,
- BADVALUE = 10,
- SEQERROR = 11,
- BADDEST = 12,
- CAPUNSUPPORTED = 13,
- CAPBADOPERATION = 14,
- CAPSEQERROR = 15,
- DENIED = 16,
- FILEEXISTS = 17,
- FILENOTFOUND = 18,
- NOTEMPTY = 19,
- PAPERJAM = 20,
- PAPERDOUBLEFEED = 21,
- FILEWRITEERROR = 22,
- CHECKDEVICEONLINE = 23,
- INTERLOCK = 24,
- DAMAGEDCORNER = 25,
- FOCUSERROR = 26,
- DOCTOOLIGHT = 27,
- DOCTOODARK = 28,
- NOMEDIA = 29
- }
-
- //[StructLayout(LayoutKind.Sequential, Pack = 2)]
+ public static bool IsWindows { get; }
///
- /// Extended return type with original return code and additional
- /// status if RC is .
+ /// Whether the code is running in 64bit or 32bit.
///
- public struct STS
- {
- ///
- /// The original return code.
- ///
- public TWRC RC;
-
- ///
- /// Additional status if RC is .
- ///
- public TW_STATUS STATUS;
-
- /////
- ///// For easy conversion from DSM calls to the one we want
- /////
- /////
- //public static implicit operator STS(TWRC rc)
- //{
- // return new STS { RC = rc };
- //}
-
- ///
- /// Quick check if the RC is success.
- ///
- public bool IsSuccess => RC == TWRC.SUCCESS;
-
- ///
- /// Quick access to condition code.
- ///
- public TWCC ConditionCode => STATUS.ConditionCode;
-
- public override string ToString()
- {
- return $"{RC} - {STATUS.ConditionCode}";
- }
- }
-
- partial struct TW_STATUS
- {
- public override string ToString()
- {
- return ConditionCode.ToString();
- }
- }
+ public static bool Is32bit { get; }
///
- /// A more dotnet-friendly representation of .
+ /// Whether to use the older DSM lib on Windows and Mac.
+ /// On Windows it only takes effect when running in 32bit.
+ /// Defaults to false.
///
- ///
- public record Enumeration
- {
- public int CurrentIndex { get; set; }
+ public static bool PreferLegacyDSM { get; set; }
+}
- public int DefaultIndex { get; set; }
+///
+/// Contains value that don't fit into enums nicely.
+///
+public static class TWConst
+{
+ ///
+ /// Don't care values...
+ ///
+ public const byte TWON_DONTCARE8 = 0xff;
+ public const ushort TWON_DONTCARE16 = 0xffff;
+ public const uint TWON_DONTCARE32 = 0xffffffff;
+}
- public TValue[] Items { get; set; } = [];
- }
+///
+/// TWAIN's boolean values.
+///
+public enum TW_BOOL : ushort
+{
+ ///
+ /// The false value (0).
+ ///
+ False = 0,
+ ///
+ /// The true value (1).
+ ///
+ True = 1
+}
+
+/////
+///// A more dotnet-friendly representation of .
+/////
+//public struct Metrics
+//{
+// ///
+// /// Return code of querying the metrics.
+// ///
+// public STS ReturnCode;
+
+// ///
+// /// The number of sheets of paper processed by the scanner.
+// ///
+// public int Sheets;
+
+// ///
+// /// The number of images made available for transfer by the driver. This is not
+// /// necessarily the same as the number of images actually transferred, since the
+// /// application may opt to skip transfers or to end without transferring all images.
+// ///
+// public int Images;
+//}
+
+///
+/// More dotnet friendly return type for twaindirect set result.
+///
+public struct TwainDirectTaskResult
+{
+ ///
+ /// Return code of task.
+ ///
+ public TWRC ReturnCode;
///
- /// A more dotnet-friendly representation of .
+ /// Status if code is failure.
///
- ///
- public partial record Range
- {
- public required TValue MinValue { get; set; }
- public required TValue MaxValue { get; set; }
- public required TValue StepSize { get; set; }
- public required TValue DefaultValue { get; set; }
- public required TValue CurrentValue { get; set; }
-
- ///
- /// Tries to enumerate the range values.
- /// This could be expensive depending on the range size.
- ///
- ///
- public IEnumerable Enumerate()
- {
- if (MinValue is not IConvertible)
- throw new NotSupportedException($"The value type {typeof(TValue).Name} is not supported for range enumeration.");
-
- var dynamicType = typeof(DynamicEnumerator<>);
- var genericType = dynamicType.MakeGenericType(typeof(TValue));
-
- var de = (IEnumerator)Activator.CreateInstance(genericType, MinValue, MaxValue, StepSize)!;
- while (de.MoveNext())
- {
- yield return de.Current;
- }
- }
- }
+ public TW_STATUS Status;
///
- /// A more dotnet-friendly container of CAP value.
+ /// The response of the task in JSON if successful.
///
- ///
- public record ValueContainer
+ public string? ResponseJson;
+}
+
+public enum TWRC : ushort
+{
+ // Custom base (same for TWRC and TWCC)...
+ CUSTOMBASE = 0x8000,
+
+ // Return codes...
+ SUCCESS = 0,
+ FAILURE = 1,
+ CHECKSTATUS = 2,
+ CANCEL = 3,
+ DSEVENT = 4,
+ NOTDSEVENT = 5,
+ XFERDONE = 6,
+ ENDOFLIST = 7,
+ INFONOTSUPPORTED = 8,
+ DATANOTAVAILABLE = 9,
+ BUSY = 10,
+ SCANNERLOCKED = 11,
+}
+public enum TWCC : ushort
+{
+ // Condition codes (always associated with TWRC_FAILURE)...
+ CUSTOMBASE = 0x8000,
+ None = 0,
+ BUMMER = 1,
+ LOWMEMORY = 2,
+ NODS = 3,
+ MAXCONNECTIONS = 4,
+ OPERATIONERROR = 5,
+ BADCAP = 6,
+ BADPROTOCOL = 9,
+ BADVALUE = 10,
+ SEQERROR = 11,
+ BADDEST = 12,
+ CAPUNSUPPORTED = 13,
+ CAPBADOPERATION = 14,
+ CAPSEQERROR = 15,
+ DENIED = 16,
+ FILEEXISTS = 17,
+ FILENOTFOUND = 18,
+ NOTEMPTY = 19,
+ PAPERJAM = 20,
+ PAPERDOUBLEFEED = 21,
+ FILEWRITEERROR = 22,
+ CHECKDEVICEONLINE = 23,
+ INTERLOCK = 24,
+ DAMAGEDCORNER = 25,
+ FOCUSERROR = 26,
+ DOCTOOLIGHT = 27,
+ DOCTOODARK = 28,
+ NOMEDIA = 29
+}
+
+//[StructLayout(LayoutKind.Sequential, Pack = 2)]
+
+///
+/// Extended return type with original return code and additional
+/// status if RC is .
+///
+public struct STS
+{
+ ///
+ /// Returns a failure with sequence error condition.
+ ///
+ ///
+ public static STS SequenceError()
{
- public TWON ContainerType { get; set; }
-
- public TValue? OneValue { get; set; }
-
- public IList? ArrayValue { get; set; }
-
- public Enumeration? EnumValue { get; set; }
-
- public Range? RangeValue { get; set; }
-
- public IEnumerable GetValues()
+ return new STS
{
- return ContainerType switch
+ RC = TWRC.FAILURE,
+ STATUS = new TW_STATUS
{
- TWON.ONEVALUE => ToEnumerable(OneValue),
- TWON.ARRAY => ArrayValue ?? [],
- TWON.ENUMERATION => EnumValue?.Items ?? [],
- TWON.RANGE => RangeValue != null ? RangeValue.Enumerate() : [],
- _ => [],
- };
- }
-
- private IEnumerable ToEnumerable(TValue? value)
- {
- if (value == null) yield break;
- yield return value;
- }
- }
-
- partial struct TW_FIX32 : IEquatable, IConvertible
- {
- // this conversion logic is found in the twain spec.
-
- float ToFloat()
- {
- return Whole + Frac / 65536f;
- }
- double ToDouble()
- {
- return Whole + Frac / 65536.0;
- }
- public TW_FIX32(double value) : this((float)value) { }
- public TW_FIX32(float value)
- {
- //int temp = (int)(value * 65536.0 + 0.5);
- //Whole = (short)(temp >> 16);
- //Fraction = (ushort)(temp & 0x0000ffff);
-
- // different version from twain faq
- bool sign = value < 0;
- int temp = (int)(value * 65536.0 + (sign ? (-0.5) : 0.5));
- Whole = (short)(temp >> 16);
- Frac = (ushort)(temp & 0x0000ffff);
- }
-
- public override string ToString()
- {
- return ToFloat().ToString();
- }
-
- public bool Equals(TW_FIX32 other)
- {
- return Whole == other.Whole && Frac == other.Frac;
- }
- public override bool Equals(object? obj)
- {
- if (obj is TW_FIX32 other)
- {
- return Equals(other);
- }
- return false;
- }
- public override int GetHashCode()
- {
- return Whole ^ Frac;
- }
-
-
- #region IConvertable
-
- TypeCode IConvertible.GetTypeCode()
- {
- return TypeCode.Single;
- }
-
- bool IConvertible.ToBoolean(IFormatProvider? provider)
- {
- return this != 0;
- }
-
- byte IConvertible.ToByte(IFormatProvider? provider)
- {
- return Convert.ToByte((float)this);
- }
-
- char IConvertible.ToChar(IFormatProvider? provider)
- {
- return Convert.ToChar((float)this);
- }
-
- DateTime IConvertible.ToDateTime(IFormatProvider? provider)
- {
- return Convert.ToDateTime((float)this);
- }
-
- decimal IConvertible.ToDecimal(IFormatProvider? provider)
- {
- return Convert.ToDecimal((float)this);
- }
-
- double IConvertible.ToDouble(IFormatProvider? provider)
- {
- return Convert.ToDouble((float)this);
- }
-
- short IConvertible.ToInt16(IFormatProvider? provider)
- {
- return Convert.ToInt16((float)this);
- }
-
- int IConvertible.ToInt32(IFormatProvider? provider)
- {
- return Convert.ToInt32((float)this);
- }
-
- long IConvertible.ToInt64(IFormatProvider? provider)
- {
- return Convert.ToInt64((float)this);
- }
-
- sbyte IConvertible.ToSByte(IFormatProvider? provider)
- {
- return Convert.ToSByte((float)this);
- }
-
- float IConvertible.ToSingle(IFormatProvider? provider)
- {
- return Convert.ToSingle((float)this);
- }
-
- string IConvertible.ToString(IFormatProvider? provider)
- {
- return this.ToString();
- }
-
- object IConvertible.ToType(Type conversionType, IFormatProvider? provider)
- {
- return Convert.ChangeType((float)this, conversionType, CultureInfo.InvariantCulture);
- }
-
- ushort IConvertible.ToUInt16(IFormatProvider? provider)
- {
- return Convert.ToUInt16((float)this);
- }
-
- uint IConvertible.ToUInt32(IFormatProvider? provider)
- {
- return Convert.ToUInt32((float)this);
- }
-
- ulong IConvertible.ToUInt64(IFormatProvider? provider)
- {
- return Convert.ToUInt64((float)this);
- }
-
- #endregion
-
- public static implicit operator float(TW_FIX32 value) => value.ToFloat();
- public static implicit operator TW_FIX32(float value) => new(value);
-
- public static implicit operator double(TW_FIX32 value) => value.ToDouble();
- public static implicit operator TW_FIX32(double value) => new(value);
-
- public static bool operator ==(TW_FIX32 value1, TW_FIX32 value2) => value1.Equals(value2);
- public static bool operator !=(TW_FIX32 value1, TW_FIX32 value2) => !value1.Equals(value2);
- }
-
- partial struct TW_FRAME : IEquatable
- {
- ///
- /// Creates from a string representation of it.
- ///
- ///
- public TW_FRAME(string value) : this()
- {
- var parts = value.Split(',');
- if (parts.Length == 4)
- {
- Left = float.Parse(parts[0]);
- Top = float.Parse(parts[1]);
- Right = float.Parse(parts[2]);
- Bottom = float.Parse(parts[3]);
- }
- else
- {
- throw new ArgumentException($"Cannot create frame from \"{value}\".");
- }
- }
-
- ///
- /// String representation of Left,Top,Right,Bottom.
- ///
- ///
- public override string ToString()
- {
- return $"({Left},{Top}) ({Right},{Bottom})";
- }
-
- public bool Equals(TW_FRAME other)
- {
- return Left == other.Left && Top == other.Top &&
- Right == other.Right && Bottom == other.Bottom;
- }
-
- public override bool Equals(object? obj)
- {
- if (obj is TW_FRAME other)
- {
- return Equals(other);
- }
- return false;
- }
-
- public override int GetHashCode()
- {
- return Left.GetHashCode() ^ Top.GetHashCode() ^
- Right.GetHashCode() ^ Bottom.GetHashCode();
- }
-
-
- public static bool operator ==(TW_FRAME value1, TW_FRAME value2)
- {
- return value1.Equals(value2);
- }
- public static bool operator !=(TW_FRAME value1, TW_FRAME value2)
- {
- return !value1.Equals(value2);
- }
- }
-
- partial struct TW_STR32
- {
- public const int Size = 34;
-
- public TW_STR32(string value) : this()
- {
- Set(value);
- }
-
- public override string ToString()
- {
- return Get();
- }
-
- public static implicit operator string(TW_STR32 value) => value.ToString();
- public static implicit operator TW_STR32(string value) => new(value);
-
- }
-
- partial struct TW_STR64
- {
- public const int Size = 66;
-
- public TW_STR64(string value) : this()
- {
- Set(value);
- }
-
- public override string ToString()
- {
- return Get();
- }
-
- public static implicit operator string(TW_STR64 value) => value.ToString();
- public static implicit operator TW_STR64(string value) => new(value);
- }
-
- partial struct TW_STR128
- {
- public const int Size = 130;
-
- public TW_STR128(string value) : this()
- {
- Set(value);
- }
-
- public override string ToString()
- {
- return Get();
- }
-
- public static implicit operator string(TW_STR128 value) => value.ToString();
- public static implicit operator TW_STR128(string value) => new(value);
- }
-
- partial struct TW_STR255
- {
- public const int Size = 256;
-
- public TW_STR255(string value) : this()
- {
- Set(value);
- }
-
- public override string ToString()
- {
- return Get();
- }
-
- public static implicit operator string(TW_STR255 value) => value.ToString();
- public static implicit operator TW_STR255(string value) => new(value);
- }
-
- partial struct TW_IDENTITY
- {
- public override string ToString()
- {
- return $"{Manufacturer} - {ProductFamily} - {ProductName} {Version} (TWAIN {ProtocolMajor}.{ProtocolMinor})";
- }
- }
- partial struct TW_IDENTITY_MACOSX
- {
- public override string ToString()
- {
- return $"{Manufacturer} - {ProductName} v{Version.MajorNum}.{Version.MinorNum} (TWAIN {ProtocolMajor}.{ProtocolMinor})";
- }
- public static implicit operator TW_IDENTITY_LEGACY(TW_IDENTITY_MACOSX value) => new()
- {
- Id = value.Id,
- Manufacturer = value.Manufacturer,
- ProductFamily = value.ProductFamily,
- ProductName = value.ProductName,
- ProtocolMajor = value.ProtocolMajor,
- ProtocolMinor = value.ProtocolMinor,
- SupportedGroups = value.SupportedGroups,
- Version = new()
- {
- Country = value.Version.Country,
- Info = value.Version.Info,
- Language = value.Version.Language,
- MajorNum = value.Version.MajorNum,
- MinorNum = value.Version.MinorNum,
+ ConditionCode = TWCC.SEQERROR
}
};
}
- partial struct TW_IDENTITY_LEGACY
+
+ ///
+ /// The original return code.
+ ///
+ public TWRC RC;
+
+ ///
+ /// Additional status if RC is .
+ ///
+ public TW_STATUS STATUS;
+
+ /////
+ ///// For easy conversion from DSM calls to the one we want
+ /////
+ /////
+ //public static implicit operator STS(TWRC rc)
+ //{
+ // return new STS { RC = rc };
+ //}
+
+ ///
+ /// Quick check if the RC is success.
+ ///
+ public bool IsSuccess => RC == TWRC.SUCCESS;
+
+ ///
+ /// Quick access to condition code.
+ ///
+ public TWCC ConditionCode => STATUS.ConditionCode;
+
+ public override string ToString()
{
- ///
- /// Creates app info derived an executable file.
- ///
- ///
- ///
- ///
- public TW_IDENTITY_LEGACY(
- string exeFilePath,
- TWLG appLanguage = TWLG.ENGLISH_USA, TWCY appCountry = TWCY.USA) :
- this(FileVersionInfo.GetVersionInfo(exeFilePath), appLanguage, appCountry)
- { }
- ///
- /// Creates app info derived from a object.
- ///
- ///
- ///
- ///
- public TW_IDENTITY_LEGACY(
- FileVersionInfo appInfo,
- TWLG appLanguage = TWLG.ENGLISH_USA, TWCY appCountry = TWCY.USA) :
- this(
- appInfo.CompanyName ?? "",
- appInfo.ProductName ?? "",
- appInfo.ProductName ?? "",
- new Version(appInfo.FileVersion ?? "1.0"),
- appInfo.FileDescription ?? "", appLanguage, appCountry)
- { }
- ///
- /// Creates id with explicit app info.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public TW_IDENTITY_LEGACY(
- string companyName, string productFamily, string productName,
- Version productVersion, string productDescription = "",
- TWLG appLanguage = TWLG.ENGLISH_USA, TWCY appCountry = TWCY.USA,
- DG supportedTypes = DG.IMAGE)
+ return $"{RC} - {STATUS.ConditionCode}";
+ }
+}
+
+partial struct TW_STATUS
+{
+ public override string ToString()
+ {
+ return ConditionCode.ToString();
+ }
+}
+
+///
+/// A more dotnet-friendly representation of .
+///
+///
+public record Enumeration
+{
+ public int CurrentIndex { get; set; }
+
+ public int DefaultIndex { get; set; }
+
+ public TValue[] Items { get; set; } = [];
+}
+
+///
+/// A more dotnet-friendly representation of .
+///
+///
+public partial record Range
+{
+ public required TValue MinValue { get; set; }
+ public required TValue MaxValue { get; set; }
+ public required TValue StepSize { get; set; }
+ public required TValue DefaultValue { get; set; }
+ public required TValue CurrentValue { get; set; }
+
+ ///
+ /// Tries to enumerate the range values.
+ /// This could be expensive depending on the range size.
+ ///
+ ///
+ public IEnumerable Enumerate()
+ {
+ if (MinValue is not IConvertible)
+ throw new NotSupportedException($"The value type {typeof(TValue).Name} is not supported for range enumeration.");
+
+ var dynamicType = typeof(DynamicEnumerator<>);
+ var genericType = dynamicType.MakeGenericType(typeof(TValue));
+
+ var de = (IEnumerator)Activator.CreateInstance(genericType, MinValue, MaxValue, StepSize)!;
+ while (de.MoveNext())
{
- Manufacturer = companyName;
- ProductFamily = productFamily;
- ProductName = productName;
- ProtocolMajor = (ushort)TWON_PROTOCOL.MAJOR;
- ProtocolMinor = (ushort)TWON_PROTOCOL.MINOR;
- SupportedGroups = (uint)(supportedTypes | DG.CONTROL | DG.APP2);
+ yield return de.Current;
+ }
+ }
+}
+
+///
+/// A more dotnet-friendly container of CAP value.
+///
+///
+public record ValueContainer
+{
+ public TWON ContainerType { get; set; }
+
+ public TValue? OneValue { get; set; }
+
+ public IList? ArrayValue { get; set; }
+
+ public Enumeration? EnumValue { get; set; }
+
+ public Range? RangeValue { get; set; }
+
+ public IEnumerable GetValues()
+ {
+ return ContainerType switch
+ {
+ TWON.ONEVALUE => ToEnumerable(OneValue),
+ TWON.ARRAY => ArrayValue ?? [],
+ TWON.ENUMERATION => EnumValue?.Items ?? [],
+ TWON.RANGE => RangeValue != null ? RangeValue.Enumerate() : [],
+ _ => [],
+ };
+ }
+
+ private IEnumerable ToEnumerable(TValue? value)
+ {
+ if (value == null) yield break;
+ yield return value;
+ }
+}
+
+
+partial struct TW_ENTRYPOINT_DELEGATES
+{
+ public bool HasDelegates()
+ {
+ return DSM_MemAllocate != null &&
+ DSM_MemFree != null &&
+ DSM_MemLock != null &&
+ DSM_MemUnlock != null;
+ }
+}
+
+partial struct TW_FIX32 : IEquatable, IConvertible
+{
+ // this conversion logic is found in the twain spec.
+
+ float ToFloat()
+ {
+ return Whole + Frac / 65536f;
+ }
+ double ToDouble()
+ {
+ return Whole + Frac / 65536.0;
+ }
+ public TW_FIX32(double value) : this((float)value) { }
+ public TW_FIX32(float value)
+ {
+ //int temp = (int)(value * 65536.0 + 0.5);
+ //Whole = (short)(temp >> 16);
+ //Fraction = (ushort)(temp & 0x0000ffff);
+
+ // different version from twain faq
+ bool sign = value < 0;
+ int temp = (int)(value * 65536.0 + (sign ? (-0.5) : 0.5));
+ Whole = (short)(temp >> 16);
+ Frac = (ushort)(temp & 0x0000ffff);
+ }
+
+ public override string ToString()
+ {
+ return ToFloat().ToString();
+ }
+
+ public bool Equals(TW_FIX32 other)
+ {
+ return Whole == other.Whole && Frac == other.Frac;
+ }
+ public override bool Equals(object? obj)
+ {
+ if (obj is TW_FIX32 other)
+ {
+ return Equals(other);
+ }
+ return false;
+ }
+ public override int GetHashCode()
+ {
+ return Whole ^ Frac;
+ }
+
+
+ #region IConvertable
+
+ TypeCode IConvertible.GetTypeCode()
+ {
+ return TypeCode.Single;
+ }
+
+ bool IConvertible.ToBoolean(IFormatProvider? provider)
+ {
+ return this != 0;
+ }
+
+ byte IConvertible.ToByte(IFormatProvider? provider)
+ {
+ return Convert.ToByte((float)this);
+ }
+
+ char IConvertible.ToChar(IFormatProvider? provider)
+ {
+ return Convert.ToChar((float)this);
+ }
+
+ DateTime IConvertible.ToDateTime(IFormatProvider? provider)
+ {
+ return Convert.ToDateTime((float)this);
+ }
+
+ decimal IConvertible.ToDecimal(IFormatProvider? provider)
+ {
+ return Convert.ToDecimal((float)this);
+ }
+
+ double IConvertible.ToDouble(IFormatProvider? provider)
+ {
+ return Convert.ToDouble((float)this);
+ }
+
+ short IConvertible.ToInt16(IFormatProvider? provider)
+ {
+ return Convert.ToInt16((float)this);
+ }
+
+ int IConvertible.ToInt32(IFormatProvider? provider)
+ {
+ return Convert.ToInt32((float)this);
+ }
+
+ long IConvertible.ToInt64(IFormatProvider? provider)
+ {
+ return Convert.ToInt64((float)this);
+ }
+
+ sbyte IConvertible.ToSByte(IFormatProvider? provider)
+ {
+ return Convert.ToSByte((float)this);
+ }
+
+ float IConvertible.ToSingle(IFormatProvider? provider)
+ {
+ return Convert.ToSingle((float)this);
+ }
+
+ string IConvertible.ToString(IFormatProvider? provider)
+ {
+ return this.ToString();
+ }
+
+ object IConvertible.ToType(Type conversionType, IFormatProvider? provider)
+ {
+ return Convert.ChangeType((float)this, conversionType, CultureInfo.InvariantCulture);
+ }
+
+ ushort IConvertible.ToUInt16(IFormatProvider? provider)
+ {
+ return Convert.ToUInt16((float)this);
+ }
+
+ uint IConvertible.ToUInt32(IFormatProvider? provider)
+ {
+ return Convert.ToUInt32((float)this);
+ }
+
+ ulong IConvertible.ToUInt64(IFormatProvider? provider)
+ {
+ return Convert.ToUInt64((float)this);
+ }
+
+ #endregion
+
+ public static implicit operator float(TW_FIX32 value) => value.ToFloat();
+ public static implicit operator TW_FIX32(float value) => new(value);
+
+ public static implicit operator double(TW_FIX32 value) => value.ToDouble();
+ public static implicit operator TW_FIX32(double value) => new(value);
+
+ public static bool operator ==(TW_FIX32 value1, TW_FIX32 value2) => value1.Equals(value2);
+ public static bool operator !=(TW_FIX32 value1, TW_FIX32 value2) => !value1.Equals(value2);
+}
+
+partial struct TW_FRAME : IEquatable
+{
+ ///
+ /// Creates from a string representation of it.
+ ///
+ ///
+ public TW_FRAME(string value) : this()
+ {
+ var parts = value.Split(',');
+ if (parts.Length == 4)
+ {
+ Left = float.Parse(parts[0]);
+ Top = float.Parse(parts[1]);
+ Right = float.Parse(parts[2]);
+ Bottom = float.Parse(parts[3]);
+ }
+ else
+ {
+ throw new ArgumentException($"Cannot create frame from \"{value}\".");
+ }
+ }
+
+ ///
+ /// String representation of Left,Top,Right,Bottom.
+ ///
+ ///
+ public override string ToString()
+ {
+ return $"({Left},{Top}) ({Right},{Bottom})";
+ }
+
+ public bool Equals(TW_FRAME other)
+ {
+ return Left == other.Left && Top == other.Top &&
+ Right == other.Right && Bottom == other.Bottom;
+ }
+
+ public override bool Equals(object? obj)
+ {
+ if (obj is TW_FRAME other)
+ {
+ return Equals(other);
+ }
+ return false;
+ }
+
+ public override int GetHashCode()
+ {
+ return Left.GetHashCode() ^ Top.GetHashCode() ^
+ Right.GetHashCode() ^ Bottom.GetHashCode();
+ }
+
+
+ public static bool operator ==(TW_FRAME value1, TW_FRAME value2)
+ {
+ return value1.Equals(value2);
+ }
+ public static bool operator !=(TW_FRAME value1, TW_FRAME value2)
+ {
+ return !value1.Equals(value2);
+ }
+}
+
+partial struct TW_STR32
+{
+ public const int Size = 34;
+
+ public TW_STR32(string value) : this()
+ {
+ Set(value);
+ }
+
+ public override string ToString()
+ {
+ return Get();
+ }
+
+ public static implicit operator string(TW_STR32 value) => value.ToString();
+ public static implicit operator TW_STR32(string value) => new(value);
+
+}
+
+partial struct TW_STR64
+{
+ public const int Size = 66;
+
+ public TW_STR64(string value) : this()
+ {
+ Set(value);
+ }
+
+ public override string ToString()
+ {
+ return Get();
+ }
+
+ public static implicit operator string(TW_STR64 value) => value.ToString();
+ public static implicit operator TW_STR64(string value) => new(value);
+}
+
+partial struct TW_STR128
+{
+ public const int Size = 130;
+
+ public TW_STR128(string value) : this()
+ {
+ Set(value);
+ }
+
+ public override string ToString()
+ {
+ return Get();
+ }
+
+ public static implicit operator string(TW_STR128 value) => value.ToString();
+ public static implicit operator TW_STR128(string value) => new(value);
+}
+
+partial struct TW_STR255
+{
+ public const int Size = 256;
+
+ public TW_STR255(string value) : this()
+ {
+ Set(value);
+ }
+
+ public override string ToString()
+ {
+ return Get();
+ }
+
+ public static implicit operator string(TW_STR255 value) => value.ToString();
+ public static implicit operator TW_STR255(string value) => new(value);
+}
+
+///
+/// A single wrapper type for various TW_IDENTITY types
+/// to help pass it around.
+///
+public record TWIdentityWrapper
+{
+ internal TW_IDENTITY TW_IDENTITY;
+ internal TW_IDENTITY_LEGACY TW_IDENTITY_LEGACY;
+ internal TW_IDENTITY_MACOSX TW_IDENTITY_MACOSX;
+
+ public TWIdentityWrapper()
+ {
+
+ }
+
+ internal void SetIdentity(TW_IDENTITY_LEGACY identity)
+ {
+ TW_IDENTITY_LEGACY = identity;
+ TW_IDENTITY = identity;
+ TW_IDENTITY_MACOSX = identity;
+ }
+ internal void SetIdentity(TW_IDENTITY_MACOSX identity)
+ {
+ TW_IDENTITY_LEGACY = identity;
+ TW_IDENTITY = identity;
+ TW_IDENTITY_MACOSX = identity;
+ }
+
+ ///
+ /// Creates app info derived an executable file.
+ ///
+ ///
+ ///
+ ///
+ public TWIdentityWrapper(
+ string exeFilePath,
+ TWLG appLanguage = TWLG.ENGLISH_USA, TWCY appCountry = TWCY.USA) :
+ this(FileVersionInfo.GetVersionInfo(exeFilePath), appLanguage, appCountry)
+ { }
+
+ ///
+ /// Creates app info derived from a object.
+ ///
+ ///
+ ///
+ ///
+ public TWIdentityWrapper(
+ FileVersionInfo appInfo,
+ TWLG appLanguage = TWLG.ENGLISH_USA, TWCY appCountry = TWCY.USA) :
+ this(
+ appInfo.CompanyName ?? "",
+ appInfo.ProductName ?? "",
+ appInfo.ProductName ?? "",
+ new Version(appInfo.FileVersion ?? "1.0"),
+ appInfo.FileDescription ?? "", appLanguage, appCountry)
+ { }
+
+ ///
+ /// Creates id with explicit app info.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public TWIdentityWrapper(
+ string companyName, string productFamily, string productName,
+ Version productVersion, string productDescription = "",
+ TWLG appLanguage = TWLG.ENGLISH_USA, TWCY appCountry = TWCY.USA,
+ DG supportedTypes = DG.IMAGE)
+ {
+ SetIdentity(new TW_IDENTITY_LEGACY
+ {
+ Manufacturer = companyName,
+ ProductFamily = productFamily,
+ ProductName = productName,
+ ProtocolMajor = (ushort)TWON_PROTOCOL.MAJOR,
+ ProtocolMinor = (ushort)TWON_PROTOCOL.MINOR,
+ SupportedGroups = (uint)(supportedTypes | DG.CONTROL | DG.APP2),
Version = new TW_VERSION
{
Country = appCountry,
@@ -712,455 +737,561 @@ namespace NTwain.Data
Language = appLanguage,
MajorNum = (ushort)productVersion.Major,
MinorNum = (ushort)productVersion.Minor,
- };
- }
-
-
-
- ///
- /// A simplified check on whether this has valid data from DSM.
- ///
- public bool HasValue => Id != 0 && ProtocolMajor != 0 && ProtocolMinor != 0;
-
- public override string ToString()
- {
- return $"{Manufacturer} - {ProductName} v{Version.MajorNum}.{Version.MinorNum} (TWAIN {ProtocolMajor}.{ProtocolMinor})";
- }
-
- public static implicit operator TW_IDENTITY(TW_IDENTITY_LEGACY value) => new()
- {
- Id = value.Id,
- Manufacturer = value.Manufacturer,
- ProductFamily = value.ProductFamily,
- ProductName = value.ProductName,
- ProtocolMajor = value.ProtocolMajor,
- ProtocolMinor = value.ProtocolMinor,
- SupportedGroups = value.SupportedGroups,
- Version = new()
- {
- Country = value.Version.Country,
- Info = value.Version.Info,
- Language = value.Version.Language,
- MajorNum = value.Version.MajorNum,
- MinorNum = value.Version.MinorNum,
}
- };
- public static implicit operator TW_IDENTITY_MACOSX(TW_IDENTITY_LEGACY value) => new()
- {
- Id = value.Id,
- Manufacturer = value.Manufacturer,
- ProductFamily = value.ProductFamily,
- ProductName = value.ProductName,
- ProtocolMajor = value.ProtocolMajor,
- ProtocolMinor = value.ProtocolMinor,
- SupportedGroups = value.SupportedGroups,
- Version = new()
- {
- Country = value.Version.Country,
- Info = value.Version.Info,
- Language = value.Version.Language,
- MajorNum = value.Version.MajorNum,
- MinorNum = value.Version.MinorNum,
- }
- };
+ });
}
- partial struct TW_VERSION
+ public uint Id => TW_IDENTITY_LEGACY.Id;
+ public TW_VERSION Version => TW_IDENTITY_LEGACY.Version;
+ public ushort ProtocolMajor => TW_IDENTITY_LEGACY.ProtocolMajor;
+ public ushort ProtocolMinor => TW_IDENTITY_LEGACY.ProtocolMinor;
+ public uint SupportedGroups => TW_IDENTITY_LEGACY.SupportedGroups;
+ public TW_STR32 Manufacturer => TW_IDENTITY_LEGACY.Manufacturer;
+ public TW_STR32 ProductFamily => TW_IDENTITY_LEGACY.ProductFamily;
+ public TW_STR32 ProductName => TW_IDENTITY_LEGACY.ProductName;
+
+ public override string ToString()
{
- public override string ToString()
- {
- return $"{MajorNum}.{MinorNum}";
- }
+ return $"{Manufacturer} - {ProductFamily} - {ProductName} {Version} (TWAIN {ProtocolMajor}.{ProtocolMinor})";
+ }
+ public static implicit operator TW_IDENTITY_LEGACY(TWIdentityWrapper wrapper) => wrapper.TW_IDENTITY_LEGACY;
+ public static implicit operator TW_IDENTITY_MACOSX(TWIdentityWrapper wrapper) => wrapper.TW_IDENTITY_MACOSX;
+ public static implicit operator TW_IDENTITY(TWIdentityWrapper wrapper) => wrapper.TW_IDENTITY;
+}
+
+partial struct TW_IDENTITY
+{
+ public override string ToString()
+ {
+ return $"{Manufacturer} - {ProductFamily} - {ProductName} {Version} (TWAIN {ProtocolMajor}.{ProtocolMinor})";
}
- partial struct TW_STATUSUTF8
+ public static implicit operator TW_IDENTITY_LEGACY(TW_IDENTITY value) => new()
{
- ///
- /// Frees the memory if necessary.
- ///
- ///
- public void Free(IMemoryManager mgr)
+ Id = (uint)value.Id,
+ Manufacturer = value.Manufacturer,
+ ProductFamily = value.ProductFamily,
+ ProductName = value.ProductName,
+ ProtocolMajor = value.ProtocolMajor,
+ ProtocolMinor = value.ProtocolMinor,
+ SupportedGroups = value.SupportedGroups,
+ Version = new()
{
- // session already checks for zero
- mgr.Free(UTF8string);
- UTF8string = IntPtr.Zero;
+ Country = value.Version.Country,
+ Info = value.Version.Info,
+ Language = value.Version.Language,
+ MajorNum = value.Version.MajorNum,
+ MinorNum = value.Version.MinorNum,
}
-
- ///
- /// Tries to read the text content and optionally frees the memory.
- ///
- ///
- /// Whether to free the pointer after reads.
- ///
- public string? Read(IMemoryManager mgr, bool freeMemory = true)
+ };
+ public static implicit operator TW_IDENTITY_MACOSX(TW_IDENTITY value) => new()
+ {
+ Id = (uint)value.Id,
+ Manufacturer = value.Manufacturer,
+ ProductFamily = value.ProductFamily,
+ ProductName = value.ProductName,
+ ProtocolMajor = value.ProtocolMajor,
+ ProtocolMinor = value.ProtocolMinor,
+ SupportedGroups = value.SupportedGroups,
+ Version = new()
{
- string? val = null;
- if (UTF8string != IntPtr.Zero && Size > 0)
- {
- val = UTF8string.PtrToStringUTF8(mgr, (int)Size);
- }
- if (freeMemory) Free(mgr);
- return val;
+ Country = value.Version.Country,
+ Info = value.Version.Info,
+ Language = value.Version.Language,
+ MajorNum = value.Version.MajorNum,
+ MinorNum = value.Version.MinorNum,
}
+ };
+}
+partial struct TW_IDENTITY_MACOSX
+{
+ public override string ToString()
+ {
+ return $"{Manufacturer} - {ProductName} v{Version.MajorNum}.{Version.MinorNum} (TWAIN {ProtocolMajor}.{ProtocolMinor})";
}
- partial struct TW_CAPABILITY
+ public static implicit operator TW_IDENTITY(TW_IDENTITY_MACOSX value) => new()
{
- public TW_CAPABILITY(CAP cap)
+ Id = value.Id,
+ Manufacturer = value.Manufacturer,
+ ProductFamily = value.ProductFamily,
+ ProductName = value.ProductName,
+ ProtocolMajor = value.ProtocolMajor,
+ ProtocolMinor = value.ProtocolMinor,
+ SupportedGroups = value.SupportedGroups,
+ Version = new()
{
- Cap = cap;
- ConType = (TWON)TWConst.TWON_DONTCARE16;
+ Country = value.Version.Country,
+ Info = value.Version.Info,
+ Language = value.Version.Language,
+ MajorNum = value.Version.MajorNum,
+ MinorNum = value.Version.MinorNum,
}
+ };
+ public static implicit operator TW_IDENTITY_LEGACY(TW_IDENTITY_MACOSX value) => new()
+ {
+ Id = value.Id,
+ Manufacturer = value.Manufacturer,
+ ProductFamily = value.ProductFamily,
+ ProductName = value.ProductName,
+ ProtocolMajor = value.ProtocolMajor,
+ ProtocolMinor = value.ProtocolMinor,
+ SupportedGroups = value.SupportedGroups,
+ Version = new()
+ {
+ Country = value.Version.Country,
+ Info = value.Version.Info,
+ Language = value.Version.Language,
+ MajorNum = value.Version.MajorNum,
+ MinorNum = value.Version.MinorNum,
+ }
+ };
+}
+partial struct TW_IDENTITY_LEGACY
+{
+ /////
+ ///// A simplified check on whether this has valid data from DSM.
+ /////
+ //public bool HasValue => Id != 0 && ProtocolMajor != 0 && ProtocolMinor != 0;
- ///
- /// Frees the memory if necessary.
- ///
- ///
- public void Free(IMemoryManager mgr)
- {
- // session already checks for zero
- mgr.Free(hContainer);
- hContainer = IntPtr.Zero;
- }
+ public override string ToString()
+ {
+ return $"{Manufacturer} - {ProductName} v{Version.MajorNum}.{Version.MinorNum} (TWAIN {ProtocolMajor}.{ProtocolMinor})";
}
- partial struct TW_IMAGEINFO
+ public static implicit operator TW_IDENTITY(TW_IDENTITY_LEGACY value) => new()
{
- public override string ToString()
+ Id = value.Id,
+ Manufacturer = value.Manufacturer,
+ ProductFamily = value.ProductFamily,
+ ProductName = value.ProductName,
+ ProtocolMajor = value.ProtocolMajor,
+ ProtocolMinor = value.ProtocolMinor,
+ SupportedGroups = value.SupportedGroups,
+ Version = new()
{
- return $"{ImageWidth}x{ImageLength} {PixelType} {Compression} {BitsPerPixel}bpp";
+ Country = value.Version.Country,
+ Info = value.Version.Info,
+ Language = value.Version.Language,
+ MajorNum = value.Version.MajorNum,
+ MinorNum = value.Version.MinorNum,
}
- }
-
- partial struct TW_SETUPMEMXFER
+ };
+ public static implicit operator TW_IDENTITY_MACOSX(TW_IDENTITY_LEGACY value) => new()
{
- ///
- /// Determines the best buffer size from values
- /// specified by source
- ///
- ///
- public uint DetermineBufferSize()
+ Id = value.Id,
+ Manufacturer = value.Manufacturer,
+ ProductFamily = value.ProductFamily,
+ ProductName = value.ProductName,
+ ProtocolMajor = value.ProtocolMajor,
+ ProtocolMinor = value.ProtocolMinor,
+ SupportedGroups = value.SupportedGroups,
+ Version = new()
{
- if (Preferred != TWConst.TWON_DONTCARE32) return Preferred;
- if (MaxBufSize != TWConst.TWON_DONTCARE32) return MaxBufSize;
- if (MinBufSize != TWConst.TWON_DONTCARE32) return MinBufSize;
- // default to 16 kb if source doesn't really want to say what it needs
- return 1024 * 16;
+ Country = value.Version.Country,
+ Info = value.Version.Info,
+ Language = value.Version.Language,
+ MajorNum = value.Version.MajorNum,
+ MinorNum = value.Version.MinorNum,
}
- }
+ };
+}
- partial struct TW_IMAGEMEMXFER
+partial struct TW_VERSION
+{
+ public override string ToString()
{
- ///
- /// Get a don't care version for app use.
- ///
- ///
- public static TW_IMAGEMEMXFER DONTCARE()
- {
- return new TW_IMAGEMEMXFER
- {
- BytesPerRow = TWConst.TWON_DONTCARE32,
- BytesWritten = TWConst.TWON_DONTCARE32,
- Columns = TWConst.TWON_DONTCARE32,
- Compression = TWConst.TWON_DONTCARE16,
- Rows = TWConst.TWON_DONTCARE32,
- XOffset = TWConst.TWON_DONTCARE32,
- YOffset = TWConst.TWON_DONTCARE32,
- };
- }
- }
-
- partial struct TW_IMAGEMEMXFER_MACOSX
- {
- ///
- /// Get a don't care version for app use.
- ///
- ///
- public static TW_IMAGEMEMXFER_MACOSX DONTCARE()
- {
- return new TW_IMAGEMEMXFER_MACOSX
- {
- BytesPerRow = TWConst.TWON_DONTCARE32,
- BytesWritten = TWConst.TWON_DONTCARE32,
- Columns = TWConst.TWON_DONTCARE32,
- Compression = TWConst.TWON_DONTCARE32,
- Rows = TWConst.TWON_DONTCARE32,
- XOffset = TWConst.TWON_DONTCARE32,
- YOffset = TWConst.TWON_DONTCARE32,
- };
- }
- }
-
- partial struct TW_DEVICEEVENT
- {
- // provide casted versions over raw value
-
- public TWDE Event { get { return (TWDE)_Event; } }
-
- public TWFL FlashUsed2 { get { return (TWFL)_FlashUsed2; } }
- }
-
-
- ///
- /// Container for querying ext image info. After querying and done with
- /// the data you must call to
- /// free the memory allocated.
- ///
- public partial struct TW_EXTIMAGEINFO
- {
- ///
- /// A quick way to create a query object with only values.
- /// Limit is 100 at this time.
- ///
- ///
- ///
- public static TW_EXTIMAGEINFO CreateRequest(params TWEI[] infoNames)
- {
- if (infoNames == null || infoNames.Length == 0) return default;
- if (infoNames.Length > 100) throw new InvalidOperationException("Cannot query more than 100 TWEIs at this time.");
-
- TW_EXTIMAGEINFO container = new()
- {
- NumInfos = (uint)infoNames.Length,
- };
-
- for (var i = 0; i < infoNames.Length; i++)
- {
- TW_INFO info = new() { InfoId = infoNames[i] };
- container.Set(i, ref info);
- }
- return container;
- }
-
- ///
- /// Reads the info out of this as array.
- ///
- ///
- public TW_INFO[] AsInfos()
- {
- if (NumInfos == 0) return Array.Empty();
-
- var arr = new TW_INFO[NumInfos];
- for (var i = 0; i < NumInfos; i++)
- {
- TW_INFO blah = default;
- Get(i, ref blah);
- arr[i] = blah;
- }
- return arr;
- }
-
- ///
- /// Frees all data contained here.
- ///
- ///
- public void Free(IMemoryManager memMgr)
- {
- #region don't open this
- Info_000.Free(memMgr);
- Info_001.Free(memMgr);
- Info_002.Free(memMgr);
- Info_003.Free(memMgr);
- Info_004.Free(memMgr);
- Info_005.Free(memMgr);
- Info_006.Free(memMgr);
- Info_007.Free(memMgr);
- Info_008.Free(memMgr);
- Info_009.Free(memMgr);
- Info_010.Free(memMgr);
- Info_011.Free(memMgr);
- Info_012.Free(memMgr);
- Info_013.Free(memMgr);
- Info_014.Free(memMgr);
- Info_015.Free(memMgr);
- Info_016.Free(memMgr);
- Info_017.Free(memMgr);
- Info_018.Free(memMgr);
- Info_019.Free(memMgr);
- Info_020.Free(memMgr);
- Info_021.Free(memMgr);
- Info_022.Free(memMgr);
- Info_023.Free(memMgr);
- Info_024.Free(memMgr);
- Info_025.Free(memMgr);
- Info_026.Free(memMgr);
- Info_027.Free(memMgr);
- Info_028.Free(memMgr);
- Info_029.Free(memMgr);
- Info_030.Free(memMgr);
- Info_031.Free(memMgr);
- Info_032.Free(memMgr);
- Info_033.Free(memMgr);
- Info_034.Free(memMgr);
- Info_035.Free(memMgr);
- Info_036.Free(memMgr);
- Info_037.Free(memMgr);
- Info_038.Free(memMgr);
- Info_039.Free(memMgr);
- Info_040.Free(memMgr);
- Info_041.Free(memMgr);
- Info_042.Free(memMgr);
- Info_043.Free(memMgr);
- Info_044.Free(memMgr);
- Info_045.Free(memMgr);
- Info_046.Free(memMgr);
- Info_047.Free(memMgr);
- Info_048.Free(memMgr);
- Info_049.Free(memMgr);
- Info_050.Free(memMgr);
- Info_051.Free(memMgr);
- Info_052.Free(memMgr);
- Info_053.Free(memMgr);
- Info_054.Free(memMgr);
- Info_055.Free(memMgr);
- Info_056.Free(memMgr);
- Info_057.Free(memMgr);
- Info_058.Free(memMgr);
- Info_059.Free(memMgr);
- Info_060.Free(memMgr);
- Info_061.Free(memMgr);
- Info_062.Free(memMgr);
- Info_063.Free(memMgr);
- Info_064.Free(memMgr);
- Info_065.Free(memMgr);
- Info_066.Free(memMgr);
- Info_067.Free(memMgr);
- Info_068.Free(memMgr);
- Info_069.Free(memMgr);
- Info_070.Free(memMgr);
- Info_071.Free(memMgr);
- Info_072.Free(memMgr);
- Info_073.Free(memMgr);
- Info_074.Free(memMgr);
- Info_075.Free(memMgr);
- Info_076.Free(memMgr);
- Info_077.Free(memMgr);
- Info_078.Free(memMgr);
- Info_079.Free(memMgr);
- Info_080.Free(memMgr);
- Info_081.Free(memMgr);
- Info_082.Free(memMgr);
- Info_083.Free(memMgr);
- Info_084.Free(memMgr);
- Info_085.Free(memMgr);
- Info_086.Free(memMgr);
- Info_087.Free(memMgr);
- Info_088.Free(memMgr);
- Info_089.Free(memMgr);
- Info_090.Free(memMgr);
- Info_091.Free(memMgr);
- Info_092.Free(memMgr);
- Info_093.Free(memMgr);
- Info_094.Free(memMgr);
- Info_095.Free(memMgr);
- Info_096.Free(memMgr);
- Info_097.Free(memMgr);
- Info_098.Free(memMgr);
- Info_099.Free(memMgr);
- #endregion
- }
-
- }
-
- partial struct TW_INFO
- {
- ///
- /// Quick check to see if the pointer is really
- /// a pointer or actual data (ugh).
- ///
- public bool IsDataAPointer =>
- ItemType == TWTY.HANDLE || (ItemType.GetItemTypeSize() * NumItems) > IntPtr.Size; // should it be intptr.size or just 4?
-
- ///
- /// Try to read out the item as the type specified in .
- /// This ONLY works if the data is not a pointer (see ).
- /// For pointers you'd read it yourself with
- /// .
- /// Unless it's a handle () to non-twain-strings, then you'd use
- /// .
- ///
- ///
- ///
- public unsafe TValue ReadNonPointerData() where TValue : struct
- {
- if (ReturnCode != TWRC.SUCCESS || NumItems == 0 || IsDataAPointer) return default;
-
- // we can try a trick and make a pointer to this numeric data
- // and re-use our pointer reader. There's a good chance this is wrong in many ways.
- // TODO: test this idea in some unit test
- var value = TWPlatform.Is32bit ? Item.ToUInt32() : Item.ToUInt64(); // the value should be 32bit from the spec but not sure how it'll work in 64bit
-
- var fakePtr = (IntPtr)(&value);
-
- return fakePtr.ReadTWTYData(ItemType, 0);
- }
-
- ///
- /// Try to read a null-terminated string from the item.
- ///
- ///
- /// If item is an array specify which string to read
- /// Pass a value if you know how long it should be.
- ///
- public unsafe string? ReadHandleString(IMemoryManager memMgr, int index = 0, int lengthHint = -1)
- {
- if (index < 0 || index >= NumItems || !IsDataAPointer) return default;
-
- // why is twain being difficult and not use TW_STR* like a normal person.
- // what even is the encoding for those things? Imma yolo it.
- string? value;
- var itemAsPtr = (IntPtr)Item.ToPointer(); // this is also iffy
-
- if (NumItems == 1)
- {
- // if 1, item is already the pointer to the string
- value = LockAndReadNullTerminatedString(memMgr, itemAsPtr, lengthHint);
- }
- else
- {
- // if more than 1, item points to an array of pointers that each points to their own string
- var lockPtr = memMgr.Lock(itemAsPtr);
- lockPtr += (IntPtr.Size * index);
- // is this even correct? I hope it is
- var subItemPtr = Marshal.PtrToStructure(lockPtr);
- value = LockAndReadNullTerminatedString(memMgr, subItemPtr, lengthHint);
- memMgr.Unlock(itemAsPtr);
- }
- return value;
- }
-
- private string? LockAndReadNullTerminatedString(IMemoryManager memMgr, IntPtr data, int lengthHint = -1)
- {
- var lockPtr = memMgr.Lock(data);
- // yolo as ansi, should work in most cases
- var value = lengthHint > 0 ? Marshal.PtrToStringAnsi(lockPtr, lengthHint) : Marshal.PtrToStringAnsi(lockPtr);
- memMgr.Unlock(data);
- return value;
- }
-
- ///
- /// Frees all DS-allocated memory if necessary.
- ///
- ///
- internal unsafe void Free(IMemoryManager memMgr)
- {
- if (ReturnCode != TWRC.SUCCESS || !IsDataAPointer) return;
-
- var itemAsPtr = (IntPtr)Item.ToPointer(); // this is also iffy
- if (ItemType == TWTY.HANDLE && NumItems > 1)
- {
- // must go into each handle in the array and free them individually :(
- var lockPtr = memMgr.Lock(itemAsPtr);
- for (var i = 0; i < NumItems; i++)
- {
- // is this even correct? I hope it is
- var subItemPtr = Marshal.PtrToStructure(lockPtr);
- memMgr.Free(subItemPtr);
- lockPtr += IntPtr.Size;
- }
- }
- memMgr.Free(itemAsPtr);
- Item = UIntPtr.Zero;
- }
+ return $"{MajorNum}.{MinorNum}";
+ }
+}
+
+partial struct TW_STATUSUTF8
+{
+ ///
+ /// Frees the memory if necessary.
+ ///
+ ///
+ public void Free(IMemoryManager mgr)
+ {
+ // session already checks for zero
+ mgr.Free(UTF8string);
+ UTF8string = IntPtr.Zero;
+ }
+
+ ///
+ /// Tries to read the text content and optionally frees the memory.
+ ///
+ ///
+ /// Whether to free the pointer after reads.
+ ///
+ public string? Read(IMemoryManager mgr, bool freeMemory = true)
+ {
+ string? val = null;
+ if (UTF8string != IntPtr.Zero && Size > 0)
+ {
+ val = UTF8string.PtrToStringUTF8(mgr, (int)Size);
+ }
+ if (freeMemory) Free(mgr);
+ return val;
+ }
+}
+
+partial struct TW_CAPABILITY
+{
+ public TW_CAPABILITY(CAP cap)
+ {
+ Cap = cap;
+ ConType = (TWON)TWConst.TWON_DONTCARE16;
+ }
+
+ ///
+ /// Frees the memory if necessary.
+ ///
+ ///
+ public void Free(IMemoryManager mgr)
+ {
+ // session already checks for zero
+ mgr.Free(hContainer);
+ hContainer = IntPtr.Zero;
+ }
+}
+
+partial struct TW_IMAGEINFO
+{
+ public override string ToString()
+ {
+ return $"{ImageWidth}x{ImageLength} {PixelType} {Compression} {BitsPerPixel}bpp";
+ }
+}
+
+partial struct TW_SETUPMEMXFER
+{
+ ///
+ /// Determines the best buffer size from values
+ /// specified by source
+ ///
+ ///
+ public uint DetermineBufferSize()
+ {
+ if (Preferred != TWConst.TWON_DONTCARE32) return Preferred;
+ if (MaxBufSize != TWConst.TWON_DONTCARE32) return MaxBufSize;
+ if (MinBufSize != TWConst.TWON_DONTCARE32) return MinBufSize;
+ // default to 16 kb if source doesn't really want to say what it needs
+ return 1024 * 16;
+ }
+}
+
+partial struct TW_IMAGEMEMXFER
+{
+ ///
+ /// Get a don't care version for app use.
+ ///
+ ///
+ public static TW_IMAGEMEMXFER DONTCARE()
+ {
+ return new TW_IMAGEMEMXFER
+ {
+ BytesPerRow = TWConst.TWON_DONTCARE32,
+ BytesWritten = TWConst.TWON_DONTCARE32,
+ Columns = TWConst.TWON_DONTCARE32,
+ Compression = TWConst.TWON_DONTCARE16,
+ Rows = TWConst.TWON_DONTCARE32,
+ XOffset = TWConst.TWON_DONTCARE32,
+ YOffset = TWConst.TWON_DONTCARE32,
+ };
+ }
+}
+
+partial struct TW_IMAGEMEMXFER_MACOSX
+{
+ ///
+ /// Get a don't care version for app use.
+ ///
+ ///
+ public static TW_IMAGEMEMXFER_MACOSX DONTCARE()
+ {
+ return new TW_IMAGEMEMXFER_MACOSX
+ {
+ BytesPerRow = TWConst.TWON_DONTCARE32,
+ BytesWritten = TWConst.TWON_DONTCARE32,
+ Columns = TWConst.TWON_DONTCARE32,
+ Compression = TWConst.TWON_DONTCARE32,
+ Rows = TWConst.TWON_DONTCARE32,
+ XOffset = TWConst.TWON_DONTCARE32,
+ YOffset = TWConst.TWON_DONTCARE32,
+ };
+ }
+}
+
+partial struct TW_DEVICEEVENT
+{
+ // provide casted versions over raw value
+
+ public TWDE Event { get { return (TWDE)_Event; } }
+
+ public TWFL FlashUsed2 { get { return (TWFL)_FlashUsed2; } }
+}
+
+
+///
+/// Container for querying ext image info. After querying and done with
+/// the data you must call to
+/// free the memory allocated.
+///
+public partial struct TW_EXTIMAGEINFO
+{
+ ///
+ /// A quick way to create a query object with only values.
+ /// Limit is 100 at this time.
+ ///
+ ///
+ ///
+ public static TW_EXTIMAGEINFO CreateRequest(params TWEI[] infoNames)
+ {
+ if (infoNames == null || infoNames.Length == 0) return default;
+ if (infoNames.Length > 100) throw new InvalidOperationException("Cannot query more than 100 TWEIs at this time.");
+
+ TW_EXTIMAGEINFO container = new()
+ {
+ NumInfos = (uint)infoNames.Length,
+ };
+
+ for (var i = 0; i < infoNames.Length; i++)
+ {
+ TW_INFO info = new() { InfoId = infoNames[i] };
+ container.Set(i, ref info);
+ }
+ return container;
+ }
+
+ ///
+ /// Reads the info out of this as array.
+ ///
+ ///
+ public TW_INFO[] AsInfos()
+ {
+ if (NumInfos == 0) return Array.Empty();
+
+ var arr = new TW_INFO[NumInfos];
+ for (var i = 0; i < NumInfos; i++)
+ {
+ TW_INFO blah = default;
+ Get(i, ref blah);
+ arr[i] = blah;
+ }
+ return arr;
+ }
+
+ ///
+ /// Frees all data contained here.
+ ///
+ ///
+ public void Free(IMemoryManager memMgr)
+ {
+ #region don't open this
+ Info_000.Free(memMgr);
+ Info_001.Free(memMgr);
+ Info_002.Free(memMgr);
+ Info_003.Free(memMgr);
+ Info_004.Free(memMgr);
+ Info_005.Free(memMgr);
+ Info_006.Free(memMgr);
+ Info_007.Free(memMgr);
+ Info_008.Free(memMgr);
+ Info_009.Free(memMgr);
+ Info_010.Free(memMgr);
+ Info_011.Free(memMgr);
+ Info_012.Free(memMgr);
+ Info_013.Free(memMgr);
+ Info_014.Free(memMgr);
+ Info_015.Free(memMgr);
+ Info_016.Free(memMgr);
+ Info_017.Free(memMgr);
+ Info_018.Free(memMgr);
+ Info_019.Free(memMgr);
+ Info_020.Free(memMgr);
+ Info_021.Free(memMgr);
+ Info_022.Free(memMgr);
+ Info_023.Free(memMgr);
+ Info_024.Free(memMgr);
+ Info_025.Free(memMgr);
+ Info_026.Free(memMgr);
+ Info_027.Free(memMgr);
+ Info_028.Free(memMgr);
+ Info_029.Free(memMgr);
+ Info_030.Free(memMgr);
+ Info_031.Free(memMgr);
+ Info_032.Free(memMgr);
+ Info_033.Free(memMgr);
+ Info_034.Free(memMgr);
+ Info_035.Free(memMgr);
+ Info_036.Free(memMgr);
+ Info_037.Free(memMgr);
+ Info_038.Free(memMgr);
+ Info_039.Free(memMgr);
+ Info_040.Free(memMgr);
+ Info_041.Free(memMgr);
+ Info_042.Free(memMgr);
+ Info_043.Free(memMgr);
+ Info_044.Free(memMgr);
+ Info_045.Free(memMgr);
+ Info_046.Free(memMgr);
+ Info_047.Free(memMgr);
+ Info_048.Free(memMgr);
+ Info_049.Free(memMgr);
+ Info_050.Free(memMgr);
+ Info_051.Free(memMgr);
+ Info_052.Free(memMgr);
+ Info_053.Free(memMgr);
+ Info_054.Free(memMgr);
+ Info_055.Free(memMgr);
+ Info_056.Free(memMgr);
+ Info_057.Free(memMgr);
+ Info_058.Free(memMgr);
+ Info_059.Free(memMgr);
+ Info_060.Free(memMgr);
+ Info_061.Free(memMgr);
+ Info_062.Free(memMgr);
+ Info_063.Free(memMgr);
+ Info_064.Free(memMgr);
+ Info_065.Free(memMgr);
+ Info_066.Free(memMgr);
+ Info_067.Free(memMgr);
+ Info_068.Free(memMgr);
+ Info_069.Free(memMgr);
+ Info_070.Free(memMgr);
+ Info_071.Free(memMgr);
+ Info_072.Free(memMgr);
+ Info_073.Free(memMgr);
+ Info_074.Free(memMgr);
+ Info_075.Free(memMgr);
+ Info_076.Free(memMgr);
+ Info_077.Free(memMgr);
+ Info_078.Free(memMgr);
+ Info_079.Free(memMgr);
+ Info_080.Free(memMgr);
+ Info_081.Free(memMgr);
+ Info_082.Free(memMgr);
+ Info_083.Free(memMgr);
+ Info_084.Free(memMgr);
+ Info_085.Free(memMgr);
+ Info_086.Free(memMgr);
+ Info_087.Free(memMgr);
+ Info_088.Free(memMgr);
+ Info_089.Free(memMgr);
+ Info_090.Free(memMgr);
+ Info_091.Free(memMgr);
+ Info_092.Free(memMgr);
+ Info_093.Free(memMgr);
+ Info_094.Free(memMgr);
+ Info_095.Free(memMgr);
+ Info_096.Free(memMgr);
+ Info_097.Free(memMgr);
+ Info_098.Free(memMgr);
+ Info_099.Free(memMgr);
+ #endregion
+ }
+
+}
+
+partial struct TW_INFO
+{
+ ///
+ /// Quick check to see if the pointer is really
+ /// a pointer or actual data (ugh).
+ ///
+ public bool IsDataAPointer =>
+ ItemType == TWTY.HANDLE || (ItemType.GetItemTypeSize() * NumItems) > IntPtr.Size; // should it be intptr.size or just 4?
+
+ ///
+ /// Try to read out the item as the type specified in .
+ /// This ONLY works if the data is not a pointer (see ).
+ /// For pointers you'd read it yourself with
+ /// .
+ /// Unless it's a handle () to non-twain-strings, then you'd use
+ /// .
+ ///
+ ///
+ ///
+ public unsafe TValue ReadNonPointerData() where TValue : struct
+ {
+ if (ReturnCode != TWRC.SUCCESS || NumItems == 0 || IsDataAPointer) return default;
+
+ // we can try a trick and make a pointer to this numeric data
+ // and re-use our pointer reader. There's a good chance this is wrong in many ways.
+ // TODO: test this idea in some unit test
+ var value = TWPlatform.Is32bit ? Item.ToUInt32() : Item.ToUInt64(); // the value should be 32bit from the spec but not sure how it'll work in 64bit
+
+ var fakePtr = (IntPtr)(&value);
+
+ return fakePtr.ReadTWTYData(ItemType, 0);
+ }
+
+ ///
+ /// Try to read a null-terminated string from the item.
+ ///
+ ///
+ /// If item is an array specify which string to read
+ /// Pass a value if you know how long it should be.
+ ///
+ public unsafe string? ReadHandleString(IMemoryManager memMgr, int index = 0, int lengthHint = -1)
+ {
+ if (index < 0 || index >= NumItems || !IsDataAPointer) return default;
+
+ // why is twain being difficult and not use TW_STR* like a normal person.
+ // what even is the encoding for those things? Imma yolo it.
+ string? value;
+ var itemAsPtr = (IntPtr)Item.ToPointer(); // this is also iffy
+
+ if (NumItems == 1)
+ {
+ // if 1, item is already the pointer to the string
+ value = LockAndReadNullTerminatedString(memMgr, itemAsPtr, lengthHint);
+ }
+ else
+ {
+ // if more than 1, item points to an array of pointers that each points to their own string
+ var lockPtr = memMgr.Lock(itemAsPtr);
+ lockPtr += (IntPtr.Size * index);
+ // is this even correct? I hope it is
+ var subItemPtr = Marshal.PtrToStructure(lockPtr);
+ value = LockAndReadNullTerminatedString(memMgr, subItemPtr, lengthHint);
+ memMgr.Unlock(itemAsPtr);
+ }
+ return value;
+ }
+
+ private string? LockAndReadNullTerminatedString(IMemoryManager memMgr, IntPtr data, int lengthHint = -1)
+ {
+ var lockPtr = memMgr.Lock(data);
+ // yolo as ansi, should work in most cases
+ var value = lengthHint > 0 ? Marshal.PtrToStringAnsi(lockPtr, lengthHint) : Marshal.PtrToStringAnsi(lockPtr);
+ memMgr.Unlock(data);
+ return value;
+ }
+
+ ///
+ /// Frees all DS-allocated memory if necessary.
+ ///
+ ///
+ internal unsafe void Free(IMemoryManager memMgr)
+ {
+ if (ReturnCode != TWRC.SUCCESS || !IsDataAPointer) return;
+
+ var itemAsPtr = (IntPtr)Item.ToPointer(); // this is also iffy
+ if (ItemType == TWTY.HANDLE && NumItems > 1)
+ {
+ // must go into each handle in the array and free them individually :(
+ var lockPtr = memMgr.Lock(itemAsPtr);
+ for (var i = 0; i < NumItems; i++)
+ {
+ // is this even correct? I hope it is
+ var subItemPtr = Marshal.PtrToStructure(lockPtr);
+ memMgr.Free(subItemPtr);
+ lockPtr += IntPtr.Size;
+ }
+ }
+ memMgr.Free(itemAsPtr);
+ Item = UIntPtr.Zero;
}
}
diff --git a/src/NTwain/Data/ValueReader.cs b/src/NTwain/Data/ValueReader.cs
index 66eba1e..a308808 100644
--- a/src/NTwain/Data/ValueReader.cs
+++ b/src/NTwain/Data/ValueReader.cs
@@ -4,749 +4,748 @@ using System.IO;
using System.Runtime.InteropServices;
using System.Text;
-namespace NTwain.Data
+namespace NTwain.Data;
+
+///
+/// Contains methods for reading pointers into various things.
+///
+public static class ValueReader
{
///
- /// Contains methods for reading pointers into various things.
+ /// Reads pointer as UTF8 string.
///
- public static class ValueReader
+ /// Pointer to string.
+ ///
+ /// Number of bytes to read.
+ ///
+ public static unsafe string? PtrToStringUTF8(this IntPtr data, IMemoryManager memMgr, int length)
{
- ///
- /// Reads pointer as UTF8 string.
- ///
- /// Pointer to string.
- ///
- /// Number of bytes to read.
- ///
- public static unsafe string? PtrToStringUTF8(this IntPtr data, IMemoryManager memMgr, int length)
+ string? val = null;
+ var locked = memMgr.Lock(data);
+ if (locked != IntPtr.Zero)
{
- string? val = null;
- var locked = memMgr.Lock(data);
- if (locked != IntPtr.Zero)
+ try
{
- try
- {
#if NETFRAMEWORK
- // safe method but with 2 copies (arr and parsed string)
- //var bytes = new byte[length];
- //Marshal.Copy(locked, bytes, 0, bytes.Length);
- //val = Encoding.UTF8.GetString(bytes);
+ // safe method but with 2 copies (arr and parsed string)
+ //var bytes = new byte[length];
+ //Marshal.Copy(locked, bytes, 0, bytes.Length);
+ //val = Encoding.UTF8.GetString(bytes);
- // does this work?
- val = Encoding.UTF8.GetString((byte*)locked, length);
+ // does this work?
+ val = Encoding.UTF8.GetString((byte*)locked, length);
#else
- val = Marshal.PtrToStringUTF8(locked, length);
+ val = Marshal.PtrToStringUTF8(locked, length);
#endif
- }
- finally
- {
- memMgr.Unlock(data);
- }
- }
- return val;
- }
-
- static T MarshalTo(IntPtr ptr) => Marshal.PtrToStructure(ptr)!;
-
-
- // these contain parts from the original TWAIN.CapabilityToCsv()
-
- public static TWTY DetermineValueType(this ref TW_CAPABILITY cap, IMemoryManager memMgr, bool freeMemory = true)
- {
- var type = TWTY.Invalid;
-
-
- var lockedPtr = memMgr.Lock(cap.hContainer);
-
- try
- {
- if (TWPlatform.IsMacOSX)
- {
- type = (TWTY)(ushort)(uint)Marshal.ReadInt32(lockedPtr);
-
- }
- else
- {
- type = (TWTY)(ushort)Marshal.ReadInt16(lockedPtr);
- }
}
finally
{
- if (lockedPtr != IntPtr.Zero) memMgr.Unlock(cap.hContainer);
- if (freeMemory)
- {
- memMgr.Free(cap.hContainer);
- cap.hContainer = IntPtr.Zero;
- }
- }
-
- return type;
- }
-
-
- ///
- /// Reads a boxed one value out of a cap. This can only be done once if memory is freed.
- ///
- ///
- ///
- ///
- ///
- public static object? ReadOneValueBoxed(this ref TW_CAPABILITY cap, IMemoryManager memMgr, bool freeMemory = true)
- {
- if (cap.ConType != TWON.ONEVALUE || cap.hContainer == IntPtr.Zero) return default;
-
- var lockedPtr = memMgr.Lock(cap.hContainer);
-
- try
- {
- TWTY itemType;
- // Mac has a level of indirection and a different structure (ick)...
- if (TWPlatform.IsMacOSX)
- {
- // Crack the container...
- var onevalue = MarshalTo(lockedPtr);
- itemType = (TWTY)onevalue.ItemType;
- lockedPtr += Marshal.SizeOf(onevalue);
- }
- else
- {
- // Crack the container...
- var onevalue = MarshalTo(lockedPtr);
- itemType = onevalue.ItemType;
- lockedPtr += Marshal.SizeOf(onevalue);
- }
-
- return ReadTWTYDataBoxed(lockedPtr, itemType, 0);
- }
- finally
- {
- if (lockedPtr != IntPtr.Zero) memMgr.Unlock(cap.hContainer);
- if (freeMemory)
- {
- memMgr.Free(cap.hContainer);
- cap.hContainer = IntPtr.Zero;
- }
+ memMgr.Unlock(data);
}
}
-
- ///
- /// Reads a one value out of a cap. This can only be done once if memory is freed.
- ///
- ///
- ///
- ///
- ///
- ///
- public static TValue ReadOneValue(this ref TW_CAPABILITY cap, IMemoryManager memMgr, bool freeMemory = true) where TValue : struct
- {
- if (cap.ConType != TWON.ONEVALUE || cap.hContainer == IntPtr.Zero) return default;
-
- var lockedPtr = memMgr.Lock(cap.hContainer);
-
- try
- {
- TWTY itemType;
- // Mac has a level of indirection and a different structure (ick)...
- if (TWPlatform.IsMacOSX)
- {
- // Crack the container...
- var onevalue = MarshalTo(lockedPtr);
- itemType = (TWTY)onevalue.ItemType;
- lockedPtr += Marshal.SizeOf(onevalue);
- }
- else
- {
- // Crack the container...
- var onevalue = MarshalTo(lockedPtr);
- itemType = onevalue.ItemType;
- lockedPtr += Marshal.SizeOf(onevalue);
- }
-
- return ReadTWTYData(lockedPtr, itemType, 0);
- }
- finally
- {
- if (lockedPtr != IntPtr.Zero) memMgr.Unlock(cap.hContainer);
- if (freeMemory)
- {
- memMgr.Free(cap.hContainer);
- cap.hContainer = IntPtr.Zero;
- }
- }
- }
-
- public static Enumeration