mirror of
https://github.com/cyanfish/naps2.git
synced 2024-08-16 10:40:35 +03:00
Separated out console/automation stuff into a separate project, NAPS2.Console.
This commit is contained in:
parent
61363fec70
commit
4775859f0f
31
NAPS2.Console/.gitignore
vendored
Normal file
31
NAPS2.Console/.gitignore
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
Thumbs.db
|
||||
*.obj
|
||||
*.exe
|
||||
*.pdb
|
||||
*.user
|
||||
*.aps
|
||||
*.pch
|
||||
*.vspscc
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ncb
|
||||
*.suo
|
||||
*.sln.docstates
|
||||
*.tlb
|
||||
*.tlh
|
||||
*.bak
|
||||
*.cache
|
||||
*.ilk
|
||||
*.log
|
||||
[Bb]in
|
||||
[Dd]ebug*/
|
||||
*.lib
|
||||
*.sbr
|
||||
obj/
|
||||
[Rr]elease*/
|
||||
_ReSharper*/
|
||||
[Tt]est[Rr]esult*
|
||||
*.vssscc
|
||||
$tf*/
|
||||
publish/
|
||||
bin/
|
6
NAPS2.Console/App.config
Normal file
6
NAPS2.Console/App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using CommandLine;
|
||||
using CommandLine.Text;
|
||||
|
||||
namespace NAPS2
|
||||
{
|
||||
@ -24,6 +24,15 @@ namespace NAPS2
|
||||
[Option('d', "delay", DefaultValue = 0, HelpText = "The delay (in milliseconds) before each page is scanned.")]
|
||||
public int Delay { get; set; }
|
||||
|
||||
[ParserState]
|
||||
public IParserState LastParserState { get; set; }
|
||||
|
||||
[HelpOption]
|
||||
public string GetUsage()
|
||||
{
|
||||
return HelpText.AutoBuild(this, current => HelpText.DefaultParsingErrorsHandler(this, current));
|
||||
}
|
||||
|
||||
// TODO: PDF/Image/ImageFormat
|
||||
}
|
||||
}
|
61
NAPS2.Console/KernelManager.cs
Normal file
61
NAPS2.Console/KernelManager.cs
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
NAPS2 (Not Another PDF Scanner 2)
|
||||
http://sourceforge.net/projects/naps2/
|
||||
|
||||
Copyright (C) 2009 Pavel Sorejs
|
||||
Copyright (C) 2012 Michael Adams
|
||||
Copyright (C) 2013 Peter De Leeuw
|
||||
Copyright (C) 2012-2013 Ben Olden-Cooligan
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NAPS2.Email;
|
||||
using NAPS2.Pdf;
|
||||
using NAPS2.Scan;
|
||||
using NAPS2.Scan.Stub;
|
||||
using NAPS2.Scan.Twain;
|
||||
using NAPS2.Scan.Wia;
|
||||
using Ninject;
|
||||
using Ninject.Modules;
|
||||
|
||||
namespace NAPS2
|
||||
{
|
||||
static class KernelManager
|
||||
{
|
||||
static KernelManager()
|
||||
{
|
||||
Kernel = new StandardKernel(new DependenciesModule());
|
||||
}
|
||||
|
||||
public static IKernel Kernel { get; private set; }
|
||||
|
||||
private class DependenciesModule : NinjectModule
|
||||
{
|
||||
public override void Load()
|
||||
{
|
||||
Bind<IScanPerformer>().To<ScanPerformer>();
|
||||
Bind<IProfileManager>().To<ProfileManager>().InSingletonScope();
|
||||
Bind<IPdfExporter>().To<PdfSharpExporter>();
|
||||
Bind<IEmailer>().To<MAPIEmailer>();
|
||||
#if DEBUG
|
||||
Bind<IScanDriver>().To<StubWiaScanDriver>().Named(WiaScanDriver.DRIVER_NAME);
|
||||
Bind<IScanDriver>().To<StubTwainScanDriver>().Named(TwainScanDriver.DRIVER_NAME);
|
||||
#else
|
||||
Bind<IScanDriver>().To<WiaScanDriver>().Named(WiaScanDriver.DRIVER_NAME);
|
||||
Bind<IScanDriver>().To<TwainScanDriver>().Named(TwainScanDriver.DRIVER_NAME);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
77
NAPS2.Console/NAPS2.Console.csproj
Normal file
77
NAPS2.Console/NAPS2.Console.csproj
Normal file
@ -0,0 +1,77 @@
|
||||
<?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>{2A321772-75B2-4601-A718-AF0A2370E6A8}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>NAPS2.Console</RootNamespace>
|
||||
<AssemblyName>NAPS2.Console</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
</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>
|
||||
</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>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="CommandLine">
|
||||
<HintPath>..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Ninject">
|
||||
<HintPath>..\packages\Ninject.3.0.1.10\lib\net45-full\Ninject.dll</HintPath>
|
||||
</Reference>
|
||||
<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.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AutomatedScanning.cs" />
|
||||
<Compile Include="AutomatedScanningOptions.cs" />
|
||||
<Compile Include="KernelManager.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NAPS2\NAPS2.csproj">
|
||||
<Project>{EAC4A133-93BE-4400-BFA9-CEB1615693C4}</Project>
|
||||
<Name>NAPS2</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.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>
|
28
NAPS2.Console/Program.cs
Normal file
28
NAPS2.Console/Program.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Ninject;
|
||||
using Ninject.Parameters;
|
||||
|
||||
namespace NAPS2.Console
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
if (args.Length > 0)
|
||||
{
|
||||
var options = new AutomatedScanningOptions();
|
||||
if (!CommandLine.Parser.Default.ParseArguments(args, options))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var scanning = KernelManager.Kernel.Get<AutomatedScanning>(new ConstructorArgument("options", options));
|
||||
scanning.Execute();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
36
NAPS2.Console/Properties/AssemblyInfo.cs
Normal file
36
NAPS2.Console/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
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("NAPS2 (Not Another PDF Scanner 2)")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("NAPS2 (Not Another PDF Scanner 2)")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2009-2013 NAPS & NAPS2 Contributors")]
|
||||
[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("5c3db4a5-baec-47e9-8cf2-6acda4495255")]
|
||||
|
||||
// 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("0.10.*")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
5
NAPS2.Console/packages.config
Normal file
5
NAPS2.Console/packages.config
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="CommandLineParser" version="1.9.71" targetFramework="net45" />
|
||||
<package id="Ninject" version="3.0.1.10" targetFramework="net45" />
|
||||
</packages>
|
@ -12,6 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{F6CC4F
|
||||
.nuget\NuGet.targets = .nuget\NuGet.targets
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NAPS2.Console", "NAPS2.Console\NAPS2.Console.csproj", "{2A321772-75B2-4601-A718-AF0A2370E6A8}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -31,6 +33,12 @@ Global
|
||||
{11FC4BE1-882D-4ABA-8781-2F3F77DF9453}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{11FC4BE1-882D-4ABA-8781-2F3F77DF9453}.Standalone|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{11FC4BE1-882D-4ABA-8781-2F3F77DF9453}.Standalone|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2A321772-75B2-4601-A718-AF0A2370E6A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2A321772-75B2-4601-A718-AF0A2370E6A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2A321772-75B2-4601-A718-AF0A2370E6A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2A321772-75B2-4601-A718-AF0A2370E6A8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2A321772-75B2-4601-A718-AF0A2370E6A8}.Standalone|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2A321772-75B2-4601-A718-AF0A2370E6A8}.Standalone|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
3
NAPS2.sln.DotSettings
Normal file
3
NAPS2.sln.DotSettings
Normal file
@ -0,0 +1,3 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/FilterSettingsManager/CoverageFilterXml/@EntryValue"><data><IncludeFilters /><ExcludeFilters /></data></s:String>
|
||||
<s:String x:Key="/Default/FilterSettingsManager/AttributeFilterXml/@EntryValue"><data /></s:String></wpf:ResourceDictionary>
|
@ -15,6 +15,7 @@ namespace NAPS2
|
||||
{
|
||||
if (imageCount == 0)
|
||||
{
|
||||
// Skip the unnecesary logic below if there are no images
|
||||
return Enumerable.Empty<string>();
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,8 @@
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
@ -36,8 +38,6 @@
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@ -64,7 +64,7 @@
|
||||
<ManifestKeyFile>NAPS_TemporaryKey.pfx</ManifestKeyFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<GenerateManifests>true</GenerateManifests>
|
||||
<GenerateManifests>false</GenerateManifests>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignManifests>false</SignManifests>
|
||||
@ -78,10 +78,11 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetZone>LocalIntranet</TargetZone>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup />
|
||||
<ItemGroup>
|
||||
<Reference Include="CommandLine">
|
||||
<HintPath>..\packages\CommandLineParser.1.9.71\lib\net40\CommandLine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Ninject">
|
||||
<HintPath>..\packages\Ninject.3.0.1.10\lib\net35\Ninject.dll</HintPath>
|
||||
</Reference>
|
||||
@ -97,8 +98,6 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AutomatedScanning.cs" />
|
||||
<Compile Include="AutomatedScanningOptions.cs" />
|
||||
<Compile Include="CollectionExtensions.cs" />
|
||||
<Compile Include="ImageFileNamer.cs" />
|
||||
<Compile Include="ImageHelper.cs" />
|
||||
|
@ -34,18 +34,6 @@ namespace NAPS2
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
if (args.Length > 1)
|
||||
{
|
||||
var options = new AutomatedScanningOptions();
|
||||
if (!CommandLine.Parser.Default.ParseArguments(args, options))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var scanning = KernelManager.Kernel.Get<AutomatedScanning>(new ConstructorArgument("options", options));
|
||||
scanning.Execute();
|
||||
return;
|
||||
}
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
|
@ -29,7 +29,7 @@ using NAPS2.Scan.Wia;
|
||||
|
||||
namespace NAPS2.Scan.Stub
|
||||
{
|
||||
class StubScanDriver : IScanDriver
|
||||
public class StubScanDriver : IScanDriver
|
||||
{
|
||||
protected StubScanDriver(string driverName)
|
||||
{
|
||||
@ -64,7 +64,7 @@ namespace NAPS2.Scan.Stub
|
||||
public string DriverName { get; private set; }
|
||||
}
|
||||
|
||||
class StubWiaScanDriver : StubScanDriver
|
||||
public class StubWiaScanDriver : StubScanDriver
|
||||
{
|
||||
public StubWiaScanDriver()
|
||||
: base(WiaScanDriver.DRIVER_NAME)
|
||||
@ -72,7 +72,7 @@ namespace NAPS2.Scan.Stub
|
||||
}
|
||||
}
|
||||
|
||||
class StubTwainScanDriver : StubScanDriver
|
||||
public class StubTwainScanDriver : StubScanDriver
|
||||
{
|
||||
public StubTwainScanDriver()
|
||||
: base(TwainScanDriver.DRIVER_NAME)
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="CommandLineParser" version="1.9.71" targetFramework="net40-Client" />
|
||||
<package id="Ninject" version="3.0.1.10" targetFramework="net35-Client" />
|
||||
<package id="Ninject.MockingKernel" version="3.0.0.5" targetFramework="net35-Client" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user