Re-initialized project with types and utilities from twaincs.

This commit is contained in:
Eugene Wang
2021-04-21 08:18:26 -04:00
parent b43939726a
commit a43d10ea6e
96 changed files with 24022 additions and 16247 deletions

View File

@@ -1,19 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RootNamespace>ConsoleApp</RootNamespace>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\NTwain\NTwain.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,107 +0,0 @@
using NTwain;
using System;
using System.Reflection;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
TwainSession session = null;
try
{
var config = new TwainConfigBuilder()
.DefineApp(Assembly.GetExecutingAssembly())
.Build();
Console.WriteLine($"App = {(config.Is32Bit ? "32bit" : "64bit")}");
Console.WriteLine($"Platform = {config.Platform}");
Console.WriteLine();
session = new TwainSession(config);
session.PropertyChanged += Session_PropertyChanged;
session.SourceDisabled += Session_SourceDisabled;
if (session.Open(IntPtr.Zero) == NTwain.Data.ReturnCode.Success)
{
Console.WriteLine("Available data sources:");
DataSource firstSrc = null;
foreach (var src in session.GetSources())
{
if (firstSrc == null) firstSrc = src;
Console.WriteLine($"\t{src}");
}
Console.WriteLine();
var defaultSrc = session.DefaultSource;
Console.WriteLine($"Default data source = {defaultSrc}");
Console.WriteLine();
var selectSrc = session.ShowSourceSelector();
Console.WriteLine($"Selected data source = {selectSrc}");
Console.WriteLine();
var targetSrc = selectSrc ?? defaultSrc ?? firstSrc;
if (targetSrc != null)
{
TestThisSource(session, targetSrc);
}
else
{
Console.WriteLine("No data source to test.");
Console.WriteLine();
}
}
}
catch (Exception ex)
{
Console.WriteLine("ERROR: " + ex.ToString());
}
Console.WriteLine("---------------------------------------------");
Console.WriteLine("Test in progress, press Enter to stop testing");
Console.WriteLine("---------------------------------------------");
Console.ReadLine();
var rc = session.StepDown(NTwain.Data.TwainState.S1);
Console.WriteLine("Session StepDown RC=" + rc);
Console.WriteLine("-------------------");
Console.WriteLine("Press Enter to exit");
Console.WriteLine("-------------------");
Console.ReadLine();
}
private static void Session_SourceDisabled(object sender, EventArgs e)
{
var session = (TwainSession)sender;
Console.WriteLine($"Session source disabled.");
session.CurrentSource.Close();
}
private static void TestThisSource(TwainSession session, DataSource source)
{
Console.WriteLine($"Testing data source {source}");
Console.WriteLine();
source.Open();
var testStatus = session.GetStatus();
var testMessage = session.GetLocalizedStatus(ref testStatus);
var rc = source.ShowUI(IntPtr.Zero);
}
private static void Session_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
var session = (TwainSession)sender;
if (e.PropertyName == "State")
{
Console.WriteLine($"Session state changed to {session.State}");
}
}
}
}

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

View File

@@ -1,66 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" 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>{30C684E3-7C3E-4579-9E81-6E66236C253D}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ConsoleApp</RootNamespace>
<AssemblyName>NetFXConsole</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>7.1</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\NetCoreConsole\Program.cs">
<Link>Program.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\NTwain\NTwain.csproj">
<Project>{99a8d582-2cc1-479c-859d-c5a528a7b5c3}</Project>
<Name>NTwain</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -1,36 +0,0 @@
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("NetFXConsole")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NetFXConsole")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[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("30c684e3-7c3e-4579-9e81-6e66236c253d")]
// 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")]