More source updates.

This commit is contained in:
soukoku
2014-09-17 20:15:05 -04:00
parent 450f8aa5b0
commit 11b6cb1040
13 changed files with 227 additions and 77 deletions

View File

@@ -311,7 +311,7 @@ namespace NTwain
/// <returns></returns>
public ReturnCode ResetAll()
{
return _source.ResetAll(Capability);
return _source.CapResetAll(Capability);
}
/// <summary>
@@ -320,7 +320,7 @@ namespace NTwain
/// <returns></returns>
public ReturnCode Reset()
{
return _source.Reset(Capability);
return _source.CapReset(Capability);
}
/// <summary>

View File

@@ -9,7 +9,7 @@ namespace NTwain
// this contains all cap-related methods prefixed with Cap
partial class DataSource
partial class DataSource : ICapController
{
#region low-level cap stuff
@@ -139,7 +139,7 @@ namespace NTwain
/// </summary>
/// <param name="capabilityId">The capability identifier.</param>
/// <returns></returns>
public ReturnCode ResetAll(CapabilityId capabilityId)
public ReturnCode CapResetAll(CapabilityId capabilityId)
{
using (TWCapability cap = new TWCapability(capabilityId)
{
@@ -156,7 +156,7 @@ namespace NTwain
/// </summary>
/// <param name="capabilityId">The capability identifier.</param>
/// <returns></returns>
public ReturnCode Reset(CapabilityId capabilityId)
public ReturnCode CapReset(CapabilityId capabilityId)
{
using (TWCapability cap = new TWCapability(capabilityId)
{

View File

@@ -23,6 +23,7 @@ namespace NTwain
{
_session = session;
Identity = sourceId;
ProtocolVersion = new Version(sourceId.ProtocolMajor, sourceId.ProtocolMinor);
}
/// <summary>
@@ -61,20 +62,6 @@ namespace NTwain
return rc;
}
/// <summary>
/// Enables the source to start transferring.
/// </summary>
/// <param name="mode">The mode.</param>
/// <param name="modal">if set to <c>true</c> any driver UI will display as modal.</param>
/// <param name="windowHandle">The window handle if modal.</param>
/// <returns></returns>
[Obsolete("Use Enable() instead.")]
public ReturnCode StartTransfer(SourceEnableMode mode, bool modal, IntPtr windowHandle)
{
return Enable(mode, modal, windowHandle);
}
/// <summary>
/// Enables the source to start transferring.
/// </summary>
@@ -138,7 +125,7 @@ namespace NTwain
public string ProductFamily { get { return Identity.ProductFamily; } }
/// <summary>
/// Gets the version information.
/// Gets the source's version information.
/// </summary>
/// <value>
/// The version.
@@ -154,21 +141,12 @@ namespace NTwain
public DataGroups DataGroup { get { return Identity.DataGroup; } }
/// <summary>
/// Gets the supported TWAIN protocol major number.
/// Gets the supported TWAIN protocol version.
/// </summary>
/// <value>
/// The protocol major number.
/// The protocol version.
/// </value>
public int ProtocolMajor { get { return Identity.ProtocolMajor; } }
/// <summary>
/// Gets the supported TWAIN protocol minor number.
/// </summary>
/// <value>
/// The protocol minor number.
/// </value>
public int ProtocolMinor { get { return Identity.ProtocolMinor; } }
public Version ProtocolVersion { get; private set; }
static readonly CapabilityId[] _emptyCapList = new CapabilityId[0];

70
NTwain/ICapController.cs Normal file
View File

@@ -0,0 +1,70 @@
using NTwain.Data;
using System;
using System.Collections.Generic;
namespace NTwain
{
/// <summary>
/// Interface for controlling caps.
/// </summary>
public interface ICapController
{
/// <summary>
/// A general method that tries to get capability values from current <see cref="DataSource" />.
/// </summary>
/// <param name="capabilityId">The capability unique identifier.</param>
/// <returns></returns>
IList<object> CapGet(CapabilityId capabilityId);
/// <summary>
/// Gets the current value for a capability.
/// </summary>
/// <param name="capId">The cap id.</param>
/// <returns></returns>
object CapGetCurrent(CapabilityId capId);
/// <summary>
/// Gets the default value for a capability.
/// </summary>
/// <param name="capId">The cap id.</param>
/// <returns></returns>
object CapGetDefault(CapabilityId capId);
/// <summary>
/// Gets the actual supported operations for a capability.
/// </summary>
/// <param name="capId">The cap identifier.</param>
/// <returns></returns>
QuerySupports CapQuerySupport(CapabilityId capId);
/// <summary>
/// Resets the current value to power-on default.
/// </summary>
/// <param name="capabilityId">The capability identifier.</param>
/// <returns></returns>
ReturnCode CapReset(CapabilityId capabilityId);
/// <summary>
/// Resets all values and constraint to power-on defaults.
/// </summary>
/// <param name="capabilityId">The capability identifier.</param>
/// <returns></returns>
ReturnCode CapResetAll(CapabilityId capabilityId);
//CapabilityControl<XferMech> CapAudioXferMech { get; }
//CapabilityControl<BoolType> CapDuplexEnabled { get; }
//CapabilityControl<BoolType> CapFeederEnabled { get; }
//CapabilityControl<BoolType> CapImageAutoDeskew { get; }
//CapabilityControl<BoolType> CapImageAutomaticBorderDetection { get; }
//CapabilityControl<BoolType> CapImageAutoRotate { get; }
//CapabilityControl<CompressionType> CapImageCompression { get; }
//CapabilityControl<FileFormat> CapImageFileFormat { get; }
//CapabilityControl<PixelType> CapImagePixelType { get; }
//CapabilityControl<SupportedSize> CapImageSupportedSize { get; }
//CapabilityControl<XferMech> CapImageXferMech { get; }
//CapabilityControl<TWFix32> CapImageXResolution { get; }
//CapabilityControl<TWFix32> CapImageYResolution { get; }
//CapabilityControl<int> CapXferCount { get; }
}
}

View File

@@ -1,4 +1,6 @@
using System;
using NTwain.Data;
using System;
using System.Collections.Generic;
namespace NTwain
{
/// <summary>
@@ -13,5 +15,86 @@ namespace NTwain
/// The name.
/// </value>
string Name { get; }
/// <summary>
/// Gets the supported data group.
/// </summary>
/// <value>
/// The data group.
/// </value>
DataGroups DataGroup { get; }
/// <summary>
/// Gets the source's manufacturer name.
/// </summary>
/// <value>
/// The manufacturer.
/// </value>
string Manufacturer { get; }
/// <summary>
/// Gets the source's product family.
/// </summary>
/// <value>
/// The product family.
/// </value>
string ProductFamily { get; }
/// <summary>
/// Gets the supported TWAIN protocol version.
/// </summary>
/// <value>
/// The protocol version.
/// </value>
Version ProtocolVersion { get; }
/// <summary>
/// Gets the supported caps for this source.
/// </summary>
/// <value>
/// The supported caps.
/// </value>
IList<CapabilityId> SupportedCaps { get; }
/// <summary>
/// Gets the source's version information.
/// </summary>
/// <value>
/// The version.
/// </value>
TWVersion Version { get; }
/// <summary>
/// Opens the source for capability negotiation.
/// </summary>
/// <returns></returns>
ReturnCode Open();
/// <summary>
/// Closes the source.
/// </summary>
/// <returns></returns>
ReturnCode Close();
/// <summary>
/// Enables the source to start transferring.
/// </summary>
/// <param name="mode">The mode.</param>
/// <param name="modal">if set to <c>true</c> any driver UI will display as modal.</param>
/// <param name="windowHandle">The window handle if modal.</param>
/// <returns></returns>
ReturnCode Enable(SourceEnableMode mode, bool modal, IntPtr windowHandle);
/// <summary>
/// Gets the source status. Only call this at state 4 or higher.
/// </summary>
/// <returns></returns>
TWStatus GetStatus();
/// <summary>
/// Gets the source status. Only call this at state 4 or higher.
/// </summary>
/// <returns></returns>
TWStatusUtf8 GetStatusUtf8();
}
}

View File

@@ -1,9 +1,8 @@
using NTwain.Data;
using NTwain.Internals;
using System;
using System.ComponentModel;
namespace NTwain
namespace NTwain.Internals
{
/// <summary>
/// Provides methods for managing memory on data exchanged with twain sources using old win32 methods.

View File

@@ -61,6 +61,7 @@
<Compile Include="Data\TwainTypesExtended.cs" />
<Compile Include="DeviceEventArgs.cs" />
<Compile Include="IDataSource.cs" />
<Compile Include="ICapController.cs" />
<Compile Include="Internals\Extensions.cs" />
<Compile Include="DataTransferredEventArgs.cs" />
<Compile Include="IMemoryManager.cs" />

View File

@@ -1,4 +1,5 @@
using NTwain.Triplets;
using NTwain.Internals;
using NTwain.Triplets;
using System;
using System.Collections.Generic;
using System.IO;

View File

@@ -3,17 +3,28 @@
[assembly: AssemblyCopyright("Copyright \x00a9 Yin-Chun Wang 2012-2014")]
[assembly: AssemblyCompany("Yin-Chun Wang")]
[assembly: AssemblyVersion(NTwain._NTwainVersionInfo.Release)]
[assembly: AssemblyFileVersion(NTwain._NTwainVersionInfo.Build)]
[assembly: AssemblyInformationalVersion(NTwain._NTwainVersionInfo.Build)]
[assembly: AssemblyVersion(NTwain.NTwainVersionInfo.Release)]
[assembly: AssemblyFileVersion(NTwain.NTwainVersionInfo.Build)]
[assembly: AssemblyInformationalVersion(NTwain.NTwainVersionInfo.Build)]
namespace NTwain
{
class _NTwainVersionInfo
/// <summary>
/// Contains version info of this assembly.
/// </summary>
public class NTwainVersionInfo
{
// keep this same in major (breaking) releases
public const string Release = "3.0.0.0";
// change this for each nuget release
public const string Build = "3.0.0";
/// <summary>
/// The major release version number.
/// </summary>
public const string Release = "3.0.0.0"; // keep this same in major (breaking) releases
/// <summary>
/// The build release version number.
/// </summary>
public const string Build = "3.0.0"; // change this for each nuget release
}
}