Updated string read and fixed sample.

This commit is contained in:
soukoku
2014-04-10 07:30:00 -04:00
parent 9d30efe92a
commit f861cd8c60
13 changed files with 175 additions and 79 deletions

View File

@@ -1,26 +0,0 @@
using NTwain;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using NTwain.Values;
using System.Runtime.Serialization;
namespace NTwain.Tests
{
[TestClass]
public class DataTransferredEventArgsTests
{
[TestMethod]
public void Constructor_Sets_Correct_Properties()
{
// just some non-default values to test
IntPtr data = new IntPtr(10);
string file = "THIS IS A TEST.";
DataTransferredEventArgs target = new DataTransferredEventArgs(data, file);
Assert.AreEqual(data, target.Data, "Data mismatch.");
Assert.AreEqual(file, target.FilePath, "File mismatch.");
}
}
}

View File

@@ -54,9 +54,6 @@
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
<ItemGroup>
<Compile Include="DataTransferredEventArgsTests.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Data\TWIdentityTest.cs">
<SubType>Code</SubType>
</Compile>

View File

@@ -93,7 +93,7 @@ namespace Tester
static void twain_DataTransferred(object sender, DataTransferredEventArgs e)
{
if (e.Data != IntPtr.Zero)
if (e.NativeData != IntPtr.Zero)
{
Console.WriteLine("Got twain data on thread {0}", Thread.CurrentThread.ManagedThreadId);
}

View File

@@ -63,9 +63,9 @@ namespace Tester.WPF
protected override void OnDataTransferred(DataTransferredEventArgs e)
{
if (e.Data != IntPtr.Zero)
if (e.NativeData != IntPtr.Zero)
{
Image = e.Data.GetWPFBitmap();
Image = e.NativeData.GetWPFBitmap();
}
else if (!string.IsNullOrEmpty(e.FilePath))
{

View File

@@ -69,10 +69,10 @@ namespace Tester.Winform
pictureBox1.Image.Dispose();
pictureBox1.Image = null;
}
if (e.Data != IntPtr.Zero)
if (e.NativeData != IntPtr.Zero)
{
//_ptrTest = e.Data;
var img = e.Data.GetDrawingBitmap();
var img = e.NativeData.GetDrawingBitmap();
if (img != null)
pictureBox1.Image = img;
}
@@ -284,7 +284,7 @@ namespace Tester.Winform
{
var list = _twain.CapGetSupportedSizes();
comboSize.DataSource = list;
var cur = _twain.GetCurrentCap<SupportedSize>(CapabilityId.ICapSupportedSizes);
var cur = _twain.GetCurrentCap(CapabilityId.ICapSupportedSizes).ConvertToEnum<SupportedSize>();
if (list.Contains(cur))
{
comboSize.SelectedItem = cur;
@@ -293,7 +293,7 @@ namespace Tester.Winform
private void LoadDuplex()
{
ckDuplex.Checked = _twain.GetCurrentCap<uint>(CapabilityId.CapDuplexEnabled) != 0;
ckDuplex.Checked = _twain.GetCurrentCap(CapabilityId.CapDuplexEnabled).ConvertToEnum<uint>() != 0;
}
private void LoadDPI()
@@ -301,7 +301,7 @@ namespace Tester.Winform
// only allow dpi of certain values for those source that lists everything
var list = _twain.CapGetDPIs().Where(dpi => (dpi % 50) == 0).ToList();
comboDPI.DataSource = list;
var cur = _twain.GetCurrentCap<int>(CapabilityId.ICapXResolution);
var cur = (TWFix32)_twain.GetCurrentCap(CapabilityId.ICapXResolution);
if (list.Contains(cur))
{
comboDPI.SelectedItem = cur;
@@ -312,7 +312,7 @@ namespace Tester.Winform
{
var list = _twain.CapGetPixelTypes();
comboDepth.DataSource = list;
var cur = _twain.GetCurrentCap<PixelType>(CapabilityId.ICapPixelType);
var cur = _twain.GetCurrentCap(CapabilityId.ICapPixelType).ConvertToEnum<PixelType>();
if (list.Contains(cur))
{
comboDepth.SelectedItem = cur;