mirror of
https://github.com/soukoku/ntwain.git
synced 2025-12-29 02:05:04 +08:00
Made old session inherit the refactored version.
This commit is contained in:
@@ -12,7 +12,7 @@ namespace NTwain.Tests
|
||||
[ExpectedException(typeof(TwainStateException), "State check failed to throw.")]
|
||||
public void VerifyState_Throws_When_State_Is_Enforced()
|
||||
{
|
||||
ITwainStateInternal session = new TwainSession(TWIdentity.Create(DataGroups.Image, new Version(1, 0), "test", "test", "test", "test"));
|
||||
ITwainStateInternal session = new TwainSessionOld(TWIdentity.Create(DataGroups.Image, new Version(1, 0), "test", "test", "test", "test"));
|
||||
session.EnforceState = true;
|
||||
session.ChangeState(4, false);
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace NTwain.Tests
|
||||
[TestMethod]
|
||||
public void VerifyState_No_Throws_When_State_Is_Not_Enforced()
|
||||
{
|
||||
ITwainStateInternal session = new TwainSession(TWIdentity.Create(DataGroups.Image, new Version(1, 0), "test", "test", "test", "test"));
|
||||
ITwainStateInternal session = new TwainSessionOld(TWIdentity.Create(DataGroups.Image, new Version(1, 0), "test", "test", "test", "test"));
|
||||
session.EnforceState = false;
|
||||
session.ChangeState(4, false);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ using NTwain.Values;
|
||||
using System.Windows.Interop;
|
||||
using System.Runtime.InteropServices;
|
||||
using CommonWin32;
|
||||
using System.Threading;
|
||||
|
||||
namespace Tester.WPF
|
||||
{
|
||||
@@ -25,7 +26,7 @@ namespace Tester.WPF
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
TwainSession twain;
|
||||
TwainSessionOld twain;
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -58,7 +59,7 @@ namespace Tester.WPF
|
||||
private void SetupTwain()
|
||||
{
|
||||
TWIdentity appId = TWIdentity.Create(DataGroups.Image, new Version(1, 0), "My Company", "Test Family", "Tester", null);
|
||||
twain = new TwainSession(appId);
|
||||
twain = new TwainSessionOld(appId);
|
||||
twain.DataTransferred += (s, e) =>
|
||||
{
|
||||
if (e.Data != IntPtr.Zero)
|
||||
@@ -117,7 +118,7 @@ namespace Tester.WPF
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
step = "Open DS";
|
||||
rc = twain.OpenSource(dsId);
|
||||
rc = twain.OpenSource(dsId.ProductName);
|
||||
//rc = DGControl.Status.Get(dsId, ref stat);
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
@@ -137,7 +138,7 @@ namespace Tester.WPF
|
||||
}
|
||||
|
||||
step = "Enable DS";
|
||||
rc = twain.EnableSource(SourceEnableMode.NoUI, false, hand);
|
||||
rc = twain.EnableSource(SourceEnableMode.NoUI, false, hand, SynchronizationContext.Current);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -13,13 +13,14 @@ using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using CommonWin32;
|
||||
using System.Threading;
|
||||
|
||||
namespace Tester.Winform
|
||||
{
|
||||
sealed partial class TestForm : Form
|
||||
{
|
||||
ImageCodecInfo _tiffCodecInfo;
|
||||
TwainSession _twain;
|
||||
TwainSessionOld _twain;
|
||||
bool _stopScan;
|
||||
bool _loadingCaps;
|
||||
|
||||
@@ -63,7 +64,7 @@ namespace Tester.Winform
|
||||
|
||||
TWIdentity appId = TWIdentity.Create(DataGroups.Image, new Version(appVer.ProductMajorPart, appVer.ProductMinorPart),
|
||||
"My Company", "Test Family", "Tester", "A TWAIN testing app.");
|
||||
_twain = new TwainSession(appId);
|
||||
_twain = new TwainSessionOld(appId);
|
||||
_twain.DataTransferred += (s, e) =>
|
||||
{
|
||||
if (pictureBox1.Image != null)
|
||||
@@ -167,7 +168,7 @@ namespace Tester.Winform
|
||||
if (_twain.SupportedCaps.Contains(CapabilityId.CapUIControllable))
|
||||
{
|
||||
// hide scanner ui if possible
|
||||
if (_twain.EnableSource(SourceEnableMode.NoUI, false, hand) == ReturnCode.Success)
|
||||
if (_twain.EnableSource(SourceEnableMode.NoUI, false, hand, SynchronizationContext.Current) == ReturnCode.Success)
|
||||
{
|
||||
btnStopScan.Enabled = true;
|
||||
btnStartCapture.Enabled = false;
|
||||
@@ -176,7 +177,7 @@ namespace Tester.Winform
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_twain.EnableSource(SourceEnableMode.ShowUI, false, hand) == ReturnCode.Success)
|
||||
if (_twain.EnableSource(SourceEnableMode.ShowUI, false, hand, SynchronizationContext.Current) == ReturnCode.Success)
|
||||
{
|
||||
btnStopScan.Enabled = true;
|
||||
btnStartCapture.Enabled = false;
|
||||
@@ -360,7 +361,7 @@ namespace Tester.Winform
|
||||
private void btnAllSettings_Click(object sender, EventArgs e)
|
||||
{
|
||||
var hand = new HandleRef(this, this.Handle);
|
||||
_twain.EnableSource(SourceEnableMode.ShowUIOnly, true, hand);
|
||||
_twain.EnableSource(SourceEnableMode.ShowUIOnly, true, hand, SynchronizationContext.Current);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user