mirror of
https://github.com/soukoku/ntwain.git
synced 2025-09-19 10:08:00 +08:00
Initial move from old twain-in-dotnet.
This commit is contained in:
43
NTwain/Triplets/DGControl/DGControl.Callback.cs
Normal file
43
NTwain/Triplets/DGControl/DGControl.Callback.cs
Normal 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 application’s 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);
|
||||
}
|
||||
}
|
||||
}
|
43
NTwain/Triplets/DGControl/DGControl.Callback2.cs
Normal file
43
NTwain/Triplets/DGControl/DGControl.Callback2.cs
Normal 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 application’s 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);
|
||||
}
|
||||
}
|
||||
}
|
148
NTwain/Triplets/DGControl/DGControl.Capability.cs
Normal file
148
NTwain/Triplets/DGControl/DGControl.Capability.cs
Normal 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 Source’s 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 Source’s 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 Source’s Default Value. This is the Source’s 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 Source’s 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);
|
||||
}
|
||||
}
|
||||
}
|
57
NTwain/Triplets/DGControl/DGControl.CustomDSData.cs
Normal file
57
NTwain/Triplets/DGControl/DGControl.CustomDSData.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
37
NTwain/Triplets/DGControl/DGControl.DeviceEvent.cs
Normal file
37
NTwain/Triplets/DGControl/DGControl.DeviceEvent.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
42
NTwain/Triplets/DGControl/DGControl.EntryPoint.cs
Normal file
42
NTwain/Triplets/DGControl/DGControl.EntryPoint.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
49
NTwain/Triplets/DGControl/DGControl.Event.cs
Normal file
49
NTwain/Triplets/DGControl/DGControl.Event.cs
Normal 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 application’s main event loop. This allows the Source to update its user interface
|
||||
/// in real-time and to return messages to the application which cause state transitions. Even if the
|
||||
/// application overrides the Source’s user interface, it must forward all events once the Source has
|
||||
/// been enabled. The Source will tell the application whether or not each event belongs to the
|
||||
/// Source.
|
||||
/// </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);
|
||||
}
|
||||
}
|
||||
}
|
179
NTwain/Triplets/DGControl/DGControl.FileSystem.cs
Normal file
179
NTwain/Triplets/DGControl/DGControl.FileSystem.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
129
NTwain/Triplets/DGControl/DGControl.Identity.cs
Normal file
129
NTwain/Triplets/DGControl/DGControl.Identity.cs
Normal 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 application’s 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 application’s 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 application’s
|
||||
/// 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);
|
||||
}
|
||||
}
|
||||
}
|
69
NTwain/Triplets/DGControl/DGControl.Parent.cs
Normal file
69
NTwain/Triplets/DGControl/DGControl.Parent.cs
Normal 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 Source’s
|
||||
/// "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 Source’s
|
||||
/// "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;
|
||||
}
|
||||
}
|
||||
}
|
42
NTwain/Triplets/DGControl/DGControl.PassThru.cs
Normal file
42
NTwain/Triplets/DGControl/DGControl.PassThru.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
81
NTwain/Triplets/DGControl/DGControl.PendingXfers.cs
Normal file
81
NTwain/Triplets/DGControl/DGControl.PendingXfers.cs
Normal 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 scanner’s 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);
|
||||
}
|
||||
}
|
||||
}
|
84
NTwain/Triplets/DGControl/DGControl.SetupFileXfer.cs
Normal file
84
NTwain/Triplets/DGControl/DGControl.SetupFileXfer.cs
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
43
NTwain/Triplets/DGControl/DGControl.SetupMemXfer.cs
Normal file
43
NTwain/Triplets/DGControl/DGControl.SetupMemXfer.cs
Normal 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 Source’s 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);
|
||||
}
|
||||
}
|
||||
}
|
54
NTwain/Triplets/DGControl/DGControl.Status.cs
Normal file
54
NTwain/Triplets/DGControl/DGControl.Status.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
42
NTwain/Triplets/DGControl/DGControl.StatusUtf8.cs
Normal file
42
NTwain/Triplets/DGControl/DGControl.StatusUtf8.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
92
NTwain/Triplets/DGControl/DGControl.UserInterface.cs
Normal file
92
NTwain/Triplets/DGControl/DGControl.UserInterface.cs
Normal 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 Source’s user interface, if displayed during the
|
||||
/// EnableDS operation, to be lowered. The Source is returned to
|
||||
/// State 4, where capability negotiation can again occur. The application can invoke this operation
|
||||
/// either because it wants to shut down the current session, or in response to the Source "posting"
|
||||
/// a CloseDSReq event to it. Rarely, the application may need to close the Source because an
|
||||
/// error condition was detected.
|
||||
/// </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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
NTwain/Triplets/DGControl/DGControl.XferGroup.cs
Normal file
60
NTwain/Triplets/DGControl/DGControl.XferGroup.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
201
NTwain/Triplets/DGControl/DGControl.cs
Normal file
201
NTwain/Triplets/DGControl/DGControl.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user