mirror of
https://github.com/soukoku/ntwain.git
synced 2026-02-25 13:04:07 +08:00
Allow selecting/opening a source by id in case of duplicate names.
This commit is contained in:
@@ -103,6 +103,14 @@ namespace NTwain
|
|||||||
|
|
||||||
internal TWIdentity Identity { get; private set; }
|
internal TWIdentity Identity { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the id of the source.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The identifier.
|
||||||
|
/// </value>
|
||||||
|
public int Id { get { return Identity.Id; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the source's product name.
|
/// Gets the source's product name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -8,6 +8,14 @@ namespace NTwain
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IDataSource : ITripletControl
|
public interface IDataSource : ITripletControl
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the id of the source.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The identifier.
|
||||||
|
/// </value>
|
||||||
|
int Id { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the source's product name.
|
/// Gets the source's product name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -136,6 +136,13 @@ namespace NTwain
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
ReturnCode OpenSource(string sourceName);
|
ReturnCode OpenSource(string sourceName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Quick shortcut to open a source.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sourceId">Id of the source.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
ReturnCode OpenSource(int sourceId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the manager status. Only call this at state 2 or higher.
|
/// Gets the manager status. Only call this at state 2 or higher.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace NTwain
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The build release version number.
|
/// The build release version number.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string Build = "3.3.2"; // change this for each nuget release
|
public const string Build = "3.3.3"; // change this for each nuget release
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -309,6 +309,28 @@ namespace NTwain
|
|||||||
return ReturnCode.Failure;
|
return ReturnCode.Failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Quick shortcut to open a source.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sourceId">Id of the source.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ReturnCode OpenSource(int sourceId)
|
||||||
|
{
|
||||||
|
var curSrc = CurrentSource;
|
||||||
|
if (curSrc != null)
|
||||||
|
{
|
||||||
|
// TODO: close any open sources first
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var hit = this.Where(s => s.Id == sourceId).FirstOrDefault();
|
||||||
|
if (hit != null)
|
||||||
|
{
|
||||||
|
return hit.Open();
|
||||||
|
}
|
||||||
|
return ReturnCode.Failure;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the manager status. Only call this at state 2 or higher.
|
/// Gets the manager status. Only call this at state 2 or higher.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user