diff --git a/LICENSE.txt b/LICENSE.txt index e7ac9c7..dbc8c8f 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,5 +1,5 @@ The MIT License (MIT) -Copyright (c) 2012 Yin-Chun Wang +Copyright (c) 2012 Eugene Wang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/NTwain.sln b/NTwain.sln index 834ce5d..0ca2d5c 100644 --- a/NTwain.sln +++ b/NTwain.sln @@ -1,109 +1,22 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2048 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NTwain", "src\NTwain\NTwain.csproj", "{0C5A6FB1-0282-4D61-8354-68DEB1515001}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NTwain.Tests", "Tests\NTwain.Tests\NTwain.Tests.csproj", "{6B034C50-A397-435F-8DDF-677B403FEBAA}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{2F906640-1664-4960-93D2-A054AC6E66A3}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Winform", "samples\Sample.Winform\Sample.Winform.csproj", "{4FC243F1-318E-4FA9-9EBD-2CA3A8F35425}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.WPF", "samples\Sample.WPF\Sample.WPF.csproj", "{1715C2B7-5C35-4F8B-9D9B-8D68A3D5284D}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "common", "common", "{4CE0B9ED-2CD1-440F-B4EC-35ECA6D61EFE}" ProjectSection(SolutionItems) = preProject LICENSE.txt = LICENSE.txt README.md = README.md - Spec\twain2.3.h = Spec\twain2.3.h + Spec\TWAIN-2.4-Specification.pdf = Spec\TWAIN-2.4-Specification.pdf + Spec\twain2.4.h = Spec\twain2.4.h EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Console", "samples\Sample.Console\Sample.Console.csproj", "{12D761EF-68DF-41CE-92EF-0C7AE81857A3}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NTwain.Net35", "src\NTwain.Net35\NTwain.Net35.csproj", "{2E965494-94B0-4EC7-960C-24E5D7D04278}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{B77C17FE-FD84-4FF4-9A1C-D49DB1749C9C}" -EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|Mixed Platforms = Debug|Mixed Platforms - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|Mixed Platforms = Release|Mixed Platforms - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0C5A6FB1-0282-4D61-8354-68DEB1515001}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0C5A6FB1-0282-4D61-8354-68DEB1515001}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0C5A6FB1-0282-4D61-8354-68DEB1515001}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {0C5A6FB1-0282-4D61-8354-68DEB1515001}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {0C5A6FB1-0282-4D61-8354-68DEB1515001}.Debug|x86.ActiveCfg = Debug|Any CPU - {0C5A6FB1-0282-4D61-8354-68DEB1515001}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0C5A6FB1-0282-4D61-8354-68DEB1515001}.Release|Any CPU.Build.0 = Release|Any CPU - {0C5A6FB1-0282-4D61-8354-68DEB1515001}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {0C5A6FB1-0282-4D61-8354-68DEB1515001}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {0C5A6FB1-0282-4D61-8354-68DEB1515001}.Release|x86.ActiveCfg = Release|Any CPU - {6B034C50-A397-435F-8DDF-677B403FEBAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6B034C50-A397-435F-8DDF-677B403FEBAA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6B034C50-A397-435F-8DDF-677B403FEBAA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {6B034C50-A397-435F-8DDF-677B403FEBAA}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {6B034C50-A397-435F-8DDF-677B403FEBAA}.Debug|x86.ActiveCfg = Debug|Any CPU - {6B034C50-A397-435F-8DDF-677B403FEBAA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6B034C50-A397-435F-8DDF-677B403FEBAA}.Release|Any CPU.Build.0 = Release|Any CPU - {6B034C50-A397-435F-8DDF-677B403FEBAA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {6B034C50-A397-435F-8DDF-677B403FEBAA}.Release|x86.ActiveCfg = Release|Any CPU - {4FC243F1-318E-4FA9-9EBD-2CA3A8F35425}.Debug|Any CPU.ActiveCfg = Debug|x86 - {4FC243F1-318E-4FA9-9EBD-2CA3A8F35425}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {4FC243F1-318E-4FA9-9EBD-2CA3A8F35425}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {4FC243F1-318E-4FA9-9EBD-2CA3A8F35425}.Debug|x86.ActiveCfg = Debug|x86 - {4FC243F1-318E-4FA9-9EBD-2CA3A8F35425}.Debug|x86.Build.0 = Debug|x86 - {4FC243F1-318E-4FA9-9EBD-2CA3A8F35425}.Release|Any CPU.ActiveCfg = Release|x86 - {4FC243F1-318E-4FA9-9EBD-2CA3A8F35425}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {4FC243F1-318E-4FA9-9EBD-2CA3A8F35425}.Release|Mixed Platforms.Build.0 = Release|x86 - {4FC243F1-318E-4FA9-9EBD-2CA3A8F35425}.Release|x86.ActiveCfg = Release|x86 - {4FC243F1-318E-4FA9-9EBD-2CA3A8F35425}.Release|x86.Build.0 = Release|x86 - {1715C2B7-5C35-4F8B-9D9B-8D68A3D5284D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1715C2B7-5C35-4F8B-9D9B-8D68A3D5284D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1715C2B7-5C35-4F8B-9D9B-8D68A3D5284D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {1715C2B7-5C35-4F8B-9D9B-8D68A3D5284D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {1715C2B7-5C35-4F8B-9D9B-8D68A3D5284D}.Debug|x86.ActiveCfg = Debug|Any CPU - {1715C2B7-5C35-4F8B-9D9B-8D68A3D5284D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1715C2B7-5C35-4F8B-9D9B-8D68A3D5284D}.Release|Any CPU.Build.0 = Release|Any CPU - {1715C2B7-5C35-4F8B-9D9B-8D68A3D5284D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {1715C2B7-5C35-4F8B-9D9B-8D68A3D5284D}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {1715C2B7-5C35-4F8B-9D9B-8D68A3D5284D}.Release|x86.ActiveCfg = Release|Any CPU - {12D761EF-68DF-41CE-92EF-0C7AE81857A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {12D761EF-68DF-41CE-92EF-0C7AE81857A3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {12D761EF-68DF-41CE-92EF-0C7AE81857A3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {12D761EF-68DF-41CE-92EF-0C7AE81857A3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {12D761EF-68DF-41CE-92EF-0C7AE81857A3}.Debug|x86.ActiveCfg = Debug|Any CPU - {12D761EF-68DF-41CE-92EF-0C7AE81857A3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {12D761EF-68DF-41CE-92EF-0C7AE81857A3}.Release|Any CPU.Build.0 = Release|Any CPU - {12D761EF-68DF-41CE-92EF-0C7AE81857A3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {12D761EF-68DF-41CE-92EF-0C7AE81857A3}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {12D761EF-68DF-41CE-92EF-0C7AE81857A3}.Release|x86.ActiveCfg = Release|Any CPU - {2E965494-94B0-4EC7-960C-24E5D7D04278}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2E965494-94B0-4EC7-960C-24E5D7D04278}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2E965494-94B0-4EC7-960C-24E5D7D04278}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {2E965494-94B0-4EC7-960C-24E5D7D04278}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {2E965494-94B0-4EC7-960C-24E5D7D04278}.Debug|x86.ActiveCfg = Debug|Any CPU - {2E965494-94B0-4EC7-960C-24E5D7D04278}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2E965494-94B0-4EC7-960C-24E5D7D04278}.Release|Any CPU.Build.0 = Release|Any CPU - {2E965494-94B0-4EC7-960C-24E5D7D04278}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {2E965494-94B0-4EC7-960C-24E5D7D04278}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {2E965494-94B0-4EC7-960C-24E5D7D04278}.Release|x86.ActiveCfg = Release|Any CPU - EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {6B034C50-A397-435F-8DDF-677B403FEBAA} = {B77C17FE-FD84-4FF4-9A1C-D49DB1749C9C} - {4FC243F1-318E-4FA9-9EBD-2CA3A8F35425} = {2F906640-1664-4960-93D2-A054AC6E66A3} - {1715C2B7-5C35-4F8B-9D9B-8D68A3D5284D} = {2F906640-1664-4960-93D2-A054AC6E66A3} - {12D761EF-68DF-41CE-92EF-0C7AE81857A3} = {2F906640-1664-4960-93D2-A054AC6E66A3} + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7459323B-44F6-4E07-8574-E1B4B525086B} EndGlobalSection GlobalSection(TestCaseManagementSettings) = postSolution CategoryFile = NTwain.vsmdi diff --git a/Spec/TWAIN-2.4-Features.pdf b/Spec/TWAIN-2.4-Features.pdf new file mode 100644 index 0000000..650168d Binary files /dev/null and b/Spec/TWAIN-2.4-Features.pdf differ diff --git a/Spec/TWAIN-2.4-Specification.pdf b/Spec/TWAIN-2.4-Specification.pdf new file mode 100644 index 0000000..1edd836 Binary files /dev/null and b/Spec/TWAIN-2.4-Specification.pdf differ diff --git a/Spec/twain2.4.h b/Spec/twain2.4.h new file mode 100644 index 0000000..0d1ce92 --- /dev/null +++ b/Spec/twain2.4.h @@ -0,0 +1,2265 @@ +/* ======================================================================== *\ + + Copyright (C) 2007 TWAIN Working Group: Adobe Systems Incorporated, + AnyDoc Software Inc., Eastman Kodak Company, Fujitsu Computer Products + of America, JFL Peripheral Solutions Inc., Ricoh Corporation, and + Xerox Corporation. All rights reserved. + + Copyright (C) 1991, 1992 TWAIN Working Group: Aldus, Caere, Eastman-Kodak, + Hewlett-Packard and Logitech Corporations. All rights reserved. + + Copyright (C) 1997 TWAIN Working Group: Bell+Howell, Canon, DocuMagix, + Fujitsu, Genoa Technology, Hewlett-Packard, Kofax Imaging Products, and + Ricoh Corporation. All rights reserved. + + Copyright (C) 1998 TWAIN Working Group: Adobe Systems Incorporated, + Canon Information Systems, Eastman Kodak Company, + Fujitsu Computer Products of America, Genoa Technology, + Hewlett-Packard Company, Intel Corporation, Kofax Image Products, + JFL Peripheral Solutions Inc., Ricoh Corporation, and Xerox Corporation. + All rights reserved. + + Copyright (C) 2000 TWAIN Working Group: Adobe Systems Incorporated, + Canon Information Systems, Digimarc Corporation, Eastman Kodak Company, + Fujitsu Computer Products of America, Hewlett-Packard Company, + JFL Peripheral Solutions Inc., Ricoh Corporation, and Xerox Corporation. + All rights reserved. + + + TWAIN.h - This is the definitive include file for applications and + data sources written to the TWAIN specification. + It defines constants, data structures, messages etc. + for the public interface to TWAIN. + + Revision History: + version 1.0, March 6, 1992. TWAIN 1.0. + version 1.1, January 1993. Tech Notes 1.1 + version 1.5, June 1993. Specification Update 1.5 + Change DC to TW + Change filename from DC.H to TWAIN.H + version 1.5, July 1993. Remove spaces from country identifiers + + version 1.7, July 1997 Added Capabilities and data structure for + document imaging and digital cameras. + KHL. + version 1.7, July 1997 Inserted Borland compatibile structure packing + directives provided by Mentor. JMH + version 1.7, Aug 1997 Expanded file tabs to spaces. + NOTE: future authors should be sure to have + their editors set to automatically expand tabs + to spaces (original tab setting was 4 spaces). + version 1.7, Sept 1997 Added job control values + Added return codes + version 1.7, Sept 1997 changed definition of pRGBRESPONSE to + pTW_RGBRESPONSE + version 1.7 Aug 1998 Added missing TWEI_BARCODEROTATION values + TWBCOR_ types JMH + version 1.8 August 1998 Added new types and definitions required + for 1.8 Specification JMH + version 1.8 January 1999 Changed search mode from SRCH_ to TWBD_ as + in 1.8 Specification, added TWBT_MAXICODE JMH + version 1.8 January 1999 Removed undocumented duplicate AUTO JMH + version 1.8 March 1999 Removed undocumented 1.8 caps: + CAP_FILESYSTEM + CAP_PAPERBINDING + CAP_PASSTHRU + CAP_POWERDOWNTIME + ICAP_AUTODISCARDBLANKPAGES + * CAP_PAGEMULTIPLEACQUIRE - is CAP_REACQUIREALLOWED, + requires spec change. JMH + Added Mac structure packing modifications JMH + version 1.9 March 2000 Added new types and definations required + for 1.9 Specification MLM + version 1.9 March 2000 Added ICAP_JPEGQUALITY, TWJQ_ values, + updated TWON_PROTOCOLMINOR for Release v1.9 MN + version 1.91 August 2007 Added new types and definitions required + for 1.91 Specification MLM + version 2.0 Sept 2007 Added new types and definitions required + for 2.0 Specification FHH + version 2.0 Mar 2008 Depreciated ICAP_PIXELTYPEs TWPT_SRGB64, TWPT_BGR, + TWPT_CIELAB, TWPT_CIELUV, and TWPT_YCBCR JMW + version 2.0 Mar 2008 Added missing new 2.0 CAP_ definitions JMW + version 2.0 Dec 2008 Updated TW_INFO structure for 64bit JMW + version 2.1 Mar 2009 Added new types and definitions required + for 2.1 Specification JMW + version 2.2 Nov 2010 Added new types and definitions required + for 2.2 Specification MSM + version 2.3 Feb 2013 Added new types and definitions required + for 2.3 Specification MLM + version 2.3a Apr 2015 Errata fixes to TWCY_ANDORRA and TWCY_CUBA + version 2.4 Aug 2015 Added new types and definitions required + for 2.4 Specification MLM + version 2.4a June 2016 Added TW_INT32 and TW_UINT32 fixes for Linux, + (I just added this comment today) + version 2.4b March 2017 Missing changeset from 2.3 verion (2013/06/20) + + +\* ======================================================================== */ + +#ifndef TWAIN +#define TWAIN + +/**************************************************************************** + * TWAIN Version * + ****************************************************************************/ +#define TWON_PROTOCOLMINOR 4 /* Changed for Version 2.4 */ +#define TWON_PROTOCOLMAJOR 2 + +/**************************************************************************** + * Platform Dependent Definitions and Typedefs * + ****************************************************************************/ + +/* Microsoft C/C++ Compiler */ +#if defined(WIN32) || defined(WIN64) || defined (_WINDOWS) + #define TWH_CMP_MSC + #if defined(_WIN64) || defined(WIN64) + #define TWH_64BIT + #elif defined(WIN32) || defined(_WIN32) + #define TWH_32BIT + #endif + +/* GNU C/C++ Compiler */ +#elif defined(__GNUC__) + #define TWH_CMP_GNU + #if defined(__alpha__)\ + ||defined(__ia64__)\ + ||defined(__ppc64__)\ + ||defined(__s390x__)\ + ||defined(__x86_64__) + #define TWH_64BIT + #else + #define TWH_32BIT + #endif + + +/* Borland C/C++ Compiler */ +#elif defined(__BORLAND__) + #define TWH_CMP_BORLAND + #define TWH_32BIT +/* Unrecognized */ +#else + #error Unrecognized compiler +#endif + +/* Apple Compiler (which is GNU now) */ +#if defined(__APPLE__) + #define TWH_CMP_XCODE + #ifdef __MWERKS__ + #include + #else + #include + #endif +#endif + +/* Win32 and Win64 systems */ +#if defined(TWH_CMP_MSC) | defined(TWH_CMP_BORLAND) + typedef HANDLE TW_HANDLE; + typedef LPVOID TW_MEMREF; + typedef UINT_PTR TW_UINTPTR; + +/* MacOS/X... */ +#elif defined(TWH_CMP_XCODE) + #define PASCAL pascal + #define FAR + typedef Handle TW_HANDLE; + typedef char *TW_MEMREF; + typedef unsigned char BYTE; + + #ifdef TWH_32BIT + //32 bit GNU + typedef unsigned long TW_UINTPTR; + #else + //64 bit GNU + typedef unsigned long long TW_UINTPTR; + #endif + +/* Everything else... */ +#else + #define PASCAL + #define FAR + typedef void* TW_HANDLE; + typedef void* TW_MEMREF; + typedef unsigned char BYTE; + + #ifdef TWH_32BIT + //32 bit GNU + typedef unsigned long TW_UINTPTR; + #else + //64 bit GNU + typedef unsigned long long TW_UINTPTR; + #endif +#endif + + +/* Set the packing: this occurs before any structures are defined */ +#ifdef TWH_CMP_MSC + #pragma pack (push, before_twain) + #pragma pack (2) +#elif defined(TWH_CMP_GNU) + #if defined(__APPLE__) /* cf: Mac version of TWAIN.h */ + #pragma options align = power + #else + #pragma pack (push, before_twain) + #pragma pack (2) + #endif +#elif defined(TWH_CMP_BORLAND) + #pragma option -a2 +#endif + + +/**************************************************************************** + * Type Definitions * + ****************************************************************************/ + +/* String types. These include room for the strings and a NULL char, * + * or, on the Mac, a length byte followed by the string. * + * TW_STR255 must hold less than 256 chars so length fits in first byte. */ +#if defined(__APPLE__)/* cf: Mac version of TWAIN.h */ + typedef unsigned char TW_STR32[34], FAR *pTW_STR32; + typedef unsigned char TW_STR64[66], FAR *pTW_STR64; + typedef unsigned char TW_STR128[130], FAR *pTW_STR128; + typedef unsigned char TW_STR255[256], FAR *pTW_STR255; +#else + typedef char TW_STR32[34], FAR *pTW_STR32; + typedef char TW_STR64[66], FAR *pTW_STR64; + typedef char TW_STR128[130], FAR *pTW_STR128; + typedef char TW_STR255[256], FAR *pTW_STR255; +#endif + +/* Numeric types. */ +typedef char TW_INT8, FAR *pTW_INT8; +typedef short TW_INT16, FAR *pTW_INT16; +#if defined(_WIN32) + typedef long TW_INT32, FAR *pTW_INT32; +#else + typedef int TW_INT32, FAR *pTW_INT32; +#endif +typedef unsigned char TW_UINT8, FAR *pTW_UINT8; +typedef unsigned short TW_UINT16, FAR *pTW_UINT16; +#if defined(_WIN32) + typedef unsigned long TW_UINT32, FAR *pTW_UINT32; +#else + typedef unsigned int TW_UINT32, FAR *pTW_UINT32; +#endif +typedef unsigned short TW_BOOL, FAR *pTW_BOOL; + + +/**************************************************************************** + * Structure Definitions * + ****************************************************************************/ + +/* Fixed point structure type. */ +typedef struct { + TW_INT16 Whole; + TW_UINT16 Frac; +} TW_FIX32, FAR *pTW_FIX32; + +/* Defines a frame rectangle in ICAP_UNITS coordinates. */ +typedef struct { + TW_FIX32 Left; + TW_FIX32 Top; + TW_FIX32 Right; + TW_FIX32 Bottom; +} TW_FRAME, FAR * pTW_FRAME; + +/* Defines the parameters used for channel-specific transformation. */ +typedef struct { + TW_FIX32 StartIn; + TW_FIX32 BreakIn; + TW_FIX32 EndIn; + TW_FIX32 StartOut; + TW_FIX32 BreakOut; + TW_FIX32 EndOut; + TW_FIX32 Gamma; + TW_FIX32 SampleCount; +} TW_DECODEFUNCTION, FAR * pTW_DECODEFUNCTION; + +/* Stores a Fixed point number in two parts, a whole and a fractional part. */ +typedef struct { + TW_DECODEFUNCTION Decode[3]; + TW_FIX32 Mix[3][3]; +} TW_TRANSFORMSTAGE, FAR * pTW_TRANSFORMSTAGE; + +/* Container for array of values */ +typedef struct { + TW_UINT16 ItemType; + TW_UINT32 NumItems; + TW_UINT8 ItemList[1]; +} TW_ARRAY, FAR * pTW_ARRAY; + +/* Information about audio data */ +typedef struct { + TW_STR255 Name; + TW_UINT32 Reserved; +} TW_AUDIOINFO, FAR * pTW_AUDIOINFO; + +/* Used to register callbacks. */ +typedef struct { + TW_MEMREF CallBackProc; + #if defined(__APPLE__) /* cf: Mac version of TWAIN.h */ + TW_MEMREF RefCon; + #else + TW_UINT32 RefCon; + #endif + TW_INT16 Message; +} TW_CALLBACK, FAR * pTW_CALLBACK; + +/* Used to register callbacks. */ +typedef struct { + TW_MEMREF CallBackProc; + TW_UINTPTR RefCon; + TW_INT16 Message; +} TW_CALLBACK2, FAR * pTW_CALLBACK2; + +/* Used by application to get/set capability from/in a data source. */ +typedef struct { + TW_UINT16 Cap; + TW_UINT16 ConType; + TW_HANDLE hContainer; +} TW_CAPABILITY, FAR * pTW_CAPABILITY; + +/* Defines a CIE XYZ space tri-stimulus value. */ +typedef struct { + TW_FIX32 X; + TW_FIX32 Y; + TW_FIX32 Z; +} TW_CIEPOINT, FAR * pTW_CIEPOINT; + +/* Defines the mapping from an RGB color space device into CIE 1931 (XYZ) color space. */ +typedef struct { + TW_UINT16 ColorSpace; + TW_INT16 LowEndian; + TW_INT16 DeviceDependent; + TW_INT32 VersionNumber; + TW_TRANSFORMSTAGE StageABC; + TW_TRANSFORMSTAGE StageLMN; + TW_CIEPOINT WhitePoint; + TW_CIEPOINT BlackPoint; + TW_CIEPOINT WhitePaper; + TW_CIEPOINT BlackInk; + TW_FIX32 Samples[1]; +} TW_CIECOLOR, FAR * pTW_CIECOLOR; + +/* Allows for a data source and application to pass custom data to each other. */ +typedef struct { + TW_UINT32 InfoLength; + TW_HANDLE hData; +}TW_CUSTOMDSDATA, FAR *pTW_CUSTOMDSDATA; + +/* Provides information about the Event that was raised by the Source */ +typedef struct { + TW_UINT32 Event; + TW_STR255 DeviceName; + TW_UINT32 BatteryMinutes; + TW_INT16 BatteryPercentage; + TW_INT32 PowerSupply; + TW_FIX32 XResolution; + TW_FIX32 YResolution; + TW_UINT32 FlashUsed2; + TW_UINT32 AutomaticCapture; + TW_UINT32 TimeBeforeFirstCapture; + TW_UINT32 TimeBetweenCaptures; +} TW_DEVICEEVENT, FAR * pTW_DEVICEEVENT; + +/* This structure holds the tri-stimulus color palette information for TW_PALETTE8 structures.*/ +typedef struct { + TW_UINT8 Index; + TW_UINT8 Channel1; + TW_UINT8 Channel2; + TW_UINT8 Channel3; +} TW_ELEMENT8, FAR * pTW_ELEMENT8; + +/* Stores a group of individual values describing a capability. */ +typedef struct { + TW_UINT16 ItemType; + TW_UINT32 NumItems; + TW_UINT32 CurrentIndex; + TW_UINT32 DefaultIndex; + TW_UINT8 ItemList[1]; +} TW_ENUMERATION, FAR * pTW_ENUMERATION; + +/* Used to pass application events/messages from the application to the Source. */ +typedef struct { + TW_MEMREF pEvent; + TW_UINT16 TWMessage; +} TW_EVENT, FAR * pTW_EVENT; + +/* This structure is used to pass specific information between the data source and the application. */ +typedef struct { + TW_UINT16 InfoID; + TW_UINT16 ItemType; + TW_UINT16 NumItems; + union { + TW_UINT16 ReturnCode; + TW_UINT16 CondCode; // Deprecated, do not use + }; + TW_UINTPTR Item; +}TW_INFO, FAR* pTW_INFO; + +typedef struct { + TW_UINT32 NumInfos; + TW_INFO Info[1]; +}TW_EXTIMAGEINFO, FAR* pTW_EXTIMAGEINFO; + +/* Provides information about the currently selected device */ +typedef struct { + TW_STR255 InputName; + TW_STR255 OutputName; + TW_MEMREF Context; + union { + int Recursive; + TW_BOOL Subdirectories; + }; + union { + TW_INT32 FileType; + TW_UINT32 FileSystemType; + }; + TW_UINT32 Size; + TW_STR32 CreateTimeDate; + TW_STR32 ModifiedTimeDate; + TW_UINT32 FreeSpace; + TW_INT32 NewImageSize; + TW_UINT32 NumberOfFiles; + TW_UINT32 NumberOfSnippets; + TW_UINT32 DeviceGroupMask; + TW_INT8 Reserved[508]; +} TW_FILESYSTEM, FAR * pTW_FILESYSTEM; + +/* This structure is used by the application to specify a set of mapping values to be applied to grayscale data. */ +typedef struct { + TW_ELEMENT8 Response[1]; +} TW_GRAYRESPONSE, FAR * pTW_GRAYRESPONSE; + +/* A general way to describe the version of software that is running. */ +typedef struct { + TW_UINT16 MajorNum; + TW_UINT16 MinorNum; + TW_UINT16 Language; + TW_UINT16 Country; + TW_STR32 Info; +} TW_VERSION, FAR * pTW_VERSION; + +/* Provides identification information about a TWAIN entity.*/ +typedef struct { + #if defined(__APPLE__) /* cf: Mac version of TWAIN.h */ + TW_MEMREF Id; + #else + TW_UINT32 Id; + #endif + TW_VERSION Version; + TW_UINT16 ProtocolMajor; + TW_UINT16 ProtocolMinor; + TW_UINT32 SupportedGroups; + TW_STR32 Manufacturer; + TW_STR32 ProductFamily; + TW_STR32 ProductName; +} TW_IDENTITY, FAR * pTW_IDENTITY; + +/* Describes the "real" image data, that is, the complete image being transferred between the Source and application. */ +typedef struct { + TW_FIX32 XResolution; + TW_FIX32 YResolution; + TW_INT32 ImageWidth; + TW_INT32 ImageLength; + TW_INT16 SamplesPerPixel; + TW_INT16 BitsPerSample[8]; + TW_INT16 BitsPerPixel; + TW_BOOL Planar; + TW_INT16 PixelType; + TW_UINT16 Compression; +} TW_IMAGEINFO, FAR * pTW_IMAGEINFO; + +/* Involves information about the original size of the acquired image. */ +typedef struct { + TW_FRAME Frame; + TW_UINT32 DocumentNumber; + TW_UINT32 PageNumber; + TW_UINT32 FrameNumber; +} TW_IMAGELAYOUT, FAR * pTW_IMAGELAYOUT; + +/* Provides information for managing memory buffers. */ +typedef struct { + TW_UINT32 Flags; + TW_UINT32 Length; + TW_MEMREF TheMem; +} TW_MEMORY, FAR * pTW_MEMORY; + +/* Describes the form of the acquired data being passed from the Source to the application.*/ +typedef struct { + TW_UINT16 Compression; + TW_UINT32 BytesPerRow; + TW_UINT32 Columns; + TW_UINT32 Rows; + TW_UINT32 XOffset; + TW_UINT32 YOffset; + TW_UINT32 BytesWritten; + TW_MEMORY Memory; +} TW_IMAGEMEMXFER, FAR * pTW_IMAGEMEMXFER; + +/* Describes the information necessary to transfer a JPEG-compressed image. */ +typedef struct { + TW_UINT16 ColorSpace; + TW_UINT32 SubSampling; + TW_UINT16 NumComponents; + TW_UINT16 RestartFrequency; + TW_UINT16 QuantMap[4]; + TW_MEMORY QuantTable[4]; + TW_UINT16 HuffmanMap[4]; + TW_MEMORY HuffmanDC[2]; + TW_MEMORY HuffmanAC[2]; +} TW_JPEGCOMPRESSION, FAR * pTW_JPEGCOMPRESSION; + +/* Collects scanning metrics after returning to state 4 */ +typedef struct { + TW_UINT32 SizeOf; + TW_UINT32 ImageCount; + TW_UINT32 SheetCount; +} TW_METRICS, FAR * pTW_METRICS; + +/* Stores a single value (item) which describes a capability. */ +typedef struct { + TW_UINT16 ItemType; + TW_UINT32 Item; +} TW_ONEVALUE, FAR * pTW_ONEVALUE; + +/* This structure holds the color palette information. */ +typedef struct { + TW_UINT16 NumColors; + TW_UINT16 PaletteType; + TW_ELEMENT8 Colors[256]; +} TW_PALETTE8, FAR * pTW_PALETTE8; + +/* Used to bypass the TWAIN protocol when communicating with a device */ +typedef struct { + TW_MEMREF pCommand; + TW_UINT32 CommandBytes; + TW_INT32 Direction; + TW_MEMREF pData; + TW_UINT32 DataBytes; + TW_UINT32 DataBytesXfered; +} TW_PASSTHRU, FAR * pTW_PASSTHRU; + +/* This structure tells the application how many more complete transfers the Source currently has available. */ +typedef struct { + TW_UINT16 Count; + union { + TW_UINT32 EOJ; + TW_UINT32 Reserved; + #if defined(__APPLE__) /* cf: Mac version of TWAIN.h */ + union { + TW_UINT32 EOJ; + TW_UINT32 Reserved; + } TW_JOBCONTROL; + #endif + }; +} TW_PENDINGXFERS, FAR *pTW_PENDINGXFERS; + +/* Stores a range of individual values describing a capability. */ +typedef struct { + TW_UINT16 ItemType; + TW_UINT32 MinValue; + TW_UINT32 MaxValue; + TW_UINT32 StepSize; + TW_UINT32 DefaultValue; + TW_UINT32 CurrentValue; +} TW_RANGE, FAR * pTW_RANGE; + +/* This structure is used by the application to specify a set of mapping values to be applied to RGB color data. */ +typedef struct { + TW_ELEMENT8 Response[1]; +} TW_RGBRESPONSE, FAR * pTW_RGBRESPONSE; + +/* Describes the file format and file specification information for a transfer through a disk file. */ +typedef struct { + TW_STR255 FileName; + TW_UINT16 Format; + TW_INT16 VRefNum; +} TW_SETUPFILEXFER, FAR * pTW_SETUPFILEXFER; + +/* Provides the application information about the Source's requirements and preferences regarding allocation of transfer buffer(s). */ +typedef struct { + TW_UINT32 MinBufSize; + TW_UINT32 MaxBufSize; + TW_UINT32 Preferred; +} TW_SETUPMEMXFER, FAR * pTW_SETUPMEMXFER; + +/* Describes the status of a source. */ +typedef struct { + TW_UINT16 ConditionCode; + union { + TW_UINT16 Data; + TW_UINT16 Reserved; + }; +} TW_STATUS, FAR * pTW_STATUS; + +/* Translates the contents of Status into a localized UTF8string. */ +typedef struct { + TW_STATUS Status; + TW_UINT32 Size; + TW_HANDLE UTF8string; +} TW_STATUSUTF8, FAR * pTW_STATUSUTF8; + +typedef struct { + TW_UINT32 SizeOf; + TW_UINT16 CommunicationManager; + TW_HANDLE Send; + TW_UINT32 SendSize; + TW_HANDLE Receive; + TW_UINT32 ReceiveSize; +} TW_TWAINDIRECT, FAR * pTW_TWAINDIRECT; + +/* This structure is used to handle the user interface coordination between an application and a Source. */ +typedef struct { + TW_BOOL ShowUI; + TW_BOOL ModalUI; + TW_HANDLE hParent; +} TW_USERINTERFACE, FAR * pTW_USERINTERFACE; + + +/**************************************************************************** + * Generic Constants * + ****************************************************************************/ + +#define TWON_ARRAY 3 +#define TWON_ENUMERATION 4 +#define TWON_ONEVALUE 5 +#define TWON_RANGE 6 + +#define TWON_ICONID 962 +#define TWON_DSMID 461 +#define TWON_DSMCODEID 63 + +#define TWON_DONTCARE8 0xff +#define TWON_DONTCARE16 0xffff +#define TWON_DONTCARE32 0xffffffff + +/* Flags used in TW_MEMORY structure. */ +#define TWMF_APPOWNS 0x0001 +#define TWMF_DSMOWNS 0x0002 +#define TWMF_DSOWNS 0x0004 +#define TWMF_POINTER 0x0008 +#define TWMF_HANDLE 0x0010 + +#define TWTY_INT8 0x0000 +#define TWTY_INT16 0x0001 +#define TWTY_INT32 0x0002 + +#define TWTY_UINT8 0x0003 +#define TWTY_UINT16 0x0004 +#define TWTY_UINT32 0x0005 + +#define TWTY_BOOL 0x0006 + +#define TWTY_FIX32 0x0007 + +#define TWTY_FRAME 0x0008 + +#define TWTY_STR32 0x0009 +#define TWTY_STR64 0x000a +#define TWTY_STR128 0x000b +#define TWTY_STR255 0x000c +#define TWTY_HANDLE 0x000f + + +/**************************************************************************** + * Capability Constants * + ****************************************************************************/ + +/* CAP_ALARMS values */ +#define TWAL_ALARM 0 +#define TWAL_FEEDERERROR 1 +#define TWAL_FEEDERWARNING 2 +#define TWAL_BARCODE 3 +#define TWAL_DOUBLEFEED 4 +#define TWAL_JAM 5 +#define TWAL_PATCHCODE 6 +#define TWAL_POWER 7 +#define TWAL_SKEW 8 + +/* ICAP_AUTOSIZE values */ +#define TWAS_NONE 0 +#define TWAS_AUTO 1 +#define TWAS_CURRENT 2 + +/* TWEI_BARCODEROTATION values */ +#define TWBCOR_ROT0 0 +#define TWBCOR_ROT90 1 +#define TWBCOR_ROT180 2 +#define TWBCOR_ROT270 3 +#define TWBCOR_ROTX 4 + +/* ICAP_BARCODESEARCHMODE values */ +#define TWBD_HORZ 0 +#define TWBD_VERT 1 +#define TWBD_HORZVERT 2 +#define TWBD_VERTHORZ 3 + +/* ICAP_BITORDER values */ +#define TWBO_LSBFIRST 0 +#define TWBO_MSBFIRST 1 + +/* ICAP_AUTODISCARDBLANKPAGES values */ +#define TWBP_DISABLE -2 +#define TWBP_AUTO -1 + +/* ICAP_BITDEPTHREDUCTION values */ +#define TWBR_THRESHOLD 0 +#define TWBR_HALFTONE 1 +#define TWBR_CUSTHALFTONE 2 +#define TWBR_DIFFUSION 3 +#define TWBR_DYNAMICTHRESHOLD 4 + +/* ICAP_SUPPORTEDBARCODETYPES and TWEI_BARCODETYPE values*/ +#define TWBT_3OF9 0 +#define TWBT_2OF5INTERLEAVED 1 +#define TWBT_2OF5NONINTERLEAVED 2 +#define TWBT_CODE93 3 +#define TWBT_CODE128 4 +#define TWBT_UCC128 5 +#define TWBT_CODABAR 6 +#define TWBT_UPCA 7 +#define TWBT_UPCE 8 +#define TWBT_EAN8 9 +#define TWBT_EAN13 10 +#define TWBT_POSTNET 11 +#define TWBT_PDF417 12 +#define TWBT_2OF5INDUSTRIAL 13 +#define TWBT_2OF5MATRIX 14 +#define TWBT_2OF5DATALOGIC 15 +#define TWBT_2OF5IATA 16 +#define TWBT_3OF9FULLASCII 17 +#define TWBT_CODABARWITHSTARTSTOP 18 +#define TWBT_MAXICODE 19 +#define TWBT_QRCODE 20 + +/* ICAP_COMPRESSION values*/ +#define TWCP_NONE 0 +#define TWCP_PACKBITS 1 +#define TWCP_GROUP31D 2 +#define TWCP_GROUP31DEOL 3 +#define TWCP_GROUP32D 4 +#define TWCP_GROUP4 5 +#define TWCP_JPEG 6 +#define TWCP_LZW 7 +#define TWCP_JBIG 8 +#define TWCP_PNG 9 +#define TWCP_RLE4 10 +#define TWCP_RLE8 11 +#define TWCP_BITFIELDS 12 +#define TWCP_ZIP 13 +#define TWCP_JPEG2000 14 + +/* CAP_CAMERASIDE and TWEI_PAGESIDE values */ +#define TWCS_BOTH 0 +#define TWCS_TOP 1 +#define TWCS_BOTTOM 2 + +/* CAP_DEVICEEVENT values */ +#define TWDE_CUSTOMEVENTS 0x8000 +#define TWDE_CHECKAUTOMATICCAPTURE 0 +#define TWDE_CHECKBATTERY 1 +#define TWDE_CHECKDEVICEONLINE 2 +#define TWDE_CHECKFLASH 3 +#define TWDE_CHECKPOWERSUPPLY 4 +#define TWDE_CHECKRESOLUTION 5 +#define TWDE_DEVICEADDED 6 +#define TWDE_DEVICEOFFLINE 7 +#define TWDE_DEVICEREADY 8 +#define TWDE_DEVICEREMOVED 9 +#define TWDE_IMAGECAPTURED 10 +#define TWDE_IMAGEDELETED 11 +#define TWDE_PAPERDOUBLEFEED 12 +#define TWDE_PAPERJAM 13 +#define TWDE_LAMPFAILURE 14 +#define TWDE_POWERSAVE 15 +#define TWDE_POWERSAVENOTIFY 16 + +/* TW_PASSTHRU.Direction values. */ +#define TWDR_GET 1 +#define TWDR_SET 2 + +/* TWEI_DESKEWSTATUS values. */ +#define TWDSK_SUCCESS 0 +#define TWDSK_REPORTONLY 1 +#define TWDSK_FAIL 2 +#define TWDSK_DISABLED 3 + +/* CAP_DUPLEX values */ +#define TWDX_NONE 0 +#define TWDX_1PASSDUPLEX 1 +#define TWDX_2PASSDUPLEX 2 + +/* CAP_FEEDERALIGNMENT values */ +#define TWFA_NONE 0 +#define TWFA_LEFT 1 +#define TWFA_CENTER 2 +#define TWFA_RIGHT 3 + +/* ICAP_FEEDERTYPE values*/ +#define TWFE_GENERAL 0 +#define TWFE_PHOTO 1 + +/* ICAP_IMAGEFILEFORMAT values */ +#define TWFF_TIFF 0 +#define TWFF_PICT 1 +#define TWFF_BMP 2 +#define TWFF_XBM 3 +#define TWFF_JFIF 4 +#define TWFF_FPX 5 +#define TWFF_TIFFMULTI 6 +#define TWFF_PNG 7 +#define TWFF_SPIFF 8 +#define TWFF_EXIF 9 +#define TWFF_PDF 10 +#define TWFF_JP2 11 +#define TWFF_JPX 13 +#define TWFF_DEJAVU 14 +#define TWFF_PDFA 15 +#define TWFF_PDFA2 16 +#define TWFF_PDFRASTER 17 + +/* ICAP_FLASHUSED2 values */ +#define TWFL_NONE 0 +#define TWFL_OFF 1 +#define TWFL_ON 2 +#define TWFL_AUTO 3 +#define TWFL_REDEYE 4 + +/* CAP_FEEDERORDER values */ +#define TWFO_FIRSTPAGEFIRST 0 +#define TWFO_LASTPAGEFIRST 1 + +/* CAP_FEEDERPOCKET values*/ +#define TWFP_POCKETERROR 0 +#define TWFP_POCKET1 1 +#define TWFP_POCKET2 2 +#define TWFP_POCKET3 3 +#define TWFP_POCKET4 4 +#define TWFP_POCKET5 5 +#define TWFP_POCKET6 6 +#define TWFP_POCKET7 7 +#define TWFP_POCKET8 8 +#define TWFP_POCKET9 9 +#define TWFP_POCKET10 10 +#define TWFP_POCKET11 11 +#define TWFP_POCKET12 12 +#define TWFP_POCKET13 13 +#define TWFP_POCKET14 14 +#define TWFP_POCKET15 15 +#define TWFP_POCKET16 16 + +/* ICAP_FLIPROTATION values */ +#define TWFR_BOOK 0 +#define TWFR_FANFOLD 1 + +/* ICAP_FILTER values */ +#define TWFT_RED 0 +#define TWFT_GREEN 1 +#define TWFT_BLUE 2 +#define TWFT_NONE 3 +#define TWFT_WHITE 4 +#define TWFT_CYAN 5 +#define TWFT_MAGENTA 6 +#define TWFT_YELLOW 7 +#define TWFT_BLACK 8 + +/* TW_FILESYSTEM.FileType values */ +#define TWFY_CAMERA 0 +#define TWFY_CAMERATOP 1 +#define TWFY_CAMERABOTTOM 2 +#define TWFY_CAMERAPREVIEW 3 +#define TWFY_DOMAIN 4 +#define TWFY_HOST 5 +#define TWFY_DIRECTORY 6 +#define TWFY_IMAGE 7 +#define TWFY_UNKNOWN 8 + +/* ICAP_ICCPROFILE values */ +#define TWIC_NONE 0 +#define TWIC_LINK 1 +#define TWIC_EMBED 2 + +/* ICAP_IMAGEFILTER values */ +#define TWIF_NONE 0 +#define TWIF_AUTO 1 +#define TWIF_LOWPASS 2 +#define TWIF_BANDPASS 3 +#define TWIF_HIGHPASS 4 +#define TWIF_TEXT TWIF_BANDPASS +#define TWIF_FINELINE TWIF_HIGHPASS + +/* ICAP_IMAGEMERGE values */ +#define TWIM_NONE 0 +#define TWIM_FRONTONTOP 1 +#define TWIM_FRONTONBOTTOM 2 +#define TWIM_FRONTONLEFT 3 +#define TWIM_FRONTONRIGHT 4 + +/* CAP_JOBCONTROL values */ +#define TWJC_NONE 0 +#define TWJC_JSIC 1 +#define TWJC_JSIS 2 +#define TWJC_JSXC 3 +#define TWJC_JSXS 4 + +/* ICAP_JPEGQUALITY values */ +#define TWJQ_UNKNOWN -4 +#define TWJQ_LOW -3 +#define TWJQ_MEDIUM -2 +#define TWJQ_HIGH -1 + +/* ICAP_LIGHTPATH values */ +#define TWLP_REFLECTIVE 0 +#define TWLP_TRANSMISSIVE 1 + +/* ICAP_LIGHTSOURCE values */ +#define TWLS_RED 0 +#define TWLS_GREEN 1 +#define TWLS_BLUE 2 +#define TWLS_NONE 3 +#define TWLS_WHITE 4 +#define TWLS_UV 5 +#define TWLS_IR 6 + +/* TWEI_MAGTYPE values */ +#define TWMD_MICR 0 +#define TWMD_RAW 1 +#define TWMD_INVALID 2 + +/* ICAP_NOISEFILTER values */ +#define TWNF_NONE 0 +#define TWNF_AUTO 1 +#define TWNF_LONEPIXEL 2 +#define TWNF_MAJORITYRULE 3 + +/* ICAP_ORIENTATION values */ +#define TWOR_ROT0 0 +#define TWOR_ROT90 1 +#define TWOR_ROT180 2 +#define TWOR_ROT270 3 +#define TWOR_PORTRAIT TWOR_ROT0 +#define TWOR_LANDSCAPE TWOR_ROT270 +#define TWOR_AUTO 4 +#define TWOR_AUTOTEXT 5 +#define TWOR_AUTOPICTURE 6 + +/* ICAP_OVERSCAN values */ +#define TWOV_NONE 0 +#define TWOV_AUTO 1 +#define TWOV_TOPBOTTOM 2 +#define TWOV_LEFTRIGHT 3 +#define TWOV_ALL 4 + +/* Palette types for TW_PALETTE8 */ +#define TWPA_RGB 0 +#define TWPA_GRAY 1 +#define TWPA_CMY 2 + +/* ICAP_PLANARCHUNKY values */ +#define TWPC_CHUNKY 0 +#define TWPC_PLANAR 1 + +/* TWEI_PATCHCODE values*/ +#define TWPCH_PATCH1 0 +#define TWPCH_PATCH2 1 +#define TWPCH_PATCH3 2 +#define TWPCH_PATCH4 3 +#define TWPCH_PATCH6 4 +#define TWPCH_PATCHT 5 + +/* ICAP_PIXELFLAVOR values */ +#define TWPF_CHOCOLATE 0 +#define TWPF_VANILLA 1 + +/* CAP_PRINTERMODE values */ +#define TWPM_SINGLESTRING 0 +#define TWPM_MULTISTRING 1 +#define TWPM_COMPOUNDSTRING 2 + +/* CAP_PRINTER values */ +#define TWPR_IMPRINTERTOPBEFORE 0 +#define TWPR_IMPRINTERTOPAFTER 1 +#define TWPR_IMPRINTERBOTTOMBEFORE 2 +#define TWPR_IMPRINTERBOTTOMAFTER 3 +#define TWPR_ENDORSERTOPBEFORE 4 +#define TWPR_ENDORSERTOPAFTER 5 +#define TWPR_ENDORSERBOTTOMBEFORE 6 +#define TWPR_ENDORSERBOTTOMAFTER 7 + +/* CAP_PRINTERFONTSTYLE Added 2.3 */ +#define TWPF_NORMAL 0 +#define TWPF_BOLD 1 +#define TWPF_ITALIC 2 +#define TWPF_LARGESIZE 3 +#define TWPF_SMALLSIZE 4 + +/* CAP_PRINTERINDEXTRIGGER Added 2.3 */ +#define TWCT_PAGE 0 +#define TWCT_PATCH1 1 +#define TWCT_PATCH2 2 +#define TWCT_PATCH3 3 +#define TWCT_PATCH4 4 +#define TWCT_PATCHT 5 +#define TWCT_PATCH6 6 + +/* CAP_POWERSUPPLY values */ +#define TWPS_EXTERNAL 0 +#define TWPS_BATTERY 1 + +/* ICAP_PIXELTYPE values (PT_ means Pixel Type) */ +#define TWPT_BW 0 +#define TWPT_GRAY 1 +#define TWPT_RGB 2 +#define TWPT_PALETTE 3 +#define TWPT_CMY 4 +#define TWPT_CMYK 5 +#define TWPT_YUV 6 +#define TWPT_YUVK 7 +#define TWPT_CIEXYZ 8 +#define TWPT_LAB 9 +#define TWPT_SRGB 10 +#define TWPT_SCRGB 11 +#define TWPT_INFRARED 16 + +/* CAP_SEGMENTED values */ +#define TWSG_NONE 0 +#define TWSG_AUTO 1 +#define TWSG_MANUAL 2 + +/* ICAP_FILMTYPE values */ +#define TWFM_POSITIVE 0 +#define TWFM_NEGATIVE 1 + +/* CAP_DOUBLEFEEDDETECTION */ +#define TWDF_ULTRASONIC 0 +#define TWDF_BYLENGTH 1 +#define TWDF_INFRARED 2 + +/* CAP_DOUBLEFEEDDETECTIONSENSITIVITY */ +#define TWUS_LOW 0 +#define TWUS_MEDIUM 1 +#define TWUS_HIGH 2 + +/* CAP_DOUBLEFEEDDETECTIONRESPONSE */ +#define TWDP_STOP 0 +#define TWDP_STOPANDWAIT 1 +#define TWDP_SOUND 2 +#define TWDP_DONOTIMPRINT 3 + +/* ICAP_MIRROR values */ +#define TWMR_NONE 0 +#define TWMR_VERTICAL 1 +#define TWMR_HORIZONTAL 2 + +/* ICAP_JPEGSUBSAMPLING values */ +#define TWJS_444YCBCR 0 +#define TWJS_444RGB 1 +#define TWJS_422 2 +#define TWJS_421 3 +#define TWJS_411 4 +#define TWJS_420 5 +#define TWJS_410 6 +#define TWJS_311 7 + +/* CAP_PAPERHANDLING values */ +#define TWPH_NORMAL 0 +#define TWPH_FRAGILE 1 +#define TWPH_THICK 2 +#define TWPH_TRIFOLD 3 +#define TWPH_PHOTOGRAPH 4 + +/* CAP_INDICATORSMODE values */ +#define TWCI_INFO 0 +#define TWCI_WARNING 1 +#define TWCI_ERROR 2 +#define TWCI_WARMUP 3 + +/* ICAP_SUPPORTEDSIZES values (SS_ means Supported Sizes) */ +#define TWSS_NONE 0 +#define TWSS_A4 1 +#define TWSS_JISB5 2 +#define TWSS_USLETTER 3 +#define TWSS_USLEGAL 4 +#define TWSS_A5 5 +#define TWSS_ISOB4 6 +#define TWSS_ISOB6 7 +#define TWSS_USLEDGER 9 +#define TWSS_USEXECUTIVE 10 +#define TWSS_A3 11 +#define TWSS_ISOB3 12 +#define TWSS_A6 13 +#define TWSS_C4 14 +#define TWSS_C5 15 +#define TWSS_C6 16 +#define TWSS_4A0 17 +#define TWSS_2A0 18 +#define TWSS_A0 19 +#define TWSS_A1 20 +#define TWSS_A2 21 +#define TWSS_A7 22 +#define TWSS_A8 23 +#define TWSS_A9 24 +#define TWSS_A10 25 +#define TWSS_ISOB0 26 +#define TWSS_ISOB1 27 +#define TWSS_ISOB2 28 +#define TWSS_ISOB5 29 +#define TWSS_ISOB7 30 +#define TWSS_ISOB8 31 +#define TWSS_ISOB9 32 +#define TWSS_ISOB10 33 +#define TWSS_JISB0 34 +#define TWSS_JISB1 35 +#define TWSS_JISB2 36 +#define TWSS_JISB3 37 +#define TWSS_JISB4 38 +#define TWSS_JISB6 39 +#define TWSS_JISB7 40 +#define TWSS_JISB8 41 +#define TWSS_JISB9 42 +#define TWSS_JISB10 43 +#define TWSS_C0 44 +#define TWSS_C1 45 +#define TWSS_C2 46 +#define TWSS_C3 47 +#define TWSS_C7 48 +#define TWSS_C8 49 +#define TWSS_C9 50 +#define TWSS_C10 51 +#define TWSS_USSTATEMENT 52 +#define TWSS_BUSINESSCARD 53 +#define TWSS_MAXSIZE 54 + +/* ICAP_XFERMECH values (SX_ means Setup XFer) */ +#define TWSX_NATIVE 0 +#define TWSX_FILE 1 +#define TWSX_MEMORY 2 +#define TWSX_MEMFILE 4 + +/* ICAP_UNITS values (UN_ means UNits) */ +#define TWUN_INCHES 0 +#define TWUN_CENTIMETERS 1 +#define TWUN_PICAS 2 +#define TWUN_POINTS 3 +#define TWUN_TWIPS 4 +#define TWUN_PIXELS 5 +#define TWUN_MILLIMETERS 6 + + +/**************************************************************************** + * Country Constants * + ****************************************************************************/ + +#define TWCY_AFGHANISTAN 1001 +#define TWCY_ALGERIA 213 +#define TWCY_AMERICANSAMOA 684 +#define TWCY_ANDORRA 33 +#define TWCY_ANGOLA 1002 +#define TWCY_ANGUILLA 8090 +#define TWCY_ANTIGUA 8091 +#define TWCY_ARGENTINA 54 +#define TWCY_ARUBA 297 +#define TWCY_ASCENSIONI 247 +#define TWCY_AUSTRALIA 61 +#define TWCY_AUSTRIA 43 +#define TWCY_BAHAMAS 8092 +#define TWCY_BAHRAIN 973 +#define TWCY_BANGLADESH 880 +#define TWCY_BARBADOS 8093 +#define TWCY_BELGIUM 32 +#define TWCY_BELIZE 501 +#define TWCY_BENIN 229 +#define TWCY_BERMUDA 8094 +#define TWCY_BHUTAN 1003 +#define TWCY_BOLIVIA 591 +#define TWCY_BOTSWANA 267 +#define TWCY_BRITAIN 6 +#define TWCY_BRITVIRGINIS 8095 +#define TWCY_BRAZIL 55 +#define TWCY_BRUNEI 673 +#define TWCY_BULGARIA 359 +#define TWCY_BURKINAFASO 1004 +#define TWCY_BURMA 1005 +#define TWCY_BURUNDI 1006 +#define TWCY_CAMAROON 237 +#define TWCY_CANADA 2 +#define TWCY_CAPEVERDEIS 238 +#define TWCY_CAYMANIS 8096 +#define TWCY_CENTRALAFREP 1007 +#define TWCY_CHAD 1008 +#define TWCY_CHILE 56 +#define TWCY_CHINA 86 +#define TWCY_CHRISTMASIS 1009 +#define TWCY_COCOSIS 1009 +#define TWCY_COLOMBIA 57 +#define TWCY_COMOROS 1010 +#define TWCY_CONGO 1011 +#define TWCY_COOKIS 1012 +#define TWCY_COSTARICA 506 +#define TWCY_CUBA 5 +#define TWCY_CYPRUS 357 +#define TWCY_CZECHOSLOVAKIA 42 +#define TWCY_DENMARK 45 +#define TWCY_DJIBOUTI 1013 +#define TWCY_DOMINICA 8097 +#define TWCY_DOMINCANREP 8098 +#define TWCY_EASTERIS 1014 +#define TWCY_ECUADOR 593 +#define TWCY_EGYPT 20 +#define TWCY_ELSALVADOR 503 +#define TWCY_EQGUINEA 1015 +#define TWCY_ETHIOPIA 251 +#define TWCY_FALKLANDIS 1016 +#define TWCY_FAEROEIS 298 +#define TWCY_FIJIISLANDS 679 +#define TWCY_FINLAND 358 +#define TWCY_FRANCE 33 +#define TWCY_FRANTILLES 596 +#define TWCY_FRGUIANA 594 +#define TWCY_FRPOLYNEISA 689 +#define TWCY_FUTANAIS 1043 +#define TWCY_GABON 241 +#define TWCY_GAMBIA 220 +#define TWCY_GERMANY 49 +#define TWCY_GHANA 233 +#define TWCY_GIBRALTER 350 +#define TWCY_GREECE 30 +#define TWCY_GREENLAND 299 +#define TWCY_GRENADA 8099 +#define TWCY_GRENEDINES 8015 +#define TWCY_GUADELOUPE 590 +#define TWCY_GUAM 671 +#define TWCY_GUANTANAMOBAY 5399 +#define TWCY_GUATEMALA 502 +#define TWCY_GUINEA 224 +#define TWCY_GUINEABISSAU 1017 +#define TWCY_GUYANA 592 +#define TWCY_HAITI 509 +#define TWCY_HONDURAS 504 +#define TWCY_HONGKONG 852 +#define TWCY_HUNGARY 36 +#define TWCY_ICELAND 354 +#define TWCY_INDIA 91 +#define TWCY_INDONESIA 62 +#define TWCY_IRAN 98 +#define TWCY_IRAQ 964 +#define TWCY_IRELAND 353 +#define TWCY_ISRAEL 972 +#define TWCY_ITALY 39 +#define TWCY_IVORYCOAST 225 +#define TWCY_JAMAICA 8010 +#define TWCY_JAPAN 81 +#define TWCY_JORDAN 962 +#define TWCY_KENYA 254 +#define TWCY_KIRIBATI 1018 +#define TWCY_KOREA 82 +#define TWCY_KUWAIT 965 +#define TWCY_LAOS 1019 +#define TWCY_LEBANON 1020 +#define TWCY_LIBERIA 231 +#define TWCY_LIBYA 218 +#define TWCY_LIECHTENSTEIN 41 +#define TWCY_LUXENBOURG 352 +#define TWCY_MACAO 853 +#define TWCY_MADAGASCAR 1021 +#define TWCY_MALAWI 265 +#define TWCY_MALAYSIA 60 +#define TWCY_MALDIVES 960 +#define TWCY_MALI 1022 +#define TWCY_MALTA 356 +#define TWCY_MARSHALLIS 692 +#define TWCY_MAURITANIA 1023 +#define TWCY_MAURITIUS 230 +#define TWCY_MEXICO 3 +#define TWCY_MICRONESIA 691 +#define TWCY_MIQUELON 508 +#define TWCY_MONACO 33 +#define TWCY_MONGOLIA 1024 +#define TWCY_MONTSERRAT 8011 +#define TWCY_MOROCCO 212 +#define TWCY_MOZAMBIQUE 1025 +#define TWCY_NAMIBIA 264 +#define TWCY_NAURU 1026 +#define TWCY_NEPAL 977 +#define TWCY_NETHERLANDS 31 +#define TWCY_NETHANTILLES 599 +#define TWCY_NEVIS 8012 +#define TWCY_NEWCALEDONIA 687 +#define TWCY_NEWZEALAND 64 +#define TWCY_NICARAGUA 505 +#define TWCY_NIGER 227 +#define TWCY_NIGERIA 234 +#define TWCY_NIUE 1027 +#define TWCY_NORFOLKI 1028 +#define TWCY_NORWAY 47 +#define TWCY_OMAN 968 +#define TWCY_PAKISTAN 92 +#define TWCY_PALAU 1029 +#define TWCY_PANAMA 507 +#define TWCY_PARAGUAY 595 +#define TWCY_PERU 51 +#define TWCY_PHILLIPPINES 63 +#define TWCY_PITCAIRNIS 1030 +#define TWCY_PNEWGUINEA 675 +#define TWCY_POLAND 48 +#define TWCY_PORTUGAL 351 +#define TWCY_QATAR 974 +#define TWCY_REUNIONI 1031 +#define TWCY_ROMANIA 40 +#define TWCY_RWANDA 250 +#define TWCY_SAIPAN 670 +#define TWCY_SANMARINO 39 +#define TWCY_SAOTOME 1033 +#define TWCY_SAUDIARABIA 966 +#define TWCY_SENEGAL 221 +#define TWCY_SEYCHELLESIS 1034 +#define TWCY_SIERRALEONE 1035 +#define TWCY_SINGAPORE 65 +#define TWCY_SOLOMONIS 1036 +#define TWCY_SOMALI 1037 +#define TWCY_SOUTHAFRICA 27 +#define TWCY_SPAIN 34 +#define TWCY_SRILANKA 94 +#define TWCY_STHELENA 1032 +#define TWCY_STKITTS 8013 +#define TWCY_STLUCIA 8014 +#define TWCY_STPIERRE 508 +#define TWCY_STVINCENT 8015 +#define TWCY_SUDAN 1038 +#define TWCY_SURINAME 597 +#define TWCY_SWAZILAND 268 +#define TWCY_SWEDEN 46 +#define TWCY_SWITZERLAND 41 +#define TWCY_SYRIA 1039 +#define TWCY_TAIWAN 886 +#define TWCY_TANZANIA 255 +#define TWCY_THAILAND 66 +#define TWCY_TOBAGO 8016 +#define TWCY_TOGO 228 +#define TWCY_TONGAIS 676 +#define TWCY_TRINIDAD 8016 +#define TWCY_TUNISIA 216 +#define TWCY_TURKEY 90 +#define TWCY_TURKSCAICOS 8017 +#define TWCY_TUVALU 1040 +#define TWCY_UGANDA 256 +#define TWCY_USSR 7 +#define TWCY_UAEMIRATES 971 +#define TWCY_UNITEDKINGDOM 44 +#define TWCY_USA 1 +#define TWCY_URUGUAY 598 +#define TWCY_VANUATU 1041 +#define TWCY_VATICANCITY 39 +#define TWCY_VENEZUELA 58 +#define TWCY_WAKE 1042 +#define TWCY_WALLISIS 1043 +#define TWCY_WESTERNSAHARA 1044 +#define TWCY_WESTERNSAMOA 1045 +#define TWCY_YEMEN 1046 +#define TWCY_YUGOSLAVIA 38 +#define TWCY_ZAIRE 243 +#define TWCY_ZAMBIA 260 +#define TWCY_ZIMBABWE 263 +#define TWCY_ALBANIA 355 +#define TWCY_ARMENIA 374 +#define TWCY_AZERBAIJAN 994 +#define TWCY_BELARUS 375 +#define TWCY_BOSNIAHERZGO 387 +#define TWCY_CAMBODIA 855 +#define TWCY_CROATIA 385 +#define TWCY_CZECHREPUBLIC 420 +#define TWCY_DIEGOGARCIA 246 +#define TWCY_ERITREA 291 +#define TWCY_ESTONIA 372 +#define TWCY_GEORGIA 995 +#define TWCY_LATVIA 371 +#define TWCY_LESOTHO 266 +#define TWCY_LITHUANIA 370 +#define TWCY_MACEDONIA 389 +#define TWCY_MAYOTTEIS 269 +#define TWCY_MOLDOVA 373 +#define TWCY_MYANMAR 95 +#define TWCY_NORTHKOREA 850 +#define TWCY_PUERTORICO 787 +#define TWCY_RUSSIA 7 +#define TWCY_SERBIA 381 +#define TWCY_SLOVAKIA 421 +#define TWCY_SLOVENIA 386 +#define TWCY_SOUTHKOREA 82 +#define TWCY_UKRAINE 380 +#define TWCY_USVIRGINIS 340 +#define TWCY_VIETNAM 84 + +/**************************************************************************** + * Language Constants * + ****************************************************************************/ +#define TWLG_USERLOCALE -1 +#define TWLG_DAN 0 +#define TWLG_DUT 1 +#define TWLG_ENG 2 +#define TWLG_FCF 3 +#define TWLG_FIN 4 +#define TWLG_FRN 5 +#define TWLG_GER 6 +#define TWLG_ICE 7 +#define TWLG_ITN 8 +#define TWLG_NOR 9 +#define TWLG_POR 10 +#define TWLG_SPA 11 +#define TWLG_SWE 12 +#define TWLG_USA 13 +#define TWLG_AFRIKAANS 14 +#define TWLG_ALBANIA 15 +#define TWLG_ARABIC 16 +#define TWLG_ARABIC_ALGERIA 17 +#define TWLG_ARABIC_BAHRAIN 18 +#define TWLG_ARABIC_EGYPT 19 +#define TWLG_ARABIC_IRAQ 20 +#define TWLG_ARABIC_JORDAN 21 +#define TWLG_ARABIC_KUWAIT 22 +#define TWLG_ARABIC_LEBANON 23 +#define TWLG_ARABIC_LIBYA 24 +#define TWLG_ARABIC_MOROCCO 25 +#define TWLG_ARABIC_OMAN 26 +#define TWLG_ARABIC_QATAR 27 +#define TWLG_ARABIC_SAUDIARABIA 28 +#define TWLG_ARABIC_SYRIA 29 +#define TWLG_ARABIC_TUNISIA 30 +#define TWLG_ARABIC_UAE 31 +#define TWLG_ARABIC_YEMEN 32 +#define TWLG_BASQUE 33 +#define TWLG_BYELORUSSIAN 34 +#define TWLG_BULGARIAN 35 +#define TWLG_CATALAN 36 +#define TWLG_CHINESE 37 +#define TWLG_CHINESE_HONGKONG 38 +#define TWLG_CHINESE_PRC 39 +#define TWLG_CHINESE_SINGAPORE 40 +#define TWLG_CHINESE_SIMPLIFIED 41 +#define TWLG_CHINESE_TAIWAN 42 +#define TWLG_CHINESE_TRADITIONAL 43 +#define TWLG_CROATIA 44 +#define TWLG_CZECH 45 +#define TWLG_DANISH TWLG_DAN +#define TWLG_DUTCH TWLG_DUT +#define TWLG_DUTCH_BELGIAN 46 +#define TWLG_ENGLISH TWLG_ENG +#define TWLG_ENGLISH_AUSTRALIAN 47 +#define TWLG_ENGLISH_CANADIAN 48 +#define TWLG_ENGLISH_IRELAND 49 +#define TWLG_ENGLISH_NEWZEALAND 50 +#define TWLG_ENGLISH_SOUTHAFRICA 51 +#define TWLG_ENGLISH_UK 52 +#define TWLG_ENGLISH_USA TWLG_USA +#define TWLG_ESTONIAN 53 +#define TWLG_FAEROESE 54 +#define TWLG_FARSI 55 +#define TWLG_FINNISH TWLG_FIN +#define TWLG_FRENCH TWLG_FRN +#define TWLG_FRENCH_BELGIAN 56 +#define TWLG_FRENCH_CANADIAN TWLG_FCF +#define TWLG_FRENCH_LUXEMBOURG 57 +#define TWLG_FRENCH_SWISS 58 +#define TWLG_GERMAN TWLG_GER +#define TWLG_GERMAN_AUSTRIAN 59 +#define TWLG_GERMAN_LUXEMBOURG 60 +#define TWLG_GERMAN_LIECHTENSTEIN 61 +#define TWLG_GERMAN_SWISS 62 +#define TWLG_GREEK 63 +#define TWLG_HEBREW 64 +#define TWLG_HUNGARIAN 65 +#define TWLG_ICELANDIC TWLG_ICE +#define TWLG_INDONESIAN 66 +#define TWLG_ITALIAN TWLG_ITN +#define TWLG_ITALIAN_SWISS 67 +#define TWLG_JAPANESE 68 +#define TWLG_KOREAN 69 +#define TWLG_KOREAN_JOHAB 70 +#define TWLG_LATVIAN 71 +#define TWLG_LITHUANIAN 72 +#define TWLG_NORWEGIAN TWLG_NOR +#define TWLG_NORWEGIAN_BOKMAL 73 +#define TWLG_NORWEGIAN_NYNORSK 74 +#define TWLG_POLISH 75 +#define TWLG_PORTUGUESE TWLG_POR +#define TWLG_PORTUGUESE_BRAZIL 76 +#define TWLG_ROMANIAN 77 +#define TWLG_RUSSIAN 78 +#define TWLG_SERBIAN_LATIN 79 +#define TWLG_SLOVAK 80 +#define TWLG_SLOVENIAN 81 +#define TWLG_SPANISH TWLG_SPA +#define TWLG_SPANISH_MEXICAN 82 +#define TWLG_SPANISH_MODERN 83 +#define TWLG_SWEDISH TWLG_SWE +#define TWLG_THAI 84 +#define TWLG_TURKISH 85 +#define TWLG_UKRANIAN 86 +#define TWLG_ASSAMESE 87 +#define TWLG_BENGALI 88 +#define TWLG_BIHARI 89 +#define TWLG_BODO 90 +#define TWLG_DOGRI 91 +#define TWLG_GUJARATI 92 +#define TWLG_HARYANVI 93 +#define TWLG_HINDI 94 +#define TWLG_KANNADA 95 +#define TWLG_KASHMIRI 96 +#define TWLG_MALAYALAM 97 +#define TWLG_MARATHI 98 +#define TWLG_MARWARI 99 +#define TWLG_MEGHALAYAN 100 +#define TWLG_MIZO 101 +#define TWLG_NAGA 102 +#define TWLG_ORISSI 103 +#define TWLG_PUNJABI 104 +#define TWLG_PUSHTU 105 +#define TWLG_SERBIAN_CYRILLIC 106 +#define TWLG_SIKKIMI 107 +#define TWLG_SWEDISH_FINLAND 108 +#define TWLG_TAMIL 109 +#define TWLG_TELUGU 110 +#define TWLG_TRIPURI 111 +#define TWLG_URDU 112 +#define TWLG_VIETNAMESE 113 + + +/**************************************************************************** + * Data Groups * + ****************************************************************************/ +#define DG_CONTROL 0x0001L +#define DG_IMAGE 0x0002L +#define DG_AUDIO 0x0004L + +/* 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 + */ +#define DF_DSM2 0x10000000L +#define DF_APP2 0x20000000L + +#define DF_DS2 0x40000000L + +#define DG_MASK 0xFFFFL + +/**************************************************************************** + * * + ****************************************************************************/ +#define DAT_NULL 0x0000 +#define DAT_CUSTOMBASE 0x8000 + +/* Data Argument Types for the DG_CONTROL Data Group. */ +#define DAT_CAPABILITY 0x0001 +#define DAT_EVENT 0x0002 +#define DAT_IDENTITY 0x0003 +#define DAT_PARENT 0x0004 +#define DAT_PENDINGXFERS 0x0005 +#define DAT_SETUPMEMXFER 0x0006 +#define DAT_SETUPFILEXFER 0x0007 +#define DAT_STATUS 0x0008 +#define DAT_USERINTERFACE 0x0009 +#define DAT_XFERGROUP 0x000a +#define DAT_CUSTOMDSDATA 0x000c +#define DAT_DEVICEEVENT 0x000d +#define DAT_FILESYSTEM 0x000e +#define DAT_PASSTHRU 0x000f +#define DAT_CALLBACK 0x0010 +#define DAT_STATUSUTF8 0x0011 +#define DAT_CALLBACK2 0x0012 +#define DAT_METRICS 0x0013 +#define DAT_TWAINDIRECT 0x0014 + +/* Data Argument Types for the DG_IMAGE Data Group. */ +#define DAT_IMAGEINFO 0x0101 +#define DAT_IMAGELAYOUT 0x0102 +#define DAT_IMAGEMEMXFER 0x0103 +#define DAT_IMAGENATIVEXFER 0x0104 +#define DAT_IMAGEFILEXFER 0x0105 +#define DAT_CIECOLOR 0x0106 +#define DAT_GRAYRESPONSE 0x0107 +#define DAT_RGBRESPONSE 0x0108 +#define DAT_JPEGCOMPRESSION 0x0109 +#define DAT_PALETTE8 0x010a +#define DAT_EXTIMAGEINFO 0x010b +#define DAT_FILTER 0x010c + +/* Data Argument Types for the DG_AUDIO Data Group. */ +#define DAT_AUDIOFILEXFER 0x0201 +#define DAT_AUDIOINFO 0x0202 +#define DAT_AUDIONATIVEXFER 0x0203 + +/* misplaced */ +#define DAT_ICCPROFILE 0x0401 +#define DAT_IMAGEMEMFILEXFER 0x0402 +#define DAT_ENTRYPOINT 0x0403 + + +/**************************************************************************** + * Messages * + ****************************************************************************/ + +/* All message constants are unique. + * Messages are grouped according to which DATs they are used with.*/ + +#define MSG_NULL 0x0000 +#define MSG_CUSTOMBASE 0x8000 + +/* Generic messages may be used with any of several DATs. */ +#define MSG_GET 0x0001 +#define MSG_GETCURRENT 0x0002 +#define MSG_GETDEFAULT 0x0003 +#define MSG_GETFIRST 0x0004 +#define MSG_GETNEXT 0x0005 +#define MSG_SET 0x0006 +#define MSG_RESET 0x0007 +#define MSG_QUERYSUPPORT 0x0008 +#define MSG_GETHELP 0x0009 +#define MSG_GETLABEL 0x000a +#define MSG_GETLABELENUM 0x000b +#define MSG_SETCONSTRAINT 0x000c + +/* Messages used with DAT_NULL */ +#define MSG_XFERREADY 0x0101 +#define MSG_CLOSEDSREQ 0x0102 +#define MSG_CLOSEDSOK 0x0103 +#define MSG_DEVICEEVENT 0X0104 + +/* Messages used with a pointer to DAT_PARENT data */ +#define MSG_OPENDSM 0x0301 +#define MSG_CLOSEDSM 0x0302 + +/* Messages used with a pointer to a DAT_IDENTITY structure */ +#define MSG_OPENDS 0x0401 +#define MSG_CLOSEDS 0x0402 +#define MSG_USERSELECT 0x0403 + +/* Messages used with a pointer to a DAT_USERINTERFACE structure */ +#define MSG_DISABLEDS 0x0501 +#define MSG_ENABLEDS 0x0502 +#define MSG_ENABLEDSUIONLY 0x0503 + +/* Messages used with a pointer to a DAT_EVENT structure */ +#define MSG_PROCESSEVENT 0x0601 + +/* Messages used with a pointer to a DAT_PENDINGXFERS structure */ +#define MSG_ENDXFER 0x0701 +#define MSG_STOPFEEDER 0x0702 + +/* Messages used with a pointer to a DAT_FILESYSTEM structure */ +#define MSG_CHANGEDIRECTORY 0x0801 +#define MSG_CREATEDIRECTORY 0x0802 +#define MSG_DELETE 0x0803 +#define MSG_FORMATMEDIA 0x0804 +#define MSG_GETCLOSE 0x0805 +#define MSG_GETFIRSTFILE 0x0806 +#define MSG_GETINFO 0x0807 +#define MSG_GETNEXTFILE 0x0808 +#define MSG_RENAME 0x0809 +#define MSG_COPY 0x080A +#define MSG_AUTOMATICCAPTUREDIRECTORY 0x080B + +/* Messages used with a pointer to a DAT_PASSTHRU structure */ +#define MSG_PASSTHRU 0x0901 + +/* used with DAT_CALLBACK */ +#define MSG_REGISTER_CALLBACK 0x0902 + +/* used with DAT_CAPABILITY */ +#define MSG_RESETALL 0x0A01 + +/* used with DAT_TWAINDIRECT */ +#define MSG_SETTASK 0x0B01 + +/**************************************************************************** + * Capabilities * + ****************************************************************************/ + +#define CAP_CUSTOMBASE 0x8000 /* Base of custom capabilities */ + +/* all data sources are REQUIRED to support these caps */ +#define CAP_XFERCOUNT 0x0001 + +/* image data sources are REQUIRED to support these caps */ +#define ICAP_COMPRESSION 0x0100 +#define ICAP_PIXELTYPE 0x0101 +#define ICAP_UNITS 0x0102 +#define ICAP_XFERMECH 0x0103 + +/* all data sources MAY support these caps */ +#define CAP_AUTHOR 0x1000 +#define CAP_CAPTION 0x1001 +#define CAP_FEEDERENABLED 0x1002 +#define CAP_FEEDERLOADED 0x1003 +#define CAP_TIMEDATE 0x1004 +#define CAP_SUPPORTEDCAPS 0x1005 +#define CAP_EXTENDEDCAPS 0x1006 +#define CAP_AUTOFEED 0x1007 +#define CAP_CLEARPAGE 0x1008 +#define CAP_FEEDPAGE 0x1009 +#define CAP_REWINDPAGE 0x100a +#define CAP_INDICATORS 0x100b +#define CAP_PAPERDETECTABLE 0x100d +#define CAP_UICONTROLLABLE 0x100e +#define CAP_DEVICEONLINE 0x100f +#define CAP_AUTOSCAN 0x1010 +#define CAP_THUMBNAILSENABLED 0x1011 +#define CAP_DUPLEX 0x1012 +#define CAP_DUPLEXENABLED 0x1013 +#define CAP_ENABLEDSUIONLY 0x1014 +#define CAP_CUSTOMDSDATA 0x1015 +#define CAP_ENDORSER 0x1016 +#define CAP_JOBCONTROL 0x1017 +#define CAP_ALARMS 0x1018 +#define CAP_ALARMVOLUME 0x1019 +#define CAP_AUTOMATICCAPTURE 0x101a +#define CAP_TIMEBEFOREFIRSTCAPTURE 0x101b +#define CAP_TIMEBETWEENCAPTURES 0x101c +#define CAP_MAXBATCHBUFFERS 0x101e +#define CAP_DEVICETIMEDATE 0x101f +#define CAP_POWERSUPPLY 0x1020 +#define CAP_CAMERAPREVIEWUI 0x1021 +#define CAP_DEVICEEVENT 0x1022 +#define CAP_SERIALNUMBER 0x1024 +#define CAP_PRINTER 0x1026 +#define CAP_PRINTERENABLED 0x1027 +#define CAP_PRINTERINDEX 0x1028 +#define CAP_PRINTERMODE 0x1029 +#define CAP_PRINTERSTRING 0x102a +#define CAP_PRINTERSUFFIX 0x102b +#define CAP_LANGUAGE 0x102c +#define CAP_FEEDERALIGNMENT 0x102d +#define CAP_FEEDERORDER 0x102e +#define CAP_REACQUIREALLOWED 0x1030 +#define CAP_BATTERYMINUTES 0x1032 +#define CAP_BATTERYPERCENTAGE 0x1033 +#define CAP_CAMERASIDE 0x1034 +#define CAP_SEGMENTED 0x1035 +#define CAP_CAMERAENABLED 0x1036 +#define CAP_CAMERAORDER 0x1037 +#define CAP_MICRENABLED 0x1038 +#define CAP_FEEDERPREP 0x1039 +#define CAP_FEEDERPOCKET 0x103a +#define CAP_AUTOMATICSENSEMEDIUM 0x103b +#define CAP_CUSTOMINTERFACEGUID 0x103c +#define CAP_SUPPORTEDCAPSSEGMENTUNIQUE 0x103d +#define CAP_SUPPORTEDDATS 0x103e +#define CAP_DOUBLEFEEDDETECTION 0x103f +#define CAP_DOUBLEFEEDDETECTIONLENGTH 0x1040 +#define CAP_DOUBLEFEEDDETECTIONSENSITIVITY 0x1041 +#define CAP_DOUBLEFEEDDETECTIONRESPONSE 0x1042 +#define CAP_PAPERHANDLING 0x1043 +#define CAP_INDICATORSMODE 0x1044 +#define CAP_PRINTERVERTICALOFFSET 0x1045 +#define CAP_POWERSAVETIME 0x1046 +#define CAP_PRINTERCHARROTATION 0x1047 +#define CAP_PRINTERFONTSTYLE 0x1048 +#define CAP_PRINTERINDEXLEADCHAR 0x1049 +#define CAP_PRINTERINDEXMAXVALUE 0x104A +#define CAP_PRINTERINDEXNUMDIGITS 0x104B +#define CAP_PRINTERINDEXSTEP 0x104C +#define CAP_PRINTERINDEXTRIGGER 0x104D +#define CAP_PRINTERSTRINGPREVIEW 0x104E +#define CAP_SHEETCOUNT 0x104F + + + +/* image data sources MAY support these caps */ +#define ICAP_AUTOBRIGHT 0x1100 +#define ICAP_BRIGHTNESS 0x1101 +#define ICAP_CONTRAST 0x1103 +#define ICAP_CUSTHALFTONE 0x1104 +#define ICAP_EXPOSURETIME 0x1105 +#define ICAP_FILTER 0x1106 +#define ICAP_FLASHUSED 0x1107 +#define ICAP_GAMMA 0x1108 +#define ICAP_HALFTONES 0x1109 +#define ICAP_HIGHLIGHT 0x110a +#define ICAP_IMAGEFILEFORMAT 0x110c +#define ICAP_LAMPSTATE 0x110d +#define ICAP_LIGHTSOURCE 0x110e +#define ICAP_ORIENTATION 0x1110 +#define ICAP_PHYSICALWIDTH 0x1111 +#define ICAP_PHYSICALHEIGHT 0x1112 +#define ICAP_SHADOW 0x1113 +#define ICAP_FRAMES 0x1114 +#define ICAP_XNATIVERESOLUTION 0x1116 +#define ICAP_YNATIVERESOLUTION 0x1117 +#define ICAP_XRESOLUTION 0x1118 +#define ICAP_YRESOLUTION 0x1119 +#define ICAP_MAXFRAMES 0x111a +#define ICAP_TILES 0x111b +#define ICAP_BITORDER 0x111c +#define ICAP_CCITTKFACTOR 0x111d +#define ICAP_LIGHTPATH 0x111e +#define ICAP_PIXELFLAVOR 0x111f +#define ICAP_PLANARCHUNKY 0x1120 +#define ICAP_ROTATION 0x1121 +#define ICAP_SUPPORTEDSIZES 0x1122 +#define ICAP_THRESHOLD 0x1123 +#define ICAP_XSCALING 0x1124 +#define ICAP_YSCALING 0x1125 +#define ICAP_BITORDERCODES 0x1126 +#define ICAP_PIXELFLAVORCODES 0x1127 +#define ICAP_JPEGPIXELTYPE 0x1128 +#define ICAP_TIMEFILL 0x112a +#define ICAP_BITDEPTH 0x112b +#define ICAP_BITDEPTHREDUCTION 0x112c +#define ICAP_UNDEFINEDIMAGESIZE 0x112d +#define ICAP_IMAGEDATASET 0x112e +#define ICAP_EXTIMAGEINFO 0x112f +#define ICAP_MINIMUMHEIGHT 0x1130 +#define ICAP_MINIMUMWIDTH 0x1131 +#define ICAP_AUTODISCARDBLANKPAGES 0x1134 +#define ICAP_FLIPROTATION 0x1136 +#define ICAP_BARCODEDETECTIONENABLED 0x1137 +#define ICAP_SUPPORTEDBARCODETYPES 0x1138 +#define ICAP_BARCODEMAXSEARCHPRIORITIES 0x1139 +#define ICAP_BARCODESEARCHPRIORITIES 0x113a +#define ICAP_BARCODESEARCHMODE 0x113b +#define ICAP_BARCODEMAXRETRIES 0x113c +#define ICAP_BARCODETIMEOUT 0x113d +#define ICAP_ZOOMFACTOR 0x113e +#define ICAP_PATCHCODEDETECTIONENABLED 0x113f +#define ICAP_SUPPORTEDPATCHCODETYPES 0x1140 +#define ICAP_PATCHCODEMAXSEARCHPRIORITIES 0x1141 +#define ICAP_PATCHCODESEARCHPRIORITIES 0x1142 +#define ICAP_PATCHCODESEARCHMODE 0x1143 +#define ICAP_PATCHCODEMAXRETRIES 0x1144 +#define ICAP_PATCHCODETIMEOUT 0x1145 +#define ICAP_FLASHUSED2 0x1146 +#define ICAP_IMAGEFILTER 0x1147 +#define ICAP_NOISEFILTER 0x1148 +#define ICAP_OVERSCAN 0x1149 +#define ICAP_AUTOMATICBORDERDETECTION 0x1150 +#define ICAP_AUTOMATICDESKEW 0x1151 +#define ICAP_AUTOMATICROTATE 0x1152 +#define ICAP_JPEGQUALITY 0x1153 +#define ICAP_FEEDERTYPE 0x1154 +#define ICAP_ICCPROFILE 0x1155 +#define ICAP_AUTOSIZE 0x1156 +#define ICAP_AUTOMATICCROPUSESFRAME 0x1157 +#define ICAP_AUTOMATICLENGTHDETECTION 0x1158 +#define ICAP_AUTOMATICCOLORENABLED 0x1159 +#define ICAP_AUTOMATICCOLORNONCOLORPIXELTYPE 0x115a +#define ICAP_COLORMANAGEMENTENABLED 0x115b +#define ICAP_IMAGEMERGE 0x115c +#define ICAP_IMAGEMERGEHEIGHTTHRESHOLD 0x115d +#define ICAP_SUPPORTEDEXTIMAGEINFO 0x115e +#define ICAP_FILMTYPE 0x115f +#define ICAP_MIRROR 0x1160 +#define ICAP_JPEGSUBSAMPLING 0x1161 + +/* image data sources MAY support these audio caps */ +#define ACAP_XFERMECH 0x1202 + + +/*************************************************************************** + * Extended Image Info Attributes section Added 1.7 * + ***************************************************************************/ + +#define TWEI_BARCODEX 0x1200 +#define TWEI_BARCODEY 0x1201 +#define TWEI_BARCODETEXT 0x1202 +#define TWEI_BARCODETYPE 0x1203 +#define TWEI_DESHADETOP 0x1204 +#define TWEI_DESHADELEFT 0x1205 +#define TWEI_DESHADEHEIGHT 0x1206 +#define TWEI_DESHADEWIDTH 0x1207 +#define TWEI_DESHADESIZE 0x1208 +#define TWEI_SPECKLESREMOVED 0x1209 +#define TWEI_HORZLINEXCOORD 0x120A +#define TWEI_HORZLINEYCOORD 0x120B +#define TWEI_HORZLINELENGTH 0x120C +#define TWEI_HORZLINETHICKNESS 0x120D +#define TWEI_VERTLINEXCOORD 0x120E +#define TWEI_VERTLINEYCOORD 0x120F +#define TWEI_VERTLINELENGTH 0x1210 +#define TWEI_VERTLINETHICKNESS 0x1211 +#define TWEI_PATCHCODE 0x1212 +#define TWEI_ENDORSEDTEXT 0x1213 +#define TWEI_FORMCONFIDENCE 0x1214 +#define TWEI_FORMTEMPLATEMATCH 0x1215 +#define TWEI_FORMTEMPLATEPAGEMATCH 0x1216 +#define TWEI_FORMHORZDOCOFFSET 0x1217 +#define TWEI_FORMVERTDOCOFFSET 0x1218 +#define TWEI_BARCODECOUNT 0x1219 +#define TWEI_BARCODECONFIDENCE 0x121A +#define TWEI_BARCODEROTATION 0x121B +#define TWEI_BARCODETEXTLENGTH 0x121C +#define TWEI_DESHADECOUNT 0x121D +#define TWEI_DESHADEBLACKCOUNTOLD 0x121E +#define TWEI_DESHADEBLACKCOUNTNEW 0x121F +#define TWEI_DESHADEBLACKRLMIN 0x1220 +#define TWEI_DESHADEBLACKRLMAX 0x1221 +#define TWEI_DESHADEWHITECOUNTOLD 0x1222 +#define TWEI_DESHADEWHITECOUNTNEW 0x1223 +#define TWEI_DESHADEWHITERLMIN 0x1224 +#define TWEI_DESHADEWHITERLAVE 0x1225 +#define TWEI_DESHADEWHITERLMAX 0x1226 +#define TWEI_BLACKSPECKLESREMOVED 0x1227 +#define TWEI_WHITESPECKLESREMOVED 0x1228 +#define TWEI_HORZLINECOUNT 0x1229 +#define TWEI_VERTLINECOUNT 0x122A +#define TWEI_DESKEWSTATUS 0x122B +#define TWEI_SKEWORIGINALANGLE 0x122C +#define TWEI_SKEWFINALANGLE 0x122D +#define TWEI_SKEWCONFIDENCE 0x122E +#define TWEI_SKEWWINDOWX1 0x122F +#define TWEI_SKEWWINDOWY1 0x1230 +#define TWEI_SKEWWINDOWX2 0x1231 +#define TWEI_SKEWWINDOWY2 0x1232 +#define TWEI_SKEWWINDOWX3 0x1233 +#define TWEI_SKEWWINDOWY3 0x1234 +#define TWEI_SKEWWINDOWX4 0x1235 +#define TWEI_SKEWWINDOWY4 0x1236 +#define TWEI_BOOKNAME 0x1238 +#define TWEI_CHAPTERNUMBER 0x1239 +#define TWEI_DOCUMENTNUMBER 0x123A +#define TWEI_PAGENUMBER 0x123B +#define TWEI_CAMERA 0x123C +#define TWEI_FRAMENUMBER 0x123D +#define TWEI_FRAME 0x123E +#define TWEI_PIXELFLAVOR 0x123F +#define TWEI_ICCPROFILE 0x1240 +#define TWEI_LASTSEGMENT 0x1241 +#define TWEI_SEGMENTNUMBER 0x1242 +#define TWEI_MAGDATA 0x1243 +#define TWEI_MAGTYPE 0x1244 +#define TWEI_PAGESIDE 0x1245 +#define TWEI_FILESYSTEMSOURCE 0x1246 +#define TWEI_IMAGEMERGED 0x1247 +#define TWEI_MAGDATALENGTH 0x1248 +#define TWEI_PAPERCOUNT 0x1249 +#define TWEI_PRINTERTEXT 0x124A +#define TWEI_TWAINDIRECTMETADATA 0x124B + +#define TWEJ_NONE 0x0000 +#define TWEJ_MIDSEPARATOR 0x0001 +#define TWEJ_PATCH1 0x0002 +#define TWEJ_PATCH2 0x0003 +#define TWEJ_PATCH3 0x0004 +#define TWEJ_PATCH4 0x0005 +#define TWEJ_PATCH6 0x0006 +#define TWEJ_PATCHT 0x0007 + + +/*************************************************************************** + * Return Codes and Condition Codes section * + ***************************************************************************/ + +#define TWRC_CUSTOMBASE 0x8000 + +#define TWRC_SUCCESS 0 +#define TWRC_FAILURE 1 +#define TWRC_CHECKSTATUS 2 +#define TWRC_CANCEL 3 +#define TWRC_DSEVENT 4 +#define TWRC_NOTDSEVENT 5 +#define TWRC_XFERDONE 6 +#define TWRC_ENDOFLIST 7 +#define TWRC_INFONOTSUPPORTED 8 +#define TWRC_DATANOTAVAILABLE 9 +#define TWRC_BUSY 10 +#define TWRC_SCANNERLOCKED 11 + +/* Condition Codes: Application gets these by doing DG_CONTROL DAT_STATUS MSG_GET. */ +#define TWCC_CUSTOMBASE 0x8000 + +#define TWCC_SUCCESS 0 +#define TWCC_BUMMER 1 +#define TWCC_LOWMEMORY 2 +#define TWCC_NODS 3 +#define TWCC_MAXCONNECTIONS 4 +#define TWCC_OPERATIONERROR 5 +#define TWCC_BADCAP 6 +#define TWCC_BADPROTOCOL 9 +#define TWCC_BADVALUE 10 +#define TWCC_SEQERROR 11 +#define TWCC_BADDEST 12 +#define TWCC_CAPUNSUPPORTED 13 +#define TWCC_CAPBADOPERATION 14 +#define TWCC_CAPSEQERROR 15 +#define TWCC_DENIED 16 +#define TWCC_FILEEXISTS 17 +#define TWCC_FILENOTFOUND 18 +#define TWCC_NOTEMPTY 19 +#define TWCC_PAPERJAM 20 +#define TWCC_PAPERDOUBLEFEED 21 +#define TWCC_FILEWRITEERROR 22 +#define TWCC_CHECKDEVICEONLINE 23 +#define TWCC_INTERLOCK 24 +#define TWCC_DAMAGEDCORNER 25 +#define TWCC_FOCUSERROR 26 +#define TWCC_DOCTOOLIGHT 27 +#define TWCC_DOCTOODARK 28 +#define TWCC_NOMEDIA 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 */ +#define TWQC_GET 0x0001 +#define TWQC_SET 0x0002 +#define TWQC_GETDEFAULT 0x0004 +#define TWQC_GETCURRENT 0x0008 +#define TWQC_RESET 0x0010 +#define TWQC_SETCONSTRAINT 0x0020 +#define TWQC_GETHELP 0x0100 +#define TWQC_GETLABEL 0x0200 +#define TWQC_GETLABELENUM 0x0400 + +/**************************************************************************** + * Depreciated Items * + ****************************************************************************/ +#if defined(WIN32) || defined(WIN64) + #define TW_HUGE +#elif !defined(TWH_CMP_GNU) + #define TW_HUGE huge +#else + #define TW_HUGE +#endif + +typedef BYTE TW_HUGE * HPBYTE; +typedef void TW_HUGE * HPVOID; + +typedef unsigned char TW_STR1024[1026], FAR *pTW_STR1026, FAR *pTW_STR1024; +typedef wchar_t TW_UNI512[512], FAR *pTW_UNI512; + +#define TWTY_STR1024 0x000d +#define TWTY_UNI512 0x000e + +#define TWFF_JPN 12 + +#define DAT_TWUNKIDENTITY 0x000b +#define DAT_SETUPFILEXFER2 0x0301 + +#define CAP_CLEARBUFFERS 0x101d +#define CAP_SUPPORTEDCAPSEXT 0x100c +#define CAP_FILESYSTEM //0x???? +#define CAP_PAGEMULTIPLEACQUIRE 0x1023 +#define CAP_PAPERBINDING 0x102f +#define CAP_PASSTHRU 0x1031 +#define CAP_POWERDOWNTIME 0x1034 +#define ACAP_AUDIOFILEFORMAT 0x1201 + +#define MSG_CHECKSTATUS 0x0201 + +#define MSG_INVOKE_CALLBACK 0x0903 /* Mac Only, deprecated - use DAT_NULL and MSG_xxx instead */ + +#define TWQC_CONSTRAINABLE 0x0040 + +#define TWSX_FILE2 3 + +/* CAP_FILESYSTEM values (FS_ means file system) */ +#define TWFS_FILESYSTEM 0 +#define TWFS_RECURSIVEDELETE 1 + +/* ICAP_PIXELTYPE values (PT_ means Pixel Type) */ +#define TWPT_SRGB64 11 +#define TWPT_BGR 12 +#define TWPT_CIELAB 13 +#define TWPT_CIELUV 14 +#define TWPT_YCBCR 15 + +/* ICAP_SUPPORTEDSIZES values (SS_ means Supported Sizes) */ +#define TWSS_B 8 +#define TWSS_A4LETTER TWSS_A4 +#define TWSS_B3 TWSS_ISOB3 +#define TWSS_B4 TWSS_ISOB4 +#define TWSS_B6 TWSS_ISOB6 +#define TWSS_B5LETTER TWSS_JISB5 + +/* ACAP_AUDIOFILEFORMAT values (AF_ means audio format). Added 1.8 */ +#define TWAF_WAV 0 +#define TWAF_AIFF 1 +#define TWAF_AU 3 +#define TWAF_SND 4 + +/* CAP_CLEARBUFFERS values */ +#define TWCB_AUTO 0 +#define TWCB_CLEAR 1 +#define TWCB_NOCLEAR 2 + +/* DAT_SETUPFILEXFER2. Sets up DS to application data transfer via a file. Added 1.9 */ +typedef struct { + TW_MEMREF FileName; + TW_UINT16 FileNameType; + TW_UINT16 Format; + TW_INT16 VRefNum; + TW_UINT32 parID; +} TW_SETUPFILEXFER2, FAR * pTW_SETUPFILEXFER2; + +/* DAT_TWUNKIDENTITY. Provides DS identity and 'other' information necessary */ +/* across thunk link. */ +typedef struct { + TW_IDENTITY identity; + TW_STR255 dsPath; +} TW_TWUNKIDENTITY, FAR * pTW_TWUNKIDENTITY; + +/* Provides DS_Entry parameters over thunk link. */ +typedef struct +{ + TW_INT8 destFlag; + TW_IDENTITY dest; + TW_INT32 dataGroup; + TW_INT16 dataArgType; + TW_INT16 message; + TW_INT32 pDataSize; + // TW_MEMREF pData; +} TW_TWUNKDSENTRYPARAMS, FAR * pTW_TWUNKDSENTRYPARAMS; + +/* Provides DS_Entry results over thunk link. */ +typedef struct +{ + TW_UINT16 returnCode; + TW_UINT16 conditionCode; + TW_INT32 pDataSize; + // TW_MEMREF pData; +} TW_TWUNKDSENTRYRETURN, FAR * pTW_TWUNKDSENTRYRETURN; + +typedef struct +{ + TW_UINT16 Cap; + TW_UINT16 Properties; +} TW_CAPEXT, FAR * pTW_CAPEXT; + +/* DAT_SETUPAUDIOFILEXFER, information required to setup an audio file transfer */ +typedef struct { + TW_STR255 FileName; /* full path target file */ + TW_UINT16 Format; /* one of TWAF_xxxx */ + TW_INT16 VRefNum; +} TW_SETUPAUDIOFILEXFER, FAR * pTW_SETUPAUDIOFILEXFER; + + +/**************************************************************************** + * Entry Points * + ****************************************************************************/ + +/********************************************************************** + * Function: DSM_Entry, the only entry point into the Data Source Manager. + ********************************************************************/ +#ifdef TWH_CMP_MSC + #define TW_CALLINGSTYLE PASCAL +#else + #define TW_CALLINGSTYLE +#endif + +/* Don't mangle the name "DSM_Entry" if we're compiling in C++! */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +TW_UINT16 TW_CALLINGSTYLE DSM_Entry( pTW_IDENTITY pOrigin, + pTW_IDENTITY pDest, + TW_UINT32 DG, + TW_UINT16 DAT, + TW_UINT16 MSG, + TW_MEMREF pData); + +typedef TW_UINT16 (TW_CALLINGSTYLE *DSMENTRYPROC)(pTW_IDENTITY pOrigin, + pTW_IDENTITY pDest, + TW_UINT32 DG, + TW_UINT16 DAT, + TW_UINT16 MSG, + TW_MEMREF pData); +#ifdef __cplusplus +} +#endif /* cplusplus */ + + +/********************************************************************** + * Function: DS_Entry, the entry point provided by a Data Source. + ********************************************************************/ +/* Don't mangle the name "DS_Entry" if we're compiling in C++! */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +TW_UINT16 TW_CALLINGSTYLE DS_Entry(pTW_IDENTITY pOrigin, + TW_UINT32 DG, + TW_UINT16 DAT, + TW_UINT16 MSG, + TW_MEMREF pData); + +typedef TW_UINT16 (FAR PASCAL *DSENTRYPROC)(pTW_IDENTITY pOrigin, + TW_UINT32 DG, + TW_UINT16 DAT, + TW_UINT16 MSG, + TW_MEMREF pData); + +TW_UINT16 TW_CALLINGSTYLE TWAIN_Callback( pTW_IDENTITY pOrigin, + pTW_IDENTITY pDest, + TW_UINT32 DG, + TW_UINT16 DAT, + TW_UINT16 MSG, + TW_MEMREF pData); +typedef TW_UINT16 (TW_CALLINGSTYLE *TWAINCALLBACKPROC)(pTW_IDENTITY pOrigin, + pTW_IDENTITY pDest, + TW_UINT32 DG, + TW_UINT16 DAT, + TW_UINT16 MSG, + TW_MEMREF pData); + +TW_HANDLE TW_CALLINGSTYLE DSM_MemAllocate (TW_UINT32); +typedef TW_HANDLE (TW_CALLINGSTYLE *DSM_MEMALLOCATE)(TW_UINT32 _size); + +void TW_CALLINGSTYLE DSM_MemFree (TW_HANDLE); +typedef void (TW_CALLINGSTYLE *DSM_MEMFREE)(TW_HANDLE _handle); + +TW_MEMREF TW_CALLINGSTYLE DSM_MemLock (TW_HANDLE); +typedef TW_MEMREF (TW_CALLINGSTYLE *DSM_MEMLOCK)(TW_HANDLE _handle); + +void TW_CALLINGSTYLE DSM_MemUnlock (TW_HANDLE); +typedef void (TW_CALLINGSTYLE *DSM_MEMUNLOCK)(TW_HANDLE _handle); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* DAT_ENTRYPOINT. returns essential entry points. */ +typedef struct { + TW_UINT32 Size; + DSMENTRYPROC DSM_Entry; + DSM_MEMALLOCATE DSM_MemAllocate; + DSM_MEMFREE DSM_MemFree; + DSM_MEMLOCK DSM_MemLock; + DSM_MEMUNLOCK DSM_MemUnlock; +} TW_ENTRYPOINT, FAR * pTW_ENTRYPOINT; + +/* DAT_FILTER*/ +typedef struct { + TW_UINT32 Size; + TW_UINT32 HueStart; + TW_UINT32 HueEnd; + TW_UINT32 SaturationStart; + TW_UINT32 SaturationEnd; + TW_UINT32 ValueStart; + TW_UINT32 ValueEnd; + TW_UINT32 Replacement; +} TW_FILTER_DESCRIPTOR, *pTW_FILTER_DESCRIPTOR; + +/* DAT_FILTER */ +typedef struct { + TW_UINT32 Size; + TW_UINT32 DescriptorCount; + TW_UINT32 MaxDescriptorCount; + TW_UINT32 Condition; + TW_HANDLE hDescriptors; +} TW_FILTER, *pTW_FILTER; + + +/* Restore the previous packing alignment: this occurs after all structures are defined */ +#ifdef TWH_CMP_MSC + #pragma pack (pop, before_twain) +#elif defined(TWH_CMP_GNU) + #if defined(__APPLE__) /* cf: Mac version of TWAIN.h */ + #pragma options align = reset + #else + #pragma pack (pop, before_twain) + #endif +#elif defined(TWH_CMP_BORLAND) + #pragma option -a. +#endif + +#endif /* TWAIN */ diff --git a/Tests/NTwain.Tests/Data/TWIdentityTest.cs b/Tests/NTwain.Tests/Data/TWIdentityTest.cs deleted file mode 100644 index 6d1ffa9..0000000 --- a/Tests/NTwain.Tests/Data/TWIdentityTest.cs +++ /dev/null @@ -1,75 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using NTwain.Data; -using System; - -namespace NTwain.Tests.Data -{ - /// - ///This is a test class for TWIdentity and is intended - ///to contain all TWIdentityTest Unit Tests - /// - [TestClass] - public class TWIdentityTest - { - // the maxlength expects null terminator so at maxlength it's over the limit - - [TestMethod] - [ExpectedException(typeof(ArgumentException), "String length not enforced.")] - public void Enforce_Manufacturer_String_Length() - { - TWIdentity target = new TWIdentity(); - - var overLength = TwainConst.String32; - - string badString = new String('a', overLength); - - target.Manufacturer = badString; - } - - [TestMethod] - [ExpectedException(typeof(ArgumentException), "String length not enforced.")] - public void Enforce_ProductFamily_String_Length() - { - TWIdentity target = new TWIdentity(); - - var overLength = TwainConst.String32; - - string badString = new String('a', overLength); - target.ProductFamily = badString; - } - - [TestMethod] - [ExpectedException(typeof(ArgumentException), "String length not enforced.")] - public void Enforce_ProductName_String_Length() - { - TWIdentity target = new TWIdentity(); - - var overLength = TwainConst.String32; - - string badString = new String('a', overLength); - target.ProductName = badString; - } - - [TestMethod] - public void Setting_and_Unsetting_the_Shared_Flag_Properties_Works() - { - TWIdentity id = new TWIdentity(); - - // these 2 flag properties are store in same int value so needs to test together - - id.DataFunctionalities = DataFunctionalities.App2; - id.DataGroup = DataGroups.Audio; - Assert.AreEqual(DataFunctionalities.App2, id.DataFunctionalities); - Assert.AreEqual(DataGroups.Audio, id.DataGroup); - - // clear needs to be tested - id.DataFunctionalities = DataFunctionalities.None; - Assert.AreEqual(DataFunctionalities.None, id.DataFunctionalities); - Assert.AreEqual(DataGroups.Audio, id.DataGroup, "Cleared incorrectly."); - - id.DataGroup = DataGroups.None; - Assert.AreEqual(DataGroups.None, id.DataGroup); - } - - } -} diff --git a/Tests/NTwain.Tests/DeviceEventArgsTests.cs b/Tests/NTwain.Tests/DeviceEventArgsTests.cs deleted file mode 100644 index 6653bce..0000000 --- a/Tests/NTwain.Tests/DeviceEventArgsTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using NTwain.Data; - -namespace NTwain.Tests -{ - [TestClass] - public class DeviceEventArgsTests - { - [TestMethod] - public void Constructor_Sets_Correct_Properties() - { - // just some non-default values to test - TWDeviceEvent evt = new TWDeviceEvent(); - - DeviceEventArgs target = new DeviceEventArgs(evt); - - Assert.AreEqual(evt, target.DeviceEvent, "DeviceEvent mismatch."); - } - - } -} diff --git a/Tests/NTwain.Tests/NTwain.Tests.csproj b/Tests/NTwain.Tests/NTwain.Tests.csproj deleted file mode 100644 index ffc5d5f..0000000 --- a/Tests/NTwain.Tests/NTwain.Tests.csproj +++ /dev/null @@ -1,91 +0,0 @@ - - - - Debug - AnyCPU - - - 2.0 - {6B034C50-A397-435F-8DDF-677B403FEBAA} - Library - Properties - NTwain.Tests - NTwain.Tests - v4.0 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - true - - - Sign.snk - - - - - - 3.5 - - - - - - - - False - - - - - Code - - - Code - - - - Code - - - Code - - - Code - - - - - {0C5A6FB1-0282-4D61-8354-68DEB1515001} - NTwain - - - - - - - - \ No newline at end of file diff --git a/Tests/NTwain.Tests/Properties/AssemblyInfo.cs b/Tests/NTwain.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 8e41f28..0000000 --- a/Tests/NTwain.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("NTwain.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Yin-Chun Wang")] -[assembly: AssemblyProduct("NTwain.Tests")] -[assembly: AssemblyCopyright("Copyright © Yin-Chun Wang 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("31489afd-4b8b-413a-b996-fb05bb6bc9fe")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests/NTwain.Tests/TransferReadyEventArgsTests.cs b/Tests/NTwain.Tests/TransferReadyEventArgsTests.cs deleted file mode 100644 index 1dfd7b2..0000000 --- a/Tests/NTwain.Tests/TransferReadyEventArgsTests.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace NTwain.Tests -{ - [TestClass] - public class TransferReadyEventArgsTests - { - - } -} diff --git a/Tests/NTwain.Tests/TwainSessionTests.cs b/Tests/NTwain.Tests/TwainSessionTests.cs deleted file mode 100644 index a7a7dc0..0000000 --- a/Tests/NTwain.Tests/TwainSessionTests.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using NTwain.Data; -using NTwain.Internals; -using System; - -namespace NTwain.Tests -{ - [TestClass] - public class TwainSessionTests - { - [TestMethod] - [ExpectedException(typeof(TwainStateException), "State check failed to throw.")] - public void VerifyState_Throws_When_State_Is_Enforced() - { - ITwainSessionInternal session = new TwainSession(TWIdentity.Create(DataGroups.Image, new Version(1, 0), "test", "test", "test", "test")); - session.EnforceState = true; - session.ChangeState(4, false); - - session.VerifyState(6, 6, DataGroups.Image, DataArgumentType.ImageNativeXfer, Message.Get); - } - - [TestMethod] - public void VerifyState_No_Throws_When_State_Is_Not_Enforced() - { - ITwainSessionInternal session = new TwainSession(TWIdentity.Create(DataGroups.Image, new Version(1, 0), "test", "test", "test", "test")); - session.EnforceState = false; - session.ChangeState(4, false); - - session.VerifyState(6, 6, DataGroups.Image, DataArgumentType.ImageNativeXfer, Message.Get); - } - } -} diff --git a/Tests/NTwain.Tests/TwainStateExceptionTest.cs b/Tests/NTwain.Tests/TwainStateExceptionTest.cs deleted file mode 100644 index 3cf3d2c..0000000 --- a/Tests/NTwain.Tests/TwainStateExceptionTest.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using NTwain.Data; - -namespace NTwain.Tests -{ - /// - ///This is a test class for TwainStateException and is intended - ///to contain all TwainStateExceptionTest Unit Tests - /// - [TestClass] - public class TwainStateExceptionTest - { - /// - ///A test for TwainStateException Constructor - /// - [TestMethod] - public void Constructor_Sets_Correct_Properties() - { - // just some non-default values to test - int state = 3; - int minState = 4; - int maxState = 5; - DataGroups dataGroup = DataGroups.Control; - DataArgumentType argumentType = DataArgumentType.AudioNativeXfer; - Message twainMessage = Message.Copy; - string message = "THIS IS A TEST."; - - TwainStateException target = new TwainStateException(state, minState, maxState, dataGroup, argumentType, twainMessage, message); - - Assert.AreEqual(state, target.ActualState, "State mismatch."); - Assert.AreEqual(minState, target.MinStateExpected, "Minimum mismatch."); - Assert.AreEqual(maxState, target.MaxStateExpected, "Maximum mismatch."); - Assert.AreEqual(dataGroup, target.DataGroup, "DataGroup mismatch."); - Assert.AreEqual(argumentType, target.ArgumentType, "ArgumentType mismatch."); - Assert.AreEqual(twainMessage, target.TwainMessage, "TwainMessage mismatch."); - Assert.AreEqual(message, target.Message, "Message mismatch."); - } - - } -} diff --git a/src/NTwain.Net35/NTwain.Net35.csproj b/src/NTwain.Net35/NTwain.Net35.csproj deleted file mode 100644 index d44cfe1..0000000 --- a/src/NTwain.Net35/NTwain.Net35.csproj +++ /dev/null @@ -1,365 +0,0 @@ - - - - - Debug - AnyCPU - {2E965494-94B0-4EC7-960C-24E5D7D04278} - Library - Properties - NTwain - NTwain - v3.5 - 512 - Client - - - true - full - false - ..\NTwain\bin\Debug\Net35\ - TRACE;DEBUG;NET35 - prompt - 4 - - - pdbonly - true - ..\NTwain\bin\Release\Net35\ - TRACE;NET35 - prompt - 4 - ..\NTwain\bin\Release\Net35\NTwain.XML - - - true - - - Sign.snk - - - - - - - - - - - - Capabilities.cs - - - CapabilityReader.cs - - - CapWrapper.cs - - - DataSource.cs - - - DataTransferredEventArgs.cs - - - Data\TwainTypes.cs - - - Data\TwainTypesExtended.cs - - - Data\TwainValues.cs - - - Data\TypeExtensions.cs - - - Data\ValueExtensions.cs - - - DeviceEventArgs.cs - - - ICapabilities.cs - - - ICapWrapper.cs - - - IDataSource.cs - - - ILog.cs - - - IMemoryManager.cs - - - Internals\Extensions.cs - - - Internals\ICommittable.cs - - - Internals\ImageTools.cs - - - Internals\InternalMessageLoopHook.cs - - - Internals\ITwainSessionInternal.cs - - - Internals\IWinMessageFilter.cs - - - Internals\LinuxMemoryManager.cs - - - Internals\TentativeStateCommitable.cs - - - Internals\TraceLog.cs - - - Internals\TransferLogic.cs - - - Internals\WindowsHook.cs - - - Internals\WinMemoryManager.cs - - - Internals\WrappedManualResetEvent.cs - - - Interop\BITMAP.cs - - - Interop\MESSAGE.cs - - - Interop\NativeMethods.cs - - - Interop\TIFF.cs - - - Interop\UnsafeNativeMethods.cs - - - IPlatformInfo.cs - - - ITripletControl.cs - - - ITwainSession.cs - - - MessageLoopHooks.cs - - - PlatformInfo.cs - - - Properties\AssemblyInfo.cs - - - Properties\Resources.Designer.cs - Resources.resx - True - True - - - Properties\VersionInfo.cs - - - ProtocolVersions.cs - - - SourceEnableMode.cs - - - State.cs - - - TransferErrorEventArgs.cs - - - TransferReadyEventArgs.cs - - - Triplets\DGAudio\DGAudio.AudioFileXfer.cs - - - Triplets\DGAudio\DGAudio.AudioInfo.cs - - - Triplets\DGAudio\DGAudio.AudioNativeXfer.cs - - - Triplets\DGAudio\DGAudio.cs - - - Triplets\DGControl\DGControl.Callback.cs - - - Triplets\DGControl\DGControl.Callback2.cs - - - Triplets\DGControl\DGControl.Capability.cs - - - Triplets\DGControl\DGControl.CapabilityCustom.cs - - - Triplets\DGControl\DGControl.cs - - - Triplets\DGControl\DGControl.CustomDSData.cs - - - Triplets\DGControl\DGControl.DeviceEvent.cs - - - Triplets\DGControl\DGControl.EntryPoint.cs - - - Triplets\DGControl\DGControl.Event.cs - - - Triplets\DGControl\DGControl.FileSystem.cs - - - Triplets\DGControl\DGControl.Identity.cs - - - Triplets\DGControl\DGControl.Parent.cs - - - Triplets\DGControl\DGControl.PassThru.cs - - - Triplets\DGControl\DGControl.PendingXfers.cs - - - Triplets\DGControl\DGControl.SetupFileXfer.cs - - - Triplets\DGControl\DGControl.SetupMemXfer.cs - - - Triplets\DGControl\DGControl.Status.cs - - - Triplets\DGControl\DGControl.StatusUtf8.cs - - - Triplets\DGControl\DGControl.UserInterface.cs - - - Triplets\DGControl\DGControl.XferGroup.cs - - - Triplets\DGCustom.cs - - - Triplets\DGImage\DGImage.CieColor.cs - - - Triplets\DGImage\DGImage.cs - - - Triplets\DGImage\DGImage.ExtImageInfo.cs - - - Triplets\DGImage\DGImage.Filter.cs - - - Triplets\DGImage\DGImage.GrayResponse.cs - - - Triplets\DGImage\DGImage.IccProfile.cs - - - Triplets\DGImage\DGImage.ImageFileXfer.cs - - - Triplets\DGImage\DGImage.ImageInfo.cs - - - Triplets\DGImage\DGImage.ImageLayout.cs - - - Triplets\DGImage\DGImage.ImageMemFileXfer.cs - - - Triplets\DGImage\DGImage.ImageMemXfer.cs - - - Triplets\DGImage\DGImage.ImageNativeXfer.cs - - - Triplets\DGImage\DGImage.JpegCompression.cs - - - Triplets\DGImage\DGImage.Palette8.cs - - - Triplets\DGImage\DGImage.RgbResponse.cs - - - Triplets\Dsm.cs - - - Triplets\Dsm.Linux.cs - - - Triplets\Dsm.WinNew.cs - - - Triplets\Dsm.WinOld.cs - - - Triplets\TripletBase.cs - - - TwainException.cs - - - TwainSession.cs - - - TwainSessionInternal.cs - - - TwainStateException.cs - - - WpfImageTools.cs - - - - - Properties\Resources.resx - ResXFileCodeGenerator - Resources.Designer.cs - - - - - Triplets\WhatsThis.txt - - - - - - \ No newline at end of file diff --git a/src/NTwain.Net35/Sign.snk b/src/NTwain.Net35/Sign.snk deleted file mode 100644 index d65a7a6..0000000 Binary files a/src/NTwain.Net35/Sign.snk and /dev/null differ diff --git a/src/NTwain/CapWrapper.cs b/src/NTwain/CapWrapper.cs deleted file mode 100644 index b757204..0000000 --- a/src/NTwain/CapWrapper.cs +++ /dev/null @@ -1,533 +0,0 @@ -using NTwain.Data; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; - -namespace NTwain -{ - //TODO: handle multi-value sets - - - /// - /// Wrapped class for reading/writing a TWAIN capability associated with a . - /// - /// The TWAIN type of the value. - public class CapWrapper : NTwain.ICapWrapper - { - IDataSource _source; - Func _getConvertRoutine; - Func _setCustomRoutine; - Func _setOneValueFunc; - - /// - /// Initializes a new instance of the class. - /// - /// The source. - /// The capability. - /// The value conversion routine in Get methods. - /// if set to true then make this cap read-only. - /// - /// source - /// or - /// getConversionRoutine - /// - /// source - /// or - /// getConversionRoutine - public CapWrapper(IDataSource source, CapabilityId capability, - Func getConversionRoutine, bool readOnly) - { - if (source == null) { throw new ArgumentNullException("source"); } - if (getConversionRoutine == null) { throw new ArgumentNullException("getConversionRoutine"); } - - _source = source; - _getConvertRoutine = getConversionRoutine; - IsReadOnly = readOnly; - Capability = capability; - - CheckSupports(); - } - - - /// - /// Initializes a new instance of the class. - /// - /// The source. - /// The capability. - /// The value conversion routine in Get methods. - /// Callback to provide the capability object for set method. - /// - /// source - /// or - /// getConversionRoutine - /// or - /// setValueProvider - /// - public CapWrapper(IDataSource source, CapabilityId capability, - Func getConversionRoutine, - Func setValueProvider) - { - if (source == null) { throw new ArgumentNullException("source"); } - if (getConversionRoutine == null) { throw new ArgumentNullException("getConversionRoutine"); } - if (setValueProvider == null) { throw new ArgumentNullException("setValueProvider"); } - - _source = source; - _getConvertRoutine = getConversionRoutine; - _setOneValueFunc = setValueProvider; - Capability = capability; - - CheckSupports(); - } - - /// - /// Initializes a new instance of the class. - /// - /// The source. - /// The capability. - /// The value conversion routine in Get methods. - /// Callback to perform set value. - /// - /// source - /// or - /// getConversionRoutine - /// or - /// setValueRoutine - /// - public CapWrapper(IDataSource source, CapabilityId capability, - Func getConversionRoutine, - Func setValueRoutine) - { - if (source == null) { throw new ArgumentNullException("source"); } - if (getConversionRoutine == null) { throw new ArgumentNullException("getConversionRoutine"); } - if (setValueRoutine == null) { throw new ArgumentNullException("setValueRoutine"); } - - _source = source; - _getConvertRoutine = getConversionRoutine; - _setCustomRoutine = setValueRoutine; - Capability = capability; - - CheckSupports(); - } - - private void CheckSupports() - { - if (!_supports.HasValue && _source.IsOpen) - { - var srcVersion = _source.ProtocolVersion; - var minVer = ProtocolVersions.GetMinimumVersion(Capability); - - if (srcVersion >= minVer) - { - _supports = _source.Capabilities.QuerySupport(Capability); - - if (!_supports.HasValue) - { - // lame source, have to guess using a get call - using (TWCapability cap = new TWCapability(Capability)) - { - var rc = _source.DGControl.Capability.Get(cap); - if (rc == ReturnCode.Success) - { - // assume can do common things - if (IsReadOnly) - { - _supports = QuerySupports.Get | QuerySupports.GetCurrent | QuerySupports.GetDefault; - } - else - { - _supports = QuerySupports.Get | QuerySupports.GetCurrent | QuerySupports.GetDefault | - QuerySupports.Set | QuerySupports.Reset | QuerySupports.SetConstraint; - } - - } - else - { - Debug.WriteLine("Cap " + Capability + " supports set to None due to rc=" + rc + ", cc=" + _source.GetStatus().ConditionCode); - _supports = QuerySupports.None; - } - } - } - } - else - { - Debug.WriteLine("Cap " + Capability + " supports set to None due to not in required TWAIN version (" + minVer + ") not met by source (" + srcVersion + ")."); - _supports = QuerySupports.None; - } - } - } - - - bool Supports(QuerySupports flag) - { - return (SupportedActions & flag) == flag; - } - - #region properties - - /// - /// Gets the capability. - /// - /// - /// The capability. - /// - public CapabilityId Capability { get; private set; } - - QuerySupports? _supports; - - /// - /// Gets the supported actions. - /// - /// - /// The supported actions. - /// - public QuerySupports SupportedActions - { - get - { - CheckSupports(); - return _supports.GetValueOrDefault(); - } - } - - /// - /// Gets a value indicating whether this capability is supported. - /// - /// - /// true if this capability is supported; otherwise, false. - /// - public bool IsSupported { get { return SupportedActions > QuerySupports.None; } } - - /// - /// Gets a value indicating whether this instance is read only. - /// - /// - /// true if this instance is read only; otherwise, false. - /// - public bool IsReadOnly { get; private set; } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can get values; otherwise, false. - /// - public bool CanGet { get { return Supports(QuerySupports.Get); } } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can get default value; otherwise, false. - /// - public bool CanGetDefault { get { return Supports(QuerySupports.GetDefault); } } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can get current value; otherwise, false. - /// - public bool CanGetCurrent { get { return Supports(QuerySupports.GetCurrent); } } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can get label; otherwise, false. - /// - public bool CanGetLabel { get { return Supports(QuerySupports.GetLabel); } } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can get help; otherwise, false. - /// - public bool CanGetHelp { get { return Supports(QuerySupports.GetHelp); } } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can get label enum; otherwise, false. - /// - public bool CanGetLabelEnum { get { return Supports(QuerySupports.GetLabelEnum); } } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can reset; otherwise, false. - /// - public bool CanReset { get { return Supports(QuerySupports.Reset); } } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can set; otherwise, false. - /// - public bool CanSet { get { return Supports(QuerySupports.Set); } } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can set constraint; otherwise, false. - /// - public bool CanSetConstraint { get { return Supports(QuerySupports.SetConstraint); } } - - #endregion - - #region get methods - - /// - /// Gets the default value of this capability. - /// - /// - public TValue GetDefault() - { - if (CanGetDefault) - { - return _getConvertRoutine(_source.Capabilities.GetDefault(Capability)); - } - return default(TValue); - } - - /// - /// Gets the current value of this capability. - /// - /// - public TValue GetCurrent() - { - if (CanGetCurrent) - { - return _getConvertRoutine(_source.Capabilities.GetCurrent(Capability)); - } - return default(TValue); - } - - /// - /// Gets all the possible values of this capability without expanding. - /// This may be required to work with large range values that cannot be safely enumerated - /// with . - /// - /// - public CapabilityReader GetValuesRaw() - { - return _source.Capabilities.GetValuesRaw(Capability); - } - - /// - /// Converts the object values into typed values using the conversion routine - /// for this capability. - /// - /// The values. - /// - public IEnumerable ConvertValues(IEnumerable values) - { - return values.Select(o => _getConvertRoutine(o)); - } - - /// - /// Gets all the possible values of this capability. - /// - /// - public IEnumerable GetValues() - { - return _source.Capabilities.GetValues(Capability).Select(o => _getConvertRoutine(o));//.ToList(); - } - - /// - /// [Experimental] Gets the label value of this capability. - /// - /// - public string GetLabel() - { - object value = null; - - using (TWCapability cap = new TWCapability(Capability)) - { - var rc = _source.DGControl.Capability.GetLabel(cap); - if (rc == ReturnCode.Success) - { - var read = CapabilityReader.ReadValue(cap); - - switch (read.ContainerType) - { - case ContainerType.OneValue: - // most likely not correct - value = read.OneValue; - break; - } - } - } - return value == null ? null : value.ToString(); - } - - /// - /// [Experimental] Gets the help value of this capability. - /// - /// - public string GetHelp() - { - object value = null; - using (TWCapability cap = new TWCapability(Capability)) - { - var rc = _source.DGControl.Capability.GetHelp(cap); - if (rc == ReturnCode.Success) - { - var read = CapabilityReader.ReadValue(cap); - - switch (read.ContainerType) - { - case ContainerType.OneValue: - // most likely not correct - value = read.OneValue; - break; - } - } - } - return value == null ? null : value.ToString(); - } - - /// - /// [Experimental] Gets the display names for possible values of this capability. - /// - /// - public IEnumerable GetLabelEnum() - { - var list = new List(); - - using (TWCapability cap = new TWCapability(Capability)) - { - var rc = _source.DGControl.Capability.GetLabelEnum(cap); - if (rc == ReturnCode.Success) - { - return CapabilityReader.ReadValue(cap).EnumerateCapValues().Select(o => o.ToString()); - } - } - return Enumerable.Empty(); - } - - #endregion - - #region set methods - - /// - /// Resets the current value to power-on default. - /// - /// - public ReturnCode Reset() - { - return _source.Capabilities.Reset(Capability); - } - - /// - /// Simplified version that sets the current value of this capability. - /// - /// The value. - /// - /// Simple Set() is not defined for this capability. - public ReturnCode SetValue(TValue value) - { - ReturnCode rc = ReturnCode.Failure; - - if (_setCustomRoutine != null) - { - rc = _setCustomRoutine(value); - } - else if (_setOneValueFunc != null) - { - using (var cap = new TWCapability(Capability, _setOneValueFunc(value))) - { - rc = _source.DGControl.Capability.Set(cap); - } - } - else - { - throw new InvalidOperationException("Simple Set() is not defined for this capability."); - } - return rc; - } - - /// - /// A version of Set that uses an array. - /// - /// The value. - /// - public ReturnCode SetValue(TWArray value) - { - ReturnCode rc = ReturnCode.Failure; - using (var cap = new TWCapability(Capability, value)) - { - rc = _source.DGControl.Capability.Set(cap); - } - return rc; - } - - /// - /// A version of Set that uses an enumeration. - /// - /// The value. - /// - public ReturnCode SetValue(TWEnumeration value) - { - ReturnCode rc = ReturnCode.Failure; - using (var cap = new TWCapability(Capability, value)) - { - rc = _source.DGControl.Capability.Set(cap); - } - return rc; - } - - /// - /// Sets the constraint value of this capability. - /// - /// The value. - /// - public ReturnCode SetConstraint(TWOneValue value) - { - ReturnCode rc = ReturnCode.Failure; - using (var cap = new TWCapability(Capability, value)) - { - rc = _source.DGControl.Capability.SetConstraint(cap); - } - return rc; - } - - /// - /// Sets the constraint value of this capability. - /// - /// The value. - /// - public ReturnCode SetConstraint(TWEnumeration value) - { - ReturnCode rc = ReturnCode.Failure; - using (var cap = new TWCapability(Capability, value)) - { - rc = _source.DGControl.Capability.SetConstraint(cap); - } - return rc; - } - - /// - /// Sets the constraint value of this capability. - /// - /// The value. - /// - public ReturnCode SetConstraint(TWRange value) - { - ReturnCode rc = ReturnCode.Failure; - using (var cap = new TWCapability(Capability, value)) - { - rc = _source.DGControl.Capability.SetConstraint(cap); - } - return rc; - } - - #endregion - } -} \ No newline at end of file diff --git a/src/NTwain/Capabilities.cs b/src/NTwain/Capabilities.cs deleted file mode 100644 index fcc9f23..0000000 --- a/src/NTwain/Capabilities.cs +++ /dev/null @@ -1,3468 +0,0 @@ -using NTwain.Data; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NTwain -{ - /// - /// Exposes capabilities of a data source as properties. - /// - public class Capabilities : ICapabilities - { - IDataSource _source; - - /// - /// Initializes a new instance of the class. - /// - /// The source. - public Capabilities(IDataSource source) - { - if (source == null) { throw new ArgumentNullException("source"); } - _source = source; - } - - - #region non-wrapped cap calls - - /// - /// Gets the actual supported operations for a capability. This is not supported by all sources. - /// - /// The capability id. - /// - public QuerySupports? QuerySupport(CapabilityId capabilityId) - { - QuerySupports? retVal = null; - using (TWCapability cap = new TWCapability(capabilityId)) - { - cap.ContainerType = ContainerType.OneValue; - var rc = _source.DGControl.Capability.QuerySupport(cap); - if (rc == ReturnCode.Success) - { - var read = CapabilityReader.ReadValue(cap); - - if (read.ContainerType == ContainerType.OneValue) - { - retVal = read.OneValue.ConvertToEnum(); - } - } - } - return retVal; - } - - /// - /// Gets the current value for a capability. - /// - /// The capability id. - /// - public object GetCurrent(CapabilityId capabilityId) - { - using (TWCapability cap = new TWCapability(capabilityId)) - { - var rc = _source.DGControl.Capability.GetCurrent(cap); - if (rc == ReturnCode.Success) - { - var read = CapabilityReader.ReadValue(cap); - - switch (read.ContainerType) - { - case ContainerType.Enum: - if (read.CollectionValues != null && read.CollectionValues.Count > read.EnumCurrentIndex) - { - return read.CollectionValues[read.EnumCurrentIndex]; - } - break; - case ContainerType.OneValue: - return read.OneValue; - case ContainerType.Range: - return read.RangeCurrentValue; - case ContainerType.Array: - // no source should ever return an array but anyway - if (read.CollectionValues != null) - { - return read.CollectionValues.FirstOrDefault(); - } - break; - } - } - } - return null; - } - - /// - /// Gets the default value for a capability. - /// - /// The capability id. - /// - public object GetDefault(CapabilityId capabilityId) - { - using (TWCapability cap = new TWCapability(capabilityId)) - { - var rc = _source.DGControl.Capability.GetDefault(cap); - if (rc == ReturnCode.Success) - { - var read = CapabilityReader.ReadValue(cap); - - switch (read.ContainerType) - { - case ContainerType.Enum: - if (read.CollectionValues != null && read.CollectionValues.Count > read.EnumDefaultIndex) - { - return read.CollectionValues[read.EnumDefaultIndex]; - } - break; - case ContainerType.OneValue: - return read.OneValue; - case ContainerType.Range: - return read.RangeDefaultValue; - case ContainerType.Array: - // no source should ever return an array but anyway - if (read.CollectionValues != null) - { - return read.CollectionValues.FirstOrDefault(); - } - break; - } - } - } - return null; - } - - /// - /// A general method that tries to get capability values from current . - /// - /// The capability id. - /// - public IEnumerable GetValues(CapabilityId capabilityId) - { - using (TWCapability cap = new TWCapability(capabilityId)) - { - var rc = _source.DGControl.Capability.Get(cap); - if (rc == ReturnCode.Success) - { - return CapabilityReader.ReadValue(cap).EnumerateCapValues(); - } - } - return Enumerable.Empty(); - } - - /// - /// Gets all the possible values of this capability without expanding. - /// This may be required to work with large range values that cannot be safely enumerated - /// with . - /// - /// The capability id. - /// - public CapabilityReader GetValuesRaw(CapabilityId capabilityId) - { - using (TWCapability cap = new TWCapability(capabilityId)) - { - var rc = _source.DGControl.Capability.Get(cap); - if (rc == ReturnCode.Success) - { - return CapabilityReader.ReadValue(cap); - } - } - return new CapabilityReader(); - } - - /// - /// Resets all values and constraint to power-on defaults. - /// - /// - public ReturnCode ResetAll() - { - using (TWCapability cap = new TWCapability(CapabilityId.CapSupportedCaps)) - { - var rc = _source.DGControl.Capability.ResetAll(cap); - return rc; - } - } - - /// - /// Resets the current value to power-on default. - /// - /// The capability id. - /// - public ReturnCode Reset(CapabilityId capabilityId) - { - using (TWCapability cap = new TWCapability(capabilityId)) - { - var rc = _source.DGControl.Capability.Reset(cap); - return rc; - } - } - - #endregion - - #region audio caps - - private CapWrapper _audXferMech; - - /// - /// Gets the property to work with audio for the current source. - /// - /// - /// The audio xfer mech. - /// - public ICapWrapper ACapXferMech - { - get - { - return _audXferMech ?? (_audXferMech = new CapWrapper(_source, CapabilityId.ACapXferMech, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - #endregion - - #region img caps - - #region mandatory - - private CapWrapper _compression; - - /// - /// Gets the property to work with image for the current source. - /// - /// - /// The image compression. - /// - public ICapWrapper ICapCompression - { - get - { - return _compression ?? (_compression = new CapWrapper(_source, CapabilityId.ICapCompression, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - - private CapWrapper _pixelType; - - /// - /// Gets the property to work with image for the current source. - /// - /// - /// The image pixel type. - /// - public ICapWrapper ICapPixelType - { - get - { - return _pixelType ?? (_pixelType = new CapWrapper(_source, CapabilityId.ICapPixelType, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _imgUnits; - - /// - /// Gets the property to work with image for the current source. - /// - /// - /// The image unit of measure. - /// - public ICapWrapper ICapUnits - { - get - { - return _imgUnits ?? (_imgUnits = new CapWrapper(_source, CapabilityId.ICapUnits, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _imgXferMech; - - /// - /// Gets the property to work with image for the current source. - /// - /// - /// The image xfer mech. - /// - public ICapWrapper ICapXferMech - { - get - { - return _imgXferMech ?? (_imgXferMech = new CapWrapper(_source, CapabilityId.ICapXferMech, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - #endregion - - private CapWrapper _autoBright; - - /// - /// Gets the property to work with image auto brightness flag for the current source. - /// - /// - /// The image auto brightness flag. - /// - public ICapWrapper ICapAutoBright - { - get - { - return _autoBright ?? (_autoBright = new CapWrapper(_source, CapabilityId.ICapAutoBright, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _brightness; - - /// - /// Gets the property to work with image brightness for the current source. - /// - /// - /// The image brightness. - /// - public ICapWrapper ICapBrightness - { - get - { - return _brightness ?? (_brightness = new CapWrapper(_source, CapabilityId.ICapBrightness, ValueExtensions.ConvertToFix32, value => value.ToOneValue())); - } - } - - private CapWrapper _contrast; - - /// - /// Gets the property to work with image contrast for the current source. - /// - /// - /// The image contrast. - /// - public ICapWrapper ICapContrast - { - get - { - return _contrast ?? (_contrast = new CapWrapper(_source, CapabilityId.ICapContrast, ValueExtensions.ConvertToFix32, value => value.ToOneValue())); - } - } - - private CapWrapper _custHalftone; - - /// - /// Gets the property to work with image square-cell halftone for the current source. - /// - /// - /// The image square-cell halftone. - /// - public ICapWrapper ICapCustHalftone - { - get - { - return _custHalftone ?? (_custHalftone = new CapWrapper(_source, CapabilityId.ICapCustHalftone, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = value, - ItemType = ItemType.UInt8 - })); - } - } - - private CapWrapper _exposureTime; - - /// - /// Gets the property to work with image exposure time (in seconds) for the current source. - /// - /// - /// The image exposure time. - /// - public ICapWrapper ICapExposureTime - { - get - { - return _exposureTime ?? (_exposureTime = new CapWrapper(_source, CapabilityId.ICapExposureTime, ValueExtensions.ConvertToFix32, value => value.ToOneValue())); - } - } - - private CapWrapper _filter; - - /// - /// Gets the property to work with image color filter for the current source. - /// - /// - /// The image color filter type. - /// - public ICapWrapper ICapFilter - { - get - { - return _filter ?? (_filter = new CapWrapper(_source, CapabilityId.ICapFilter, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _gamma; - - /// - /// Gets the property to work with image gamma value for the current source. - /// - /// - /// The image gamma. - /// - public ICapWrapper ICapGamma - { - get - { - return _gamma ?? (_gamma = new CapWrapper(_source, CapabilityId.ICapGamma, ValueExtensions.ConvertToFix32, value => value.ToOneValue())); - } - } - - private CapWrapper _halftones; - - /// - /// Gets the property to work with image halftone patterns for the current source. - /// - /// - /// The image halftone patterns. - /// - public ICapWrapper ICapHalftones - { - get - { - return _halftones ?? (_halftones = new CapWrapper(_source, CapabilityId.ICapHalftones, ValueExtensions.ConvertToString, false)); - } - } - - private CapWrapper _highlight; - - /// - /// Gets the property to work with image highlight value for the current source. - /// - /// - /// The image highlight. - /// - public ICapWrapper ICapHighlight - { - get - { - return _highlight ?? (_highlight = new CapWrapper(_source, CapabilityId.ICapHighlight, ValueExtensions.ConvertToFix32, value => value.ToOneValue())); - } - } - - private CapWrapper _fileFormat; - - /// - /// Gets the property to work with image for the current source. - /// - /// - /// The image file format. - /// - public ICapWrapper ICapImageFileFormat - { - get - { - return _fileFormat ?? (_fileFormat = new CapWrapper(_source, CapabilityId.ICapImageFileFormat, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - - private CapWrapper _lampState; - - /// - /// Gets the property to work with image lamp state flag for the current source. - /// - /// - /// The image lamp state flag. - /// - public ICapWrapper ICapLampState - { - get - { - return _lampState ?? (_lampState = new CapWrapper(_source, CapabilityId.ICapLampState, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _lightSource; - - /// - /// Gets the property to work with image light source for the current source. - /// - /// - /// The image light source. - /// - public ICapWrapper ICapLightSource - { - get - { - return _lightSource ?? (_lightSource = new CapWrapper(_source, CapabilityId.ICapLightSource, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _orientation; - - /// - /// Gets the property to work with image orientation for the current source. - /// - /// - /// The image orientation. - /// - public ICapWrapper ICapOrientation - { - get - { - return _orientation ?? (_orientation = new CapWrapper(_source, CapabilityId.ICapOrientation, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _physicalWidth; - - /// - /// Gets the property to work with image physical width for the current source. - /// - /// - /// The image physical width. - /// - public IReadOnlyCapWrapper ICapPhysicalWidth - { - get - { - return _physicalWidth ?? (_physicalWidth = new CapWrapper(_source, CapabilityId.ICapPhysicalWidth, ValueExtensions.ConvertToFix32, true)); - } - } - - private CapWrapper _physicalHeight; - - /// - /// Gets the property to work with image physical height for the current source. - /// - /// - /// The image physical height. - /// - public IReadOnlyCapWrapper ICapPhysicalHeight - { - get - { - return _physicalHeight ?? (_physicalHeight = new CapWrapper(_source, CapabilityId.ICapPhysicalHeight, ValueExtensions.ConvertToFix32, true)); - } - } - - private CapWrapper _shadow; - - /// - /// Gets the property to work with image shadow value for the current source. - /// - /// - /// The image shadow. - /// - public ICapWrapper ICapShadow - { - get - { - return _shadow ?? (_shadow = new CapWrapper(_source, CapabilityId.ICapShadow, ValueExtensions.ConvertToFix32, value => value.ToOneValue())); - } - } - - private CapWrapper _frames; - - /// - /// Gets the property to work with the list of frames the source will acquire on each page. - /// - /// - /// The capture frames. - /// - public ICapWrapper ICapFrames - { - get - { - return _frames ?? (_frames = new CapWrapper(_source, CapabilityId.ICapFrames, ValueExtensions.ConvertToFrame, - value => - { - using (var cap = new TWCapability(CapabilityId.ICapFrames, value)) - { - return _source.DGControl.Capability.Set(cap); - } - })); - } - } - - private CapWrapper _nativeXRes; - - /// - /// Gets the property to work with image's native x-axis resolution for the current source. - /// - /// - /// The image's native x-axis resolution. - /// - public IReadOnlyCapWrapper ICapXNativeResolution - { - get - { - return _nativeXRes ?? (_nativeXRes = new CapWrapper(_source, CapabilityId.ICapXNativeResolution, ValueExtensions.ConvertToFix32, true)); - } - } - - private CapWrapper _nativeYRes; - - /// - /// Gets the property to work with image's native y-axis resolution for the current source. - /// - /// - /// The image's native y-axis resolution. - /// - public IReadOnlyCapWrapper ICapYNativeResolution - { - get - { - return _nativeYRes ?? (_nativeYRes = new CapWrapper(_source, CapabilityId.ICapYNativeResolution, ValueExtensions.ConvertToFix32, true)); - } - } - - private CapWrapper _xResolution; - - /// - /// Gets the property to work with image x-axis resolution for the current source. - /// - /// - /// The image x-axis resolution. - /// - public ICapWrapper ICapXResolution - { - get - { - return _xResolution ?? (_xResolution = new CapWrapper(_source, CapabilityId.ICapXResolution, ValueExtensions.ConvertToFix32, value => value.ToOneValue())); - } - } - - - private CapWrapper _yResolution; - - /// - /// Gets the property to work with image y-axis resolution for the current source. - /// - /// - /// The image y-axis resolution. - /// - public ICapWrapper ICapYResolution - { - get - { - return _yResolution ?? (_yResolution = new CapWrapper(_source, CapabilityId.ICapYResolution, ValueExtensions.ConvertToFix32, value => value.ToOneValue())); - } - } - - private CapWrapper _maxFrames; - - /// - /// Gets the property to work with image max frames for the current source. - /// - /// - /// The image max frames. - /// - public ICapWrapper ICapMaxFrames - { - get - { - return _maxFrames ?? (_maxFrames = new CapWrapper(_source, CapabilityId.ICapMaxFrames, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _tiles; - - /// - /// Gets the property to work with image tiles flag for the current source. - /// - /// - /// The image tiles flag. - /// - public ICapWrapper ICapTiles - { - get - { - return _tiles ?? (_tiles = new CapWrapper(_source, CapabilityId.ICapTiles, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _bitOrder; - - /// - /// Gets the property to work with image for the current source. - /// - /// - /// The image bit order. - /// - public ICapWrapper ICapBitOrder - { - get - { - return _bitOrder ?? (_bitOrder = new CapWrapper(_source, CapabilityId.ICapBitOrder, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _ccittKFactor; - - /// - /// Gets the property to work with image CCITT K factor for the current source. - /// - /// - /// The image CCITT K factor. - /// - public ICapWrapper ICapCCITTKFactor - { - get - { - return _ccittKFactor ?? (_ccittKFactor = new CapWrapper(_source, CapabilityId.ICapCCITTKFactor, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _lightPath; - - /// - /// Gets the property to work with image light path for the current source. - /// - /// - /// The image light path. - /// - public ICapWrapper ICapLightPath - { - get - { - return _lightPath ?? (_lightPath = new CapWrapper(_source, CapabilityId.ICapLightPath, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _pixelFlavor; - - /// - /// Gets the property to work with image pixel flavor for the current source. - /// - /// - /// The image pixel flavor. - /// - public ICapWrapper ICapPixelFlavor - { - get - { - return _pixelFlavor ?? (_pixelFlavor = new CapWrapper(_source, CapabilityId.ICapPixelFlavor, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _planarChunky; - - /// - /// Gets the property to work with image color format for the current source. - /// - /// - /// The image color format. - /// - public ICapWrapper ICapPlanarChunky - { - get - { - return _planarChunky ?? (_planarChunky = new CapWrapper(_source, CapabilityId.ICapPlanarChunky, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _rotation; - - /// - /// Gets the property to work with image rotation for the current source. - /// - /// - /// The image rotation. - /// - public ICapWrapper ICapRotation - { - get - { - return _rotation ?? (_rotation = new CapWrapper(_source, CapabilityId.ICapRotation, ValueExtensions.ConvertToFix32, value => value.ToOneValue())); - } - } - - private CapWrapper _supportSize; - - /// - /// Gets the property to work with image for the current source. - /// - /// - /// The image supported size. - /// - public ICapWrapper ICapSupportedSizes - { - get - { - return _supportSize ?? (_supportSize = new CapWrapper(_source, CapabilityId.ICapSupportedSizes, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _threshold; - - /// - /// Gets the property to work with image threshold for the current source. - /// - /// - /// The image threshold. - /// - public ICapWrapper ICapThreshold - { - get - { - return _threshold ?? (_threshold = new CapWrapper(_source, CapabilityId.ICapThreshold, ValueExtensions.ConvertToFix32, value => value.ToOneValue())); - } - } - - private CapWrapper _xscaling; - - /// - /// Gets the property to work with image x-axis scaling for the current source. - /// - /// - /// The image x-axis scaling. - /// - public ICapWrapper ICapXScaling - { - get - { - return _xscaling ?? (_xscaling = new CapWrapper(_source, CapabilityId.ICapXScaling, ValueExtensions.ConvertToFix32, value => value.ToOneValue())); - } - } - - private CapWrapper _yscaling; - - /// - /// Gets the property to work with image y-axis scaling for the current source. - /// - /// - /// The image y-axis scaling. - /// - public ICapWrapper ICapYScaling - { - get - { - return _yscaling ?? (_yscaling = new CapWrapper(_source, CapabilityId.ICapYScaling, ValueExtensions.ConvertToFix32, value => value.ToOneValue())); - } - } - - private CapWrapper _bitorderCodes; - - /// - /// Gets the property to work with image CCITT compression for the current source. - /// - /// - /// The image bit order for CCITT compression. - /// - public ICapWrapper ICapBitOrderCodes - { - get - { - return _bitorderCodes ?? (_bitorderCodes = new CapWrapper(_source, CapabilityId.ICapBitOrderCodes, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _pixelFlavorCodes; - - /// - /// Gets the property to work with image CCITT compression for the current source. - /// - /// - /// The image pixel flavor for CCITT compression. - /// - public ICapWrapper ICapPixelFlavorCodes - { - get - { - return _pixelFlavorCodes ?? (_pixelFlavorCodes = new CapWrapper(_source, CapabilityId.ICapPixelFlavorCodes, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _jpegPixelType; - - /// - /// Gets the property to work with image jpeg compression for the current source. - /// - /// - /// The image pixel type for jpeg compression. - /// - public ICapWrapper ICapJpegPixelType - { - get - { - return _jpegPixelType ?? (_jpegPixelType = new CapWrapper(_source, CapabilityId.ICapJpegPixelType, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _timeFill; - - /// - /// Gets the property to work with image CCITT time fill for the current source. - /// - /// - /// The image CCITT time fill. - /// - public ICapWrapper ICapTimeFill - { - get - { - return _timeFill ?? (_timeFill = new CapWrapper(_source, CapabilityId.ICapTimeFill, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _bitDepth; - - /// - /// Gets the property to work with image bit depth for the current source. - /// - /// - /// The image bit depth. - /// - public ICapWrapper ICapBitDepth - { - get - { - return _bitDepth ?? (_bitDepth = new CapWrapper(_source, CapabilityId.ICapBitDepth, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _bitDepthReduction; - - /// - /// Gets the property to work with image bit depth reduction method for the current source. - /// - /// - /// The image bit depth reduction method. - /// - public ICapWrapper ICapBitDepthReduction - { - get - { - return _bitDepthReduction ?? (_bitDepthReduction = new CapWrapper(_source, CapabilityId.ICapBitDepthReduction, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _undefinedImgSize; - - /// - /// Gets the property to work with image undefined size flag for the current source. - /// - /// - /// The image undefined size flag. - /// - public ICapWrapper ICapUndefinedImageSize - { - get - { - return _undefinedImgSize ?? (_undefinedImgSize = new CapWrapper(_source, CapabilityId.ICapUndefinedImageSize, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _imgDataSet; - - /// - /// Gets or sets the image indices that will be delivered during the standard image transfer done in - /// States 6 and 7. - /// - /// - /// The image indicies. - /// - public ICapWrapper ICapImageDataSet - { - get - { - return _imgDataSet ?? (_imgDataSet = new CapWrapper(_source, CapabilityId.ICapImageDataSet, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = value, - ItemType = ItemType.UInt32 - })); - } - } - - private CapWrapper _extImgInfo; - - /// - /// Gets the property to work with ext image info flag for the current source. - /// - /// - /// The ext image info flag. - /// - public ICapWrapper ICapExtImageInfo - { - get - { - return _extImgInfo ?? (_extImgInfo = new CapWrapper(_source, CapabilityId.ICapExtImageInfo, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _minHeight; - - /// - /// Gets the property to work with image minimum height for the current source. - /// - /// - /// The image minimumm height. - /// - public IReadOnlyCapWrapper ICapMinimumHeight - { - get - { - return _minHeight ?? (_minHeight = new CapWrapper(_source, CapabilityId.ICapMinimumHeight, ValueExtensions.ConvertToFix32, true)); - } - } - - private CapWrapper _minWidth; - - /// - /// Gets the property to work with image minimum width for the current source. - /// - /// - /// The image minimumm width. - /// - public IReadOnlyCapWrapper ICapMinimumWidth - { - get - { - return _minWidth ?? (_minWidth = new CapWrapper(_source, CapabilityId.ICapMinimumWidth, ValueExtensions.ConvertToFix32, true)); - } - } - - private CapWrapper _autoDiscBlankPg; - - /// - /// Gets the property to work with image blank page behavior for the current source. - /// - /// - /// The image blank page behavior. - /// - public ICapWrapper ICapAutoDiscardBlankPages - { - get - { - return _autoDiscBlankPg ?? (_autoDiscBlankPg = new CapWrapper(_source, CapabilityId.ICapAutoDiscardBlankPages, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Int32 - })); - } - } - - private CapWrapper _flipRotation; - - /// - /// Gets the property to work with image flip-rotation behavior for the current source. - /// - /// - /// The image flip-rotation behavior. - /// - public ICapWrapper ICapFlipRotation - { - get - { - return _flipRotation ?? (_flipRotation = new CapWrapper(_source, CapabilityId.ICapFlipRotation, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Int32 - })); - } - } - - private CapWrapper _barcodeDetectEnabled; - - /// - /// Gets the property to work with image barcode detection flag for the current source. - /// - /// - /// The image barcode detection flag. - /// - public ICapWrapper ICapBarcodeDetectionEnabled - { - get - { - return _barcodeDetectEnabled ?? (_barcodeDetectEnabled = new CapWrapper(_source, CapabilityId.ICapBarcodeDetectionEnabled, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _barcodeType; - - /// - /// Gets the property to work with image barcode types for the current source. - /// - /// - /// The image barcode types. - /// - public IReadOnlyCapWrapper ICapSupportedBarcodeTypes - { - get - { - return _barcodeType ?? (_barcodeType = new CapWrapper(_source, CapabilityId.ICapSupportedBarcodeTypes, ValueExtensions.ConvertToEnum, true)); - } - } - - private CapWrapper _barcodeMaxPriority; - - /// - /// Gets the property to work with image barcode max search priorities for the current source. - /// - /// - /// The image barcode max search priorities. - /// - public ICapWrapper ICapBarcodeMaxSearchPriorities - { - get - { - return _barcodeMaxPriority ?? (_barcodeMaxPriority = new CapWrapper(_source, CapabilityId.ICapBarcodeMaxSearchPriorities, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = value, - ItemType = ItemType.UInt32 - })); - } - } - - private CapWrapper _barcodeSearchPriority; - - /// - /// Gets the property to work with image barcode search priority for the current source. - /// - /// - /// The image barcode search priority. - /// - public ICapWrapper ICapBarcodeSearchPriorities - { - get - { - return _barcodeSearchPriority ?? (_barcodeSearchPriority = new CapWrapper(_source, CapabilityId.ICapBarcodeSearchPriorities, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _barcodeSearchMode; - - /// - /// Gets the property to work with image barcode search direction for the current source. - /// - /// - /// The image barcode search direction. - /// - public ICapWrapper ICapBarcodeSearchMode - { - get - { - return _barcodeSearchMode ?? (_barcodeSearchMode = new CapWrapper(_source, CapabilityId.ICapBarcodeSearchMode, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _barcodeMaxRetries; - - /// - /// Gets the property to work with image barcode max search retries for the current source. - /// - /// - /// The image barcode max search retries. - /// - public ICapWrapper ICapBarcodeMaxRetries - { - get - { - return _barcodeMaxRetries ?? (_barcodeMaxRetries = new CapWrapper(_source, CapabilityId.ICapBarcodeMaxRetries, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = value, - ItemType = ItemType.UInt32 - })); - } - } - - private CapWrapper _barcodeTimeout; - - /// - /// Gets the property to work with image barcode max search timeout for the current source. - /// - /// - /// The image barcode max search timeout. - /// - public ICapWrapper ICapBarcodeTimeout - { - get - { - return _barcodeTimeout ?? (_barcodeTimeout = new CapWrapper(_source, CapabilityId.ICapBarcodeTimeout, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = value, - ItemType = ItemType.UInt32 - })); - } - } - - private CapWrapper _zoomFactor; - - /// - /// Gets the property to work with image zoom factor for the current source. - /// - /// - /// The image zoom factor. - /// - public ICapWrapper ICapZoomFactor - { - get - { - return _zoomFactor ?? (_zoomFactor = new CapWrapper(_source, CapabilityId.ICapZoomFactor, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _patchcodeDetectEnabled; - - /// - /// Gets the property to work with image patch code detection flag for the current source. - /// - /// - /// The image patch code detection flag. - /// - public ICapWrapper ICapPatchCodeDetectionEnabled - { - get - { - return _patchcodeDetectEnabled ?? (_patchcodeDetectEnabled = new CapWrapper(_source, CapabilityId.ICapPatchCodeDetectionEnabled, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _patchcodeType; - - /// - /// Gets the property to work with image patch code types for the current source. - /// - /// - /// The image patch code types. - /// - public IReadOnlyCapWrapper ICapSupportedPatchCodeTypes - { - get - { - return _patchcodeType ?? (_patchcodeType = new CapWrapper(_source, CapabilityId.ICapSupportedPatchCodeTypes, ValueExtensions.ConvertToEnum, true)); - } - } - - private CapWrapper _patchcodeMaxPriority; - - /// - /// Gets the property to work with image patch code max search priorities for the current source. - /// - /// - /// The image patch code max search priorities. - /// - public ICapWrapper ICapPatchCodeMaxSearchPriorities - { - get - { - return _patchcodeMaxPriority ?? (_patchcodeMaxPriority = new CapWrapper(_source, CapabilityId.ICapPatchCodeMaxSearchPriorities, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = value, - ItemType = ItemType.UInt32 - })); - } - } - - private CapWrapper _patchcodeSearchPriority; - - /// - /// Gets the property to work with image patch code search priority for the current source. - /// - /// - /// The image patch code search priority. - /// - public ICapWrapper ICapPatchCodeSearchPriorities - { - get - { - return _patchcodeSearchPriority ?? (_patchcodeSearchPriority = new CapWrapper(_source, CapabilityId.ICapPatchCodeSearchPriorities, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _patchcodeSearchMode; - - /// - /// Gets the property to work with image patch code search direction for the current source. - /// - /// - /// The image patch code search direction. - /// - public ICapWrapper ICapPatchCodeSearchMode - { - get - { - return _patchcodeSearchMode ?? (_patchcodeSearchMode = new CapWrapper(_source, CapabilityId.ICapPatchCodeSearchMode, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _patchCodeMaxRetries; - - /// - /// Gets the property to work with image patch code max search retries for the current source. - /// - /// - /// The image patch code max search retries. - /// - public ICapWrapper ICapPatchCodeMaxRetries - { - get - { - return _patchCodeMaxRetries ?? (_patchCodeMaxRetries = new CapWrapper(_source, CapabilityId.ICapPatchCodeMaxRetries, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = value, - ItemType = ItemType.UInt32 - })); - } - } - - private CapWrapper _patchCodeTimeout; - - /// - /// Gets the property to work with image patch code max search timeout for the current source. - /// - /// - /// The image patch code max search timeout. - /// - public ICapWrapper ICapPatchCodeTimeout - { - get - { - return _patchCodeTimeout ?? (_patchCodeTimeout = new CapWrapper(_source, CapabilityId.ICapPatchCodeTimeout, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = value, - ItemType = ItemType.UInt32 - })); - } - } - - private CapWrapper _flashUsed2; - - /// - /// Gets the property to work with flash option for the current source. - /// - /// - /// The flash option. - /// - public ICapWrapper ICapFlashUsed2 - { - get - { - return _flashUsed2 ?? (_flashUsed2 = new CapWrapper(_source, CapabilityId.ICapFlashUsed2, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _imgFilter; - - /// - /// Gets the property to work with image enhancement filter for the current source. - /// - /// - /// The image enhancement filter. - /// - public ICapWrapper ICapImageFilter - { - get - { - return _imgFilter ?? (_imgFilter = new CapWrapper(_source, CapabilityId.ICapImageFilter, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _noiseFilter; - - /// - /// Gets the property to work with image noise filter for the current source. - /// - /// - /// The image noise filter. - /// - public ICapWrapper ICapNoiseFilter - { - get - { - return _noiseFilter ?? (_noiseFilter = new CapWrapper(_source, CapabilityId.ICapNoiseFilter, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _overscan; - - /// - /// Gets the property to work with image overscan option for the current source. - /// - /// - /// The image overscan option. - /// - public ICapWrapper ICapOverScan - { - get - { - return _overscan ?? (_overscan = new CapWrapper(_source, CapabilityId.ICapOverScan, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _borderDetect; - - /// - /// Gets the property to work with auto border detection flag for the current source. - /// - /// - /// The auto border detection flag. - /// - public ICapWrapper ICapAutomaticBorderDetection - { - get - { - return _borderDetect ?? (_borderDetect = new CapWrapper(_source, CapabilityId.ICapAutomaticBorderDetection, ValueExtensions.ConvertToEnum, - value => - { - var rc = ReturnCode.Failure; - - var one = new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - }; - - // this needs to also set undefined size optino - rc = ICapUndefinedImageSize.SetValue(value); - using (TWCapability capValue = new TWCapability(CapabilityId.ICapAutomaticBorderDetection, one)) - { - rc = _source.DGControl.Capability.Set(capValue); - } - - return rc; - })); - } - } - - private CapWrapper _autoDeskew; - - /// - /// Gets the property to work with image auto deskew flag for the current source. - /// - /// - /// The image auto deskew flag. - /// - public ICapWrapper ICapAutomaticDeskew - { - get - { - return _autoDeskew ?? (_autoDeskew = new CapWrapper(_source, CapabilityId.ICapAutomaticDeskew, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _autoRotate; - - /// - /// Gets the property to work with image auto rotate flag for the current source. - /// - /// - /// The image auto rotate flag. - /// - public ICapWrapper ICapAutomaticRotate - { - get - { - return _autoRotate ?? (_autoRotate = new CapWrapper(_source, CapabilityId.ICapAutomaticRotate, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _jpegQuality; - - /// - /// Gets the property to work with image jpeg quality for the current source. - /// - /// - /// The image jpeg quality. - /// - public ICapWrapper ICapJpegQuality - { - get - { - //TODO: verify - return _jpegQuality ?? (_jpegQuality = new CapWrapper(_source, CapabilityId.ICapJpegQuality, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Int16 - })); - } - } - - private CapWrapper _feederType; - - /// - /// Gets the property to work with feeder type for the current source. - /// - /// - /// The feeder type. - /// - public ICapWrapper ICapFeederType - { - get - { - return _feederType ?? (_feederType = new CapWrapper(_source, CapabilityId.ICapFeederType, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _iccProfile; - - /// - /// Gets the property to work with image icc profile for the current source. - /// - /// - /// The image icc profile. - /// - public ICapWrapper ICapICCProfile - { - get - { - return _iccProfile ?? (_iccProfile = new CapWrapper(_source, CapabilityId.ICapICCProfile, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _autoSize; - - /// - /// Gets the property to work with image auto size option for the current source. - /// - /// - /// The image auto size option. - /// - public ICapWrapper ICapAutoSize - { - get - { - return _autoSize ?? (_autoSize = new CapWrapper(_source, CapabilityId.ICapAutoSize, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _cropUseFrame; - - /// - /// Gets the property to work with image auto crop flag for the current source. - /// - /// - /// The image auto crop flag. - /// - public IReadOnlyCapWrapper ICapAutomaticCropUsesFrame - { - get - { - return _cropUseFrame ?? (_cropUseFrame = new CapWrapper(_source, CapabilityId.ICapAutomaticCropUsesFrame, ValueExtensions.ConvertToEnum, true)); - } - } - - private CapWrapper _lengthDetect; - - /// - /// Gets the property to work with image auto length detection flag for the current source. - /// - /// - /// The image auto length detection flag. - /// - public ICapWrapper ICapAutomaticLengthDetection - { - get - { - return _lengthDetect ?? (_lengthDetect = new CapWrapper(_source, CapabilityId.ICapAutomaticLengthDetection, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _autoColor; - - /// - /// Gets the property to work with image auto color detection flag for the current source. - /// - /// - /// The image auto color detection flag. - /// - public ICapWrapper ICapAutomaticColorEnabled - { - get - { - return _autoColor ?? (_autoColor = new CapWrapper(_source, CapabilityId.ICapAutomaticColorEnabled, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _autoColorNonPixel; - - /// - /// Gets the property to work with image auto non-color pixel type for the current source. - /// - /// - /// The image auto non-color pixel type. - /// - public ICapWrapper ICapAutomaticColorNonColorPixelType - { - get - { - return _autoColorNonPixel ?? (_autoColorNonPixel = new CapWrapper(_source, CapabilityId.ICapAutomaticColorNonColorPixelType, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _colorMgmt; - - /// - /// Gets the property to work with image color management flag for the current source. - /// - /// - /// The image color management flag. - /// - public ICapWrapper ICapColorManagementEnabled - { - get - { - return _colorMgmt ?? (_colorMgmt = new CapWrapper(_source, CapabilityId.ICapColorManagementEnabled, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _imgMerge; - - /// - /// Gets the property to work with image merge option for the current source. - /// - /// - /// The image merge option. - /// - public ICapWrapper ICapImageMerge - { - get - { - return _imgMerge ?? (_imgMerge = new CapWrapper(_source, CapabilityId.ICapImageMerge, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _mergeHeight; - - /// - /// Gets the property to work with image merge height threshold for the current source. - /// - /// - /// The image merge height threshold. - /// - public ICapWrapper ICapImageMergeHeightThreshold - { - get - { - return _mergeHeight ?? (_mergeHeight = new CapWrapper(_source, CapabilityId.ICapImageMergeHeightThreshold, ValueExtensions.ConvertToFix32, value => value.ToOneValue())); - } - } - - private CapWrapper _supportedExtInfo; - - /// - /// Gets the property to get supported ext image info for the current source. - /// - /// - /// The supported ext image info. - /// - public IReadOnlyCapWrapper ICapSupportedExtImageInfo - { - get - { - return _supportedExtInfo ?? (_supportedExtInfo = new CapWrapper(_source, CapabilityId.ICapSupportedExtImageInfo, ValueExtensions.ConvertToEnum, true)); - } - } - - private CapWrapper _filmType; - - /// - /// Gets the property to work with image film type for the current source. - /// - /// - /// The image film type. - /// - public ICapWrapper ICapFilmType - { - get - { - return _filmType ?? (_filmType = new CapWrapper(_source, CapabilityId.ICapFilmType, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _mirror; - - /// - /// Gets the property to work with image mirror option for the current source. - /// - /// - /// The image mirror option. - /// - public ICapWrapper ICapMirror - { - get - { - return _mirror ?? (_mirror = new CapWrapper(_source, CapabilityId.ICapMirror, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _jpegSubSampling; - - /// - /// Gets the property to work with image jpeg sub sampling for the current source. - /// - /// - /// The image jpeg sub sampling. - /// - public ICapWrapper ICapJpegSubsampling - { - get - { - return _jpegSubSampling ?? (_jpegSubSampling = new CapWrapper(_source, CapabilityId.ICapJpegSubsampling, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - #endregion - - #region general caps - - #region mandatory - - private CapWrapper _xferCount; - - /// - /// Gets the property to work with xfer count for the current source. - /// - /// - /// The xfer count. - /// - public ICapWrapper CapXferCount - { - get - { - return _xferCount ?? (_xferCount = new CapWrapper(_source, CapabilityId.CapXferCount, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = value > 0 ? (uint)value : uint.MaxValue, - ItemType = ItemType.Int16 - })); - } - } - - #endregion - - private CapWrapper _author; - - /// - /// Gets the property to work with the name or other identifying information about the - /// Author of the image. It may include a copyright string. - /// - /// - /// The author string. - /// - public ICapWrapper CapAuthor - { - get - { - return _author ?? (_author = new CapWrapper(_source, CapabilityId.CapAuthor, ValueExtensions.ConvertToString, - value => - { - using (var cap = new TWCapability(CapabilityId.CapAuthor, value, ItemType.String128)) - { - return _source.DGControl.Capability.Set(cap); - } - })); - } - } - - - private CapWrapper _caption; - - /// - /// Gets the property to work with the general note about the acquired image. - /// - /// - /// The general note string. - /// - public ICapWrapper CapCaption - { - get - { - return _caption ?? (_caption = new CapWrapper(_source, CapabilityId.CapCaption, ValueExtensions.ConvertToString, - value => - { - using (var cap = new TWCapability(CapabilityId.CapCaption, value, ItemType.String255)) - { - return _source.DGControl.Capability.Set(cap); - } - })); - } - } - - private CapWrapper _feederEnabled; - - /// - /// Gets the property to work with feeder enabled flag for the current source. - /// - /// - /// The feeder enabled flag. - /// - public ICapWrapper CapFeederEnabled - { - get - { - return _feederEnabled ?? (_feederEnabled = new CapWrapper(_source, CapabilityId.CapFeederEnabled, ValueExtensions.ConvertToEnum, - value => - { - var rc = ReturnCode.Failure; - - var one = new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - }; - - using (TWCapability enabled = new TWCapability(CapabilityId.CapFeederEnabled, one)) - { - rc = _source.DGControl.Capability.Set(enabled); - } - - // to really use feeder we must also set autofeed or autoscan, but only - // for one of them since setting autoscan also sets autofeed - if (CapAutoScan.CanSet) - { - rc = CapAutoScan.SetValue(value); - } - else if (CapAutoFeed.CanSet) - { - rc = CapAutoFeed.SetValue(value); - } - - return rc; - })); - } - } - - private CapWrapper _feederLoaded; - - /// - /// Gets the property to work with feeder loaded flag for the current source. - /// - /// - /// The feeder loaded flag. - /// - public IReadOnlyCapWrapper CapFeederLoaded - { - get - { - return _feederLoaded ?? (_feederLoaded = new CapWrapper(_source, CapabilityId.CapFeederLoaded, ValueExtensions.ConvertToEnum, true)); - } - } - - private CapWrapper _timedate; - - /// - /// Gets the property to get the image acquired time and date. - /// - /// - /// The time and date string. - /// - public IReadOnlyCapWrapper CapTimeDate - { - get - { - return _timedate ?? (_timedate = new CapWrapper(_source, CapabilityId.CapTimeDate, ValueExtensions.ConvertToString, true)); - } - } - - private CapWrapper _supportedCaps; - - /// - /// Gets the supported caps for the current source. This is not supported by all sources. - /// - /// - /// The supported caps. - /// - public IReadOnlyCapWrapper CapSupportedCaps - { - get - { - return _supportedCaps ?? (_supportedCaps = new CapWrapper(_source, CapabilityId.CapSupportedCaps, value => value.ConvertToEnum(false), true)); - } - } - - private CapWrapper _extendedCaps; - - /// - /// Gets the extended caps for the current source. - /// - /// - /// The extended caps. - /// - public ICapWrapper CapExtendedCaps - { - get - { - return _extendedCaps ?? (_extendedCaps = new CapWrapper(_source, CapabilityId.CapExtendedCaps, value => value.ConvertToEnum(false), - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _autoFeed; - - /// - /// Gets the property to work with auto feed page flag for the current source. - /// - /// - /// The auto feed flag. - /// - public ICapWrapper CapAutoFeed - { - get - { - return _autoFeed ?? (_autoFeed = new CapWrapper(_source, CapabilityId.CapAutoFeed, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _clearPage; - - /// - /// Gets the property to work with clear page flag for the current source. - /// - /// - /// The clear page flag. - /// - public ICapWrapper CapClearPage - { - get - { - return _clearPage ?? (_clearPage = new CapWrapper(_source, CapabilityId.CapClearPage, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _feedPage; - - /// - /// Gets the property to work with feed page flag for the current source. - /// - /// - /// The feed page flag. - /// - public ICapWrapper CapFeedPage - { - get - { - return _feedPage ?? (_feedPage = new CapWrapper(_source, CapabilityId.CapFeedPage, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _rewindPage; - - /// - /// Gets the property to work with rewind page flag for the current source. - /// - /// - /// The rewind page flag. - /// - public ICapWrapper CapRewindPage - { - get - { - return _rewindPage ?? (_rewindPage = new CapWrapper(_source, CapabilityId.CapRewindPage, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _indicators; - - /// - /// Gets the property to work with indicators flag for the current source. - /// - /// - /// The indicators flag. - /// - public ICapWrapper CapIndicators - { - get - { - return _indicators ?? (_indicators = new CapWrapper(_source, CapabilityId.CapIndicators, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _paperDetectable; - - /// - /// Gets the property to work with paper sensor flag for the current source. - /// - /// - /// The paper sensor flag. - /// - public IReadOnlyCapWrapper CapPaperDetectable - { - get - { - return _paperDetectable ?? (_paperDetectable = new CapWrapper(_source, CapabilityId.CapPaperDetectable, ValueExtensions.ConvertToEnum, true)); - } - } - - private CapWrapper _uiControllable; - - /// - /// Gets the property to work with UI controllable flag for the current source. - /// - /// - /// The UI controllable flag. - /// - public IReadOnlyCapWrapper CapUIControllable - { - get - { - return _uiControllable ?? (_uiControllable = new CapWrapper(_source, CapabilityId.CapUIControllable, ValueExtensions.ConvertToEnum, true)); - } - } - - private CapWrapper _devOnline; - - /// - /// Gets the property to work with devince online flag for the current source. - /// - /// - /// The devince online flag. - /// - public IReadOnlyCapWrapper CapDeviceOnline - { - get - { - return _devOnline ?? (_devOnline = new CapWrapper(_source, CapabilityId.CapDeviceOnline, ValueExtensions.ConvertToEnum, true)); - } - } - - private CapWrapper _autoScan; - - /// - /// Gets the property to work with auto scan page flag for the current source. - /// - /// - /// The auto scan flag. - /// - public ICapWrapper CapAutoScan - { - get - { - return _autoScan ?? (_autoScan = new CapWrapper(_source, CapabilityId.CapAutoScan, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _thumbsEnabled; - - /// - /// Gets the property to work with thumbnails enabled flag for the current source. - /// - /// - /// The thumbnails enabled flag. - /// - public ICapWrapper CapThumbnailsEnabled - { - get - { - return _thumbsEnabled ?? (_thumbsEnabled = new CapWrapper(_source, CapabilityId.CapThumbnailsEnabled, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _duplex; - - /// - /// Gets the property to see what's the duplex mode for the current source. - /// - /// - /// The duplex mode. - /// - public IReadOnlyCapWrapper CapDuplex - { - get - { - return _duplex ?? (_duplex = new CapWrapper(_source, CapabilityId.CapDuplex, ValueExtensions.ConvertToEnum, true)); - } - } - - private CapWrapper _duplexEnabled; - - /// - /// Gets the property to work with duplex enabled flag for the current source. - /// - /// - /// The duplex enabled flag. - /// - public ICapWrapper CapDuplexEnabled - { - get - { - return _duplexEnabled ?? (_duplexEnabled = new CapWrapper(_source, CapabilityId.CapDuplexEnabled, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _dsUIonly; - - /// - /// Gets the property to see whether device supports UI only flag (no transfer). - /// - /// - /// The UI only flag. - /// - public IReadOnlyCapWrapper CapEnableDSUIOnly - { - get - { - return _dsUIonly ?? (_dsUIonly = new CapWrapper(_source, CapabilityId.CapEnableDSUIOnly, ValueExtensions.ConvertToEnum, true)); - } - } - - private CapWrapper _dsData; - - /// - /// Gets the property to see whether device supports custom data triplets. - /// - /// - /// The custom data flag. - /// - public IReadOnlyCapWrapper CapCustomDSData - { - get - { - return _dsData ?? (_dsData = new CapWrapper(_source, CapabilityId.CapCustomDSData, ValueExtensions.ConvertToEnum, true)); - } - } - - private CapWrapper _endorser; - - /// - /// Gets the property to work with endorser for the current source. - /// - /// - /// The endorser option. - /// - public ICapWrapper CapEndorser - { - get - { - return _endorser ?? (_endorser = new CapWrapper(_source, CapabilityId.CapEndorser, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = value, - ItemType = ItemType.UInt32 - })); - } - } - - private CapWrapper _jobControl; - - /// - /// Gets the property to work with job control option for the current source. - /// - /// - /// The job control option. - /// - public ICapWrapper CapJobControl - { - get - { - return _jobControl ?? (_jobControl = new CapWrapper(_source, CapabilityId.CapJobControl, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _alarms; - - /// - /// Gets the property to work with alarms for the current source. - /// - /// - /// The alarms. - /// - public ICapWrapper CapAlarms - { - get - { - return _alarms ?? (_alarms = new CapWrapper(_source, CapabilityId.CapAlarms, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _alarmVolume; - - /// - /// Gets the property to work with alarm volume for the current source. - /// - /// - /// The alarm volume. - /// - public ICapWrapper CapAlarmVolume - { - get - { - return _alarmVolume ?? (_alarmVolume = new CapWrapper(_source, CapabilityId.CapAlarmVolume, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Int32 - })); - } - } - - private CapWrapper _autoCapture; - - /// - /// Gets the property to work with auto capture count for the current source. - /// - /// - /// The auto capture count. - /// - public ICapWrapper CapAutomaticCapture - { - get - { - return _autoCapture ?? (_autoCapture = new CapWrapper(_source, CapabilityId.CapAutomaticCapture, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Int32 - })); - } - } - - private CapWrapper _timeBeforeCap; - - /// - /// Gets the property to work with the time before first capture (milliseconds) for the current source. - /// - /// - /// The time before first capture. - /// - public ICapWrapper CapTimeBeforeFirstCapture - { - get - { - return _timeBeforeCap ?? (_timeBeforeCap = new CapWrapper(_source, CapabilityId.CapTimeBeforeFirstCapture, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Int32 - })); - } - } - - private CapWrapper _timeBetweenCap; - - /// - /// Gets the property to work with the time between captures (milliseconds) for the current source. - /// - /// - /// The time between captures. - /// - public ICapWrapper CapTimeBetweenCaptures - { - get - { - return _timeBetweenCap ?? (_timeBetweenCap = new CapWrapper(_source, CapabilityId.CapTimeBetweenCaptures, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Int32 - })); - } - } - - private CapWrapper _clearBuff; - - /// - /// Gets the property to work with the clear buffers option for the current source. - /// - /// - /// The clear buffers option. - /// - public ICapWrapper CapClearBuffers - { - get - { - return _clearBuff ?? (_clearBuff = new CapWrapper(_source, CapabilityId.CapClearBuffers, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _maxBatchBuff; - - /// - /// Gets the property to work with the max buffered pages for the current source. - /// - /// - /// The max batch buffered pages. - /// - public ICapWrapper CapMaxBatchBuffers - { - get - { - return _maxBatchBuff ?? (_maxBatchBuff = new CapWrapper(_source, CapabilityId.CapMaxBatchBuffers, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = value, - ItemType = ItemType.UInt32 - })); - } - } - - private CapWrapper _devTimeDate; - - /// - /// Gets the property to work with the device's time and date. - /// - /// - /// The device time and date. - /// - public ICapWrapper CapDeviceTimeDate - { - get - { - return _devTimeDate ?? (_devTimeDate = new CapWrapper(_source, CapabilityId.CapDeviceTimeDate, ValueExtensions.ConvertToString, - value => - { - using (var cap = new TWCapability(CapabilityId.CapDeviceTimeDate, value, ItemType.String32)) - { - return _source.DGControl.Capability.Set(cap); - } - })); - } - } - - private CapWrapper _powerSup; - - /// - /// Gets the property to see current device's power supply. - /// - /// - /// The power supply indicator. - /// - public IReadOnlyCapWrapper CapPowerSupply - { - get - { - return _powerSup ?? (_powerSup = new CapWrapper(_source, CapabilityId.CapPowerSupply, ValueExtensions.ConvertToEnum, true)); - } - } - - private CapWrapper _camPreviewUI; - - /// - /// Gets the property to see whether device supports camera preview UI flag. - /// - /// - /// The camera preview UI flag. - /// - public IReadOnlyCapWrapper CapCameraPreviewUI - { - get - { - return _camPreviewUI ?? (_camPreviewUI = new CapWrapper(_source, CapabilityId.CapCameraPreviewUI, ValueExtensions.ConvertToEnum, true)); - } - } - - private CapWrapper _devEvent; - - /// - /// Gets the property to work with the reported device events for the current source. - /// - /// - /// The reported device events. - /// - public ICapWrapper CapDeviceEvent - { - get - { - return _devEvent ?? (_devEvent = new CapWrapper(_source, CapabilityId.CapDeviceEvent, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _serialNo; - - /// - /// Gets the property for device serial number. - /// - /// - /// The device serial number. - /// - public IReadOnlyCapWrapper CapSerialNumber - { - get - { - return _serialNo ?? (_serialNo = new CapWrapper(_source, CapabilityId.CapSerialNumber, ValueExtensions.ConvertToString, true)); - } - } - - private CapWrapper _printer; - - /// - /// Gets the property to work with printer list for the current source. - /// - /// - /// The printer list. - /// - public ICapWrapper CapPrinter - { - get - { - return _printer ?? (_printer = new CapWrapper(_source, CapabilityId.CapPrinter, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _printerEnabled; - - /// - /// Gets the property to work with printer enabled flag. - /// - /// - /// The printer enabled flag. - /// - public ICapWrapper CapPrinterEnabled - { - get - { - return _printerEnabled ?? (_printerEnabled = new CapWrapper(_source, CapabilityId.CapPrinterEnabled, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _printerIndex; - - /// - /// Gets the property to work with the starting printer index for the current source. - /// - /// - /// The printer index. - /// - public ICapWrapper CapPrinterIndex - { - get - { - return _printerIndex ?? (_printerIndex = new CapWrapper(_source, CapabilityId.CapPrinterIndex, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt32 - })); - } - } - - private CapWrapper _printerMode; - - /// - /// Gets the property to work with printer mode for the current source. - /// - /// - /// The printer mode. - /// - public ICapWrapper CapPrinterMode - { - get - { - return _printerMode ?? (_printerMode = new CapWrapper(_source, CapabilityId.CapPrinterMode, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _printerString; - - /// - /// Specifies the string(s) that are to be used in the string component when the current - /// device is enabled. - /// - /// - /// The printer string. - /// - public ICapWrapper CapPrinterString - { - get - { - return _printerString ?? (_printerString = new CapWrapper(_source, CapabilityId.CapPrinterString, ValueExtensions.ConvertToString, - value => - { - using (var cap = new TWCapability(CapabilityId.CapPrinterString, value, ItemType.String255)) - { - return _source.DGControl.Capability.Set(cap); - } - })); - } - } - - private CapWrapper _printerSuffix; - - /// - /// Specifies the string that shall be used as the current device’s suffix. - /// - /// - /// The printer suffix string. - /// - public ICapWrapper CapPrinterSuffix - { - get - { - return _printerSuffix ?? (_printerSuffix = new CapWrapper(_source, CapabilityId.CapPrinterSuffix, ValueExtensions.ConvertToString, - value => - { - using (var cap = new TWCapability(CapabilityId.CapPrinterSuffix, value, ItemType.String255)) - { - return _source.DGControl.Capability.Set(cap); - } - })); - } - } - - private CapWrapper _language; - - /// - /// Gets the property to work with string data language for the current source. - /// - /// - /// The language. - /// - public ICapWrapper CapLanguage - { - get - { - return _language ?? (_language = new CapWrapper(_source, CapabilityId.CapLanguage, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _feedAlign; - - /// - /// Gets the property to work with feeder alignment for the current source. - /// - /// - /// The feeder alignment. - /// - public ICapWrapper CapFeederAlignment - { - get - { - return _feedAlign ?? (_feedAlign = new CapWrapper(_source, CapabilityId.CapFeederAlignment, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _feedOrder; - - /// - /// Gets the property to work with feeder order for the current source. - /// - /// - /// The feeder order. - /// - public ICapWrapper CapFeederOrder - { - get - { - return _feedOrder ?? (_feedOrder = new CapWrapper(_source, CapabilityId.CapFeederOrder, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _reacuireAllow; - - /// - /// Gets the property to see whether device supports reacquire flag. - /// - /// - /// The reacquire flag. - /// - public IReadOnlyCapWrapper CapReacquireAllowed - { - get - { - return _reacuireAllow ?? (_reacuireAllow = new CapWrapper(_source, CapabilityId.CapReacquireAllowed, ValueExtensions.ConvertToEnum, true)); - } - } - - private CapWrapper _battMinutes; - - /// - /// Gets the property to see the remaining battery power for the device. - /// - /// - /// The battery minutes. - /// - public IReadOnlyCapWrapper CapBatteryMinutes - { - get - { - return _battMinutes ?? (_battMinutes = new CapWrapper(_source, CapabilityId.CapBatteryMinutes, ValueExtensions.ConvertToEnum, true)); - } - } - - private CapWrapper _battPercent; - - /// - /// Gets the property to see the remaining battery percentage for the device. - /// - /// - /// The battery percentage. - /// - public IReadOnlyCapWrapper CapBatteryPercentage - { - get - { - return _battPercent ?? (_battPercent = new CapWrapper(_source, CapabilityId.CapBatteryPercentage, ValueExtensions.ConvertToEnum, true)); - } - } - - private CapWrapper _camSide; - - /// - /// Gets the property to work with camera side for the current source. - /// - /// - /// The camera side. - /// - public ICapWrapper CapCameraSide - { - get - { - return _camSide ?? (_camSide = new CapWrapper(_source, CapabilityId.CapCameraSide, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _segmented; - - /// - /// Gets the property to work with segmentation setting for the current source. - /// - /// - /// The segmentation setting. - /// - public ICapWrapper CapSegmented - { - get - { - return _segmented ?? (_segmented = new CapWrapper(_source, CapabilityId.CapSegmented, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _camEnabled; - - /// - /// Gets the property to work with camera enabled flag. - /// - /// - /// The camera enabled flag. - /// - public ICapWrapper CapCameraEnabled - { - get - { - return _camEnabled ?? (_camEnabled = new CapWrapper(_source, CapabilityId.CapCameraEnabled, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _camOrder; - - /// - /// Gets the property to work with camera order for the current source. - /// - /// - /// The camera order setting. - /// - public ICapWrapper CapCameraOrder - { - get - { - return _camOrder ?? (_camOrder = new CapWrapper(_source, CapabilityId.CapCameraOrder, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _micrEnabled; - - /// - /// Gets the property to work with check scanning support flag. - /// - /// - /// The check scanning support flag. - /// - public ICapWrapper CapMicrEnabled - { - get - { - return _micrEnabled ?? (_micrEnabled = new CapWrapper(_source, CapabilityId.CapMicrEnabled, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _feederPrep; - - /// - /// Gets the property to work with feeder prep flag. - /// - /// - /// The feeder prep flag. - /// - public ICapWrapper CapFeederPrep - { - get - { - return _feederPrep ?? (_feederPrep = new CapWrapper(_source, CapabilityId.CapFeederPrep, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _feedPocket; - - /// - /// Gets the property to work with feeder pocket for the current source. - /// - /// - /// The feeder pocket setting. - /// - public ICapWrapper CapFeederPocket - { - get - { - return _feedPocket ?? (_feedPocket = new CapWrapper(_source, CapabilityId.CapFeederPocket, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _autoMedium; - - /// - /// Gets the property to work with auto-sense medium (paper source) flag. - /// - /// - /// The auto-sense medium flag. - /// - public ICapWrapper CapAutomaticSenseMedium - { - get - { - return _autoMedium ?? (_autoMedium = new CapWrapper(_source, CapabilityId.CapAutomaticSenseMedium, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _custGuid; - - /// - /// Gets the property for device interface guid. - /// - /// - /// The device interface guid. - /// - public IReadOnlyCapWrapper CapCustomInterfaceGuid - { - get - { - return _custGuid ?? (_custGuid = new CapWrapper(_source, CapabilityId.CapCustomInterfaceGuid, ValueExtensions.ConvertToString, true)); - } - } - - private CapWrapper _supportedCapsUnique; - - /// - /// Gets the supported caps for unique segments for the current source. - /// - /// - /// The supported caps for unique segments. - /// - public IReadOnlyCapWrapper CapSupportedCapsSegmentUnique - { - get - { - return _supportedCapsUnique ?? (_supportedCapsUnique = new CapWrapper(_source, CapabilityId.CapSupportedCapsSegmentUnique, value => value.ConvertToEnum(false), true)); - } - } - - private CapWrapper _supportedDat; - - /// - /// Gets the supported caps for supported DATs. - /// - /// - /// The supported DATs. - /// - public IReadOnlyCapWrapper CapSupportedDATs - { - get - { - return _supportedDat ?? (_supportedDat = new CapWrapper(_source, CapabilityId.CapSupportedDATs, ValueExtensions.ConvertToEnum, true)); - } - } - - private CapWrapper _dblFeedDetect; - - /// - /// Gets the property to work with double feed detection option for the current source. - /// - /// - /// The double feed detection option. - /// - public ICapWrapper CapDoubleFeedDetection - { - get - { - return _dblFeedDetect ?? (_dblFeedDetect = new CapWrapper(_source, CapabilityId.CapDoubleFeedDetection, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _dblFeedLength; - - /// - /// Gets the property to work with double feed detection length for the current source. - /// - /// - /// The double feed detection length. - /// - public ICapWrapper CapDoubleFeedDetectionLength - { - get - { - return _dblFeedLength ?? (_dblFeedLength = new CapWrapper(_source, CapabilityId.CapDoubleFeedDetectionLength, ValueExtensions.ConvertToFix32, value => value.ToOneValue())); - } - } - - private CapWrapper _dblFeedSensitivity; - - /// - /// Gets the property to work with double feed detection sensitivity for the current source. - /// - /// - /// The double feed detection sensitivity. - /// - public ICapWrapper CapDoubleFeedDetectionSensitivity - { - get - { - return _dblFeedSensitivity ?? (_dblFeedSensitivity = new CapWrapper(_source, CapabilityId.CapDoubleFeedDetectionSensitivity, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _dblFeedResp; - - /// - /// Gets the property to work with double feed detection response for the current source. - /// - /// - /// The double feed detection response. - /// - public ICapWrapper CapDoubleFeedDetectionResponse - { - get - { - return _dblFeedResp ?? (_dblFeedResp = new CapWrapper(_source, CapabilityId.CapDoubleFeedDetectionResponse, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _paperHandling; - - /// - /// Gets the property to work with paper handling option for the current source. - /// - /// - /// The paper handling option. - /// - public ICapWrapper CapPaperHandling - { - get - { - return _paperHandling ?? (_paperHandling = new CapWrapper(_source, CapabilityId.CapPaperHandling, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _indicatorMode; - - /// - /// Gets the property to work with diplayed indicators for the current source. - /// - /// - /// The diplayed indicators. - /// - public ICapWrapper CapIndicatorsMode - { - get - { - return _indicatorMode ?? (_indicatorMode = new CapWrapper(_source, CapabilityId.CapIndicatorsMode, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt16 - })); - } - } - - private CapWrapper _printVOffset; - - /// - /// Gets the property to work with printer y-offset for the current source. - /// - /// - /// The printer y-offset. - /// - public ICapWrapper CapPrinterVerticalOffset - { - get - { - return _printVOffset ?? (_printVOffset = new CapWrapper(_source, CapabilityId.CapPrinterVerticalOffset, ValueExtensions.ConvertToFix32, value => value.ToOneValue())); - } - } - - private CapWrapper _powerSaveTime; - - /// - /// Gets the property to work with camera power down time (seconds) for the current source. - /// - /// - /// The camera power down time. - /// - public ICapWrapper CapPowerSaveTime - { - get - { - return _powerSaveTime ?? (_powerSaveTime = new CapWrapper(_source, CapabilityId.CapPowerSaveTime, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Int32 - })); - } - } - - private CapWrapper _printCharRot; - - /// - /// Gets the property to work with printer character rotation for the current source. - /// - /// - /// The printer character rotation. - /// - public ICapWrapper CapPrinterCharRotation - { - get - { - return _printCharRot ?? (_printCharRot = new CapWrapper(_source, CapabilityId.CapPrinterCharRotation, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt32 - })); - } - } - - private CapWrapper _printFontStyle; - - /// - /// Gets the property to work with printer font style for the current source. - /// - /// - /// The printer font style. - /// - public ICapWrapper CapPrinterFontStyle - { - get - { - return _printFontStyle ?? (_printFontStyle = new CapWrapper(_source, CapabilityId.CapPrinterFontStyle, ValueExtensions.ConvertToEnum, false)); - } - } - - private CapWrapper _printerIdxLeadChar; - - /// - /// Set the character to be used for filling the leading digits before the counter value if the - /// counter digits are fewer than . - /// - /// - /// The printer leading string. - /// - public ICapWrapper CapPrinterIndexLeadChar - { - get - { - return _printerIdxLeadChar ?? (_printerIdxLeadChar = new CapWrapper(_source, CapabilityId.CapPrinterIndexLeadChar, ValueExtensions.ConvertToString, - value => - { - using (var cap = new TWCapability(CapabilityId.CapPrinterIndexLeadChar, value, ItemType.String32)) - { - return _source.DGControl.Capability.Set(cap); - } - })); - } - } - - private CapWrapper _printIdxMax; - - /// - /// Gets the property to work with printer index max value for the current source. - /// - /// - /// The printer index max value. - /// - public ICapWrapper CapPrinterIndexMaxValue - { - get - { - return _printIdxMax ?? (_printIdxMax = new CapWrapper(_source, CapabilityId.CapPrinterIndexMaxValue, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = value, - ItemType = ItemType.UInt32 - })); - } - } - - private CapWrapper _printNumDigit; - - /// - /// Gets the property to work with printer number digits value for the current source. - /// - /// - /// The printer number digits value. - /// - public ICapWrapper CapPrinterIndexNumDigits - { - get - { - return _printNumDigit ?? (_printNumDigit = new CapWrapper(_source, CapabilityId.CapPrinterIndexNumDigits, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt32 - })); - } - } - - private CapWrapper _printIdxStep; - - /// - /// Gets the property to work with printer index step value for the current source. - /// - /// - /// The printer index step value. - /// - public ICapWrapper CapPrinterIndexStep - { - get - { - return _printIdxStep ?? (_printIdxStep = new CapWrapper(_source, CapabilityId.CapPrinterIndexStep, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.UInt32 - })); - } - } - - private CapWrapper _printIdxTrig; - - /// - /// Gets the property to work with printer index trigger for the current source. - /// - /// - /// The printer index trigger. - /// - public ICapWrapper CapPrinterIndexTrigger - { - get - { - return _printIdxTrig ?? (_printIdxTrig = new CapWrapper(_source, CapabilityId.CapPrinterIndexTrigger, ValueExtensions.ConvertToEnum, false)); - } - } - - private CapWrapper _printPreview; - - /// - /// Gets the next print values. - /// - /// - /// The next print values. - /// - public IReadOnlyCapWrapper CapPrinterStringPreview - { - get - { - return _printPreview ?? (_printPreview = new CapWrapper(_source, CapabilityId.CapPrinterStringPreview, ValueExtensions.ConvertToString, true)); - } - } - - #endregion - - } -} diff --git a/src/NTwain/CapabilityReader.cs b/src/NTwain/CapabilityReader.cs deleted file mode 100644 index 9633427..0000000 --- a/src/NTwain/CapabilityReader.cs +++ /dev/null @@ -1,485 +0,0 @@ -using NTwain.Data; -using NTwain.Properties; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.Linq; -using System.Runtime.InteropServices; - -namespace NTwain -{ - /// - /// The one-stop class for reading raw TWAIN cap values from the cap container. - /// This contains all the properties for the 4 container types. - /// - public class CapabilityReader - { - /// - /// Reads the value from a that was returned - /// from a TWAIN source. - /// - /// The capability. - /// - /// capability - /// Capability contains no data.;capability - /// or - /// capability - public static CapabilityReader ReadValue(TWCapability capability) - { - return ReadValue(capability, PlatformInfo.Current.MemoryManager); - } - - /// - /// Reads the value from a that was returned - /// from a TWAIN source. - /// - /// The capability. - /// The memory manager. - /// - /// - /// capability - /// or - /// memoryManager - /// - /// capability - public static CapabilityReader ReadValue(TWCapability capability, IMemoryManager memoryManager) - { - if (capability == null) { throw new ArgumentNullException("capability"); } - if (memoryManager == null) { throw new ArgumentNullException("memoryManager"); } - - if (capability.Container != IntPtr.Zero) - { - IntPtr baseAddr = IntPtr.Zero; - try - { - baseAddr = memoryManager.Lock(capability.Container); - switch (capability.ContainerType) - { - case ContainerType.Array: - return new CapabilityReader - { - ContainerType = capability.ContainerType, - }.ReadArrayValue(baseAddr); - case ContainerType.Enum: - return new CapabilityReader - { - ContainerType = capability.ContainerType, - }.ReadEnumValue(baseAddr); - case ContainerType.OneValue: - return new CapabilityReader - { - ContainerType = capability.ContainerType, - }.ReadOneValue(baseAddr); - case ContainerType.Range: - return new CapabilityReader - { - ContainerType = capability.ContainerType, - }.ReadRangeValue(baseAddr); - default: - throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, - Resources.CapHasBadContainer, capability.Capability, capability.ContainerType), "capability"); - } - } - finally - { - if (baseAddr != IntPtr.Zero) - { - //memoryManager.Unlock(baseAddr); - memoryManager.Unlock(capability.Container); - } - } - } - else - { - return new CapabilityReader(); - } - } - - /// - /// Initializes a new instance of the class. - /// - public CapabilityReader() - { - RangeCount = -1; - } - - #region common prop - - /// - /// Gets the underlying container type. - /// - /// - /// The container. - /// - public ContainerType ContainerType { get; private set; } - - /// - /// Gets the type of the TWAIN value. - /// - /// - /// The type of the value. - /// - public ItemType ItemType { get; private set; } - - /// - /// Gets the one value if container is . - /// - /// - /// The one value. - /// - public object OneValue { get; private set; } - - /// - /// Gets the collection values if container is or . - /// - /// - /// The collection values. - /// - public IList CollectionValues { get; private set; } - - #endregion - - #region enum prop - - /// - /// Gets the current value index if container is . - /// - public int EnumCurrentIndex { get; private set; } - /// - /// Gets the default value index if container is . - /// - public int EnumDefaultIndex { get; private set; } - - #endregion - - #region range prop - - /// - /// Gets the current value if container is . - /// - /// - /// The range current value. - /// - public object RangeCurrentValue { get; private set; } - /// - /// Gets the default value if container is . - /// - /// - /// The range default value. - /// - public object RangeDefaultValue { get; private set; } - /// - /// The least positive/most negative value of the range. - /// - /// - /// The range minimum value. - /// - public object RangeMinValue { get; private set; } - /// - /// The most positive/least negative value of the range. - /// - /// - /// The range maximum value. - /// - public object RangeMaxValue { get; private set; } - /// - /// The delta between two adjacent values of the range. - /// e.g. Item2 - Item1 = StepSize; - /// - /// - /// The size of the range step. - /// - public object RangeStepSize { get; private set; } - - /// - /// Gets the number of range values if range is expanded. - /// You should check for this before expanding range type containers to prevent - /// possible . - /// - /// - /// The range count. - /// - public int RangeCount { get; private set; } - - #endregion - - #region reader methods - - /// - /// Don't care what container it is, just enumerate the capability values. - /// - /// - public IEnumerable EnumerateCapValues() - { - switch (ContainerType) - { - case ContainerType.OneValue: - return EnumerateOneValue(); - case ContainerType.Array: - case ContainerType.Enum: - if (CollectionValues != null) - { - return CollectionValues; - } - break; - case ContainerType.Range: - return EnumerateRange(); - } - return Enumerable.Empty(); - } - - IEnumerable EnumerateOneValue() - { - if (OneValue != null) - { - yield return OneValue; - } - } - - IEnumerable EnumerateRange() - { - // horrible cast but should work. - // in the for loop we also compare against min in case the step - // is parsed as negative number and causes infinite loop. - switch (ItemType) - { - case Data.ItemType.Fix32: - { - var min = (TWFix32)RangeMinValue; - var max = (TWFix32)RangeMaxValue; - var step = (TWFix32)RangeStepSize; - - for (var i = min; i >= min && i <= max; i += step) - { - yield return i; - } - } - break; - case Data.ItemType.UInt32: - { - var min = (uint)RangeMinValue; - var max = (uint)RangeMaxValue; - var step = (uint)RangeStepSize; - - for (var i = min; i >= min && i <= max; i += step) - { - yield return i; - } - } - break; - case Data.ItemType.Int32: - { - var min = (int)RangeMinValue; - var max = (int)RangeMaxValue; - var step = (int)RangeStepSize; - - for (var i = min; i >= min && i <= max; i += step) - { - yield return i; - } - } - break; - // these should never happen since TW_RANGE fields are 4 bytes but you never know - case Data.ItemType.UInt16: - { - var min = (ushort)RangeMinValue; - var max = (ushort)RangeMaxValue; - var step = (ushort)RangeStepSize; - - for (var i = min; i >= min && i <= max; i += step) - { - yield return i; - } - } - break; - case Data.ItemType.Int16: - { - var min = (short)RangeMinValue; - var max = (short)RangeMaxValue; - var step = (short)RangeStepSize; - - for (var i = min; i >= min && i <= max; i += step) - { - yield return i; - } - } - break; - case Data.ItemType.UInt8: - { - var min = (byte)RangeMinValue; - var max = (byte)RangeMaxValue; - var step = (byte)RangeStepSize; - - for (var i = min; i >= min && i <= max; i += step) - { - yield return i; - } - } - break; - case Data.ItemType.Int8: - { - var min = (sbyte)RangeMinValue; - var max = (sbyte)RangeMaxValue; - var step = (sbyte)RangeStepSize; - - for (var i = min; i >= min && i <= max; i += step) - { - yield return i; - } - } - break; - } - } - - ///// - ///// Don't care what container it is, just populate the specified list with the capability values (count be one or many). - ///// - ///// The list to populate the values. - ///// - //public IList PopulateFromCapValues(IList toPopulate) - //{ - // if (toPopulate == null) { toPopulate = new List(); } - // foreach(var obj in EnumerateCapValues()) - // { - // toPopulate.Add(obj); - // } - // return toPopulate; - //} - - CapabilityReader ReadOneValue(IntPtr baseAddr) - { - int offset = 0; - ItemType = (ItemType)(ushort)Marshal.ReadInt16(baseAddr, offset); - offset += 2; - OneValue = baseAddr.ReadValue(ref offset, ItemType); - return this; - } - - CapabilityReader ReadArrayValue(IntPtr baseAddr) - { - int offset = 0; - ItemType = (ItemType)(ushort)Marshal.ReadInt16(baseAddr, offset); - offset += 2; - var count = Marshal.ReadInt32(baseAddr, offset); - offset += 4; - if (count > 0) - { - CollectionValues = new object[count]; - for (int i = 0; i < count; i++) - { - CollectionValues[i] = baseAddr.ReadValue(ref offset, ItemType); - } - } - return this; - } - - CapabilityReader ReadEnumValue(IntPtr baseAddr) - { - int offset = 0; - ItemType = (ItemType)(ushort)Marshal.ReadInt16(baseAddr, offset); - offset += 2; - int count = Marshal.ReadInt32(baseAddr, offset); - offset += 4; - EnumCurrentIndex = Marshal.ReadInt32(baseAddr, offset); - offset += 4; - EnumDefaultIndex = Marshal.ReadInt32(baseAddr, offset); - offset += 4; - if (count > 0) - { - CollectionValues = new object[count]; - for (int i = 0; i < count; i++) - { - CollectionValues[i] = baseAddr.ReadValue(ref offset, ItemType); - } - } - return this; - } - - CapabilityReader ReadRangeValue(IntPtr baseAddr) - { - int offset = 0; - ItemType = (ItemType)(ushort)Marshal.ReadInt16(baseAddr, offset); - offset += 2; - - RangeMinValue = baseAddr.ReadValue(ref offset, ItemType); - RangeMaxValue = baseAddr.ReadValue(ref offset, ItemType); - RangeStepSize = baseAddr.ReadValue(ref offset, ItemType); - RangeDefaultValue = baseAddr.ReadValue(ref offset, ItemType); - RangeCurrentValue = baseAddr.ReadValue(ref offset, ItemType); - - - // do range count - switch (ItemType) - { - case Data.ItemType.Fix32: - { - var min = (TWFix32)RangeMinValue; - var max = (TWFix32)RangeMaxValue; - var step = (TWFix32)RangeStepSize; - - RangeCount = (int)((max - min) / step) + 1; - } - break; - case Data.ItemType.UInt32: - { - var min = (uint)RangeMinValue; - var max = (uint)RangeMaxValue; - var step = (uint)RangeStepSize; - - RangeCount = (int)((max - min) / step) + 1; - } - break; - case Data.ItemType.Int32: - { - var min = (int)RangeMinValue; - var max = (int)RangeMaxValue; - var step = (int)RangeStepSize; - - RangeCount = ((max - min) / step) + 1; - } - break; - // these should never happen since TW_RANGE fields are 4 bytes but you never know - case Data.ItemType.UInt16: - { - var min = (ushort)RangeMinValue; - var max = (ushort)RangeMaxValue; - var step = (ushort)RangeStepSize; - - RangeCount = ((max - min) / step) + 1; - } - break; - case Data.ItemType.Int16: - { - var min = (short)RangeMinValue; - var max = (short)RangeMaxValue; - var step = (short)RangeStepSize; - - RangeCount = ((max - min) / step) + 1; - } - break; - case Data.ItemType.UInt8: - { - var min = (byte)RangeMinValue; - var max = (byte)RangeMaxValue; - var step = (byte)RangeStepSize; - - RangeCount = ((max - min) / step) + 1; - } - break; - case Data.ItemType.Int8: - { - var min = (sbyte)RangeMinValue; - var max = (sbyte)RangeMaxValue; - var step = (sbyte)RangeStepSize; - - RangeCount = ((max - min) / step) + 1; - } - break; - } - return this; - } - - #endregion - } -} diff --git a/src/NTwain/Data/TwainTypes.cs b/src/NTwain/Data/TwainTypes.cs deleted file mode 100644 index fba5a4f..0000000 --- a/src/NTwain/Data/TwainTypes.cs +++ /dev/null @@ -1,519 +0,0 @@ -// This file contains all the structs defined in the twain.h file. - -using System; -using System.Runtime.InteropServices; - -// The following TWAIN basic types are mapped with "using" -// to aid in mapping against the twain.h file using copy-paste. -// Consumers will not see those names. - -using TW_BOOL = System.UInt16; // unsigned short - -// use HandleRef instead? -using TW_HANDLE = System.IntPtr; // HANDLE, todo: should really be uintptr? -using TW_MEMREF = System.IntPtr; // LPVOID -using TW_UINTPTR = System.UIntPtr; // UINT_PTR - -using TW_INT16 = System.Int16; // short -using TW_INT32 = System.Int32; // long -using TW_INT8 = System.SByte; // char - -using TW_UINT16 = System.UInt16; // unsigned short -using TW_UINT32 = System.UInt32; // unsigned long -using TW_UINT8 = System.Byte; // unsigned char - - -// This mono doc is awesome. An interop must-read -// http://www.mono-project.com/Interop_with_Native_Libraries (old) -// http://www.mono-project.com/docs/advanced/pinvoke/ (new url) - -////////////////////////////////// -// Data structures that -// are passed to the TWAIN method -// are defined as classes to reduce -// ref/out in the low-level calls. -// Others continue to be structs. -////////////////////////////////// - - -namespace NTwain.Data -{ - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial struct TWFix32 - { - TW_INT16 _whole; - TW_UINT16 _frac; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial struct TWFrame - { - TWFix32 _left; - TWFix32 _top; - TWFix32 _right; - TWFix32 _bottom; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial struct TWDecodeFunction - { - TWFix32 _startIn; - TWFix32 _breakIn; - TWFix32 _endIn; - TWFix32 _startOut; - TWFix32 _breakOut; - TWFix32 _endOut; - TWFix32 _gamma; - TWFix32 _sampleCount; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial struct TWTransformStage - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - TWDecodeFunction[] _decode; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)] - TWFix32[] _mix; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWArray - { - TW_UINT16 _itemType; - TW_UINT32 _numItems; - object[] _itemList; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2), - BestFitMapping(false, ThrowOnUnmappableChar = true)] - partial class TWAudioInfo - { - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = TwainConst.String255)] - string _name; - - TW_UINT32 _reserved; - } - - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWCallback - { - [MarshalAs(UnmanagedType.FunctionPtr)] - CallbackDelegate _callBackProc; - TW_UINT32 _refCon; - TW_INT16 _message; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWCallback2 - { - [MarshalAs(UnmanagedType.FunctionPtr)] - CallbackDelegate _callBackProc; - TW_UINTPTR _refCon; - TW_INT16 _message; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWCapability - { - TW_UINT16 _cap; - TW_UINT16 _conType; - TW_HANDLE _hContainer; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial struct TWCiePoint - { - TWFix32 _x; - TWFix32 _y; - TWFix32 _z; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWCieColor - { - TW_UINT16 _colorSpace; - TW_INT16 _lowEndian; - TW_INT16 _deviceDependent; - TW_INT32 _versionNumber; - TWTransformStage _stageABC; - TWTransformStage _stageLMN; - TWCiePoint _whitePoint; - TWCiePoint _blackPoint; - TWCiePoint _whitePaper; - TWCiePoint _blackInk; - - // TODO: may be totally wrong - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] - TWFix32[] _samples; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWCustomDSData - { - TW_UINT32 _infoLength; - TW_HANDLE _hData; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2), - BestFitMapping(false, ThrowOnUnmappableChar = true)] - partial class TWDeviceEvent - { - TW_UINT32 _event; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = TwainConst.String255)] - string _deviceName; - - TW_UINT32 _batteryMinutes; - TW_INT16 _batteryPercentage; - TW_INT32 _powerSupply; - TWFix32 _xResolution; - TWFix32 _yResolution; - TW_UINT32 _flashUsed2; - TW_UINT32 _automaticCapture; - TW_UINT32 _timeBeforeFirstCapture; - TW_UINT32 _timeBetweenCaptures; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial struct TWElement8 - { - TW_UINT8 _index; - TW_UINT8 _channel1; - TW_UINT8 _channel2; - TW_UINT8 _channel3; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWEnumeration - { - TW_UINT16 _itemType; - TW_UINT32 _numItems; - TW_UINT32 _currentIndex; - TW_UINT32 _defaultIndex; - object[] _itemList; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWEvent - { - TW_MEMREF _pEvent; - TW_UINT16 _tWMessage; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial struct TWInfo - { - TW_UINT16 _infoID; - TW_UINT16 _itemType; - TW_UINT16 _numItems; - TW_UINT16 _returnCode; - //TW_UINTPTR _item; - TW_HANDLE _item; // easier to work with intptr - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWExtImageInfo - { - TW_UINT32 _numInfos; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 200)] - TWInfo[] _info; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2), - BestFitMapping(false, ThrowOnUnmappableChar = true)] - partial class TWFileSystem - { - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = TwainConst.String255)] - string _inputName; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = TwainConst.String255)] - string _outputName; - - TW_MEMREF _context; - TW_BOOL _subdirectories; - TW_INT32 _fileType; - TW_UINT32 _size; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = TwainConst.String32)] - string _createTimeDate; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = TwainConst.String32)] - string _modifiedTimeDate; - - TW_UINT32 _freeSpace; - TW_INT32 _newImageSize; - TW_UINT32 _numberOfFiles; - TW_UINT32 _numberOfSnippets; - TW_UINT32 _deviceGroupMask; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 508)] - TW_INT8[] _reserved; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWGrayResponse - { - // TODO: may be totally wrong - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] - TWElement8[] _response; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2), - BestFitMapping(false, ThrowOnUnmappableChar = true)] - partial struct TWVersion - { - TW_UINT16 _majorNum; - TW_UINT16 _minorNum; - TW_UINT16 _language; - TW_UINT16 _country; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = TwainConst.String32)] - string _info; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2), - BestFitMapping(false, ThrowOnUnmappableChar = true)] - partial class TWIdentity - { - TW_UINT32 _id; - TWVersion _version; - TW_UINT16 _protocolMajor; - TW_UINT16 _protocolMinor; - TW_UINT32 _supportedGroups; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = TwainConst.String32)] - string _manufacturer; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = TwainConst.String32)] - string _productFamily; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = TwainConst.String32)] - string _productName; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWImageInfo - { - TWFix32 _xResolution; - TWFix32 _yResolution; - TW_INT32 _imageWidth; - TW_INT32 _imageLength; - TW_INT16 _samplesPerPixel; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - TW_INT16[] _bitsPerSample; - - TW_INT16 _bitsPerPixel; - TW_BOOL _planar; - TW_INT16 _pixelType; - TW_UINT16 _compression; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWImageLayout - { - TWFrame _frame; - TW_UINT32 _documentNumber; - TW_UINT32 _pageNumber; - TW_UINT32 _frameNumber; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial struct TWMemory - { - // this is not a class due to being embedded by other classes - - TW_UINT32 _flags; - TW_UINT32 _length; - TW_MEMREF _theMem; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWImageMemXfer - { - TW_UINT16 _compression; - TW_UINT32 _bytesPerRow; - TW_UINT32 _columns; - TW_UINT32 _rows; - TW_UINT32 _xOffset; - TW_UINT32 _yOffset; - TW_UINT32 _bytesWritten; - TWMemory _memory; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWJpegCompression - { - TW_UINT16 _colorSpace; - TW_UINT32 _subSampling; - TW_UINT16 _numComponents; - TW_UINT16 _restartFrequency; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] - TW_UINT16[] _quantMap; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] - TWMemory[] _quantTable; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] - TW_UINT16[] _huffmanMap; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] - TWMemory[] _huffmanDC; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] - TWMemory[] _huffmanAC; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWOneValue - { - TW_UINT16 _itemType; - TW_UINT32 _item; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWPalette8 - { - TW_UINT16 _numColors; - TW_UINT16 _paletteType; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] - TWElement8[] _colors; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWPassThru - { - TW_MEMREF _pCommand; - TW_UINT32 _commandBytes; - TW_INT32 _direction; - TW_MEMREF _pData; - TW_UINT32 _dataBytes; - TW_UINT32 _dataBytesXfered; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWPendingXfers - { - TW_UINT16 _count; - TW_UINT32 _eOJ; - - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWRange - { - TW_UINT16 _itemType; - TW_UINT32 _minValue; - TW_UINT32 _maxValue; - TW_UINT32 _stepSize; - TW_UINT32 _defaultValue; - TW_UINT32 _currentValue; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWRgbResponse - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] - TWElement8[] _response; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2), - BestFitMapping(false, ThrowOnUnmappableChar = true)] - partial class TWSetupFileXfer - { - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = TwainConst.String255)] - string _fileName; - - TW_UINT16 _format; - TW_INT16 _vRefNum = -1; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWSetupMemXfer - { - TW_UINT32 _minBufSize; - TW_UINT32 _maxBufSize; - TW_UINT32 _preferred; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWStatus - { - TW_UINT16 _conditionCode; - TW_UINT16 _data; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWStatusUtf8 - { - // NOTE: rather than embedding the TWStatus directly I'm using its fields instead - // so the TWStatus could become a class object. If TWStatus changes - // definition remember to change it here - TW_UINT16 _conditionCode; - TW_UINT16 _data; - TW_UINT32 _size; - TW_HANDLE _uTF8string; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWUserInterface - { - TW_BOOL _showUI; - TW_BOOL _modalUI; - TW_HANDLE _hParent; - } - - delegate ReturnCode CallbackDelegate(TWIdentity origin, TWIdentity destination, - DataGroups dg, DataArgumentType dat, Message msg, TW_MEMREF data); - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWEntryPoint - { - TW_UINT32 _size; - // this is not a delegate cuz it's not used by the app - IntPtr _dSM_Entry; - - [MarshalAs(UnmanagedType.FunctionPtr)] - MemAllocateDelegate _dSM_MemAllocate; - [MarshalAs(UnmanagedType.FunctionPtr)] - MemFreeDelegate _dSM_MemFree; - [MarshalAs(UnmanagedType.FunctionPtr)] - MemLockDelegate _dSM_MemLock; - [MarshalAs(UnmanagedType.FunctionPtr)] - MemUnlockDelegate _dSM_MemUnlock; - - public delegate TW_HANDLE MemAllocateDelegate(TW_UINT32 size); - public delegate void MemFreeDelegate(TW_HANDLE handle); - public delegate TW_MEMREF MemLockDelegate(TW_HANDLE handle); - public delegate void MemUnlockDelegate(TW_HANDLE handle); - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWFilterDescriptor - { - TW_UINT32 _size; - TW_UINT32 _hueStart; - TW_UINT32 _hueEnd; - TW_UINT32 _saturationStart; - TW_UINT32 _saturationEnd; - TW_UINT32 _valueStart; - TW_UINT32 _valueEnd; - TW_UINT32 _replacement; - } - - [StructLayout(LayoutKind.Sequential, Pack = 2)] - partial class TWFilter - { - TW_UINT32 _size; - TW_UINT32 _descriptorCount; - TW_UINT32 _maxDescriptorCount; - TW_UINT32 _condition; - TW_HANDLE _hDescriptors; - } - - -} diff --git a/src/NTwain/Data/TwainTypesExtended.cs b/src/NTwain/Data/TwainTypesExtended.cs deleted file mode 100644 index 0289c99..0000000 --- a/src/NTwain/Data/TwainTypesExtended.cs +++ /dev/null @@ -1,2552 +0,0 @@ -using NTwain.Internals; -using NTwain.Properties; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Security.Permissions; -using System.Text; - -namespace NTwain.Data -{ - - //// This file contains custom logic added to the twain types. - //// Separating the raw field definitions out makes finding all the - //// custom code logic easier. Mostly this just makes the fields - //// into .net friendly properties. - - //// potentially unit tests for the twain types only need to target - //// code in this file since everything else is just interop and - //// field definitions. - - //// most of the doc text are copied from the twain spec pdf. - - - /// - /// Stores a fixed point number. This can be implicitly converted - /// to a float in dotnet. - /// - public partial struct TWFix32 : IEquatable, IConvertible - { - // the conversion logic is found in the spec. - - float ToFloat() - { - return (float)_whole + _frac / 65536f; - } - TWFix32(float value) - { - //int temp = (int)(value * 65536.0 + 0.5); - //_whole = (short)(temp >> 16); - //_frac = (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); - - } - - /// - /// The Whole part of the floating point number. This number is signed. - /// - public short Whole { get { return _whole; } set { _whole = value; } } - /// - /// The Fractional part of the floating point number. This number is unsigned. - /// - public ushort Fraction { get { return _frac; } set { _frac = value; } } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() - { - return ToFloat().ToString(CultureInfo.InvariantCulture); - } - - /// - /// Converts this to for capability set methods. - /// - /// - public TWOneValue ToOneValue() - { - // copy struct parts as-is. - // probably has a faster way but can't think now - - byte[] array = new byte[4]; - var part = BitConverter.GetBytes(Whole); - Buffer.BlockCopy(part, 0, array, 0, 2); - - part = BitConverter.GetBytes(Fraction); - Buffer.BlockCopy(part, 0, array, 2, 2); - - var converted = BitConverter.ToUInt32(array, 0); - - return new TWOneValue - { - ItemType = ItemType.Fix32, - Item = converted - // old wrong conversion - // (uint)this,// ((uint)dpi) << 16; - }; - } - - #region equals - - /// - /// Determines whether the specified is equal to this instance. - /// - /// The to compare with this instance. - /// - /// true if the specified is equal to this instance; otherwise, false. - /// - public override bool Equals(object obj) - { - if (!(obj is TWFix32)) - return false; - - return Equals((TWFix32)obj); - } - /// - /// Indicates whether the current object is equal to another object of the same type. - /// - /// An object to compare with this object. - /// - public bool Equals(TWFix32 other) - { - return _whole == other._whole && _frac == other._frac; - } - /// - /// Returns a hash code for this instance. - /// - /// - /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - /// - public override int GetHashCode() - { - return _whole ^ _frac; - } - - #endregion - - #region static stuff - - /// - /// Performs an implicit conversion from to . - /// - /// The value. - /// The result of the conversion. - public static implicit operator float(TWFix32 value) - { - return value.ToFloat(); - } - /// - /// Performs an implicit conversion from to . - /// - /// The value. - /// The result of the conversion. - public static implicit operator TWFix32(float value) - { - return new TWFix32(value); - } - /// - /// Performs an implicit conversion from to . - /// - /// The value. - /// The result of the conversion. - public static implicit operator double(TWFix32 value) - { - return value.ToFloat(); - } - /// - /// Performs an implicit conversion from to . - /// - /// The value. - /// The result of the conversion. - public static implicit operator TWFix32(double value) - { - return new TWFix32((float)value); - } - /// - /// Implements the operator ==. - /// - /// The value1. - /// The value2. - /// The result of the operator. - public static bool operator ==(TWFix32 value1, TWFix32 value2) - { - return value1.Equals(value2); - } - /// - /// Implements the operator !=. - /// - /// The value1. - /// The value2. - /// The result of the operator. - public static bool operator !=(TWFix32 value1, TWFix32 value2) - { - return !value1.Equals(value2); - } - #endregion - - #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 - } - - /// - /// Embedded in the structure. - /// Defines a frame rectangle in ICapUnits coordinates. - /// - public partial struct TWFrame : IEquatable - { - #region properties - - /// - /// Value of the left-most edge of the rectangle. - /// - public float Left { get { return _left; } set { _left = value; } } - /// - /// Value of the top-most edge of the rectangle. - /// - public float Top { get { return _top; } set { _top = value; } } - /// - /// Value of the right-most edge of the rectangle. - /// - public float Right { get { return _right; } set { _right = value; } } - /// - /// Value of the bottom-most edge of the rectangle. - /// - public float Bottom { get { return _bottom; } set { _bottom = value; } } - - #endregion - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() - { - return string.Format(CultureInfo.InvariantCulture, "L={0}, T={1}, R={2}, B={3}", Left, Top, Right, Bottom); - } - - #region equals - - /// - /// Determines whether the specified is equal to this instance. - /// - /// The to compare with this instance. - /// - /// true if the specified is equal to this instance; otherwise, false. - /// - public override bool Equals(object obj) - { - if (!(obj is TWFrame)) - return false; - - return Equals((TWFrame)obj); - } - /// - /// Indicates whether the current object is equal to another object of the same type. - /// - /// An object to compare with this object. - /// - public bool Equals(TWFrame other) - { - return _left == other._left && _top == other._top && - _right == other._right && _bottom == other._bottom; - } - /// - /// Returns a hash code for this instance. - /// - /// - /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - /// - public override int GetHashCode() - { - return _left.GetHashCode() ^ _top.GetHashCode() ^ - _right.GetHashCode() ^ _bottom.GetHashCode(); - } - - #endregion - - #region static stuff - - /// - /// Implements the operator ==. - /// - /// The value1. - /// The value2. - /// The result of the operator. - public static bool operator ==(TWFrame value1, TWFrame value2) - { - return value1.Equals(value2); - } - /// - /// Implements the operator !=. - /// - /// The value1. - /// The value2. - /// The result of the operator. - public static bool operator !=(TWFrame value1, TWFrame value2) - { - return !value1.Equals(value2); - } - #endregion - } - - /// - /// Embedded in the structure that is embedded in the - /// structure. Defines the parameters used for channel-specific transformation. The transform can be - /// described either as an extended form of the gamma function or as a table look-up with linear - /// interpolation. - /// - public partial struct TWDecodeFunction : IEquatable - { - #region properties - /// - /// Starting input value of the extended gamma function. Defines the - /// minimum input value of channel data. - /// - public float StartIn { get { return _startIn; } }//set { _startIn = value; } } - /// - /// Ending input value of the extended gamma function. Defines the maximum - /// input value of channel data. - /// - public float BreakIn { get { return _breakIn; } }//set { _breakIn = value; } } - /// - /// The input value at which the transform switches from linear - /// transformation/interpolation to gamma transformation. - /// - public float EndIn { get { return _endIn; } }//set { _endIn = value; } } - /// - /// Starting output value of the extended gamma function. Defines the - /// minimum output value of channel data. - /// - public float StartOut { get { return _startOut; } }//set { _startOut = value; } } - /// - /// Ending output value of the extended gamma function. Defines the - /// maximum output value of channel data. - /// - public float BreakOut { get { return _breakOut; } }//set { _breakOut = value; } } - /// - /// The output value at which the transform switches from linear - /// transformation/interpolation to gamma transformation. - /// - public float EndOut { get { return _endOut; } }//set { _endOut = value; } } - /// - /// Constant value. The exponential used in the gamma function. - /// - public float Gamma { get { return _gamma; } }//set { _gamma = value; } } - /// - /// The number of samples in the look-up table. Includes the values of StartIn - /// and EndIn. Zero-based index (actually, number of samples - 1). If zero, use - /// extended gamma, otherwise use table look-up. - /// - public float SampleCount { get { return _sampleCount; } }//set { _sampleCount = value; } } - #endregion - - #region equals - - /// - /// Determines whether the specified is equal to this instance. - /// - /// The to compare with this instance. - /// - /// true if the specified is equal to this instance; otherwise, false. - /// - public override bool Equals(object obj) - { - if (!(obj is TWDecodeFunction)) - return false; - - return Equals((TWDecodeFunction)obj); - } - /// - /// Indicates whether the current object is equal to another object of the same type. - /// - /// An object to compare with this object. - /// - public bool Equals(TWDecodeFunction other) - { - return _startIn == other._startIn && _startOut == other._startOut && - _breakIn == other._breakIn && _breakOut == other._breakOut && - _endIn == other._endIn && _endOut == other._endOut && - _gamma == other._gamma && _sampleCount == other._sampleCount; - } - /// - /// Returns a hash code for this instance. - /// - /// - /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - /// - public override int GetHashCode() - { - return _startIn.GetHashCode() ^ _startOut.GetHashCode() ^ - _breakIn.GetHashCode() ^ _breakOut.GetHashCode() ^ - _endIn.GetHashCode() ^ _endOut.GetHashCode() ^ - _gamma.GetHashCode() ^ _sampleCount.GetHashCode(); - } - - #endregion - - #region static stuff - - /// - /// Implements the operator ==. - /// - /// The value1. - /// The value2. - /// The result of the operator. - public static bool operator ==(TWDecodeFunction value1, TWDecodeFunction value2) - { - return value1.Equals(value2); - } - /// - /// Implements the operator !=. - /// - /// The value1. - /// The value2. - /// The result of the operator. - public static bool operator !=(TWDecodeFunction value1, TWDecodeFunction value2) - { - return !value1.Equals(value2); - } - #endregion - } - - /// - /// Specifies the parametrics used for either the ABC or LMN transform stages. - /// - public partial struct TWTransformStage - { - /// - /// Channel-specific transform parameters. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public TWDecodeFunction[] Decode { get { return _decode; } }//set { _decode = value; } } - /// - /// Flattened 3x3 matrix that specifies how channels are mixed in. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public TWFix32[] Mix { get { return _mix; } }//set { _mix = value; } } - - /// - /// Gets the value as matrix. - /// - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1814:PreferJaggedArraysOverMultidimensional", MessageId = "Body"), - System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1814:PreferJaggedArraysOverMultidimensional", MessageId = "Return")] - public TWFix32[,] GetMixMatrix() - { - // from http://stackoverflow.com/questions/3845235/convert-array-to-matrix, haven't tested it - TWFix32[,] mat = new TWFix32[3, 3]; - Buffer.BlockCopy(_mix, 0, mat, 0, _mix.Length * 4); - return mat; - } - } - - /// - /// Stores a group of associated individual values for a capability. - /// The values need have no relationship to one another aside from - /// being used to describe the same "value" of the capability - /// - public partial class TWArray - { - /// - /// The type of items in the array. All items in the array have the same size. - /// - public ItemType ItemType { get { return (ItemType)_itemType; } set { _itemType = (ushort)value; } } - - ///// - ///// How many items are in the array. - ///// - //public int Count { get { return (int)_numItems; } set { _numItems = (uint)value; } } - - /// - /// Array of ItemType values starts here. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public object[] ItemList - { - get { return _itemList; } - set - { - _itemList = value; - if (value != null) { _numItems = (uint)value.Length; } - else { _numItems = 0; } - } - } - } - - /// - /// Used to get audio info. - /// - public partial class TWAudioInfo - { - internal TWAudioInfo() { } - - /// - /// Name of audio data. - /// - public string Name { get { return _name; } } - } - - /// - /// Used in Callback mechanism for sending messages from the Source to the Application. - /// Applications version 2.2 or higher must use . - /// - partial class TWCallback - { - /// - /// Initializes a new instance of the class. - /// - /// The callback function’s entry point. - public TWCallback(CallbackDelegate callback) - { - _callBackProc = callback; - } - - ///// - ///// An application defined reference constant. - ///// - ///// - ///// The reference constant. - ///// - //public uint RefCon { get { return _refCon; } set { _refCon = value; } } - - ///// - ///// Initialized to any valid DG_CONTROL / DAT_NULL message. - ///// - ///// - ///// The message. - ///// - //public short Message { get { return _message; } set { _message = value; } } - } - /// - /// Used in the Callback mechanism for sending messages from the Source to the Application. - /// - partial class TWCallback2 - { - /// - /// Initializes a new instance of the class. - /// - /// The callback function’s entry point. - public TWCallback2(CallbackDelegate callback) - { - _callBackProc = callback; - } - - ///// - ///// An application defined reference constant. It has a different size on different - ///// platforms. - ///// - ///// - ///// The reference constant. - ///// - //public UIntPtr RefCon { get { return _refCon; } set { _refCon = value; } } - - ///// - ///// Initialized to any valid DG_CONTROL / DAT_NULL message. - ///// - ///// - ///// The message. - ///// - //public short Message { get { return _message; } set { _message = value; } } - } - - /// - /// Used by an application either to get information about, or control the setting of a capability. - /// - public sealed partial class TWCapability : IDisposable - { - #region ctors - - /// - /// Initializes a new instance of the class. - /// - /// The capability. - public TWCapability(CapabilityId capability) - { - Capability = capability; - ContainerType = ContainerType.DoNotCare; - } - /// - /// Initializes a new instance of the class. - /// - /// The capability. - /// The value. - public TWCapability(CapabilityId capability, TWOneValue value) - { - Capability = capability; - SetOneValue(value, PlatformInfo.Current.MemoryManager); - } - /// - /// Initializes a new instance of the class. - /// - /// The capability. - /// The value. - /// The type. - public TWCapability(CapabilityId capability, string value, ItemType type) - { - Capability = capability; - SetOneValue(value, type, PlatformInfo.Current.MemoryManager); - } - /// - /// Initializes a new instance of the class. - /// - /// The capability. - /// The value. - public TWCapability(CapabilityId capability, TWFrame value) - { - Capability = capability; - SetOneValue(value, PlatformInfo.Current.MemoryManager); - } - - /// - /// Initializes a new instance of the class. - /// - /// The capability. - /// The value. - public TWCapability(CapabilityId capability, TWEnumeration value) - { - Capability = capability; - SetEnumValue(value, PlatformInfo.Current.MemoryManager); - } - - /// - /// Initializes a new instance of the class. - /// - /// The capability. - /// The value. - public TWCapability(CapabilityId capability, TWRange value) - { - Capability = capability; - SetRangeValue(value, PlatformInfo.Current.MemoryManager); - } - - /// - /// Initializes a new instance of the class. - /// - /// The capability. - /// The value. - public TWCapability(CapabilityId capability, TWArray value) - { - Capability = capability; - SetArrayValue(value, PlatformInfo.Current.MemoryManager); - } - #endregion - - #region properties - - /// - /// Id of capability to set or get. - /// - public CapabilityId Capability { get { return (CapabilityId)_cap; } set { _cap = (ushort)value; } } - /// - /// The type of the container structure referenced by the pointer internally. The container - /// will be one of four types: , , - /// , or . - /// - public ContainerType ContainerType { get { return (ContainerType)_conType; } set { _conType = (ushort)value; } } - - internal IntPtr Container { get { return _hContainer; } } - - #endregion - - #region value functions - - void SetOneValue(string value, ItemType type, IMemoryManager memoryManager) - { - ContainerType = ContainerType.OneValue; - switch (type) - { - case ItemType.String128: - case ItemType.String255: - case ItemType.String32: - case ItemType.String64: - - _hContainer = memoryManager.Allocate((uint)(Marshal.SizeOf(typeof(TWFrame)) + 2)); - if (_hContainer != IntPtr.Zero) - { - IntPtr baseAddr = memoryManager.Lock(_hContainer); - int offset = 0; - baseAddr.WriteValue(ref offset, ItemType.UInt16, type); - baseAddr.WriteValue(ref offset, type, value); - memoryManager.Unlock(_hContainer); - } - break; - default: - throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Type {0} is not valid for string.", type)); - } - } - void SetOneValue(TWFrame value, IMemoryManager memoryManager) - { - ContainerType = ContainerType.OneValue; - - _hContainer = memoryManager.Allocate((uint)(Marshal.SizeOf(typeof(TWFrame)) + 2)); - if (_hContainer != IntPtr.Zero) - { - IntPtr baseAddr = memoryManager.Lock(_hContainer); - int offset = 0; - baseAddr.WriteValue(ref offset, ItemType.UInt16, ItemType.Frame); - baseAddr.WriteValue(ref offset, ItemType.Frame, value); - memoryManager.Unlock(_hContainer); - } - } - - void SetOneValue(TWOneValue value, IMemoryManager memoryManager) - { - if (value == null) { throw new ArgumentNullException("value"); } - ContainerType = ContainerType.OneValue; - - // since one value can only house UInt32 we will not allow type size > 4 - if (TypeExtensions.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.BadValueType, "TWOneValue")); } - - _hContainer = memoryManager.Allocate((uint)Marshal.SizeOf(value)); - if (_hContainer != IntPtr.Zero) - { - Marshal.StructureToPtr(value, _hContainer, false); - } - } - - void SetEnumValue(TWEnumeration value, IMemoryManager memoryManager) - { - if (value == null) { throw new ArgumentNullException("value"); } - ContainerType = ContainerType.Enum; - - - Int32 valueSize = TWEnumeration.ItemOffset + value.ItemList.Length * TypeExtensions.GetItemTypeSize(value.ItemType); - - int offset = 0; - _hContainer = memoryManager.Allocate((uint)valueSize); - if (_hContainer != IntPtr.Zero) - { - IntPtr baseAddr = memoryManager.Lock(_hContainer); - - // can't safely use StructureToPtr here so write it our own - baseAddr.WriteValue(ref offset, ItemType.UInt16, value.ItemType); - baseAddr.WriteValue(ref offset, ItemType.UInt32, (uint)value.ItemList.Length); - baseAddr.WriteValue(ref offset, ItemType.UInt32, value.CurrentIndex); - baseAddr.WriteValue(ref offset, ItemType.UInt32, value.DefaultIndex); - foreach (var item in value.ItemList) - { - baseAddr.WriteValue(ref offset, value.ItemType, item); - } - memoryManager.Unlock(_hContainer); - } - } - - void SetRangeValue(TWRange value, IMemoryManager memoryManager) - { - if (value == null) { throw new ArgumentNullException("value"); } - ContainerType = ContainerType.Range; - - // since range value can only house UInt32 we will not allow type size > 4 - if (TypeExtensions.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.BadValueType, "TWRange")); } - - _hContainer = memoryManager.Allocate((uint)Marshal.SizeOf(value)); - if (_hContainer != IntPtr.Zero) - { - Marshal.StructureToPtr(value, _hContainer, false); - } - } - - void SetArrayValue(TWArray value, IMemoryManager memoryManager) - { - if (value == null) { throw new ArgumentNullException("value"); } - ContainerType = ContainerType.Array; - - Int32 valueSize = 6 + value.ItemList.Length * TypeExtensions.GetItemTypeSize(value.ItemType); - - int offset = 0; - _hContainer = memoryManager.Allocate((uint)valueSize); - if (_hContainer != IntPtr.Zero) - { - IntPtr baseAddr = memoryManager.Lock(_hContainer); - - // can't safely use StructureToPtr here so write it our own - baseAddr.WriteValue(ref offset, ItemType.UInt16, value.ItemType); - baseAddr.WriteValue(ref offset, ItemType.UInt32, (uint)value.ItemList.Length); - foreach (var item in value.ItemList) - { - baseAddr.WriteValue(ref offset, value.ItemType, item); - } - memoryManager.Unlock(_hContainer); - } - } - - #endregion - - - #region IDisposable Members - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - void Dispose(bool disposing) - { - if (disposing) { } - if (_hContainer != IntPtr.Zero) - { - PlatformInfo.Current.MemoryManager.Free(_hContainer); - _hContainer = IntPtr.Zero; - } - } - - /// - /// Finalizes an instance of the class. - /// - ~TWCapability() - { - Dispose(false); - } - #endregion - - } - - /// - /// Embedded in the structure; - /// defines a CIE XYZ space tri-stimulus value. - /// - public partial struct TWCiePoint : IEquatable - { - #region properties - /// - /// First tri-stimulus value of the CIE space representation. - /// - public float X { get { return _z; } } - /// - /// Second tri-stimulus value of the CIE space representation. - /// - public float Y { get { return _z; } } - /// - /// Third tri-stimulus value of the CIE space representation. - /// - public float Z { get { return _z; } } - #endregion - - #region equals - - /// - /// Determines whether the specified is equal to this instance. - /// - /// The to compare with this instance. - /// - /// true if the specified is equal to this instance; otherwise, false. - /// - public override bool Equals(object obj) - { - if (!(obj is TWCiePoint)) - return false; - - return Equals((TWCiePoint)obj); - } - /// - /// Indicates whether the current object is equal to another object of the same type. - /// - /// An object to compare with this object. - /// - public bool Equals(TWCiePoint other) - { - return _x == other._x && _y == other._y && - _z == other._z; - } - /// - /// Returns a hash code for this instance. - /// - /// - /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - /// - public override int GetHashCode() - { - return _x.GetHashCode() ^ _y.GetHashCode() ^ - _z.GetHashCode(); - } - - #endregion - - #region static stuff - - /// - /// Implements the operator ==. - /// - /// The value1. - /// The value2. - /// The result of the operator. - public static bool operator ==(TWCiePoint value1, TWCiePoint value2) - { - return value1.Equals(value2); - } - /// - /// Implements the operator !=. - /// - /// The value1. - /// The value2. - /// The result of the operator. - public static bool operator !=(TWCiePoint value1, TWCiePoint value2) - { - return !value1.Equals(value2); - } - #endregion - } - - /// - /// Defines the mapping from an RGB color space device into CIE 1931 (XYZ) color space. - /// - public partial class TWCieColor - { - internal TWCieColor() { } - - /// - /// Defines the original color space that was transformed into CIE XYZ. - /// This value is not set-able by the application. - /// - public ushort ColorSpace { get { return _colorSpace; } } - /// - /// Used to indicate which data byte is taken first. If zero, then high byte is - /// first. If non-zero, then low byte is first. - /// - public short LowEndian { get { return _lowEndian; } } - /// - /// If non-zero then color data is device-dependent and only ColorSpace is - /// valid in this structure. - /// - public short DeviceDependent { get { return _deviceDependent; } } - /// - /// Version of the color space descriptor specification used to define the - /// transform data. The current version is zero. - /// - public int VersionNumber { get { return _versionNumber; } } - /// - /// Describes parametrics for the first stage transformation of the Postscript - /// Level 2 CIE color space transform process. - /// - public TWTransformStage StageABC { get { return _stageABC; } } - /// - /// Describes parametrics for the first stage transformation of the Postscript - /// Level 2 CIE color space transform process. - /// - public TWTransformStage StageLMN { get { return _stageLMN; } } - /// - /// Values that specify the CIE 1931 (XYZ space) tri-stimulus value of the - /// diffused white point. - /// - public TWCiePoint WhitePoint { get { return _whitePoint; } } - /// - /// Values that specify the CIE 1931 (XYZ space) tri-stimulus value of the - /// diffused black point. - /// - public TWCiePoint BlackPoint { get { return _blackPoint; } } - /// - /// Values that specify the CIE 1931 (XYZ space) tri-stimulus value of inkless - /// "paper" from which the image was acquired. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "WhitePaper")] - public TWCiePoint WhitePaper { get { return _whitePaper; } } - /// - /// Values that specify the CIE 1931 (XYZ space) tri-stimulus value of solid - /// black ink on the "paper" from which the image was acquired. - /// - public TWCiePoint BlackInk { get { return _blackInk; } } - /// - /// Optional table look-up values used by the decode function. Samples - /// are ordered sequentially and end-to-end as A, B, C, L, M, and N. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public TWFix32[] Samples { get { return _samples; } } - } - - /// - /// Allows for a data source and application to pass custom data to each other. - /// - partial class TWCustomDSData - { - /// - /// Length, in bytes, of data. - /// - public uint InfoLength { get { return _infoLength; } set { _infoLength = value; } } - /// - /// Handle to memory containing InfoLength bytes of data. - /// - public IntPtr hData { get { return _hData; } set { _hData = value; } } - } - - /// - /// Provides information about the Event that was raised by the Source. The Source should only fill - /// in those fields applicable to the Event. The Application must only read those fields applicable to - /// the Event. - /// - public partial class TWDeviceEvent - { - internal TWDeviceEvent() { } - - /// - /// Defines event that has taken place. - /// - public DeviceEvent Event { get { return (DeviceEvent)_event; } } - /// - /// The name of the device that generated the event. - /// - public string DeviceName { get { return _deviceName; } } - /// - /// Battery minutes remaining. Valid for BatteryCheck event only. - /// - public int BatteryMinutes { get { return (int)_batteryMinutes; } } - /// - /// Battery percentage remaining. Valid for BatteryCheck event only. - /// - public int BatteryPercentage { get { return (int)_batteryPercentage; } } - /// - /// Current power supply in use. Valid for PowerSupply event only. - /// - public int PowerSupply { get { return (int)_powerSupply; } } - /// - /// Current X Resolution. Valid for Resolution event only. - /// - public float XResolution { get { return _xResolution; } } - /// - /// Current Y Resolution. Valid for Resolution event only. - /// - public float YResolution { get { return _yResolution; } } - /// - /// Current flash setting. Valid for BatteryCheck event only. - /// - public FlashedUsed FlashUsed2 { get { return (FlashedUsed)_flashUsed2; } } - /// - /// Number of images camera will capture. Valid for AutomaticCapture event only. - /// - public int AutomaticCapture { get { return (int)_automaticCapture; } } - /// - /// Number of seconds before first capture. Valid for AutomaticCapture event only. - /// - public int TimeBeforeFirstCapture { get { return (int)_timeBeforeFirstCapture; } } - /// - /// Hundredths of a second between captures. Valid for AutomaticCapture event only. - /// - public int TimeBetweenCaptures { get { return (int)_timeBetweenCaptures; } } - } - - /// - /// Embedded in the , , and structures. - /// This structure holds the tri-stimulus color palette information for structures. - /// The order of the channels shall match their alphabetic representation. That is, for RGB data, R - /// shall be channel 1. For CMY data, C shall be channel 1. This allows the application and Source - /// to maintain consistency. Grayscale data will have the same values entered in all three channels. - /// - public partial struct TWElement8 : IEquatable - { - /// - /// Value used to index into the color table. - /// - public byte Index { get { return _index; } set { _index = value; } } - /// - /// First tri-stimulus value (e.g. Red). - /// - public byte Channel1 { get { return _channel1; } set { _channel1 = value; } } - /// - /// Second tri-stimulus value (e.g Green). - /// - public byte Channel2 { get { return _channel2; } set { _channel2 = value; } } - /// - /// Third tri-stimulus value (e.g Blue). - /// - public byte Channel3 { get { return _channel3; } set { _channel3 = value; } } - - - #region equals - - /// - /// Determines whether the specified is equal to this instance. - /// - /// The to compare with this instance. - /// - /// true if the specified is equal to this instance; otherwise, false. - /// - public override bool Equals(object obj) - { - if (!(obj is TWElement8)) - return false; - - return Equals((TWElement8)obj); - } - /// - /// Indicates whether the current object is equal to another object of the same type. - /// - /// An object to compare with this object. - /// - public bool Equals(TWElement8 other) - { - return _channel1 == other._channel1 && _channel2 == other._channel2 && - _channel3 == other._channel3 && _index == other._index; - } - /// - /// Returns a hash code for this instance. - /// - /// - /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - /// - public override int GetHashCode() - { - return _channel1.GetHashCode() ^ _channel2.GetHashCode() ^ - _channel3.GetHashCode() ^ _index.GetHashCode(); - } - - /// - /// Check for value equality. - /// - /// The v1. - /// The v2. - /// - public static bool operator ==(TWElement8 v1, TWElement8 v2) - { - return v1.Equals(v2); - } - - /// - /// Check for value inequality. - /// - /// The v1. - /// The v2. - /// - public static bool operator !=(TWElement8 v1, TWElement8 v2) - { - return !(v1 == v2); - } - - - #endregion - } - - /// - /// An enumeration stores a list of individual values, with one of the items designated as the current - /// value. There is no required order to the values in the list. - /// - public partial class TWEnumeration - { - /// - /// The type of items in the enumerated list. All items in the array have the same size. - /// - public ItemType ItemType { get { return (ItemType)_itemType; } set { _itemType = (ushort)value; } } - ///// - ///// How many items are in the enumeration. - ///// - //public int Count { get { return (int)_numItems; } set { _numItems = (uint)value; } } - /// - /// The item number, or index (zero-based) into , of the "current" - /// value for the capability. - /// - public int CurrentIndex { get { return (int)_currentIndex; } set { _currentIndex = (uint)value; } } - /// - /// The item number, or index (zero-based) into , of the "power-on" - /// value for the capability. - /// - public int DefaultIndex { get { return (int)_defaultIndex; } set { _defaultIndex = (uint)value; } } - /// - /// The enumerated list: one value resides within each array element. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public object[] ItemList - { - get { return _itemList; } - set - { - _itemList = value; - if (value != null) { _numItems = (uint)value.Length; } - else { _numItems = 0; } - } - } - - /// - /// Gets the byte offset of the item list from a Ptr to the first item. - /// - internal const int ItemOffset = 14; - } - - - /// - /// Used on Windows and Macintosh pre OS X to pass application events/messages from the - /// application to the Source. - /// - public partial class TWEvent - { - /// - /// A pointer to the event/message to be examined by the Source. - /// Under Microsoft Windows, pEvent is a pMSG (pointer to a Microsoft - /// Windows MSG struct). That is, the message the application received from - /// GetMessage(). On the Macintosh, pEvent is a pointer to an EventRecord. - /// - public IntPtr pEvent { get { return _pEvent; } set { _pEvent = value; } } - /// - /// Any message the Source needs to send to the application in - /// response to processing the event/message. The messages currently defined for - /// this purpose are , - /// and . - /// - public Message TWMessage { get { return (Message)_tWMessage; } } - } - - /// - /// This structure is used to pass specific information between the data source and the application - /// through . - /// - [DebuggerDisplay("ID = {InfoID}, Type = {ItemType}")] - public partial struct TWInfo - { - /// - /// Tag identifying an information. - /// - public ExtendedImageInfo InfoID { get { return (ExtendedImageInfo)_infoID; } set { _infoID = (ushort)value; } } - /// - /// Item data type. - /// - public ItemType ItemType { get { return (ItemType)_itemType; } set { _itemType = (ushort)value; } } - /// - /// Number of items. - /// - public ushort NumItems { get { return _numItems; } } - - /// - /// This is the return code of availability of data for extended image attribute requested. - /// - /// - /// The return code. - /// - public ReturnCode ReturnCode { get { return (ReturnCode)_returnCode; } } - - /// - /// Contains either data or a handle to data. The field - /// contains data if the total amount of data is less than or equal to four bytes. The - /// field contains a handle if the total amount of data is more than four bytes. - /// The amount of data is determined by multiplying NumItems times - /// the byte size of the data type specified by ItemType. - /// If the Item field contains a handle to data, then the Application is - /// responsible for freeing that memory. - /// - public IntPtr Item { get { return _item; } internal set { _item = value; } } - - bool ItemIsPointer - { - get - { - return ItemType == Data.ItemType.Handle || - (TypeExtensions.GetItemTypeSize(ItemType) * NumItems) > 4;// IntPtr.Size - } - } - - /// - /// Try to reads the values from the property. - /// - /// - public IList ReadValues() - { - var values = new List(); - if (NumItems > 0) - { - if (ItemIsPointer) - { - if (Item != IntPtr.Zero) - { - IntPtr lockPtr = IntPtr.Zero; - try - { - int offset = 0; - lockPtr = PlatformInfo.Current.MemoryManager.Lock(Item); - - for (int i = 0; i < NumItems; i++) - { - values.Add(TypeExtensions.ReadValue(lockPtr, ref offset, ItemType)); - } - } - finally - { - if (lockPtr != IntPtr.Zero) - { - PlatformInfo.Current.MemoryManager.Unlock(Item); - //PlatformInfo.Current.MemoryManager.Unlock(lockPtr); - } - } - } - } - else - { - // do the lame and create a ptr to the value so we can reuse TypeReader - IntPtr tempPtr = IntPtr.Zero; - try - { - tempPtr = Marshal.AllocHGlobal(IntPtr.Size); - Marshal.WriteIntPtr(tempPtr, Item); - int offset = 0; - values.Add(TypeExtensions.ReadValue(tempPtr, ref offset, ItemType)); - } - finally - { - if (tempPtr != IntPtr.Zero) - { - Marshal.FreeHGlobal(tempPtr); - } - } - } - } - return values; - } - - #region IDisposable Members - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// - public void Dispose() - { - Dispose(true); - //GC.SuppressFinalize(this); - } - - private void Dispose(bool disposing) - { - if (disposing) { } - - if (ItemIsPointer && Item != IntPtr.Zero) - { - PlatformInfo.Current.MemoryManager.Free(Item); - } - Item = IntPtr.Zero; - } - - - //~TWInfo() - //{ - // Dispose(false); - //} - #endregion - } - - /// - /// This structure is used to pass extended image information from the data source to application at - /// the end of State 7. The application creates this structure at the end of State 7, when it receives - /// XFERDONE. Application fills NumInfos for Number information it needs, and array of - /// extended information attributes in Info[ ] array. Application, then, sends it down to the source - /// using the above operation triplet. The data source then examines each Info, and fills the rest of - /// data with information allocating memory when necessary. - /// - sealed partial class TWExtImageInfo - { - /// - /// Initializes a new instance of the class. - /// - public TWExtImageInfo() - { - _info = new TWInfo[200]; - } - - /// - /// Number of information that application is requesting. This is filled by the - /// application. If positive, then the application is requesting specific extended - /// image information. The application should allocate memory and fill in the - /// attribute tag for image information. - /// - public uint NumInfos - { - //get { return _numInfos; } - set { _numInfos = value; } - } - - /// - /// Array of information. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public TWInfo[] Info { get { return _info; } } - } - - /// - /// Provides information about the currently selected device. - /// - public partial class TWFileSystem - { - /// - /// The name of the input or source file. - /// - public string InputName { get { return _inputName; } set { _inputName = value; } } - /// - /// The result of an operation or the name of a destination file. - /// - public string OutputName { get { return _outputName; } set { _outputName = value; } } - /// - /// A pointer to Source specific data used to remember state - /// information, such as the current directory. - /// - public IntPtr Context { get { return _context; } set { _context = value; } } - - /// - /// When set to TRUE recursively apply the operation. (ex: deletes - /// all subdirectories in the directory being deleted; or copies all - /// sub-directories in the directory being copied. - /// - public bool Recursive { get { return _subdirectories == TwainConst.True; } set { _subdirectories = value ? TwainConst.True : TwainConst.False; } } - - /// - /// Gets the type of the file. - /// - /// - /// The type of the file. - /// - public FileType FileType { get { return (FileType)_fileType; } set { _fileType = (int)value; } } - - /// - /// If , total size of media in bytes. - /// If , size of image in bytes. - /// - /// - /// The size. - /// - public uint Size { get { return _size; } set { _size = value; } } - /// - /// The create date of the file, in the form "YYYY/MM/DD - /// HH:mm:SS:sss" where YYYY is the year, MM is the numerical - /// month, DD is the numerical day, HH is the hour, mm is the - /// minute, SS is the second, and sss is the millisecond. - /// - public string CreateTimeDate { get { return _createTimeDate; } set { _createTimeDate = value; } } - /// - /// Last date the file was modified. Same format as . - /// - public string ModifiedTimeDate { get { return _modifiedTimeDate; } set { _modifiedTimeDate = value; } } - /// - /// The bytes of free space left on the current device. - /// - public uint FreeSpace { get { return _freeSpace; } set { _freeSpace = value; } } - /// - /// An estimate of the amount of space a new image would take - /// up, based on image layout, resolution and compression. - /// Dividing this value into the FreeSpace will yield the - /// approximate number of images that the Device has room for. - /// - public int NewImageSize { get { return _newImageSize; } set { _newImageSize = value; } } - /// - /// If applicable, return the number of files on the file system including those in all sub-directories. - /// - /// - /// The number of files. - /// - public uint NumberOfFiles { get { return _numberOfFiles; } set { _numberOfFiles = value; } } - /// - /// The number of audio snippets associated with a file of type . - /// - /// - /// The number of snippets. - /// - public uint NumberOfSnippets { get { return _numberOfSnippets; } set { _numberOfSnippets = value; } } - /// - /// Used to group cameras (ex: front/rear bitonal, front/rear grayscale...). - /// - public uint DeviceGroupMask { get { return _deviceGroupMask; } set { _deviceGroupMask = value; } } - } - - /// - /// This structure is used by the application to specify a set of mapping values to be applied to - /// grayscale data. - /// - public partial class TWGrayResponse - { - /// - /// Transfer curve descriptors. All three channels (Channel1, Channel2 - /// and Channel3) must contain the same value for every entry. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public TWElement8[] Response { get { return _response; } set { _response = value; } } - } - - /// - /// A general way to describe the version of software that is running. - /// - public partial struct TWVersion : IEquatable - { - /// - /// This refers to your application or Source’s major revision number. e.g. The - /// "2" in "version 2.1". - /// - public short Major { get { return (short)_majorNum; } set { _majorNum = (ushort)value; } } - /// - /// The incremental revision number of your application or Source. e.g. The "1" - /// in "version 2.1". - /// - public short Minor { get { return (short)_minorNum; } set { _minorNum = (ushort)value; } } - /// - /// The primary language for your Source or application. - /// - public Language Language { get { return (Language)_language; } set { _language = (ushort)value; } } - /// - /// The primary country where your Source or application is intended to be - /// distributed. e.g. Germany. - /// - public Country Country { get { return (Country)_country; } set { _country = (ushort)value; } } - /// - /// General information string - fill in as needed. e.g. "1.0b3 Beta release". - /// - public string Info { get { return _info; } set { _info.VerifyLengthUnder(TwainConst.String32 - 1); _info = value; } } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() - { - return string.Format(CultureInfo.InvariantCulture, "{0}.{1} {2}", Major, Minor, Info); - } - - #region equals - - /// - /// Determines whether the specified is equal to this instance. - /// - /// The to compare with this instance. - /// - /// true if the specified is equal to this instance; otherwise, false. - /// - public override bool Equals(object obj) - { - if (!(obj is TWVersion)) - return false; - - return Equals((TWVersion)obj); - } - /// - /// Indicates whether the current object is equal to another object of the same type. - /// - /// An object to compare with this object. - /// - public bool Equals(TWVersion other) - { - return _majorNum == other._majorNum && _minorNum == other._minorNum && - _language == other._language && _country == other._country && - string.Equals(_info, other._info); - } - /// - /// Returns a hash code for this instance. - /// - /// - /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - /// - public override int GetHashCode() - { - return _majorNum.GetHashCode() ^ _minorNum.GetHashCode() ^ - _language.GetHashCode() ^ _country.GetHashCode() ^ - (_info == null ? 0 : _info.GetHashCode()); - } - - /// - /// Check for value equality. - /// - /// The v1. - /// The v2. - /// - public static bool operator ==(TWVersion v1, TWVersion v2) - { - return v1.Equals(v2); - } - - /// - /// Check for value inequality. - /// - /// The v1. - /// The v2. - /// - public static bool operator !=(TWVersion v1, TWVersion v2) - { - return !(v1 == v2); - } - - #endregion - } - - /// - /// Provides identification information about a TWAIN entity. Used to maintain consistent - /// communication between entities. - /// - public partial class TWIdentity - { - /// - /// A unique, internal identifier for the TWAIN entity. This field is only - /// filled by the Source Manager. Neither an application nor a Source - /// should fill this field. The Source uses the contents of this field to - /// "identify" which application is invoking the operation sent to the - /// Source. - /// - public int Id { get { return (int)_id; } } - - /// - /// Gets the supported data group. The application will normally set this field to specify which Data - /// Group(s) it wants the Source Manager to sort Sources by when - /// presenting the Select Source dialog, or returning a list of available - /// Sources. - /// - /// The data group. - public DataGroups DataGroup - { - get { return (DataGroups)(_supportedGroups & 0xffff); } - set { _supportedGroups = ((uint)value & 0xffff) | (0xffff0000 & _supportedGroups); } - } - - /// - /// Major number of latest TWAIN version that this element supports. - /// - public short ProtocolMajor { get { return (short)_protocolMajor; } set { _protocolMajor = (ushort)value; } } - - /// - /// Minor number of latest TWAIN version that this element supports. - /// - public short ProtocolMinor { get { return (short)_protocolMinor; } set { _protocolMinor = (ushort)value; } } - - - /// - /// A structure identifying the TWAIN entity. - /// - public TWVersion Version { get { return _version; } set { _version = value; } } - /// - /// Gets the data functionalities for TWAIN 2 detection. - /// - /// The data functionalities. - public DataFunctionalities DataFunctionalities - { - get { return (DataFunctionalities)(_supportedGroups & 0xffff0000); } - set { _supportedGroups = ((uint)value & 0xffff0000) | (0x0000ffff & _supportedGroups); } - } - - /// - /// String identifying the manufacturer of the application or Source. e.g. "Aldus". - /// - public string Manufacturer { get { return _manufacturer; } set { value.VerifyLengthUnder(TwainConst.String32 - 1); _manufacturer = value; } } - /// - /// Tells an application that performs device-specific operations which - /// product family the Source supports. This is useful when a new Source - /// has been released and the application doesn't know about the - /// particular Source but still wants to perform Custom operations with it. - /// e.g. "ScanMan". - /// - public string ProductFamily { get { return _productFamily; } set { value.VerifyLengthUnder(TwainConst.String32 - 1); _productFamily = value; } } - /// - /// A string uniquely identifying the Source. This is the string that will be - /// displayed to the user at Source select-time. This string must uniquely - /// identify your Source for the user, and should identify the application - /// unambiguously for Sources that care. e.g. "ScanJet IIc". - /// - public string ProductName { get { return _productName; } set { value.VerifyLengthUnder(TwainConst.String32 - 1); _productName = value; } } - - /// - /// Creates a from assembly values. - /// - /// The supported groups. - /// The assembly. - /// - /// assembly - /// - public static TWIdentity CreateFromAssembly(DataGroups supportedGroups, Assembly assembly) - { - if (assembly == null) { throw new ArgumentNullException("assembly"); } - - var info = FileVersionInfo.GetVersionInfo(assembly.Location); - - return Create(supportedGroups, assembly.GetName().Version, info.CompanyName, info.ProductName, info.ProductName, info.FileDescription); - } - - /// - /// Creates a from specified values. - /// - /// The supported groups. - /// The version. - /// The manufacturer. - /// The product family. - /// Name of the product. - /// The product description. - /// - /// assembly - /// - public static TWIdentity Create(DataGroups supportedGroups, Version version, - string manufacturer, string productFamily, string productName, string productDescription) - { - if ((supportedGroups & DataGroups.Image) == 0 && - (supportedGroups & DataGroups.Audio) == 0) - { - throw new ArgumentException(Resources.BadDataGroupsForAppId); - } - if (version == null) { throw new ArgumentNullException("version"); } - - return new TWIdentity - { - Manufacturer = string.IsNullOrEmpty(manufacturer) ? "UNKNOWN" : manufacturer, - ProtocolMajor = TwainConst.ProtocolMajor, - ProtocolMinor = TwainConst.ProtocolMinor, - DataGroup = DataGroups.Control | supportedGroups, - DataFunctionalities = DataFunctionalities.App2, - - ProductFamily = string.IsNullOrEmpty(productFamily) ? "UNKNOWN" : productFamily, - ProductName = string.IsNullOrEmpty(productName) ? "UNKNOWN" : productName, - Version = new TWVersion - { - Major = (short)version.Major, - Minor = (short)version.Minor, - Country = Country.Usa, - Language = Language.EnglishUSA, - Info = productDescription ?? string.Empty, - } - }; - } - } - - /// - /// Describes the "real" image data, that is, the complete image being transferred between the - /// Source and application. The Source may transfer the data in a different format--the information - /// may be transferred in "strips" or "tiles" in either compressed or uncompressed form. - /// - public partial class TWImageInfo - { - internal TWImageInfo() { } - - /// - /// The number of pixels per ICapUnits in the horizontal direction. The - /// current unit is assumed to be "inches" unless it has been otherwise - /// negotiated between the application and Source. - /// - public float XResolution { get { return _xResolution; } } - /// - /// The number of pixels per ICapUnits in the vertical direction. - /// - public float YResolution { get { return _yResolution; } } - /// - /// How wide, in pixels, the entire image to be transferred is. If the Source - /// doesn’t know, set this field to -1 (hand scanners may do this). - /// - public int ImageWidth { get { return _imageWidth; } } - /// - /// How tall/long, in pixels, the image to be transferred is. If the Source - /// doesn’t know, set this field to -1 (hand scanners may do this). - /// - public int ImageLength { get { return _imageLength; } } - /// - /// The number of samples being returned. For R-G-B, this field would be - /// set to 3. For C-M-Y-K, 4. For Grayscale or Black and White, 1. - /// - public short SamplesPerPixel { get { return _samplesPerPixel; } } - - /// - /// For each sample, the number of bits of information. 24-bit R-G-B will - /// typically have 8 bits of information in each sample (8+8+8). Some 8-bit - /// color is sampled at 3 bits Red, 3 bits Green, and 2 bits Blue. Such a - /// scheme would put 3, 3, and 2 into the first 3 elements of this array. The - /// supplied array allows up to 8 samples. Samples are not limited to 8 - /// bits. However, both the application and Source must simultaneously - /// support sample sizes greater than 8 bits per color. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public short[] BitsPerSample { get { return _bitsPerSample; } } - /// - /// The number of bits in each image pixel (or bit depth). This value is - /// invariant across the image. 24-bit R-G-B has BitsPerPixel = 24. 40-bit - /// CMYK has BitsPerPixel=40. 8-bit Grayscale has BitsPerPixel = 8. Black - /// and White has BitsPerPixel = 1. - /// - public short BitsPerPixel { get { return _bitsPerPixel; } } - /// - /// If SamplesPerPixel > 1, indicates whether the samples follow one - /// another on a pixel-by-pixel basis (R-G-B-R-G-B-R-G-B...) as is common - /// with a one-pass scanner or all the pixels for each sample are grouped - /// together (complete group of R, complete group of G, complete group of - /// B) as is common with a three-pass scanner. If the pixel-by-pixel - /// method (also known as "chunky") is used, the Source should set Planar - /// = FALSE. If the grouped method (also called "planar") is used, the - /// Source should set Planar = TRUE. - /// - public bool Planar { get { return _planar == TwainConst.True; } } - /// - /// This is the highest categorization for how the data being transferred - /// should be interpreted by the application. This is how the application - /// can tell if the data is Black and White, Grayscale, or Color. Currently, - /// the only color type defined is "tri-stimulus", or color described by three - /// characteristics. Most popular color description methods use tristimulus - /// descriptors. For simplicity, the constant used to identify tristimulus - /// color is called Rgb, for R-G-B color. There is no - /// default for this value. - /// - public PixelType PixelType { get { return (PixelType)_pixelType; } } - /// - /// The compression method used to process the data being transferred. - /// Default is no compression. - /// - public CompressionType Compression { get { return (CompressionType)_compression; } } - } - - /// - /// Involves information about the original size of the acquired image and its position on the - /// original "page" relative to the "page’s" upper-left corner. Default measurements are in inches - /// (units of measure can be changed by negotiating the ICapUnits capability). This information - /// may be used by the application to relate the acquired (and perhaps processed image) to the - /// original. Further, the application can, using this structure, set the size of the image it wants - /// acquired. - /// - /// Another attribute of this structure is the included frame, page, and document indexing - /// information. Most Sources and applications, at least at first, will likely set all these fields to one. - /// For Sources that can acquire more than one frame from a page in a single acquisition, the - /// FrameNumber field will be handy. Sources that can acquire more than one page from a - /// document feeder will use PageNumber and DocumentNumber. These fields will be especially - /// useful for forms-processing applications and other applications with similar document tracking - /// requirements. - /// - public partial class TWImageLayout - { - /// - /// Frame coords within larger document. - /// - public TWFrame Frame { get { return _frame; } set { _frame = value; } } - /// - /// The document number, assigned by the Source, that the acquired data - /// originated on. Useful for grouping pages together. - /// Initial value is 1. Increment when a new document is placed into the - /// document feeder (usually tell this has happened when the feeder - /// empties). Reset when no longer acquiring from the feeder. - /// - public int DocumentNumber { get { return (int)_documentNumber; } set { _documentNumber = (uint)value; } } - /// - /// The page which the acquired data was captured from. Useful for - /// grouping Frames together that are in some way related. - /// Initial value is 1. Increment for each page fed from - /// a page feeder. Reset when a new document is placed into the feeder. - /// - public int PageNumber { get { return (int)_pageNumber; } set { _pageNumber = (uint)value; } } - /// - /// Usually a chronological index of the acquired frame. These frames - /// are related to one another in some way; usually they were acquired - /// from the same page. The Source assigns these values. Initial value is - /// 1. Reset when a new page is acquired from. - /// - public int FrameNumber { get { return (int)_frameNumber; } set { _frameNumber = (uint)value; } } - } - - /// - /// Provides information for managing memory buffers. Memory for transfer buffers is allocated - /// by the application--the Source is asked to fill these buffers. This structure keeps straight which - /// entity is responsible for deallocation. - /// - public partial struct TWMemory - { - // not a class due to embedded - - /// - /// Encodes which entity releases the buffer and how the buffer is referenced. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags")] - public MemoryFlags Flags { get { return (MemoryFlags)_flags; } set { _flags = (uint)value; } } - /// - /// The size of the buffer in bytes. Should always be an even number and wordaligned. - /// - public uint Length { get { return _length; } set { _length = value; } } - /// - /// Reference to the buffer. May be a Pointer or a Handle (see Flags field to make - /// this determination). - /// - public IntPtr TheMem { get { return _theMem; } set { _theMem = value; } } - } - - /// - /// Describes the form of the acquired data being passed from the Source to the application in memory transfer mode. - /// - public partial class TWImageMemXfer - { - /// - /// The compression method used to process the data being transferred. - /// - public CompressionType Compression { get { return (CompressionType)_compression; } } - /// - /// The number of uncompressed bytes in each row of the piece of the image - /// being described in this buffer. - /// - public uint BytesPerRow { get { return _bytesPerRow; } } - /// - /// The number of uncompressed columns (in pixels) in this buffer. - /// - public uint Columns { get { return _columns; } } - /// - /// The number or uncompressed rows (in pixels) in this buffer. - /// - public uint Rows { get { return _rows; } } - /// - /// How far, in pixels, the left edge of the piece of the image being described - /// by this structure is inset from the "left" side of the original image. If the - /// Source is transferring in "strips", this value will equal zero. If the Source - /// is transferring in "tiles", this value will often be non-zero. - /// - public uint XOffset { get { return _xOffset; } } - /// - /// Same idea as XOffset, but the measure is in pixels from the "top" of the - /// original image to the upper edge of this piece. - /// - public uint YOffset { get { return _yOffset; } } - /// - /// The number of bytes written into the transfer buffer. This field must - /// always be filled in correctly, whether compressed or uncompressed data - /// is being transferred. - /// - public uint BytesWritten { get { return _bytesWritten; } } - /// - /// A structure of type describing who must dispose of the - /// buffer, the actual size of the buffer, in bytes, and where the buffer is - /// located in memory. - /// - internal TWMemory Memory { get { return _memory; } set { _memory = value; } } - } - - /// - /// Describes the information necessary to transfer a JPEG-compressed image during a buffered - /// transfer. Images compressed in this fashion will be compatible with the JPEG File Interchange - /// Format, version 1.1. - /// - public partial class TWJpegCompression - { - /// - /// Defines the color space in which the - /// compressed components are stored. - /// - public PixelType ColorSpace { get { return (PixelType)_colorSpace; } set { _colorSpace = (ushort)value; } } - /// - /// Encodes the horizontal and vertical subsampling in the form - /// ABCDEFGH, where ABCD are the high-order four nibbles which - /// represent the horizontal subsampling and EFGH are the low-order four - /// nibbles which represent the vertical subsampling. Each nibble may - /// have a value of 0, 1, 2, 3, or 4. However, max(A,B,C,D) * max(E,F,G,H) - /// must be less than or equal to 10. Subsampling is irrelevant for single - /// component images. Therefore, the corresponding nibbles should be set - /// to 1. e.g. To indicate subsampling two Y for each U and V in a YUV - /// space image, where the same subsampling occurs in both horizontal - /// and vertical axes, this field would hold 0x21102110. For a grayscale - /// image, this field would hold 0x10001000. A CMYK image could hold - /// 0x11111111. - /// - public uint Subsampling { get { return _subSampling; } set { _subSampling = value; } } - /// - /// Number of color components in the image to be compressed. - /// - public ushort NumComponents { get { return _numComponents; } set { _numComponents = value; } } - /// - /// Number of MDUs (Minimum Data Units) between restart markers. - /// Default is 0, indicating that no restart markers are used. An MDU is - /// defined for interleaved data (i.e. R-G-B, Y-U-V, etc.) as a minimum - /// complete set of 8x8 component blocks. - /// - public ushort RestartFrequency { get { return _restartFrequency; } set { _restartFrequency = value; } } - /// - /// Mapping of components to Quantization tables. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public ushort[] QuantMap { get { return _quantMap; } set { _quantMap = value; } } - /// - /// Quantization tables. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public TWMemory[] QuantTable { get { return _quantTable; } set { _quantTable = value; } } - /// - /// Mapping of components to Huffman tables. Null entries signify - /// selection of the default tables. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public ushort[] HuffmanMap { get { return _huffmanMap; } set { _huffmanMap = value; } } - /// - /// DC Huffman tables. Null entries signify selection of the default tables. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public TWMemory[] HuffmanDC { get { return _huffmanDC; } set { _huffmanDC = value; } } - /// - /// AC Huffman tables. Null entries signify selection of the default tables. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public TWMemory[] HuffmanAC { get { return _huffmanAC; } set { _huffmanAC = value; } } - } - - /// - /// Container for one value. - /// - public partial class TWOneValue - { - /// - /// The type of the item. - /// - public ItemType ItemType { get { return (ItemType)_itemType; } set { _itemType = (ushort)value; } } - /// - /// The value. - /// - public uint Item { get { return _item; } set { _item = value; } } - } - - - /// - /// This structure holds the color palette information for buffered memory transfers of type - /// ICapPixelType = Palette. - /// - public partial class TWPalette8 - { - /// - /// Number of colors in the color table; maximum index into the color table - /// should be one less than this (since color table indexes are zero-based). - /// - public ushort NumColors { get { return _numColors; } set { _numColors = value; } } - /// - /// Specifies type of palette. - /// - public PaletteType PaletteType { get { return (PaletteType)_paletteType; } set { _paletteType = (ushort)value; } } - /// - /// Array of palette values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public TWElement8[] Colors { get { return _colors; } set { _colors = value; } } - } - - /// - /// Used to bypass the TWAIN protocol when communicating with a device. All memory must be - /// allocated and freed by the Application. - /// - public partial class TWPassThru - { - /// - /// Pointer to Command buffer. - /// - public IntPtr pCommand { get { return _pCommand; } set { _pCommand = value; } } - /// - /// Number of bytes in Command buffer. - /// - public uint CommandBytes { get { return _commandBytes; } set { _commandBytes = value; } } - /// - /// Defines the direction of data flow. - /// - public Direction Direction { get { return (Direction)_direction; } set { _direction = (int)value; } } - /// - /// Pointer to Data buffer. - /// - public IntPtr pData { get { return _pData; } set { _pData = value; } } - /// - /// Number of bytes in Data buffer. - /// - public uint DataBytes { get { return _dataBytes; } set { _dataBytes = value; } } - /// - /// Number of bytes successfully transferred. - /// - public uint DataBytesXfered { get { return _dataBytesXfered; } set { _dataBytesXfered = value; } } - } - - /// - /// This structure tells the application how many more complete transfers the Source currently has - /// available. - /// - partial class TWPendingXfers - { - /// - /// Initializes a new instance of the class. - /// - public TWPendingXfers() - { - _count = TwainConst.DoNotCare16; - } - - /// - /// The number of complete transfers a Source has available for the application it is - /// connected to. If no more transfers are available, set to zero. If an unknown and - /// non-zero number of transfers are available, set to -1. - /// - public int Count { get { return _count == TwainConst.DoNotCare16 ? -1 : (int)_count; } } - /// - /// The application should check this field if the CapJobControl is set to other - /// than None. If this is not 0, the application should expect more data - /// from the driver according to CapJobControl settings. - /// - public EndXferJob EndOfJob { get { return (EndXferJob)_eOJ; } } - } - - - /// - /// Container for a range of values. - /// - public partial class TWRange - { - /// - /// The type of items in the list. - /// - public ItemType ItemType { get { return (ItemType)_itemType; } set { _itemType = (ushort)value; } } - /// - /// The least positive/most negative value of the range. - /// - public uint MinValue { get { return _minValue; } set { _minValue = value; } } - /// - /// The most positive/least negative value of the range. - /// - public uint MaxValue { get { return _maxValue; } set { _maxValue = value; } } - /// - /// The delta between two adjacent values of the range. - /// e.g. Item2 - Item1 = StepSize; - /// - public uint StepSize { get { return _stepSize; } set { _stepSize = value; } } - /// - /// The device’s "power-on" value for the capability. If the application is - /// performing a MSG_SET operation and isn’t sure what the default - /// value is, set this field to . - /// - public uint DefaultValue { get { return _defaultValue; } set { _defaultValue = value; } } - /// - /// The value to which the device (or its user interface) is currently set to - /// for the capability. - /// - public uint CurrentValue { get { return _currentValue; } set { _currentValue = value; } } - } - - /// - /// This structure is used by the application to specify a set of mapping values to be applied to RGB - /// color data. Use this structure for RGB data whose bit depth is up to, and including, 8-bits. - /// The number of elements in the array is determined by —the number of - /// elements is 2 raised to the power of . - /// - public partial class TWRgbResponse - { - /// - /// Transfer curve descriptors. To minimize color shift problems, writing the - /// same values into each channel is desirable. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public TWElement8[] Response { get { return _response; } set { _response = value; } } - } - - /// - /// Describes the file format and file specification information for a transfer through a disk file. - /// - public partial class TWSetupFileXfer - { - /// - /// A complete file specifier to the target file. On Windows, be sure to include the - /// complete pathname. - /// - public string FileName { get { return _fileName; } set { value.VerifyLengthUnder(TwainConst.String255 - 1); _fileName = value; } } - /// - /// The format of the file the Source is to fill. - /// - public FileFormat Format { get { return (FileFormat)_format; } set { _format = (ushort)value; } } - - /// - /// The volume reference number for the file. This applies to Macintosh only. On - /// Windows, fill the field with -1. - /// - public short VRefNum { get { return _vRefNum; } set { _vRefNum = value; } } - } - - - /// - /// Provides the application information about the Source’s requirements and preferences - /// regarding allocation of transfer buffer(s). - /// - public partial class TWSetupMemXfer - { - internal TWSetupMemXfer() { } - - /// - /// The size of the smallest transfer buffer, in bytes, that a Source can be - /// successful with. This will typically be the number of bytes in an - /// uncompressed row in the block to be transferred. An application should - /// never allocate a buffer smaller than this. - /// - public uint MinBufferSize { get { return _minBufSize; } } - /// - /// The size of the largest transfer buffer, in bytes, that a Source can fill. If a - /// Source can fill an arbitrarily large buffer, it might set this field to negative 1 to - /// indicate this (a hand-held scanner might do this, depending on how long its - /// cord is). Other Sources, such as frame grabbers, cannot fill a buffer larger than - /// a certain size. Allocation of a transfer buffer larger than this value is wasteful. - /// - public uint MaxBufferSize { get { return _maxBufSize; } } - /// - /// The size of the optimum transfer buffer, in bytes. A smart application will - /// allocate transfer buffers of this size, if possible. Buffers of this size will - /// optimize the Source’s performance. Sources should be careful to put - /// reasonable values in this field. Buffers that are 10’s of kbytes will be easier for - /// applications to allocate than buffers that are 100’s or 1000’s of kbytes. - /// - public uint Preferred { get { return _preferred; } } - } - - /// - /// Describes the status of a source. - /// - public partial class TWStatus - { - internal TWStatus() { } - internal TWStatus(ushort code, ushort data) - { - _conditionCode = code; - _data = data; - } - /// - /// Condition Code describing the status. - /// - public ConditionCode ConditionCode { get { return (ConditionCode)_conditionCode; } } - /// - /// Valid for TWAIN 2.1 and later. This field contains additional - /// scanner-specific data. If there is no data, then this value must be zero. - /// - public ushort Data { get { return _data; } } - } - - /// - /// Translates the contents of Status into a localized UTF8string, with the total number of bytes - /// in the string. - /// - public sealed partial class TWStatusUtf8 : IDisposable - { - /// - /// data received from a previous call. - /// - public TWStatus Status - { - get { return new TWStatus(_conditionCode, _data); } - } - - /// - /// Total number of bytes in the UTF8string, plus the terminating NULL byte. - /// This is not the same as the total number of characters in the string. - /// - public int Size { get { return (int)_size; } } - - /// - /// TW_HANDLE to a UTF-8 encoded localized string (based on - /// TwIdentity.Language or CapLanguage). The Source allocates - /// it, the Application frees it. - /// - public IntPtr UTF8StringPtr { get { return _uTF8string; } } - - /// - /// Gets the actual string from the pointer. This may be incorrect. - /// - /// - public string TryGetString() - { - if (_uTF8string != IntPtr.Zero) - { - var sb = new StringBuilder(Size - 1); - byte bt; - while (sb.Length < _size && - (bt = Marshal.ReadByte(_uTF8string, sb.Length)) != 0) - { - sb.Append((char)bt); - } - return sb.ToString(); - } - return null; - } - - - #region IDisposable Members - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - void Dispose(bool disposing) - { - if (disposing) - { - - } - if (_uTF8string != IntPtr.Zero) - { - PlatformInfo.Current.MemoryManager.Free(_uTF8string); - _uTF8string = IntPtr.Zero; - } - } - - /// - /// Finalizes an instance of the class. - /// - ~TWStatusUtf8() - { - Dispose(false); - } - - #endregion - } - - - /// - /// This structure is used to handle the user interface coordination between an application and a - /// Source. - /// - partial class TWUserInterface - { - /// - /// Set to TRUE by the application if the Source should activate its built-in user - /// interface. Otherwise, set to FALSE. Note that not all sources support ShowUI = - /// FALSE. - /// - public bool ShowUI - { - get { return _showUI > 0; } - set { _showUI = value ? TwainConst.True : TwainConst.False; } - } - /// - /// If ShowUI is TRUE, then an application setting this to TRUE requests the Source to - /// run Modal. - /// - public bool ModalUI - { - //get { return _modalUI > 0; } - set { _modalUI = value ? TwainConst.True : TwainConst.False; } - } - /// - /// Microsoft Windows only: Application’s window handle. The Source designates - /// the hWnd as its parent when creating the Source dialog. - /// - public IntPtr hParent - { - //get { return _hParent; } - set { _hParent = value; } - } - } - - - - /// - /// Provides entry points required by TWAIN 2.0 Applications and Sources. - /// - partial class TWEntryPoint : IMemoryManager - { - /// - /// Initializes a new instance of the class. - /// - public TWEntryPoint() - { - _size = (uint)Marshal.SizeOf(this); - } - - #region IMemoryManager Members - - public IntPtr Allocate(uint size) - { - return _dSM_MemAllocate(size); - } - - public void Free(IntPtr handle) - { - _dSM_MemFree(handle); - } - - public IntPtr Lock(IntPtr handle) - { - return _dSM_MemLock(handle); - } - - public void Unlock(IntPtr handle) - { - _dSM_MemUnlock(handle); - } - - #endregion - } - - - /// - /// The range of colors specified by this structure is replaced with Replacement grayscale value in the - /// binary image. The color is specified in HSV color space. - /// - public partial class TWFilterDescriptor - { - /// - /// Initializes a new instance of the struct. - /// - public TWFilterDescriptor() - { - _size = (uint)Marshal.SizeOf(this); - } - - /// - /// Size of this structure in bytes. - /// - /// - /// The size. - /// - public uint Size { get { return _size; } set { _size = value; } } - /// - /// Hue starting number. Valid values 0 to 3600 (0° to 360°). - /// - public uint HueStart { get { return _hueStart; } set { _hueStart = value; } } - /// - /// Hue ending number. Valid values 0 to 3600 (0° to 360°). - /// - public uint HueEnd { get { return _hueEnd; } set { _hueEnd = value; } } - /// - /// Saturation starting number. Valid values 0 to 1000 (0% to 100%). - /// - public uint SaturationStart { get { return _saturationStart; } set { _saturationStart = value; } } - /// - /// Saturation ending number. Valid values 0 to 1000 (0% to 100%). - /// - public uint SaturationEnd { get { return _saturationEnd; } set { _saturationEnd = value; } } - /// - /// Luminosity starting number. Valid values 0 to 1000 (0% to 100%). - /// - public uint ValueStart { get { return _valueStart; } set { _valueStart = value; } } - /// - /// Luminosity ending number. Valid values 0 to 1000 (0% to 100%). - /// - public uint ValueEnd { get { return _valueEnd; } set { _valueEnd = value; } } - /// - /// Replacement grayscale value. Valid values 0 to (2^32)–1 (Maximum value - /// depends on grayscale bit depth). - /// - public uint Replacement { get { return _replacement; } set { _replacement = value; } } - } - - /// - /// Specifies the filter to be applied during image acquisition. More than one descriptor can be - /// specified. All descriptors are applied with an OR statement. - /// - public partial class TWFilter - { - /// - /// Initializes a new instance of the class. - /// - public TWFilter() - { - _size = (uint)Marshal.SizeOf(this); - } - - /// - /// Number of descriptors in hDescriptors array. - /// - /// - /// The descriptor count. - /// - public uint DescriptorCount { get { return _descriptorCount; } set { _descriptorCount = value; } } - /// - /// Maximum possible descriptors. Valid only for GET and GETDEFAULT operations. - /// - /// - /// The maximum descriptor count. - /// - public uint MaxDescriptorCount { get { return _maxDescriptorCount; } set { _maxDescriptorCount = value; } } - /// - /// If the value is 0 filter will check if current pixel color is inside the area - /// specified by the descriptor. If the value is 1 it will check if it is outside - /// of this area. - /// - /// - /// The condition. - /// - public uint Condition { get { return _condition; } set { _condition = value; } } - /// - /// Handle to array of . - /// - /// - /// The descriptors. - /// - public IntPtr hDescriptors { get { return _hDescriptors; } set { _hDescriptors = value; } } - } - - -} diff --git a/src/NTwain/Data/TwainValues.cs b/src/NTwain/Data/TwainValues.cs deleted file mode 100644 index 3c4bea3..0000000 --- a/src/NTwain/Data/TwainValues.cs +++ /dev/null @@ -1,2152 +0,0 @@ -using System; - -namespace NTwain.Data -{ - // these are from the corresponding twain.h sections - - /**************************************************************************** - * Generic Constants * - ****************************************************************************/ - - #region gen constants - - /// - /// Indicates the type of container used in capability. - /// Corresponds to TWON_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum ContainerType : ushort - { - /// - /// The default value for this enum. - /// - Invalid = 0, - /// - /// The container is . - /// - Array = 3, - /// - /// The container is . - /// - Enum = 4, - /// - /// The container is . - /// - OneValue = 5, - /// - /// The container is . - /// - Range = 6, - /// - /// The don't care value. - /// - DoNotCare = TwainConst.DoNotCare16, - } - - /// - /// Flags used in . - /// Corresponds to TWMF_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - [Flags] - public enum MemoryFlags : uint - { - None = 0, - AppOwns = 0x1, - DsmOwns = 0x2, - DSOwns = 0x4, - Pointer = 0x8, - Handle = 0x10 - } - - /// - /// The data types of item in TWAIN, used in the - /// capability containers. - /// Corresponds to TWTY_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1027:MarkEnumsWithFlags")] - public enum ItemType : ushort - { - /// - /// Means Item is a an 8 bit value. - /// - Int8 = 0, - /// - /// Means Item is a 16 bit value. - /// - Int16 = 1, - /// - /// Means Item is a 32 bit value. - /// - Int32 = 2, - /// - /// Means Item is an unsigned 8 bit value. - /// - UInt8 = 3, - /// - /// Means Item is an unsigned 16 bit value. - /// - UInt16 = 4, - /// - /// Means Item is an unsigned 32 bit value. - /// - UInt32 = 5, - /// - /// Means Item is an unsigned 16 bit value (supposedly, YMMV). - /// - Bool = 6, - /// - /// Means Item is a . - /// - Fix32 = 7, - /// - /// Means Item is a . - /// - Frame = 8, - /// - /// Means Item is a 32 char string (max). - /// - String32 = 9, - /// - /// Means Item is a 64 char string (max). - /// - String64 = 0xa, - /// - /// Means Item is a 128 char string (max). - /// - String128 = 0xb, - /// - /// Means Item is a char string shorter than 255. - /// - String255 = 0xc, - //String1024 = 0xd, - //Unicode512 = 0xe, - /// - /// Means Item is a handle (pointer). - /// - Handle = 0xf - } - - #endregion - - /**************************************************************************** - * Capability Constants * - ****************************************************************************/ - - #region cap constants - - /// - /// CapAlarms values. - /// Corresponds to TWAL_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum AlarmType : ushort - { - Alarm = 0, - FeederError = 1, - FeederWarning = 2, - Barcode = 3, - DoubleFeed = 4, - Jam = 5, - PatchCode = 6, - Power = 7, - Skew = 8 - } - - /// - /// ICapAutoSize values. - /// Corresponds to TWAS_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum AutoSize : ushort - { - None = 0, - Auto = 1, - Current = 2 - } - - /// - /// The bar code’s orientation on the scanned image is described in - /// reference to a Western-style interpretation of the image. - /// Corresponds to TWBCOR_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum BarcodeRotation : uint - { - /// - /// Normal reading orientation. - /// - Rot0 = 0, - /// - /// Rotated 90 degrees clockwise. - /// - Rot90 = 1, - /// - /// Rotated 180 degrees clockwise. - /// - Rot180 = 2, - /// - /// Rotated 270 degrees clockwise. - /// - Rot270 = 3, - /// - /// The orientation is not known. - /// - RotX = 4 - } - - /// - /// ICapBarcodeSearchMode values, - /// ICapPatchCodeSearchMode values. - /// Corresponds to TWBD_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum BarcodeDirection : ushort - { - Horz = 0, - Vert = 1, - HorzVert = 2, - VertHorz = 3 - } - - /// - /// ICapBitOrder/ICapBitOrderCodes values. - /// Corresponds to TWBO_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum BitOrder : ushort - { - LsbFirst = 0, - MsbFirst = 1 - } - - /// - /// ICapAutoDiscardBlankPages values. - /// Corresponds to TWBP_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum BlankPage //: short - { - Invalid = 0, - Disable = -2, - Auto = -1 - } - - /// - /// Values for ICapBitDepthReduction. - /// Corresponds to TWBR_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum BitDepthReduction : ushort - { - Threshold = 0, - Halftone = 1, - CustHalftone = 2, - Diffusion = 3, - DynamicThreashold = 4 - } - - /// - /// ICapBarcodeSearchPriorities values, - /// ICapSupportedBarcodeTypes values. - /// Corresponds to TWBT_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum BarcodeType : ushort - { - ThreeOfNine = 0, - TwoOfFiveInterleaved = 1, - TwoOfFiveNonInterleaved = 2, - Code92 = 3, - Code128 = 4, - Ucc128 = 5, - Codabar = 6, - UpcA = 7, - UpcE = 8, - Ean8 = 9, - Ean13 = 10, - PostNet = 11, - Pdf417 = 12, - TwoOfFiveIndustrial = 13, - TwoOfFiveMatrix = 14, - TwoOfFiveDataLogic = 15, - TwoOfFiveIata = 16, - ThreeOfNineFullAscii = 17, - CodabarWithStartStop = 18, - MaxiCode = 19, - QRCode = 20 - } - - /// - /// ICapCompression values. Allows the application and Source to identify which compression schemes they have in common - /// for Buffered Memory and File transfers. Since only certain file formats support compression, this capability must be negotiated after - /// setting the desired file format with ICAP_IMAGEFILEFORMAT. - /// Corresponds to TWCP_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum CompressionType : ushort - { - /// - /// All Sources must support this. - /// - None = 0, - /// - /// Can be used with TIFF or PICT - /// - PackBits = 1, - /// - /// From the CCITT specification (now ITU), intended for document images (can be used with TIFF). - /// - Group31D = 2, - /// - /// From the CCITT specification (now ITU), intended for document images (can be used with TIFF). - /// - Group31DEol = 3, - /// - /// From the CCITT specification (now ITU), intended for document images (can be used with TIFF). - /// - Group32D = 4, - /// - /// From the CCITT specification (now ITU), intended for document images (can be used with TIFF). - /// - Group4 = 5, - /// - /// Intended for the compression of color photographs (can be used with TIFF, JFIF or SPIFF). - /// - Jpeg = 6, - /// - /// A compression licensed by UNISYS (can be used with TIFF). - /// - Lzw = 7, - /// - /// Intended for bitonal and grayscale document images (can be used with TIFF or SPIFF). - /// - Jbig = 8, - /// - /// This compression can only be used if ICAP_IMAGEFILEFORMAT is set to TWFF_PNG. - /// - Png = 9, - /// - /// Can only be used if ICAP_IMAGEFILEFORMAT is set to TWFF_BMP. - /// - Rle4 = 10, - /// - /// Can only be used if ICAP_IMAGEFILEFORMAT is set to TWFF_BMP. - /// - Rle8 = 11, - /// - /// Can only be used if ICAP_IMAGEFILEFORMAT is set to TWFF_BMP. - /// - BitFields = 12, - /// - /// Per RFC 1951 (AKA 'Flate' and 'Deflate') - /// - Zip = 13, - /// - /// Per ISO/IEC 15444 - /// - Jpeg2000 = 14 - } - - /// - /// CapCameraSide/TWEI_PAGESIDE values. - /// Corresponds to TWCS_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum CameraSide : ushort - { - Both = 0, - Top = 1, - Bottom = 2 - } - - /// - /// CapClearBuffers values. - /// Corresponds to TWCB_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum ClearBuffer : ushort - { - Auto = 0, - Clear = 1, - NoClear = 2 - } - - /// - /// Indicates the type of event from the source. - /// Also CapDeviceEvent values. If used as - /// a cap value it's ushort. - /// Corresponds to TWDE_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1027:MarkEnumsWithFlags")] - public enum DeviceEvent : uint // using uint to support custom event values - { - 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, - - CustomEvents = 0x8000 - } - - /// - /// values. - /// Corresponds to TWDR_* values. - /// - public enum Direction // using int to match TWPassThru - { - Invalid = 0, - Get = 1, - Set = 2 - } - - /// - /// TWEI_DESKEWSTATUS values. - /// Corresponds to TWDSK_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum DeskewStatus : uint - { - Success = 0, - ReportOnly = 1, - Fail = 2, - Disabled = 3 - } - - /// - /// CapDuplex values. - /// Corresponds to TWDX_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum Duplex : ushort - { - None = 0, - OnePass = 1, - TwoPass = 2 - } - - /// - /// CapFeederAlignment values. - /// Corresponds to TWFA_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum FeederAlignment : ushort - { - None = 0, - Left = 1, - Center = 2, - Right = 3 - } - - /// - /// ICapFeederType values. - /// Corresponds to TWFE_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum FeederType : ushort - { - General = 0, - Photo = 1 - } - - /// - /// ICapImageFileFormat values. - /// Corresponds to TWFF_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1027:MarkEnumsWithFlags")] - public enum FileFormat : ushort - { - /// - /// Used for document imaging. Native Linux format. - /// - Tiff = 0, - /// - /// Native Macintosh format - /// - Pict = 1, - /// - /// Native Microsoft format - /// - Bmp = 2, - /// - /// Used for document imaging - /// - Xbm = 3, - /// - /// Wrapper for JPEG images - /// - Jfif = 4, - /// - /// FlashPix, used with digital cameras - /// - Fpx = 5, - /// - /// Multi-page TIFF files - /// - TiffMulti = 6, - /// - /// An image format standard intended for use on the web, replaces GIF - /// - Png = 7, - /// - /// A standard from JPEG, intended to replace JFIF, also supports JBIG - /// - Spiff = 8, - /// - /// File format for use with digital cameras. - /// - Exif = 9, - /// - /// A file format from Adobe - /// - Pdf = 10, - /// - /// A file format from the Joint Photographic Experts Group ISO/IEC 15444-1 - /// - Jp2 = 11, - /// - /// A file format from the Joint Photographic Experts Group ISO/IEC 15444-2 - /// - Jpx = 13, - /// - /// A file format from LizardTech - /// - Dejavu = 14, - /// - /// A file format from Adobe PDF/A, Version 1 - /// - PdfA = 15, - /// - /// A file format from Adobe PDF/A, Version 2 - /// - PdfA2 = 16 - } - - /// - /// ICapFlashUsed2 values. - /// Corresponds to TWFL_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum FlashedUsed : ushort - { - None = 0, - Off = 1, - On = 2, - Auto = 3, - Redeye = 4 - } - - /// - /// CapFeederOrder values. - /// Corresponds to TWFO_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum FeederOrder : ushort - { - FirstPageFirst = 0, - LastPageFirst = 1 - } - - /// - /// CapFeederPocket values. - /// Corresponds to TWFP_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum FeederPocket : 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, - } - - /// - /// ICapFlipRotation values. - /// Corresponds to TWFR_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum FlipRotation : ushort - { - Book = 0, - Fanfold = 1 - } - - /// - /// ICapFilter values. - /// Corresponds to TWFT_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum FilterType : ushort - { - Red = 0, - Green = 1, - Blue = 2, - None = 3, - White = 4, - Cyan = 5, - Magenta = 6, - Yellow = 7, - Black = 8 - } - - /// - /// values. - /// Corresponds to TWFY_* values. - /// - public enum FileType // using int to match value - { - Camera = 0, - CameraTop = 1, - CameraBottom = 2, - CameraPreview = 3, - Domain = 4, - Host = 5, - Directory = 6, - Image = 7, - Unknown = 8 - } - - /// - /// ICapIccProfile values. - /// Corresponds to TWIC* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum IccProfile : ushort - { - None = 0, - Link = 1, - Embed = 2 - } - - /// - /// ICapImageFilter values. - /// Corresponds to TWIF_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum ImageFilter : ushort - { - None = 0, - Auto = 1, - LowPass = 2, - BandPass = 3, - HighPass = 4, - Text = BandPass, - FineLine = HighPass - } - - /// - /// ICapImageMerge values. - /// Corresponds to TWIM_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum ImageMerge : ushort - { - None = 0, - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "FrontOn")] - FrontOnTop = 1, - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "FrontOn")] - FrontOnBottom = 2, - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "FrontOn")] - FrontOnLeft = 3, - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "FrontOn")] - FrontOnRight = 4 - } - - /// - /// CapJobControl values. - /// Corresponds to TWJC_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum JobControl : ushort - { - /// - /// No job control. - /// - None = 0, - /// - /// Detect and include job separator and continue scanning. - /// - IncludeContinue = 1, - /// - /// Detect and include job separator and stop scanning. - /// - IncludeStop = 2, - /// - /// Detect and exclude job separator and continue scanning. - /// - ExcludeContinue = 3, - /// - /// Detect and exclude job separator and stop scanning. - /// - ExcludeStop = 4 - } - - /// - /// ICapJpegQuality values. - /// Corresponds to TWJQ_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum JpegQuality : short - { - Invalid = 0, - Unknown = -4, - Low = -3, - Medium = -2, - High = -1 - } - - /// - /// ICapLightPath values. - /// Corresponds to TWLP_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum LightPath : ushort - { - Reflective = 0, - Transmissive = 1 - } - - /// - /// ICapLightSource values. - /// Corresponds to TWLS_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum LightSource : ushort - { - Red = 0, - Green = 1, - Blue = 2, - None = 3, - White = 4, - UV = 5, - IR = 6 - } - - /// - /// TWEI_MAGTYPE values. - /// Corresponds to TWMD_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum MagType : ushort - { - Micr = 0, - Raw = 1, - Invalid = 2 - } - - /// - /// ICapNoiseFilter values. - /// Corresponds to TWNF_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum NoiseFilter : ushort - { - None = 0, - Auto = 1, - LonePixel = 2, - MajorityRule = 3 - } - - /// - /// ICapOrientation values. - /// Corresponds to TWOR_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum OrientationType : ushort - { - Rot0 = 0, - Rot90 = 1, - Rot180 = 2, - Rot270 = 3, - Portrait = Rot0, - Landscape = Rot270, - Auto = 4, - AutoTet = 5, - AutoPicture = 6 - } - - /// - /// ICapOverscan values. - /// Corresponds to TWOV_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum OverScan : ushort - { - None = 0, - Auto = 1, - TopBottom = 2, - LeftRight = 3, - All = 4 - } - - /// - /// values. - /// Corresponds to TWPA_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum PaletteType : ushort - { - Rgb = 0, - Gray = 1, - Cmy = 2 - } - - /// - /// ICapPlanarChunky values. - /// Corresponds to TWPC_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum PlanarChunky : ushort - { - Chunky = 0, - Planar = 1 - } - - /// - /// ICapPatchCodeSearchPriorities, - /// ICapSupportedPatchCodeTypes values. - /// Corresponds to TWPCH_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum PatchCode : ushort - { - Patch1 = 0, - Patch2 = 1, - Patch3 = 2, - Patch4 = 3, - Patch6 = 4, - PatchT = 5 - } - - /// - /// ICapPixelFlavor, ICapPixelFlavorCodes values. - /// Corresponds to TWPF_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum PixelFlavor : ushort - { - Chocolate = 0, - Vanilla = 1 - } - - /// - /// CapPrinterMode values. - /// Corresponds to TWPM_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum PrinterMode : ushort - { - SingleString = 0, - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "MultiString")] - MultiString = 1, - CompoundString = 2 - } - - /// - /// CapPrinter values. - /// Corresponds to TWPR_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum Printer : ushort - { - ImprinterTopBefore = 0, - ImprinterTopAfter = 1, - ImprinterBottomBefore = 2, - ImprinterBottomAfter = 3, - EndorserTopBefore = 4, - EndorserTopAfter = 5, - EndorserBottomBefore = 6, - EndorserBottomAfter = 7 - } - - /// - /// CapPrinterFontStyle values. - /// Corresponds to TWPF_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum PrinterFontStyle : ushort - { - Normal = 0, - Bold = 1, - Italic = 2, - LargeSize = 3, - SmallSize = 4 - } - - /// - /// CapPrinterIndexTrigger values. - /// Corresponds to TWCT_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum PrinterIndexTrigger : ushort - { - Page = 0, - Patch1 = 1, - Patch2 = 2, - Patch3 = 3, - Patch4 = 4, - PatchT = 5, - Patch6 = 6 - } - - /// - /// CapPowerSupply values. - /// Corresponds to TWPS_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum PowerSupply : ushort - { - External = 0, - Battery = 1 - } - - /// - /// Also ICapAutomaticColorNonColorPixelType (bw/gray), - /// ICapJpegPixelType, ICapPixelType values. - /// Corresponds to TWPT_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1027:MarkEnumsWithFlags")] - public enum PixelType : ushort - { - BlackWhite = 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 - } - - /// - /// CapSegmented values. - /// Corresponds to TWSG_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum Segmented : ushort - { - None = 0, - Auto = 1, - Manual = 2 - } - - /// - /// ICapFilmType values. - /// Corresponds to TWFM_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum FilmType : ushort - { - Positive = 0, - Negative = 1 - } - - /// - /// CapDoubleFeedDetection values. - /// Corresponds to TWDF_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum DoubleFeedDetection : ushort - { - Ultrasonic = 0, - ByLength = 1, - Infrared = 2 - } - - /// - /// CapDoubleFeedDetectionSensitivity values. - /// Corresponds to TWUS_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum DoubleFeedDetectionSensitivity : ushort - { - Low = 0, - Medium = 1, - High = 2 - } - - /// - /// CapDoubleFeedDetectionResponse values. - /// Corresponds to TWDP_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum DoubleFeedDetectionResponse : ushort - { - Stop = 0, - StopAndWait = 1, - Sound = 2, - DoNotImprint = 3 - } - - /// - /// ICapMirror values. - /// Corresponds to TWMR* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum Mirror : ushort - { - None = 0, - Vertical = 1, - Horizontal = 2 - } - - /// - /// ICapJpegSubsampling values. - /// Corresponds to TWJS_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum JpegSubsampling : ushort - { - x444YCBCR = 0, - x444RGB = 1, - x422 = 2, - x421 = 3, - x411 = 4, - x420 = 5, - x410 = 6, - x311 = 7 - } - - /// - /// CapPaperHandling values. - /// Corresponds to TWPH_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum PaperHandling : ushort - { - Normal = 0, - Fragile = 1, - Thick = 2, - Trifold = 3, - Photograph = 4 - } - - /// - /// CapIndicatorsMode values. - /// Corresponds to TWCI_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum IndicatorsMode : ushort - { - Info = 0, - Warning = 1, - Error = 2, - Warmup = 3 - } - - /// - /// ICapSupportedSizes values. - /// Corresponds to TWSS_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum SupportedSize : 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, - FourA0 = 17, - TwoA0 = 18, - 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 = 31, - 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 - } - - /// - /// ICapXferMech, ACapXferMech values. - /// Corresponds to TWSX_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1027:MarkEnumsWithFlags")] - public enum XferMech : ushort - { - Native = 0, - File = 1, - Memory = 2, - MemFile = 4 - } - - /// - /// ICapUnits values. - /// Corresponds to TWUN_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum Unit : ushort - { - Inches = 0, - Centimeters = 1, - Picas = 2, - Points = 3, - Twips = 4, - Pixels = 5, - Millimeters = 6 - } - - #endregion - - /**************************************************************************** - * others * - ****************************************************************************/ - - /// - /// Corresponds to TWCY_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum Country : ushort - { - None = 0, - Afghanistan = 1001, - Algeria = 213, - AmericanSamoa = 684, - Andorra = 033, - Angola = 1002, - Anguilla = 8090, - Antigua = 8091, - Argentina = 54, - Aruba = 297, - AscensionIsland = 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, - BritishVirginIslands = 8095, - Brazil = 55, - Brunei = 673, - Bulgaria = 359, - BurkinaFaso = 1004, - Burma = 1005, - Burundi = 1006, - Camaroon = 237, - Canada = 2, - CapeVerdeIslands = 238, - CaymanIslands = 8096, - CentralAfricanRepublic = 1007, - Chad = 1008, - Chile = 56, - China = 86, - ChristmasIsland = 1009, - CocosIslands = 1009, - Colombia = 57, - Comoros = 1010, - Congo = 1011, - CookIs = 1012, - Costarica = 506, - Cuba = 005, - Cyprus = 357, - Czechoslovakia = 42, - Denmark = 45, - Djibouti = 1013, - Dominica = 8097, - DomincanRep = 8098, - EasterIs = 1014, - Ecuador = 593, - Egypt = 20, - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "El")] - 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, - } - - /// - /// Corresponds to TWLG_* values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum Language : short - { - UserLocale = -1, - Danish = 0, - Dutch = 1, - English = 2, - FrenchCanadian = 3, - Finnish = 4, - French = 5, - German = 6, - Icelandic = 7, - Italian = 8, - Norwegian = 9, - Portuguese = 10, - Spanish = 11, - Swedish = 12, - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "USA")] - EnglishUSA = 13, - Afrikaans = 14, - Albania = 15, - Arabic = 16, - ArabicAlgeria = 17, - ArabicBahrain = 18, - ArabicEgypt = 19, - ArabicIraq = 20, - ArabicJordan = 21, - ArabicKuwait = 22, - ArabicLebanon = 23, - ArabicLibya = 24, - ArabicMorocco = 25, - ArabicOman = 26, - ArabicQatar = 27, - ArabicSaudiArabia = 28, - ArabicSyria = 29, - ArabicTunisia = 30, - ArabicUAE = 31, - ArabicYemen = 32, - Basque = 33, - Byelorussian = 34, - Bulgarian = 35, - Catalan = 36, - Chinese = 37, - ChineseHongKong = 38, - ChinesePRC = 39, - ChineseSingapore = 40, - ChineseSimplified = 41, - ChineseTaiwan = 42, - ChineseTraditional = 43, - Croatia = 44, - Czech = 45, - DutchBelgian = 46, - EnglishAustralian = 47, - EnglishCanadian = 48, - EnglishIreland = 49, - EnglishNewZealand = 50, - EnglishSouthAfrica = 51, - EnglishUK = 52, - Estonian = 53, - Faeroese = 54, - Farsi = 55, - FrenchBelgian = 56, - FrenchLuxembourg = 57, - FrenchSwiss = 58, - GermanAustrian = 59, - GermanLuxembourg = 60, - GermanLiechtenstein = 61, - GermanSwiss = 62, - Greek = 63, - Hebrew = 64, - Hungarian = 65, - Indonesian = 66, - ItalianSwiss = 67, - Japanese = 68, - Korean = 69, - KoreanJohab = 70, - Latvian = 71, - Lithuanian = 72, - NorwegianBokmal = 73, - NorwegianNynorsk = 74, - Polish = 75, - PortugueseBrazil = 76, - Romanian = 77, - Russian = 78, - SerbianLatin = 79, - Slovak = 80, - Slovenian = 81, - SpanishMexican = 82, - SpanishModern = 83, - 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, - SerbianCyrillic = 106, - Sikkimi = 107, - SwedishFinland = 108, - Tamil = 109, - Telugu = 110, - Tripuri = 111, - Urdu = 112, - Vietnamese = 113, - } - - - /// - /// Corresponds to DG_*. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2217:DoNotMarkEnumsWithFlags")] - [Flags] - public enum DataGroups : uint - { - None = 0, - Control = 0x1, - Image = 0x2, - Audio = 0x4, - Mask = 0xffff, - } - - /// - /// Corresponds to DF_*. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - [Flags] - public enum DataFunctionalities : uint - { - None = 0, - Dsm2 = 0x10000000, - App2 = 0x20000000, - Ds2 = 0x40000000, - } - - /// - /// Corresponds to DAT_*. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum DataArgumentType : ushort - { - Null = 0, - CustomBase = 0x8000, - - // control 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, - - // image group - ImageInfo = 0x101, - ImageLayout = 0x102, - ImageMemXfer = 0x103, - ImageNativeXfer = 0x104, - ImageFileXfer = 0x105, - CieColor = 0x106, - GrayResponse = 0x107, - RgbResponse = 0x108, - JpegCompression = 0x109, - Palette8 = 0x10a, - ExtImageInfo = 0x10b, - Filter = 0x10c, - - // audio group - AudioFileXfer = 0x201, - AudioInfo = 0x202, - AudioNativeXfer = 0x203, - - // crap - IccProfile = 0x401, - ImageMemFileXfer = 0x402, - EntryPoint = 0x403, - } - - /// - /// Corresponds to MSG_*. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum Message : ushort - { - Null = 0, - CustomBase = 0x8000, - - // 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 = 0x801, - CreateDirectory = 0x802, - Delete = 0x803, - FormatMedia = 0x804, - GetClose = 0x805, - GetFirstFile = 0x806, - GetInfo = 0x807, - GetNextFile = 0x808, - Rename = 0x809, - Copy = 0x80a, - AutomaticCaptureDirectory = 0x80b, - - // Messages used with a pointer to a DAT_PASSTHRU structure - PassThru = 0x901, - - // used with DAT_CALLBACK - RegisterCallback = 0x902, - - // used with DAT_CAPABILITY - ResetAll = 0xa01, - } - - /// - /// Indicates the type of capability. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum CapabilityId : ushort - { - None = 0, - CustomBase = 0x8000, /* Base of custom capabilities */ - - /* all data sources are REQUIRED to support these caps */ - CapXferCount = 0x0001, - - /* image data sources are REQUIRED to support these caps */ - ICapCompression = 0x0100, - ICapPixelType = 0x0101, - ICapUnits = 0x0102, /* default is TWUN_INCHES */ - ICapXferMech = 0x0103, - - /* all data sources MAY support these caps */ - CapAuthor = 0x1000, - CapCaption = 0x1001, - CapFeederEnabled = 0x1002, - CapFeederLoaded = 0x1003, - CapTimeDate = 0x1004, - CapSupportedCaps = 0x1005, - CapExtendedCaps = 0x1006, - CapAutoFeed = 0x1007, - CapClearPage = 0x1008, - CapFeedPage = 0x1009, - CapRewindPage = 0x100a, - CapIndicators = 0x100b, /* Added 1.1 */ - CapPaperDetectable = 0x100d, /* Added 1.6 */ - CapUIControllable = 0x100e, /* Added 1.6 */ - CapDeviceOnline = 0x100f, /* Added 1.6 */ - CapAutoScan = 0x1010, /* Added 1.6 */ - CapThumbnailsEnabled = 0x1011, /* Added 1.7 */ - CapDuplex = 0x1012, /* Added 1.7 */ - CapDuplexEnabled = 0x1013, /* Added 1.7 */ - CapEnableDSUIOnly = 0x1014, /* Added 1.7 */ - CapCustomDSData = 0x1015, /* Added 1.7 */ - CapEndorser = 0x1016, /* Added 1.7 */ - CapJobControl = 0x1017, /* Added 1.7 */ - CapAlarms = 0x1018, /* Added 1.8 */ - CapAlarmVolume = 0x1019, /* Added 1.8 */ - CapAutomaticCapture = 0x101a, /* Added 1.8 */ - CapTimeBeforeFirstCapture = 0x101b, /* Added 1.8 */ - CapTimeBetweenCaptures = 0x101c, /* Added 1.8 */ - CapClearBuffers = 0x101d, /* Added 1.8 */ - CapMaxBatchBuffers = 0x101e, /* Added 1.8 */ - CapDeviceTimeDate = 0x101f, /* Added 1.8 */ - CapPowerSupply = 0x1020, /* Added 1.8 */ - CapCameraPreviewUI = 0x1021, /* Added 1.8 */ - CapDeviceEvent = 0x1022, /* Added 1.8 */ - CapSerialNumber = 0x1024, /* Added 1.8 */ - CapPrinter = 0x1026, /* Added 1.8 */ - CapPrinterEnabled = 0x1027, /* Added 1.8 */ - CapPrinterIndex = 0x1028, /* Added 1.8 */ - CapPrinterMode = 0x1029, /* Added 1.8 */ - CapPrinterString = 0x102a, /* Added 1.8 */ - CapPrinterSuffix = 0x102b, /* Added 1.8 */ - CapLanguage = 0x102c, /* Added 1.8 */ - CapFeederAlignment = 0x102d, /* Added 1.8 */ - CapFeederOrder = 0x102e, /* Added 1.8 */ - CapReacquireAllowed = 0x1030, /* Added 1.8 */ - CapBatteryMinutes = 0x1032, /* Added 1.8 */ - CapBatteryPercentage = 0x1033, /* Added 1.8 */ - CapCameraSide = 0x1034, /* Added 1.91 */ - CapSegmented = 0x1035, /* Added 1.91 */ - CapCameraEnabled = 0x1036, /* Added 2.0 */ - CapCameraOrder = 0x1037, /* Added 2.0 */ - CapMicrEnabled = 0x1038, /* Added 2.0 */ - CapFeederPrep = 0x1039, /* Added 2.0 */ - CapFeederPocket = 0x103a, /* Added 2.0 */ - CapAutomaticSenseMedium = 0x103b, /* Added 2.1 */ - CapCustomInterfaceGuid = 0x103c, /* Added 2.1 */ - CapSupportedCapsSegmentUnique = 0x103d, - CapSupportedDATs = 0x103e, - CapDoubleFeedDetection = 0x103f, - CapDoubleFeedDetectionLength = 0x1040, - CapDoubleFeedDetectionSensitivity = 0x1041, - CapDoubleFeedDetectionResponse = 0x1042, - CapPaperHandling = 0x1043, - CapIndicatorsMode = 0x1044, - CapPrinterVerticalOffset = 0x1045, - CapPowerSaveTime = 0x1046, - CapPrinterCharRotation = 0x1047, - CapPrinterFontStyle = 0x1048, - CapPrinterIndexLeadChar = 0x1049, - CapPrinterIndexMaxValue = 0x104A, - CapPrinterIndexNumDigits = 0x104B, - CapPrinterIndexStep = 0x104C, - CapPrinterIndexTrigger = 0x104D, - CapPrinterStringPreview = 0x104E, - - - /* image data sources MAY support these caps */ - ICapAutoBright = 0x1100, - ICapBrightness = 0x1101, - ICapContrast = 0x1103, - ICapCustHalftone = 0x1104, - ICapExposureTime = 0x1105, - ICapFilter = 0x1106, - [Obsolete("Use ICapFlashUsed2 instead.")] - ICapFlashUsed = 0x1107, - ICapGamma = 0x1108, - ICapHalftones = 0x1109, - ICapHighlight = 0x110a, - ICapImageFileFormat = 0x110c, - ICapLampState = 0x110d, - ICapLightSource = 0x110e, - ICapOrientation = 0x1110, - ICapPhysicalWidth = 0x1111, - ICapPhysicalHeight = 0x1112, - ICapShadow = 0x1113, - ICapFrames = 0x1114, - ICapXNativeResolution = 0x1116, - ICapYNativeResolution = 0x1117, - ICapXResolution = 0x1118, - ICapYResolution = 0x1119, - ICapMaxFrames = 0x111a, - ICapTiles = 0x111b, - ICapBitOrder = 0x111c, - ICapCCITTKFactor = 0x111d, - ICapLightPath = 0x111e, - ICapPixelFlavor = 0x111f, - ICapPlanarChunky = 0x1120, - ICapRotation = 0x1121, - ICapSupportedSizes = 0x1122, - ICapThreshold = 0x1123, - ICapXScaling = 0x1124, - ICapYScaling = 0x1125, - ICapBitOrderCodes = 0x1126, - ICapPixelFlavorCodes = 0x1127, - ICapJpegPixelType = 0x1128, - ICapTimeFill = 0x112a, - ICapBitDepth = 0x112b, - ICapBitDepthReduction = 0x112c, /* Added 1.5 */ - ICapUndefinedImageSize = 0x112d, /* Added 1.6 */ - ICapImageDataSet = 0x112e, /* Added 1.7 */ - ICapExtImageInfo = 0x112f, /* Added 1.7 */ - ICapMinimumHeight = 0x1130, /* Added 1.7 */ - ICapMinimumWidth = 0x1131, /* Added 1.7 */ - ICapAutoDiscardBlankPages = 0x1134, /* Added 2.0 */ - ICapFlipRotation = 0x1136, /* Added 1.8 */ - ICapBarcodeDetectionEnabled = 0x1137, /* Added 1.8 */ - ICapSupportedBarcodeTypes = 0x1138, /* Added 1.8 */ - ICapBarcodeMaxSearchPriorities = 0x1139, /* Added 1.8 */ - ICapBarcodeSearchPriorities = 0x113a, /* Added 1.8 */ - ICapBarcodeSearchMode = 0x113b, /* Added 1.8 */ - ICapBarcodeMaxRetries = 0x113c, /* Added 1.8 */ - ICapBarcodeTimeout = 0x113d, /* Added 1.8 */ - ICapZoomFactor = 0x113e, /* Added 1.8 */ - ICapPatchCodeDetectionEnabled = 0x113f, /* Added 1.8 */ - ICapSupportedPatchCodeTypes = 0x1140, /* Added 1.8 */ - ICapPatchCodeMaxSearchPriorities = 0x1141, /* Added 1.8 */ - ICapPatchCodeSearchPriorities = 0x1142, /* Added 1.8 */ - ICapPatchCodeSearchMode = 0x1143, /* Added 1.8 */ - ICapPatchCodeMaxRetries = 0x1144, /* Added 1.8 */ - ICapPatchCodeTimeout = 0x1145, /* Added 1.8 */ - ICapFlashUsed2 = 0x1146, /* Added 1.8 */ - ICapImageFilter = 0x1147, /* Added 1.8 */ - ICapNoiseFilter = 0x1148, /* Added 1.8 */ - ICapOverScan = 0x1149, /* Added 1.8 */ - ICapAutomaticBorderDetection = 0x1150, /* Added 1.8 */ - ICapAutomaticDeskew = 0x1151, /* Added 1.8 */ - ICapAutomaticRotate = 0x1152, /* Added 1.8 */ - ICapJpegQuality = 0x1153, /* Added 1.9 */ - ICapFeederType = 0x1154, /* Added 1.91 */ - ICapICCProfile = 0x1155, /* Added 1.91 */ - ICapAutoSize = 0x1156, /* Added 2.0 */ - ICapAutomaticCropUsesFrame = 0x1157, /* Added 2.1 */ - ICapAutomaticLengthDetection = 0x1158, /* Added 2.1 */ - ICapAutomaticColorEnabled = 0x1159, /* Added 2.1 */ - ICapAutomaticColorNonColorPixelType = 0x115a, /* Added 2.1 */ - ICapColorManagementEnabled = 0x115b, /* Added 2.1 */ - ICapImageMerge = 0x115c, /* Added 2.1 */ - ICapImageMergeHeightThreshold = 0x115d, /* Added 2.1 */ - ICapSupportedExtImageInfo = 0x115e, /* Added 2.1 */ - ICapFilmType = 0x115f, - ICapMirror = 0x1160, - ICapJpegSubsampling = 0x1161, - - /* image data sources MAY support these audio caps */ - ACapXferMech = 0x1202, /* Added 1.8 */ - - } - - /// - /// Extended Image Info Attributes. - /// Corresponds to TWEI_*. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum ExtendedImageInfo : ushort - { - Invalid = 0, - 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, /* added 1.9 */ - ChapterNumber = 0x1239,/* added 1.9 */ - DocumentNumber = 0x123A, /* added 1.9 */ - PageNumber = 0x123B, /* added 1.9 */ - Camera = 0x123C, /* added 1.9 */ - FrameNumber = 0x123D, /* added 1.9 */ - Frame = 0x123E, /* added 1.9 */ - PixelFlavor = 0x123F, /* added 1.9 */ - IccProfile = 0x1240, /* added 1.91 */ - LastSegment = 0x1241, /* added 1.91 */ - SegmentNumber = 0x1242, /* added 1.91 */ - MagData = 0x1243, /* added 2.0 */ - MagType = 0x1244, /* added 2.0 */ - PageSide = 0x1245, /* added 2.0 */ - FileSystemSource = 0x1246, /* added 2.0 */ - ImageMerged = 0x1247, /* added 2.1 */ - MagDataLength = 0x1248, /* added 2.1 */ - PaperCount = 0x1249, - PrinterText = 0x124a - } - - /// - /// EndXfer job control values. - /// Corresponds to TWEJ_*. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum EndXferJob : ushort - { - None = 0x0000, - MidSeparator = 0x0001, - Patch1 = 0x0002, - Patch2 = 0x0003, - Patch3 = 0x0004, - Patch4 = 0x0005, - Patch6 = 0x0006, - PatchT = 0x0007 - } - - /// - /// Corresponds to TWRC_*. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1027:MarkEnumsWithFlags")] - public enum ReturnCode : ushort - { - CustomBase = 0x8000, - - Success = 0, - Failure = 1, - CheckStatus = 2, - Cancel = 3, - DSEvent = 4, - NotDSEvent = 5, - XferDone = 6, - EndOfList = 7, - InfoNotSupported = 8, - DataNotAvailable = 9, - Busy = 10, - ScannerLocked = 11, - } - - /// - /// Corresponds to TWCC_*. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum ConditionCode : ushort - { - CustomBase = 0x8000, - - Success = 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, - - } - - /// - /// Bit mask for querying the operation that are supported by the data source on a capability. - /// Corresponds to TWQC_*. - /// - [Flags] - public enum QuerySupports - { - None = 0, - Get = 0x1, - Set = 0x2, - GetDefault = 0x4, - GetCurrent = 0x8, - Reset = 0x10, - SetConstraint = 0x20, - Constrainable = 0x40, - GetHelp = 0x100, - GetLabel = 0x200, - GetLabelEnum = 0x400, - - /// - /// Cap applies to entire session/machine. - /// - Machine = 0x1000, - /// - /// Cap applies to bitonal cameras. - /// - Bitonal = 0x2000, - /// - /// Cap applies to color cameras. - /// - Color = 0x4000 - } - - /// - /// TWAIN's boolean values. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum BoolType : ushort - { - /// - /// The false value (0). - /// - False = 0, - /// - /// The true value (1). - /// - True = 1 - } - - - /// - /// Contains direct magic values for some TWAIN stuff. - /// - public static class TwainConst - { - // these are specified here since the actual - // array length doesn't reflect the name :( - - /// - /// Length of an array that holds TW_STR32. - /// - public const int String32 = 34; - /// - /// Length of an array that holds TW_STR64. - /// - public const int String64 = 66; - /// - /// Length of an array that holds TW_STR128. - /// - public const int String128 = 130; - /// - /// Length of an array that holds TW_STR255. - /// - public const int String255 = 256; - - // deprecated - //public const int String1024 = 1026; - - /// - /// Don't care value for 8 bit types. - /// - public const byte DoNotCare8 = 0xff; - /// - /// Don't care value for 16 bit types. - /// - public const ushort DoNotCare16 = 0xffff; - /// - /// Don't care value for 32 bit types. - /// - public const uint DoNotCare32 = 0xffffffff; - - /// - /// The major version number of TWAIN supported by this library. - /// - public const short ProtocolMajor = 2; - /// - /// The minor version number of TWAIN supported by this library. - /// - public const short ProtocolMinor = 3; - - /// - /// Value for false where applicable. - /// - public const ushort True = 1; - /// - /// Value for true where applicable. - /// - public const ushort False = 0; - } -} diff --git a/src/NTwain/Data/TypeExtensions.cs b/src/NTwain/Data/TypeExtensions.cs deleted file mode 100644 index c538005..0000000 --- a/src/NTwain/Data/TypeExtensions.cs +++ /dev/null @@ -1,249 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Runtime.InteropServices; - -namespace NTwain.Data -{ - /// - /// Contains extensions for reading/writing TWAIN types from/to pointer. - /// - public static class TypeExtensions - { - static readonly IDictionary __sizes = new Dictionary - { - {ItemType.Int8, 1}, - {ItemType.UInt8, 1}, - {ItemType.Int16, 2}, - {ItemType.UInt16, 2}, - {ItemType.Bool, 2}, - {ItemType.Int32, 4}, - {ItemType.UInt32, 4}, - {ItemType.Fix32, 4}, - {ItemType.Frame, 16}, - {ItemType.String32, TwainConst.String32}, - {ItemType.String64, TwainConst.String64}, - {ItemType.String128, TwainConst.String128}, - {ItemType.String255, TwainConst.String255}, - // TODO: find out if it should be fixed 4 bytes or intptr size - {ItemType.Handle, IntPtr.Size}, - }; - - /// - /// Gets the byte size of the item type. - /// - /// - /// - public static int GetItemTypeSize(this ItemType type) - { - if (__sizes.ContainsKey(type)) - { - return __sizes[type]; - } - return 0; - } - - - /// - /// Reads a TWAIN value. - /// - /// The base address. - /// The offset. - /// The TWAIN type. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "1#")] - public static object ReadValue(this IntPtr baseAddress, ref int offset, ItemType type) - { - object val = null; - switch (type) - { - case ItemType.Int8: - val = (sbyte)Marshal.ReadByte(baseAddress, offset); - break; - case ItemType.UInt8: - val = Marshal.ReadByte(baseAddress, offset); - break; - case ItemType.Bool: - case ItemType.UInt16: - val = (ushort)Marshal.ReadInt16(baseAddress, offset); - break; - case ItemType.Int16: - val = Marshal.ReadInt16(baseAddress, offset); - break; - case ItemType.UInt32: - val = (uint)Marshal.ReadInt32(baseAddress, offset); - break; - case ItemType.Int32: - val = Marshal.ReadInt32(baseAddress, offset); - break; - case ItemType.Fix32: - TWFix32 f32 = new TWFix32(); - f32.Whole = Marshal.ReadInt16(baseAddress, offset); - f32.Fraction = (ushort)Marshal.ReadInt16(baseAddress, offset + 2); - val = f32; - break; - case ItemType.Frame: - TWFrame frame = new TWFrame(); - frame.Left = (TWFix32)ReadValue(baseAddress, ref offset, ItemType.Fix32); - frame.Top = (TWFix32)ReadValue(baseAddress, ref offset, ItemType.Fix32); - frame.Right = (TWFix32)ReadValue(baseAddress, ref offset, ItemType.Fix32); - frame.Bottom = (TWFix32)ReadValue(baseAddress, ref offset, ItemType.Fix32); - return frame; // no need to update offset again after reading fix32 - case ItemType.String128: - case ItemType.String255: - case ItemType.String32: - case ItemType.String64: - val = Marshal.PtrToStringAnsi(new IntPtr(baseAddress.ToInt64() + offset)); - break; - case ItemType.Handle: - val = Marshal.ReadIntPtr(baseAddress, offset); - break; - } - offset += GetItemTypeSize(type); - return val; - } - - - - #region writes - - /// - /// Writes a TWAIN value. - /// - /// The base addr. - /// The offset. - /// The TWAIN type. - /// The value. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "1#"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] - public static void WriteValue(this IntPtr baseAddr, ref int offset, ItemType type, object value) - { - switch (type) - { - case ItemType.Int8: - case ItemType.UInt8: - Marshal.WriteByte(baseAddr, offset, Convert.ToByte(value, CultureInfo.InvariantCulture));// (byte)value); - break; - case ItemType.Bool: - case ItemType.Int16: - case ItemType.UInt16: - Marshal.WriteInt16(baseAddr, offset, Convert.ToInt16(value, CultureInfo.InvariantCulture));//(short)value); - break; - case ItemType.UInt32: - case ItemType.Int32: - Marshal.WriteInt32(baseAddr, offset, Convert.ToInt32(value, CultureInfo.InvariantCulture));//(int)value); - break; - case ItemType.Fix32: - TWFix32 f32 = (TWFix32)value; - Marshal.WriteInt16(baseAddr, offset, f32.Whole); - if (f32.Fraction > Int16.MaxValue) - { - Marshal.WriteInt16(baseAddr, offset + 2, (Int16)(f32.Fraction - 32768)); - } - else - { - Marshal.WriteInt16(baseAddr, offset + 2, (Int16)f32.Fraction); - } - break; - case ItemType.Frame: - TWFrame frame = (TWFrame)value; - WriteValue(baseAddr, ref offset, ItemType.Fix32, (TWFix32)frame.Left); - WriteValue(baseAddr, ref offset, ItemType.Fix32, (TWFix32)frame.Top); - WriteValue(baseAddr, ref offset, ItemType.Fix32, (TWFix32)frame.Right); - WriteValue(baseAddr, ref offset, ItemType.Fix32, (TWFix32)frame.Bottom); - return; // no need to update offset for this - //case ItemType.String1024: - // WriteString(baseAddr, offset, value as string, 1024); - // break; - case ItemType.String128: - WriteString(baseAddr, offset, (string)value, 128); - break; - case ItemType.String255: - WriteString(baseAddr, offset, (string)value, 255); - break; - case ItemType.String32: - WriteString(baseAddr, offset, (string)value, 32); - break; - case ItemType.String64: - WriteString(baseAddr, offset, (string)value, 64); - break; - //case ItemType.Unicode512: - // WriteUString(baseAddr, offset, value as string, 512); - // break; - } - offset += TypeExtensions.GetItemTypeSize(type); - } - /// - /// Writes string value. THIS MAY BE WRONG. - /// - /// - /// - /// - /// - static void WriteString(IntPtr baseAddr, int offset, string item, int maxLength) - { - if (string.IsNullOrEmpty(item)) - { - // write zero - Marshal.WriteByte(baseAddr, offset, 0); - } - else - { - for (int i = 0; i < maxLength; i++) - { - if (i == item.Length) - { - // string end reached, so write \0 and quit - Marshal.WriteByte(baseAddr, offset, 0); - return; - } - else - { - Marshal.WriteByte(baseAddr, offset, (byte)item[i]); - offset++; - } - } - // when ended normally also write \0 - Marshal.WriteByte(baseAddr, offset, 0); - } - } - ///// - ///// Writes unicode string value. - ///// - ///// - ///// - ///// - ///// - //[EnvironmentPermissionAttribute(SecurityAction.LinkDemand)] - //private void WriteUString(IntPtr baseAddr, int offset, string item, int maxLength) - //{ - // if (string.IsNullOrEmpty(item)) - // { - // // write zero - // Marshal.WriteInt16(baseAddr, offset, (char)0); - // } - // else - // { - // // use 2 bytes per char - // for (int i = 0; i < maxLength; i++) - // { - // if (i == item.Length) - // { - // // string end reached, so write \0 and quit - // Marshal.WriteInt16(baseAddr, offset, (char)0); - // return; - // } - // else - // { - // Marshal.WriteInt16(baseAddr, offset, item[i]); - // offset += 2; - // } - // } - // // when ended normally also write \0 - // Marshal.WriteByte(baseAddr, offset, 0); - // } - //} - - #endregion - - } -} diff --git a/src/NTwain/Data/ValueExtensions.cs b/src/NTwain/Data/ValueExtensions.cs deleted file mode 100644 index d152cb4..0000000 --- a/src/NTwain/Data/ValueExtensions.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; - -namespace NTwain.Data -{ - /// - /// Contains extension methods for converting (possibly bad) integer values to enum values. - /// - public static class ValueExtensions - { - /// - /// Casts a list of objects to a list of specified enum. - /// - /// The type of the enum. - /// The list. - /// - public static IList CastToEnum(this IEnumerable list) where TEnum : struct, IConvertible - { - return list.CastToEnum(true); - } - /// - /// Casts a list of objects to a list of specified enum. - /// - /// The type of the enum. - /// The list. - /// set to true for working with bad values. - /// - public static IList CastToEnum(this IEnumerable list, bool tryUpperWord) where TEnum : struct, IConvertible - { - return list.Select(o => o.ConvertToEnum(tryUpperWord)).ToList(); - } - - /// - /// Casts an objects to the specified enum. - /// - /// The type of the enum. - /// The value. - /// - public static TEnum ConvertToEnum(this object value) where TEnum : struct, IConvertible - { - return ConvertToEnum(value, true); - } - /// - /// Casts an objects to the specified enum. - /// - /// The type of the enum. - /// The value. - /// if set to true [try upper word]. - /// - public static TEnum ConvertToEnum(this object value, bool tryUpperWord) where TEnum : struct, IConvertible - { - if (value != null) - { - var returnType = typeof(TEnum); - - // standard int values - if (returnType.IsEnum) - { - var rawType = Enum.GetUnderlyingType(returnType); - - if (tryUpperWord) - { - // small routine to work with bad sources that may put - // 16bit value in the upper word instead of lower word (as per the twain spec). - if (typeof(ushort).IsAssignableFrom(rawType)) - { - var intVal = Convert.ToUInt32(value, CultureInfo.InvariantCulture); - var enumVal = GetLowerWord(intVal); - if (!Enum.IsDefined(returnType, enumVal)) - { - return (TEnum)Enum.ToObject(returnType, GetUpperWord(intVal)); - } - } - } - // old method: - // return (TEnum)Enum.ToObject(returnType, value); - - // new method: - // try to convert to enum's underlying type first then cast to the enum - return (TEnum)Convert.ChangeType(value, rawType, CultureInfo.InvariantCulture); - } - else if (typeof(IConvertible).IsAssignableFrom(returnType)) - { - // for regular integers and whatnot - return (TEnum)Convert.ChangeType(value, returnType, CultureInfo.InvariantCulture); - } - // return as-is from cap. if caller made a mistake then there should be exceptions - return (TEnum)value; - } - return default(TEnum); - } - - static ushort GetLowerWord(uint value) - { - return (ushort)(value & 0xffff); - } - static uint GetUpperWord(uint value) - { - return (ushort)(value >> 16); - } - - /// - /// Tries to convert a value to if possible. - /// - /// The value. - /// - public static TWFix32 ConvertToFix32(this object value) - { - if (value != null) - { - if (value is TWFix32) - { - return (TWFix32)value; - } - return (TWFix32)Convert.ToSingle(value, CultureInfo.InvariantCulture); - } - return default(TWFix32); - } - - /// - /// Tries to cast a value to if possible. - /// - /// The value. - /// - public static TWFrame ConvertToFrame(this object value) - { - if (value != null) - { - if (value is TWFrame) - { - return (TWFrame)value; - } - } - return default(TWFrame); - } - - /// - /// Converts object to string. - /// - /// The value. - /// - public static string ConvertToString(this object value) - { - if (value == null) { return null; } - return value.ToString(); - } - - - ///// - ///// Routine that does nothing. - ///// - ///// The value. - ///// - //public static object NoConvertRoutine(object value) - //{ - // return value; - //} - - ///// - ///// Predefined routine for - ///// - ///// The value. - ///// - //public static string ConvertToString(object value) - //{ - // if (value != null) - // { - // return value.ToString(); - // } - // return default(string); - //} - } -} diff --git a/src/NTwain/DataSource.cs b/src/NTwain/DataSource.cs deleted file mode 100644 index 17b183e..0000000 --- a/src/NTwain/DataSource.cs +++ /dev/null @@ -1,398 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; -using NTwain.Triplets; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; -using System.Globalization; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading; - -namespace NTwain -{ - /// - /// Represents a TWAIN data source. - /// - public partial class DataSource : IDataSource - { - ITwainSessionInternal _session; - - internal DataSource(ITwainSessionInternal session, TWIdentity sourceId) - { - _session = session; - Identity = sourceId; - ProtocolVersion = new Version(sourceId.ProtocolMajor, sourceId.ProtocolMinor); - } - - /// - /// Opens the source for capability negotiation. - /// - /// - public ReturnCode Open() - { - var rc = ReturnCode.Failure; - _session.MessageLoopHook.Invoke(() => - { - PlatformInfo.Current.Log.Debug("Thread {0}: OpenSource.", Thread.CurrentThread.ManagedThreadId); - - rc = _session.DGControl.Identity.OpenDS(this); - _session.UpdateCallback(); - }); - return rc; - } - - /// - /// Closes the source. - /// - /// - public ReturnCode Close() - { - var rc = ReturnCode.Failure; - _session.MessageLoopHook.Invoke(() => - { - PlatformInfo.Current.Log.Debug("Thread {0}: CloseSource.", Thread.CurrentThread.ManagedThreadId); - - rc = _session.DGControl.Identity.CloseDS(); - //if (rc == ReturnCode.Success) - //{ - // SupportedCaps = null; - //} - _session.UpdateCallback(); - }); - return rc; - } - - /// - /// Enables the source to start transferring. - /// - /// The mode. - /// if set to true any driver UI will display as modal. - /// The window handle if modal. - /// - public ReturnCode Enable(SourceEnableMode mode, bool modal, IntPtr windowHandle) - { - return _session.EnableSource(mode, modal, windowHandle); - } - - /// - /// Gets the source status. Only call this at state 4 or higher. - /// - /// - public TWStatus GetStatus() - { - TWStatus stat; - _session.DGControl.Status.GetSource(out stat); - return stat; - } - /// - /// Gets the source status. Only call this at state 4 or higher. - /// - /// - public TWStatusUtf8 GetStatusUtf8() - { - TWStatusUtf8 stat; - _session.DGControl.StatusUtf8.GetSource(out stat); - return stat; - } - - - #region properties - - internal TWIdentity Identity { get; private set; } - - /// - /// Gets the id of the source. - /// - /// - /// The identifier. - /// - public int Id { get { return Identity.Id; } } - - /// - /// Gets the source's product name. - /// - /// - /// The name. - /// - public string Name { get { return Identity.ProductName; } } - - /// - /// Gets the source's manufacturer name. - /// - /// - /// The manufacturer. - /// - public string Manufacturer { get { return Identity.Manufacturer; } } - - /// - /// Gets the source's product family. - /// - /// - /// The product family. - /// - public string ProductFamily { get { return Identity.ProductFamily; } } - - /// - /// Gets the source's version information. - /// - /// - /// The version. - /// - public TWVersion Version { get { return Identity.Version; } } - - /// - /// Gets the supported data group. - /// - /// - /// The data group. - /// - public DataGroups DataGroup { get { return Identity.DataGroup; } } - - /// - /// Gets the supported TWAIN protocol version. - /// - /// - /// The protocol version. - /// - public Version ProtocolVersion { get; private set; } - - /// - /// Gets a value indicating whether this data source has been opened. - /// - /// - /// true if this data source is open; otherwise, false. - /// - public bool IsOpen { get { return _session.IsSourceOpen && _session.CurrentSource == this; } } - - /// - /// Gets or sets the current settings (CustomDSData) of this source if supported. - /// - /// - /// The source settings. - /// - public byte[] Settings - { - get - { - byte[] value = null; - if (Capabilities.CapCustomDSData.GetCurrent() == BoolType.True) - { - TWCustomDSData data; - if (DGControl.CustomDSData.Get(out data) == ReturnCode.Success && data.InfoLength > 0) - { - try - { - value = new byte[data.InfoLength]; - var ptr = PlatformInfo.Current.MemoryManager.Lock(data.hData); - Marshal.Copy(ptr, value, 0, (int)data.InfoLength); - } - finally - { - PlatformInfo.Current.MemoryManager.Unlock(data.hData); - PlatformInfo.Current.MemoryManager.Free(data.hData); - } - } - } - return value; - } - set - { - if (value != null && value.Length > 0 && - Capabilities.CapCustomDSData.GetCurrent() == BoolType.True) - { - TWCustomDSData data = new TWCustomDSData - { - InfoLength = (uint)value.Length - }; - try - { - data.hData = PlatformInfo.Current.MemoryManager.Allocate(data.InfoLength); - var ptr = PlatformInfo.Current.MemoryManager.Lock(data.hData); - Marshal.Copy(value, 0, ptr, value.Length); - var rc = DGControl.CustomDSData.Set(data); - if (rc != ReturnCode.Success) - { - // do something - } - } - finally - { - if (data.hData != IntPtr.Zero) - { - PlatformInfo.Current.MemoryManager.Unlock(data.hData); - PlatformInfo.Current.MemoryManager.Free(data.hData); - } - } - } - } - } - - //static readonly CapabilityId[] _emptyCapList = new CapabilityId[0]; - - //private IList _supportedCapsList; - ///// - ///// Gets the list of supported caps for this source. - ///// - ///// - ///// The supported caps. - ///// - //[Obsolete("Use CapSupportedCaps.Get() instead.")] - //public IList SupportedCaps - //{ - // get - // { - // if (_supportedCapsList == null && _session.State > 3) - // { - // _supportedCapsList = CapSupportedCaps.GetValues(); - // } - // return _supportedCapsList ?? _emptyCapList; - // } - // private set - // { - // _supportedCapsList = value; - // //OnPropertyChanged("SupportedCaps"); - // } - //} - - private Capabilities _caps; - - /// - /// Gets the capabilities for this data source. - /// - /// - /// The capabilities. - /// - public ICapabilities Capabilities - { - get { return _caps ?? (_caps = new Capabilities(this)); } - } - - - - /// - /// Gets the triplet operations defined for control data group. - /// - public DGControl DGControl - { - get - { - return _session.DGControl; - } - } - - /// - /// Gets the triplet operations defined for image data group. - /// - public DGImage DGImage - { - get - { - return _session.DGImage; - } - } - - /// - /// Gets the direct triplet operation entry for custom values. - /// - public DGCustom DGCustom - { - get - { - return _session.DGCustom; - } - } - - internal DGAudio DGAudio - { - get - { - return _session.DGAudio; - } - } - - #endregion - - //#region INotifyPropertyChanged Members - - ///// - ///// Occurs when a property value changes. - ///// - //public event PropertyChangedEventHandler PropertyChanged; - - ///// - ///// Raises the event. - ///// - ///// Name of the property. - //protected void OnPropertyChanged(string propertyName) - //{ - // var syncer = Session.SynchronizationContext; - // if (syncer == null) - // { - // try - // { - // var hand = PropertyChanged; - // if (hand != null) { hand(this, new PropertyChangedEventArgs(propertyName)); } - // } - // catch { } - // } - // else - // { - // syncer.Post(o => - // { - // try - // { - // var hand = PropertyChanged; - // if (hand != null) { hand(this, new PropertyChangedEventArgs(propertyName)); } - // } - // catch { } - // }, null); - // } - //} - - //#endregion - - #region cameras - - /// - /// [Experimental] Gets the cameras supported by the source. - /// - /// - public IList GetCameras() - { - TWFileSystem fs = new TWFileSystem(); - List cams = new List(); - var rc = DGControl.FileSystem.GetFirstFile(fs); - while (rc == ReturnCode.Success) - { - switch (fs.FileType) - { - case FileType.Camera: - case FileType.CameraBottom: - case FileType.CameraTop: - case FileType.CameraPreview: - cams.Add(fs.OutputName); - break; - } - rc = DGControl.FileSystem.GetNextFile(fs); - } - return cams; - } - - /// - /// [Experimental] Sets the target camera for cap negotiation that can be set per camera. - /// - /// - /// - public ReturnCode SetCamera(string cameraName) - { - TWFileSystem fs = new TWFileSystem(); - fs.InputName = cameraName; - return DGControl.FileSystem.ChangeDirectory(fs); - } - - #endregion - } -} diff --git a/src/NTwain/DataTransferredEventArgs.cs b/src/NTwain/DataTransferredEventArgs.cs deleted file mode 100644 index d55df79..0000000 --- a/src/NTwain/DataTransferredEventArgs.cs +++ /dev/null @@ -1,200 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; -using NTwain.Interop; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Imaging; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using System.Security.Permissions; - -namespace NTwain -{ - /// - /// Contains event data after whatever data from the source has been transferred. - /// - public class DataTransferredEventArgs : EventArgs - { - /// - /// Initializes a new instance of the class. - /// - /// The source. - /// The native data. - public DataTransferredEventArgs(DataSource source, IntPtr nativeData) - { - TransferType = XferMech.Native; - DataSource = source; - NativeData = nativeData; - } - /// - /// Initializes a new instance of the class. - /// - /// The source. - /// The file data path. - /// The image file format. - public DataTransferredEventArgs(DataSource source, string fileDataPath, FileFormat imageFileFormat) - { - TransferType = XferMech.File; - DataSource = source; - FileDataPath = fileDataPath; - ImageFileFormat = imageFileFormat; - } - /// - /// Initializes a new instance of the class. - /// - /// The source. - /// The memory information. - /// The memory data. - public DataTransferredEventArgs(DataSource source, TWImageMemXfer memoryInfo, byte[] memoryData) - { - TransferType = XferMech.Memory; - DataSource = source; - MemoryInfo = memoryInfo; - MemoryData = memoryData; - } - - /// - /// Gets the type of the transfer mode. - /// - /// - /// The type of the transfer. - /// - public XferMech TransferType { get; private set; } - - /// - /// Gets the raw pointer to the complete data if is . - /// The data will be freed once the event handler ends - /// so consumers must complete whatever processing before then. - /// For image type this data is DIB (Windows) or TIFF (Linux). - /// This pointer is already locked for the duration of this event. - /// - /// The data pointer. - public IntPtr NativeData { get; private set; } - - /// - /// Gets the file path to the complete data if the transfer was file or memory-file. - /// This is only available if is . - /// - /// - /// The file path. - /// - public string FileDataPath { get; private set; } - - /// - /// Gets the file format if applicable. - /// This is only available if is . - /// - /// - /// The file format. - /// - public FileFormat ImageFileFormat { get; private set; } - - /// - /// Gets the info object if the transfer was memory. - /// This is only available if is . - /// - /// - /// The memory information. - /// - public TWImageMemXfer MemoryInfo { get; private set; } - - /// - /// Gets the raw memory data if the transfer was memory. - /// Consumer application will need to do the parsing based on the values - /// from . - /// - /// - /// The memory data. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public byte[] MemoryData { get; private set; } - - TWImageInfo _imgInfo; - /// - /// Gets the final image information if applicable. - /// - /// - /// The final image information. - /// - public TWImageInfo ImageInfo - { - get - { - if (_imgInfo == null) - { - if (DataSource.DGImage.ImageInfo.Get(out _imgInfo) != ReturnCode.Success) - { - _imgInfo = null; - } - } - return _imgInfo; - } - } - - /// - /// Gets the data source. - /// - /// - /// The data source. - /// - public DataSource DataSource { get; private set; } - - /// - /// Gets the extended image information if applicable. - /// - /// The information ids. - /// - /// - public IEnumerable GetExtImageInfo(params ExtendedImageInfo[] infoIds) - { - if (infoIds != null && infoIds.Length > 0)// && DataSource.SupportedCaps.Contains(CapabilityId.ICapExtImageInfo)) - { - var request = new TWExtImageInfo { NumInfos = (uint)infoIds.Length }; - if (infoIds.Length > request.Info.Length) - { - throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Info ID array exceeded maximum length of {0}.", request.Info.Length)); - } - - for (int i = 0; i < infoIds.Length; i++) - { - request.Info[i].InfoID = infoIds[i]; - } - - if (DataSource.DGImage.ExtImageInfo.Get(request) == ReturnCode.Success) - { - return request.Info.Where(it => it.InfoID != ExtendedImageInfo.Invalid); - } - } - return Enumerable.Empty(); - } - - - /// - /// Gets the image stream from the if it's an image. - /// - /// - public Stream GetNativeImageStream() - { - Stream retVal = null; - - if (NativeData != IntPtr.Zero) - { - if (ImageTools.IsDib(NativeData)) - { - retVal = ImageTools.GetBitmapStream(NativeData); - } - else if (ImageTools.IsTiff(NativeData)) - { - retVal = ImageTools.GetTiffStream(NativeData); - } - - } - return retVal; ; - } - - - } -} \ No newline at end of file diff --git a/src/NTwain/DeviceEventArgs.cs b/src/NTwain/DeviceEventArgs.cs deleted file mode 100644 index d38fb0c..0000000 --- a/src/NTwain/DeviceEventArgs.cs +++ /dev/null @@ -1,25 +0,0 @@ -using NTwain.Data; -using System; - -namespace NTwain -{ - /// - /// Contains event data for a TWAIN source hardware event. - /// - public class DeviceEventArgs : EventArgs - { - /// - /// Initializes a new instance of the class. - /// - /// The device event. - internal DeviceEventArgs(TWDeviceEvent deviceEvent) - { - DeviceEvent = deviceEvent; - } - /// - /// Gets the detailed device event. - /// - /// The device event. - public TWDeviceEvent DeviceEvent { get; private set; } - } -} diff --git a/src/NTwain/GlobalSuppressions.cs b/src/NTwain/GlobalSuppressions.cs deleted file mode 100644 index 77ae691..0000000 Binary files a/src/NTwain/GlobalSuppressions.cs and /dev/null differ diff --git a/src/NTwain/ICapWrapper.cs b/src/NTwain/ICapWrapper.cs deleted file mode 100644 index 6d69cb6..0000000 --- a/src/NTwain/ICapWrapper.cs +++ /dev/null @@ -1,217 +0,0 @@ -using NTwain.Data; -using System; -using System.Collections.Generic; -namespace NTwain -{ - - /// - /// Interface for reading a TWAIN capability associated with a . - /// - /// The TWAIN type of the value. - public interface IReadOnlyCapWrapper - { - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can get values; otherwise, false. - /// - bool CanGet { get; } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can get default value; otherwise, false. - /// - bool CanGetCurrent { get; } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can get current value; otherwise, false. - /// - bool CanGetDefault { get; } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can get help; otherwise, false. - /// - bool CanGetHelp { get; } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can get label; otherwise, false. - /// - bool CanGetLabel { get; } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can get label enum; otherwise, false. - /// - bool CanGetLabelEnum { get; } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can reset; otherwise, false. - /// - bool CanReset { get; } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can set; otherwise, false. - /// - bool CanSet { get; } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can set constraint; otherwise, false. - /// - bool CanSetConstraint { get; } - - - /// - /// Gets the capability. - /// - /// - /// The capability. - /// - CapabilityId Capability { get; } - - /// - /// Gets all the possible values of this capability without expanding. - /// This may be required to work with large range values that cannot be safely enumerated - /// with . - /// - /// - CapabilityReader GetValuesRaw(); - - /// - /// Converts the object values into typed values using the conversion routine - /// for this capability. - /// - /// The values. - /// - IEnumerable ConvertValues(IEnumerable values); - - /// - /// Gets all the possible values of this capability. - /// - /// - IEnumerable GetValues(); - - /// - /// Gets the current value of this capability. - /// - /// - TValue GetCurrent(); - - /// - /// Gets the default value of this capability. - /// - /// - TValue GetDefault(); - - /// - /// [Experimental] Gets the help value of this capability. - /// - /// - string GetHelp(); - - /// - /// [Experimental] Gets the label value of this capability. - /// - /// - string GetLabel(); - - /// - /// [Experimental] Gets the display names for possible values of this capability. - /// - /// - IEnumerable GetLabelEnum(); - - /// - /// Gets a value indicating whether this capability is at all supported. - /// - /// - /// true if this capability is supported; otherwise, false. - /// - bool IsSupported { get; } - - /// - /// Gets a value indicating whether this instance is read only. - /// - /// - /// true if this instance is read only; otherwise, false. - /// - bool IsReadOnly { get; } - } - - /// - /// Interface for reading/writing a TWAIN capability associated with a . - /// - /// The TWAIN type of the value. - public interface ICapWrapper : IReadOnlyCapWrapper - { - /// - /// Resets the current value to power-on default. - /// - /// - ReturnCode Reset(); - - /// - /// Simplified version that sets the current value of this capability. - /// - /// The value. - /// - ReturnCode SetValue(TValue value); - - /// - /// A version of Set that uses an array. - /// - /// The value. - /// - ReturnCode SetValue(TWArray value); - - /// - /// A version of Set that uses an enumeration. - /// - /// The value. - /// - ReturnCode SetValue(TWEnumeration value); - - /// - /// Sets the constraint value of this capability. - /// - /// The value. - /// - ReturnCode SetConstraint(TWOneValue value); - - /// - /// Sets the constraint value of this capability. - /// - /// The value. - /// - ReturnCode SetConstraint(TWEnumeration value); - - /// - /// Sets the constraint value of this capability. - /// - /// The value. - /// - ReturnCode SetConstraint(TWRange value); - } -} diff --git a/src/NTwain/ICapabilities.cs b/src/NTwain/ICapabilities.cs deleted file mode 100644 index 6a1309a..0000000 --- a/src/NTwain/ICapabilities.cs +++ /dev/null @@ -1,1206 +0,0 @@ -using System.Collections.Generic; -using NTwain.Data; - -namespace NTwain -{ - /// - /// Exposes capabilities of a data source as properties. - /// - public interface ICapabilities - { - /// - /// Gets the property to work with audio for the current source. - /// - /// - /// The audio xfer mech. - /// - ICapWrapper ACapXferMech { get; } - - - /// - /// Gets the property to work with alarms for the current source. - /// - /// - /// The alarms. - /// - ICapWrapper CapAlarms { get; } - /// - /// Gets the property to work with alarm volume for the current source. - /// - /// - /// The alarm volume. - /// - ICapWrapper CapAlarmVolume { get; } - /// - /// Gets the property to work with the name or other identifying information about the - /// Author of the image. It may include a copyright string. - /// - /// - /// The author string. - /// - ICapWrapper CapAuthor { get; } - /// - /// Gets the property to work with auto feed page flag for the current source. - /// - /// - /// The auto feed flag. - /// - ICapWrapper CapAutoFeed { get; } - /// - /// Gets the property to work with auto capture count for the current source. - /// - /// - /// The auto capture count. - /// - ICapWrapper CapAutomaticCapture { get; } - /// - /// Gets the property to work with auto-sense medium (paper source) flag. - /// - /// - /// The auto-sense medium flag. - /// - ICapWrapper CapAutomaticSenseMedium { get; } - /// - /// Gets the property to work with auto scan page flag for the current source. - /// - /// - /// The auto scan flag. - /// - ICapWrapper CapAutoScan { get; } - /// - /// Gets the property to see the remaining battery power for the device. - /// - /// - /// The battery minutes. - /// - IReadOnlyCapWrapper CapBatteryMinutes { get; } - /// - /// Gets the property to see the remaining battery percentage for the device. - /// - /// - /// The battery percentage. - /// - IReadOnlyCapWrapper CapBatteryPercentage { get; } - /// - /// Gets the property to work with camera enabled flag. - /// - /// - /// The camera enabled flag. - /// - ICapWrapper CapCameraEnabled { get; } - /// - /// Gets the property to work with camera order for the current source. - /// - /// - /// The camera order setting. - /// - ICapWrapper CapCameraOrder { get; } - /// - /// Gets the property to see whether device supports camera preview UI flag. - /// - /// - /// The camera preview UI flag. - /// - IReadOnlyCapWrapper CapCameraPreviewUI { get; } - /// - /// Gets the property to work with camera side for the current source. - /// - /// - /// The camera side. - /// - ICapWrapper CapCameraSide { get; } - /// - /// Gets the property to work with the general note about the acquired image. - /// - /// - /// The general note string. - /// - ICapWrapper CapCaption { get; } - /// - /// Gets the property to work with the clear buffers option for the current source. - /// - /// - /// The clear buffers option. - /// - ICapWrapper CapClearBuffers { get; } - /// - /// Gets the property to work with clear page flag for the current source. - /// - /// - /// The clear page flag. - /// - ICapWrapper CapClearPage { get; } - /// - /// Gets the property to see whether device supports custom data triplets. - /// - /// - /// The custom data flag. - /// - IReadOnlyCapWrapper CapCustomDSData { get; } - /// - /// Gets the property for device interface guid. - /// - /// - /// The device interface guid. - /// - IReadOnlyCapWrapper CapCustomInterfaceGuid { get; } - /// - /// Gets the property to work with the reported device events for the current source. - /// - /// - /// The reported device events. - /// - ICapWrapper CapDeviceEvent { get; } - /// - /// Gets the property to work with devince online flag for the current source. - /// - /// - /// The devince online flag. - /// - IReadOnlyCapWrapper CapDeviceOnline { get; } - /// - /// Gets the property to work with the device's time and date. - /// - /// - /// The device time and date. - /// - ICapWrapper CapDeviceTimeDate { get; } - /// - /// Gets the property to work with double feed detection option for the current source. - /// - /// - /// The double feed detection option. - /// - ICapWrapper CapDoubleFeedDetection { get; } - /// - /// Gets the property to work with double feed detection length for the current source. - /// - /// - /// The double feed detection length. - /// - ICapWrapper CapDoubleFeedDetectionLength { get; } - /// - /// Gets the property to work with double feed detection response for the current source. - /// - /// - /// The double feed detection response. - /// - ICapWrapper CapDoubleFeedDetectionResponse { get; } - /// - /// Gets the property to work with double feed detection sensitivity for the current source. - /// - /// - /// The double feed detection sensitivity. - /// - ICapWrapper CapDoubleFeedDetectionSensitivity { get; } - /// - /// Gets the property to see what's the duplex mode for the current source. - /// - /// - /// The duplex mode. - /// - IReadOnlyCapWrapper CapDuplex { get; } - /// - /// Gets the property to work with duplex enabled flag for the current source. - /// - /// - /// The duplex enabled flag. - /// - ICapWrapper CapDuplexEnabled { get; } - /// - /// Gets the property to see whether device supports UI only flag (no transfer). - /// - /// - /// The UI only flag. - /// - IReadOnlyCapWrapper CapEnableDSUIOnly { get; } - /// - /// Gets the property to work with endorser for the current source. - /// - /// - /// The endorser option. - /// - ICapWrapper CapEndorser { get; } - /// - /// Gets the extended caps for the current source. - /// - /// - /// The extended caps. - /// - ICapWrapper CapExtendedCaps { get; } - /// - /// Gets the property to work with feeder alignment for the current source. - /// - /// - /// The feeder alignment. - /// - ICapWrapper CapFeederAlignment { get; } - /// - /// Gets the property to work with feeder enabled flag for the current source. - /// - /// - /// The feeder enabled flag. - /// - ICapWrapper CapFeederEnabled { get; } - /// - /// Gets the property to work with feeder loaded flag for the current source. - /// - /// - /// The feeder loaded flag. - /// - IReadOnlyCapWrapper CapFeederLoaded { get; } - /// - /// Gets the property to work with feeder order for the current source. - /// - /// - /// The feeder order. - /// - ICapWrapper CapFeederOrder { get; } - /// - /// Gets the property to work with feeder pocket for the current source. - /// - /// - /// The feeder pocket setting. - /// - ICapWrapper CapFeederPocket { get; } - /// - /// Gets the property to work with feeder prep flag. - /// - /// - /// The feeder prep flag. - /// - ICapWrapper CapFeederPrep { get; } - /// - /// Gets the property to work with feed page flag for the current source. - /// - /// - /// The feed page flag. - /// - ICapWrapper CapFeedPage { get; } - /// - /// Gets the property to work with indicators flag for the current source. - /// - /// - /// The indicators flag. - /// - ICapWrapper CapIndicators { get; } - /// - /// Gets the property to work with diplayed indicators for the current source. - /// - /// - /// The diplayed indicators. - /// - ICapWrapper CapIndicatorsMode { get; } - /// - /// Gets the property to work with job control option for the current source. - /// - /// - /// The job control option. - /// - ICapWrapper CapJobControl { get; } - /// - /// Gets the property to work with string data language for the current source. - /// - /// - /// The language. - /// - ICapWrapper CapLanguage { get; } - /// - /// Gets the property to work with the max buffered pages for the current source. - /// - /// - /// The max batch buffered pages. - /// - ICapWrapper CapMaxBatchBuffers { get; } - /// - /// Gets the property to work with check scanning support flag. - /// - /// - /// The check scanning support flag. - /// - ICapWrapper CapMicrEnabled { get; } - /// - /// Gets the property to work with paper sensor flag for the current source. - /// - /// - /// The paper sensor flag. - /// - IReadOnlyCapWrapper CapPaperDetectable { get; } - /// - /// Gets the property to work with paper handling option for the current source. - /// - /// - /// The paper handling option. - /// - ICapWrapper CapPaperHandling { get; } - /// - /// Gets the property to work with camera power down time (seconds) for the current source. - /// - /// - /// The camera power down time. - /// - ICapWrapper CapPowerSaveTime { get; } - /// - /// Gets the property to see current device's power supply. - /// - /// - /// The power supply indicator. - /// - IReadOnlyCapWrapper CapPowerSupply { get; } - /// - /// Gets the property to work with printer list for the current source. - /// - /// - /// The printer list. - /// - ICapWrapper CapPrinter { get; } - /// - /// Gets the property to work with printer character rotation for the current source. - /// - /// - /// The printer character rotation. - /// - ICapWrapper CapPrinterCharRotation { get; } - /// - /// Gets the property to work with printer enabled flag. - /// - /// - /// The printer enabled flag. - /// - ICapWrapper CapPrinterEnabled { get; } - /// - /// Gets the property to work with printer font style for the current source. - /// - /// - /// The printer font style. - /// - ICapWrapper CapPrinterFontStyle { get; } - /// - /// Gets the property to work with the starting printer index for the current source. - /// - /// - /// The printer index. - /// - ICapWrapper CapPrinterIndex { get; } - /// - /// Set the character to be used for filling the leading digits before the counter value if the - /// counter digits are fewer than . - /// - /// - /// The printer leading string. - /// - ICapWrapper CapPrinterIndexLeadChar { get; } - /// - /// Gets the property to work with printer index max value for the current source. - /// - /// - /// The printer index max value. - /// - ICapWrapper CapPrinterIndexMaxValue { get; } - /// - /// Gets the property to work with printer number digits value for the current source. - /// - /// - /// The printer number digits value. - /// - ICapWrapper CapPrinterIndexNumDigits { get; } - /// - /// Gets the property to work with printer index step value for the current source. - /// - /// - /// The printer index step value. - /// - ICapWrapper CapPrinterIndexStep { get; } - /// - /// Gets the property to work with printer index trigger for the current source. - /// - /// - /// The printer index trigger. - /// - ICapWrapper CapPrinterIndexTrigger { get; } - /// - /// Gets the property to work with printer mode for the current source. - /// - /// - /// The printer mode. - /// - ICapWrapper CapPrinterMode { get; } - /// - /// Specifies the string(s) that are to be used in the string component when the current - /// device is enabled. - /// - /// - /// The printer string. - /// - ICapWrapper CapPrinterString { get; } - /// - /// Gets the next print values. - /// - /// - /// The next print values. - /// - IReadOnlyCapWrapper CapPrinterStringPreview { get; } - /// - /// Specifies the string that shall be used as the current device’s suffix. - /// - /// - /// The printer suffix string. - /// - ICapWrapper CapPrinterSuffix { get; } - /// - /// Gets the property to work with printer y-offset for the current source. - /// - /// - /// The printer y-offset. - /// - ICapWrapper CapPrinterVerticalOffset { get; } - /// - /// Gets the property to see whether device supports reacquire flag. - /// - /// - /// The reacquire flag. - /// - IReadOnlyCapWrapper CapReacquireAllowed { get; } - /// - /// Gets the property to work with rewind page flag for the current source. - /// - /// - /// The rewind page flag. - /// - ICapWrapper CapRewindPage { get; } - /// - /// Gets the property to work with segmentation setting for the current source. - /// - /// - /// The segmentation setting. - /// - ICapWrapper CapSegmented { get; } - /// - /// Gets the property for device serial number. - /// - /// - /// The device serial number. - /// - IReadOnlyCapWrapper CapSerialNumber { get; } - /// - /// Gets the supported caps for the current source. This is not supported by all sources. - /// - /// - /// The supported caps. - /// - IReadOnlyCapWrapper CapSupportedCaps { get; } - /// - /// Gets the supported caps for unique segments for the current source. - /// - /// - /// The supported caps for unique segments. - /// - IReadOnlyCapWrapper CapSupportedCapsSegmentUnique { get; } - /// - /// Gets the supported caps for supported DATs. - /// - /// - /// The supported DATs. - /// - IReadOnlyCapWrapper CapSupportedDATs { get; } - /// - /// Gets the property to work with thumbnails enabled flag for the current source. - /// - /// - /// The thumbnails enabled flag. - /// - ICapWrapper CapThumbnailsEnabled { get; } - /// - /// Gets the property to work with the time before first capture (milliseconds) for the current source. - /// - /// - /// The time before first capture. - /// - ICapWrapper CapTimeBeforeFirstCapture { get; } - /// - /// Gets the property to work with the time between captures (milliseconds) for the current source. - /// - /// - /// The time between captures. - /// - ICapWrapper CapTimeBetweenCaptures { get; } - /// - /// Gets the property to get the image acquired time and date. - /// - /// - /// The time and date string. - /// - IReadOnlyCapWrapper CapTimeDate { get; } - /// - /// Gets the property to work with UI controllable flag for the current source. - /// - /// - /// The UI controllable flag. - /// - IReadOnlyCapWrapper CapUIControllable { get; } - /// - /// Gets the property to work with xfer count for the current source. - /// - /// - /// The xfer count. - /// - ICapWrapper CapXferCount { get; } - - - /// - /// Gets the property to work with image auto brightness flag for the current source. - /// - /// - /// The image auto brightness flag. - /// - ICapWrapper ICapAutoBright { get; } - /// - /// Gets the property to work with image blank page behavior for the current source. - /// - /// - /// The image blank page behavior. - /// - ICapWrapper ICapAutoDiscardBlankPages { get; } - /// - /// Gets the property to work with auto border detection flag for the current source. - /// - /// - /// The auto border detection flag. - /// - ICapWrapper ICapAutomaticBorderDetection { get; } - /// - /// Gets the property to work with image auto color detection flag for the current source. - /// - /// - /// The image auto color detection flag. - /// - ICapWrapper ICapAutomaticColorEnabled { get; } - /// - /// Gets the property to work with image auto non-color pixel type for the current source. - /// - /// - /// The image auto non-color pixel type. - /// - ICapWrapper ICapAutomaticColorNonColorPixelType { get; } - /// - /// Gets the property to work with image auto crop flag for the current source. - /// - /// - /// The image auto crop flag. - /// - IReadOnlyCapWrapper ICapAutomaticCropUsesFrame { get; } - /// - /// Gets the property to work with image auto deskew flag for the current source. - /// - /// - /// The image auto deskew flag. - /// - ICapWrapper ICapAutomaticDeskew { get; } - /// - /// Gets the property to work with image auto length detection flag for the current source. - /// - /// - /// The image auto length detection flag. - /// - ICapWrapper ICapAutomaticLengthDetection { get; } - /// - /// Gets the property to work with image auto rotate flag for the current source. - /// - /// - /// The image auto rotate flag. - /// - ICapWrapper ICapAutomaticRotate { get; } - /// - /// Gets the property to work with image auto size option for the current source. - /// - /// - /// The image auto size option. - /// - ICapWrapper ICapAutoSize { get; } - /// - /// Gets the property to work with image barcode detection flag for the current source. - /// - /// - /// The image barcode detection flag. - /// - ICapWrapper ICapBarcodeDetectionEnabled { get; } - /// - /// Gets the property to work with image barcode max search retries for the current source. - /// - /// - /// The image barcode max search retries. - /// - ICapWrapper ICapBarcodeMaxRetries { get; } - /// - /// Gets the property to work with image barcode max search priorities for the current source. - /// - /// - /// The image barcode max search priorities. - /// - ICapWrapper ICapBarcodeMaxSearchPriorities { get; } - /// - /// Gets the property to work with image barcode search direction for the current source. - /// - /// - /// The image barcode search direction. - /// - ICapWrapper ICapBarcodeSearchMode { get; } - /// - /// Gets the property to work with image barcode search priority for the current source. - /// - /// - /// The image barcode search priority. - /// - ICapWrapper ICapBarcodeSearchPriorities { get; } - /// - /// Gets the property to work with image barcode max search timeout for the current source. - /// - /// - /// The image barcode max search timeout. - /// - ICapWrapper ICapBarcodeTimeout { get; } - /// - /// Gets the property to work with image bit depth for the current source. - /// - /// - /// The image bit depth. - /// - ICapWrapper ICapBitDepth { get; } - /// - /// Gets the property to work with image bit depth reduction method for the current source. - /// - /// - /// The image bit depth reduction method. - /// - ICapWrapper ICapBitDepthReduction { get; } - /// - /// Gets the property to work with image for the current source. - /// - /// - /// The image bit order. - /// - ICapWrapper ICapBitOrder { get; } - /// - /// Gets the property to work with image CCITT compression for the current source. - /// - /// - /// The image bit order for CCITT compression. - /// - ICapWrapper ICapBitOrderCodes { get; } - /// - /// Gets the property to work with image brightness for the current source. - /// - /// - /// The image brightness. - /// - ICapWrapper ICapBrightness { get; } - /// - /// Gets the property to work with image CCITT K factor for the current source. - /// - /// - /// The image CCITT K factor. - /// - ICapWrapper ICapCCITTKFactor { get; } - /// - /// Gets the property to work with image color management flag for the current source. - /// - /// - /// The image color management flag. - /// - ICapWrapper ICapColorManagementEnabled { get; } - /// - /// Gets the property to work with image for the current source. - /// - /// - /// The image compression. - /// - ICapWrapper ICapCompression { get; } - /// - /// Gets the property to work with image contrast for the current source. - /// - /// - /// The image contrast. - /// - ICapWrapper ICapContrast { get; } - /// - /// Gets the property to work with image square-cell halftone for the current source. - /// - /// - /// The image square-cell halftone. - /// - ICapWrapper ICapCustHalftone { get; } - /// - /// Gets the property to work with image exposure time (in seconds) for the current source. - /// - /// - /// The image exposure time. - /// - ICapWrapper ICapExposureTime { get; } - /// - /// Gets the property to work with ext image info flag for the current source. - /// - /// - /// The ext image info flag. - /// - ICapWrapper ICapExtImageInfo { get; } - /// - /// Gets the property to work with feeder type for the current source. - /// - /// - /// The feeder type. - /// - ICapWrapper ICapFeederType { get; } - /// - /// Gets the property to work with image film type for the current source. - /// - /// - /// The image film type. - /// - ICapWrapper ICapFilmType { get; } - /// - /// Gets the property to work with image color filter for the current source. - /// - /// - /// The image color filter type. - /// - ICapWrapper ICapFilter { get; } - /// - /// Gets the property to work with flash option for the current source. - /// - /// - /// The flash option. - /// - ICapWrapper ICapFlashUsed2 { get; } - /// - /// Gets the property to work with image flip-rotation behavior for the current source. - /// - /// - /// The image flip-rotation behavior. - /// - ICapWrapper ICapFlipRotation { get; } - /// - /// Gets the property to work with the list of frames the source will acquire on each page. - /// - /// - /// The capture frames. - /// - ICapWrapper ICapFrames { get; } - /// - /// Gets the property to work with image gamma value for the current source. - /// - /// - /// The image gamma. - /// - ICapWrapper ICapGamma { get; } - /// - /// Gets the property to work with image halftone patterns for the current source. - /// - /// - /// The image halftone patterns. - /// - ICapWrapper ICapHalftones { get; } - /// - /// Gets the property to work with image highlight value for the current source. - /// - /// - /// The image highlight. - /// - ICapWrapper ICapHighlight { get; } - /// - /// Gets the property to work with image icc profile for the current source. - /// - /// - /// The image icc profile. - /// - ICapWrapper ICapICCProfile { get; } - /// - /// Gets or sets the image indices that will be delivered during the standard image transfer done in - /// States 6 and 7. - /// - /// - /// The image indicies. - /// - ICapWrapper ICapImageDataSet { get; } - /// - /// Gets the property to work with image for the current source. - /// - /// - /// The image file format. - /// - ICapWrapper ICapImageFileFormat { get; } - /// - /// Gets the property to work with image enhancement filter for the current source. - /// - /// - /// The image enhancement filter. - /// - ICapWrapper ICapImageFilter { get; } - /// - /// Gets the property to work with image merge option for the current source. - /// - /// - /// The image merge option. - /// - ICapWrapper ICapImageMerge { get; } - /// - /// Gets the property to work with image merge height threshold for the current source. - /// - /// - /// The image merge height threshold. - /// - ICapWrapper ICapImageMergeHeightThreshold { get; } - /// - /// Gets the property to work with image jpeg compression for the current source. - /// - /// - /// The image pixel type for jpeg compression. - /// - ICapWrapper ICapJpegPixelType { get; } - /// - /// Gets the property to work with image jpeg quality for the current source. - /// - /// - /// The image jpeg quality. - /// - ICapWrapper ICapJpegQuality { get; } - /// - /// Gets the property to work with image jpeg sub sampling for the current source. - /// - /// - /// The image jpeg sub sampling. - /// - ICapWrapper ICapJpegSubsampling { get; } - /// - /// Gets the property to work with image lamp state flag for the current source. - /// - /// - /// The image lamp state flag. - /// - ICapWrapper ICapLampState { get; } - /// - /// Gets the property to work with image light path for the current source. - /// - /// - /// The image light path. - /// - ICapWrapper ICapLightPath { get; } - /// - /// Gets the property to work with image light source for the current source. - /// - /// - /// The image light source. - /// - ICapWrapper ICapLightSource { get; } - /// - /// Gets the property to work with image max frames for the current source. - /// - /// - /// The image max frames. - /// - ICapWrapper ICapMaxFrames { get; } - /// - /// Gets the property to work with image minimum height for the current source. - /// - /// - /// The image minimumm height. - /// - IReadOnlyCapWrapper ICapMinimumHeight { get; } - /// - /// Gets the property to work with image minimum width for the current source. - /// - /// - /// The image minimumm width. - /// - IReadOnlyCapWrapper ICapMinimumWidth { get; } - /// - /// Gets the property to work with image mirror option for the current source. - /// - /// - /// The image mirror option. - /// - ICapWrapper ICapMirror { get; } - /// - /// Gets the property to work with image noise filter for the current source. - /// - /// - /// The image noise filter. - /// - ICapWrapper ICapNoiseFilter { get; } - /// - /// Gets the property to work with image orientation for the current source. - /// - /// - /// The image orientation. - /// - ICapWrapper ICapOrientation { get; } - /// - /// Gets the property to work with image overscan option for the current source. - /// - /// - /// The image overscan option. - /// - ICapWrapper ICapOverScan { get; } - /// - /// Gets the property to work with image patch code detection flag for the current source. - /// - /// - /// The image patch code detection flag. - /// - ICapWrapper ICapPatchCodeDetectionEnabled { get; } - /// - /// Gets the property to work with image patch code max search retries for the current source. - /// - /// - /// The image patch code max search retries. - /// - ICapWrapper ICapPatchCodeMaxRetries { get; } - /// - /// Gets the property to work with image patch code max search priorities for the current source. - /// - /// - /// The image patch code max search priorities. - /// - ICapWrapper ICapPatchCodeMaxSearchPriorities { get; } - /// - /// Gets the property to work with image patch code search direction for the current source. - /// - /// - /// The image patch code search direction. - /// - ICapWrapper ICapPatchCodeSearchMode { get; } - /// - /// Gets the property to work with image patch code search priority for the current source. - /// - /// - /// The image patch code search priority. - /// - ICapWrapper ICapPatchCodeSearchPriorities { get; } - /// - /// Gets the property to work with image patch code max search timeout for the current source. - /// - /// - /// The image patch code max search timeout. - /// - ICapWrapper ICapPatchCodeTimeout { get; } - /// - /// Gets the property to work with image physical height for the current source. - /// - /// - /// The image physical height. - /// - IReadOnlyCapWrapper ICapPhysicalHeight { get; } - /// - /// Gets the property to work with image physical width for the current source. - /// - /// - /// The image physical width. - /// - IReadOnlyCapWrapper ICapPhysicalWidth { get; } - /// - /// Gets the property to work with image pixel flavor for the current source. - /// - /// - /// The image pixel flavor. - /// - ICapWrapper ICapPixelFlavor { get; } - /// - /// Gets the property to work with image CCITT compression for the current source. - /// - /// - /// The image pixel flavor for CCITT compression. - /// - ICapWrapper ICapPixelFlavorCodes { get; } - /// - /// Gets the property to work with image for the current source. - /// - /// - /// The image pixel type. - /// - ICapWrapper ICapPixelType { get; } - /// - /// Gets the property to work with image color format for the current source. - /// - /// - /// The image color format. - /// - ICapWrapper ICapPlanarChunky { get; } - /// - /// Gets the property to work with image rotation for the current source. - /// - /// - /// The image rotation. - /// - ICapWrapper ICapRotation { get; } - /// - /// Gets the property to work with image shadow value for the current source. - /// - /// - /// The image shadow. - /// - ICapWrapper ICapShadow { get; } - /// - /// Gets the property to work with image barcode types for the current source. - /// - /// - /// The image barcode types. - /// - IReadOnlyCapWrapper ICapSupportedBarcodeTypes { get; } - /// - /// Gets the property to get supported ext image info for the current source. - /// - /// - /// The supported ext image info. - /// - IReadOnlyCapWrapper ICapSupportedExtImageInfo { get; } - /// - /// Gets the property to work with image patch code types for the current source. - /// - /// - /// The image patch code types. - /// - IReadOnlyCapWrapper ICapSupportedPatchCodeTypes { get; } - /// - /// Gets the property to work with image for the current source. - /// - /// - /// The image supported size. - /// - ICapWrapper ICapSupportedSizes { get; } - /// - /// Gets the property to work with image threshold for the current source. - /// - /// - /// The image threshold. - /// - ICapWrapper ICapThreshold { get; } - /// - /// Gets the property to work with image tiles flag for the current source. - /// - /// - /// The image tiles flag. - /// - ICapWrapper ICapTiles { get; } - /// - /// Gets the property to work with image CCITT time fill for the current source. - /// - /// - /// The image CCITT time fill. - /// - ICapWrapper ICapTimeFill { get; } - /// - /// Gets the property to work with image undefined size flag for the current source. - /// - /// - /// The image undefined size flag. - /// - ICapWrapper ICapUndefinedImageSize { get; } - /// - /// Gets the property to work with image for the current source. - /// - /// - /// The image unit of measure. - /// - ICapWrapper ICapUnits { get; } - /// - /// Gets the property to work with image for the current source. - /// - /// - /// The image xfer mech. - /// - ICapWrapper ICapXferMech { get; } - /// - /// Gets the property to work with image's native x-axis resolution for the current source. - /// - /// - /// The image's native x-axis resolution. - /// - IReadOnlyCapWrapper ICapXNativeResolution { get; } - /// - /// Gets the property to work with image x-axis resolution for the current source. - /// - /// - /// The image x-axis resolution. - /// - ICapWrapper ICapXResolution { get; } - /// - /// Gets the property to work with image x-axis scaling for the current source. - /// - /// - /// The image x-axis scaling. - /// - ICapWrapper ICapXScaling { get; } - /// - /// Gets the property to work with image's native y-axis resolution for the current source. - /// - /// - /// The image's native y-axis resolution. - /// - IReadOnlyCapWrapper ICapYNativeResolution { get; } - /// - /// Gets the property to work with image y-axis resolution for the current source. - /// - /// - /// The image y-axis resolution. - /// - ICapWrapper ICapYResolution { get; } - /// - /// Gets the property to work with image y-axis scaling for the current source. - /// - /// - /// The image y-axis scaling. - /// - ICapWrapper ICapYScaling { get; } - /// - /// Gets the property to work with image zoom factor for the current source. - /// - /// - /// The image zoom factor. - /// - ICapWrapper ICapZoomFactor { get; } - - - /// - /// Gets the current value for a capability. - /// - /// The capability id. - /// - object GetCurrent(CapabilityId capabilityId); - /// - /// Gets the default value for a capability. - /// - /// The capability id. - /// - object GetDefault(CapabilityId capabilityId); - /// - /// A general method that tries to get capability values from current . - /// - /// The capability id. - /// - IEnumerable GetValues(CapabilityId capabilityId); - /// - /// Gets all the possible values of this capability without expanding. - /// This may be required to work with large range values that cannot be safely enumerated - /// with . - /// - /// The capability id. - /// - CapabilityReader GetValuesRaw(CapabilityId capabilityId); - /// - /// Gets the actual supported operations for a capability. This is not supported by all sources. - /// - /// The capability id. - /// - QuerySupports? QuerySupport(CapabilityId capabilityId); - /// - /// Resets the current value to power-on default. - /// - /// The capability id. - /// - ReturnCode Reset(CapabilityId capabilityId); - /// - /// Resets all values and constraint to power-on defaults. - /// - /// - ReturnCode ResetAll(); - } -} \ No newline at end of file diff --git a/src/NTwain/IDataSource.cs b/src/NTwain/IDataSource.cs deleted file mode 100644 index eee29be..0000000 --- a/src/NTwain/IDataSource.cs +++ /dev/null @@ -1,124 +0,0 @@ -using NTwain.Data; -using System; -using System.Collections.Generic; -namespace NTwain -{ - /// - /// Represents a TWAIN data source. - /// - public interface IDataSource : ITripletControl - { - /// - /// Gets the id of the source. - /// - /// - /// The identifier. - /// - int Id { get; } - - /// - /// Gets the source's product name. - /// - /// - /// The name. - /// - string Name { get; } - - /// - /// Gets the supported data group. - /// - /// - /// The data group. - /// - DataGroups DataGroup { get; } - - /// - /// Gets the source's manufacturer name. - /// - /// - /// The manufacturer. - /// - string Manufacturer { get; } - - /// - /// Gets the source's product family. - /// - /// - /// The product family. - /// - string ProductFamily { get; } - - /// - /// Gets the supported TWAIN protocol version. - /// - /// - /// The protocol version. - /// - Version ProtocolVersion { get; } - - /// - /// Gets the source's version information. - /// - /// - /// The version. - /// - TWVersion Version { get; } - - /// - /// Gets a value indicating whether this data source has been opened. - /// - /// - /// true if this data source is open; otherwise, false. - /// - bool IsOpen { get; } - - /// - /// Gets the capabilities for this data source. - /// - /// - /// The capabilities. - /// - ICapabilities Capabilities { get; } - - /// - /// Gets or sets the current settings (CustomDSData) of this source if supported. - /// - /// - /// The source settings. - /// - byte[] Settings { get; set; } - - /// - /// Opens the source for capability negotiation. - /// - /// - ReturnCode Open(); - - /// - /// Closes the source. - /// - /// - ReturnCode Close(); - - /// - /// Enables the source to start transferring. - /// - /// The mode. - /// if set to true any driver UI will display as modal. - /// The window handle if modal. - /// - ReturnCode Enable(SourceEnableMode mode, bool modal, IntPtr windowHandle); - - /// - /// Gets the source status. Only call this at state 4 or higher. - /// - /// - TWStatus GetStatus(); - - /// - /// Gets the source status. Only call this at state 4 or higher. - /// - /// - TWStatusUtf8 GetStatusUtf8(); - } -} diff --git a/src/NTwain/ILog.cs b/src/NTwain/ILog.cs deleted file mode 100644 index d9b4cc9..0000000 --- a/src/NTwain/ILog.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NTwain -{ - /// - /// Simple log interface used by NTwain. - /// - public interface ILog - { - /// - /// Gets or sets a value indicating whether info messages will be logged. - /// - /// - /// true to enable info logging. - /// - bool IsInfoEnabled { get; set; } - - /// - /// Gets or sets a value indicating whether debug messages will be logged. - /// - /// - /// true to enable debug logging. - /// - bool IsDebugEnabled { get; set; } - - /// - /// Gets or sets a value indicating whether error messages will be logged. - /// - /// - /// true to enable error logging. - /// - bool IsErrorEnabled { get; set; } - - /// - /// Logs info type message. - /// - /// The message. - void Info(string message); - - /// - /// Logs info type message. - /// - /// The message format. - /// The arguments. - void Info(string messageFormat, params object[] args); - - /// - /// Logs debug type message. - /// - /// The message. - void Debug(string message); - /// - /// Logs debug type message. - /// - /// The message format. - /// The arguments. - void Debug(string messageFormat, params object[] args); - - /// - /// Logs error type message. - /// - /// The message. - void Error(string message); - - /// - /// Logs error type message. - /// - /// The message. - /// The exception. - void Error(string message, Exception exception); - - /// - /// Logs error type message. - /// - /// The message format. - /// The exception. - /// The arguments. - void Error(string messageFormat, Exception exception, params object[] args); - } -} diff --git a/src/NTwain/IMemoryManager.cs b/src/NTwain/IMemoryManager.cs deleted file mode 100644 index 9464475..0000000 --- a/src/NTwain/IMemoryManager.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -namespace NTwain -{ - /// - /// Interface that provides the correct methods for managing memory on data exchanged with TWAIN sources. - /// - public interface IMemoryManager - { - /// - /// Function to allocate memory. Calls to this must be coupled with later. - /// - /// The size in bytes. - /// Handle to the allocated memory. - IntPtr Allocate(uint size); - - /// - /// Function to free memory. - /// - /// The handle from . - void Free(IntPtr handle); - - /// - /// Function to lock some memory. Calls to this must be coupled with later. - /// - /// The handle to allocated memory. - /// Handle to the lock. - IntPtr Lock(IntPtr handle); - - /// - /// Function to unlock a previously locked memory region. - /// - /// The same handle passed . - void Unlock(IntPtr handle); - } -} diff --git a/src/NTwain/IPlatformInfo.cs b/src/NTwain/IPlatformInfo.cs deleted file mode 100644 index 0371028..0000000 --- a/src/NTwain/IPlatformInfo.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.IO; -namespace NTwain -{ - /// - /// Contains various platform requirements and conditions for TWAIN. - /// - public interface IPlatformInfo - { - /// - /// Gets a value indicating whether the applicable TWAIN DSM library exists in the operating system. - /// - /// - /// true if the TWAIN DSM; otherwise, false. - /// - bool DsmExists { get; } - - /// - /// Gets the expected TWAIN DSM dll path. - /// - /// - /// The expected DSM path. - /// - string ExpectedDsmPath { get; } - - /// - /// Gets a value indicating whether the application is running in 64-bit. - /// - /// - /// true if the application is 64-bit; otherwise, false. - /// - bool IsApp64Bit { get; } - - /// - /// Gets a value indicating whether this library is supported on current OS. - /// Check the other platform properties to determine the reason if this is false. - /// - /// - /// true if this library is supported; otherwise, false. - /// - bool IsSupported { get; } - /// - /// Gets a value indicating whether the lib is expecting to use new DSM. - /// - /// - /// true if using the new DSM; otherwise, false. - /// - bool UseNewWinDSM { get; } - - /// - /// Gets or sets a value indicating whether to prefer using the new DSM on Windows over old twain_32 dsm if applicable. - /// - /// - /// true to prefer new DSM; otherwise, false. - /// - bool PreferNewDSM { get; set; } - - /// - /// Gets a value indicating whether the current runtime is mono. - /// - /// - /// true if the current runtime is on mono; otherwise, false. - /// - bool IsOnMono { get; } - - /// - /// Gets a value indicating whether the current OS is windows. - /// - /// - /// true if the current OS is windows; otherwise, false. - /// - bool IsWindows { get; } - /// - /// Gets a value indicating whether the current OS is linux. - /// - /// - /// true if the current OS is linux; otherwise, false. - /// - bool IsLinux { get; } - - /// - /// Gets the for communicating with data sources. - /// This should only be used when a is open. - /// - /// - /// The memory manager. - /// - IMemoryManager MemoryManager { get; } - - /// - /// Gets or sets the log used by NTwain. - /// - /// - /// The log. - /// - ILog Log { get; set; } - } -} diff --git a/src/NTwain/ITripletControl.cs b/src/NTwain/ITripletControl.cs deleted file mode 100644 index 68a703a..0000000 --- a/src/NTwain/ITripletControl.cs +++ /dev/null @@ -1,29 +0,0 @@ -using NTwain.Triplets; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NTwain -{ - /// - /// Interface for providing TWAIN triplet access. - /// - public interface ITripletControl - { - /// - /// Gets the triplet operations defined for control data group. - /// - DGControl DGControl { get; } - - /// - /// Gets the triplet operations defined for image data group. - /// - DGImage DGImage { get; } - - /// - /// Gets the direct triplet operation entry for custom values. - /// - DGCustom DGCustom { get; } - } -} diff --git a/src/NTwain/ITwainSession.cs b/src/NTwain/ITwainSession.cs deleted file mode 100644 index a1ec498..0000000 --- a/src/NTwain/ITwainSession.cs +++ /dev/null @@ -1,207 +0,0 @@ -using NTwain.Data; -using NTwain.Triplets; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading; - -namespace NTwain -{ - /// - /// General interface for a TWAIN session. - /// - public interface ITwainSession : IEnumerable, INotifyPropertyChanged - { - - /// - /// [Experimental] Gets or sets the optional synchronization context when not specifying a on . - /// This allows events to be raised on the thread associated with the context. This is experimental is not recommended for use. - /// - /// - /// The synchronization context. - /// - SynchronizationContext SynchronizationContext { get; set; } - - /// - /// Gets or sets a value indicating whether calls to triplets will verify the current twain session state. - /// - /// - /// true if state value is enforced; otherwise, false. - /// - bool EnforceState { get; set; } - - - /// - /// Gets the currently open source. - /// - /// - /// The current source. - /// - DataSource CurrentSource { get; } - - /// - /// Gets or sets the default source for this application. - /// While this can be get as long as the session is open, - /// it can only be set at State 3. - /// - /// - /// The default source. - /// - DataSource DefaultSource { get; set; } - - /// - /// Gets the current state number as defined by the TWAIN spec. - /// - /// The state. - int State { get; } - - /// - /// Gets the named state value as defined by the TWAIN spec. - /// - /// - /// The state. - /// - State StateEx { get; } - - /// - /// Quick flag to check if the DSM has been opened. - /// - bool IsDsmOpen { get; } - - /// - /// Quick flag to check if a source has been opened. - /// - bool IsSourceOpen { get; } - - /// - /// Quick flag to check if a source has been enabled. - /// - bool IsSourceEnabled { get; } - - /// - /// Quick flag to check if a source is in the transferring state. - /// - bool IsTransferring { get; } - - /// - /// Whether to stop the transfer process when transfer error is encountered. - /// May be required on some sources. - /// - /// - /// true to stop on transfer error; otherwise, false. - /// - bool StopOnTransferError { get; set; } - - /// - /// Gets the reason a source was disabled (dropped from state 5) if it's due to user action. - /// Mostly only or . - /// - /// - /// The dialog result. - /// - Message DisableReason { get; } - - /// - /// Try to show the built-in source selector dialog and return the selected source. - /// This is not recommended and is only included for completeness. - /// - /// - DataSource ShowSourceSelector(); - - - /// - /// Opens the data source manager. This must be the first method used - /// before using other TWAIN functions. Calls to this must be followed by - /// when done with a TWAIN session. - /// - /// - ReturnCode Open(); - - /// - /// Opens the data source manager. This must be the first method used - /// before using other TWAIN functions. Calls to this must be followed by - /// when done with a TWAIN session. - /// - /// The message loop hook. - /// - ReturnCode Open(MessageLoopHook messageLoopHook); - - /// - /// Closes the data source manager. - /// - /// - ReturnCode Close(); - - /// - /// Forces the stepping down of an opened source when things gets out of control. - /// Used when session state and source state become out of sync. - /// - /// State of the target. - void ForceStepDown(int targetState); - - /// - /// Gets list of sources available in the system. - /// - /// - IEnumerable GetSources(); - - /// - /// Quick shortcut to open a source. - /// - /// Name of the source. - /// - ReturnCode OpenSource(string sourceName); - - /// - /// Quick shortcut to open a source. - /// - /// Id of the source. - /// - ReturnCode OpenSource(int sourceId); - - /// - /// Gets the manager status. Only call this at state 2 or higher. - /// - /// - TWStatus GetStatus(); - - /// - /// Gets the manager status. Only call this at state 3 or higher. - /// - /// - TWStatusUtf8 GetStatusUtf8(); - - - /// - /// Occurs when has changed. - /// - event EventHandler StateChanged; - /// - /// Occurs when has changed. - /// - event EventHandler SourceChanged; - /// - /// Occurs when source has been disabled (back to state 4). - /// - event EventHandler SourceDisabled; - /// - /// Occurs when the source has generated an event. - /// - event EventHandler DeviceEvent; - /// - /// Occurs when a data transfer is ready. - /// - event EventHandler TransferReady; - /// - /// Occurs when data has been transferred. - /// - event EventHandler DataTransferred; - /// - /// Occurs when an error has been encountered during transfer. - /// - event EventHandler TransferError; - - } -} diff --git a/src/NTwain/Internals/Extensions.cs b/src/NTwain/Internals/Extensions.cs deleted file mode 100644 index bb506db..0000000 --- a/src/NTwain/Internals/Extensions.cs +++ /dev/null @@ -1,101 +0,0 @@ -using NTwain.Data; -using NTwain.Properties; -using System; -using System.Globalization; -using System.IO; - -namespace NTwain.Internals -{ - static class Extensions - { - /// - /// Verifies the string length is under the maximum length - /// and throws if violated. - /// - /// The value. - /// The maximum length. - public static void VerifyLengthUnder(this string value, int maxLength) - { - if (value != null && value.Length > maxLength) - throw new ArgumentException(Resources.MaxStringLengthExceeded); - } - - - /// - /// Verifies the session is within the specified state range (inclusive). Throws - /// if violated. - /// - /// The session. - /// The allowed minimum. - /// The allowed maximum. - /// The triplet data group. - /// The triplet data argument type. - /// The triplet message. - /// - public static void VerifyState(this ITwainSessionInternal session, int allowedMinimum, int allowedMaximum, DataGroups group, DataArgumentType dataArgumentType, Message message) - { - if (session.EnforceState && (session.State < allowedMinimum || session.State > allowedMaximum)) - { - throw new TwainStateException(session.State, allowedMinimum, allowedMaximum, group, dataArgumentType, message, - string.Format(CultureInfo.InvariantCulture, "TWAIN state {0} does not match required range {1}-{2} for operation {3}-{4}-{5}.", - session.State, allowedMinimum, allowedMaximum, group, dataArgumentType, message)); - } - } - - - public static string ChangeExtensionByFormat(this TWSetupFileXfer fileInfo, string currentFilePath) - { - string finalFile = null; - switch (fileInfo.Format) - { - case FileFormat.Bmp: - finalFile = Path.ChangeExtension(currentFilePath, ".bmp"); - break; - case FileFormat.Dejavu: - finalFile = Path.ChangeExtension(currentFilePath, ".dejavu"); - break; - case FileFormat.Exif: - finalFile = Path.ChangeExtension(currentFilePath, ".exit"); - break; - case FileFormat.Fpx: - finalFile = Path.ChangeExtension(currentFilePath, ".fpx"); - break; - case FileFormat.Jfif: - finalFile = Path.ChangeExtension(currentFilePath, ".jpg"); - break; - case FileFormat.Jp2: - finalFile = Path.ChangeExtension(currentFilePath, ".jp2"); - break; - case FileFormat.Jpx: - finalFile = Path.ChangeExtension(currentFilePath, ".jpx"); - break; - case FileFormat.Pdf: - case FileFormat.PdfA: - case FileFormat.PdfA2: - finalFile = Path.ChangeExtension(currentFilePath, ".pdf"); - break; - case FileFormat.Pict: - finalFile = Path.ChangeExtension(currentFilePath, ".pict"); - break; - case FileFormat.Png: - finalFile = Path.ChangeExtension(currentFilePath, ".png"); - break; - case FileFormat.Spiff: - finalFile = Path.ChangeExtension(currentFilePath, ".spiff"); - break; - case FileFormat.Tiff: - case FileFormat.TiffMulti: - finalFile = Path.ChangeExtension(currentFilePath, ".tif"); - break; - case FileFormat.Xbm: - finalFile = Path.ChangeExtension(currentFilePath, ".xbm"); - break; - default: - finalFile = Path.ChangeExtension(currentFilePath, ".unknown"); - break; - } - return finalFile; - } - - } -} diff --git a/src/NTwain/Internals/ICommittable.cs b/src/NTwain/Internals/ICommittable.cs deleted file mode 100644 index 5d63c2a..0000000 --- a/src/NTwain/Internals/ICommittable.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace NTwain.Internals -{ - /// - /// For something that is in a pending state until finalized with a Commit() call. - /// The changes are rolled back if it is disposed without being committed. - /// - interface ICommittable : IDisposable - { - /// - /// Commits the pending changes. - /// - void Commit(); - } -} diff --git a/src/NTwain/Internals/ITwainSessionInternal.cs b/src/NTwain/Internals/ITwainSessionInternal.cs deleted file mode 100644 index 9655c21..0000000 --- a/src/NTwain/Internals/ITwainSessionInternal.cs +++ /dev/null @@ -1,56 +0,0 @@ -using NTwain.Data; -using NTwain.Triplets; -using System; -using System.Collections.Generic; -using System.Threading; - -namespace NTwain.Internals -{ - /// - /// Extends with extra stuff for internal use. - /// - interface ITwainSessionInternal : ITwainSession, ITripletControl - { - /// - /// Gets the app id used for the session. - /// - /// - TWIdentity AppId { get; } - - MessageLoopHook MessageLoopHook { get; } - - /// - /// Changes the state right away. - /// - /// The new state. - /// if set to true to notify change. - void ChangeState(int newState, bool notifyChange); - - /// - /// Gets the pending state changer and tentatively changes the session state to the specified value. - /// Value will only stick if committed. - /// - /// The new state. - /// - ICommittable GetPendingStateChanger(int newState); - - void ChangeCurrentSource(DataSource source); - - void UpdateCallback(); - - ReturnCode DisableSource(); - - void SafeSyncableRaiseEvent(DataTransferredEventArgs e); - void SafeSyncableRaiseEvent(TransferErrorEventArgs e); - void SafeSyncableRaiseEvent(TransferReadyEventArgs e); - - ReturnCode EnableSource(SourceEnableMode mode, bool modal, IntPtr windowHandle); - - bool CloseDSRequested { get; } - - /// - /// Gets the triplet operations defined for audio data group. - /// - DGAudio DGAudio { get; } - } -} diff --git a/src/NTwain/Internals/IWinMessageFilter.cs b/src/NTwain/Internals/IWinMessageFilter.cs deleted file mode 100644 index 3abc27a..0000000 --- a/src/NTwain/Internals/IWinMessageFilter.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NTwain.Internals -{ - /// - /// Interface for something that can check whether messages from WndProc is a TWAIN message and already handled. - /// - interface IWinMessageFilter - { - /// - /// Checks and handle the message if it's a TWAIN message. - /// - /// The window handle. - /// The message. - /// The w parameter. - /// The l parameter. - /// true if handled internally. - bool IsTwainMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam); - } - - -} diff --git a/src/NTwain/Internals/ImageTools.cs b/src/NTwain/Internals/ImageTools.cs deleted file mode 100644 index ecf46df..0000000 --- a/src/NTwain/Internals/ImageTools.cs +++ /dev/null @@ -1,138 +0,0 @@ -using NTwain.Interop; -using System; -using System.IO; -using System.Runtime.InteropServices; - -namespace NTwain.Internals -{ - static class ImageTools - { - // this is modified from twain cs sample - // http://sourceforge.net/projects/twainforcsharp/?source=typ_redirect - - public static bool IsDib(IntPtr data) - { - // a quick check not guaranteed correct, - // compare first 2 bytes to size of struct (which is also the first field) - var test = Marshal.ReadInt16(data); - // should be 40 - return test == BITMAPINFOHEADER.GetByteSize(); - } - public static bool IsTiff(IntPtr data) - { - var test = Marshal.ReadInt16(data); - // should be II - return test == 0x4949; - } - - - public static Stream GetBitmapStream(IntPtr data) - { - var infoHeader = (BITMAPINFOHEADER)Marshal.PtrToStructure(data, typeof(BITMAPINFOHEADER)); - if (infoHeader.Validate()) - { - var fileHeaderSize = Marshal.SizeOf(typeof(BITMAPFILEHEADER)); - - - var fileHeader = new BITMAPFILEHEADER(); - fileHeader.bfType = 0x4D42; // "BM" - fileHeader.bfOffBits = (uint)fileHeaderSize + - infoHeader.biSize + - (infoHeader.biClrUsed * 4); - fileHeader.bfSize = fileHeader.bfOffBits + infoHeader.biSizeImage; - - var dataCopy = new byte[fileHeader.bfSize]; - // write file header - IntPtr tempPtr = Marshal.AllocHGlobal(fileHeaderSize); - Marshal.StructureToPtr(fileHeader, tempPtr, true); - Marshal.Copy(tempPtr, dataCopy, 0, fileHeaderSize); - Marshal.FreeHGlobal(tempPtr); - // write image - Marshal.Copy(data, dataCopy, fileHeaderSize, (int)fileHeader.bfSize - fileHeaderSize); - - return new MemoryStream(dataCopy); - } - return null; - } - - public static Stream GetTiffStream(IntPtr data) - { - // Find the size of the image so we can turn it into a memory stream... - var headerSize = Marshal.SizeOf(typeof(TIFFHEADER)); - var tagSize = Marshal.SizeOf(typeof(TIFFTAG)); - var tiffSize = 0; - var tagPtr = data.ToInt64() + headerSize; - for (int i = 0; i < 999; i++) - { - tagPtr += (tagSize * i); - var tag = (TIFFTAG)Marshal.PtrToStructure((IntPtr)tagPtr, typeof(TIFFTAG)); - - switch (tag.u16Tag) - { - case 273: // StripOffsets... - case 279: // StripByteCounts... - tiffSize += (int)tag.u32Value; - break; - } - } - - if (tiffSize > 0) - { - var dataCopy = new byte[tiffSize]; - // is this optimal? - Marshal.Copy(data, dataCopy, 0, tiffSize); - return new MemoryStream(dataCopy); - } - return null; - } - - //internal static Bitmap ReadBitmapImage(IntPtr data) - //{ - // Bitmap finalImg = null; - // Bitmap tempImg = null; - // try - // { - // var header = (BITMAPINFOHEADER)Marshal.PtrToStructure(data, typeof(BITMAPINFOHEADER)); - - // if (header.Validate()) - // { - // PixelFormat format = header.GetDrawingPixelFormat(); - // tempImg = new Bitmap(header.biWidth, Math.Abs(header.biHeight), header.GetStride(), format, header.GetScan0(data)); - // ColorPalette pal = header.GetDrawingPalette(data); - // if (pal != null) - // { - // tempImg.Palette = pal; - // } - // float xdpi = header.GetXDpi(); - // float ydpi = header.GetYDpi(); - // if (xdpi != 0 && ydpi == 0) - // { - // ydpi = xdpi; - // } - // else if (ydpi != 0 && xdpi == 0) - // { - // xdpi = ydpi; - // } - // if (xdpi != 0) - // { - // tempImg.SetResolution(xdpi, ydpi); - // } - // if (header.IsBottomUpImage) - // { - // tempImg.RotateFlip(RotateFlipType.RotateNoneFlipY); - // } - // finalImg = tempImg; - // tempImg = null; - // } - // } - // finally - // { - // if (tempImg != null) - // { - // tempImg.Dispose(); - // } - // } - // return finalImg; - //} - } -} diff --git a/src/NTwain/Internals/InternalMessageLoopHook.cs b/src/NTwain/Internals/InternalMessageLoopHook.cs deleted file mode 100644 index b0650d7..0000000 --- a/src/NTwain/Internals/InternalMessageLoopHook.cs +++ /dev/null @@ -1,114 +0,0 @@ -using NTwain.Properties; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading; -using System.Windows.Threading; - -namespace NTwain.Internals -{ - /// - /// This is the self-hosted message loop for TWAIN communication. - /// It utilizes the wpf Dispatcher to do all the hard work. - /// - sealed class InternalMessageLoopHook : MessageLoopHook - { - Dispatcher _dispatcher; - WindowsHook _hook; - - internal override void Stop() - { - if (_dispatcher != null) - { - _dispatcher.InvokeShutdown(); - } - } - internal override void Start(IWinMessageFilter filter) - { - if (_dispatcher == null) - { - // using this hack so the new thread will start running before this function returns - using (var hack = new WrappedManualResetEvent()) - { - var loopThread = new Thread(new ThreadStart(() => - { - PlatformInfo.Current.Log.Debug("NTwain internal message loop is starting."); - _dispatcher = Dispatcher.CurrentDispatcher; - if (!PlatformInfo.Current.IsOnMono) - { - _hook = new WindowsHook(filter); - Handle = _hook.Handle; - } - hack.Set(); - Dispatcher.Run(); - // if dispatcher shutsdown we'll get here so make everything uninitialized - _dispatcher = null; - if (_hook != null) - { - _hook.Dispose(); - _hook = null; - Handle = IntPtr.Zero; - } - })); - loopThread.IsBackground = true; - loopThread.SetApartmentState(ApartmentState.STA); - loopThread.Start(); - hack.Wait(); - } - } - } - - public override void BeginInvoke(Action action) - { - if (_dispatcher == null) { throw new InvalidOperationException(Resources.MsgLoopUnavailble); } - - _dispatcher.BeginInvoke(DispatcherPriority.Normal, action); - } - - public override void Invoke(Action action) - { - if (_dispatcher == null) { throw new InvalidOperationException(Resources.MsgLoopUnavailble); } - - Exception error = null; - - if (_dispatcher.CheckAccess()) - { - action(); - } - else if (PlatformInfo.Current.IsOnMono) - { - using (var man = new WrappedManualResetEvent()) - { - _dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => - { - try - { - action(); - } - catch (Exception ex) { error = ex; } - finally - { - man.Set(); - } - })); - man.Wait(); - } - } - else - { - _dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => - { - try - { - action(); - } - catch (Exception ex) { error = ex; } - })); - } - - if (error != null) { Rethrow(error); } - } - } -} diff --git a/src/NTwain/Internals/LinuxMemoryManager.cs b/src/NTwain/Internals/LinuxMemoryManager.cs deleted file mode 100644 index 484001d..0000000 --- a/src/NTwain/Internals/LinuxMemoryManager.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; - -namespace NTwain.Internals -{ - class LinuxMemoryManager : IMemoryManager - { - #region IMemoryManager Members - - public IntPtr Allocate(uint size) - { - return Marshal.AllocHGlobal((int)size); - } - - public void Free(IntPtr handle) - { - Marshal.FreeHGlobal(handle); - } - - public IntPtr Lock(IntPtr handle) - { - return handle; - } - - public void Unlock(IntPtr handle) - { - // no op - } - - #endregion - } -} diff --git a/src/NTwain/Internals/TentativeStateCommitable.cs b/src/NTwain/Internals/TentativeStateCommitable.cs deleted file mode 100644 index 266e9e9..0000000 --- a/src/NTwain/Internals/TentativeStateCommitable.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace NTwain.Internals -{ - class TentativeStateCommitable : ICommittable - { - bool _commit; - ITwainSessionInternal _session; - int _origState; - int _newState; - public TentativeStateCommitable(ITwainSessionInternal session, int newState) - { - _session = session; - _origState = session.State; - _newState = newState; - _session.ChangeState(newState, false); - } - - #region ICommitable Members - - public void Commit() - { - if (_session.State == _newState) - { - _session.ChangeState(_newState, true); - } - _commit = true; - } - - #endregion - - #region IDisposable Members - - public void Dispose() - { - if (!_commit && _session.State == _newState) - { - _session.ChangeState(_origState, false); - } - } - - #endregion - } -} diff --git a/src/NTwain/Internals/TraceLog.cs b/src/NTwain/Internals/TraceLog.cs deleted file mode 100644 index e607478..0000000 --- a/src/NTwain/Internals/TraceLog.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; - -namespace NTwain.Internals -{ - class TraceLog : ILog - { - public TraceLog() - { - IsInfoEnabled = true; - IsErrorEnabled = true; - } - - public bool IsInfoEnabled { get; set; } - - public bool IsDebugEnabled { get; set; } - - public bool IsErrorEnabled { get; set; } - - - public void Info(string message) - { - if (IsInfoEnabled && message != null) - { - System.Diagnostics.Trace.WriteLine(message, "Info"); - } - } - - public void Info(string messageFormat, params object[] args) - { - Debug(string.Format(CultureInfo.CurrentCulture, messageFormat, args)); - } - - public void Debug(string message) - { - if (IsDebugEnabled && message != null) - { - System.Diagnostics.Trace.WriteLine(message, "Debug"); - } - } - - public void Debug(string messageFormat, params object[] args) - { - Debug(string.Format(CultureInfo.CurrentCulture, messageFormat, args)); - } - - public void Error(string message) - { - if (IsErrorEnabled && message != null) - { - System.Diagnostics.Trace.WriteLine(message, "Error"); - } - } - - public void Error(string message, Exception exception) - { - if (exception == null) - { - Error(message); - } - else - { - Error(message + Environment.NewLine + exception.ToString()); - } - } - - public void Error(string messageFormat, Exception exception, params object[] args) - { - if (exception == null) - { - Error(string.Format(CultureInfo.CurrentCulture, messageFormat, args)); - } - else - { - Error(string.Format(CultureInfo.CurrentCulture, messageFormat, args) + Environment.NewLine + exception.ToString()); - } - } - } -} diff --git a/src/NTwain/Internals/TransferLogic.cs b/src/NTwain/Internals/TransferLogic.cs deleted file mode 100644 index dcbafd2..0000000 --- a/src/NTwain/Internals/TransferLogic.cs +++ /dev/null @@ -1,476 +0,0 @@ -using NTwain.Data; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; - -namespace NTwain.Internals -{ - /// - /// Contains the actual data transfer logic since TwainSession is getting too large. - /// - static class TransferLogic - { - /// - /// Performs the TWAIN transfer routine at state 6. - /// - public static void DoTransferRoutine(ITwainSessionInternal session) - { - #region get xfer types - - bool xferImage = true; // default to always xfer image - bool xferAudio = false; - DataGroups xferGroup = DataGroups.None; - XferMech imgXferMech = XferMech.Native; - XferMech audXferMech = XferMech.Native; - if (session.DGControl.XferGroup.Get(ref xferGroup) == ReturnCode.Success) - { - xferAudio = (xferGroup & DataGroups.Audio) == DataGroups.Audio; - // check for Plustek OpticSlim 2680H, this scanner returns wrong xferGroup after first scanning - if (session.CurrentSource.Identity.ProductName.IndexOf("Plustek", StringComparison.OrdinalIgnoreCase) > -1 && - session.CurrentSource.Identity.ProductName.IndexOf("OpticSlim", StringComparison.OrdinalIgnoreCase) > -1 && - session.CurrentSource.Identity.ProductName.IndexOf("2680H", StringComparison.OrdinalIgnoreCase) > -1) - { - xferImage = true; - } - else - { - xferImage = xferGroup == DataGroups.None || (xferGroup & DataGroups.Image) == DataGroups.Image; - } - } - // some DS end up getting none but we will assume it's image - if (xferImage) - { - imgXferMech = session.CurrentSource.Capabilities.ICapXferMech.GetCurrent(); - } - if (xferAudio) - { - var mech = session.CurrentSource.Capabilities.ACapXferMech.GetCurrent(); - } - - #endregion - - var pending = new TWPendingXfers(); - var rc = session.DGControl.PendingXfers.Get(pending); - if (rc == ReturnCode.Success) - { - do - { - #region raise xfer ready - - var preXferArgs = new TransferReadyEventArgs(session.CurrentSource, pending.Count, pending.EndOfJob); ; - session.SafeSyncableRaiseEvent(preXferArgs); - - #endregion - - #region actually handle xfer - - if (preXferArgs.CancelAll || session.CloseDSRequested) - { - rc = session.DGControl.PendingXfers.Reset(pending); - } - else - { - if (!preXferArgs.CancelCurrent) - { - if (xferImage) - { - switch (imgXferMech) - { - case XferMech.Memory: - rc = DoImageMemoryXfer(session); - break; - case XferMech.File: - rc = DoImageFileXfer(session); - break; - case XferMech.MemFile: - rc = DoImageMemoryFileXfer(session); - break; - case XferMech.Native: - default: // always assume native - rc = DoImageNativeXfer(session); - break; - } - } - if (xferAudio) - { - switch (audXferMech) - { - case XferMech.File: - rc = DoAudioFileXfer(session); - break; - case XferMech.Native: - default: // always assume native - rc = DoAudioNativeXfer(session); - break; - } - } - } - - if (rc != ReturnCode.Success && session.StopOnTransferError) - { - // end xfer without setting rc to exit (good/bad?) - session.DGControl.PendingXfers.Reset(pending); - } - else - { - rc = session.DGControl.PendingXfers.EndXfer(pending); - } - } - #endregion - - } while (rc == ReturnCode.Success && pending.Count != 0 && !session.CloseDSRequested); - } - else - { - HandleReturnCode(session, rc); - } - - // some poorly written scanner drivers return failure on EndXfer so also check for pending count now. - // this may break with other sources but we'll see - if (//pending.Count == 0 && - session.State > 5) - { - session.ChangeState(5, true); - session.DisableSource(); - } - } - - private static void HandleReturnCode(ITwainSessionInternal session, ReturnCode rc) - { - switch (rc) - { - case ReturnCode.Success: - case ReturnCode.XferDone: - case ReturnCode.Cancel: - // ok to keep going - break; - default: - var status = session.CurrentSource.GetStatus(); - session.SafeSyncableRaiseEvent(new TransferErrorEventArgs(rc, status)); - break; - } - } - - #region audio xfers - - static ReturnCode DoAudioNativeXfer(ITwainSessionInternal session) - { - IntPtr dataPtr = IntPtr.Zero; - IntPtr lockedPtr = IntPtr.Zero; - ReturnCode xrc = ReturnCode.Failure; - try - { - xrc = session.DGAudio.AudioNativeXfer.Get(ref dataPtr); - if (xrc == ReturnCode.XferDone) - { - session.ChangeState(7, true); - if (dataPtr != IntPtr.Zero) - { - lockedPtr = PlatformInfo.Current.MemoryManager.Lock(dataPtr); - } - - session.SafeSyncableRaiseEvent(new DataTransferredEventArgs(session.CurrentSource, lockedPtr)); - } - else - { - HandleReturnCode(session, xrc); - } - } - catch (Exception ex) - { - session.SafeSyncableRaiseEvent(new TransferErrorEventArgs(ex)); - } - finally - { - session.ChangeState(6, true); - // data here is allocated by source so needs to use shared mem calls - if (lockedPtr != IntPtr.Zero) - { - //PlatformInfo.Current.MemoryManager.Unlock(lockedPtr); - PlatformInfo.Current.MemoryManager.Unlock(dataPtr); - lockedPtr = IntPtr.Zero; - } - if (dataPtr != IntPtr.Zero) - { - PlatformInfo.Current.MemoryManager.Free(dataPtr); - dataPtr = IntPtr.Zero; - } - } - return xrc; - } - - static ReturnCode DoAudioFileXfer(ITwainSessionInternal session) - { - string filePath = null; - TWSetupFileXfer setupInfo; - ReturnCode xrc = session.DGControl.SetupFileXfer.Get(out setupInfo); - if (xrc == ReturnCode.Success) - { - filePath = setupInfo.FileName; - - xrc = session.DGAudio.AudioFileXfer.Get(); - if (xrc == ReturnCode.XferDone) - { - session.SafeSyncableRaiseEvent(new DataTransferredEventArgs(session.CurrentSource, filePath, (FileFormat)0)); - } - else - { - HandleReturnCode(session, xrc); - } - } - return xrc; - } - - #endregion - - #region image xfers - - static ReturnCode DoImageNativeXfer(ITwainSessionInternal session) - { - IntPtr dataPtr = IntPtr.Zero; - IntPtr lockedPtr = IntPtr.Zero; - ReturnCode xrc = ReturnCode.Failure; - try - { - xrc = session.DGImage.ImageNativeXfer.Get(ref dataPtr); - if (xrc == ReturnCode.XferDone) - { - session.ChangeState(7, true); - if (dataPtr != IntPtr.Zero) - { - lockedPtr = PlatformInfo.Current.MemoryManager.Lock(dataPtr); - } - DoImageXferredEventRoutine(session, lockedPtr, null, null, null, (FileFormat)0); - } - else - { - HandleReturnCode(session, xrc); - } - } - catch (Exception ex) - { - session.SafeSyncableRaiseEvent(new TransferErrorEventArgs(ex)); - } - finally - { - session.ChangeState(6, true); - // data here is allocated by source so needs to use shared mem calls - if (lockedPtr != IntPtr.Zero) - { - //PlatformInfo.Current.MemoryManager.Unlock(lockedPtr); - PlatformInfo.Current.MemoryManager.Unlock(dataPtr); - lockedPtr = IntPtr.Zero; - } - if (dataPtr != IntPtr.Zero) - { - PlatformInfo.Current.MemoryManager.Free(dataPtr); - dataPtr = IntPtr.Zero; - } - } - return xrc; - } - - static ReturnCode DoImageFileXfer(ITwainSessionInternal session) - { - string filePath = null; - TWSetupFileXfer setupInfo; - if (session.DGControl.SetupFileXfer.Get(out setupInfo) == ReturnCode.Success) - { - filePath = setupInfo.FileName; - } - - var xrc = session.DGImage.ImageFileXfer.Get(); - if (xrc == ReturnCode.XferDone) - { - DoImageXferredEventRoutine(session, IntPtr.Zero, null, null, filePath, setupInfo.Format); - } - else - { - HandleReturnCode(session, xrc); - } - return xrc; - } - - static ReturnCode DoImageMemoryXfer(ITwainSessionInternal session) - { - TWSetupMemXfer memInfo; - ReturnCode xrc = session.DGControl.SetupMemXfer.Get(out memInfo); - if (xrc == ReturnCode.Success) - { - TWImageMemXfer xferInfo = new TWImageMemXfer(); - try - { - // how to tell if going to xfer in strip vs tile? - // if tile don't allocate memory in app? - - xferInfo.Memory = new TWMemory - { - Flags = MemoryFlags.AppOwns | MemoryFlags.Pointer, - Length = memInfo.Preferred, - TheMem = PlatformInfo.Current.MemoryManager.Allocate(memInfo.Preferred) - }; - - - do - { - xrc = session.DGImage.ImageMemXfer.Get(xferInfo); - - if (xrc == ReturnCode.Success || - xrc == ReturnCode.XferDone) - { - if (session.State != 7) { session.ChangeState(7, true); } - - // optimize and allocate buffer only once instead of inside the loop? - byte[] buffer = new byte[(int)xferInfo.BytesWritten]; - - IntPtr lockPtr = IntPtr.Zero; - try - { - lockPtr = PlatformInfo.Current.MemoryManager.Lock(xferInfo.Memory.TheMem); - Marshal.Copy(lockPtr, buffer, 0, buffer.Length); - } - finally - { - if (lockPtr != IntPtr.Zero) - { - PlatformInfo.Current.MemoryManager.Unlock(xferInfo.Memory.TheMem); - } - } - DoImageXferredEventRoutine(session, IntPtr.Zero, xferInfo, buffer, null, (FileFormat)0); - } - } while (xrc == ReturnCode.Success); - - HandleReturnCode(session, xrc); - } - catch (Exception ex) - { - session.SafeSyncableRaiseEvent(new TransferErrorEventArgs(ex)); - } - finally - { - session.ChangeState(6, true); - if (xferInfo.Memory.TheMem != IntPtr.Zero) - { - PlatformInfo.Current.MemoryManager.Free(xferInfo.Memory.TheMem); - } - } - - } - return xrc; - } - - static ReturnCode DoImageMemoryFileXfer(ITwainSessionInternal session) - { - // since it's memory-file xfer need info from both (maybe) - TWSetupMemXfer memInfo; - TWSetupFileXfer fileInfo; - ReturnCode xrc = ReturnCode.Failure; - if (session.DGControl.SetupMemXfer.Get(out memInfo) == ReturnCode.Success && - session.DGControl.SetupFileXfer.Get(out fileInfo) == ReturnCode.Success) - { - TWImageMemXfer xferInfo = new TWImageMemXfer(); - var tempFile = Path.GetTempFileName(); - string finalFile = null; - try - { - // no strip or tile here, just chunks - xferInfo.Memory = new TWMemory - { - Flags = MemoryFlags.AppOwns | MemoryFlags.Pointer, - Length = memInfo.Preferred, - TheMem = PlatformInfo.Current.MemoryManager.Allocate(memInfo.Preferred) - }; - - xrc = ReturnCode.Success; - using (var outStream = File.OpenWrite(tempFile)) - { - do - { - xrc = session.DGImage.ImageMemFileXfer.Get(xferInfo); - - if (xrc == ReturnCode.Success || - xrc == ReturnCode.XferDone) - { - session.ChangeState(7, true); - byte[] buffer = new byte[(int)xferInfo.BytesWritten]; - - IntPtr lockPtr = IntPtr.Zero; - try - { - lockPtr = PlatformInfo.Current.MemoryManager.Lock(xferInfo.Memory.TheMem); - Marshal.Copy(lockPtr, buffer, 0, buffer.Length); - } - finally - { - if (lockPtr != IntPtr.Zero) - { - PlatformInfo.Current.MemoryManager.Unlock(xferInfo.Memory.TheMem); - //PlatformInfo.Current.MemoryManager.Unlock(lockPtr); - } - } - outStream.Write(buffer, 0, buffer.Length); - } - } while (xrc == ReturnCode.Success); - } - - if (xrc == ReturnCode.XferDone) - { - finalFile = fileInfo.ChangeExtensionByFormat(tempFile); - File.Move(tempFile, finalFile); - } - else - { - HandleReturnCode(session, xrc); - } - } - catch (Exception ex) - { - session.SafeSyncableRaiseEvent(new TransferErrorEventArgs(ex)); - } - finally - { - session.ChangeState(6, true); - if (xferInfo.Memory.TheMem != IntPtr.Zero) - { - PlatformInfo.Current.MemoryManager.Free(xferInfo.Memory.TheMem); - } - if (File.Exists(tempFile)) - { - File.Delete(tempFile); - } - } - - if (File.Exists(finalFile)) - { - DoImageXferredEventRoutine(session, IntPtr.Zero, null, null, finalFile, fileInfo.Format); - } - } - return xrc; - } - - static void DoImageXferredEventRoutine(ITwainSessionInternal session, IntPtr dataPtr, TWImageMemXfer memInfo, byte[] memData, string filePath, FileFormat format) - { - DataTransferredEventArgs args = null; - - if (dataPtr != IntPtr.Zero) - { - args = new DataTransferredEventArgs(session.CurrentSource, dataPtr); - } - else if (memData != null) - { - args = new DataTransferredEventArgs(session.CurrentSource, memInfo, memData); - } - else - { - args = new DataTransferredEventArgs(session.CurrentSource, filePath, format); - } - session.SafeSyncableRaiseEvent(args); - } - - #endregion - } -} diff --git a/src/NTwain/Internals/WinMemoryManager.cs b/src/NTwain/Internals/WinMemoryManager.cs deleted file mode 100644 index 50b1ae9..0000000 --- a/src/NTwain/Internals/WinMemoryManager.cs +++ /dev/null @@ -1,39 +0,0 @@ -using NTwain.Data; -using NTwain.Interop; -using System; -using System.ComponentModel; - -namespace NTwain.Internals -{ - /// - /// Provides methods for managing memory on data exchanged with twain sources using old win32 methods. - /// - class WinMemoryManager : IMemoryManager - { - public IntPtr Allocate(uint size) - { - IntPtr retVal = UnsafeNativeMethods.WinGlobalAlloc(0x0040, new UIntPtr(size)); - - if (retVal == IntPtr.Zero) - { - throw new Win32Exception(); - } - return retVal; - } - - public void Free(IntPtr handle) - { - UnsafeNativeMethods.WinGlobalFree(handle); - } - - public IntPtr Lock(IntPtr handle) - { - return UnsafeNativeMethods.WinGlobalLock(handle); - } - - public void Unlock(IntPtr handle) - { - UnsafeNativeMethods.WinGlobalUnlock(handle); - } - } -} diff --git a/src/NTwain/Internals/WindowsHook.cs b/src/NTwain/Internals/WindowsHook.cs deleted file mode 100644 index 8b274aa..0000000 --- a/src/NTwain/Internals/WindowsHook.cs +++ /dev/null @@ -1,75 +0,0 @@ -using NTwain.Interop; -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Windows.Interop; - -namespace NTwain.Internals -{ - - /// - /// Abstracts out wnd proc hook on Windows from InternalMessageLoopHook class. - /// This allows things to not depend on PresentationCore.dll at runtime on mono. - /// - class WindowsHook : IDisposable - { - IDisposable _win; - IWinMessageFilter _filter; - - public WindowsHook(IWinMessageFilter filter) - { - _filter = filter; - - HwndSource win = null; - try - { - // hook into windows msg loop for old twain to post msgs. - // the style values are purely guesses here with - // CS_NOCLOSE, WS_TILEDWINDOW, and WS_EX_APPWINDOW - win = new HwndSource(0x0200, 0xCF0000, 0x40000, 0, 0, "NTWAIN_LOOPER", IntPtr.Zero); - Handle = win.Handle; - win.AddHook(WndProc); - _win = win; - } - catch - { - if (win != null) { win.Dispose(); } - throw; - } - } - - - private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) - { - if (_filter != null) - { - handled = _filter.IsTwainMessage(hwnd, msg, wParam, lParam); - } - if (!handled) - { - handled = true; - // unnecessary to do default wndproc? - return NativeMethods.DefWindowProc(hwnd, (uint)msg, wParam, lParam); - } - return IntPtr.Zero; - } - - public IntPtr Handle { get; private set; } - - - #region IDisposable Members - - public void Dispose() - { - if (_win != null) - { - ((HwndSource)_win).RemoveHook(WndProc); - _win.Dispose(); - _win = null; - Handle = IntPtr.Zero; - } - } - - #endregion - } -} diff --git a/src/NTwain/Internals/WrappedManualResetEvent.cs b/src/NTwain/Internals/WrappedManualResetEvent.cs deleted file mode 100644 index a99a401..0000000 --- a/src/NTwain/Internals/WrappedManualResetEvent.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Threading; - -namespace NTwain.Internals -{ - - // just a test - - class WrappedManualResetEvent : IDisposable - { -#if NET35 - ManualResetEvent _mre; -#else - ManualResetEventSlim _slim; -#endif - - public WrappedManualResetEvent() - { -#if NET35 - _mre = new ManualResetEvent(false); -#else - _slim = new ManualResetEventSlim(); -#endif - } - - public void Wait() - { -#if NET35 - _mre.WaitOne(); -#else - _slim.Wait(); -#endif - } - - public void Set() - { -#if NET35 - _mre.Set(); -#else - _slim.Set(); -#endif - } - - #region IDisposable Members - - public void Dispose() - { -#if NET35 - _mre.Close(); -#else - _slim.Dispose(); -#endif - } - - #endregion - } -} diff --git a/src/NTwain/Interop/BITMAP.cs b/src/NTwain/Interop/BITMAP.cs deleted file mode 100644 index 01afa22..0000000 --- a/src/NTwain/Interop/BITMAP.cs +++ /dev/null @@ -1,342 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Imaging; -using System.Runtime.InteropServices; -using System.Text; - -namespace NTwain.Interop -{ - // this is a good read - // http://atlc.sourceforge.net/bmp.html - - /// - /// Defines the dimensions and color information for a DIB. - /// - [StructLayout(LayoutKind.Sequential)] - struct BITMAPINFO - { - /// - /// Structure that contains information about the dimensions of color format. - /// - public BITMAPINFOHEADER bmiHeader; - /// - /// This contains one of the following: - /// 1. An array of RGBQUAD. The elements of the array that make up the color table. - /// 2. An array of 16-bit unsigned integers that specifies indexes into the currently realized logical palette. This use of bmiColors is allowed for functions that use DIBs. - /// The number of entries in the array depends on the values of the biBitCount and biClrUsed members of the BITMAPINFOHEADER structure. - /// - public IntPtr bmiColors; - - }; - - /// - /// Structure that contains information about the dimensions and color format of a DIB. - /// - [StructLayout(LayoutKind.Sequential)] - struct BITMAPINFOHEADER - { - #region fields - /// - /// The number of bytes required by the structure. - /// - public uint biSize; - /// - /// The width of the bitmap, in pixels. - /// If Compression is JPEG or PNG, the Width member specifies the width of the decompressed - /// JPEG or PNG image file, respectively. - /// - public int biWidth; - /// - /// The height of the bitmap, in pixels. If Height is positive, - /// the bitmap is a bottom-up DIB and its origin is the lower-left corner. - /// If Height is negative, the bitmap is a top-down DIB and its origin is the upper-left corner. - /// If Height is negative, indicating a top-down DIB, Compression must be either RGB or BITFIELDS. Top-down DIBs cannot be compressed. - /// If Compression is JPEG or PNG, the Height member specifies the height of the decompressed JPEG or PNG image file, respectively. - /// - public int biHeight; - /// - /// The number of planes for the target device. This value must be set to 1. - /// - public ushort biPlanes; - /// - /// The number of bits-per-pixel. The BitCount member - /// determines the number of bits that define each pixel and the maximum number of colors in the bitmap. - /// - public ushort biBitCount; - /// - /// The type of compression for a compressed bottom-up bitmap (top-down DIBs cannot be compressed). - /// - public CompressionType biCompression; - /// - /// The size, in bytes, of the image. This may be set to zero for RGB bitmaps. - /// If Compression is JPEG or PNG, SizeImage indicates the size of the JPEG or PNG image buffer, respectively. - /// - public uint biSizeImage; - /// - /// The horizontal resolution, in pixels-per-meter, of the target device for the bitmap. - /// An application can use this value to select a bitmap from a resource group that - /// best matches the characteristics of the current device. - /// - public int biXPelsPerMeter; - /// - /// The vertical resolution, in pixels-per-meter, of the target device for the bitmap. - /// - public int biYPelsPerMeter; - /// - /// The number of color indexes in the color table that are actually used by the bitmap. - /// If this value is zero, the bitmap uses the maximum number of colors corresponding to - /// the value of the BitCount member for the compression mode specified by Compression. - /// - public uint biClrUsed; - /// - /// The number of color indexes that are required for displaying the bitmap. - /// If this value is zero, all colors are required. - /// - public uint biClrImportant; - #endregion - - #region utilities - - const double METER_INCH_RATIO = 39.3700787; - - /// - /// Gets the horizontal dpi of the bitmap. - /// - /// - public float GetXDpi() - { - return (float)Math.Round(biXPelsPerMeter / METER_INCH_RATIO, 0); - } - /// - /// Gets the vertical dpi of the bitmap. - /// - /// - public float GetYDpi() - { - return (float)Math.Round(biYPelsPerMeter / METER_INCH_RATIO, 0); - } - /// - /// Gets the size of the structure. - /// - /// - public static uint GetByteSize() - { - return (uint)Marshal.SizeOf(typeof(BITMAPINFOHEADER)); - } - /// - /// Checks to see if this structure contain valid data. - /// It also fills in any missing pieces if possible. - /// - /// - public bool Validate() - { - if (biHeight != 0 && biWidth != 0 && biBitCount != 0) - { - if (biSize == 0) - { - biSize = GetByteSize(); - } - if (biClrUsed == 0) - { - switch (biBitCount) - { - case 1: - biClrUsed = 2; - break; - case 4: - biClrUsed = 16; - break; - case 8: - biClrUsed = 256; - break; - } - } - if (biSizeImage == 0) - { - biSizeImage = (uint)(((( - biWidth * biBitCount) + 31) & ~31) >> 3) * (uint)Math.Abs(biHeight); - } - - return true; - } - return false; - } - - /// - /// Gets the pointer to scan0 given the header pointer. - /// - /// The header PTR. - /// - public IntPtr GetScan0(IntPtr headerPtr) - { - int p = (int)biClrUsed; - if ((p == 0) && (biBitCount <= 8)) - { - p = 1 << biBitCount; - } - p = (p * 4) + (int)biSize + headerPtr.ToInt32(); - return new IntPtr(p); - } - - /// - /// Gets whether the bitmap is bottom-up or top-down format. - /// - /// - /// true if this instance is bottom up image; otherwise, false. - /// - /// - public bool IsBottomUpImage - { - get - { - return biHeight > 0; - } - } - - - /// - /// Gets the System.Drawing pixel format of current structure. - /// - /// - public PixelFormat GetDrawingPixelFormat() - { - switch (biBitCount) - { - case 1: - return PixelFormat.Format1bppIndexed; - case 4: - return PixelFormat.Format4bppIndexed; - case 8: - return PixelFormat.Format8bppIndexed; - case 16: - return PixelFormat.Format16bppRgb565; - case 24: - return PixelFormat.Format24bppRgb; - case 32: - return PixelFormat.Format32bppRgb; - case 48: - return PixelFormat.Format48bppRgb; - } - return PixelFormat.DontCare; - } - /// - /// Gets the color palette that's contained in the header. - /// Note not all images will have palette, so check if the return value - /// is null before using it. - /// - /// - public ColorPalette GetDrawingPalette(IntPtr headerPtr) - { - //if (format == PixelFormat.Format8bppIndexed) - //{ - // // update color palette to grayscale version - // ColorPalette grayPallet = bitmap.Palette; - // for (int i = 0; i < grayPallet.Entries.Length; i++) - // { - // grayPallet.Entries[i] = Color.FromArgb(i, i, i); - // } - // bitmap.Palette = grayPallet; // this is what makes the gray pallet take effect - //} - - if (biClrUsed > 0) - { - byte[] data = new byte[biClrUsed * 4]; - Marshal.Copy(new IntPtr(headerPtr.ToInt32() + biSize), data, 0, data.Length); - var dummy = new System.Drawing.Bitmap(1, 1, GetDrawingPixelFormat()); - ColorPalette pal = dummy.Palette; - dummy.Dispose(); - int index = 0; - int setCount = data.Length / 4; - for (int i = 0; i < setCount; i++) - { - index = i * 4; - pal.Entries[i] = Color.FromArgb(data[index + 2], data[index + 1], data[index]); - } - return pal; - } - return null; - } - - /// - /// Gets the stride size of this bitmap. - /// - /// - public int GetStride() - { - int bitsPerRow = (biBitCount * biWidth); - int strideTest = bitsPerRow / 8 + (bitsPerRow % 8 != 0 ? 1 : 0); - int overage = strideTest % 4; - if (overage > 0) - { - strideTest += (4 - overage); - } - return strideTest; - } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() - { - return new StringBuilder().Append("BitmapInfoHeader:") - .Append("\r\n\tSize = " + biSize) - .Append("\r\n\tWidth = " + biWidth) - .Append("\r\n\tHeight = " + biHeight) - .Append("\r\n\tPlanes = " + biPlanes) - .Append("\r\n\tBitCount = " + biBitCount) - .Append("\r\n\tCompression = " + biCompression) - .Append("\r\n\tSizeImage = " + biSizeImage) - .Append("\r\n\tXPixelsPerMeter = " + biXPelsPerMeter) - .Append("\r\n\tYPixelsPerMeter = " + biYPelsPerMeter) - .Append("\r\n\tColorUsed = " + biClrUsed) - .Append("\r\n\tColorImportant = " + biClrImportant).ToString(); - } - #endregion - - /// - /// Indicates the bitmap compression of . - /// - public enum CompressionType : uint - { - /// - /// An uncompressed format. - /// - BI_RGB = 0, - /// - /// A run-length encoded (RLE) format for bitmaps with 8 bpp. The compression format is a 2-byte format consisting of a count byte followed by a byte containing a color index. For more information, see Bitmap Compression. - /// - BI_RLE8 = 1, - /// - /// An RLE, format for bitmaps with 4 bpp. The compression format is a 2-byte format consisting of a count byte followed by two word-length color indexes. For more information, see Bitmap Compression. - /// - BI_RLE4 = 2, - /// - /// Specifies that the bitmap is not compressed and that the color table consists of three DWORD color masks that specify the red, green, and blue components of each pixel. - /// This is valid when used with 16- and 32-bpp bitmaps. - /// - BI_BITFIELDS = 3, - /// - /// Indicates that the image is a JPEG image. - /// - BI_JPEG = 4, - /// - /// Indicates that the image is a PNG image. - /// - BI_PNG = 5 - } - }; - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BITMAPFILEHEADER - { - public ushort bfType; - public uint bfSize; - public ushort bfReserved1; - public ushort bfReserved2; - public uint bfOffBits; - } -} diff --git a/src/NTwain/Interop/MESSAGE.cs b/src/NTwain/Interop/MESSAGE.cs deleted file mode 100644 index 5cec9f6..0000000 --- a/src/NTwain/Interop/MESSAGE.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; - -namespace NTwain.Interop -{ - /// - /// The MSG structure in Windows for TWAIN use. - /// - [StructLayout(LayoutKind.Sequential)] - struct MESSAGE - { - public MESSAGE(IntPtr hwnd, int message, IntPtr wParam, IntPtr lParam) - { - _hwnd = hwnd; - _message = (uint)message; - _wParam = wParam; - _lParam = lParam; - _time = 0; - _x = 0; - _y = 0; - } - - IntPtr _hwnd; - uint _message; - IntPtr _wParam; - IntPtr _lParam; - uint _time; - int _x; - int _y; - } -} diff --git a/src/NTwain/Interop/NativeMethods.cs b/src/NTwain/Interop/NativeMethods.cs deleted file mode 100644 index 7743e06..0000000 --- a/src/NTwain/Interop/NativeMethods.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; - -namespace NTwain.Interop -{ - static class NativeMethods - { - [DllImport("gdi32.dll", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool DeleteObject(IntPtr hObject); - - [DllImport("user32.dll")] - public static extern IntPtr DefWindowProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam); - } -} diff --git a/src/NTwain/Interop/TIFF.cs b/src/NTwain/Interop/TIFF.cs deleted file mode 100644 index ebfba86..0000000 --- a/src/NTwain/Interop/TIFF.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; - -namespace NTwain.Interop -{ - // this is from twain cs sample - // http://sourceforge.net/projects/twainforcsharp/?source=typ_redirect - - /// - /// The TIFF file header. - /// - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct TIFFHEADER - { - public ushort u8ByteOrder; - public ushort u16Version; - public uint u32OffsetFirstIFD; - public ushort u16u16IFD; - } - - /// - /// An individual TIFF Tag. - /// - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct TIFFTAG - { - public ushort u16Tag; - public ushort u16Type; - public uint u32Count; - public uint u32Value; - } -} diff --git a/src/NTwain/Interop/UnsafeNativeMethods.cs b/src/NTwain/Interop/UnsafeNativeMethods.cs deleted file mode 100644 index 21ea7b8..0000000 --- a/src/NTwain/Interop/UnsafeNativeMethods.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using System.Security; - -namespace NTwain.Interop -{ - [SuppressUnmanagedCodeSecurity] - static class UnsafeNativeMethods - { - #region mem stuff for twain 1.x - - [DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalAlloc")] - internal static extern IntPtr WinGlobalAlloc(uint uFlags, UIntPtr dwBytes); - - [DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalFree")] - internal static extern IntPtr WinGlobalFree(IntPtr hMem); - - [DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalLock")] - internal static extern IntPtr WinGlobalLock(IntPtr handle); - - [DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalUnlock")] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool WinGlobalUnlock(IntPtr handle); - - #endregion - } -} diff --git a/src/NTwain/MessageLoopHooks.cs b/src/NTwain/MessageLoopHooks.cs deleted file mode 100644 index f91f619..0000000 --- a/src/NTwain/MessageLoopHooks.cs +++ /dev/null @@ -1,221 +0,0 @@ -using NTwain.Internals; -using System; -using System.Reflection; -using System.Threading; -using System.Windows.Interop; - -namespace NTwain -{ - /// - /// An abstract class for TWAIN to hook into windows message loops. - /// - public abstract class MessageLoopHook - { - internal IntPtr Handle { get; set; } - internal SynchronizationContext SyncContext { get; set; } - - internal abstract void Start(IWinMessageFilter filter); - internal abstract void Stop(); - - /// - /// Asynchronously invokes the specified action on the message loop thread. - /// - /// The action. - public virtual void BeginInvoke(Action action) - { - if (SyncContext == null) - { - action(); - } - else - { - SyncContext.Post(o => - { - action(); - }, null); - } - } - - /// - /// Synchronously invokes the specified action on the message loop thread. - /// - /// The action. - public virtual void Invoke(Action action) - { - if (SyncContext == null) - { - action(); - } - else - { - Exception error = null; - SyncContext.Send(o => - { - try - { - action(); - } - catch (Exception ex) - { - error = ex; - } - }, null); - - if (error != null) { Rethrow(error); } - } - } - - /// - /// Rethrows the specified excetion while keeping stack trace. - /// - /// The ex. - protected static void Rethrow(Exception ex) - { - typeof(Exception).GetMethod("PrepForRemoting", - BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(ex, new object[0]); - throw ex; - } - - internal void ThrowInvalidOp() - { - throw new InvalidOperationException(InvalidMessage); - } - - internal virtual string InvalidMessage { get { return string.Empty; } } - } - - /// - /// A for use in winform applications. - /// - public sealed class WindowsFormsMessageLoopHook : MessageLoopHook, System.Windows.Forms.IMessageFilter - { - IWinMessageFilter _filter; - - /// - /// Initializes a new instance of the class. - /// - /// The handle to the app window. - /// A valid window handle is required. - public WindowsFormsMessageLoopHook(IntPtr windowHandle) - { - if (windowHandle == IntPtr.Zero) { throw new ArgumentException("A valid window handle is required."); } - - if (!System.Windows.Forms.Application.MessageLoop) - { - ThrowInvalidOp(); - } - var sync = SynchronizationContext.Current; - if (sync == null) - { - ThrowInvalidOp(); - } - Handle = windowHandle; - SyncContext = sync; - } - internal override string InvalidMessage - { - get - { - return "This can only be created on the Windows Forms UI thread."; - } - } - - internal override void Start(IWinMessageFilter filter) - { - //Invoke(() => - //{ - _filter = filter; - System.Windows.Forms.Application.AddMessageFilter(this); - //}); - } - - internal override void Stop() - { - //Invoke(() => - //{ - System.Windows.Forms.Application.RemoveMessageFilter(this); - _filter = null; - //}); - } - - - #region IMessageFilter Members - - bool System.Windows.Forms.IMessageFilter.PreFilterMessage(ref System.Windows.Forms.Message m) - { - if (_filter != null) - { - return _filter.IsTwainMessage(m.HWnd, m.Msg, m.WParam, m.LParam); - } - return false; - } - - #endregion - } - - /// - /// A for use in WPF applications. - /// - public sealed class WpfMessageLoopHook : MessageLoopHook - { - HwndSource _hooker; - IWinMessageFilter _filter; - - /// - /// Initializes a new instance of the class. - /// - /// The handle to the app window. - /// A valid window handle is required. - public WpfMessageLoopHook(IntPtr windowHandle) - { - if (windowHandle == IntPtr.Zero) { throw new ArgumentException("A valid window handle is required."); } - - if (System.Windows.Application.Current == null || - !System.Windows.Application.Current.Dispatcher.CheckAccess()) - { - ThrowInvalidOp(); - } - var sync = SynchronizationContext.Current; - if (sync == null) - { - ThrowInvalidOp(); - } - Handle = windowHandle; - SyncContext = sync; - } - internal override string InvalidMessage - { - get - { - return "This can only be created on the WPF UI thread."; - } - } - - internal override void Start(IWinMessageFilter filter) - { - _filter = filter; - _hooker = HwndSource.FromHwnd(Handle); - _hooker.AddHook(FilterMessage); - } - - private IntPtr FilterMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) - { - if (_filter != null) - { - handled = _filter.IsTwainMessage(hwnd, msg, wParam, lParam); - } - return IntPtr.Zero; - } - - internal override void Stop() - { - if (_hooker != null) - { - _hooker.RemoveHook(FilterMessage); - // cannot really dispose _hook or the window will also dispose - //_hooker.Dispose(); - _hooker = null; - } - } - } -} diff --git a/src/NTwain/NTwain.csproj b/src/NTwain/NTwain.csproj deleted file mode 100644 index 10d66ac..0000000 --- a/src/NTwain/NTwain.csproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - Release - AnyCPU - 8.0.30703 - 2.0 - {0C5A6FB1-0282-4D61-8354-68DEB1515001} - Library - Properties - NTwain - NTwain - v4.0 - 512 - ..\ - Client - - - true - full - false - bin\Debug\ - TRACE;DEBUG;NET4 - prompt - 4 - false - - - false - AllRules.ruleset - - - pdbonly - true - bin\Release\ - TRACE;NET4 - prompt - 4 - bin\Release\NTwain.xml - false - AllRules.ruleset - - - true - - - Sign.snk - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - - \ No newline at end of file diff --git a/src/NTwain/NTwain.nuspec b/src/NTwain/NTwain.nuspec deleted file mode 100644 index 48fa90e..0000000 --- a/src/NTwain/NTwain.nuspec +++ /dev/null @@ -1,24 +0,0 @@ - - - - $id$ - $version$ - $title$ - $author$ - $author$ - https://bitbucket.org/soukoku/ntwain/src/15de55c6314f14ab2b1cb22f64397d9487c783d0/LICENSE.txt?at=master - https://bitbucket.org/soukoku/ntwain - https://bytebucket.org/soukoku/ntwain/raw/6927ac18780cebbfa33ee7bc4864b9a6777c5fb6/Scanner-Icon.png - false - $description$ - This release supports TWAIN 2.3. - $copyright$ - twain scan - - - - - - - - \ No newline at end of file diff --git a/src/NTwain/PlatformInfo.cs b/src/NTwain/PlatformInfo.cs deleted file mode 100644 index e18880e..0000000 --- a/src/NTwain/PlatformInfo.cs +++ /dev/null @@ -1,247 +0,0 @@ -using NTwain.Internals; -using NTwain.Triplets; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace NTwain -{ - /// - /// Contains various platform requirements and conditions for TWAIN. - /// - public class PlatformInfo : IPlatformInfo - { - static readonly PlatformInfo __global = new PlatformInfo(); - internal static PlatformInfo InternalCurrent { get { return __global; } } - /// - /// Gets the current platform info related to TWAIN. - /// - /// - /// The current info. - /// - public static IPlatformInfo Current { get { return __global; } } - - - PlatformInfo() - { - IsApp64Bit = IntPtr.Size == 8; - - IsOnMono = Type.GetType("Mono.Runtime") != null; - IsWindows = Environment.OSVersion.Platform == PlatformID.Win32NT; - IsLinux = Environment.OSVersion.Platform == PlatformID.Unix; - _defaultLog = new TraceLog(); - if (IsWindows) - { - _defaultMemManager = new WinMemoryManager(); - - // only the new twaindsm can be loaded outside of windows folder, twain_32 can't - newDsmPath = GetFirstFilePathThatExists(Dsm.WIN_NEW_DSM_NAME, - // should be same order as dllimport search order - GetExeFolder(), - AppDomain.CurrentDomain.BaseDirectory, - Environment.SystemDirectory, - GetWindowsFolder(), - Environment.CurrentDirectory) - ?? - Path.Combine(Environment.SystemDirectory, Dsm.WIN_NEW_DSM_NAME); - - oldDsmPath = Path.Combine(GetWindowsFolder(), Dsm.WIN_OLD_DSM_NAME); - - PreferNewDSM = true; - } - else if (IsLinux) - { - _defaultMemManager = new LinuxMemoryManager(); - - ExpectedDsmPath = Dsm.LINUX_DSM_PATH; - DsmExists = File.Exists(ExpectedDsmPath); - IsSupported = DsmExists && IsOnMono; - } - else - { - // mac? not gonna happen - } - } - - private string GetExeFolder() - { - var assembly = Assembly.GetEntryAssembly(); - if (assembly != null) - { - return Path.GetDirectoryName(assembly.Location); - } - return null; - } - private string GetWindowsFolder() - { -#if NET35 - return Environment.GetEnvironmentVariable("windir"); -#else - return Environment.GetFolderPath(Environment.SpecialFolder.Windows); -#endif - } - - static string GetFirstFilePathThatExists(string filename, params string[] folders) - { - return folders.Where(fdr => fdr != null) - .Select(fdr => Path.Combine(fdr, filename)) - .FirstOrDefault(path => File.Exists(path)); - } - - string oldDsmPath; - string newDsmPath; - - private bool _preferNewDSM; - - /// - /// Gets a value indicating whether to prefer using the new DSM on Windows over old twain_32 dsm if applicable. - /// - /// - /// true to prefer new DSM; otherwise, false. - /// - public bool PreferNewDSM - { - get { return _preferNewDSM; } - set - { - if (IsWindows) - { - _preferNewDSM = value; - - if (IsApp64Bit) - { - ExpectedDsmPath = newDsmPath; - IsSupported = DsmExists = File.Exists(ExpectedDsmPath); - UseNewWinDSM = true; - Log.Debug("Using new dsm."); - } - else - { - if (_preferNewDSM && File.Exists(newDsmPath)) - { - ExpectedDsmPath = newDsmPath; - UseNewWinDSM = IsSupported = DsmExists = true; - Log.Debug("Using new dsm."); - } - else - { - ExpectedDsmPath = oldDsmPath; - IsSupported = DsmExists = File.Exists(ExpectedDsmPath); - UseNewWinDSM = false; - Log.Debug("Using old dsm in windows."); - } - } - } - } - } - - - /// - /// Gets a value indicating whether the lib is expecting to use new DSM. - /// - /// - /// true if using the new DSM; otherwise, false. - /// - public bool UseNewWinDSM { get; private set; } - - /// - /// Gets a value indicating whether the current runtime is mono. - /// - /// - /// true if the current runtime is on mono; otherwise, false. - /// - public bool IsOnMono { get; private set; } - - /// - /// Gets a value indicating whether the current OS is windows. - /// - /// - /// true if the current OS is windows; otherwise, false. - /// - public bool IsWindows { get; private set; } - /// - /// Gets a value indicating whether the current OS is linux. - /// - /// - /// true if the current OS is linux; otherwise, false. - /// - public bool IsLinux { get; private set; } - - /// - /// Gets a value indicating whether the application is running in 64-bit. - /// - /// - /// true if the application is 64-bit; otherwise, false. - /// - public bool IsApp64Bit { get; private set; } - - /// - /// Gets a value indicating whether the applicable TWAIN DSM library exists in the operating system. - /// - /// - /// true if the TWAIN DSM; otherwise, false. - /// - public bool DsmExists { get; private set; } - - /// - /// Gets the expected TWAIN DSM dll path. - /// - /// - /// The expected DSM path. - /// - public string ExpectedDsmPath { get; private set; } - - /// - /// Gets a value indicating whether this library is supported on current OS. - /// Check the other platform properties to determine the reason if this is false. - /// - /// - /// true if this library is supported; otherwise, false. - /// - public bool IsSupported { get; private set; } - - - readonly IMemoryManager _defaultMemManager; - IMemoryManager _specifiedMemManager; - - /// - /// Gets the for communicating with data sources. - /// This should only be used when a is open. - /// - /// - /// The memory manager. - /// - public IMemoryManager MemoryManager - { - get - { - return _specifiedMemManager ?? _defaultMemManager; - } - internal set - { - _specifiedMemManager = value; - } - } - - - readonly ILog _defaultLog; - private ILog _log; - - /// - /// Gets or sets the log used by NTwain. - /// - /// - /// The log. - /// - public ILog Log - { - get { return _log ?? _defaultLog; } - set { _log = value; } - } - - } -} diff --git a/src/NTwain/Properties/AssemblyInfo.cs b/src/NTwain/Properties/AssemblyInfo.cs deleted file mode 100644 index cc8dc6d..0000000 --- a/src/NTwain/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("NTwain")] -[assembly: AssemblyDescription("Library containing the TWAIN API for dotnet.")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyProduct("NTwain")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: ComVisible(false)] -[assembly: CLSCompliant(false)] -[assembly: NeutralResourcesLanguage("en", UltimateResourceFallbackLocation.MainAssembly)] - -#if DEBUG -[assembly: InternalsVisibleTo(@"NTwain.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100ad02a9cc0f8ee929ad066a59951057ba3b9f400ff5c176988935ea72d9738003df98d65ccde2c8eecd75fa0414e7816d7475d379ef9b93601ff4d2a8807d61398a19405e0f6a79c7c523fd02c93c2bfaf9b818f43a88542ba22df80811d24260be737d6e303e91aadf4588b23c809494d164728462d6f1292928c8fab7ea06c5")] -#endif \ No newline at end of file diff --git a/src/NTwain/Properties/Resources.Designer.cs b/src/NTwain/Properties/Resources.Designer.cs deleted file mode 100644 index 9ebbf18..0000000 --- a/src/NTwain/Properties/Resources.Designer.cs +++ /dev/null @@ -1,117 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.0 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace NTwain.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NTwain.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Data group for application must contain either Image or Audio.. - /// - internal static string BadDataGroupsForAppId { - get { - return ResourceManager.GetString("BadDataGroupsForAppId", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid value type for {0}.. - /// - internal static string BadValueType { - get { - return ResourceManager.GetString("BadValueType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Capability {0} has invalid container type {1}.. - /// - internal static string CapHasBadContainer { - get { - return ResourceManager.GetString("CapHasBadContainer", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The string value has exceeded the maximum length allowed.. - /// - internal static string MaxStringLengthExceeded { - get { - return ResourceManager.GetString("MaxStringLengthExceeded", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Message loop has not started yet.. - /// - internal static string MsgLoopUnavailble { - get { - return ResourceManager.GetString("MsgLoopUnavailble", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Source name is required.. - /// - internal static string SourceRequired { - get { - return ResourceManager.GetString("SourceRequired", resourceCulture); - } - } - } -} diff --git a/src/NTwain/Properties/Resources.resx b/src/NTwain/Properties/Resources.resx deleted file mode 100644 index 6c9172c..0000000 --- a/src/NTwain/Properties/Resources.resx +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Data group for application must contain either Image or Audio. - - - Invalid value type for {0}. - - - Capability {0} has invalid container type {1}. - - - The string value has exceeded the maximum length allowed. - - - Message loop has not started yet. - - - Source name is required. - - \ No newline at end of file diff --git a/src/NTwain/Properties/VersionInfo.cs b/src/NTwain/Properties/VersionInfo.cs deleted file mode 100644 index d3c0256..0000000 --- a/src/NTwain/Properties/VersionInfo.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Reflection; - -[assembly: AssemblyCopyright("Copyright \x00a9 Yin-Chun Wang 2012-2018")] -[assembly: AssemblyCompany("Yin-Chun Wang")] - -[assembly: AssemblyVersion(NTwain.VersionInfo.Release)] -[assembly: AssemblyFileVersion(NTwain.VersionInfo.Build)] -[assembly: AssemblyInformationalVersion(NTwain.VersionInfo.Build)] - -namespace NTwain -{ - /// - /// Contains version info of NTwain. - /// - static class VersionInfo - { - /// - /// The major release version number. - /// - public const string Release = "3.0.0.0"; // keep this same in major (breaking) releases - - - /// - /// The build release version number. - /// - public const string Build = "3.5.3"; // change this for each nuget release - - - } -} \ No newline at end of file diff --git a/src/NTwain/ProtocolVersions.cs b/src/NTwain/ProtocolVersions.cs deleted file mode 100644 index d39a137..0000000 --- a/src/NTwain/ProtocolVersions.cs +++ /dev/null @@ -1,209 +0,0 @@ -using NTwain.Data; -using System; -using System.Collections.Generic; - -namespace NTwain -{ - /// - /// Contains the minimum TWAIN protocol version for various things. - /// - public static class ProtocolVersions - { - internal static readonly Version v10 = new Version(1, 0); - internal static readonly Version v11 = new Version(1, 1); - internal static readonly Version v15 = new Version(1, 5); - internal static readonly Version v16 = new Version(1, 6); - internal static readonly Version v17 = new Version(1, 7); - internal static readonly Version v18 = new Version(1, 8); - internal static readonly Version v19 = new Version(1, 9); - internal static readonly Version v20 = new Version(2, 0); - internal static readonly Version v21 = new Version(2, 1); - internal static readonly Version v22 = new Version(2, 2); - internal static readonly Version v23 = new Version(2, 3); - - - static readonly Dictionary __capMinVersions = new Dictionary - { - { CapabilityId.ACapXferMech, v18 }, - - { CapabilityId.CapAlarms, v18 }, - { CapabilityId.CapAlarmVolume, v18 }, - { CapabilityId.CapAuthor, v10 }, - { CapabilityId.CapAutoFeed, v10 }, - { CapabilityId.CapAutomaticCapture, v18 }, - { CapabilityId.CapAutomaticSenseMedium, v21 }, - { CapabilityId.CapAutoScan, v16 }, - { CapabilityId.CapBatteryMinutes, v18 }, - { CapabilityId.CapBatteryPercentage, v18 }, - { CapabilityId.CapCameraEnabled, v20 }, - { CapabilityId.CapCameraOrder, v20 }, - { CapabilityId.CapCameraPreviewUI, v18 }, - { CapabilityId.CapCameraSide, v19 }, - { CapabilityId.CapCaption, v10 }, - { CapabilityId.CapClearBuffers, v18 }, - { CapabilityId.CapClearPage, v10 }, - { CapabilityId.CapCustomDSData, v17 }, - { CapabilityId.CapCustomInterfaceGuid, v21 }, - { CapabilityId.CapDeviceEvent, v18 }, - { CapabilityId.CapDeviceOnline, v16 }, - { CapabilityId.CapDeviceTimeDate, v18 }, - { CapabilityId.CapDoubleFeedDetection, v22 }, - { CapabilityId.CapDoubleFeedDetectionLength, v22 }, - { CapabilityId.CapDoubleFeedDetectionResponse, v22 }, - { CapabilityId.CapDoubleFeedDetectionSensitivity, v22 }, - { CapabilityId.CapDuplex, v17 }, - { CapabilityId.CapDuplexEnabled, v17 }, - { CapabilityId.CapEnableDSUIOnly, v17 }, - { CapabilityId.CapEndorser, v17 }, - { CapabilityId.CapExtendedCaps, v10 }, - { CapabilityId.CapFeederAlignment, v18 }, - { CapabilityId.CapFeederEnabled, v10 }, - { CapabilityId.CapFeederLoaded, v10 }, - { CapabilityId.CapFeederOrder, v18 }, - { CapabilityId.CapFeederPocket, v20 }, - { CapabilityId.CapFeederPrep, v20}, - { CapabilityId.CapFeedPage, v10 }, - { CapabilityId.CapIndicators, v11 }, - { CapabilityId.CapIndicatorsMode, v22 }, - { CapabilityId.CapJobControl, v17 }, - { CapabilityId.CapLanguage, v18 }, - { CapabilityId.CapMaxBatchBuffers, v18 }, - { CapabilityId.CapMicrEnabled, v20 }, - { CapabilityId.CapPaperDetectable, v16 }, - { CapabilityId.CapPaperHandling, v22 }, - { CapabilityId.CapPowerSaveTime, v18 }, - { CapabilityId.CapPowerSupply, v18 }, - { CapabilityId.CapPrinter, v18 }, - { CapabilityId.CapPrinterEnabled, v18 }, - { CapabilityId.CapPrinterCharRotation, v23 }, - { CapabilityId.CapPrinterFontStyle, v23 }, - { CapabilityId.CapPrinterIndex, v18 }, - { CapabilityId.CapPrinterIndexLeadChar, v23 }, - { CapabilityId.CapPrinterIndexMaxValue, v23 }, - { CapabilityId.CapPrinterIndexNumDigits, v23 }, - { CapabilityId.CapPrinterIndexStep, v23 }, - { CapabilityId.CapPrinterIndexTrigger, v23 }, - { CapabilityId.CapPrinterMode, v18 }, - { CapabilityId.CapPrinterString, v18 }, - { CapabilityId.CapPrinterStringPreview, v23 }, - { CapabilityId.CapPrinterSuffix, v18 }, - { CapabilityId.CapPrinterVerticalOffset, v22 }, - { CapabilityId.CapReacquireAllowed, v18 }, - { CapabilityId.CapRewindPage, v10 }, - { CapabilityId.CapSegmented, v19 }, - { CapabilityId.CapSerialNumber, v18 }, - { CapabilityId.CapSupportedCaps, v10 }, - { CapabilityId.CapSupportedCapsSegmentUnique, v22 }, - { CapabilityId.CapSupportedDATs, v22 }, - { CapabilityId.CapTimeBeforeFirstCapture, v18 }, - { CapabilityId.CapTimeBetweenCaptures, v18 }, - { CapabilityId.CapTimeDate, v10 }, - { CapabilityId.CapThumbnailsEnabled, v17 }, - { CapabilityId.CapUIControllable, v16 }, - { CapabilityId.CapXferCount, v10 }, - - { CapabilityId.ICapAutoBright, v10 }, - { CapabilityId.ICapAutoDiscardBlankPages, v20 }, - { CapabilityId.ICapAutomaticBorderDetection, v18 }, - { CapabilityId.ICapAutomaticColorEnabled, v21 }, - { CapabilityId.ICapAutomaticColorNonColorPixelType, v18 }, - { CapabilityId.ICapAutomaticCropUsesFrame, v21 }, - { CapabilityId.ICapAutomaticDeskew, v18 }, - { CapabilityId.ICapAutomaticLengthDetection, v21 }, - { CapabilityId.ICapAutomaticRotate, v18 }, - { CapabilityId.ICapAutoSize, v20 }, - { CapabilityId.ICapBarcodeDetectionEnabled, v18 }, - { CapabilityId.ICapBarcodeMaxRetries, v18 }, - { CapabilityId.ICapBarcodeMaxSearchPriorities, v18 }, - { CapabilityId.ICapBarcodeSearchMode, v18 }, - { CapabilityId.ICapBarcodeSearchPriorities, v18 }, - { CapabilityId.ICapBarcodeTimeout, v18 }, - { CapabilityId.ICapBitDepth, v10 }, - { CapabilityId.ICapBitDepthReduction, v15 }, - { CapabilityId.ICapBitOrder, v10 }, - { CapabilityId.ICapBitOrderCodes, v10 }, - { CapabilityId.ICapBrightness, v10 }, - { CapabilityId.ICapCCITTKFactor, v10 }, - { CapabilityId.ICapColorManagementEnabled, v21 }, - { CapabilityId.ICapCompression, v10 }, - { CapabilityId.ICapContrast, v10 }, - { CapabilityId.ICapCustHalftone, v10 }, - { CapabilityId.ICapExposureTime, v10 }, - { CapabilityId.ICapExtImageInfo, v17 }, - { CapabilityId.ICapFeederType, v19 }, - { CapabilityId.ICapFilmType, v22 }, - { CapabilityId.ICapFilter, v10 }, - { CapabilityId.ICapFlashUsed, v16 }, // maybe - { CapabilityId.ICapFlashUsed2, v18 }, - { CapabilityId.ICapFlipRotation, v18 }, - { CapabilityId.ICapFrames, v10 }, - { CapabilityId.ICapGamma, v10 }, - { CapabilityId.ICapHalftones, v10 }, - { CapabilityId.ICapHighlight, v10 }, - { CapabilityId.ICapICCProfile, v19 }, - { CapabilityId.ICapImageDataSet, v17 }, - { CapabilityId.ICapImageFileFormat, v10 }, - { CapabilityId.ICapImageFilter, v18 }, - { CapabilityId.ICapImageMerge, v21 }, - { CapabilityId.ICapImageMergeHeightThreshold, v21 }, - { CapabilityId.ICapJpegPixelType, v10 }, - { CapabilityId.ICapJpegQuality, v19 }, - { CapabilityId.ICapJpegSubsampling, v22 }, - { CapabilityId.ICapLampState, v10 }, - { CapabilityId.ICapLightPath, v10 }, - { CapabilityId.ICapLightSource, v10 }, - { CapabilityId.ICapMaxFrames, v10 }, - { CapabilityId.ICapMinimumHeight, v17 }, - { CapabilityId.ICapMinimumWidth, v17 }, - { CapabilityId.ICapMirror, v22 }, - { CapabilityId.ICapNoiseFilter, v18 }, - { CapabilityId.ICapOrientation, v10 }, - { CapabilityId.ICapOverScan, v18 }, - { CapabilityId.ICapPatchCodeDetectionEnabled, v18 }, - { CapabilityId.ICapPatchCodeMaxRetries, v18 }, - { CapabilityId.ICapPatchCodeMaxSearchPriorities, v18 }, - { CapabilityId.ICapPatchCodeSearchMode, v18 }, - { CapabilityId.ICapPatchCodeSearchPriorities, v18 }, - { CapabilityId.ICapPatchCodeTimeout, v18 }, - { CapabilityId.ICapPhysicalHeight, v10 }, - { CapabilityId.ICapPhysicalWidth, v10 }, - { CapabilityId.ICapPixelFlavor, v10 }, - { CapabilityId.ICapPixelFlavorCodes, v10 }, - { CapabilityId.ICapPixelType, v10 }, - { CapabilityId.ICapPlanarChunky, v10 }, - { CapabilityId.ICapRotation, v10 }, - { CapabilityId.ICapShadow, v10 }, - { CapabilityId.ICapSupportedBarcodeTypes, v18 }, - { CapabilityId.ICapSupportedExtImageInfo, v21 }, - { CapabilityId.ICapSupportedPatchCodeTypes, v18 }, - { CapabilityId.ICapSupportedSizes, v10 }, - { CapabilityId.ICapThreshold, v10 }, - { CapabilityId.ICapTiles, v10 }, - { CapabilityId.ICapTimeFill, v10 }, - { CapabilityId.ICapUndefinedImageSize, v16 }, - { CapabilityId.ICapUnits, v10 }, - { CapabilityId.ICapXferMech, v10 }, - { CapabilityId.ICapXNativeResolution, v10 }, - { CapabilityId.ICapXResolution, v10 }, - { CapabilityId.ICapXScaling, v10 }, - { CapabilityId.ICapYNativeResolution, v10 }, - { CapabilityId.ICapYResolution, v10 }, - { CapabilityId.ICapYScaling, v10 }, - { CapabilityId.ICapZoomFactor, v18 }, - }; - - /// - /// Gets the minimum TWAIN protocol version for a capability. - /// - /// The capability type. - /// - public static Version GetMinimumVersion(CapabilityId id) - { - if (__capMinVersions.ContainsKey(id)) - { - return __capMinVersions[id]; - } - return v10; - } - } -} diff --git a/src/NTwain/Sign.snk b/src/NTwain/Sign.snk deleted file mode 100644 index d65a7a6..0000000 Binary files a/src/NTwain/Sign.snk and /dev/null differ diff --git a/src/NTwain/SourceEnableMode.cs b/src/NTwain/SourceEnableMode.cs deleted file mode 100644 index 00db080..0000000 --- a/src/NTwain/SourceEnableMode.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace NTwain -{ - /// - /// Indicates how the source should be enabled in a TWAIN session. - /// - public enum SourceEnableMode - { - /// - /// Start acquiring without driver UI. - /// - NoUI, - /// - /// Start acquiring with driver UI. - /// - ShowUI, - /// - /// Show driver UI for settings change but no acquisition. - /// - ShowUIOnly - } -} diff --git a/src/NTwain/State.cs b/src/NTwain/State.cs deleted file mode 100644 index fdc65a0..0000000 --- a/src/NTwain/State.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NTwain -{ - /// - /// The logical state of a TWAIN session. - /// - public enum State - { - /// - /// Just a default value. - /// - Invalid = 0, - /// - /// The starting state, corresponds to state 1. - /// - DsmUnloaded = 1, - /// - /// The DSM library has been loaded, corresponds to state 2. - /// - DsmLoaded = 2, - /// - /// The DSM has been opened, corresponds to state 3. - /// - DsmOpened = 3, - /// - /// A data source has been opened, corresponds to state 4. - /// - SourceOpened = 4, - /// - /// A data source has been enabled, corresponds to state 5. - /// - SourceEnabled = 5, - /// - /// Data is ready for transfer from the source, corresponds to state 6. - /// - TransferReady = 6, - /// - /// Data is being transferred, corresponds to state 7. - /// - Transferring = 7 - }; - -} diff --git a/src/NTwain/TransferErrorEventArgs.cs b/src/NTwain/TransferErrorEventArgs.cs deleted file mode 100644 index 2ad4434..0000000 --- a/src/NTwain/TransferErrorEventArgs.cs +++ /dev/null @@ -1,55 +0,0 @@ -using NTwain.Data; -using System; - -namespace NTwain -{ - /// - /// Contains TWAIN codes and source status when an error is encountered during transfer. - /// - public class TransferErrorEventArgs : EventArgs - { - /// - /// Initializes a new instance of the class. - /// - /// The error. - public TransferErrorEventArgs(Exception error) - { - Exception = error; - } - - /// - /// Initializes a new instance of the class. - /// - /// The code. - /// The status. - public TransferErrorEventArgs(ReturnCode code, TWStatus status) - { - ReturnCode = code; - SourceStatus = status; - } - - /// - /// Gets the return code from the transfer. - /// - /// - /// The return code. - /// - public ReturnCode ReturnCode { get; private set; } - - /// - /// Gets the source status. - /// - /// - /// The source status. - /// - public TWStatus SourceStatus { get; private set; } - - /// - /// Gets the exception if the error is from some exception. - /// - /// - /// The exception. - /// - public Exception Exception { get; private set; } - } -} diff --git a/src/NTwain/TransferReadyEventArgs.cs b/src/NTwain/TransferReadyEventArgs.cs deleted file mode 100644 index 1059371..0000000 --- a/src/NTwain/TransferReadyEventArgs.cs +++ /dev/null @@ -1,112 +0,0 @@ -using NTwain.Data; -using System; - -namespace NTwain -{ - /// - /// Contains event data when a data transfer is ready to be processed. - /// - public class TransferReadyEventArgs : EventArgs - { - /// - /// Initializes a new instance of the class. - /// - /// The source. - /// The pending count. - /// - public TransferReadyEventArgs(DataSource source, int pendingCount, EndXferJob endOfJobFlag) - { - DataSource = source; - PendingTransferCount = pendingCount; - EndOfJobFlag = endOfJobFlag; - } - - /// - /// Gets the data source. - /// - /// - /// The data source. - /// - public DataSource DataSource { get; private set; } - - /// - /// Gets or sets a value indicating whether the current transfer should be canceled - /// and continue next transfer if there are more data. - /// - /// true to cancel current transfer; otherwise, false. - public bool CancelCurrent { get; set; } - - /// - /// Gets or sets a value indicating whether all transfers should be canceled. - /// - /// true to cancel all transfers; otherwise, false. - public bool CancelAll { get; set; } - - /// - /// Gets a value indicating whether current transfer signifies an end of job in TWAIN world. - /// - /// true if transfer is end of job; otherwise, false. - public bool EndOfJob { get { return EndOfJobFlag != EndXferJob.None; } } - - /// - /// Gets the end of job flag value for this transfer (if job control is enabled). - /// - /// - /// The end of job flag. - /// - public EndXferJob EndOfJobFlag { get; private set; } - - /// - /// Gets the known pending transfer count. This may not be appilicable - /// for certain scanning modes. - /// - /// The pending count. - public int PendingTransferCount { get; private set; } - - TWImageInfo _imgInfo; - /// - /// Gets the tentative image information for the current transfer if applicable. - /// This may differ from the final image depending on the transfer mode used (mostly when doing mem xfer). - /// - /// - /// The image info. - /// - public TWImageInfo PendingImageInfo - { - get - { - if (_imgInfo == null) - { - if (DataSource.DGImage.ImageInfo.Get(out _imgInfo) != ReturnCode.Success) - { - _imgInfo = null; - } - } - return _imgInfo; - } - } - - TWAudioInfo _audInfo; - /// - /// Gets the audio information for the current transfer if applicable. - /// - /// - /// The audio information. - /// - public TWAudioInfo AudioInfo - { - get - { - if (_audInfo == null) - { - if (DataSource.DGAudio.AudioInfo.Get(out _audInfo) != ReturnCode.Success) - { - _audInfo = null; - } - } - return _audInfo; - } - } - - } -} diff --git a/src/NTwain/Triplets/DGAudio/DGAudio.AudioFileXfer.cs b/src/NTwain/Triplets/DGAudio/DGAudio.AudioFileXfer.cs deleted file mode 100644 index b594cf4..0000000 --- a/src/NTwain/Triplets/DGAudio/DGAudio.AudioFileXfer.cs +++ /dev/null @@ -1,25 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; -using System; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - sealed class AudioFileXfer : TripletBase - { - internal AudioFileXfer(ITwainSessionInternal session) : base(session) { } - /// - /// This operation is used to initiate the transfer of audio from the Source to the application via the - /// disk-file transfer mechanism. It causes the transfer to begin. - /// - /// - public ReturnCode Get() - { - Session.VerifyState(6, 6, DataGroups.Audio, DataArgumentType.AudioFileXfer, Message.Get); - IntPtr z = IntPtr.Zero; - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataGroups.Audio, DataArgumentType.AudioFileXfer, Message.Get, ref z); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGAudio/DGAudio.AudioInfo.cs b/src/NTwain/Triplets/DGAudio/DGAudio.AudioInfo.cs deleted file mode 100644 index fcb1c7f..0000000 --- a/src/NTwain/Triplets/DGAudio/DGAudio.AudioInfo.cs +++ /dev/null @@ -1,25 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - sealed class AudioInfo : TripletBase - { - internal AudioInfo(ITwainSessionInternal session) : base(session) { } - - /// - /// Used to get the information of the current audio data ready to transfer. - /// - /// The info. - /// - public ReturnCode Get(out TWAudioInfo info) - { - Session.VerifyState(6, 7, DataGroups.Audio, DataArgumentType.AudioInfo, Message.Get); - info = new TWAudioInfo(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, info); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGAudio/DGAudio.AudioNativeXfer.cs b/src/NTwain/Triplets/DGAudio/DGAudio.AudioNativeXfer.cs deleted file mode 100644 index e562343..0000000 --- a/src/NTwain/Triplets/DGAudio/DGAudio.AudioNativeXfer.cs +++ /dev/null @@ -1,28 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; -using System; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - sealed class AudioNativeXfer : TripletBase - { - internal AudioNativeXfer(ITwainSessionInternal session) : base(session) { } - /// - /// Causes the transfer of an audio data from the Source to the application, via the Native - /// transfer mechanism, to begin. The resulting data is stored in main memory in a single block. - /// The data is stored in AIFF format on the Macintosh and as a WAV format under Microsoft - /// Windows. The size of the audio snippet that can be transferred is limited to the size of the - /// memory block that can be allocated by the Source. - /// - /// The handle. - /// - public ReturnCode Get(ref IntPtr handle) - { - Session.VerifyState(6, 6, DataGroups.Audio, DataArgumentType.AudioNativeXfer, Message.Get); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataGroups.Audio, DataArgumentType.AudioNativeXfer, Message.Get, ref handle); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGAudio/DGAudio.cs b/src/NTwain/Triplets/DGAudio/DGAudio.cs deleted file mode 100644 index a644eda..0000000 --- a/src/NTwain/Triplets/DGAudio/DGAudio.cs +++ /dev/null @@ -1,49 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; -using System; -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - sealed class DGAudio - { - ITwainSessionInternal _session; - internal DGAudio(ITwainSessionInternal session) - { - if (session == null) { throw new ArgumentNullException("session"); } - _session = session; - } - - - AudioFileXfer _audioFileXfer; - internal AudioFileXfer AudioFileXfer - { - get - { - if (_audioFileXfer == null) { _audioFileXfer = new AudioFileXfer(_session); } - return _audioFileXfer; - } - } - - AudioInfo _audioInfo; - internal AudioInfo AudioInfo - { - get - { - if (_audioInfo == null) { _audioInfo = new AudioInfo(_session); } - return _audioInfo; - } - } - - AudioNativeXfer _audioNativeXfer; - internal AudioNativeXfer AudioNativeXfer - { - get - { - if (_audioNativeXfer == null) { _audioNativeXfer = new AudioNativeXfer(_session); } - return _audioNativeXfer; - } - } - } -} diff --git a/src/NTwain/Triplets/DGControl/DGControl.Callback.cs b/src/NTwain/Triplets/DGControl/DGControl.Callback.cs deleted file mode 100644 index c89d4b1..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.Callback.cs +++ /dev/null @@ -1,22 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - sealed class Callback : TripletBase - { - internal Callback(ITwainSessionInternal session) : base(session) { } - /// - /// This triplet is sent to the DSM by the Application to register the application’s entry point with - /// the DSM, so that the DSM can use callbacks to inform the application of events generated by the - /// DS. - /// - /// The callback. - /// - public ReturnCode RegisterCallback(TWCallback callback) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Callback, Message.RegisterCallback); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.RegisterCallback, callback); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.Callback2.cs b/src/NTwain/Triplets/DGControl/DGControl.Callback2.cs deleted file mode 100644 index 8b62f44..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.Callback2.cs +++ /dev/null @@ -1,22 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - sealed class Callback2 : TripletBase - { - internal Callback2(ITwainSessionInternal session) : base(session) { } - /// - /// This triplet is sent to the DSM by the Application to register the application’s entry point with - /// the DSM, so that the DSM can use callbacks to inform the application of events generated by the - /// DS. - /// - /// The callback. - /// - public ReturnCode RegisterCallback(TWCallback2 callback) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Callback, Message.RegisterCallback); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.RegisterCallback, callback); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.Capability.cs b/src/NTwain/Triplets/DGControl/DGControl.Capability.cs deleted file mode 100644 index 555b9fd..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.Capability.cs +++ /dev/null @@ -1,145 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - public sealed class Capability : TripletBase - { - internal Capability(ITwainSessionInternal session) : base(session) { } - /// - /// Returns the Source’s Current, Default and Available Values for a specified capability. - /// - /// The capability. - /// - public ReturnCode Get(TWCapability capability) - { - Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.Get); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataArgumentType.Capability, Message.Get, capability); - } - - /// - /// Returns the Source’s Current Value for the specified capability. - /// - /// The capability. - /// - public ReturnCode GetCurrent(TWCapability capability) - { - Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.GetCurrent); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataArgumentType.Capability, Message.GetCurrent, capability); - } - - /// - /// Returns the Source’s Default Value. This is the Source’s preferred default value. - /// - /// The capability. - /// - public ReturnCode GetDefault(TWCapability capability) - { - Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.GetDefault); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataArgumentType.Capability, Message.GetDefault, capability); - } - - /// - /// Returns help text suitable for use in a GUI; for instance: "Specify the amount of detail in an - /// image. Higher values result in more detail." for ICapXRESOLUTION. - /// - /// The capability. - /// - public ReturnCode GetHelp(TWCapability capability) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.GetHelp); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataArgumentType.Capability, Message.GetHelp, capability); - } - - /// - /// Returns a label suitable for use in a GUI, for instance "Resolution:" - /// for ICapXRESOLUTION. - /// - /// The capability. - /// - public ReturnCode GetLabel(TWCapability capability) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.GetLabel); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataArgumentType.Capability, Message.GetLabel, capability); - } - - /// - /// Return all of the labels for a capability of type or , for example - /// "US Letter" for ICapSupportedSizes’ TWSS_USLETTER. - /// - /// The capability. - /// - public ReturnCode GetLabelEnum(TWCapability capability) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.GetLabelEnum); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataArgumentType.Capability, Message.GetLabelEnum, capability); - } - - /// - /// Returns the Source’s support status of this capability. - /// - /// The capability. - /// - public ReturnCode QuerySupport(TWCapability capability) - { - Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.QuerySupport); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataArgumentType.Capability, Message.QuerySupport, capability); - } - - /// - /// Change the Current Value of the specified capability back to its power-on value and return the - /// new Current Value. - /// - /// The capability. - /// - public ReturnCode Reset(TWCapability capability) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.Reset); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataArgumentType.Capability, Message.Reset, capability); - } - - /// - /// This command resets all of the current values and constraints to their defaults for all of the - /// negotiable capabilities supported by the driver. - /// - /// The capability. - /// - public ReturnCode ResetAll(TWCapability capability) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.ResetAll); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataArgumentType.Capability, Message.ResetAll, capability); - } - - /// - /// Changes the Current Value(s) and Available Values of the specified capability to those specified - /// by the application. As of TWAIN 2.2 this only modifies the Current Value of the specified capability, constraints cannot be - /// changed with this. - /// Current Values are set when the container is a or . Available and - /// Current Values are set when the container is a or . - /// - /// The capability. - /// - public ReturnCode Set(TWCapability capability) - { - Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.Capability, Message.Set); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataArgumentType.Capability, Message.Set, capability); - } - - /// - /// Changes the Current Value(s) and Available Value(s) of the specified capability to those specified - /// by the application. - /// - /// Current Values are set when the container is a or . Available and - /// Current Values are set when the container is a or . - /// The capability. - /// - public ReturnCode SetConstraint(TWCapability capability) - { - Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.SetConstraint); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataArgumentType.Capability, Message.SetConstraint, capability); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.CapabilityCustom.cs b/src/NTwain/Triplets/DGControl/DGControl.CapabilityCustom.cs deleted file mode 100644 index a1f33ff..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.CapabilityCustom.cs +++ /dev/null @@ -1,168 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// This is to support custom DAT value for custom capability defined by some manufacturers. - /// - public sealed class CapabilityCustom : TripletBase - { - internal CapabilityCustom(ITwainSessionInternal session) : base(session) { } - - /// - /// Returns the Source’s Current, Default and Available Values for a specified capability. - /// - /// The custom DAT_* value from manufacturer. - /// The capability. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "DAT")] - public ReturnCode Get(ushort customDAT, TWCapability capability) - { - Session.VerifyState(4, 7, DataGroups.Control, (DataArgumentType)customDAT, Message.Get); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, (DataArgumentType)customDAT, Message.Get, capability); - } - - /// - /// Returns the Source’s Current Value for the specified capability. - /// - /// The custom DAT_* value from manufacturer. - /// The capability. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "DAT")] - public ReturnCode GetCurrent(ushort customDAT, TWCapability capability) - { - Session.VerifyState(4, 7, DataGroups.Control, (DataArgumentType)customDAT, Message.GetCurrent); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, (DataArgumentType)customDAT, Message.GetCurrent, capability); - } - - /// - /// Returns the Source’s Default Value. This is the Source’s preferred default value. - /// - /// The custom DAT_* value from manufacturer. - /// The capability. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "DAT")] - public ReturnCode GetDefault(ushort customDAT, TWCapability capability) - { - Session.VerifyState(4, 7, DataGroups.Control, (DataArgumentType)customDAT, Message.GetDefault); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, (DataArgumentType)customDAT, Message.GetDefault, capability); - } - - /// - /// Returns help text suitable for use in a GUI; for instance: "Specify the amount of detail in an - /// image. Higher values result in more detail." for ICapXRESOLUTION. - /// - /// The custom DAT_* value from manufacturer. - /// The capability. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "DAT")] - public ReturnCode GetHelp(ushort customDAT, TWCapability capability) - { - Session.VerifyState(4, 4, DataGroups.Control, (DataArgumentType)customDAT, Message.GetHelp); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, (DataArgumentType)customDAT, Message.GetHelp, capability); - } - - /// - /// Returns a label suitable for use in a GUI, for instance "Resolution:" - /// for ICapXRESOLUTION. - /// - /// The custom DAT_* value from manufacturer. - /// The capability. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "DAT")] - public ReturnCode GetLabel(ushort customDAT, TWCapability capability) - { - Session.VerifyState(4, 4, DataGroups.Control, (DataArgumentType)customDAT, Message.GetLabel); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, (DataArgumentType)customDAT, Message.GetLabel, capability); - } - - /// - /// Return all of the labels for a capability of type or , for example - /// "US Letter" for ICapSupportedSizes’ TWSS_USLETTER. - /// - /// The custom DAT_* value from manufacturer. - /// The capability. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "DAT")] - public ReturnCode GetLabelEnum(ushort customDAT, TWCapability capability) - { - Session.VerifyState(4, 4, DataGroups.Control, (DataArgumentType)customDAT, Message.GetLabelEnum); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, (DataArgumentType)customDAT, Message.GetLabelEnum, capability); - } - - /// - /// Returns the Source’s support status of this capability. - /// - /// The custom DAT_* value from manufacturer. - /// The capability. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "DAT")] - public ReturnCode QuerySupport(ushort customDAT, TWCapability capability) - { - Session.VerifyState(4, 7, DataGroups.Control, (DataArgumentType)customDAT, Message.QuerySupport); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, (DataArgumentType)customDAT, Message.QuerySupport, capability); - } - - /// - /// Change the Current Value of the specified capability back to its power-on value and return the - /// new Current Value. - /// - /// The custom DAT_* value from manufacturer. - /// The capability. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "DAT")] - public ReturnCode Reset(ushort customDAT, TWCapability capability) - { - Session.VerifyState(4, 4, DataGroups.Control, (DataArgumentType)customDAT, Message.Reset); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, (DataArgumentType)customDAT, Message.Reset, capability); - } - - /// - /// This command resets all of the current values and constraints to their defaults for all of the - /// negotiable capabilities supported by the driver. - /// - /// The custom DAT_* value from manufacturer. - /// The capability. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "DAT")] - public ReturnCode ResetAll(ushort customDAT, TWCapability capability) - { - Session.VerifyState(4, 4, DataGroups.Control, (DataArgumentType)customDAT, Message.ResetAll); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, (DataArgumentType)customDAT, Message.ResetAll, capability); - } - - /// - /// Changes the Current Value(s) and Available Values of the specified capability to those specified - /// by the application. As of TWAIN 2.2 this only modifies the Current Value of the specified capability, constraints cannot be - /// changed with this. - /// Current Values are set when the container is a or . Available and - /// Current Values are set when the container is a or . - /// - /// The custom DAT_* value from manufacturer. - /// The capability. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "DAT")] - public ReturnCode Set(ushort customDAT, TWCapability capability) - { - Session.VerifyState(4, 6, DataGroups.Control, (DataArgumentType)customDAT, Message.Set); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, (DataArgumentType)customDAT, Message.Set, capability); - } - - /// - /// Changes the Current Value(s) and Available Value(s) of the specified capability to those specified - /// by the application. - /// - /// Current Values are set when the container is a or . Available and - /// Current Values are set when the container is a or . - /// The custom DAT_* value from manufacturer. - /// The capability. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "DAT")] - public ReturnCode SetConstraint(ushort customDAT, TWCapability capability) - { - Session.VerifyState(4, 7, DataGroups.Control, (DataArgumentType)customDAT, Message.SetConstraint); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, (DataArgumentType)customDAT, Message.SetConstraint, capability); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.CustomDSData.cs b/src/NTwain/Triplets/DGControl/DGControl.CustomDSData.cs deleted file mode 100644 index a5470c3..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.CustomDSData.cs +++ /dev/null @@ -1,39 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - sealed class CustomDSData : TripletBase - { - internal CustomDSData(ITwainSessionInternal session) : base(session) { } - /// - /// This operation is used by the application to query the data source for its current settings, e.g. - /// DPI, paper size, color format. The actual format of the data is data source dependent and not - /// defined by TWAIN. - /// - /// The custom data. - /// - public ReturnCode Get(out TWCustomDSData customData) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.CustomDSData, Message.Get); - customData = new TWCustomDSData(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, customData); - } - - /// - /// This operation is used by the application to set the current settings for a data source to a - /// previous state as defined by the data contained in the customData data structure. The actual - /// format of the data is data source dependent and not defined by TWAIN. - /// - /// The custom data. - /// - public ReturnCode Set(TWCustomDSData customData) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.CustomDSData, Message.Set); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Set, customData); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.DeviceEvent.cs b/src/NTwain/Triplets/DGControl/DGControl.DeviceEvent.cs deleted file mode 100644 index 1c2c070..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.DeviceEvent.cs +++ /dev/null @@ -1,20 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - sealed class DeviceEvent : TripletBase - { - internal DeviceEvent(ITwainSessionInternal session) : base(session) { } - - public ReturnCode Get(out TWDeviceEvent sourceDeviceEvent) - { - Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.DeviceEvent, Message.Get); - sourceDeviceEvent = new TWDeviceEvent(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, sourceDeviceEvent); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.EntryPoint.cs b/src/NTwain/Triplets/DGControl/DGControl.EntryPoint.cs deleted file mode 100644 index 101a8e1..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.EntryPoint.cs +++ /dev/null @@ -1,24 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - sealed class EntryPoint : TripletBase - { - internal EntryPoint(ITwainSessionInternal session) : base(session) { } - /// - /// Gets the function entry points for twain 2.0 or higher. - /// - /// The entry point. - /// - public ReturnCode Get(out TWEntryPoint entryPoint) - { - Session.VerifyState(3, 3, DataGroups.Control, DataArgumentType.EntryPoint, Message.Get); - entryPoint = new TWEntryPoint(); - return Dsm.DsmEntry(Session.AppId, Message.Get, entryPoint); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.Event.cs b/src/NTwain/Triplets/DGControl/DGControl.Event.cs deleted file mode 100644 index 1096c3d..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.Event.cs +++ /dev/null @@ -1,28 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - sealed class Event : TripletBase - { - internal Event(ITwainSessionInternal session) : base(session) { } - - /// - /// This operation supports the distribution of events from the application to Sources so that the - /// Source can maintain its user interface and return messages to the application. Once the - /// application has enabled the Source, it must immediately begin sending to the Source all events - /// that enter the application’s main event loop. This allows the Source to update its user interface - /// in real-time and to return messages to the application which cause state transitions. Even if the - /// application overrides the Source’s user interface, it must forward all events once the Source has - /// been enabled. The Source will tell the application whether or not each event belongs to the - /// Source. - /// - /// The event. - /// - public ReturnCode ProcessEvent(TWEvent theEvent) - { - Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Event, Message.ProcessEvent); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.ProcessEvent, theEvent); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.FileSystem.cs b/src/NTwain/Triplets/DGControl/DGControl.FileSystem.cs deleted file mode 100644 index a454e7e..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.FileSystem.cs +++ /dev/null @@ -1,161 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - public sealed class FileSystem : TripletBase - { - internal FileSystem(ITwainSessionInternal session) : base(session) { } - /// - /// This operation selects the destination directory within the Source (camera, storage, etc), where - /// images captured using CapAutomaticCapture will be stored. This command only selects - /// the destination directory (a file of type Directory). The directory must exist and be - /// accessible to the Source. The creation of images within the directory is at the discretion of the - /// Source, and may result in the creation of additional sub-directories. - /// - /// The file system. - /// - public ReturnCode AutomaticCaptureDirectory(TWFileSystem fileSystem) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.AutomaticCaptureDirectory); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.AutomaticCaptureDirectory, fileSystem); - } - - /// - /// This operation selects the current device within the Source (camera, storage, etc). If the device is - /// a , then this command enters a directory that can contain files. If the - /// device is a , then this command enters a directory that can contain - /// files. If the device is a , then this command enters a - /// directory that can contain or files. - /// - /// The file system. - /// - public ReturnCode ChangeDirectory(TWFileSystem fileSystem) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.ChangeDirectory); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.ChangeDirectory, fileSystem); - } - - /// - /// This operation copies a file or directory. Absolute and relative pathnames are supported. A file - /// may not be overwritten with this command. If an Application wishes to do this, it must first - /// delete the unwanted file and then reissue the Copy command. - /// The Application specifies the path and name of the entry to be copied in InputName. The - /// Application specifies the new patch and name in OutputName. - /// It is not permitted to copy files into the root directory. - /// - /// The file system. - /// - public ReturnCode Copy(TWFileSystem fileSystem) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.Copy); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Copy, fileSystem); - } - - /// - /// This operation creates a new directory within the current directory. Pathnames are not allowed, - /// only the name of the new directory can be specified. - /// - /// The file system. - /// - public ReturnCode CreateDirectory(TWFileSystem fileSystem) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.CreateDirectory); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.CreateDirectory, fileSystem); - } - - /// - /// This operation deletes a file or directory on the device. Pathnames are not allowed, only the - /// name of the file or directory to be deleted can be specified. Recursive deletion can be specified - /// by setting the Recursive to TRUE. - /// - /// The file system. - /// - public ReturnCode Delete(TWFileSystem fileSystem) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.Delete); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Delete, fileSystem); - } - - /// - /// This operation formats the specified storage. This operation destroys all images and subdirectories - /// under the selected device. Use with caution. - /// - /// The file system. - /// - public ReturnCode FormatMedia(TWFileSystem fileSystem) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.FormatMedia); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.FormatMedia, fileSystem); - } - - /// - /// The operation frees the Context field in fileSystem. - /// Every call to GetFirstFile must be matched by - /// a call to GetClose to release the Context field. - /// - /// The file system. - /// - public ReturnCode GetClose(TWFileSystem fileSystem) - { - Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.FileSystem, Message.GetClose); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.GetClose, fileSystem); - } - - /// - /// This operation gets the first filename in a directory, and returns information about that file (the - /// same information that can be retrieved with GetInfo). - /// - /// The file system. - /// - public ReturnCode GetFirstFile(TWFileSystem fileSystem) - { - Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.FileSystem, Message.GetFirstFile); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.GetFirstFile, fileSystem); - } - - /// - /// This operation fills the information fields in fileSystem. - /// InputName contains the absolute or relative path and filename of the requested file. - /// OutputName returns the absolute path to the file. - /// - /// The file system. - /// - public ReturnCode GetInfo(TWFileSystem fileSystem) - { - Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.FileSystem, Message.GetInfo); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.GetInfo, fileSystem); - } - - /// - /// This operation gets the next filename in a directory, and returns information about that file (the - /// same information that can be retrieved with GetInfo). - /// - /// The file system. - /// - public ReturnCode GetNextFile(TWFileSystem fileSystem) - { - Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.FileSystem, Message.GetNextFile); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.GetNextFile, fileSystem); - } - - /// - /// This operation renames (and optionally moves) a file or directory. Absolute and relative path - /// names are supported. A file may not be overwritten with this command. If an Application - /// wishes to do this it must first delete the unwanted file, then issue the rename command. - /// The Application specifies the path and name of the entry to be renamed in InputName. The - /// Application specifies the new path and name in OutputName. - /// Filenames in the root directory cannot be moved or renamed. - /// - /// The file system. - /// - public ReturnCode Rename(TWFileSystem fileSystem) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.Rename); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Rename, fileSystem); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.Identity.cs b/src/NTwain/Triplets/DGControl/DGControl.Identity.cs deleted file mode 100644 index 5b667ff..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.Identity.cs +++ /dev/null @@ -1,115 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - sealed class Identity : TripletBase - { - internal Identity(ITwainSessionInternal session) : base(session) { } - - /// - /// When an application is finished with a Source, it must formally close the session between them - /// using this operation. This is necessary in case the Source only supports connection with a single - /// application (many desktop scanners will behave this way). A Source such as this cannot be - /// accessed by other applications until its current session is terminated. - /// - /// - public ReturnCode CloseDS() - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Identity, Message.CloseDS); - var rc = Dsm.DsmEntry(Session.AppId, Message.CloseDS, Session.CurrentSource.Identity); - if (rc == ReturnCode.Success) - { - Session.ChangeCurrentSource(null); - Session.ChangeState(3, true); - } - return rc; - } - - /// - /// Gets the identification information of the system default Source. - /// - /// The source. - /// - public ReturnCode GetDefault(out TWIdentity source) - { - Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.Identity, Message.GetDefault); - source = new TWIdentity(); - return Dsm.DsmEntry(Session.AppId, Message.GetDefault, source); - } - - - /// - /// The application may obtain the first Source that are currently available on the system which - /// match the application’s supported groups. - /// - /// The source. - /// - public ReturnCode GetFirst(out TWIdentity source) - { - Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.Identity, Message.GetFirst); - source = new TWIdentity(); - return Dsm.DsmEntry(Session.AppId, Message.GetFirst, source); - } - - /// - /// The application may obtain the next Source that are currently available on the system which - /// match the application’s supported groups. - /// - /// The source. - /// - public ReturnCode GetNext(out TWIdentity source) - { - Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.Identity, Message.GetNext); - source = new TWIdentity(); - return Dsm.DsmEntry(Session.AppId, Message.GetNext, source); - } - - /// - /// Loads the specified Source into main memory and causes its initialization. - /// - /// The source. - /// - public ReturnCode OpenDS(DataSource source) - { - Session.VerifyState(3, 3, DataGroups.Control, DataArgumentType.Identity, Message.OpenDS); - var rc = Dsm.DsmEntry(Session.AppId, Message.OpenDS, source.Identity); - if (rc == ReturnCode.Success) - { - Session.ChangeCurrentSource(source); - Session.ChangeState(4, true); - } - return rc; - } - - - /// - /// It allows an application to set the - /// default TWAIN driver, which is reported back by GetDefault. - /// - /// The source. - /// - public ReturnCode Set(TWIdentity source) - { - Session.VerifyState(3, 3, DataGroups.Control, DataArgumentType.Identity, Message.Set); - return Dsm.DsmEntry(Session.AppId, Message.Set, source); - } - - /// - /// This operation should be invoked when the user chooses Select Source... from the application’s - /// File menu (or an equivalent user action). The Source selected becomes the system default Source. - /// - /// The source. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode UserSelect(out TWIdentity source) - { - Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.Identity, Message.UserSelect); - source = new TWIdentity(); - return Dsm.DsmEntry(Session.AppId, Message.UserSelect, source); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.Parent.cs b/src/NTwain/Triplets/DGControl/DGControl.Parent.cs deleted file mode 100644 index 2944739..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.Parent.cs +++ /dev/null @@ -1,51 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; -using System; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - sealed class Parent : TripletBase - { - internal Parent(ITwainSessionInternal session) : base(session) { } - - /// - /// When the application has closed all the Sources it had previously opened, and is finished with - /// the Source Manager (the application plans to initiate no other TWAIN sessions), it must close - /// the Source Manager. - /// - /// The handle. On Windows = points to the window handle (hWnd) that will act as the Source’s - /// "parent". On Macintosh = should be a NULL value. - /// - public ReturnCode CloseDsm(IntPtr handle) - { - Session.VerifyState(3, 3, DataGroups.Control, DataArgumentType.Parent, Message.CloseDSM); - var rc = Dsm.DsmEntry(Session.AppId, null, DataGroups.Control, DataArgumentType.Parent, Message.CloseDSM, ref handle); - if (rc == ReturnCode.Success) - { - Session.ChangeState(2, true); - } - return rc; - } - - /// - /// Causes the Source Manager to initialize itself. This operation must be executed before any other - /// operations will be accepted by the Source Manager. - /// - /// The handle. On Windows = points to the window handle (hWnd) that will act as the Source’s - /// "parent". On Macintosh = should be a NULL value. - /// - public ReturnCode OpenDsm(IntPtr handle) - { - Session.VerifyState(1, 2, DataGroups.Control, DataArgumentType.Parent, Message.OpenDSM); - var rc = Dsm.DsmEntry(Session.AppId, null, DataGroups.Control, DataArgumentType.Parent, Message.OpenDSM, ref handle); - if (rc == ReturnCode.Success) - { - Session.ChangeState(3, true); - } - return rc; - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.PassThru.cs b/src/NTwain/Triplets/DGControl/DGControl.PassThru.cs deleted file mode 100644 index 5075f34..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.PassThru.cs +++ /dev/null @@ -1,24 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - public sealed class PassThru : TripletBase - { - internal PassThru(ITwainSessionInternal session) : base(session) { } - /// - /// PASSTHRU is intended for the use of Source writers writing diagnostic applications. It allows - /// raw communication with the currently selected device in the Source. - /// - /// The source pass thru. - /// - public ReturnCode PassThrough(TWPassThru sourcePassThru) - { - Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.PassThru, Message.PassThru); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.PassThru, sourcePassThru); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.PendingXfers.cs b/src/NTwain/Triplets/DGControl/DGControl.PendingXfers.cs deleted file mode 100644 index 2590823..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.PendingXfers.cs +++ /dev/null @@ -1,63 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - sealed class PendingXfers : TripletBase - { - internal PendingXfers(ITwainSessionInternal session) : base(session) { } - /// - /// This triplet is used to cancel or terminate a transfer. Issued in state 6, this triplet cancels the next - /// pending transfer, discards the transfer data, and decrements the pending transfers count. In - /// state 7, this triplet terminates the current transfer. If any data has not been transferred (this is - /// only possible during a memory transfer) that data is discarded. - /// - /// The pending xfers. - /// - internal ReturnCode EndXfer(TWPendingXfers pendingXfers) - { - Session.VerifyState(6, 7, DataGroups.Control, DataArgumentType.PendingXfers, Message.EndXfer); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.EndXfer, pendingXfers); - } - - /// - /// Returns the number of transfers the Source is ready to supply to the application, upon demand. - /// If DAT_XFERGROUP is set to DG_Image, this is the number of images. If DAT_XFERGROUP is set - /// to DG_AUDIO, this is the number of audio snippets for the current image. If there is no current - /// image, this call must return Failure / SeqError. - /// - /// The pending xfers. - /// - public ReturnCode Get(TWPendingXfers pendingXfers) - { - Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.PendingXfers, Message.Get); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, pendingXfers); - } - - /// - /// Sets the number of pending transfers in the Source to zero. - /// - /// The pending xfers. - /// - internal ReturnCode Reset(TWPendingXfers pendingXfers) - { - Session.VerifyState(6, 6, DataGroups.Control, DataArgumentType.PendingXfers, Message.Reset); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Reset, pendingXfers); - } - - /// - /// If CapAutoScan is TRUE, this command will stop the operation of the scanner’s automatic - /// feeder. No other action is taken. - /// - /// The pending xfers. - /// - public ReturnCode StopFeeder(TWPendingXfers pendingXfers) - { - Session.VerifyState(6, 6, DataGroups.Control, DataArgumentType.PendingXfers, Message.StopFeeder); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.StopFeeder, pendingXfers); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.SetupFileXfer.cs b/src/NTwain/Triplets/DGControl/DGControl.SetupFileXfer.cs deleted file mode 100644 index 779022b..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.SetupFileXfer.cs +++ /dev/null @@ -1,71 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer")] - public sealed class SetupFileXfer : TripletBase - { - internal SetupFileXfer(ITwainSessionInternal session) : base(session) { } - /// - /// Returns information about the file into which the Source has or will put the acquired image - /// or audio data. - /// - /// The setup file xfer. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode Get(out TWSetupFileXfer setupFileXfer) - { - Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.SetupFileXfer, Message.Get); - setupFileXfer = new TWSetupFileXfer(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, setupFileXfer); - } - - /// - /// Returns information for the default image or audio file. - /// - /// The setup file xfer. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode GetDefault(out TWSetupFileXfer setupFileXfer) - { - Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.SetupFileXfer, Message.GetDefault); - setupFileXfer = new TWSetupFileXfer(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.GetDefault, setupFileXfer); - } - - /// - /// Resets the current file information to the image or audio default file information and - /// returns that default information. - /// - /// The setup file xfer. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode Reset(out TWSetupFileXfer setupFileXfer) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.SetupFileXfer, Message.Reset); - setupFileXfer = new TWSetupFileXfer(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Reset, setupFileXfer); - } - - /// - /// Sets the file transfer information for the next file transfer. The application is responsible for - /// verifying that the specified file name is valid and that the file either does not currently exist (in - /// which case, the Source is to create the file), or that the existing file is available for opening and - /// read/write operations. The application should also assure that the file format it is requesting - /// can be provided by the Source - /// - /// The setup file xfer. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer")] - public ReturnCode Set(TWSetupFileXfer setupFileXfer) - { - Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.SetupFileXfer, Message.Set); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Set, setupFileXfer); - } - - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.SetupMemXfer.cs b/src/NTwain/Triplets/DGControl/DGControl.SetupMemXfer.cs deleted file mode 100644 index 3d32abc..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.SetupMemXfer.cs +++ /dev/null @@ -1,27 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mem")] - public sealed class SetupMemXfer : TripletBase - { - internal SetupMemXfer(ITwainSessionInternal session) : base(session) { } - /// - /// Returns the Source’s preferred, minimum, and maximum allocation sizes for transfer memory - /// buffers. - /// - /// The setup mem xfer. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mem"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode Get(out TWSetupMemXfer setupMemXfer) - { - Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.SetupMemXfer, Message.Get); - setupMemXfer = new TWSetupMemXfer(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, setupMemXfer); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.Status.cs b/src/NTwain/Triplets/DGControl/DGControl.Status.cs deleted file mode 100644 index 4127b2c..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.Status.cs +++ /dev/null @@ -1,36 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - sealed class Status : TripletBase - { - internal Status(ITwainSessionInternal session) : base(session) { } - /// - /// Returns the current Condition Code for the Source Manager. - /// - /// The status. - /// - public ReturnCode GetManager(out TWStatus status) - { - Session.VerifyState(2, 7, DataGroups.Control, DataArgumentType.Status, Message.Get); - status = new TWStatus(); - return Dsm.DsmEntry(Session.AppId, null, Message.Get, status); - } - - /// - /// Returns the current Condition Code for the specified Source. - /// - /// The status. - /// - public ReturnCode GetSource(out TWStatus status) - { - Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Status, Message.Get); - status = new TWStatus(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, status); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.StatusUtf8.cs b/src/NTwain/Triplets/DGControl/DGControl.StatusUtf8.cs deleted file mode 100644 index 372327b..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.StatusUtf8.cs +++ /dev/null @@ -1,39 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - sealed class StatusUtf8 : TripletBase - { - internal StatusUtf8(ITwainSessionInternal session) : base(session) { } - - /// - /// Translate the contents of a TW_STATUS structure received from the manager into a localized UTF-8 - /// encoded string. - /// - /// The status. - /// - public ReturnCode GetManager(out TWStatusUtf8 status) - { - status = new TWStatusUtf8(); - Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.StatusUtf8, Message.Get); - return Dsm.DsmEntry(Session.AppId, null, Message.Get, status); - } - - /// - /// Translate the contents of a TW_STATUS structure received from a Source into a localized UTF-8 - /// encoded string. - /// - /// The status. - /// - public ReturnCode GetSource(out TWStatusUtf8 status) - { - status = new TWStatusUtf8(); - Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.StatusUtf8, Message.Get); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, status); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.UserInterface.cs b/src/NTwain/Triplets/DGControl/DGControl.UserInterface.cs deleted file mode 100644 index cdf798a..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.UserInterface.cs +++ /dev/null @@ -1,74 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - sealed class UserInterface : TripletBase - { - internal UserInterface(ITwainSessionInternal session) : base(session) { } - /// - /// This operation causes the Source’s user interface, if displayed during the - /// EnableDS operation, to be lowered. The Source is returned to - /// State 4, where capability negotiation can again occur. The application can invoke this operation - /// either because it wants to shut down the current session, or in response to the Source "posting" - /// a CloseDSReq event to it. Rarely, the application may need to close the Source because an - /// error condition was detected. - /// - /// The user interface. - /// - public ReturnCode DisableDS(TWUserInterface userInterface) - { - Session.VerifyState(5, 5, DataGroups.Control, DataArgumentType.UserInterface, Message.DisableDS); - var rc = Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.DisableDS, userInterface); - if (rc == ReturnCode.Success) - { - Session.ChangeState(4, true); - } - return rc; - } - - /// - /// Enables the DS. - /// - /// The user interface. - /// - public ReturnCode EnableDS(TWUserInterface userInterface) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.UserInterface, Message.EnableDS); - using (var pending = Session.GetPendingStateChanger(5)) - { - var rc = Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.EnableDS, userInterface); - if (rc == ReturnCode.Success || - (!userInterface.ShowUI && rc == ReturnCode.CheckStatus)) - { - pending.Commit(); - } - return rc; - } - } - - /// - /// This operation is used by applications - /// that wish to display the source user interface to allow the user to manipulate the sources current - /// settings for DPI, paper size, etc. but not acquire an image. - /// - /// The user interface. - /// - public ReturnCode EnableDSUIOnly(TWUserInterface userInterface) - { - Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.UserInterface, Message.EnableDSUIOnly); - using (var pending = Session.GetPendingStateChanger(5)) - { - var rc = Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.EnableDSUIOnly, userInterface); - if (rc == ReturnCode.Success) - { - pending.Commit(); - } - return rc; - } - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.XferGroup.cs b/src/NTwain/Triplets/DGControl/DGControl.XferGroup.cs deleted file mode 100644 index ffce49f..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.XferGroup.cs +++ /dev/null @@ -1,40 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer")] - public sealed class XferGroup : TripletBase - { - internal XferGroup(ITwainSessionInternal session) : base(session) { } - - /// - /// Returns the Data Group (the type of data) for the upcoming transfer. The Source is required to - /// only supply one of the DGs specified in the SupportedGroups field of origin. - /// - /// The value. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "0#")] - public ReturnCode Get(ref DataGroups value) - { - Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.XferGroup, Message.Get); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataGroups.Control, DataArgumentType.XferGroup, Message.Get, ref value); - } - - /// - /// The transfer group determines the kind of data being passed from the Source to the Application. - /// By default a TWAIN Source must default to DG_IMAGE. Currently the only other data group - /// supported is DG_AUDIO, which is a feature supported by some digital cameras. - /// - /// The value. - /// - public ReturnCode Set(DataGroups value) - { - Session.VerifyState(6, 6, DataGroups.Control, DataArgumentType.XferGroup, Message.Set); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataGroups.Control, DataArgumentType.XferGroup, Message.Set, ref value); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGControl/DGControl.cs b/src/NTwain/Triplets/DGControl/DGControl.cs deleted file mode 100644 index 11c912d..0000000 --- a/src/NTwain/Triplets/DGControl/DGControl.cs +++ /dev/null @@ -1,215 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; -using System; -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - public sealed class DGControl - { - ITwainSessionInternal _session; - internal DGControl(ITwainSessionInternal session) - { - if (session == null) { throw new ArgumentNullException("session"); } - _session = session; - } - - Callback _callback; - internal Callback Callback - { - get - { - if (_callback == null) { _callback = new Callback(_session); } - return _callback; - } - } - - Callback2 _callback2; - internal Callback2 Callback2 - { - get - { - if (_callback2 == null) { _callback2 = new Callback2(_session); } - return _callback2; - } - } - Capability _capability; - /// - /// Gets the operations defined for DAT_CAPABILITY. - /// - public Capability Capability - { - get - { - if (_capability == null) { _capability = new Capability(_session); } - return _capability; - } - } - CapabilityCustom _capabilityCust; - /// - /// Gets the operations defined for a custom DAT_* value with capability data. - /// - public CapabilityCustom CapabilityCustom - { - get - { - if (_capabilityCust == null) { _capabilityCust = new CapabilityCustom(_session); } - return _capabilityCust; - } - } - CustomDSData _customDSData; - internal CustomDSData CustomDSData - { - get - { - if (_customDSData == null) { _customDSData = new CustomDSData(_session); } - return _customDSData; - } - } - DeviceEvent _deviceEvent; - internal DeviceEvent DeviceEvent - { - get - { - if (_deviceEvent == null) { _deviceEvent = new DeviceEvent(_session); } - return _deviceEvent; - } - } - EntryPoint _entryPoint; - internal EntryPoint EntryPoint - { - get - { - if (_entryPoint == null) { _entryPoint = new EntryPoint(_session); } - return _entryPoint; - } - } - Event _event; - internal Event Event - { - get - { - if (_event == null) { _event = new Event(_session); } - return _event; - } - } - FileSystem _fileSys; - /// - /// Gets the operations defined for DAT_FILESYSTEM. - /// - public FileSystem FileSystem - { - get - { - if (_fileSys == null) { _fileSys = new FileSystem(_session); } - return _fileSys; - } - } - Identity _identity; - internal Identity Identity - { - get - { - if (_identity == null) { _identity = new Identity(_session); } - return _identity; - } - } - Parent _parent; - internal Parent Parent - { - get - { - if (_parent == null) { _parent = new Parent(_session); } - return _parent; - } - } - PassThru _passThru; - /// - /// Gets the operations defined for DAT_PASSTHRU. - /// - public PassThru PassThru - { - get - { - if (_passThru == null) { _passThru = new PassThru(_session); } - return _passThru; - } - } - PendingXfers _pendingXfers; - internal PendingXfers PendingXfers - { - get - { - if (_pendingXfers == null) { _pendingXfers = new PendingXfers(_session); } - return _pendingXfers; - } - } - SetupFileXfer _setupFileXfer; - /// - /// Gets the operations defined for DAT_SETUPFILEXFER. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer")] - public SetupFileXfer SetupFileXfer - { - get - { - if (_setupFileXfer == null) { _setupFileXfer = new SetupFileXfer(_session); } - return _setupFileXfer; - } - } - SetupMemXfer _setupMemXfer; - /// - /// Gets the operations defined for DAT_SETUPMEMXFER. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mem")] - public SetupMemXfer SetupMemXfer - { - get - { - if (_setupMemXfer == null) { _setupMemXfer = new SetupMemXfer(_session); } - return _setupMemXfer; - } - } - Status _status; - internal Status Status - { - get - { - if (_status == null) { _status = new Status(_session); } - return _status; - } - } - StatusUtf8 _statusUtf8; - internal StatusUtf8 StatusUtf8 - { - get - { - if (_statusUtf8 == null) { _statusUtf8 = new StatusUtf8(_session); } - return _statusUtf8; - } - } - UserInterface _userInterface; - internal UserInterface UserInterface - { - get - { - if (_userInterface == null) { _userInterface = new UserInterface(_session); } - return _userInterface; - } - } - XferGroup _xferGroup; - /// - /// Gets the operations defined for DAT_XFERGROUP. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer")] - public XferGroup XferGroup - { - get - { - if (_xferGroup == null) { _xferGroup = new XferGroup(_session); } - return _xferGroup; - } - } - } -} diff --git a/src/NTwain/Triplets/DGCustom.cs b/src/NTwain/Triplets/DGCustom.cs deleted file mode 100644 index 1d5d320..0000000 --- a/src/NTwain/Triplets/DGCustom.cs +++ /dev/null @@ -1,44 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NTwain.Triplets -{ - /// - /// Provides direct access to the triplet call. - /// - public class DGCustom - { - ITwainSessionInternal _session; - internal DGCustom(ITwainSessionInternal session) - { - if (session == null) { throw new ArgumentNullException("session"); } - _session = session; - } - - - /// - /// Direct DSM_Entry call with full arguments for custom values. - /// - /// The group. - /// The dat. - /// The message. - /// The data. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "3#"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "dat"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dsm")] - public ReturnCode DsmEntry( - DataGroups group, - DataArgumentType dat, - Message message, - ref IntPtr data) - { - _session.VerifyState(3, 7, group, dat, message); - return Dsm.DsmEntry(_session.AppId, _session.CurrentSource.Identity, group, dat, message, ref data); - } - - // todo: add other data value types? - } -} diff --git a/src/NTwain/Triplets/DGImage/DGImage.CieColor.cs b/src/NTwain/Triplets/DGImage/DGImage.CieColor.cs deleted file mode 100644 index c1e3f22..0000000 --- a/src/NTwain/Triplets/DGImage/DGImage.CieColor.cs +++ /dev/null @@ -1,28 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cie")] - public sealed class CieColor : TripletBase - { - internal CieColor(ITwainSessionInternal session) : base(session) { } - - /// - /// This operation causes the Source to report the currently active parameters to be used in - /// converting acquired color data into CIE XYZ. - /// - /// Color data. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "cie"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode Get(out TWCieColor cieColor) - { - Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.CieColor, Message.Get); - cieColor = new TWCieColor(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, cieColor); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGImage/DGImage.ExtImageInfo.cs b/src/NTwain/Triplets/DGImage/DGImage.ExtImageInfo.cs deleted file mode 100644 index 3b3b062..0000000 --- a/src/NTwain/Triplets/DGImage/DGImage.ExtImageInfo.cs +++ /dev/null @@ -1,25 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - sealed class ExtImageInfo : TripletBase - { - internal ExtImageInfo(ITwainSessionInternal session) : base(session) { } - - /// - /// This operation is used by the application to query the data source for extended image attributes. - /// The application is responsible for creating and disiposing the info object. - /// - /// The information. - /// - public ReturnCode Get(TWExtImageInfo info) - { - Session.VerifyState(7, 7, DataGroups.Image, DataArgumentType.ExtImageInfo, Message.Get); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, info); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGImage/DGImage.Filter.cs b/src/NTwain/Triplets/DGImage/DGImage.Filter.cs deleted file mode 100644 index da11cf9..0000000 --- a/src/NTwain/Triplets/DGImage/DGImage.Filter.cs +++ /dev/null @@ -1,66 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - public sealed class Filter : TripletBase - { - internal Filter(ITwainSessionInternal session) : base(session) { } - - - /// - /// Causes the Source to return the filter parameters that will be used during the next image - /// acquisition. - /// - /// The filter. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode Get(out TWFilter filter) - { - Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.Filter, Message.Get); - filter = new TWFilter(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, filter); - } - - /// - /// Causes the Source to return the power-on default values applied to the filter. - /// - /// The filter. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode GetDefault(out TWFilter filter) - { - Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.Filter, Message.GetDefault); - filter = new TWFilter(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.GetDefault, filter); - } - - /// - /// Allows the Application to configure the filter parameters that will be used during the next image - /// acquisition. - /// - /// The filter. - /// - public ReturnCode Set(TWFilter filter) - { - Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.Filter, Message.Set); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Set, filter); - } - - /// - /// Return the Source to using its power-on default values when it is applying the filter. - /// - /// The filter. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode Reset(out TWFilter filter) - { - Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.Filter, Message.Reset); - filter = new TWFilter(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Reset, filter); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGImage/DGImage.GrayResponse.cs b/src/NTwain/Triplets/DGImage/DGImage.GrayResponse.cs deleted file mode 100644 index caf6861..0000000 --- a/src/NTwain/Triplets/DGImage/DGImage.GrayResponse.cs +++ /dev/null @@ -1,39 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - public sealed class GrayResponse : TripletBase - { - internal GrayResponse(ITwainSessionInternal session) : base(session) { } - - /// - /// The Reset operation causes the Source to use its "identity response curve." The identity - /// curve causes no change in the values of the captured data when it is applied. - /// - /// The response. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode Reset(out TWGrayResponse response) - { - Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.GrayResponse, Message.Reset); - response = new TWGrayResponse(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Reset, response); - } - - /// - /// This operation causes the Source to transform any grayscale data according to the response - /// curve specified. - /// - /// The response. - /// - public ReturnCode Set(TWGrayResponse response) - { - Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.GrayResponse, Message.Set); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Set, response); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGImage/DGImage.IccProfile.cs b/src/NTwain/Triplets/DGImage/DGImage.IccProfile.cs deleted file mode 100644 index 35d9157..0000000 --- a/src/NTwain/Triplets/DGImage/DGImage.IccProfile.cs +++ /dev/null @@ -1,28 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Icc")] - public sealed class IccProfile : TripletBase - { - internal IccProfile(ITwainSessionInternal session) : base(session) { } - - /// - /// This operation provides the application with the ICC profile associated with the image which is - /// about to be transferred (state 6) or is being transferred (state 7). - /// - /// The profile. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "0#")] - public ReturnCode Get(ref TWMemory profile) - { - Session.VerifyState(6, 7, DataGroups.Image, DataArgumentType.IccProfile, Message.Get); - profile = new TWMemory(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataArgumentType.IccProfile, Message.Get, ref profile); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGImage/DGImage.ImageFileXfer.cs b/src/NTwain/Triplets/DGImage/DGImage.ImageFileXfer.cs deleted file mode 100644 index 2354e4f..0000000 --- a/src/NTwain/Triplets/DGImage/DGImage.ImageFileXfer.cs +++ /dev/null @@ -1,26 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; -using System; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - sealed class ImageFileXfer : TripletBase - { - internal ImageFileXfer(ITwainSessionInternal session) : base(session) { } - - /// - /// This operation is used to initiate the transfer of an image from the Source to the application via - /// the disk-file transfer mechanism. It causes the transfer to begin. - /// - /// - public ReturnCode Get() - { - Session.VerifyState(6, 6, DataGroups.Image, DataArgumentType.ImageFileXfer, Message.Get); - IntPtr z = IntPtr.Zero; - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataGroups.Image, DataArgumentType.ImageFileXfer, Message.Get, ref z); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGImage/DGImage.ImageInfo.cs b/src/NTwain/Triplets/DGImage/DGImage.ImageInfo.cs deleted file mode 100644 index 33e8856..0000000 --- a/src/NTwain/Triplets/DGImage/DGImage.ImageInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - sealed class ImageInfo : TripletBase - { - internal ImageInfo(ITwainSessionInternal session) : base(session) { } - - public ReturnCode Get(out TWImageInfo info) - { - Session.VerifyState(6, 7, DataGroups.Image, DataArgumentType.ImageInfo, Message.Get); - info = new TWImageInfo(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, info); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGImage/DGImage.ImageLayout.cs b/src/NTwain/Triplets/DGImage/DGImage.ImageLayout.cs deleted file mode 100644 index 28e9eab..0000000 --- a/src/NTwain/Triplets/DGImage/DGImage.ImageLayout.cs +++ /dev/null @@ -1,72 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - public sealed class ImageLayout : TripletBase - { - internal ImageLayout(ITwainSessionInternal session) : base(session) { } - - /// - /// Gets both the size and placement of the image on the scanner. The - /// coordinates on the scanner and the extents of the image are expressed in the unit of measure - /// currently negotiated for ICAP_UNITS (default is inches). - /// - /// The layout. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode Get(out TWImageLayout layout) - { - Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.ImageLayout, Message.Get); - layout = new TWImageLayout(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, layout); - } - - /// - /// returns the default information on the layout of an image. This is the size and - /// position of the image that will be acquired from the Source if the acquisition is started with the - /// Source (and the device it is controlling) in its power-on state (for instance, most flatbed scanners - /// will capture the entire bed). - /// - /// The layout. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode GetDefault(out TWImageLayout layout) - { - Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.ImageLayout, Message.GetDefault); - layout = new TWImageLayout(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.GetDefault, layout); - } - - /// - /// This operation sets the image layout information for the next transfer to its default settings. - /// - /// The layout. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode Reset(out TWImageLayout layout) - { - Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.ImageLayout, Message.Reset); - layout = new TWImageLayout(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Reset, layout); - } - - /// - /// This operation sets the layout for the next image transfer. This allows the application to specify - /// the physical area to be acquired during the next image transfer (for instance, a frame-based - /// application would pass to the Source the size of the frame the user selected within the - /// application—the helpful Source would present a selection region already sized to match the - /// layout frame size). - /// - /// The layout. - /// - public ReturnCode Set(TWImageLayout layout) - { - Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.ImageLayout, Message.Set); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Set, layout); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGImage/DGImage.ImageMemFileXfer.cs b/src/NTwain/Triplets/DGImage/DGImage.ImageMemFileXfer.cs deleted file mode 100644 index dffce16..0000000 --- a/src/NTwain/Triplets/DGImage/DGImage.ImageMemFileXfer.cs +++ /dev/null @@ -1,23 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - sealed class ImageMemFileXfer : TripletBase - { - internal ImageMemFileXfer(ITwainSessionInternal session) : base(session) { } - - /// - /// This operation is used to initiate the transfer of an image from the Source to the application via - /// the Memory-File transfer mechanism. - /// - /// The xfer. - /// - public ReturnCode Get(TWImageMemXfer xfer) - { - Session.VerifyState(6, 7, DataGroups.Image, DataArgumentType.ImageMemFileXfer, Message.Get); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, xfer); - } - - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGImage/DGImage.ImageMemXfer.cs b/src/NTwain/Triplets/DGImage/DGImage.ImageMemXfer.cs deleted file mode 100644 index f3f85bf..0000000 --- a/src/NTwain/Triplets/DGImage/DGImage.ImageMemXfer.cs +++ /dev/null @@ -1,22 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - sealed class ImageMemXfer : TripletBase - { - internal ImageMemXfer(ITwainSessionInternal session) : base(session) { } - - /// - /// This operation is used to initiate the transfer of an image from the Source to the application via - /// the Buffered Memory transfer mechanism. - /// - /// The xfer. - /// - public ReturnCode Get(TWImageMemXfer xfer) - { - Session.VerifyState(6, 7, DataGroups.Image, DataArgumentType.ImageMemXfer, Message.Get); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, xfer); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGImage/DGImage.ImageNativeXfer.cs b/src/NTwain/Triplets/DGImage/DGImage.ImageNativeXfer.cs deleted file mode 100644 index f0bd7f5..0000000 --- a/src/NTwain/Triplets/DGImage/DGImage.ImageNativeXfer.cs +++ /dev/null @@ -1,26 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; -using System; - -namespace NTwain.Triplets -{ - sealed class ImageNativeXfer : TripletBase - { - internal ImageNativeXfer(ITwainSessionInternal session) : base(session) { } - - /// - /// Causes the transfer of an image’s data from the Source to the application, via the Native transfer - /// mechanism, to begin. The resulting data is stored in main memory in a single block. The data is - /// stored in Picture (PICT) format on the Macintosh and as a device-independent bitmap (DIB) - /// under Microsoft Windows. The size of the image that can be transferred is limited to the size of - /// the memory block that can be allocated by the Source. - /// - /// The handle. - /// - public ReturnCode Get(ref IntPtr handle) - { - Session.VerifyState(6, 6, DataGroups.Image, DataArgumentType.ImageNativeXfer, Message.Get); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataGroups.Image, DataArgumentType.ImageNativeXfer, Message.Get, ref handle); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGImage/DGImage.JpegCompression.cs b/src/NTwain/Triplets/DGImage/DGImage.JpegCompression.cs deleted file mode 100644 index 1d07ad2..0000000 --- a/src/NTwain/Triplets/DGImage/DGImage.JpegCompression.cs +++ /dev/null @@ -1,67 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - public sealed class JpegCompression : TripletBase - { - internal JpegCompression(ITwainSessionInternal session) : base(session) { } - - /// - /// Causes the Source to return the parameters that will be used during the compression of data - /// using the JPEG algorithms. - /// - /// The compression. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode Get(out TWJpegCompression compression) - { - Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.JpegCompression, Message.Get); - compression = new TWJpegCompression(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, compression); - } - - /// - /// Causes the Source to return the power-on default values applied to JPEG-compressed data - /// transfers. - /// - /// The compression. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode GetDefault(out TWJpegCompression compression) - { - Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.JpegCompression, Message.GetDefault); - compression = new TWJpegCompression(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.GetDefault, compression); - } - - /// - /// Return the Source to using its power-on default values for JPEG-compressed transfers. - /// - /// The compression. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode Reset(out TWJpegCompression compression) - { - Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.JpegCompression, Message.Reset); - compression = new TWJpegCompression(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Reset, compression); - } - - /// - /// Allows the application to configure the compression parameters to be used on all future JPEGcompressed - /// transfers during the current session. The application should have already - /// established that the requested values are supported by the Source. - /// - /// The compression. - /// - public ReturnCode Set(TWJpegCompression compression) - { - Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.JpegCompression, Message.Set); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Set, compression); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGImage/DGImage.Palette8.cs b/src/NTwain/Triplets/DGImage/DGImage.Palette8.cs deleted file mode 100644 index b8025ca..0000000 --- a/src/NTwain/Triplets/DGImage/DGImage.Palette8.cs +++ /dev/null @@ -1,67 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - public sealed class Palette8 : TripletBase - { - internal Palette8(ITwainSessionInternal session) : base(session) { } - - /// - /// This operation causes the Source to report its current palette information. - /// - /// The palette. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode Get(out TWPalette8 palette) - { - Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.Palette8, Message.Get); - palette = new TWPalette8(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, palette); - } - - /// - /// This operation causes the Source to report its power-on default palette. - /// - /// The palette. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode GetDefault(out TWPalette8 palette) - { - Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.Palette8, Message.GetDefault); - palette = new TWPalette8(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.GetDefault, palette); - } - - /// - /// This operation causes the Source to dispose of any current palette it has and to use its default - /// palette for the next palette transfer. - /// - /// The palette. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode Reset(out TWPalette8 palette) - { - Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.Palette8, Message.Reset); - palette = new TWPalette8(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Reset, palette); - } - - /// - /// This operation requests that the Source adopt the specified palette for use with all subsequent - /// palette transfers. The application should be careful to supply a palette that matches the bit - /// depth of the Source. The Source is not required to adopt this palette. The application should be - /// careful to check the return value from this operation. - /// - /// The palette. - /// - public ReturnCode Set(TWPalette8 palette) - { - Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.Palette8, Message.Set); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Set, palette); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGImage/DGImage.RgbResponse.cs b/src/NTwain/Triplets/DGImage/DGImage.RgbResponse.cs deleted file mode 100644 index 24c5d36..0000000 --- a/src/NTwain/Triplets/DGImage/DGImage.RgbResponse.cs +++ /dev/null @@ -1,41 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; - -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rgb")] - public sealed class RgbResponse : TripletBase - { - internal RgbResponse(ITwainSessionInternal session) : base(session) { } - - /// - /// Causes the Source to use its "identity" response curves for future RGB transfers. The identity - /// curve causes no change in the values of the captured data when it is applied. (Note that - /// resetting the curves for RGB data does not reset any curves for other pixel types). - /// - /// The response. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] - public ReturnCode Reset(out TWRgbResponse response) - { - Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.RgbResponse, Message.Reset); - response = new TWRgbResponse(); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Reset, response); - } - - /// - /// Causes the Source to transform any RGB data according to the response curves specified by the - /// application. - /// - /// The response. - /// - public ReturnCode Set(TWRgbResponse response) - { - Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.RgbResponse, Message.Set); - return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Set, response); - } - } -} \ No newline at end of file diff --git a/src/NTwain/Triplets/DGImage/DGImage.cs b/src/NTwain/Triplets/DGImage/DGImage.cs deleted file mode 100644 index 48f9ed0..0000000 --- a/src/NTwain/Triplets/DGImage/DGImage.cs +++ /dev/null @@ -1,193 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; -using System; -namespace NTwain.Triplets -{ - /// - /// Represents . - /// - public sealed class DGImage - { - ITwainSessionInternal _session; - internal DGImage(ITwainSessionInternal session) - { - if (session == null) { throw new ArgumentNullException("session"); } - _session = session; - } - - CieColor _cieColor; - /// - /// Gets the operations defined for DAT_CIECOLOR. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cie")] - public CieColor CieColor - { - get - { - if (_cieColor == null) { _cieColor = new CieColor(_session); } - return _cieColor; - } - } - - - ExtImageInfo _extImgInfo; - /// - /// Gets the operations defined for DAT_EXTIMAGEINFO. - /// - internal ExtImageInfo ExtImageInfo - { - get - { - if (_extImgInfo == null) { _extImgInfo = new ExtImageInfo(_session); } - return _extImgInfo; - } - } - - - Filter _filter; - /// - /// Gets the operations defined for DAT_FILTER. - /// - public Filter Filter - { - get - { - if (_filter == null) { _filter = new Filter(_session); } - return _filter; - } - } - - GrayResponse _grayResponse; - /// - /// Gets the operations defined for DAT_GRAYRESPONSE. - /// - public GrayResponse GrayResponse - { - get - { - if (_grayResponse == null) { _grayResponse = new GrayResponse(_session); } - return _grayResponse; - } - } - - IccProfile _iccProfile; - /// - /// Gets the operations defined for DAT_ICCPROFILE. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Icc")] - public IccProfile IccProfile - { - get - { - if (_iccProfile == null) { _iccProfile = new IccProfile(_session); } - return _iccProfile; - } - } - - ImageFileXfer _imgFileXfer; - internal ImageFileXfer ImageFileXfer - { - get - { - if (_imgFileXfer == null) { _imgFileXfer = new ImageFileXfer(_session); } - return _imgFileXfer; - } - } - - ImageInfo _imgInfo; - internal ImageInfo ImageInfo - { - get - { - if (_imgInfo == null) { _imgInfo = new ImageInfo(_session); } - return _imgInfo; - } - } - - ImageLayout _imgLayout; - /// - /// Gets the operations defined for DAT_IMAGELAYOUT. - /// - public ImageLayout ImageLayout - { - get - { - if (_imgLayout == null) { _imgLayout = new ImageLayout(_session); } - return _imgLayout; - } - } - - ImageMemFileXfer _imgMemFileXfer; - internal ImageMemFileXfer ImageMemFileXfer - { - get - { - if (_imgMemFileXfer == null) { _imgMemFileXfer = new ImageMemFileXfer(_session); } - return _imgMemFileXfer; - } - } - - ImageMemXfer _imgMemXfer; - internal ImageMemXfer ImageMemXfer - { - get - { - if (_imgMemXfer == null) { _imgMemXfer = new ImageMemXfer(_session); } - return _imgMemXfer; - } - } - - ImageNativeXfer _imgNativeXfer; - internal ImageNativeXfer ImageNativeXfer - { - get - { - if (_imgNativeXfer == null) { _imgNativeXfer = new ImageNativeXfer(_session); } - return _imgNativeXfer; - } - } - - JpegCompression _jpegComp; - /// - /// Gets the operations defined for DAT_JPEGCOMPRESSION. - /// - public JpegCompression JpegCompression - { - get - { - if (_jpegComp == null) { _jpegComp = new JpegCompression(_session); } - return _jpegComp; - } - } - - Palette8 _palette8; - /// - /// Gets the operations defined for DAT_PALETTE8. - /// - public Palette8 Palette8 - { - get - { - if (_palette8 == null) { _palette8 = new Palette8(_session); } - return _palette8; - } - } - - RgbResponse _rgbResp; - /// - /// Gets the operations defined for DAT_RGBRESPONSE. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rgb")] - public RgbResponse RgbResponse - { - get - { - if (_rgbResp == null) { _rgbResp = new RgbResponse(_session); } - return _rgbResp; - } - } - - - - } -} diff --git a/src/NTwain/Triplets/Dsm.Linux.cs b/src/NTwain/Triplets/Dsm.Linux.cs deleted file mode 100644 index 68b0355..0000000 --- a/src/NTwain/Triplets/Dsm.Linux.cs +++ /dev/null @@ -1,283 +0,0 @@ -using NTwain.Data; -using System; -using System.Runtime.InteropServices; - -namespace NTwain.Triplets -{ - static partial class Dsm - { - - static partial class NativeMethods - { - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - ref IntPtr data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - ref DataGroups data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWAudioInfo data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWCapability data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWCustomDSData data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWDeviceEvent data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWCallback data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWCallback2 data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWEntryPoint data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWEvent data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWFileSystem data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - IntPtr zero, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWIdentity data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWPassThru data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWPendingXfers data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWSetupFileXfer data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWSetupMemXfer data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWStatusUtf8 data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWUserInterface data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWCieColor data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWExtImageInfo data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWFilter data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWGrayResponse data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWImageInfo data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWImageLayout data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWImageMemXfer data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWJpegCompression data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWPalette8 data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWRgbResponse data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWStatus data); - - [DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmLinux( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - ref TWMemory data); - } - } -} diff --git a/src/NTwain/Triplets/Dsm.WinNew.cs b/src/NTwain/Triplets/Dsm.WinNew.cs deleted file mode 100644 index 0c87b72..0000000 --- a/src/NTwain/Triplets/Dsm.WinNew.cs +++ /dev/null @@ -1,283 +0,0 @@ -using NTwain.Data; -using System; -using System.Runtime.InteropServices; - -namespace NTwain.Triplets -{ - static partial class Dsm - { - static partial class NativeMethods - { - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - ref IntPtr data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - ref DataGroups data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWAudioInfo data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWCapability data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWCustomDSData data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWDeviceEvent data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWCallback data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWCallback2 data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWEntryPoint data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWEvent data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWFileSystem data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - IntPtr zero, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWIdentity data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWPassThru data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWPendingXfers data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWSetupFileXfer data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWSetupMemXfer data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWStatusUtf8 data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWUserInterface data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWCieColor data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWExtImageInfo data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWFilter data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWGrayResponse data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWImageInfo data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWImageLayout data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWImageMemXfer data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWJpegCompression data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWPalette8 data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWRgbResponse data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWStatus data); - - [DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinNew( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - ref TWMemory data); - - } - } -} diff --git a/src/NTwain/Triplets/Dsm.WinOld.cs b/src/NTwain/Triplets/Dsm.WinOld.cs deleted file mode 100644 index fabf125..0000000 --- a/src/NTwain/Triplets/Dsm.WinOld.cs +++ /dev/null @@ -1,282 +0,0 @@ -using NTwain.Data; -using System; -using System.Runtime.InteropServices; - -namespace NTwain.Triplets -{ - static partial class Dsm - { - static partial class NativeMethods - { - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - ref IntPtr data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - ref DataGroups data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWAudioInfo data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWCapability data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWCustomDSData data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWDeviceEvent data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWCallback data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWCallback2 data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWEntryPoint data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWEvent data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWFileSystem data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - IntPtr zero, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWIdentity data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWPassThru data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWPendingXfers data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWSetupFileXfer data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWSetupMemXfer data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWStatusUtf8 data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWUserInterface data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWCieColor data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWExtImageInfo data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWFilter data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWGrayResponse data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWImageInfo data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWImageLayout data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWImageMemXfer data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWJpegCompression data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWPalette8 data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWRgbResponse data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - [In, Out]TWStatus data); - - [DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)] - public static extern ReturnCode DsmWinOld( - [In, Out]TWIdentity origin, - [In, Out]TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - ref TWMemory data); - } - } -} diff --git a/src/NTwain/Triplets/Dsm.cs b/src/NTwain/Triplets/Dsm.cs deleted file mode 100644 index 8425f33..0000000 --- a/src/NTwain/Triplets/Dsm.cs +++ /dev/null @@ -1,591 +0,0 @@ -using NTwain.Data; -using System; - -namespace NTwain.Triplets -{ - /// - /// Contains the full TWAIN entry signatures through pinvoke. - /// These are called by all the defined triplets methods in - /// this namespace. - /// - static partial class Dsm - { - internal const string DSM_ENTRY = "DSM_Entry"; - internal const string LINUX_DSM_PATH = "/usr/local/lib/libtwaindsm.so"; - internal const string WIN_NEW_DSM_NAME = "twaindsm.dll"; - internal const string WIN_OLD_DSM_NAME = "twain_32.dll"; - - #region wrapped calls - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - ref IntPtr data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, dg, dat, msg, ref data); } - else { return NativeMethods.DsmWinOld(origin, destination, dg, dat, msg, ref data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, dg, dat, msg, ref data); - } - throw new PlatformNotSupportedException(); - } - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - DataGroups dg, - DataArgumentType dat, - Message msg, - ref DataGroups data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, dg, dat, msg, ref data); } - else { return NativeMethods.DsmWinOld(origin, destination, dg, dat, msg, ref data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, dg, dat, msg, ref data); - } - throw new PlatformNotSupportedException(); - } - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWAudioInfo data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - DataArgumentType dat, - Message msg, - TWCapability data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, dat, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, dat, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, dat, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWCustomDSData data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWDeviceEvent data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWCallback data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWCallback2 data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - Message msg, - TWEntryPoint data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, null, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); } - else { return NativeMethods.DsmWinOld(origin, null, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, null, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWEvent data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWFileSystem data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); - } - throw new PlatformNotSupportedException(); - } - - public static ReturnCode DsmEntry( - TWIdentity origin, - Message msg, - TWIdentity data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); } - else { return NativeMethods.DsmWinOld(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWPassThru data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWPendingXfers data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWSetupFileXfer data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWSetupMemXfer data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWStatusUtf8 data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWUserInterface data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWCieColor data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWExtImageInfo data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); - } - throw new PlatformNotSupportedException(); - } - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWFilter data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); - } - throw new PlatformNotSupportedException(); - } - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWGrayResponse data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWImageInfo data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWImageLayout data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWImageMemXfer data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWJpegCompression data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWPalette8 data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWRgbResponse data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - Message msg, - TWStatus data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); - } - throw new PlatformNotSupportedException(); - } - - - public static ReturnCode DsmEntry( - TWIdentity origin, - TWIdentity destination, - DataArgumentType dat, - Message msg, - ref TWMemory data) - { - if (PlatformInfo.Current.IsWindows) - { - if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, dat, msg, ref data); } - else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, dat, msg, ref data); } - } - else if (PlatformInfo.Current.IsLinux) - { - return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, dat, msg, ref data); - } - throw new PlatformNotSupportedException(); - } - - - #endregion - } -} diff --git a/src/NTwain/Triplets/TripletBase.cs b/src/NTwain/Triplets/TripletBase.cs deleted file mode 100644 index c5ddcb3..0000000 --- a/src/NTwain/Triplets/TripletBase.cs +++ /dev/null @@ -1,30 +0,0 @@ -using NTwain.Internals; -using System; - -namespace NTwain.Triplets -{ - /// - /// Base class for grouping triplet operations messages. - /// - public abstract class TripletBase - { - /// - /// Initializes a new instance of the class. - /// - /// The session. - /// - internal TripletBase(ITwainSessionInternal session) - { - if (session == null) { throw new ArgumentNullException("session"); } - Session = session; - } - - /// - /// Gets the twain session. - /// - /// - /// The session. - /// - internal ITwainSessionInternal Session { get; private set; } - } -} diff --git a/src/NTwain/Triplets/WhatsThis.txt b/src/NTwain/Triplets/WhatsThis.txt deleted file mode 100644 index 60d30f0..0000000 --- a/src/NTwain/Triplets/WhatsThis.txt +++ /dev/null @@ -1,23 +0,0 @@ -All TWAIN operations are done through the a combination of -Data Group (DG), Data Argument Type (DAT), and Message (MSG) -triplets. Rather than letting consumers of this lib deal -with all the combinations themselves and risk passing the -wrong thing, all valid triplet combinations are simply -made available under this namespace. - -Example: -To get the status of the DS, just use the -"Get" method (represents MSG), in the -"Status" embedded class (represnts DAT), in the -"DGControl" class (represents DG). - -or better explained in code: - -DGControl.Status.Get(...) - -and that's the triplet at-a-glance. Only triplets usable by the -application-side are defined here. - -Also some of the operations are marked as internal when there are -better wrapped managed version available. Goal is to -eventually keep the exposed triplets to a minimum. \ No newline at end of file diff --git a/src/NTwain/TwainException.cs b/src/NTwain/TwainException.cs deleted file mode 100644 index 64d0f7d..0000000 --- a/src/NTwain/TwainException.cs +++ /dev/null @@ -1,110 +0,0 @@ -using NTwain.Data; -using System; -using System.Runtime.Serialization; -using System.Security.Permissions; - -namespace NTwain -{ - /// - /// Represents a general exception with TWAIN. - /// - [Serializable] - public class TwainException : Exception - { - /// - /// Initializes a new instance of the class. - /// - public TwainException() { } - - /// - /// Initializes a new instance of the class. - /// - /// The message that describes the error. - public TwainException(string message) - : base(message) - { - - } - - /// - /// Initializes a new instance of the class. - /// - /// The return code. - /// The message. - public TwainException(ReturnCode returnCode, string message) - : this(returnCode, message, null) { } - - /// - /// Initializes a new instance of the class. - /// - /// The error message that explains the reason for the exception. - /// The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified. - public TwainException(string message, Exception innerException) - : base(message, innerException) - { - - } - - /// - /// Initializes a new instance of the class. - /// - /// The return code. - /// The message. - /// The inner exception. - public TwainException(ReturnCode returnCode, string message, Exception innerException) - : base(message, innerException) - { - ReturnCode = returnCode; - } - - /// - /// Initializes a new instance of the class. - /// - /// The that holds the serialized object data about the exception being thrown. - /// The that contains contextual information about the source or destination. - /// - /// The parameter is null. - /// - /// - /// The class name is null or is zero (0). - /// - protected TwainException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - if (info != null) - { - ReturnCode = (ReturnCode)info.GetUInt16("RC"); - } - } - - /// - /// When overridden in a derived class, sets the with information about the exception. - /// - /// The that holds the serialized object data about the exception being thrown. - /// The that contains contextual information about the source or destination. - /// - /// The parameter is a null reference (Nothing in Visual Basic). - /// - /// - /// - /// - /// - [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)] - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - if (info != null) - { - info.AddValue("RC", ReturnCode); - } - base.GetObjectData(info, context); - } - - /// - /// Gets the return code from the TWAIN operation if applicable. - /// - /// - /// The return code. - /// - public ReturnCode ReturnCode { get; private set; } - } -} diff --git a/src/NTwain/TwainSession.cs b/src/NTwain/TwainSession.cs deleted file mode 100644 index c2d7005..0000000 --- a/src/NTwain/TwainSession.cs +++ /dev/null @@ -1,679 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; -using NTwain.Properties; -using NTwain.Triplets; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Threading; - -namespace NTwain -{ - /// - /// Basic class for interfacing with TWAIN. You should only have one of this per application process. - /// - public partial class TwainSession - { - /// - /// Initializes a new instance of the class. - /// - /// The supported groups. - public TwainSession(DataGroups supportedGroups) - : this(TWIdentity.CreateFromAssembly(supportedGroups, Assembly.GetEntryAssembly())) - { - - } - - /// - /// Initializes a new instance of the class. - /// - /// The app id that represents calling application. - /// - public TwainSession(TWIdentity appId) - { - if (appId == null) { throw new ArgumentNullException("appId"); } - - _appId = appId; - _ownedSources = new Dictionary(); - if (PlatformInfo.Current.IsSupported) - { - ((ITwainSessionInternal)this).ChangeState(2, false); - } -#if DEBUG - // defaults to false on release since it's only useful during dev - EnforceState = true; -#endif - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] - object _callbackObj; // kept around so it doesn't get gc'ed - TWIdentity _appId; - TWUserInterface _twui; - - // cache generated twain sources so if you get same source from one session it'll return the same object - readonly Dictionary _ownedSources; - - DataSource GetSourceInstance(ITwainSessionInternal session, TWIdentity sourceId) - { - DataSource source = null; - PlatformInfo.Current.Log.Debug("Source id = {0}", sourceId.Id); - var key = string.Format(CultureInfo.InvariantCulture, "{0}|{1}|{2}|{3}", sourceId.Id, sourceId.Manufacturer, sourceId.ProductFamily, sourceId.ProductName); - if (_ownedSources.ContainsKey(key)) - { - source = _ownedSources[key]; - } - else - { - _ownedSources[key] = source = new DataSource(session, sourceId); - } - return source; - } - - #region ITwainSession Members - - - /// - /// Gets or sets a value indicating whether calls to triplets will verify the current twain session state. - /// - /// - /// true if state value is enforced; otherwise, false. - /// - public bool EnforceState { get; set; } - - /// - /// [Experimental] Gets or sets the optional synchronization context when not specifying a on . - /// This allows events to be raised on the thread associated with the context. This is experimental is not recommended for use. - /// - /// - /// The synchronization context. - /// - public SynchronizationContext SynchronizationContext { get; set; } - - - /// - /// Gets the currently open source. - /// - /// - /// The current source. - /// - public DataSource CurrentSource { get; private set; } - - /// - /// Gets or sets the default source for this application. - /// While this can be get as long as the session is open, - /// it can only be set at State 3. - /// - /// - /// The default source. - /// - public DataSource DefaultSource - { - get - { - TWIdentity id; - if (((ITwainSessionInternal)this).DGControl.Identity.GetDefault(out id) == ReturnCode.Success) - { - return GetSourceInstance(this, id); - } - return null; - } - set - { - if (value != null) - { - ((ITwainSessionInternal)this).DGControl.Identity.Set(value.Identity); - } - } - } - - /// - /// Try to show the built-in source selector dialog and return the selected source. - /// This is not recommended and is only included for completeness. - /// - /// - public DataSource ShowSourceSelector() - { - TWIdentity id; - if (((ITwainSessionInternal)this).DGControl.Identity.UserSelect(out id) == ReturnCode.Success) - { - return GetSourceInstance(this, id); - } - return null; - } - - int _state = 1; - /// - /// Gets the current state number as defined by the TWAIN spec. - /// - /// - /// The state. - /// - public int State - { - get { return _state; } - private set - { - if (value > 0 && value < 8) - { - _state = value; - OnPropertyChanged("State"); - SafeAsyncSyncableRaiseOnEvent(OnStateChanged, StateChanged); - } - } - } - - /// - /// Gets the named state value as defined by the TWAIN spec. - /// - /// - /// The state. - /// - public State StateEx - { - get - { - return (State)_state; - } - } - - /// - /// Quick flag to check if the DSM has been opened. - /// - public bool IsDsmOpen { get { return State > 2; } } - - /// - /// Quick flag to check if a source has been opened. - /// - public bool IsSourceOpen { get { return State > 3; } } - - /// - /// Quick flag to check if a source has been enabled. - /// - public bool IsSourceEnabled { get { return State > 4; } } - - /// - /// Quick flag to check if a source is in the transferring state. - /// - public bool IsTransferring { get { return State > 5; } } - - /// - /// Whether to stop the transfer process when transfer error is encountered. - /// May be required on some sources. - /// - /// - /// true to stop on transfer error; otherwise, false. - /// - public bool StopOnTransferError { get; set; } - - /// - /// Gets the reason a source was disabled (dropped from state 5) if it's due to user action. - /// Mostly only or . - /// - /// - /// The dialog result. - /// - public Message DisableReason { get; private set; } - - /// - /// Opens the data source manager. This must be the first method used - /// before using other TWAIN functions. Calls to this must be followed by - /// when done with a TWAIN session. - /// - /// - public ReturnCode Open() - { - return Open(new InternalMessageLoopHook()); - } - - /// - /// Opens the data source manager. This must be the first method used - /// before using other TWAIN functions. Calls to this must be followed by - /// when done with a TWAIN session. - /// - /// The message loop hook. - /// - /// messageLoopHook - public ReturnCode Open(MessageLoopHook messageLoopHook) - { - if (messageLoopHook == null) { throw new ArgumentNullException("messageLoopHook"); } - - _msgLoopHook = messageLoopHook; - _msgLoopHook.Start(this); - var rc = ReturnCode.Failure; - _msgLoopHook.Invoke(() => - { - PlatformInfo.Current.Log.Debug("Thread {0}: OpenManager.", Thread.CurrentThread.ManagedThreadId); - - rc = ((ITwainSessionInternal)this).DGControl.Parent.OpenDsm(_msgLoopHook.Handle); - if (rc == ReturnCode.Success) - { - // if twain2 then get memory management functions - if ((_appId.DataFunctionalities & DataFunctionalities.Dsm2) == DataFunctionalities.Dsm2) - { - TWEntryPoint entry; - rc = ((ITwainSessionInternal)this).DGControl.EntryPoint.Get(out entry); - if (rc == ReturnCode.Success) - { - PlatformInfo.InternalCurrent.MemoryManager = entry; - PlatformInfo.Current.Log.Debug("Using TWAIN2 memory functions."); - } - else - { - Close(); - } - } - } - }); - return rc; - } - - /// - /// Closes the data source manager. - /// - /// - public ReturnCode Close() - { - var rc = ReturnCode.Failure; - _msgLoopHook?.Invoke(() => - { - PlatformInfo.Current.Log.Debug("Thread {0}: CloseManager.", Thread.CurrentThread.ManagedThreadId); - - rc = ((ITwainSessionInternal)this).DGControl.Parent.CloseDsm(_msgLoopHook.Handle); - if (rc == ReturnCode.Success) - { - PlatformInfo.InternalCurrent.MemoryManager = null; - _msgLoopHook.Stop(); - _msgLoopHook = null; - } - }); - return rc; - } - - - /// - /// Gets list of sources available in the system. - /// Only call this at state 2 or higher. - /// - /// - public IEnumerable GetSources() - { - return this; - } - - /// - /// Quick shortcut to open a source. - /// - /// Name of the source. - /// - public ReturnCode OpenSource(string sourceName) - { - var curSrc = CurrentSource; - if (curSrc != null) - { - // TODO: close any open sources first - - } - - var hit = this.Where(s => string.Equals(s.Name, sourceName)).FirstOrDefault(); - if (hit != null) - { - return hit.Open(); - } - return ReturnCode.Failure; - } - - /// - /// Quick shortcut to open a source. - /// - /// Id of the source. - /// - public ReturnCode OpenSource(int sourceId) - { - var curSrc = CurrentSource; - if (curSrc != null) - { - // TODO: close any open sources first - - } - - var hit = this.Where(s => s.Id == sourceId).FirstOrDefault(); - if (hit != null) - { - return hit.Open(); - } - return ReturnCode.Failure; - } - - /// - /// Gets the manager status. Only call this at state 2 or higher. - /// - /// - public TWStatus GetStatus() - { - TWStatus stat; - ((ITwainSessionInternal)this).DGControl.Status.GetManager(out stat); - return stat; - } - - /// - /// Gets the manager status. Only call this at state 3 or higher. - /// - /// - public TWStatusUtf8 GetStatusUtf8() - { - TWStatusUtf8 stat; - ((ITwainSessionInternal)this).DGControl.StatusUtf8.GetManager(out stat); - return stat; - } - - /// - /// Forces the stepping down of an opened source when things gets out of control. - /// Used when session state and source state become out of sync. - /// - /// State of the target. - public void ForceStepDown(int targetState) - { - PlatformInfo.Current.Log.Debug("Thread {0}: ForceStepDown.", Thread.CurrentThread.ManagedThreadId); - - bool origFlag = EnforceState; - EnforceState = false; - - // From the twain spec - // Stepping Back Down the States - // DG_CONTROL / DAT_PENDINGXFERS / MSG_ENDXFER → state 7 to 6 - // DG_CONTROL / DAT_PENDINGXFERS / MSG_RESET → state 6 to 5 - // DG_CONTROL / DAT_USERINTERFACE / MSG_DISABLEDS → state 5 to 4 - // DG_CONTROL / DAT_IDENTITY / MSG_CLOSEDS → state 4 to 3 - // Ignore the status returns from the calls prior to the one yielding the desired state. For instance, if a - // call during scanning returns TWCC_SEQERROR and the desire is to return to state 5, then use the - // following commands. - // DG_CONTROL / DAT_PENDINGXFERS / MSG_ENDXFER → state 7 to 6 - // DG_CONTROL / DAT_PENDINGXFERS / MSG_RESET → state 6 to 5 - // Being sure to confirm that DG_CONTROL / DAT_PENDINGXFERS / MSG_RESET returned - // success, the return status from DG_CONTROL / DAT_PENDINGXFERS / MSG_ENDXFER may - // be ignored. - - _msgLoopHook?.Invoke(() => - { - if (targetState < 7 && CurrentSource != null) - { - // not sure if really necessary but can't hurt to pin it - var pending = new TWPendingXfers(); - var handle = GCHandle.Alloc(pending, GCHandleType.Pinned); - try - { - ((ITwainSessionInternal)this).DGControl.PendingXfers.EndXfer(pending); - } - finally - { - handle.Free(); - } - } - if (targetState < 6 && CurrentSource != null) - { - var pending = new TWPendingXfers(); - var handle = GCHandle.Alloc(pending, GCHandleType.Pinned); - try - { - ((ITwainSessionInternal)this).DGControl.PendingXfers.Reset(pending); - } - finally - { - handle.Free(); - } - } - if (targetState < 5 && CurrentSource != null) - { - ((ITwainSessionInternal)this).DisableSource(); - } - if (targetState < 4 && CurrentSource != null) - { - CurrentSource.Close(); - } - if (targetState < 3) - { - Close(); - } - }); - EnforceState = origFlag; - } - - - /// - /// Occurs when has changed. - /// - public event EventHandler StateChanged; - /// - /// Occurs when has changed. - /// - public event EventHandler SourceChanged; - /// - /// Occurs when source has been disabled (back to state 4). - /// - public event EventHandler SourceDisabled; - /// - /// Occurs when the source has generated an event. - /// - public event EventHandler DeviceEvent; - /// - /// Occurs when a data transfer is ready. - /// - public event EventHandler TransferReady; - /// - /// Occurs when data has been transferred. - /// - public event EventHandler DataTransferred; - /// - /// Occurs when an error has been encountered during transfer. - /// - public event EventHandler TransferError; - - - #endregion - - #region INotifyPropertyChanged Members - - /// - /// Occurs when a property value changes. - /// - public event PropertyChangedEventHandler PropertyChanged; - - /// - /// Raises the event. - /// - /// Name of the property. - protected void OnPropertyChanged(string propertyName) - { - var syncer = SynchronizationContext; - if (syncer == null) - { - try - { - var hand = PropertyChanged; - if (hand != null) { hand(this, new PropertyChangedEventArgs(propertyName)); } - } - catch (Exception ex) - { - PlatformInfo.Current.Log.Error("PropertyChanged event error.", ex); - } - } - else - { - syncer.Post(o => - { - try - { - var hand = PropertyChanged; - if (hand != null) { hand(this, new PropertyChangedEventArgs(propertyName)); } - } - catch (Exception ex) - { - PlatformInfo.Current.Log.Error("PropertyChanged event error.", ex); - } - }, null); - } - } - - #endregion - - - #region IEnumerable Members - - /// - /// Gets the enumerator. - /// - /// - public IEnumerator GetEnumerator() - { - TWIdentity srcId; - var rc = ((ITwainSessionInternal)this).DGControl.Identity.GetFirst(out srcId); - while (rc == ReturnCode.Success) - { - yield return GetSourceInstance(this, srcId); - rc = ((ITwainSessionInternal)this).DGControl.Identity.GetNext(out srcId); - } - } - - #endregion - - #region IEnumerable Members - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - #endregion - - #region events overridables - - /// - /// Raises event and if applicable marshal it asynchronously to the thread - /// without exceptions. - /// - /// The on event function. - /// The handler. - void SafeAsyncSyncableRaiseOnEvent(Action onEventFunc, EventHandler handler) - { - var syncer = SynchronizationContext; - if (syncer == null) - { - try - { - onEventFunc(); - if (handler != null) { handler(this, EventArgs.Empty); } - } - catch (Exception ex) - { - PlatformInfo.Current.Log.Error("{0} event error.", ex, handler.Method.Name); - } - } - else - { - syncer.Post(o => - { - try - { - onEventFunc(); - if (handler != null) { handler(this, EventArgs.Empty); } - } - catch (Exception ex) - { - PlatformInfo.Current.Log.Error("{0} event error.", ex, handler.Method.Name); - } - }, null); - } - } - - /// - /// Raises event and if applicable marshal it synchronously to the thread - /// without exceptions. - /// - /// The type of the event arguments. - /// The on event function. - /// The handler. - /// The TEventArgs instance containing the event data. - void SafeSyncableRaiseOnEvent(Action onEventFunc, EventHandler handler, TEventArgs e) where TEventArgs : EventArgs - { - var syncer = SynchronizationContext; - if (syncer == null) - { - PlatformInfo.Current.Log.Debug("Trying to raise event {0} on thread {1} without sync.", e.GetType().Name, Thread.CurrentThread.ManagedThreadId); - - try - { - onEventFunc(e); - if (handler != null) { handler(this, e); } - } - catch (Exception ex) - { - PlatformInfo.Current.Log.Error("{0} event error.", ex, handler.Method.Name); - } - } - else - { - PlatformInfo.Current.Log.Debug("Trying to raise event {0} on thread {1} with sync.", e.GetType().Name, Thread.CurrentThread.ManagedThreadId); - // on some consumer desktop scanner with poor drivers this can frequently hang. there's nothing I can do here. - syncer.Send(o => - { - try - { - onEventFunc(e); - if (handler != null) { handler(this, e); } - } - catch (Exception ex) - { - PlatformInfo.Current.Log.Error("{0} event error.", ex, handler.Method.Name); - } - }, null); - } - } - - /// - /// Called when changed. - /// - protected virtual void OnStateChanged() { } - - /// - /// Called when changed. - /// - protected virtual void OnSourceChanged() { } - - /// - /// Called when source has been disabled (back to state 4). - /// - protected virtual void OnSourceDisabled() { } - - /// - /// Called when the source has generated an event. - /// - /// The instance containing the event data. - protected virtual void OnDeviceEvent(DeviceEventArgs e) { } - - /// - /// Called when a data transfer is ready. - /// - /// The instance containing the event data. - protected virtual void OnTransferReady(TransferReadyEventArgs e) { } - - /// - /// Called when data has been transferred. - /// - /// The instance containing the event data. - protected virtual void OnDataTransferred(DataTransferredEventArgs e) { } - - /// - /// Called when an error has been encountered during transfer. - /// - /// The instance containing the event data. - protected virtual void OnTransferError(TransferErrorEventArgs e) { } - - #endregion - } -} diff --git a/src/NTwain/TwainSessionInternal.cs b/src/NTwain/TwainSessionInternal.cs deleted file mode 100644 index 2d80645..0000000 --- a/src/NTwain/TwainSessionInternal.cs +++ /dev/null @@ -1,345 +0,0 @@ -using NTwain.Data; -using NTwain.Internals; -using NTwain.Interop; -using NTwain.Triplets; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading; - -namespace NTwain -{ - // for internal pieces since the main twain session file is getting too long - - partial class TwainSession : ITwainSessionInternal, IWinMessageFilter - { - #region ITwainSessionInternal Members - - MessageLoopHook _msgLoopHook; - MessageLoopHook ITwainSessionInternal.MessageLoopHook { get { return _msgLoopHook; } } - - /// - /// Gets the app id used for the session. - /// - /// The app id. - TWIdentity ITwainSessionInternal.AppId { get { return _appId; } } - - bool _closeRequested; - bool ITwainSessionInternal.CloseDSRequested { get { return _closeRequested; } } - - void ITwainSessionInternal.UpdateCallback() - { - if (State < 4) - { - _callbackObj = null; - } - else - { - ReturnCode rc = ReturnCode.Failure; - // per the spec (8-10) apps for 2.2 or higher uses callback2 so try this first - if (_appId.ProtocolMajor > 2 || (_appId.ProtocolMajor >= 2 && _appId.ProtocolMinor >= 2)) - { - var cb = new TWCallback2(HandleCallback); - rc = ((ITwainSessionInternal)this).DGControl.Callback2.RegisterCallback(cb); - - if (rc == ReturnCode.Success) - { - PlatformInfo.Current.Log.Debug("Registered callback2 OK."); - _callbackObj = cb; - } - } - - if (rc != ReturnCode.Success) - { - // always try old callback - var cb = new TWCallback(HandleCallback); - - rc = ((ITwainSessionInternal)this).DGControl.Callback.RegisterCallback(cb); - - if (rc == ReturnCode.Success) - { - PlatformInfo.Current.Log.Debug("Registered callback OK."); - _callbackObj = cb; - } - } - } - } - - void ITwainSessionInternal.ChangeState(int newState, bool notifyChange) - { - _state = newState; - if (notifyChange) - { - OnPropertyChanged("State"); - SafeAsyncSyncableRaiseOnEvent(OnStateChanged, StateChanged); - } - } - - ICommittable ITwainSessionInternal.GetPendingStateChanger(int newState) - { - return new TentativeStateCommitable(this, newState); - } - - void ITwainSessionInternal.ChangeCurrentSource(DataSource source) - { - CurrentSource = source; - DisableReason = Message.Null; - OnPropertyChanged("CurrentSource"); - SafeAsyncSyncableRaiseOnEvent(OnSourceChanged, SourceChanged); - } - - void ITwainSessionInternal.SafeSyncableRaiseEvent(DataTransferredEventArgs e) - { - SafeSyncableRaiseOnEvent(OnDataTransferred, DataTransferred, e); - } - void ITwainSessionInternal.SafeSyncableRaiseEvent(TransferErrorEventArgs e) - { - SafeSyncableRaiseOnEvent(OnTransferError, TransferError, e); - } - void ITwainSessionInternal.SafeSyncableRaiseEvent(TransferReadyEventArgs e) - { - SafeSyncableRaiseOnEvent(OnTransferReady, TransferReady, e); - } - - DGAudio _dgAudio; - DGAudio ITwainSessionInternal.DGAudio - { - get - { - if (_dgAudio == null) { _dgAudio = new DGAudio(this); } - return _dgAudio; - } - } - - DGControl _dgControl; - DGControl ITripletControl.DGControl { get { return DGControl; } } - protected DGControl DGControl - { - get - { - if (_dgControl == null) { _dgControl = new DGControl(this); } - return _dgControl; - } - } - - - DGImage _dgImage; - DGImage ITripletControl.DGImage { get { return DGImage; } } - protected DGImage DGImage - { - get - { - if (_dgImage == null) { _dgImage = new DGImage(this); } - return _dgImage; - } - } - - DGCustom _dgCustom; - DGCustom ITripletControl.DGCustom { get { return DGCustom; } } - protected DGCustom DGCustom - { - get - { - if (_dgCustom == null) { _dgCustom = new DGCustom(this); } - return _dgCustom; - } - } - - - /// - /// Enables the source to start transferring. - /// - /// The mode. - /// if set to true any driver UI will display as modal. - /// The window handle if modal. - /// - ReturnCode ITwainSessionInternal.EnableSource(SourceEnableMode mode, bool modal, IntPtr windowHandle) - { - _closeRequested = false; - DisableReason = Message.Null; - var rc = ReturnCode.Failure; - - _msgLoopHook?.Invoke(() => - { - PlatformInfo.Current.Log.Debug("Thread {0}: EnableSource with {1}.", Thread.CurrentThread.ManagedThreadId, mode); - - - _twui = new TWUserInterface(); - _twui.ShowUI = mode == SourceEnableMode.ShowUI; - _twui.ModalUI = modal; - _twui.hParent = windowHandle; - - if (mode == SourceEnableMode.ShowUIOnly) - { - rc = ((ITwainSessionInternal)this).DGControl.UserInterface.EnableDSUIOnly(_twui); - } - else - { - rc = ((ITwainSessionInternal)this).DGControl.UserInterface.EnableDS(_twui); - } - }); - return rc; - } - - bool _disabling; - ReturnCode ITwainSessionInternal.DisableSource() - { - var rc = ReturnCode.Failure; - if (!_disabling) // temp hack as a workaround to this being called from multiple threads (xfer logic & closedsreq msg) - { - _disabling = true; - try - { - _msgLoopHook?.Invoke(() => - { - PlatformInfo.Current.Log.Debug("Thread {0}: DisableSource.", Thread.CurrentThread.ManagedThreadId); - - rc = ((ITwainSessionInternal)this).DGControl.UserInterface.DisableDS(_twui); - if (rc == ReturnCode.Success) - { - SafeAsyncSyncableRaiseOnEvent(OnSourceDisabled, SourceDisabled); - } - }); - } - finally - { - _disabling = false; - } - } - return rc; - } - - - #endregion - - #region IWinMessageFilter Members - - /// - /// Checks and handles the message if it's a TWAIN message. - /// - /// The window handle. - /// The message. - /// The w parameter. - /// The l parameter. - /// - /// true if handled internally. - /// - public bool IsTwainMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam) - { - bool handled = false; - // this handles the message from a typical WndProc message loop and check if it's from the TWAIN source. - if (_state >= 5) - { - // transform it into a pointer for twain - IntPtr msgPtr = IntPtr.Zero; - try - { - var winMsg = new MESSAGE(hwnd, msg, wParam, lParam); - - // no need to do another lock call when using marshal alloc - msgPtr = Marshal.AllocHGlobal(Marshal.SizeOf(winMsg)); - Marshal.StructureToPtr(winMsg, msgPtr, false); - - var evt = new TWEvent(); - evt.pEvent = msgPtr; - if (handled = (((ITwainSessionInternal)this).DGControl.Event.ProcessEvent(evt) == ReturnCode.DSEvent)) - { - PlatformInfo.Current.Log.Debug("Thread {0}: HandleWndProcMessage at state {1} with MSG={2}.", Thread.CurrentThread.ManagedThreadId, State, evt.TWMessage); - - HandleSourceMsg(evt.TWMessage); - } - } - finally - { - if (msgPtr != IntPtr.Zero) { Marshal.FreeHGlobal(msgPtr); } - } - } - return handled; - } - - #endregion - - #region handle twain ds message - - - ReturnCode HandleCallback(TWIdentity origin, TWIdentity destination, DataGroups dg, DataArgumentType dat, Message msg, IntPtr data) - { - if (origin != null && CurrentSource != null && origin.Id == CurrentSource.Identity.Id && _state >= 5) - { - PlatformInfo.Current.Log.Debug("Thread {0}: CallbackHandler at state {1} with MSG={2}.", Thread.CurrentThread.ManagedThreadId, State, msg); - // spec says we must handle this on the thread that enabled the DS. - // by using the internal dispatcher this will be the case. - - // In any event the trick to get this thing working is to return from the callback first - // before trying to process the msg or there will be unpredictable errors. - - // changed to sync invoke instead of begininvoke for hp scanjet. - if (origin.ProductName.IndexOf("scanjet", StringComparison.OrdinalIgnoreCase) > -1) - { - _msgLoopHook?.Invoke(() => - { - HandleSourceMsg(msg); - }); - } - else - { - _msgLoopHook?.BeginInvoke(() => - { - HandleSourceMsg(msg); - }); - } - return ReturnCode.Success; - } - return ReturnCode.Failure; - } - - // final method that handles msg from the source, whether it's from wndproc or callbacks - void HandleSourceMsg(Message msg) - { - PlatformInfo.Current.Log.Debug("Got TWAIN msg " + msg); - switch (msg) - { - case Message.XferReady: - if (State < 6) - { - State = 6; - } - TransferLogic.DoTransferRoutine(this); - break; - case Message.DeviceEvent: - TWDeviceEvent de; - var rc = ((ITwainSessionInternal)this).DGControl.DeviceEvent.Get(out de); - if (rc == ReturnCode.Success) - { - SafeSyncableRaiseOnEvent(OnDeviceEvent, DeviceEvent, new DeviceEventArgs(de)); - } - break; - case Message.CloseDSReq: - case Message.CloseDSOK: - DisableReason = msg; - // even though it says closeDS it's really disable. - // dsok is sent if source is enabled with uionly - - // some sources send this at other states so do a step down - if (State > 5) - { - // rather than do a close here let the transfer logic handle the close down now - //ForceStepDown(4); - _closeRequested = true; - } - else if (State == 5) - { - // needs this state check since some source sends this more than once - ((ITwainSessionInternal)this).DisableSource(); - } - break; - } - } - - #endregion - } -} diff --git a/src/NTwain/TwainStateException.cs b/src/NTwain/TwainStateException.cs deleted file mode 100644 index 5f32df6..0000000 --- a/src/NTwain/TwainStateException.cs +++ /dev/null @@ -1,124 +0,0 @@ -using NTwain.Data; -using System; -using System.Runtime.Serialization; -using System.Security.Permissions; - -namespace NTwain -{ - /// - /// Represents an exception from calling a TWAIN triplet operation in the wrong state. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] - [Serializable] - public class TwainStateException : TwainException - { - /// - /// Initializes a new instance of the class. - /// - public TwainStateException() { } - - /// - /// Initializes a new instance of the class. - /// - /// The actual state number. - /// The minimum state allowed. - /// The maximum state allowed. - /// The data group used. - /// The data argument type used. - /// The twain message used. - /// The message. - public TwainStateException(int currentState, int minStateExpected, int maxStateExpected, DataGroups dataGroup, DataArgumentType argumentType, Message twainMessage, string message) - : base(default(ReturnCode), message) - { - ActualState = currentState; - MinStateExpected = minStateExpected; - MaxStateExpected = maxStateExpected; - DataGroup = dataGroup; - ArgumentType = argumentType; - TwainMessage = twainMessage; - } - - /// - /// Initializes a new instance of the class. - /// - /// The that holds the serialized object data about the exception being thrown. - /// The that contains contextual information about the source or destination. - /// - /// The parameter is null. - /// - /// - /// The class name is null or is zero (0). - /// - protected TwainStateException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - if (info != null) - { - MinStateExpected = info.GetInt32("MIN"); - MaxStateExpected = info.GetInt32("MAX"); - ActualState = info.GetInt32("State"); - DataGroup = (DataGroups)info.GetUInt32("DG"); - ArgumentType = (DataArgumentType)info.GetUInt16("DAT"); - TwainMessage = (Message)info.GetUInt16("MSG"); - } - } - - /// - /// When overridden in a derived class, sets the with information about the exception. - /// - /// The that holds the serialized object data about the exception being thrown. - /// The that contains contextual information about the source or destination. - /// - /// The parameter is a null reference (Nothing in Visual Basic). - /// - /// - /// - /// - /// - [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)] - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - if (info != null) - { - info.AddValue("MIN", MinStateExpected); - info.AddValue("MAX", MaxStateExpected); - info.AddValue("State", ActualState); - info.AddValue("DG", DataGroup); - info.AddValue("DAT", ArgumentType); - info.AddValue("MSG", TwainMessage); - } - base.GetObjectData(info, context); - } - - /// - /// Gets the allowed minimum state. - /// - /// The minimum. - public int MinStateExpected { get; private set; } - /// - /// Gets the allowed maximum state. - /// - /// The maximum. - public int MaxStateExpected { get; private set; } - /// - /// Gets the actual state number. - /// - /// The state. - public int ActualState { get; private set; } - /// - /// Gets the triplet data group. - /// - /// The data group. - public DataGroups DataGroup { get; private set; } - /// - /// Gets the triplet data argument type. - /// - /// The type of the argument. - public DataArgumentType ArgumentType { get; private set; } - /// - /// Gets the triplet message. - /// - /// The twain message. - public Message TwainMessage { get; private set; } - } -} diff --git a/src/NTwain/WpfImageTools.cs b/src/NTwain/WpfImageTools.cs deleted file mode 100644 index 2b0dae9..0000000 --- a/src/NTwain/WpfImageTools.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System.IO; -using System.Windows.Media.Imaging; - -namespace NTwain -{ - // this is in its own class to not depend on PresentationCore.dll on mono if it's not used. - - /// - /// Contains extension methods for wpf images. - /// - public static class WpfImageTools - { - /// - /// Loads a into WPF . The image created - /// will be a copy so the stream can be disposed once this call returns. - /// - /// The image stream. - /// - public static BitmapSource ConvertToWpfBitmap(this Stream stream) - { - return ConvertToWpfBitmap(stream, 0, 0); - } - - /// - /// Loads a into WPF . The image created - /// will be a copy so the stream can be disposed once this call returns. - /// - /// The image stream. - /// Max width of the decoded image. Pass 0 to use default. - /// Max height of the decoded image. Pass 0 to use default. - /// - public static BitmapSource ConvertToWpfBitmap(this Stream stream, int decodeWidth, int decodeHeight) - { - if (stream != null) - { - var image = new BitmapImage(); - image.BeginInit(); - image.CacheOption = BitmapCacheOption.OnLoad; - image.DecodePixelHeight = decodeHeight; - image.DecodePixelWidth = decodeWidth; - image.StreamSource = stream; - image.EndInit(); - if (image.CanFreeze) - { - image.Freeze(); - } - return image; - } - return null; - } - - - ///// - ///// Converts an to WPF if the image - ///// is a . - ///// - ///// The image to convert. - ///// - //public static BitmapSource ConvertToWpfBitmap(this Image image) - //{ - // var bmp = image as Bitmap; - // if (bmp != null) - // { - // using (var hbm = new SafeHBitmapHandle(bmp.GetHbitmap(), true)) - // { - // return System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( - // hbm.DangerousGetHandle(), - // IntPtr.Zero, - // System.Windows.Int32Rect.Empty, - // BitmapSizeOptions.FromEmptyOptions()); - // } - // } - // return null; - //} - - //class SafeHBitmapHandle : SafeHandleZeroOrMinusOneIsInvalid - //{ - // [SecurityCritical] - // public SafeHBitmapHandle(IntPtr preexistingHandle, bool ownsHandle) - // : base(ownsHandle) - // { - // SetHandle(preexistingHandle); - // } - - // protected override bool ReleaseHandle() - // { - // return NativeMethods.DeleteObject(handle); - // } - //} - } -} diff --git a/Tests/NTwain.Tests/Sign.snk b/src/Sign.snk similarity index 100% rename from Tests/NTwain.Tests/Sign.snk rename to src/Sign.snk