mirror of
https://github.com/soukoku/ntwain.git
synced 2025-04-30 00:47:19 +08:00
Added metrics triplet.
This commit is contained in:
parent
1e8f47346d
commit
1ee5668ff1
@ -423,7 +423,7 @@ namespace NTwain.Data
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 2)]
|
||||
partial struct TW_METRICS
|
||||
{
|
||||
TW_UINT32 _sizeOf;
|
||||
internal TW_UINT32 SizeOf;
|
||||
TW_UINT32 _imageCount;
|
||||
TW_UINT32 _sheetCount;
|
||||
}
|
||||
|
@ -1937,10 +1937,6 @@ namespace NTwain.Data
|
||||
/// </summary>
|
||||
public partial struct TW_METRICS
|
||||
{
|
||||
/// <summary>
|
||||
/// Set by the application. Specifies the number of bytes in the structure
|
||||
/// </summary>
|
||||
public uint SizeOf => _sizeOf;
|
||||
/// <summary>
|
||||
/// The number of images made available for transfer by the driver. This is not
|
||||
/// necessarily the same as the number of images actually transferred, since the
|
||||
|
23
src/NTwain/Threading/ThreadDispatcher.cs
Normal file
23
src/NTwain/Threading/ThreadDispatcher.cs
Normal file
@ -0,0 +1,23 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using System.Threading;
|
||||
|
||||
//namespace NTwain.Threading
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// A base thread-marshalling class that does no marshalling.
|
||||
// /// </summary>
|
||||
// public class ThreadDispatcher
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// Invokes an action and returns after it's done.
|
||||
// /// </summary>
|
||||
// /// <param name="action"></param>
|
||||
// public virtual void Invoke(Action action)
|
||||
// {
|
||||
// action(); SynchronizationContext.Current
|
||||
// }
|
||||
// }
|
||||
//}
|
52
src/NTwain/Triplets/Control/Metrics.cs
Normal file
52
src/NTwain/Triplets/Control/Metrics.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using NTwain.Data;
|
||||
using NTwain.Internals;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NTwain.Triplets.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.Metrics"/>.
|
||||
/// </summary>
|
||||
public sealed class Metrics : BaseTriplet
|
||||
{
|
||||
internal Metrics(TwainSession session) : base(session) { }
|
||||
|
||||
/// <summary>
|
||||
/// Reads information relating to the last time DG_CONTROL / DAT_USERINTERFACE / MSG_ENABLEDS was sent.
|
||||
/// An application calls this to get final counts after scanning. This is
|
||||
/// necessary because some metrics cannot be detected during scanning, such as blank images
|
||||
/// discarded at the very end of a session.
|
||||
/// </summary>
|
||||
/// <param name="metrics"></param>
|
||||
/// <returns></returns>
|
||||
public ReturnCode Get(ref TW_METRICS metrics)
|
||||
{
|
||||
metrics.SizeOf = (uint)Marshal.SizeOf(typeof(TW_METRICS));
|
||||
|
||||
if (Is32Bit)
|
||||
{
|
||||
if (IsWin)
|
||||
return NativeMethods.DsmWin32(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.Metrics, Message.Get, ref metrics);
|
||||
if (IsLinux)
|
||||
return NativeMethods.DsmLinux32(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.Metrics, Message.Get, ref metrics);
|
||||
if (IsMac)
|
||||
return NativeMethods.DsmMac32(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.Metrics, Message.Get, ref metrics);
|
||||
}
|
||||
|
||||
if (IsWin)
|
||||
return NativeMethods.DsmWin64(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.Metrics, Message.Get, ref metrics);
|
||||
if (IsLinux)
|
||||
return NativeMethods.DsmLinux64(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.Metrics, Message.Get, ref metrics);
|
||||
if (IsMac)
|
||||
return NativeMethods.DsmMac64(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.Metrics, Message.Get, ref metrics);
|
||||
|
||||
return ReturnCode.Failure;
|
||||
}
|
||||
}
|
||||
}
|
@ -86,5 +86,11 @@ namespace NTwain.Triplets
|
||||
/// Gets the operations defined for DAT_XFERGROUP.
|
||||
/// </summary>
|
||||
public XferGroup XferGroup => _xferGroup ?? (_xferGroup = new XferGroup(Session));
|
||||
|
||||
Metrics _metrics;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_METRICS.
|
||||
/// </summary>
|
||||
public Metrics Metrics => _metrics ?? (_metrics = new Metrics(Session));
|
||||
}
|
||||
}
|
||||
|
@ -279,5 +279,14 @@ namespace NTwain.Triplets
|
||||
Message msg,
|
||||
ref TW_MEMORY data);
|
||||
|
||||
[DllImport(LinuxDll, EntryPoint = EntryName)]
|
||||
public static extern ReturnCode DsmLinux32(
|
||||
[In, Out]TW_IDENTITY origin,
|
||||
[In, Out]TW_IDENTITY destination,
|
||||
DataGroups dg,
|
||||
DataArgumentType dat,
|
||||
Message msg,
|
||||
ref TW_METRICS data);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -279,5 +279,14 @@ namespace NTwain.Triplets
|
||||
Message msg,
|
||||
ref TW_MEMORY data);
|
||||
|
||||
[DllImport(LinuxDll, EntryPoint = EntryName)]
|
||||
public static extern ReturnCode DsmLinux64(
|
||||
[In, Out]TW_IDENTITY origin,
|
||||
[In, Out]TW_IDENTITY destination,
|
||||
DataGroups dg,
|
||||
DataArgumentType dat,
|
||||
Message msg,
|
||||
ref TW_METRICS data);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -279,5 +279,14 @@ namespace NTwain.Triplets
|
||||
Message msg,
|
||||
ref TW_MEMORY data);
|
||||
|
||||
[DllImport(Mac32Dll, EntryPoint = EntryName)]
|
||||
public static extern ReturnCode DsmMac32(
|
||||
[In, Out]TW_IDENTITY origin,
|
||||
[In, Out]TW_IDENTITY destination,
|
||||
DataGroups dg,
|
||||
DataArgumentType dat,
|
||||
Message msg,
|
||||
ref TW_METRICS data);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -279,5 +279,14 @@ namespace NTwain.Triplets
|
||||
Message msg,
|
||||
ref TW_MEMORY data);
|
||||
|
||||
[DllImport(Mac64Dll, EntryPoint = EntryName)]
|
||||
public static extern ReturnCode DsmMac64(
|
||||
[In, Out]TW_IDENTITY origin,
|
||||
[In, Out]TW_IDENTITY destination,
|
||||
DataGroups dg,
|
||||
DataArgumentType dat,
|
||||
Message msg,
|
||||
ref TW_METRICS data);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -279,5 +279,14 @@ namespace NTwain.Triplets
|
||||
Message msg,
|
||||
ref TW_MEMORY data);
|
||||
|
||||
[DllImport(WinDll, EntryPoint = EntryName)]
|
||||
public static extern ReturnCode DsmWin32(
|
||||
[In, Out]TW_IDENTITY origin,
|
||||
[In, Out]TW_IDENTITY destination,
|
||||
DataGroups dg,
|
||||
DataArgumentType dat,
|
||||
Message msg,
|
||||
ref TW_METRICS data);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -279,5 +279,14 @@ namespace NTwain.Triplets
|
||||
Message msg,
|
||||
ref TW_MEMORY data);
|
||||
|
||||
[DllImport(WinDll, EntryPoint = EntryName)]
|
||||
public static extern ReturnCode DsmWin64(
|
||||
[In, Out]TW_IDENTITY origin,
|
||||
[In, Out]TW_IDENTITY destination,
|
||||
DataGroups dg,
|
||||
DataArgumentType dat,
|
||||
Message msg,
|
||||
ref TW_METRICS data);
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user