mirror of
https://github.com/soukoku/ntwain.git
synced 2025-09-20 02:37:57 +08:00
Merged v2 into master
This commit is contained in:
@@ -2056,7 +2056,20 @@ namespace NTwain.Data
|
|||||||
Constrainable = 0x40,
|
Constrainable = 0x40,
|
||||||
GetHelp = 0x100,
|
GetHelp = 0x100,
|
||||||
GetLabel = 0x200,
|
GetLabel = 0x200,
|
||||||
GetLabelEnum = 0x400
|
GetLabelEnum = 0x400,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Cap applies to entire session/machine.
|
||||||
|
/// </summary>
|
||||||
|
Machine = 0x1000,
|
||||||
|
/// <summary>
|
||||||
|
/// Cap applies to bitonal cameras.
|
||||||
|
/// </summary>
|
||||||
|
Bitonal = 0x2000,
|
||||||
|
/// <summary>
|
||||||
|
/// Cap applies to color cameras.
|
||||||
|
/// </summary>
|
||||||
|
Color = 0x4000
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@@ -70,7 +70,15 @@ namespace NTwain.Internals
|
|||||||
if (xferGroup == DataGroups.None ||
|
if (xferGroup == DataGroups.None ||
|
||||||
(xferGroup & DataGroups.Image) == DataGroups.Image)
|
(xferGroup & DataGroups.Image) == DataGroups.Image)
|
||||||
{
|
{
|
||||||
var mech = session.CurrentSource.CapGetCurrent(CapabilityId.ICapXferMech).ConvertToEnum<XferMech>();
|
// default to memory
|
||||||
|
var mech = XferMech.Memory;
|
||||||
|
|
||||||
|
object mechRaw = session.CurrentSource.CapGetCurrent(CapabilityId.ICapXferMech);
|
||||||
|
if (mechRaw != null)
|
||||||
|
{
|
||||||
|
mech = mechRaw.ConvertToEnum<XferMech>();
|
||||||
|
}
|
||||||
|
|
||||||
switch (mech)
|
switch (mech)
|
||||||
{
|
{
|
||||||
case XferMech.Memory:
|
case XferMech.Memory:
|
||||||
@@ -110,9 +118,13 @@ namespace NTwain.Internals
|
|||||||
|
|
||||||
} while (rc == ReturnCode.Success && pending.Count != 0);
|
} while (rc == ReturnCode.Success && pending.Count != 0);
|
||||||
|
|
||||||
session.ChangeState(5, true);
|
// some poorly written scanner drivers return failure on EndXfer so also check for pending count now
|
||||||
session.DisableSource();
|
// this may break with other sources but we'll see
|
||||||
|
if (pending.Count == 0)
|
||||||
|
{
|
||||||
|
session.ChangeState(5, true);
|
||||||
|
session.DisableSource();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region audio xfers
|
#region audio xfers
|
||||||
|
@@ -14,6 +14,6 @@ namespace NTwain
|
|||||||
// keep this same in majors releases
|
// keep this same in majors releases
|
||||||
public const string Release = "2.0.0.0";
|
public const string Release = "2.0.0.0";
|
||||||
// change this for each nuget release
|
// change this for each nuget release
|
||||||
public const string Build = "2.0.1";
|
public const string Build = "2.0.3";
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -15,7 +15,7 @@ namespace NTwain.Triplets
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public ReturnCode Get(TWImageMemXfer xfer)
|
public ReturnCode Get(TWImageMemXfer xfer)
|
||||||
{
|
{
|
||||||
Session.VerifyState(6, 6, DataGroups.Image, DataArgumentType.ImageMemFileXfer, Message.Get);
|
Session.VerifyState(6, 7, DataGroups.Image, DataArgumentType.ImageMemFileXfer, Message.Get);
|
||||||
return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, xfer);
|
return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, xfer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@ namespace NTwain
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a TWAIN data source.
|
/// Represents a TWAIN data source.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class TwainSource : INotifyPropertyChanged
|
public partial class TwainSource
|
||||||
{
|
{
|
||||||
ITwainSessionInternal _session;
|
ITwainSessionInternal _session;
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ namespace NTwain
|
|||||||
private set
|
private set
|
||||||
{
|
{
|
||||||
_supportedCaps = value;
|
_supportedCaps = value;
|
||||||
OnPropertyChanged("SupportedCaps");
|
//OnPropertyChanged("SupportedCaps");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,41 +219,82 @@ namespace NTwain
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region INotifyPropertyChanged Members
|
//#region INotifyPropertyChanged Members
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// Occurs when a property value changes.
|
||||||
|
///// </summary>
|
||||||
|
//public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// Raises the <see cref="PropertyChanged"/> event.
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="propertyName">Name of the property.</param>
|
||||||
|
//protected void OnPropertyChanged(string propertyName)
|
||||||
|
//{
|
||||||
|
// var syncer = _session.SynchronizationContext;
|
||||||
|
// if (syncer == null)
|
||||||
|
// {
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// var hand = PropertyChanged;
|
||||||
|
// if (hand != null) { hand(this, new PropertyChangedEventArgs(propertyName)); }
|
||||||
|
// }
|
||||||
|
// catch { }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// syncer.Post(o =>
|
||||||
|
// {
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// var hand = PropertyChanged;
|
||||||
|
// if (hand != null) { hand(this, new PropertyChangedEventArgs(propertyName)); }
|
||||||
|
// }
|
||||||
|
// catch { }
|
||||||
|
// }, null);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
#region cameras
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs when a property value changes.
|
/// Gets the cameras supported by the source.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
/// <returns></returns>
|
||||||
|
public IList<string> GetCameras()
|
||||||
/// <summary>
|
|
||||||
/// Raises the <see cref="PropertyChanged"/> event.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="propertyName">Name of the property.</param>
|
|
||||||
protected void OnPropertyChanged(string propertyName)
|
|
||||||
{
|
{
|
||||||
var syncer = _session.SynchronizationContext;
|
TWFileSystem fs = new TWFileSystem();
|
||||||
if (syncer == null)
|
List<string> cams = new List<string>();
|
||||||
|
var rc = DGControl.FileSystem.GetFirstFile(fs);
|
||||||
|
while (rc == ReturnCode.Success)
|
||||||
{
|
{
|
||||||
try
|
switch (fs.FileType)
|
||||||
{
|
{
|
||||||
var hand = PropertyChanged;
|
case FileType.Camera:
|
||||||
if (hand != null) { hand(this, new PropertyChangedEventArgs(propertyName)); }
|
case FileType.CameraBottom:
|
||||||
|
case FileType.CameraTop:
|
||||||
|
case FileType.CameraPreview:
|
||||||
|
cams.Add(fs.OutputName);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
catch { }
|
rc = DGControl.FileSystem.GetNextFile(fs);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
syncer.Post(o =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var hand = PropertyChanged;
|
|
||||||
if (hand != null) { hand(this, new PropertyChangedEventArgs(propertyName)); }
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
}, null);
|
|
||||||
}
|
}
|
||||||
|
return cams;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the target camera for cap negotiation that can be set per camera.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cameraName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ReturnCode SetCamera(string cameraName)
|
||||||
|
{
|
||||||
|
TWFileSystem fs = new TWFileSystem();
|
||||||
|
fs.InputName = cameraName;
|
||||||
|
return DGControl.FileSystem.ChangeDirectory(fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@@ -105,19 +105,22 @@ namespace Tester.Winform
|
|||||||
|
|
||||||
private void CleanupTwain()
|
private void CleanupTwain()
|
||||||
{
|
{
|
||||||
if (_twain.State == 4)
|
if (_twain != null)
|
||||||
{
|
{
|
||||||
_twain.CurrentSource.Close();
|
if (_twain.State == 4)
|
||||||
}
|
{
|
||||||
if (_twain.State == 3)
|
_twain.CurrentSource.Close();
|
||||||
{
|
}
|
||||||
_twain.Close();
|
if (_twain.State == 3)
|
||||||
}
|
{
|
||||||
|
_twain.Close();
|
||||||
|
}
|
||||||
|
|
||||||
if (_twain.State > 2)
|
if (_twain.State > 2)
|
||||||
{
|
{
|
||||||
// normal close down didn't work, do hard kill
|
// normal close down didn't work, do hard kill
|
||||||
_twain.ForceStepDown(2);
|
_twain.ForceStepDown(2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user