Initial move from old twain-in-dotnet.

This commit is contained in:
soukoku
2014-04-02 19:01:21 -04:00
parent d34b359f8d
commit 0a39a47d3b
116 changed files with 38426 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
using NTwain.Data;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using NTwain.Values;
namespace NTwain.Tests.Data
{
/// <summary>
///This is a test class for TWIdentity and is intended
///to contain all TWIdentityTest Unit Tests
///</summary>
[TestClass]
public class TWIdentityTest
{
// the maxlength expects null terminator so at maxlength it's over the limit
[TestMethod]
[ExpectedException(typeof(ArgumentException), "String length not enforced.")]
public void Enforce_Manufacturer_String_Length()
{
TWIdentity target = new TWIdentity();
var overLength = TwainConst.String32;
string badString = new String('a', overLength);
target.Manufacturer = badString;
}
[TestMethod]
[ExpectedException(typeof(ArgumentException), "String length not enforced.")]
public void Enforce_ProductFamily_String_Length()
{
TWIdentity target = new TWIdentity();
var overLength = TwainConst.String32;
string badString = new String('a', overLength);
target.ProductFamily = badString;
}
[TestMethod]
[ExpectedException(typeof(ArgumentException), "String length not enforced.")]
public void Enforce_ProductName_String_Length()
{
TWIdentity target = new TWIdentity();
var overLength = TwainConst.String32;
string badString = new String('a', overLength);
target.ProductName = badString;
}
}
}

View File

@@ -0,0 +1,26 @@
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

@@ -0,0 +1,25 @@
using NTwain;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using NTwain.Values;
using System.Runtime.Serialization;
using NTwain.Data;
namespace NTwain.Tests
{
[TestClass]
public class DeviceEventArgsTests
{
[TestMethod]
public void Constructor_Sets_Correct_Properties()
{
// just some non-default values to test
TWDeviceEvent evt = new TWDeviceEvent();
DeviceEventArgs target = new DeviceEventArgs(evt);
Assert.AreEqual(evt, target.DeviceEvent, "DeviceEvent mismatch.");
}
}
}

View File

@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6B034C50-A397-435F-8DDF-677B403FEBAA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NTwain.Tests</RootNamespace>
<AssemblyName>NTwain.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>Sign.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
<Visible>False</Visible>
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
<ItemGroup>
<Compile Include="DataTransferredEventArgsTests.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Data\TWIdentityTest.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="DeviceEventArgsTests.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TransferReadyEventArgsTests.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="TwainSessionTests.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="TwainStateExceptionTest.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\NTwain\NTwain.csproj">
<Project>{0C5A6FB1-0282-4D61-8354-68DEB1515001}</Project>
<Name>NTwain</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Sign.snk" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("NTwain.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Yin-Chun Wang")]
[assembly: AssemblyProduct("NTwain.Tests")]
[assembly: AssemblyCopyright("Copyright © Yin-Chun Wang 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("31489afd-4b8b-413a-b996-fb05bb6bc9fe")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

BIN
Tests/NTwain.Tests/Sign.snk Normal file

Binary file not shown.

View File

@@ -0,0 +1,39 @@
using NTwain;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using NTwain.Values;
using System.Runtime.Serialization;
using NTwain.Data;
using NTwain.Values.Cap;
using System.Collections.Generic;
namespace NTwain.Tests
{
[TestClass]
public class TransferReadyEventArgsTests
{
[TestMethod]
public void Constructor_Sets_Correct_Properties()
{
// just some non-default values to test
TWPendingXfers pending = new TWPendingXfers();
List<ImageFileFormat> formats = new List<ImageFileFormat> { ImageFileFormat.Bmp, ImageFileFormat.Tiff };
ImageFileFormat curFormat = ImageFileFormat.Tiff;
List<Compression> compressions = new List<Compression> { Compression.None, Compression.Group4 };
Compression curCompress = Compression.None;
bool fileXfer = true;
TWImageInfo info = new TWImageInfo();
TransferReadyEventArgs target = new TransferReadyEventArgs(pending, formats, curFormat, compressions, curCompress, fileXfer, info);
Assert.AreEqual(pending.Count, target.PendingCount, "PendingCount mismatch.");
Assert.AreEqual(formats, target.SupportedFormats, "SupportedFormats mismatch.");
Assert.AreEqual(curFormat, target.ImageFormat, "ImageFormat mismatch.");
Assert.AreEqual(compressions, target.SupportedCompressions, "SupportedCompressions mismatch.");
Assert.AreEqual(curCompress, target.ImageCompression, "ImageCompression mismatch.");
Assert.AreEqual(fileXfer, target.CanDoFileXfer, "CanDoFileXfer mismatch.");
Assert.AreEqual(info, target.ImageInfo, "ImageInfo mismatch.");
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NTwain.Data;
using NTwain.Values;
namespace NTwain.Tests
{
[TestClass]
public class TwainSessionTests
{
[TestMethod]
[ExpectedException(typeof(TwainStateException), "State check failed to throw.")]
public void VerifyState_Throws_When_State_Is_Enforced()
{
TwainSession session = new TwainSession(TWIdentity.Create(DataGroups.Image, new Version(1, 0), "test", "test", "test", "test"));
session.EnforceState = true;
session.State = 4;
session.VerifyState(6, 6, DataGroups.Image, DataArgumentType.ImageNativeXfer, Message.Get);
}
[TestMethod]
public void VerifyState_No_Throws_When_State_Is_Not_Enforced()
{
TwainSession session = new TwainSession(TWIdentity.Create(DataGroups.Image, new Version(1, 0), "test", "test", "test", "test"));
session.EnforceState = false;
session.State = 4;
session.VerifyState(6, 6, DataGroups.Image, DataArgumentType.ImageNativeXfer, Message.Get);
}
}
}

View File

@@ -0,0 +1,43 @@
using NTwain;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using NTwain.Values;
using System.Runtime.Serialization;
namespace NTwain.Tests
{
/// <summary>
///This is a test class for TwainStateException and is intended
///to contain all TwainStateExceptionTest Unit Tests
///</summary>
[TestClass]
public class TwainStateExceptionTest
{
/// <summary>
///A test for TwainStateException Constructor
///</summary>
[TestMethod]
public void Constructor_Sets_Correct_Properties()
{
// just some non-default values to test
int state = 3;
int minState = 4;
int maxState = 5;
DataGroups dataGroup = DataGroups.Control;
DataArgumentType argumentType = DataArgumentType.AudioNativeXfer;
Message twainMessage = Message.Copy;
string message = "THIS IS A TEST.";
TwainStateException target = new TwainStateException(state, minState, maxState, dataGroup, argumentType, twainMessage, message);
Assert.AreEqual(state, target.ActualState, "State mismatch.");
Assert.AreEqual(minState, target.MinStateExpected, "Minimum mismatch.");
Assert.AreEqual(maxState, target.MaxStateExpected, "Maximum mismatch.");
Assert.AreEqual(dataGroup, target.DataGroup, "DataGroup mismatch.");
Assert.AreEqual(argumentType, target.ArgumentType, "ArgumentType mismatch.");
Assert.AreEqual(twainMessage, target.TwainMessage, "TwainMessage mismatch.");
Assert.AreEqual(message, target.Message, "Message mismatch.");
}
}
}

21
Tests/Tester.WPF/App.xaml Normal file
View File

@@ -0,0 +1,21 @@
<Application x:Class="Tester.WPF.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<!-- Dummy Style, anything you won't use goes -->
<Style TargetType="{x:Type Rectangle}" />
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/ModernWPF;component/Themes/ModernBase.xaml" />
<ResourceDictionary Source="/ModernWPF;component/Themes/ModernLight.xaml" />
<ResourceDictionary Source="/ModernWPF;component/Themes/ModernStyles.xaml" />
<ResourceDictionary>
<Style x:Key="AppWindow" TargetType="Window" BasedOn="{StaticResource ModernWindow}"/>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

View File

@@ -0,0 +1,22 @@
using ModernWPF;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
namespace Tester.WPF
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
ModernTheme.ApplyTheme(ModernTheme.Theme.Light, Accent.Green);
base.OnStartup(e);
}
}
}

View File

@@ -0,0 +1,28 @@
<Window x:Class="Tester.WPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:modern="http://modernwpf"
Title="TWAIN Tester" Height="600" Width="900" ResizeMode="CanResizeWithGrip"
Style="{StaticResource AppWindow}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.ColumnSpan="2">
<Button Content="Test Acquire" Click="Button_Click_1"></Button>
</StackPanel>
<ListBox x:Name="CapList" Grid.Row="1" BorderThickness="0"></ListBox>
<modern:AnimatedScrollViewer Grid.Row="1" Grid.Column="1" VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto">
<Image x:Name="ImageDisplay" Stretch="Uniform" MaxWidth="1000"
RenderOptions.BitmapScalingMode="HighQuality"></Image>
</modern:AnimatedScrollViewer>
</Grid>
</Window>

View File

@@ -0,0 +1,163 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using NTwain;
using NTwain.Data;
using NTwain.Values;
using System.Windows.Interop;
using System.Runtime.InteropServices;
using NTwain.Values.Cap;
using CommonWin32;
namespace Tester.WPF
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
TwainSession twain;
public MainWindow()
{
InitializeComponent();
if (IntPtr.Size == 8)
{
Title = Title + " (64bit)";
}
else
{
Title = Title + " (32bit)";
}
SetupTwain();
}
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
var hwnd = new WindowInteropHelper(this).Handle;
HwndSource.FromHwnd(hwnd).AddHook(WndProc);
}
IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
var res = twain.PreFilterMessage(hwnd, msg, wParam, lParam, ref handled);
return res;
}
private void SetupTwain()
{
TWIdentity appId = TWIdentity.Create(DataGroups.Image, new Version(1, 0), "My Company", "Test Family", "Tester", null);
twain = new TwainSession(appId);
twain.DataTransferred += (s, e) =>
{
if (e.Data != IntPtr.Zero)
{
ImageDisplay.Source = e.Data.GetWPFBitmap();
}
else if (!string.IsNullOrEmpty(e.FilePath))
{
var img = new BitmapImage(new Uri(e.FilePath));
ImageDisplay.Source = img;
}
};
twain.SourceDisabled += delegate
{
//step = "Close DS";
var rc2 = twain.CloseSource();
rc2 = twain.CloseManager();
MessageBox.Show("Success!");
};
twain.TransferReady += (s, te) =>
{
//var type = twain.GetCurrentCap<PixelType>(CapabilityId.ICapPixelType);
//if (type == PixelType.BlackWhite)
//{
// te.ImageFormat = ImageFileFormat.Tiff;
// te.ImageCompression = Compression.Group31D;
// te.OutputFile = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "test.tif");
//}
//else
//{
//te.OutputFile = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "test.bmp");
//}
};
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
TWIdentity dsId;
TWStatus status = null;
string step = "Open DSM";
HandleRef hand = new HandleRef(this, new WindowInteropHelper(Application.Current.MainWindow).Handle);
var rc = twain.OpenManager(hand);
if (rc == ReturnCode.Success)
{
step = "User Select";
rc = twain.DGControl.Identity.UserSelect(out dsId);
//rc = DGControl.Status.Get(ref stat);
//TwEntryPoint entry;
//rc = DGControl.EntryPoint.Get(dsId, out entry);
if (rc == ReturnCode.Success)
{
step = "Open DS";
rc = twain.OpenSource(dsId);
//rc = DGControl.Status.Get(dsId, ref stat);
if (rc == ReturnCode.Success)
{
var caps = twain.SupportedCaps.Select(o =>
{
if (o > CapabilityId.CustomBase)
{
return "[Custom] " + ((int)o - (int)CapabilityId.CustomBase);
}
return o.ToString();
}).OrderBy(o => o).ToList();
CapList.ItemsSource = caps;
if (twain.CapGetPixelTypes().Contains(PixelType.BlackWhite))
{
twain.CapSetPixelType(PixelType.BlackWhite);
}
step = "Enable DS";
rc = twain.EnableSource(SourceEnableMode.NoUI, false, hand);
return;
}
else
{
twain.DGControl.Status.GetSource(out status);
}
}
else
{
twain.DGControl.Status.GetManager(out status);
}
twain.CloseManager();
}
else
{
twain.DGControl.Status.GetManager(out status);
}
MessageBox.Show(string.Format("Step {0}: RC={1}, CC={2}", step, rc, status.ConditionCode));
}
}
}

View File

@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Tester.WPF")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Yin-Chun Wang")]
[assembly: AssemblyProduct("Tester.WPF")]
[assembly: AssemblyCopyright("Copyright © Yin-Chun Wang 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18034
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Tester.WPF.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tester.WPF.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18034
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Tester.WPF.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1715C2B7-5C35-4F8B-9D9B-8D68A3D5284D}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Tester.WPF</RootNamespace>
<AssemblyName>Tester.WPF</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>
</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommonWin32, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a0a4edcfe233918d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\CommonWin32.2.0.4\lib\net35-Client\CommonWin32.dll</HintPath>
</Reference>
<Reference Include="ModernWPF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c99d0cfbea7491ef, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\ModernWPF.1.1.41.1\lib\net40-Client\ModernWPF.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\NTwain\NTwain.csproj">
<Project>{0c5a6fb1-0282-4d61-8354-68deb1515001}</Project>
<Name>NTwain</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup></configuration>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonWin32" version="2.0.4" targetFramework="net40-Client" />
<package id="ModernWPF" version="1.1.41.1" targetFramework="net40-Client" />
</packages>

View File

@@ -0,0 +1,19 @@
using System;
using System.Windows.Forms;
namespace Tester.Winform
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new TestForm());
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Tester.Winform")]
[assembly: AssemblyDescription("Winform app for quick testing implementations in the TWAIN lib.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Yin-Chun Wang")]
[assembly: AssemblyProduct("Tester.Winform")]
[assembly: AssemblyCopyright("Copyright © Yin-Chun Wang 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("81c482ce-db1a-45ac-8db8-86a784082c1b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18034
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Tester.Winform.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tester.Winform.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18034
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Tester.Winform.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

328
Tests/Tester.Winform/TestForm.Designer.cs generated Normal file
View File

@@ -0,0 +1,328 @@
namespace Tester.Winform
{
partial class TestForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TestForm));
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.btnSources = new System.Windows.Forms.ToolStripDropDownButton();
this.sepSourceList = new System.Windows.Forms.ToolStripSeparator();
this.reloadSourcesListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.btnStartCapture = new System.Windows.Forms.ToolStripButton();
this.btnStopScan = new System.Windows.Forms.ToolStripButton();
this.btnSaveImage = new System.Windows.Forms.ToolStripButton();
this.panelOptions = new System.Windows.Forms.TableLayoutPanel();
this.groupDuplex = new System.Windows.Forms.GroupBox();
this.ckDuplex = new System.Windows.Forms.CheckBox();
this.groupSize = new System.Windows.Forms.GroupBox();
this.comboSize = new System.Windows.Forms.ComboBox();
this.groupDepth = new System.Windows.Forms.GroupBox();
this.comboDepth = new System.Windows.Forms.ComboBox();
this.groupDPI = new System.Windows.Forms.GroupBox();
this.comboDPI = new System.Windows.Forms.ComboBox();
this.btnAllSettings = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.toolStrip1.SuspendLayout();
this.panelOptions.SuspendLayout();
this.groupDuplex.SuspendLayout();
this.groupSize.SuspendLayout();
this.groupDepth.SuspendLayout();
this.groupDPI.SuspendLayout();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox1.Location = new System.Drawing.Point(222, 25);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(580, 430);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 1;
this.pictureBox1.TabStop = false;
//
// saveFileDialog1
//
this.saveFileDialog1.FileName = "Test";
this.saveFileDialog1.Filter = "png files|*.png";
this.saveFileDialog1.Title = "Save Image";
//
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.btnSources,
this.btnStartCapture,
this.btnStopScan,
this.btnSaveImage});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(802, 25);
this.toolStrip1.TabIndex = 2;
this.toolStrip1.Text = "toolStrip1";
//
// btnSources
//
this.btnSources.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.btnSources.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.sepSourceList,
this.reloadSourcesListToolStripMenuItem});
this.btnSources.Image = ((System.Drawing.Image)(resources.GetObject("btnSources.Image")));
this.btnSources.ImageTransparentColor = System.Drawing.Color.Magenta;
this.btnSources.Name = "btnSources";
this.btnSources.Size = new System.Drawing.Size(94, 22);
this.btnSources.Text = "Select &sources";
this.btnSources.DropDownOpening += new System.EventHandler(this.btnSources_DropDownOpening);
//
// sepSourceList
//
this.sepSourceList.Name = "sepSourceList";
this.sepSourceList.Size = new System.Drawing.Size(168, 6);
//
// reloadSourcesListToolStripMenuItem
//
this.reloadSourcesListToolStripMenuItem.Name = "reloadSourcesListToolStripMenuItem";
this.reloadSourcesListToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.reloadSourcesListToolStripMenuItem.Text = "&Reload sources list";
this.reloadSourcesListToolStripMenuItem.Click += new System.EventHandler(this.reloadSourcesListToolStripMenuItem_Click);
//
// btnStartCapture
//
this.btnStartCapture.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.btnStartCapture.Enabled = false;
this.btnStartCapture.Image = ((System.Drawing.Image)(resources.GetObject("btnStartCapture.Image")));
this.btnStartCapture.ImageTransparentColor = System.Drawing.Color.Magenta;
this.btnStartCapture.Name = "btnStartCapture";
this.btnStartCapture.Size = new System.Drawing.Size(62, 22);
this.btnStartCapture.Text = "S&tart scan";
this.btnStartCapture.Click += new System.EventHandler(this.btnStartCapture_Click);
//
// btnStopScan
//
this.btnStopScan.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.btnStopScan.Enabled = false;
this.btnStopScan.Image = ((System.Drawing.Image)(resources.GetObject("btnStopScan.Image")));
this.btnStopScan.ImageTransparentColor = System.Drawing.Color.Magenta;
this.btnStopScan.Name = "btnStopScan";
this.btnStopScan.Size = new System.Drawing.Size(62, 22);
this.btnStopScan.Text = "Sto&p scan";
this.btnStopScan.Click += new System.EventHandler(this.btnStopScan_Click);
//
// btnSaveImage
//
this.btnSaveImage.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.btnSaveImage.Image = ((System.Drawing.Image)(resources.GetObject("btnSaveImage.Image")));
this.btnSaveImage.ImageTransparentColor = System.Drawing.Color.Magenta;
this.btnSaveImage.Name = "btnSaveImage";
this.btnSaveImage.Size = new System.Drawing.Size(71, 22);
this.btnSaveImage.Text = "S&ave image";
this.btnSaveImage.Click += new System.EventHandler(this.btnSaveImage_Click);
//
// panelOptions
//
this.panelOptions.AutoScroll = true;
this.panelOptions.ColumnCount = 1;
this.panelOptions.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.panelOptions.Controls.Add(this.groupDuplex, 0, 3);
this.panelOptions.Controls.Add(this.groupSize, 0, 2);
this.panelOptions.Controls.Add(this.groupDepth, 0, 1);
this.panelOptions.Controls.Add(this.groupDPI, 0, 0);
this.panelOptions.Controls.Add(this.btnAllSettings, 0, 6);
this.panelOptions.Dock = System.Windows.Forms.DockStyle.Left;
this.panelOptions.Location = new System.Drawing.Point(0, 25);
this.panelOptions.Name = "panelOptions";
this.panelOptions.RowCount = 7;
this.panelOptions.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.panelOptions.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.panelOptions.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.panelOptions.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.panelOptions.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.panelOptions.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.panelOptions.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.panelOptions.Size = new System.Drawing.Size(222, 430);
this.panelOptions.TabIndex = 3;
//
// groupDuplex
//
this.groupDuplex.Controls.Add(this.ckDuplex);
this.groupDuplex.Dock = System.Windows.Forms.DockStyle.Top;
this.groupDuplex.Enabled = false;
this.groupDuplex.Location = new System.Drawing.Point(8, 203);
this.groupDuplex.Margin = new System.Windows.Forms.Padding(8);
this.groupDuplex.Name = "groupDuplex";
this.groupDuplex.Size = new System.Drawing.Size(206, 58);
this.groupDuplex.TabIndex = 6;
this.groupDuplex.TabStop = false;
this.groupDuplex.Text = "Duplex";
//
// ckDuplex
//
this.ckDuplex.AutoSize = true;
this.ckDuplex.Location = new System.Drawing.Point(18, 24);
this.ckDuplex.Name = "ckDuplex";
this.ckDuplex.Size = new System.Drawing.Size(65, 17);
this.ckDuplex.TabIndex = 0;
this.ckDuplex.Text = "Enabled";
this.ckDuplex.UseVisualStyleBackColor = true;
this.ckDuplex.CheckedChanged += new System.EventHandler(this.ckDuplex_CheckedChanged);
//
// groupSize
//
this.groupSize.Controls.Add(this.comboSize);
this.groupSize.Dock = System.Windows.Forms.DockStyle.Top;
this.groupSize.Enabled = false;
this.groupSize.Location = new System.Drawing.Point(8, 138);
this.groupSize.Margin = new System.Windows.Forms.Padding(8, 8, 8, 3);
this.groupSize.Name = "groupSize";
this.groupSize.Size = new System.Drawing.Size(206, 54);
this.groupSize.TabIndex = 5;
this.groupSize.TabStop = false;
this.groupSize.Text = "Size";
//
// comboSize
//
this.comboSize.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.comboSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboSize.FormattingEnabled = true;
this.comboSize.Location = new System.Drawing.Point(18, 19);
this.comboSize.Name = "comboSize";
this.comboSize.Size = new System.Drawing.Size(169, 21);
this.comboSize.TabIndex = 0;
this.comboSize.SelectedIndexChanged += new System.EventHandler(this.comboSize_SelectedIndexChanged);
//
// groupDepth
//
this.groupDepth.Controls.Add(this.comboDepth);
this.groupDepth.Dock = System.Windows.Forms.DockStyle.Top;
this.groupDepth.Enabled = false;
this.groupDepth.Location = new System.Drawing.Point(8, 73);
this.groupDepth.Margin = new System.Windows.Forms.Padding(8, 8, 8, 3);
this.groupDepth.Name = "groupDepth";
this.groupDepth.Size = new System.Drawing.Size(206, 54);
this.groupDepth.TabIndex = 4;
this.groupDepth.TabStop = false;
this.groupDepth.Text = "Depth";
//
// comboDepth
//
this.comboDepth.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.comboDepth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboDepth.FormattingEnabled = true;
this.comboDepth.Location = new System.Drawing.Point(18, 19);
this.comboDepth.Name = "comboDepth";
this.comboDepth.Size = new System.Drawing.Size(169, 21);
this.comboDepth.TabIndex = 0;
this.comboDepth.SelectedIndexChanged += new System.EventHandler(this.comboDepth_SelectedIndexChanged);
//
// groupDPI
//
this.groupDPI.Controls.Add(this.comboDPI);
this.groupDPI.Dock = System.Windows.Forms.DockStyle.Top;
this.groupDPI.Enabled = false;
this.groupDPI.Location = new System.Drawing.Point(8, 8);
this.groupDPI.Margin = new System.Windows.Forms.Padding(8, 8, 8, 3);
this.groupDPI.Name = "groupDPI";
this.groupDPI.Size = new System.Drawing.Size(206, 54);
this.groupDPI.TabIndex = 0;
this.groupDPI.TabStop = false;
this.groupDPI.Text = "DPI";
//
// comboDPI
//
this.comboDPI.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.comboDPI.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboDPI.FormattingEnabled = true;
this.comboDPI.Location = new System.Drawing.Point(18, 19);
this.comboDPI.Name = "comboDPI";
this.comboDPI.Size = new System.Drawing.Size(169, 21);
this.comboDPI.TabIndex = 0;
this.comboDPI.SelectedIndexChanged += new System.EventHandler(this.comboDPI_SelectedIndexChanged);
//
// btnAllSettings
//
this.btnAllSettings.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.btnAllSettings.Enabled = false;
this.btnAllSettings.Location = new System.Drawing.Point(34, 312);
this.btnAllSettings.Name = "btnAllSettings";
this.btnAllSettings.Size = new System.Drawing.Size(153, 23);
this.btnAllSettings.TabIndex = 7;
this.btnAllSettings.Text = "Open driver settings";
this.btnAllSettings.UseVisualStyleBackColor = true;
this.btnAllSettings.Click += new System.EventHandler(this.btnAllSettings_Click);
//
// TestForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(802, 455);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.panelOptions);
this.Controls.Add(this.toolStrip1);
this.Name = "TestForm";
this.Text = "Test Form";
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.panelOptions.ResumeLayout(false);
this.groupDuplex.ResumeLayout(false);
this.groupDuplex.PerformLayout();
this.groupSize.ResumeLayout(false);
this.groupDepth.ResumeLayout(false);
this.groupDPI.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripDropDownButton btnSources;
private System.Windows.Forms.ToolStripSeparator sepSourceList;
private System.Windows.Forms.ToolStripMenuItem reloadSourcesListToolStripMenuItem;
private System.Windows.Forms.TableLayoutPanel panelOptions;
private System.Windows.Forms.GroupBox groupDPI;
private System.Windows.Forms.GroupBox groupDepth;
private System.Windows.Forms.GroupBox groupSize;
private System.Windows.Forms.GroupBox groupDuplex;
private System.Windows.Forms.ComboBox comboDPI;
private System.Windows.Forms.ComboBox comboSize;
private System.Windows.Forms.ComboBox comboDepth;
private System.Windows.Forms.ToolStripButton btnStartCapture;
private System.Windows.Forms.ToolStripButton btnStopScan;
private System.Windows.Forms.ToolStripButton btnSaveImage;
private System.Windows.Forms.CheckBox ckDuplex;
private System.Windows.Forms.Button btnAllSettings;
}
}

View File

@@ -0,0 +1,372 @@
using System;
using System.Windows.Forms;
using System.Linq;
using NTwain.Data;
using NTwain.Values;
using NTwain.Triplets;
using NTwain;
using System.Diagnostics;
using System.IO;
using System.Drawing.Imaging;
using System.Drawing;
using System.Runtime.InteropServices;
using NTwain.Values.Cap;
using System.Collections.Generic;
using System.Reflection;
using CommonWin32;
namespace Tester.Winform
{
sealed partial class TestForm : Form
{
ImageCodecInfo _tiffCodecInfo;
TwainSession _twain;
bool _stopScan;
bool _loadingCaps;
#region setup & cleanup
public TestForm()
{
InitializeComponent();
if (IntPtr.Size == 8)
{
Text = Text + " (64bit)";
}
else
{
Text = Text + " (32bit)";
}
foreach (var enc in ImageCodecInfo.GetImageEncoders())
{
if (enc.MimeType == "image/tiff") { _tiffCodecInfo = enc; break; }
}
SetupTwain();
}
protected override void OnFormClosing(FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing && _twain.State > 4)
{
e.Cancel = true;
}
else
{
CleanupTwain();
}
base.OnFormClosing(e);
}
private void SetupTwain()
{
var appVer = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location);
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.DataTransferred += (s, e) =>
{
if (pictureBox1.Image != null)
{
pictureBox1.Image.Dispose();
pictureBox1.Image = null;
}
if (e.Data != IntPtr.Zero)
{
//_ptrTest = e.Data;
var img = e.Data.GetDrawingBitmap();
if (img != null)
pictureBox1.Image = img;
}
else if (!string.IsNullOrEmpty(e.FilePath))
{
var img = new Bitmap(e.FilePath);
pictureBox1.Image = img;
}
};
_twain.SourceDisabled += (s, e) =>
{
btnStopScan.Enabled = false;
btnStartCapture.Enabled = true;
panelOptions.Enabled = true;
LoadSourceCaps();
};
_twain.TransferReady += (s, e) =>
{
e.CancelAll = _stopScan;
};
Application.AddMessageFilter(_twain);
}
private void CleanupTwain()
{
Application.RemoveMessageFilter(_twain);
if (_twain.State == 4)
{
_twain.CloseSource();
}
if (_twain.State == 3)
{
_twain.CloseManager();
}
if (_twain.State > 2)
{
// normal close down didn't work, do hard kill
_twain.ForceStepDown(2);
}
}
#endregion
#region toolbar
private void btnSources_DropDownOpening(object sender, EventArgs e)
{
if (btnSources.DropDownItems.Count == 2)
{
ReloadSourceList();
}
}
private void reloadSourcesListToolStripMenuItem_Click(object sender, EventArgs e)
{
ReloadSourceList();
}
void SourceMenuItem_Click(object sender, EventArgs e)
{
// do nothing if source is enabled
if (_twain.State > 4) { return; }
if (_twain.State == 4) { _twain.CloseSource(); }
foreach (var btn in btnSources.DropDownItems)
{
var srcBtn = btn as ToolStripMenuItem;
if (srcBtn != null) { srcBtn.Checked = false; }
}
var curBtn = (sender as ToolStripMenuItem);
var src = curBtn.Tag as TWIdentity;
if (_twain.OpenSource(src) == ReturnCode.Success)
{
curBtn.Checked = true;
btnStartCapture.Enabled = true;
LoadSourceCaps();
}
}
private void btnStartCapture_Click(object sender, EventArgs e)
{
if (_twain.State == 4)
{
var hand = new HandleRef(this, this.Handle);
_stopScan = false;
if (_twain.SupportedCaps.Contains(CapabilityId.CapUIControllable))
{
// hide scanner ui if possible
if (_twain.EnableSource(SourceEnableMode.NoUI, false, hand) == ReturnCode.Success)
{
btnStopScan.Enabled = true;
btnStartCapture.Enabled = false;
panelOptions.Enabled = false;
}
}
else
{
if (_twain.EnableSource(SourceEnableMode.ShowUI, false, hand) == ReturnCode.Success)
{
btnStopScan.Enabled = true;
btnStartCapture.Enabled = false;
panelOptions.Enabled = false;
}
}
}
}
private void btnStopScan_Click(object sender, EventArgs e)
{
_stopScan = true;
}
private void btnSaveImage_Click(object sender, EventArgs e)
{
var img = pictureBox1.Image;
if (img != null)
{
switch (img.PixelFormat)
{
case PixelFormat.Format1bppIndexed:
saveFileDialog1.Filter = "tiff files|*.tif";
break;
default:
saveFileDialog1.Filter = "png files|*.png";
break;
}
if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if (saveFileDialog1.FileName.EndsWith(".tif", StringComparison.OrdinalIgnoreCase))
{
EncoderParameters tiffParam = new EncoderParameters(1);
tiffParam.Param[0] = new EncoderParameter(Encoder.Compression, (long)EncoderValue.CompressionCCITT4);
pictureBox1.Image.Save(saveFileDialog1.FileName, _tiffCodecInfo, tiffParam);
}
else
{
pictureBox1.Image.Save(saveFileDialog1.FileName, ImageFormat.Png);
}
}
}
}
#endregion
#region real work
private void ReloadSourceList()
{
if (_twain.State < 3)
{
_twain.OpenManager(new HandleRef(this, this.Handle));
}
if (_twain.State >= 3)
{
while (btnSources.DropDownItems.IndexOf(sepSourceList) > 0)
{
var first = btnSources.DropDownItems[0];
first.Click -= SourceMenuItem_Click;
btnSources.DropDownItems.Remove(first);
}
foreach (var src in _twain.GetSources())
{
var srcBtn = new ToolStripMenuItem(src.ProductName);
srcBtn.Tag = src;
srcBtn.Click += SourceMenuItem_Click;
srcBtn.Checked = _twain.SourceId != null && _twain.SourceId.Id == src.Id;
btnSources.DropDownItems.Insert(0, srcBtn);
}
}
}
#region cap control
private void LoadSourceCaps()
{
var caps = _twain.SupportedCaps;
_loadingCaps = true;
if (groupDepth.Enabled = caps.Contains(CapabilityId.ICapPixelType))
{
LoadDepth();
}
if (groupDPI.Enabled = caps.Contains(CapabilityId.ICapXResolution) && caps.Contains(CapabilityId.ICapYResolution))
{
LoadDPI();
}
// TODO: find out if this is how duplex works or also needs the other option
if (groupDuplex.Enabled = caps.Contains(CapabilityId.CapDuplexEnabled))
{
LoadDuplex();
}
if (groupSize.Enabled = caps.Contains(CapabilityId.ICapSupportedSizes))
{
LoadPaperSize();
}
btnAllSettings.Enabled = caps.Contains(CapabilityId.CapEnableDSUIOnly);
_loadingCaps = false;
}
private void LoadPaperSize()
{
var list = _twain.CapGetSupportedSizes();
comboSize.DataSource = list;
var cur = _twain.GetCurrentCap<SupportedSize>(CapabilityId.ICapSupportedSizes);
if (list.Contains(cur))
{
comboSize.SelectedItem = cur;
}
}
private void LoadDuplex()
{
ckDuplex.Checked = _twain.GetCurrentCap<uint>(CapabilityId.CapDuplexEnabled) != 0;
}
private void LoadDPI()
{
// 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);
if (list.Contains(cur))
{
comboDPI.SelectedItem = cur;
}
}
private void LoadDepth()
{
var list = _twain.CapGetPixelTypes();
comboDepth.DataSource = list;
var cur = _twain.GetCurrentCap<PixelType>(CapabilityId.ICapPixelType);
if (list.Contains(cur))
{
comboDepth.SelectedItem = cur;
}
}
private void comboSize_SelectedIndexChanged(object sender, EventArgs e)
{
if (!_loadingCaps && _twain.State == 4)
{
var sel = (SupportedSize)comboSize.SelectedItem;
_twain.CapSetSupportedSize(sel);
}
}
private void comboDepth_SelectedIndexChanged(object sender, EventArgs e)
{
if (!_loadingCaps && _twain.State == 4)
{
var sel = (PixelType)comboDepth.SelectedItem;
_twain.CapSetPixelType(sel);
}
}
private void comboDPI_SelectedIndexChanged(object sender, EventArgs e)
{
if (!_loadingCaps && _twain.State == 4)
{
var sel = (int)comboDPI.SelectedItem;
_twain.CapSetDPI(sel);
}
}
private void ckDuplex_CheckedChanged(object sender, EventArgs e)
{
if (!_loadingCaps && _twain.State == 4)
{
_twain.CapSetDuplex(ckDuplex.Checked);
}
}
private void btnAllSettings_Click(object sender, EventArgs e)
{
var hand = new HandleRef(this, this.Handle);
_twain.EnableSource(SourceEnableMode.ShowUIOnly, true, hand);
}
#endregion
#endregion
}
}

View File

@@ -0,0 +1,187 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="saveFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>153, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="btnSources.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
</value>
</data>
<data name="btnStartCapture.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
</value>
</data>
<data name="btnStopScan.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
</value>
</data>
<data name="btnSaveImage.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
</value>
</data>
</root>

View File

@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{4FC243F1-318E-4FA9-9EBD-2CA3A8F35425}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Tester.Winform</RootNamespace>
<AssemblyName>Tester.Winform</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x64</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommonWin32, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a0a4edcfe233918d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\CommonWin32.2.0.4\lib\net35-Client\CommonWin32.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="TestForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="TestForm.Designer.cs">
<DependentUpon>TestForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="TestForm.resx">
<DependentUpon>TestForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\NTwain\NTwain.csproj">
<Project>{0C5A6FB1-0282-4D61-8354-68DEB1515001}</Project>
<Name>NTwain</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v2.0.50727" sku="Client"/></startup></configuration>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonWin32" version="2.0.4" targetFramework="net35-Client" />
</packages>