From ac881c0438c9b12de2855ce2e61b421a61166013 Mon Sep 17 00:00:00 2001 From: soukoku Date: Sat, 31 May 2014 07:13:18 -0400 Subject: [PATCH] Added quickie to open a source. --- NTwain/ITwainSession.cs | 7 +++++++ NTwain/Properties/VersionInfo.cs | 2 +- NTwain/TwainSession.cs | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/NTwain/ITwainSession.cs b/NTwain/ITwainSession.cs index a1adb98..15ec9c3 100644 --- a/NTwain/ITwainSession.cs +++ b/NTwain/ITwainSession.cs @@ -81,6 +81,13 @@ namespace NTwain /// IEnumerable GetSources(); + /// + /// Quick shortcut to open a source. + /// + /// Name of the source. + /// + ReturnCode OpenSource(string sourceName); + /// /// Gets the manager status. Only call this at state 2 or higher. /// diff --git a/NTwain/Properties/VersionInfo.cs b/NTwain/Properties/VersionInfo.cs index 8c62ff0..183c8b0 100644 --- a/NTwain/Properties/VersionInfo.cs +++ b/NTwain/Properties/VersionInfo.cs @@ -14,6 +14,6 @@ namespace NTwain // keep this same in majors releases public const string Release = "2.0.0.0"; // change this for each nuget release - public const string Build = "2.0.0"; + public const string Build = "2.0.1"; } } \ No newline at end of file diff --git a/NTwain/TwainSession.cs b/NTwain/TwainSession.cs index 253682b..a1c5a60 100644 --- a/NTwain/TwainSession.cs +++ b/NTwain/TwainSession.cs @@ -8,6 +8,7 @@ using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; +using System.Linq; using System.Reflection; using System.Runtime.InteropServices; using System.Threading; @@ -332,6 +333,21 @@ namespace NTwain } } + /// + /// Quick shortcut to open a source. + /// + /// Name of the source. + /// + public ReturnCode OpenSource(string sourceName) + { + var hit = GetSources().Where(s => string.Equals(s.Name, sourceName)).FirstOrDefault(); + if (hit != null) + { + return hit.Open(); + } + return ReturnCode.Failure; + } + /// /// Gets the manager status. Only call this at state 2 or higher. ///