Made framework 4 the default and added fx3 as old.

This commit is contained in:
soukoku
2014-04-20 09:09:25 -04:00
parent 5b1997236a
commit 06d1358fd1
12 changed files with 392 additions and 38 deletions

View File

@@ -0,0 +1,281 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.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>{2E965494-94B0-4EC7-960C-24E5D7D04278}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NTwain</RootNamespace>
<AssemblyName>NTwain</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\NTwain\bin\Debug\Net35\</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>..\NTwain\bin\Release\Net35\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>..\NTwain\bin\Release\Net35\NTwain.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>Sign.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\NTwain\DataTransferredEventArgs.cs">
<Link>DataTransferredEventArgs.cs</Link>
</Compile>
<Compile Include="..\NTwain\Data\CapReadOut.cs">
<Link>Data\CapReadOut.cs</Link>
</Compile>
<Compile Include="..\NTwain\Data\TypeReader.cs">
<Link>Data\TypeReader.cs</Link>
</Compile>
<Compile Include="..\NTwain\Data\Types.cs">
<Link>Data\Types.cs</Link>
</Compile>
<Compile Include="..\NTwain\Data\TypesExtended.cs">
<Link>Data\TypesExtended.cs</Link>
</Compile>
<Compile Include="..\NTwain\DeviceEventArgs.cs">
<Link>DeviceEventArgs.cs</Link>
</Compile>
<Compile Include="..\NTwain\Extensions.cs">
<Link>Extensions.cs</Link>
</Compile>
<Compile Include="..\NTwain\IMemoryManager.cs">
<Link>IMemoryManager.cs</Link>
</Compile>
<Compile Include="..\NTwain\ITwainOperation.cs">
<Link>ITwainOperation.cs</Link>
</Compile>
<Compile Include="..\NTwain\ITwainState.cs">
<Link>ITwainState.cs</Link>
</Compile>
<Compile Include="..\NTwain\MemoryManager.cs">
<Link>MemoryManager.cs</Link>
</Compile>
<Compile Include="..\NTwain\MessageLoop.cs">
<Link>MessageLoop.cs</Link>
</Compile>
<Compile Include="..\NTwain\NativeMethods.cs">
<Link>NativeMethods.cs</Link>
</Compile>
<Compile Include="..\NTwain\Properties\AssemblyInfo.cs">
<Link>Properties\AssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\NTwain\Properties\Resources.Designer.cs">
<Link>Properties\Resources.Designer.cs</Link>
<DependentUpon>Resources.resx</DependentUpon>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="..\NTwain\Properties\VersionInfo.cs">
<Link>Properties\VersionInfo.cs</Link>
</Compile>
<Compile Include="..\NTwain\TentativeStateCommitable.cs">
<Link>TentativeStateCommitable.cs</Link>
</Compile>
<Compile Include="..\NTwain\TransferErrorEventArgs.cs">
<Link>TransferErrorEventArgs.cs</Link>
</Compile>
<Compile Include="..\NTwain\TransferReadyEventArgs.cs">
<Link>TransferReadyEventArgs.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGAudio\DGAudio.AudioFileXfer.cs">
<Link>Triplets\DGAudio\DGAudio.AudioFileXfer.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGAudio\DGAudio.AudioInfo.cs">
<Link>Triplets\DGAudio\DGAudio.AudioInfo.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGAudio\DGAudio.AudioNativeXfer.cs">
<Link>Triplets\DGAudio\DGAudio.AudioNativeXfer.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGAudio\DGAudio.cs">
<Link>Triplets\DGAudio\DGAudio.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.Callback.cs">
<Link>Triplets\DGControl\DGControl.Callback.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.Callback2.cs">
<Link>Triplets\DGControl\DGControl.Callback2.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.Capability.cs">
<Link>Triplets\DGControl\DGControl.Capability.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.cs">
<Link>Triplets\DGControl\DGControl.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.CustomDSData.cs">
<Link>Triplets\DGControl\DGControl.CustomDSData.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.DeviceEvent.cs">
<Link>Triplets\DGControl\DGControl.DeviceEvent.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.EntryPoint.cs">
<Link>Triplets\DGControl\DGControl.EntryPoint.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.Event.cs">
<Link>Triplets\DGControl\DGControl.Event.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.FileSystem.cs">
<Link>Triplets\DGControl\DGControl.FileSystem.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.Identity.cs">
<Link>Triplets\DGControl\DGControl.Identity.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.Parent.cs">
<Link>Triplets\DGControl\DGControl.Parent.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.PassThru.cs">
<Link>Triplets\DGControl\DGControl.PassThru.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.PendingXfers.cs">
<Link>Triplets\DGControl\DGControl.PendingXfers.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.SetupFileXfer.cs">
<Link>Triplets\DGControl\DGControl.SetupFileXfer.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.SetupMemXfer.cs">
<Link>Triplets\DGControl\DGControl.SetupMemXfer.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.Status.cs">
<Link>Triplets\DGControl\DGControl.Status.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.StatusUtf8.cs">
<Link>Triplets\DGControl\DGControl.StatusUtf8.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.UserInterface.cs">
<Link>Triplets\DGControl\DGControl.UserInterface.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGControl\DGControl.XferGroup.cs">
<Link>Triplets\DGControl\DGControl.XferGroup.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGImage\DGImage.CieColor.cs">
<Link>Triplets\DGImage\DGImage.CieColor.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGImage\DGImage.cs">
<Link>Triplets\DGImage\DGImage.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGImage\DGImage.ExtImageInfo.cs">
<Link>Triplets\DGImage\DGImage.ExtImageInfo.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGImage\DGImage.Filter.cs">
<Link>Triplets\DGImage\DGImage.Filter.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGImage\DGImage.GrayResponse.cs">
<Link>Triplets\DGImage\DGImage.GrayResponse.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGImage\DGImage.IccProfile.cs">
<Link>Triplets\DGImage\DGImage.IccProfile.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGImage\DGImage.ImageFileXfer.cs">
<Link>Triplets\DGImage\DGImage.ImageFileXfer.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGImage\DGImage.ImageInfo.cs">
<Link>Triplets\DGImage\DGImage.ImageInfo.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGImage\DGImage.ImageLayout.cs">
<Link>Triplets\DGImage\DGImage.ImageLayout.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGImage\DGImage.ImageMemFileXfer.cs">
<Link>Triplets\DGImage\DGImage.ImageMemFileXfer.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGImage\DGImage.ImageMemXfer.cs">
<Link>Triplets\DGImage\DGImage.ImageMemXfer.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGImage\DGImage.ImageNativeXfer.cs">
<Link>Triplets\DGImage\DGImage.ImageNativeXfer.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGImage\DGImage.JpegCompression.cs">
<Link>Triplets\DGImage\DGImage.JpegCompression.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGImage\DGImage.Palette8.cs">
<Link>Triplets\DGImage\DGImage.Palette8.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\DGImage\DGImage.RgbResponse.cs">
<Link>Triplets\DGImage\DGImage.RgbResponse.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\Dsm.cs">
<Link>Triplets\Dsm.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\Dsm.Linux.cs">
<Link>Triplets\Dsm.Linux.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\Dsm.WinNew.cs">
<Link>Triplets\Dsm.WinNew.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\Dsm.WinOld.cs">
<Link>Triplets\Dsm.WinOld.cs</Link>
</Compile>
<Compile Include="..\NTwain\Triplets\OpBase.cs">
<Link>Triplets\OpBase.cs</Link>
</Compile>
<Compile Include="..\NTwain\TwainException.cs">
<Link>TwainException.cs</Link>
</Compile>
<Compile Include="..\NTwain\TwainSession.cs">
<Link>TwainSession.cs</Link>
</Compile>
<Compile Include="..\NTwain\TwainSessionExtensions.cs">
<Link>TwainSessionExtensions.cs</Link>
</Compile>
<Compile Include="..\NTwain\TwainStateException.cs">
<Link>TwainStateException.cs</Link>
</Compile>
<Compile Include="..\NTwain\Values\DataValues.cs">
<Link>Values\DataValues.cs</Link>
</Compile>
<Compile Include="..\NTwain\Values\SourceEnableMode.cs">
<Link>Values\SourceEnableMode.cs</Link>
</Compile>
<Compile Include="..\NTwain\Values\TwainConst.cs">
<Link>Values\TwainConst.cs</Link>
</Compile>
<Compile Include="..\NTwain\Values\ValueConverter.cs">
<Link>Values\ValueConverter.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\NTwain\Properties\Resources.resx">
<Link>Properties\Resources.resx</Link>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="..\NTwain\Triplets\WhatsThis.txt">
<Link>Triplets\WhatsThis.txt</Link>
</None>
<None Include="Sign.snk" />
</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>

BIN
NTwain.Net35/Sign.snk Normal file

Binary file not shown.

View File

@@ -22,6 +22,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Others", "Others", "{4CE0B9
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tester.Console", "Tests\Tester.Console\Tester.Console.csproj", "{12D761EF-68DF-41CE-92EF-0C7AE81857A3}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tester.Console", "Tests\Tester.Console\Tester.Console.csproj", "{12D761EF-68DF-41CE-92EF-0C7AE81857A3}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NTwain.Net35", "NTwain.Net35\NTwain.Net35.csproj", "{2E965494-94B0-4EC7-960C-24E5D7D04278}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -81,6 +83,16 @@ Global
{12D761EF-68DF-41CE-92EF-0C7AE81857A3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {12D761EF-68DF-41CE-92EF-0C7AE81857A3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{12D761EF-68DF-41CE-92EF-0C7AE81857A3}.Release|Mixed Platforms.Build.0 = Release|Any CPU {12D761EF-68DF-41CE-92EF-0C7AE81857A3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{12D761EF-68DF-41CE-92EF-0C7AE81857A3}.Release|x86.ActiveCfg = Release|Any CPU {12D761EF-68DF-41CE-92EF-0C7AE81857A3}.Release|x86.ActiveCfg = Release|Any CPU
{2E965494-94B0-4EC7-960C-24E5D7D04278}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E965494-94B0-4EC7-960C-24E5D7D04278}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E965494-94B0-4EC7-960C-24E5D7D04278}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{2E965494-94B0-4EC7-960C-24E5D7D04278}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{2E965494-94B0-4EC7-960C-24E5D7D04278}.Debug|x86.ActiveCfg = Debug|Any CPU
{2E965494-94B0-4EC7-960C-24E5D7D04278}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E965494-94B0-4EC7-960C-24E5D7D04278}.Release|Any CPU.Build.0 = Release|Any CPU
{2E965494-94B0-4EC7-960C-24E5D7D04278}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2E965494-94B0-4EC7-960C-24E5D7D04278}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2E965494-94B0-4EC7-960C-24E5D7D04278}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -707,7 +707,7 @@ namespace NTwain.Data
ContainerType = Values.ContainerType.Enum; ContainerType = Values.ContainerType.Enum;
Int32 valueSize = value.ItemOffset + value.ItemList.Length * TypeReader.GetItemTypeSize(value.ItemType); Int32 valueSize = TWEnumeration.ItemOffset + value.ItemList.Length * TypeReader.GetItemTypeSize(value.ItemType);
int offset = 0; int offset = 0;
_hContainer = MemoryManager.Instance.Allocate((uint)valueSize); _hContainer = MemoryManager.Instance.Allocate((uint)valueSize);
@@ -817,7 +817,7 @@ namespace NTwain.Data
/// <param name="offset"></param> /// <param name="offset"></param>
/// <param name="item"></param> /// <param name="item"></param>
/// <param name="maxLength"></param> /// <param name="maxLength"></param>
private void WriteString(IntPtr baseAddr, int offset, string item, int maxLength) static void WriteString(IntPtr baseAddr, int offset, string item, int maxLength)
{ {
if (string.IsNullOrEmpty(item)) if (string.IsNullOrEmpty(item))
{ {
@@ -1262,7 +1262,7 @@ namespace NTwain.Data
/// <summary> /// <summary>
/// Gets the byte offset of the item list from a Ptr to the first item. /// Gets the byte offset of the item list from a Ptr to the first item.
/// </summary> /// </summary>
internal int ItemOffset { get { return 14; } } internal const int ItemOffset = 14;
} }
@@ -1695,9 +1695,12 @@ namespace NTwain.Data
/// <param name="productName">Name of the product.</param> /// <param name="productName">Name of the product.</param>
/// <param name="productDescription">The product description.</param> /// <param name="productDescription">The product description.</param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="ArgumentNullException">version</exception>
public static TWIdentity Create(DataGroups supportedGroups, Version version, public static TWIdentity Create(DataGroups supportedGroups, Version version,
string manufacturer, string productFamily, string productName, string productDescription) string manufacturer, string productFamily, string productName, string productDescription)
{ {
if (version == null) { throw new ArgumentNullException("version"); }
return new TWIdentity return new TWIdentity
{ {
Manufacturer = string.IsNullOrEmpty(manufacturer) ? "UNKNOWN" : manufacturer, Manufacturer = string.IsNullOrEmpty(manufacturer) ? "UNKNOWN" : manufacturer,
@@ -1796,7 +1799,7 @@ namespace NTwain.Data
/// The compression method used to process the data being transferred. /// The compression method used to process the data being transferred.
/// Default is no compression. /// Default is no compression.
/// </summary> /// </summary>
public Compression Compression { get { return (Values.Compression)_compression; } } public CompressionType Compression { get { return (Values.CompressionType)_compression; } }
} }
/// <summary> /// <summary>
@@ -1877,7 +1880,7 @@ namespace NTwain.Data
/// <summary> /// <summary>
/// The compression method used to process the data being transferred. /// The compression method used to process the data being transferred.
/// </summary> /// </summary>
public Compression Compression { get { return (Compression)_compression; } } public CompressionType Compression { get { return (CompressionType)_compression; } }
/// <summary> /// <summary>
/// The number of uncompressed bytes in each row of the piece of the image /// The number of uncompressed bytes in each row of the piece of the image
/// being described in this buffer. /// being described in this buffer.
@@ -2221,10 +2224,10 @@ namespace NTwain.Data
/// TwIdentity.Language or CapLanguage). The Source allocates /// TwIdentity.Language or CapLanguage). The Source allocates
/// it, the Application frees it. /// it, the Application frees it.
/// </summary> /// </summary>
IntPtr UTF8StringPtr { get { return _uTF8string; } } public IntPtr UTF8StringPtr { get { return _uTF8string; } }
/// <summary> /// <summary>
/// Gets the actual string from the pointer. /// Gets the actual string from the pointer. This may be incorrect.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public string GetActualString() public string GetActualString()

View File

@@ -26,7 +26,7 @@ namespace NTwain
if (_dispatcher == null) if (_dispatcher == null)
{ {
// using this terrible hack so the new thread will start running before this function returns // using this terrible hack so the new thread will start running before this function returns
using (var hack = new ManualResetEvent(false)) using (var hack = new WrappedManualResetEvent())
{ {
var loopThread = new Thread(new ThreadStart(() => var loopThread = new Thread(new ThreadStart(() =>
{ {
@@ -49,7 +49,7 @@ namespace NTwain
loopThread.IsBackground = true; loopThread.IsBackground = true;
loopThread.SetApartmentState(ApartmentState.STA); loopThread.SetApartmentState(ApartmentState.STA);
loopThread.Start(); loopThread.Start();
hack.WaitOne(); hack.Wait();
} }
} }
} }
@@ -79,7 +79,7 @@ namespace NTwain
} }
else if (Dsm.IsOnMono) else if (Dsm.IsOnMono)
{ {
using (var man = new ManualResetEvent(false)) using (var man = new WrappedManualResetEvent())
{ {
_dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => _dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
{ {
@@ -92,7 +92,7 @@ namespace NTwain
man.Set(); man.Set();
} }
})); }));
man.WaitOne(); man.Wait();
} }
} }
else else
@@ -117,12 +117,20 @@ namespace NTwain
// hook into windows msg loop for old twain to post msgs. // hook into windows msg loop for old twain to post msgs.
// the style values are purely guesses here with // the style values are purely guesses here with
// CS_NOCLOSE, WS_DISABLED, and WS_EX_NOACTIVATE // CS_NOCLOSE, WS_DISABLED, and WS_EX_NOACTIVATE
var win = new HwndSource(0x0200, 0x8000000, 0x8000000, 0, 0, "NTWAIN_LOOPER", IntPtr.Zero); HwndSource win = null;
try
{
win = new HwndSource(0x0200, 0x8000000, 0x8000000, 0, 0, "NTWAIN_LOOPER", IntPtr.Zero);
Handle = win.Handle; Handle = win.Handle;
win.AddHook(WndProc); win.AddHook(WndProc);
_win = win; _win = win;
_hook = hook; _hook = hook;
} }
catch
{
if (win != null) { win.Dispose(); }
}
}
public delegate void WndProcHook(ref MESSAGE winMsg, ref bool handled); public delegate void WndProcHook(ref MESSAGE winMsg, ref bool handled);
@@ -180,4 +188,55 @@ namespace NTwain
#endregion #endregion
} }
// just a test
class WrappedManualResetEvent : IDisposable
{
#if NET4
ManualResetEventSlim _slim;
#else
ManualResetEvent _mre;
#endif
public WrappedManualResetEvent()
{
#if NET4
_slim = new ManualResetEventSlim();
#else
_mre = new ManualResetEvent(false);
#endif
}
public void Wait()
{
#if NET4
_slim.Wait();
#else
_mre.WaitOne();
#endif
}
public void Set()
{
#if NET4
_slim.Set();
#else
_mre.Set();
#endif
}
#region IDisposable Members
public void Dispose()
{
#if NET4
_slim.Dispose();
#else
_mre.Close();
#endif
}
#endregion
}
} }

View File

@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NTwain</RootNamespace> <RootNamespace>NTwain</RootNamespace>
<AssemblyName>NTwain</AssemblyName> <AssemblyName>NTwain</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir> <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<TargetFrameworkProfile>Client</TargetFrameworkProfile> <TargetFrameworkProfile>Client</TargetFrameworkProfile>
@@ -33,11 +33,12 @@
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;WIN32</DefineConstants> <DefineConstants>TRACE;NET4</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\NTwain.xml</DocumentationFile> <DocumentationFile>bin\Release\NTwain.xml</DocumentationFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>
@@ -48,8 +49,6 @@
<ItemGroup> <ItemGroup>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -16,9 +16,9 @@
<tags>twain scan</tags> <tags>twain scan</tags>
</metadata> </metadata>
<files> <files>
<file src="bin\$configuration$\$id$.pdb" target="lib\net35-client"/> <file src="bin\$configuration$\$id$.pdb" target="lib\net40-client"/>
<!--<file src="bin\$configuration$\Net4\$id$.dll" target="lib\net40-client"/> <file src="bin\$configuration$\Net35\$id$.dll" target="lib\net35-client"/>
<file src="bin\$configuration$\Net4\$id$.xml" target="lib\net40-client"/> <file src="bin\$configuration$\Net35\$id$.xml" target="lib\net35-client"/>
<file src="bin\$configuration$\Net4\$id$.pdb" target="lib\net40-client"/>--> <file src="bin\$configuration$\Net35\$id$.pdb" target="lib\net35-client"/>
</files> </files>
</package> </package>

View File

@@ -1,6 +1,7 @@
using NTwain.Data; using NTwain.Data;
using NTwain.Values; using NTwain.Values;
using System; using System;
using System.IO;
namespace NTwain.Triplets namespace NTwain.Triplets
{ {
@@ -27,9 +28,8 @@ namespace NTwain.Triplets
return IntPtr.Size == 8; return IntPtr.Size == 8;
#else #else
var path = Path.Combine(Environment.SystemDirectory, "twaindsm.dll"); var path = Path.Combine(Environment.SystemDirectory, "twaindsm.dll");
// if 64bit or the dll exists use it // if 64bit or the new dll exists use it
return IntPtr.Size == 8 || return IntPtr.Size == 8 || File.Exists(path);
File.Exists(path);
#endif #endif
} }
internal static readonly bool IsOnMono = Type.GetType("Mono.Runtime") != null; internal static readonly bool IsOnMono = Type.GetType("Mono.Runtime") != null;

View File

@@ -213,14 +213,14 @@ namespace NTwain
#region compression #region compression
/// <summary> /// <summary>
/// Gets the supported <see cref="Compression"/> for the current source. /// Gets the supported <see cref="CompressionType"/> for the current source.
/// Only call this at state 4 or higher. /// Only call this at state 4 or higher.
/// </summary> /// </summary>
/// <param name="session">The session.</param> /// <param name="session">The session.</param>
/// <returns></returns> /// <returns></returns>
public static IList<Compression> CapGetCompression(this TwainSession session) public static IList<CompressionType> CapGetCompression(this TwainSession session)
{ {
return session.GetCapabilityValues(CapabilityId.ICapCompression).CastToEnum<Compression>(true); return session.GetCapabilityValues(CapabilityId.ICapCompression).CastToEnum<CompressionType>(true);
} }
/// <summary> /// <summary>
@@ -229,7 +229,7 @@ namespace NTwain
/// <param name="session">The session.</param> /// <param name="session">The session.</param>
/// <param name="compression">The compression.</param> /// <param name="compression">The compression.</param>
/// <returns></returns> /// <returns></returns>
public static ReturnCode CapSetImageCompression(this TwainSession session, Compression compression) public static ReturnCode CapSetImageCompression(this TwainSession session, CompressionType compression)
{ {
using (TWCapability compressCap = new TWCapability(CapabilityId.ICapCompression, new TWOneValue { Item = (uint)compression, ItemType = Values.ItemType.UInt16 })) using (TWCapability compressCap = new TWCapability(CapabilityId.ICapCompression, new TWOneValue { Item = (uint)compression, ItemType = Values.ItemType.UInt16 }))
{ {

View File

@@ -267,7 +267,7 @@ namespace NTwain.Values
/// setting the desired file format with ICAP_IMAGEFILEFORMAT. /// setting the desired file format with ICAP_IMAGEFILEFORMAT.
/// Corresponds to TWCP_* values. /// Corresponds to TWCP_* values.
/// </summary> /// </summary>
public enum Compression : ushort public enum CompressionType : ushort
{ {
/// <summary> /// <summary>
/// All Sources must support this. /// All Sources must support this.

View File

@@ -426,7 +426,7 @@ namespace Tester.WPF
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap); CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);
break; break;
case CapabilityId.ICapCompression: case CapabilityId.ICapCompression:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<Compression>(); CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<CompressionType>();
break; break;
case CapabilityId.ICapContrast: case CapabilityId.ICapContrast:
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap); CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap);

View File

@@ -79,9 +79,9 @@
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\NTwain\NTwain.csproj"> <ProjectReference Include="..\..\NTwain.Net35\NTwain.Net35.csproj">
<Project>{0C5A6FB1-0282-4D61-8354-68DEB1515001}</Project> <Project>{2e965494-94b0-4ec7-960c-24e5d7d04278}</Project>
<Name>NTwain</Name> <Name>NTwain.Net35</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />