mirror of
https://github.com/soukoku/ntwain.git
synced 2026-02-25 13:04:07 +08:00
Some name-breaking changes so master is now v3. V2 will continue to be the code on nuget for now.
This commit is contained in:
@@ -2,8 +2,15 @@
|
||||
|
||||
namespace NTwain.Internals
|
||||
{
|
||||
/// <summary>
|
||||
/// For something that is in a pending state until finalized with a Commit() call.
|
||||
/// The changes are rolled back if it is disposed without being committed.
|
||||
/// </summary>
|
||||
interface ICommittable : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Commits the pending changes.
|
||||
/// </summary>
|
||||
void Commit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ using System.Threading;
|
||||
|
||||
namespace NTwain.Internals
|
||||
{
|
||||
/// <summary>
|
||||
/// Extends <see cref="ITwainSession"/> with extra stuff for internal use.
|
||||
/// </summary>
|
||||
interface ITwainSessionInternal : ITwainSession
|
||||
{
|
||||
/// <summary>
|
||||
@@ -31,7 +34,7 @@ namespace NTwain.Internals
|
||||
/// <returns></returns>
|
||||
ICommittable GetPendingStateChanger(int newState);
|
||||
|
||||
void ChangeCurrentSource(TwainSource source);
|
||||
void ChangeCurrentSource(DataSource source);
|
||||
|
||||
ReturnCode DisableSource();
|
||||
|
||||
@@ -41,8 +44,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>
|
||||
|
||||
@@ -9,7 +9,11 @@ using System.Windows.Threading;
|
||||
|
||||
namespace NTwain.Internals
|
||||
{
|
||||
sealed class InternalMessageLoopHook : MessageLoopHook
|
||||
/// <summary>
|
||||
/// This is the self-hosted message loop for TWAIN communication.
|
||||
/// It utilizes the wpf Dispatcher to do all the hard work.
|
||||
/// </summary>
|
||||
sealed class InternalMessageLoopHook : MessageLoopHook
|
||||
{
|
||||
Dispatcher _dispatcher;
|
||||
WindowsHook _hook;
|
||||
@@ -32,7 +36,7 @@ namespace NTwain.Internals
|
||||
{
|
||||
Debug.WriteLine("NTwain message loop is starting.");
|
||||
_dispatcher = Dispatcher.CurrentDispatcher;
|
||||
if (!Platform.IsOnMono)
|
||||
if (!PlatformInfo.__global.IsOnMono)
|
||||
{
|
||||
_hook = new WindowsHook(filter);
|
||||
Handle = _hook.Handle;
|
||||
@@ -71,7 +75,7 @@ namespace NTwain.Internals
|
||||
{
|
||||
action();
|
||||
}
|
||||
else if (Platform.IsOnMono)
|
||||
else if (PlatformInfo.__global.IsOnMono)
|
||||
{
|
||||
using (var man = new WrappedManualResetEvent())
|
||||
{
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace NTwain.Internals
|
||||
session.ChangeState(7, true);
|
||||
if (dataPtr != IntPtr.Zero)
|
||||
{
|
||||
lockedPtr = Platform.MemoryManager.Lock(dataPtr);
|
||||
lockedPtr = PlatformInfo.Current.MemoryManager.Lock(dataPtr);
|
||||
}
|
||||
|
||||
session.SafeSyncableRaiseEvent(new DataTransferredEventArgs(lockedPtr, null));
|
||||
@@ -154,12 +154,12 @@ namespace NTwain.Internals
|
||||
// data here is allocated by source so needs to use shared mem calls
|
||||
if (lockedPtr != IntPtr.Zero)
|
||||
{
|
||||
Platform.MemoryManager.Unlock(lockedPtr);
|
||||
PlatformInfo.Current.MemoryManager.Unlock(lockedPtr);
|
||||
lockedPtr = IntPtr.Zero;
|
||||
}
|
||||
if (dataPtr != IntPtr.Zero)
|
||||
{
|
||||
Platform.MemoryManager.Free(dataPtr);
|
||||
PlatformInfo.Current.MemoryManager.Free(dataPtr);
|
||||
dataPtr = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
@@ -201,7 +201,7 @@ namespace NTwain.Internals
|
||||
session.ChangeState(7, true);
|
||||
if (dataPtr != IntPtr.Zero)
|
||||
{
|
||||
lockedPtr = Platform.MemoryManager.Lock(dataPtr);
|
||||
lockedPtr = PlatformInfo.Current.MemoryManager.Lock(dataPtr);
|
||||
}
|
||||
DoImageXferredEventRoutine(session, lockedPtr, null, null);
|
||||
}
|
||||
@@ -220,12 +220,12 @@ namespace NTwain.Internals
|
||||
// data here is allocated by source so needs to use shared mem calls
|
||||
if (lockedPtr != IntPtr.Zero)
|
||||
{
|
||||
Platform.MemoryManager.Unlock(lockedPtr);
|
||||
PlatformInfo.Current.MemoryManager.Unlock(lockedPtr);
|
||||
lockedPtr = IntPtr.Zero;
|
||||
}
|
||||
if (dataPtr != IntPtr.Zero)
|
||||
{
|
||||
Platform.MemoryManager.Free(dataPtr);
|
||||
PlatformInfo.Current.MemoryManager.Free(dataPtr);
|
||||
dataPtr = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
@@ -266,7 +266,7 @@ namespace NTwain.Internals
|
||||
{
|
||||
Flags = MemoryFlags.AppOwns | MemoryFlags.Pointer,
|
||||
Length = memInfo.Preferred,
|
||||
TheMem = Platform.MemoryManager.Allocate(memInfo.Preferred)
|
||||
TheMem = PlatformInfo.Current.MemoryManager.Allocate(memInfo.Preferred)
|
||||
};
|
||||
|
||||
// do the unthinkable and keep all xferred batches in memory,
|
||||
@@ -290,7 +290,7 @@ namespace NTwain.Internals
|
||||
IntPtr lockPtr = IntPtr.Zero;
|
||||
try
|
||||
{
|
||||
lockPtr = Platform.MemoryManager.Lock(xferInfo.Memory.TheMem);
|
||||
lockPtr = PlatformInfo.Current.MemoryManager.Lock(xferInfo.Memory.TheMem);
|
||||
Marshal.Copy(lockPtr, buffer, 0, buffer.Length);
|
||||
xferredData.Write(buffer, 0, buffer.Length);
|
||||
}
|
||||
@@ -298,7 +298,7 @@ namespace NTwain.Internals
|
||||
{
|
||||
if (lockPtr != IntPtr.Zero)
|
||||
{
|
||||
Platform.MemoryManager.Unlock(lockPtr);
|
||||
PlatformInfo.Current.MemoryManager.Unlock(lockPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -323,7 +323,7 @@ namespace NTwain.Internals
|
||||
session.ChangeState(6, true);
|
||||
if (xferInfo.Memory.TheMem != IntPtr.Zero)
|
||||
{
|
||||
Platform.MemoryManager.Free(xferInfo.Memory.TheMem);
|
||||
PlatformInfo.Current.MemoryManager.Free(xferInfo.Memory.TheMem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ namespace NTwain.Internals
|
||||
{
|
||||
Flags = MemoryFlags.AppOwns | MemoryFlags.Pointer,
|
||||
Length = memInfo.Preferred,
|
||||
TheMem = Platform.MemoryManager.Allocate(memInfo.Preferred)
|
||||
TheMem = PlatformInfo.Current.MemoryManager.Allocate(memInfo.Preferred)
|
||||
};
|
||||
|
||||
var xrc = ReturnCode.Success;
|
||||
@@ -367,14 +367,14 @@ namespace NTwain.Internals
|
||||
IntPtr lockPtr = IntPtr.Zero;
|
||||
try
|
||||
{
|
||||
lockPtr = Platform.MemoryManager.Lock(xferInfo.Memory.TheMem);
|
||||
lockPtr = PlatformInfo.Current.MemoryManager.Lock(xferInfo.Memory.TheMem);
|
||||
Marshal.Copy(lockPtr, buffer, 0, buffer.Length);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (lockPtr != IntPtr.Zero)
|
||||
{
|
||||
Platform.MemoryManager.Unlock(lockPtr);
|
||||
PlatformInfo.Current.MemoryManager.Unlock(lockPtr);
|
||||
}
|
||||
}
|
||||
outStream.Write(buffer, 0, buffer.Length);
|
||||
@@ -401,7 +401,7 @@ namespace NTwain.Internals
|
||||
session.ChangeState(6, true);
|
||||
if (xferInfo.Memory.TheMem != IntPtr.Zero)
|
||||
{
|
||||
Platform.MemoryManager.Free(xferInfo.Memory.TheMem);
|
||||
PlatformInfo.Current.MemoryManager.Free(xferInfo.Memory.TheMem);
|
||||
}
|
||||
if (File.Exists(tempFile))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user