Small-time backports.

This commit is contained in:
soukoku 2014-09-16 18:42:28 -04:00
parent 35cbad1056
commit b9a5bb86ad
7 changed files with 63 additions and 23 deletions

View File

@ -949,7 +949,7 @@ namespace NTwain.Data
}
break;
case ContainerType.Range:
for (var i = read.RangeMinValue; i <= read.RangeMaxValue; i += read.RangeStepSize)
for (var i = read.RangeMinValue; i >= read.RangeMinValue && i <= read.RangeMaxValue; i += read.RangeStepSize)
{
toPopulate.Add(i);
}
@ -1390,7 +1390,10 @@ namespace NTwain.Data
/// </summary>
public sealed partial class TWExtImageInfo : IDisposable
{
internal TWExtImageInfo()
/// <summary>
/// Initializes a new instance of the <see cref="TWExtImageInfo"/> class.
/// </summary>
public TWExtImageInfo()
{
_info = new TWInfo[200];
}

View File

@ -12,7 +12,7 @@ namespace NTwain
/// <summary>
/// General interface for a TWAIN session.
/// </summary>
public interface ITwainSession : INotifyPropertyChanged
public interface ITwainSession : IEnumerable<TwainSource>, INotifyPropertyChanged
{
/// <summary>

View File

@ -41,8 +41,6 @@ namespace NTwain.Internals
ReturnCode EnableSource(SourceEnableMode mode, bool modal, IntPtr windowHandle);
SynchronizationContext SynchronizationContext { get; set; }
/// <summary>
/// Gets the triplet operations defined for audio data group.
/// </summary>

View File

@ -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.7";
public const string Build = "2.0.8";
}
}

View File

@ -18,7 +18,7 @@ namespace NTwain
/// <summary>
/// Basic class for interfacing with TWAIN. You should only have one of this per application process.
/// </summary>
public partial class TwainSession
public partial class TwainSession
{
/// <summary>
/// Initializes a new instance of the <see cref="TwainSession"/> class.
@ -71,7 +71,7 @@ namespace NTwain
}
return source;
}
#region ITwainSession Members
@ -267,13 +267,7 @@ namespace NTwain
/// <returns></returns>
public IEnumerable<TwainSource> GetSources()
{
TWIdentity srcId;
var rc = ((ITwainSessionInternal)this).DGControl.Identity.GetFirst(out srcId);
while (rc == ReturnCode.Success)
{
yield return GetSourceInstance(this, srcId);
rc = ((ITwainSessionInternal)this).DGControl.Identity.GetNext(out srcId);
}
return this;
}
/// <summary>
@ -427,7 +421,10 @@ namespace NTwain
var hand = PropertyChanged;
if (hand != null) { hand(this, new PropertyChangedEventArgs(propertyName)); }
}
catch { }
catch (Exception ex)
{
Debug.WriteLine("PropertyChanged event error: " + ex.ToString());
}
}
else
{
@ -438,13 +435,44 @@ namespace NTwain
var hand = PropertyChanged;
if (hand != null) { hand(this, new PropertyChangedEventArgs(propertyName)); }
}
catch { }
catch (Exception ex)
{
Debug.WriteLine("PropertyChanged event error: " + ex.ToString());
}
}, null);
}
}
#endregion
#region IEnumerable<TwainSource> Members
/// <summary>
/// Gets the enumerator.
/// </summary>
/// <returns></returns>
public IEnumerator<TwainSource> GetEnumerator()
{
TWIdentity srcId;
var rc = ((ITwainSessionInternal)this).DGControl.Identity.GetFirst(out srcId);
while (rc == ReturnCode.Success)
{
yield return GetSourceInstance(this, srcId);
rc = ((ITwainSessionInternal)this).DGControl.Identity.GetNext(out srcId);
}
}
#endregion
#region IEnumerable Members
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
#endregion
#region events overridables
/// <summary>
@ -463,7 +491,10 @@ namespace NTwain
onEventFunc();
if (handler != null) { handler(this, EventArgs.Empty); }
}
catch { }
catch (Exception ex)
{
Debug.WriteLine(handler.Method.Name + " event error: " + ex.ToString());
}
}
else
{
@ -474,7 +505,10 @@ namespace NTwain
onEventFunc();
if (handler != null) { handler(this, EventArgs.Empty); }
}
catch { }
catch (Exception ex)
{
Debug.WriteLine(handler.Method.Name + " event error: " + ex.ToString());
}
}, null);
}
}
@ -499,7 +533,10 @@ namespace NTwain
onEventFunc(e);
if (handler != null) { handler(this, e); }
}
catch { }
catch (Exception ex)
{
Debug.WriteLine(handler.Method.Name + " event error: " + ex.ToString());
}
}
else
{
@ -512,7 +549,10 @@ namespace NTwain
onEventFunc(e);
if (handler != null) { handler(this, e); }
}
catch { }
catch (Exception ex)
{
Debug.WriteLine(handler.Method.Name + " event error: " + ex.ToString());
}
}, null);
}
}

View File

@ -305,6 +305,5 @@ namespace NTwain
}
#endregion
}
}

View File

@ -60,7 +60,7 @@ and call Open() to start using it.
#!c#
// choose and open the first source found
IEnumerable<TwainSources> sources = session.GetSources();
IEnumerable<TwainSource> sources = session.GetSources();
var myDS = sources.First();
myDS.Open();