mirror of
https://github.com/soukoku/ntwain.git
synced 2026-01-26 21:48:36 +08:00
Added GetStatus() call.
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||||
<RootNamespace>ConsoleApp</RootNamespace>
|
<RootNamespace>ConsoleApp</RootNamespace>
|
||||||
|
<LangVersion>7.1</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<LangVersion>7.1</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
@@ -30,6 +31,7 @@
|
|||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<LangVersion>7.1</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
|||||||
@@ -35,6 +35,17 @@ namespace NTwain
|
|||||||
public ReturnCode Close() => Session.DGControl.Identity.CloseDS(Identity);
|
public ReturnCode Close() => Session.DGControl.Identity.CloseDS(Identity);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the source status. Useful after getting a non-success return code.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public TW_STATUS GetStatus()
|
||||||
|
{
|
||||||
|
TW_STATUS stat = default;
|
||||||
|
var rc = Session.DGControl.Status.GetSourceStatus(ref stat);
|
||||||
|
return stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a <see cref="System.String"/> that represents this instance.
|
/// Returns a <see cref="System.String"/> that represents this instance.
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
<AssemblyVersion>4.0.0.0</AssemblyVersion>
|
<AssemblyVersion>4.0.0.0</AssemblyVersion>
|
||||||
<FileVersion>4.0.0.0</FileVersion>
|
<FileVersion>4.0.0.0</FileVersion>
|
||||||
<Version>4.0.0</Version>
|
<Version>4.0.0</Version>
|
||||||
|
<LangVersion>7.1</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
22
src/NTwain/Triplets/DGControl.Status.cs
Normal file
22
src/NTwain/Triplets/DGControl.Status.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using NTwain.Data;
|
||||||
|
using NTwain.Internals;
|
||||||
|
|
||||||
|
namespace NTwain.Triplets
|
||||||
|
{
|
||||||
|
sealed class Status : BaseTriplet
|
||||||
|
{
|
||||||
|
internal Status(TwainSession session) : base(session) { }
|
||||||
|
|
||||||
|
public ReturnCode GetManagerStatus(ref TW_STATUS status)
|
||||||
|
{
|
||||||
|
return NativeMethods.DsmWin32(Session.Config.AppWin32, null,
|
||||||
|
DataGroups.Control, DataArgumentType.Status, Message.Get, ref status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReturnCode GetSourceStatus(ref TW_STATUS status)
|
||||||
|
{
|
||||||
|
return NativeMethods.DsmWin32(Session.Config.AppWin32, Session.CurrentSource.Identity,
|
||||||
|
DataGroups.Control, DataArgumentType.Status, Message.Get, ref status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,5 +27,8 @@ namespace NTwain.Triplets
|
|||||||
|
|
||||||
Callback2 _callback2;
|
Callback2 _callback2;
|
||||||
internal Callback2 Callback2 => _callback2 ?? (_callback2 = new Callback2(Session));
|
internal Callback2 Callback2 => _callback2 ?? (_callback2 = new Callback2(Session));
|
||||||
|
|
||||||
|
Status _status;
|
||||||
|
internal Status Status => _status ?? (_status = new Status(Session));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,17 @@ namespace NTwain
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the manager status. Useful after getting a non-success return code.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public TW_STATUS GetStatus()
|
||||||
|
{
|
||||||
|
TW_STATUS stat = default;
|
||||||
|
var rc = DGControl.Status.GetManagerStatus(ref stat);
|
||||||
|
return stat;
|
||||||
|
}
|
||||||
|
|
||||||
internal void RegisterCallback()
|
internal void RegisterCallback()
|
||||||
{
|
{
|
||||||
var callbackPtr = Marshal.GetFunctionPointerForDelegate(_callbackDelegate);
|
var callbackPtr = Marshal.GetFunctionPointerForDelegate(_callbackDelegate);
|
||||||
@@ -92,7 +103,8 @@ namespace NTwain
|
|||||||
if (rc == ReturnCode.Success) Debug.WriteLine("Registed Callback2 success.");
|
if (rc == ReturnCode.Success) Debug.WriteLine("Registed Callback2 success.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
var status = GetStatus();
|
||||||
|
Debug.WriteLine($"Register Callback2 failed with condition code: {status.ConditionCode}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -106,7 +118,8 @@ namespace NTwain
|
|||||||
if (rc == ReturnCode.Success) Debug.WriteLine("Registed Callback success.");
|
if (rc == ReturnCode.Success) Debug.WriteLine("Registed Callback success.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
var status = GetStatus();
|
||||||
|
Debug.WriteLine($"Register Callback failed with {status.ConditionCode}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user