Initial move from old twain-in-dotnet.

This commit is contained in:
soukoku
2014-04-02 19:01:21 -04:00
parent d34b359f8d
commit 0a39a47d3b
116 changed files with 38426 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using NTwain.Data;
using NTwain.Values;
namespace NTwain.Triplets
{
sealed class AudioFileXfer : OpBase
{
internal AudioFileXfer(TwainSession session) : base(session) { }
/// <summary>
/// This operation is used to initiate the transfer of audio from the Source to the application via the
/// disk-file transfer mechanism. It causes the transfer to begin.
/// </summary>
/// <returns></returns>
public ReturnCode Get()
{
Session.VerifyState(6, 6, DataGroups.Audio, DataArgumentType.AudioFileXfer, Message.Get);
IntPtr z = IntPtr.Zero;
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, DataGroups.Audio, DataArgumentType.AudioFileXfer, Message.Get, ref z);
}
}
}

View File

@@ -0,0 +1,42 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class AudioInfo : OpBase
{
internal AudioInfo(TwainSession session) : base(session) { }
/// <summary>
/// Used to get the information of the current audio data ready to transfer.
/// </summary>
/// <param name="info">The info.</param>
/// <returns></returns>
public ReturnCode Get(out TWAudioInfo info)
{
Session.VerifyState(6, 7, DataGroups.Audio, DataArgumentType.AudioInfo, Message.Get);
info = new TWAudioInfo();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Get, info);
}
}
}

View File

@@ -0,0 +1,45 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using NTwain.Data;
using NTwain.Values;
namespace NTwain.Triplets
{
sealed class AudioNativeXfer : OpBase
{
internal AudioNativeXfer(TwainSession session) : base(session) { }
/// <summary>
/// Causes the transfer of an audio data from the Source to the application, via the Native
/// transfer mechanism, to begin. The resulting data is stored in main memory in a single block.
/// 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.
/// </summary>
/// <param name="handle">The handle.</param>
/// <returns></returns>
public ReturnCode Get(ref IntPtr handle)
{
Session.VerifyState(6, 6, DataGroups.Audio, DataArgumentType.AudioNativeXfer, Message.Get);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, DataGroups.Audio, DataArgumentType.AudioNativeXfer, Message.Get, ref handle);
}
}
}

View File

@@ -0,0 +1,68 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace NTwain.Triplets
{
/// <summary>
/// Class for grouping triplet operations under the Audio data group.
/// </summary>
public sealed class DGAudio
{
TwainSession _session;
internal DGAudio(TwainSession 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;
public 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;
}
}
}
}

View File

@@ -0,0 +1,43 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
sealed class Callback : OpBase
{
internal Callback(TwainSession session) : base(session) { }
/// <summary>
/// This triplet is sent to the DSM by the Application to register the applications entry point with
/// the DSM, so that the DSM can use callbacks to inform the application of events generated by the
/// DS.
/// </summary>
/// <param name="callback">The callback.</param>
/// <returns></returns>
public ReturnCode RegisterCallback(TWCallback callback)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Callback, Message.RegisterCallback);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.RegisterCallback, callback);
}
}
}

View File

@@ -0,0 +1,43 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
sealed class Callback2 : OpBase
{
internal Callback2(TwainSession session) : base(session) { }
/// <summary>
/// This triplet is sent to the DSM by the Application to register the applications entry point with
/// the DSM, so that the DSM can use callbacks to inform the application of events generated by the
/// DS.
/// </summary>
/// <param name="callback">The callback.</param>
/// <returns></returns>
public ReturnCode RegisterCallback(TWCallback2 callback)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Callback, Message.RegisterCallback);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.RegisterCallback, callback);
}
}
}

View File

@@ -0,0 +1,148 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class Capability : OpBase
{
internal Capability(TwainSession session) : base(session) { }
/// <summary>
/// Returns the Sources Current, Default and Available Values for a specified capability.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode Get(TWCapability capability)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.Get);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Get, capability);
}
/// <summary>
/// Returns the Sources Current Value for the specified capability.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode GetCurrent(TWCapability capability)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.GetCurrent);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.GetCurrent, capability);
}
/// <summary>
/// Returns the Sources Default Value. This is the Sources preferred default value.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode GetDefault(TWCapability capability)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.GetDefault);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.GetDefault, capability);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode GetHelp(TWCapability capability)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.GetHelp);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.GetHelp, capability);
}
/// <summary>
/// Returns a label suitable for use in a GUI, for instance "Resolution:"
/// for ICapXRESOLUTION.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode GetLabel(TWCapability capability)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.GetLabel);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.GetLabel, capability);
}
/// <summary>
/// Return all of the labels for a capability of type <see cref="TWArray"/> or <see cref="TWEnumeration"/>, for example
/// "US Letter" for ICapSupportedSizes TWSS_USLETTER.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode GetLabelEnum(TWCapability capability)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.GetLabelEnum);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.GetLabelEnum, capability);
}
/// <summary>
/// Returns the Sources support status of this capability.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode QuerySupport(TWCapability capability)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.QuerySupport);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.QuerySupport, capability);
}
/// <summary>
/// Change the Current Value of the specified capability back to its power-on value and return the
/// new Current Value.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode Reset(TWCapability capability)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.Reset);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Reset, capability);
}
/// <summary>
/// This command resets all of the current values and constraints to their defaults for all of the
/// negotiable capabilities supported by the driver.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode ResetAll(TWCapability capability)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.ResetAll);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.ResetAll, capability);
}
/// <summary>
/// Changes the Current Value(s) and Available Values of the specified capability to those specified
/// by the application.
/// Current Values are set when the container is a <see cref="TWOneValue"/> or <see cref="TWArray"/>. Available and
/// Current Values are set when the container is a <see cref="TWEnumeration"/> or <see cref="TWRange"/>.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode Set(TWCapability capability)
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.Capability, Message.Set);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Set, capability);
}
}
}

View File

@@ -0,0 +1,57 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class CustomDSData : OpBase
{
internal CustomDSData(TwainSession session) : base(session) { }
/// <summary>
/// This operation is used by the application to query the data source for its current settings, e.g.
/// DPI, paper size, color format. The actual format of the data is data source dependent and not
/// defined by TWAIN.
/// </summary>
/// <param name="customData">The custom data.</param>
/// <returns></returns>
public ReturnCode Get(out TWCustomDSData customData)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.CustomDSData, Message.Get);
customData = new TWCustomDSData();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Get, customData);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="customData">The custom data.</param>
/// <returns></returns>
public ReturnCode Set(TWCustomDSData customData)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.CustomDSData, Message.Set);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Set, customData);
}
}
}

View File

@@ -0,0 +1,37 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class DeviceEvent : OpBase
{
internal DeviceEvent(TwainSession session) : base(session) { }
public ReturnCode Get(out TWDeviceEvent sourceDeviceEvent)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.DeviceEvent, Message.Get);
sourceDeviceEvent = new TWDeviceEvent();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Get, sourceDeviceEvent);
}
}
}

View File

@@ -0,0 +1,42 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
sealed class EntryPoint : OpBase
{
internal EntryPoint(TwainSession session) : base(session) { }
/// <summary>
/// Gets the function entry points for twain 2.0 or higher.
/// </summary>
/// <param name="entryPoint">The entry point.</param>
/// <returns></returns>
public ReturnCode Get(out TWEntryPoint entryPoint)
{
Session.VerifyState(3, 3, DataGroups.Control, DataArgumentType.EntryPoint, Message.Get);
entryPoint = new TWEntryPoint();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Get, entryPoint);
}
}
}

View File

@@ -0,0 +1,49 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
sealed class Event : OpBase
{
internal Event(TwainSession session) : base(session) { }
/// <summary>
/// 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 applications 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 Sources 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.
/// </summary>
/// <param name="theEvent">The event.</param>
/// <returns></returns>
public ReturnCode ProcessEvent(TWEvent theEvent)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Event, Message.ProcessEvent);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.ProcessEvent, theEvent);
}
}
}

View File

@@ -0,0 +1,179 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class FileSystem : OpBase
{
internal FileSystem(TwainSession session) : base(session) { }
/// <summary>
/// This operation selects the destination directory within the Source (camera, storage, etc), where
/// images captured using CapAutomaticCapture will be stored. This command only selects
/// 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.
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <returns></returns>
public ReturnCode AutomaticCaptureDirectory(TWFileSystem fileSystem)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.AutomaticCaptureDirectory);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.AutomaticCaptureDirectory, fileSystem);
}
/// <summary>
/// This operation selects the current device within the Source (camera, storage, etc). If the device is
/// a <see cref="FileType.Domain"/>, then this command enters a directory that can contain <see cref="FileType.Host"/> files. If the
/// device is a <see cref="FileType.Host"/>, then this command enters a directory that can contain
/// <see cref="FileType.Directory"/> files. If the device is a <see cref="FileType.Directory"/>, then this command enters a
/// directory that can contain <see cref="FileType.Directory"/> or <see cref="FileType.Image"/> files.
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <returns></returns>
public ReturnCode ChangeDirectory(TWFileSystem fileSystem)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.ChangeDirectory);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.ChangeDirectory, fileSystem);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <returns></returns>
public ReturnCode Copy(TWFileSystem fileSystem)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.Copy);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Copy, fileSystem);
}
/// <summary>
/// This operation creates a new directory within the current directory. Pathnames are not allowed,
/// only the name of the new directory can be specified.
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <returns></returns>
public ReturnCode CreateDirectory(TWFileSystem fileSystem)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.CreateDirectory);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.CreateDirectory, fileSystem);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <returns></returns>
public ReturnCode Delete(TWFileSystem fileSystem)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.Delete);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Delete, fileSystem);
}
/// <summary>
/// This operation formats the specified storage. This operation destroys all images and subdirectories
/// under the selected device. Use with caution.
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <returns></returns>
public ReturnCode FormatMedia(TWFileSystem fileSystem)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.FormatMedia);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.FormatMedia, fileSystem);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <returns></returns>
public ReturnCode GetClose(TWFileSystem fileSystem)
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.FileSystem, Message.GetClose);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.GetClose, fileSystem);
}
/// <summary>
/// This operation gets the first filename in a directory, and returns information about that file (the
/// same information that can be retrieved with GetInfo).
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <returns></returns>
public ReturnCode GetFirstFile(TWFileSystem fileSystem)
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.FileSystem, Message.GetFirstFile);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.GetFirstFile, fileSystem);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <returns></returns>
public ReturnCode GetInfo(TWFileSystem fileSystem)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.FileSystem, Message.GetInfo);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.GetInfo, fileSystem);
}
/// <summary>
/// This operation gets the next filename in a directory, and returns information about that file (the
/// same information that can be retrieved with GetInfo).
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <returns></returns>
public ReturnCode GetNextFile(TWFileSystem fileSystem)
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.FileSystem, Message.GetNextFile);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.GetNextFile, fileSystem);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <returns></returns>
public ReturnCode Rename(TWFileSystem fileSystem)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.FileSystem, Message.Rename);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Rename, fileSystem);
}
}
}

View File

@@ -0,0 +1,129 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class Identity : OpBase
{
internal Identity(TwainSession session) : base(session) { }
/// <summary>
/// When an application is finished with a Source, it must formally close the session between them
/// using this operation. This is necessary in case the Source only supports connection with a single
/// 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.
/// </summary>
/// <returns></returns>
internal ReturnCode CloseDS()
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Identity, Message.CloseDS);
var rc = PInvoke.DsmEntry(Session.AppId, Message.CloseDS, Session.SourceId);
if (rc == ReturnCode.Success)
{
Session.State = 3;
}
return rc;
}
/// <summary>
/// Gets the identification information of the system default Source.
/// </summary>
/// <param name="source">The source.</param>
/// <returns></returns>
public ReturnCode GetDefault(out TWIdentity source)
{
Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.Identity, Message.GetDefault);
source = new TWIdentity();
return PInvoke.DsmEntry(Session.AppId, Message.GetDefault, source);
}
/// <summary>
/// The application may obtain the first Source that are currently available on the system which
/// match the applications supported groups.
/// </summary>
/// <param name="source">The source.</param>
/// <returns></returns>
public ReturnCode GetFirst(out TWIdentity source)
{
Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.Identity, Message.GetFirst);
source = new TWIdentity();
return PInvoke.DsmEntry(Session.AppId, Message.GetFirst, source);
}
/// <summary>
/// The application may obtain the next Source that are currently available on the system which
/// match the applications supported groups.
/// </summary>
/// <param name="source">The source.</param>
/// <returns></returns>
public ReturnCode GetNext(out TWIdentity source)
{
Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.Identity, Message.GetNext);
source = new TWIdentity();
return PInvoke.DsmEntry(Session.AppId, Message.GetNext, source);
}
/// <summary>
/// Loads the specified Source into main memory and causes its initialization.
/// </summary>
/// <param name="source">The source.</param>
/// <returns></returns>
internal ReturnCode OpenDS(TWIdentity source)
{
Session.VerifyState(3, 3, DataGroups.Control, DataArgumentType.Identity, Message.OpenDS);
var rc = PInvoke.DsmEntry(Session.AppId, Message.OpenDS, source);
if (rc == ReturnCode.Success)
{
Session.State = 4;
}
return rc;
}
/// <summary>
/// It allows an application to set the
/// default TWAIN driver, which is reported back by GetDefault.
/// </summary>
/// <param name="source">The source.</param>
/// <returns></returns>
public ReturnCode Set(TWIdentity source)
{
Session.VerifyState(3, 3, DataGroups.Control, DataArgumentType.Identity, Message.Set);
return PInvoke.DsmEntry(Session.AppId, Message.Set, source);
}
/// <summary>
/// This operation should be invoked when the user chooses Select Source... from the applications
/// File menu (or an equivalent user action). The Source selected becomes the system default Source.
/// </summary>
/// <param name="source">The source.</param>
/// <returns></returns>
public ReturnCode UserSelect(out TWIdentity source)
{
Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.Identity, Message.UserSelect);
source = new TWIdentity();
return PInvoke.DsmEntry(Session.AppId, Message.UserSelect, source);
}
}
}

View File

@@ -0,0 +1,69 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using NTwain.Data;
using NTwain.Values;
using System.Runtime.InteropServices;
namespace NTwain.Triplets
{
sealed class Parent : OpBase
{
internal Parent(TwainSession session) : base(session) { }
/// <summary>
/// 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.
/// </summary>
/// <param name="handle">The handle. On Windows = points to the window handle (hWnd) that will act as the Sources
/// "parent". On Macintosh = should be a NULL value.</param>
/// <returns></returns>
public ReturnCode CloseDsm(ref IntPtr handle)
{
Session.VerifyState(3, 3, DataGroups.Control, DataArgumentType.Parent, Message.CloseDsm);
var rc = PInvoke.DsmEntry(Session.AppId, null, DataGroups.Control, DataArgumentType.Parent, Message.CloseDsm, ref handle);
if (rc == ReturnCode.Success)
{
Session.State = 2;
}
return rc;
}
/// <summary>
/// Causes the Source Manager to initialize itself. This operation must be executed before any other
/// operations will be accepted by the Source Manager.
/// </summary>
/// <param name="handle">The handle. On Windows = points to the window handle (hWnd) that will act as the Sources
/// "parent". On Macintosh = should be a NULL value.</param>
/// <returns></returns>
public ReturnCode OpenDsm(ref IntPtr handle)
{
Session.VerifyState(1, 2, DataGroups.Control, DataArgumentType.Parent, Message.OpenDsm);
var rc = PInvoke.DsmEntry(Session.AppId, null, DataGroups.Control, DataArgumentType.Parent, Message.OpenDsm, ref handle);
if (rc == ReturnCode.Success)
{
Session.State = 3;
}
return rc;
}
}
}

View File

@@ -0,0 +1,42 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class PassThru : OpBase
{
internal PassThru(TwainSession session) : base(session) { }
/// <summary>
/// PASSTHRU is intended for the use of Source writers writing diagnostic applications. It allows
/// raw communication with the currently selected device in the Source.
/// </summary>
/// <param name="sourcePassThru">The source pass thru.</param>
/// <returns></returns>
public ReturnCode PassThrough(TWPassThru sourcePassThru)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.PassThru, Message.PassThru);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.PassThru, sourcePassThru);
}
}
}

View File

@@ -0,0 +1,81 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
sealed class PendingXfers : OpBase
{
internal PendingXfers(TwainSession session) : base(session) { }
/// <summary>
/// This triplet is used to cancel or terminate a transfer. Issued in state 6, this triplet cancels the next
/// pending transfer, discards the transfer data, and decrements the pending transfers count. In
/// 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.
/// </summary>
/// <param name="pendingXfers">The pending xfers.</param>
/// <returns></returns>
internal ReturnCode EndXfer(TWPendingXfers pendingXfers)
{
Session.VerifyState(6, 7, DataGroups.Control, DataArgumentType.PendingXfers, Message.EndXfer);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.EndXfer, pendingXfers);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="pendingXfers">The pending xfers.</param>
/// <returns></returns>
public ReturnCode Get(TWPendingXfers pendingXfers)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.PendingXfers, Message.Get);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Get, pendingXfers);
}
/// <summary>
/// Sets the number of pending transfers in the Source to zero.
/// </summary>
/// <param name="pendingXfers">The pending xfers.</param>
/// <returns></returns>
internal ReturnCode Reset(TWPendingXfers pendingXfers)
{
Session.VerifyState(6, 6, DataGroups.Control, DataArgumentType.PendingXfers, Message.Reset);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Reset, pendingXfers);
}
/// <summary>
/// If CapAutoScan is TRUE, this command will stop the operation of the scanners automatic
/// feeder. No other action is taken.
/// </summary>
/// <param name="pendingXfers">The pending xfers.</param>
/// <returns></returns>
public ReturnCode StopFeeder(TWPendingXfers pendingXfers)
{
Session.VerifyState(6, 6, DataGroups.Control, DataArgumentType.PendingXfers, Message.StopFeeder);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.StopFeeder, pendingXfers);
}
}
}

View File

@@ -0,0 +1,84 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class SetupFileXfer : OpBase
{
internal SetupFileXfer(TwainSession session) : base(session) { }
/// <summary>
/// Returns information about the file into which the Source has or will put the acquired image
/// or audio data.
/// </summary>
/// <param name="setupFileXfer">The setup file xfer.</param>
/// <returns></returns>
public ReturnCode Get(out TWSetupFileXfer setupFileXfer)
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.SetupFileXfer, Message.Get);
setupFileXfer = new TWSetupFileXfer();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Get, setupFileXfer);
}
/// <summary>
/// Returns information for the default image or audio file.
/// </summary>
/// <param name="setupFileXfer">The setup file xfer.</param>
/// <returns></returns>
public ReturnCode GetDefault(out TWSetupFileXfer setupFileXfer)
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.SetupFileXfer, Message.GetDefault);
setupFileXfer = new TWSetupFileXfer();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.GetDefault, setupFileXfer);
}
/// <summary>
/// Resets the current file information to the image or audio default file information and
/// returns that default information.
/// </summary>
/// <param name="setupFileXfer">The setup file xfer.</param>
/// <returns></returns>
public ReturnCode Reset(out TWSetupFileXfer setupFileXfer)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.SetupFileXfer, Message.Reset);
setupFileXfer = new TWSetupFileXfer();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Reset, setupFileXfer);
}
/// <summary>
/// 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
/// </summary>
/// <param name="setupFileXfer">The setup file xfer.</param>
/// <returns></returns>
public ReturnCode Set(TWSetupFileXfer setupFileXfer)
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.SetupFileXfer, Message.Set);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Set, setupFileXfer);
}
}
}

View File

@@ -0,0 +1,43 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class SetupMemXfer : OpBase
{
internal SetupMemXfer(TwainSession session) : base(session) { }
/// <summary>
/// Returns the Sources preferred, minimum, and maximum allocation sizes for transfer memory
/// buffers.
/// </summary>
/// <param name="setupMemXfer">The setup mem xfer.</param>
/// <returns></returns>
public ReturnCode Get(out TWSetupMemXfer setupMemXfer)
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.SetupMemXfer, Message.Get);
setupMemXfer = new TWSetupMemXfer();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Get, setupMemXfer);
}
}
}

View File

@@ -0,0 +1,54 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class Status : OpBase
{
internal Status(TwainSession session) : base(session) { }
/// <summary>
/// Returns the current Condition Code for the Source Manager.
/// </summary>
/// <param name="status">The status.</param>
/// <returns></returns>
public ReturnCode GetManager(out TWStatus status)
{
Session.VerifyState(2, 7, DataGroups.Control, DataArgumentType.Status, Message.Get);
status = new TWStatus();
return PInvoke.DsmEntry(Session.AppId, null, Message.Get, status);
}
/// <summary>
/// Returns the current Condition Code for the specified Source.
/// </summary>
/// <param name="status">The status.</param>
/// <returns></returns>
public ReturnCode GetSource(out TWStatus status)
{
Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Status, Message.Get);
status = new TWStatus();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Get, status);
}
}
}

View File

@@ -0,0 +1,42 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class StatusUtf8 : OpBase
{
internal StatusUtf8(TwainSession session) : base(session) { }
/// <summary>
/// Translate the contents of a TW_STATUS structure received from a Source into a localized UTF-8
/// encoded string.
/// </summary>
/// <param name="status">The status.</param>
/// <returns></returns>
public ReturnCode Get(TWStatusUtf8 status)
{
Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.StatusUtf8, Message.Get);
return PInvoke.DsmEntry(Session.AppId, null, Message.Get, status);
}
}
}

View File

@@ -0,0 +1,92 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
sealed class UserInterface : OpBase
{
internal UserInterface(TwainSession session) : base(session) { }
/// <summary>
/// This operation causes the Sources 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.
/// </summary>
/// <param name="userInterface">The user interface.</param>
/// <returns></returns>
public ReturnCode DisableDS(TWUserInterface userInterface)
{
Session.VerifyState(5, 5, DataGroups.Control, DataArgumentType.UserInterface, Message.DisableDS);
var rc = PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.DisableDS, userInterface);
if (rc == ReturnCode.Success)
{
Session.State = 4;
}
return rc;
}
/// <summary>
/// Enables the DS.
/// </summary>
/// <param name="userInterface">The user interface.</param>
/// <returns></returns>
public ReturnCode EnableDS(TWUserInterface userInterface)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.UserInterface, Message.EnableDS);
using (var pending = Session.GetPendingStateChanger(5))
{
var rc = PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.EnableDS, userInterface);
if (rc == ReturnCode.Success ||
(!userInterface.ShowUI && rc == ReturnCode.CheckStatus))
{
pending.Commit();
}
return rc;
}
}
/// <summary>
/// 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.
/// </summary>
/// <param name="userInterface">The user interface.</param>
/// <returns></returns>
public ReturnCode EnableDSUIOnly(TWUserInterface userInterface)
{
Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.UserInterface, Message.EnableDSUIOnly);
using (var pending = Session.GetPendingStateChanger(5))
{
var rc = PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.EnableDSUIOnly, userInterface);
if (rc == ReturnCode.Success)
{
pending.Commit();
}
return rc;
}
}
}
}

View File

@@ -0,0 +1,60 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using NTwain.Data;
using NTwain.Values;
namespace NTwain.Triplets
{
public sealed class XferGroup : OpBase
{
internal XferGroup(TwainSession session) : base(session) { }
/// <summary>
/// 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.
/// </summary>
/// <param name="value">The value.</param>
/// <returns></returns>
public ReturnCode Get(out uint value)
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.XferGroup, Message.Get);
throw new NotImplementedException();
// TODO: I have no idea if this even works, just something that looks logical.
// Does memory from pointer need to be released once we got the value?
//IntPtr ptr = IntPtr.Zero;
//var rc = Custom.DsmEntry(Session.AppId, Session.SourceId, DataGroup.Control, DataArgumentType.XferGroup, Message.Get, ref ptr);
//unsafe
//{
// uint* realPtr = (uint*)ptr.ToPointer();
// value = (*realPtr);
//}
//return rc;
}
public ReturnCode Set(uint value)
{
Session.VerifyState(6, 6, DataGroups.Control, DataArgumentType.XferGroup, Message.Set);
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,201 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace NTwain.Triplets
{
/// <summary>
/// Class for grouping triplet operations under the Control data group.
/// </summary>
public sealed class DGControl
{
TwainSession _session;
internal DGControl(TwainSession 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;
public Capability Capability
{
get
{
if (_capability == null) { _capability = new Capability(_session); }
return _capability;
}
}
CustomDSData _customDSData;
public CustomDSData CustomDSData
{
get
{
if (_customDSData == null) { _customDSData = new CustomDSData(_session); }
return _customDSData;
}
}
DeviceEvent _deviceEvent;
public 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;
public FileSystem FileSystem
{
get
{
if (_fileSys == null) { _fileSys = new FileSystem(_session); }
return _fileSys;
}
}
Identity _identity;
public 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;
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;
public SetupFileXfer SetupFileXfer
{
get
{
if (_setupFileXfer == null) { _setupFileXfer = new SetupFileXfer(_session); }
return _setupFileXfer;
}
}
SetupMemXfer _setupMemXfer;
public SetupMemXfer SetupMemXfer
{
get
{
if (_setupMemXfer == null) { _setupMemXfer = new SetupMemXfer(_session); }
return _setupMemXfer;
}
}
Status _status;
public Status Status
{
get
{
if (_status == null) { _status = new Status(_session); }
return _status;
}
}
StatusUtf8 _statusUtf8;
public 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;
public XferGroup XferGroup
{
get
{
if (_xferGroup == null) { _xferGroup = new XferGroup(_session); }
return _xferGroup;
}
}
}
}

View File

@@ -0,0 +1,44 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class CieColor : OpBase
{
internal CieColor(TwainSession session) : base(session) { }
/// <summary>
/// This operation causes the Source to report the currently active parameters to be used in
/// converting acquired color data into CIE XYZ.
/// </summary>
/// <param name="cieColor">Color data.</param>
/// <returns></returns>
public ReturnCode Get(out TWCieColor cieColor)
{
Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.CieColor, Message.Get);
cieColor = new TWCieColor();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Get, cieColor);
}
}
}

View File

@@ -0,0 +1,37 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class ExtImageInfo : OpBase
{
internal ExtImageInfo(TwainSession session) : base(session) { }
public ReturnCode Get(TWExtImageInfo info)
{
Session.VerifyState(7, 7, DataGroups.Image, DataArgumentType.ExtImageInfo, Message.Get);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Get, info);
}
}
}

View File

@@ -0,0 +1,56 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class GrayResponse : OpBase
{
internal GrayResponse(TwainSession session) : base(session) { }
/// <summary>
/// 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.
/// </summary>
/// <param name="response">The response.</param>
/// <returns></returns>
public ReturnCode Reset(out TWGrayResponse response)
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.GrayResponse, Message.Reset);
response = new TWGrayResponse();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Reset, response);
}
/// <summary>
/// This operation causes the Source to transform any grayscale data according to the response
/// curve specified.
/// </summary>
/// <param name="response">The response.</param>
/// <returns></returns>
public ReturnCode Set(TWGrayResponse response)
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.GrayResponse, Message.Set);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Set, response);
}
}
}

View File

@@ -0,0 +1,44 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class IccProfile : OpBase
{
internal IccProfile(TwainSession session) : base(session) { }
/// <summary>
/// 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).
/// </summary>
/// <param name="profile">The profile.</param>
/// <returns></returns>
public ReturnCode Get(ref TWMemory profile)
{
Session.VerifyState(6, 7, DataGroups.Image, DataArgumentType.IccProfile, Message.Get);
profile = new TWMemory();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, DataArgumentType.IccProfile, Message.Get, ref profile);
}
}
}

View File

@@ -0,0 +1,43 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using NTwain.Data;
using NTwain.Values;
namespace NTwain.Triplets
{
sealed class ImageFileXfer : OpBase
{
internal ImageFileXfer(TwainSession session) : base(session) { }
/// <summary>
/// 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.
/// </summary>
/// <returns></returns>
public ReturnCode Get()
{
Session.VerifyState(6, 6, DataGroups.Image, DataArgumentType.ImageFileXfer, Message.Get);
IntPtr z = IntPtr.Zero;
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, DataGroups.Image, DataArgumentType.ImageFileXfer, Message.Get, ref z);
}
}
}

View File

@@ -0,0 +1,38 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class ImageInfo : OpBase
{
internal ImageInfo(TwainSession session) : base(session) { }
public ReturnCode Get(out TWImageInfo info)
{
Session.VerifyState(6, 7, DataGroups.Image, DataArgumentType.ImageInfo, Message.Get);
info = new TWImageInfo();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Get, info);
}
}
}

View File

@@ -0,0 +1,58 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class ImageLayout : OpBase
{
internal ImageLayout(TwainSession session) : base(session) { }
public ReturnCode Get(out TWImageLayout layout)
{
Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.ImageLayout, Message.Get);
layout = new TWImageLayout();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Get, layout);
}
public ReturnCode GetDefault(out TWImageLayout layout)
{
Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.ImageLayout, Message.GetDefault);
layout = new TWImageLayout();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.GetDefault, layout);
}
public ReturnCode Reset(out TWImageLayout layout)
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.ImageLayout, Message.Reset);
layout = new TWImageLayout();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Reset, layout);
}
public ReturnCode Set(TWImageLayout layout)
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.ImageLayout, Message.Set);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Set, layout);
}
}
}

View File

@@ -0,0 +1,44 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
sealed class ImageMemFileXfer : OpBase
{
internal ImageMemFileXfer(TwainSession session) : base(session) { }
/// <summary>
/// This operation is used to initiate the transfer of an image from the Source to the application via
/// the Memory-File transfer mechanism.
/// </summary>
/// <param name="xfer">The xfer.</param>
/// <returns></returns>
public ReturnCode Get(TWImageMemXfer xfer)
{
Session.VerifyState(6, 6, DataGroups.Image, DataArgumentType.ImageMemFileXfer, Message.Get);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Get, xfer);
}
}
}

View File

@@ -0,0 +1,43 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
sealed class ImageMemXfer : OpBase
{
internal ImageMemXfer(TwainSession session) : base(session) { }
/// <summary>
/// This operation is used to initiate the transfer of an image from the Source to the application via
/// the Buffered Memory transfer mechanism.
/// </summary>
/// <param name="xfer">The xfer.</param>
/// <returns></returns>
public ReturnCode Get(TWImageMemXfer xfer)
{
Session.VerifyState(6, 7, DataGroups.Image, DataArgumentType.ImageMemXfer, Message.Get);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Get, xfer);
}
}
}

View File

@@ -0,0 +1,46 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using NTwain.Data;
using NTwain.Values;
namespace NTwain.Triplets
{
sealed class ImageNativeXfer : OpBase
{
internal ImageNativeXfer(TwainSession session) : base(session) { }
/// <summary>
/// Causes the transfer of an images 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.
/// </summary>
/// <param name="handle">The handle.</param>
/// <returns></returns>
public ReturnCode Get(ref IntPtr handle)
{
Session.VerifyState(6, 6, DataGroups.Image, DataArgumentType.ImageNativeXfer, Message.Get);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, DataGroups.Image, DataArgumentType.ImageNativeXfer, Message.Get, ref handle);
}
}
}

View File

@@ -0,0 +1,82 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class JpegCompression : OpBase
{
internal JpegCompression(TwainSession session) : base(session) { }
/// <summary>
/// Causes the Source to return the parameters that will be used during the compression of data
/// using the JPEG algorithms.
/// </summary>
/// <param name="compression">The compression.</param>
/// <returns></returns>
public ReturnCode Get(out TWJpegCompression compression)
{
Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.JpegCompression, Message.Get);
compression = new TWJpegCompression();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Get, compression);
}
/// <summary>
/// Causes the Source to return the power-on default values applied to JPEG-compressed data
/// transfers.
/// </summary>
/// <param name="compression">The compression.</param>
/// <returns></returns>
public ReturnCode GetDefault(out TWJpegCompression compression)
{
Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.JpegCompression, Message.GetDefault);
compression = new TWJpegCompression();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.GetDefault, compression);
}
/// <summary>
/// Return the Source to using its power-on default values for JPEG-compressed transfers.
/// </summary>
/// <param name="compression">The compression.</param>
/// <returns></returns>
public ReturnCode Reset(out TWJpegCompression compression)
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.JpegCompression, Message.Reset);
compression = new TWJpegCompression();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Reset, compression);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="compression">The compression.</param>
/// <returns></returns>
public ReturnCode Set(TWJpegCompression compression)
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.JpegCompression, Message.Set);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Set, compression);
}
}
}

View File

@@ -0,0 +1,82 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class Palette8 : OpBase
{
internal Palette8(TwainSession session) : base(session) { }
/// <summary>
/// This operation causes the Source to report its current palette information.
/// </summary>
/// <param name="palette">The palette.</param>
/// <returns></returns>
public ReturnCode Get(out TWPalette8 palette)
{
Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.Palette8, Message.Get);
palette = new TWPalette8();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Get, palette);
}
/// <summary>
/// This operation causes the Source to report its power-on default palette.
/// </summary>
/// <param name="palette">The palette.</param>
/// <returns></returns>
public ReturnCode GetDefault(out TWPalette8 palette)
{
Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.Palette8, Message.GetDefault);
palette = new TWPalette8();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.GetDefault, palette);
}
/// <summary>
/// This operation causes the Source to dispose of any current palette it has and to use its default
/// palette for the next palette transfer.
/// </summary>
/// <param name="palette">The palette.</param>
/// <returns></returns>
public ReturnCode Reset(out TWPalette8 palette)
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.Palette8, Message.Reset);
palette = new TWPalette8();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Reset, palette);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="palette">The palette.</param>
/// <returns></returns>
public ReturnCode Set(TWPalette8 palette)
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.Palette8, Message.Set);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Set, palette);
}
}
}

View File

@@ -0,0 +1,57 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NTwain.Data;
using NTwain.Values;
using System;
namespace NTwain.Triplets
{
public sealed class RgbResponse : OpBase
{
internal RgbResponse(TwainSession session) : base(session) { }
/// <summary>
/// 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).
/// </summary>
/// <param name="response">The response.</param>
/// <returns></returns>
public ReturnCode Reset(out TWRgbResponse response)
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.RgbResponse, Message.Reset);
response = new TWRgbResponse();
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Reset, response);
}
/// <summary>
/// Causes the Source to transform any RGB data according to the response curves specified by the
/// application.
/// </summary>
/// <param name="response">The response.</param>
/// <returns></returns>
public ReturnCode Set(TWRgbResponse response)
{
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.RgbResponse, Message.Set);
return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Set, response);
}
}
}

View File

@@ -0,0 +1,171 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace NTwain.Triplets
{
/// <summary>
/// Class for grouping triplet operations under the Image data group.
/// </summary>
public sealed class DGImage
{
TwainSession _session;
internal DGImage(TwainSession session)
{
if (session == null) { throw new ArgumentNullException("session"); }
_session = session;
}
CieColor _cieColor;
public CieColor CieColor
{
get
{
if (_cieColor == null) { _cieColor = new CieColor(_session); }
return _cieColor;
}
}
ExtImageInfo _extImgInfo;
public ExtImageInfo ExtImageInfo
{
get
{
if (_extImgInfo == null) { _extImgInfo = new ExtImageInfo(_session); }
return _extImgInfo;
}
}
GrayResponse _grayResponse;
public GrayResponse GrayResponse
{
get
{
if (_grayResponse == null) { _grayResponse = new GrayResponse(_session); }
return _grayResponse;
}
}
IccProfile _iccProfile;
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;
public ImageInfo ImageInfo
{
get
{
if (_imgInfo == null) { _imgInfo = new ImageInfo(_session); }
return _imgInfo;
}
}
ImageLayout _imgLayout;
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;
public JpegCompression JpegCompression
{
get
{
if (_jpegComp == null) { _jpegComp = new JpegCompression(_session); }
return _jpegComp;
}
}
Palette8 _palette8;
public Palette8 Palette8
{
get
{
if (_palette8 == null) { _palette8 = new Palette8(_session); }
return _palette8;
}
}
RgbResponse _rgbResp;
public RgbResponse RgbResponse
{
get
{
if (_rgbResp == null) { _rgbResp = new RgbResponse(_session); }
return _rgbResp;
}
}
}
}

34
NTwain/Triplets/OpBase.cs Normal file
View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NTwain.Values;
namespace NTwain.Triplets
{
/// <summary>
/// Base class for grouping triplet operations messages.
/// </summary>
public abstract class OpBase
{
TwainSession _session;
/// <summary>
/// Initializes a new instance of the <see cref="OpBase" /> class.
/// </summary>
/// <param name="session">The session.</param>
/// <exception cref="System.ArgumentNullException"></exception>
protected OpBase(TwainSession session)
{
if (session == null) { throw new ArgumentNullException("session"); }
_session = session;
}
/// <summary>
/// Gets the twain session.
/// </summary>
/// <value>
/// The session.
/// </value>
protected TwainSession Session { get { return _session; } }
}
}

360
NTwain/Triplets/PInvoke.cs Normal file
View File

@@ -0,0 +1,360 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.InteropServices;
using NTwain.Data;
using NTwain.Values;
namespace NTwain.Triplets
{
/// <summary>
/// Contains the full TWAIN entry signatures through pinvoke.
/// These are called by all the defined triplets methods in
/// this namespace.
/// </summary>
static partial class PInvoke
{
// Change pinvoke base on where running in 64bit mode.
// Theoretically [DllImport("twaindsm", EntryPoint = "#1")]
// works on both 32 and 64 bit
// but it's not installed on either system by default.
// A proper 64 bit twain driver would've installed it so
// in essence it only exists in 64 bit systems and thus
// the 2 sets of identical pinvokes :(
// There's another way of doing own pinvoke at runtime but
// that's not easy to understand.
public static readonly bool Is64Bit = IntPtr.Size == 8;
// define sig for each different data type since "object" doesn't work
#region wrapped calls
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
ref IntPtr data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, dg, dat, msg, ref data); }
else { return NativeMethods.DsmEntry32(origin, destination, dg, dat, msg, ref data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWAudioInfo data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWCapability data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Capability, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Capability, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWCustomDSData data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWDeviceEvent data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWCallback data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWCallback2 data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWEntryPoint data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWEvent data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWFileSystem data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
Message msg,
TWIdentity data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); }
else { return NativeMethods.DsmEntry32(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWPassThru data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWPendingXfers data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWSetupFileXfer data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWSetupMemXfer data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWStatusUtf8 data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWUserInterface data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWCieColor data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWExtImageInfo data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWGrayResponse data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWImageInfo data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWImageLayout data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWImageMemXfer data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWJpegCompression data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWPalette8 data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWRgbResponse data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
Message msg,
TWStatus data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); }
}
public static ReturnCode DsmEntry(
TWIdentity origin,
TWIdentity destination,
DataArgumentType dat,
Message msg,
ref TWMemory data)
{
if (Is64Bit) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, dat, msg, ref data); }
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, dat, msg, ref data); }
}
#endregion
}
}

View File

@@ -0,0 +1,285 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.InteropServices;
using NTwain.Data;
using NTwain.Values;
namespace NTwain.Triplets
{
static partial class PInvoke
{
static partial class NativeMethods
{
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
ref IntPtr data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWAudioInfo data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWCapability data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWCustomDSData data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWDeviceEvent data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWCallback data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWCallback2 data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWEntryPoint data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWEvent data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWFileSystem data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
IntPtr zero,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWIdentity data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWPassThru data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWPendingXfers data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWSetupFileXfer data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWSetupMemXfer data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWStatusUtf8 data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWUserInterface data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWCieColor data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWExtImageInfo data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWGrayResponse data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWImageInfo data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWImageLayout data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWImageMemXfer data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWJpegCompression data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWPalette8 data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWRgbResponse data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWStatus data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
ref TWMemory data);
}
}
}

View File

@@ -0,0 +1,286 @@
// The MIT License (MIT)
// Copyright (c) 2013 Yin-Chun 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 in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.InteropServices;
using NTwain.Data;
using NTwain.Values;
namespace NTwain.Triplets
{
static partial class PInvoke
{
static partial class NativeMethods
{
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
ref IntPtr data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWAudioInfo data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWCapability data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWCustomDSData data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWDeviceEvent data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWCallback data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWCallback2 data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWEntryPoint data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWEvent data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWFileSystem data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
IntPtr zero,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWIdentity data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWPassThru data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWPendingXfers data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWSetupFileXfer data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWSetupMemXfer data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWStatusUtf8 data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWUserInterface data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWCieColor data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWExtImageInfo data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWGrayResponse data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWImageInfo data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWImageLayout data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWImageMemXfer data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWJpegCompression data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWPalette8 data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWRgbResponse data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
[In, Out]TWStatus data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
[In, Out]TWIdentity origin,
[In, Out]TWIdentity destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
ref TWMemory data);
}
}
}

View File

@@ -0,0 +1,19 @@
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 defined 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 used by the
application are explicitly defined this way.