public static extern ReturnCode DsmLinux64( [In, Out] TW_IDENTITY origin, [In, Out] TW_IDENTITY destination, DataGroups dg, DataArgumentType dat, Message msg, ref TW_AUDIOINFO data);
public static extern ReturnCode DsmLinux64( [In, Out] TW_IDENTITY origin, IntPtr zero, DataGroups dg, DataArgumentType dat, Message msg, [In, Out] TW_IDENTITY data);
public static extern ReturnCode DsmWin32( [In, Out] TW_IDENTITY origin, [In, Out] TW_IDENTITY destination, DataGroups dg, DataArgumentType dat, Message msg, ref TW_EVENT data);
public static extern ReturnCode DsmLinux( [In, Out] TWIdentity origin, [In, Out] TWIdentity destination, DataGroups dg, DataArgumentType dat, Message msg, [In, Out] TWDeviceEvent data);
public static extern ReturnCode DsmWinNew( [In, Out] TWIdentity origin, IntPtr zero, DataGroups dg, DataArgumentType dat, Message msg, [In, Out] TWIdentity data);
public static extern ReturnCode DsmWinNew( [In, Out] TWIdentity origin, [In, Out] TWIdentity destination, DataGroups dg, DataArgumentType dat, Message msg, [In, Out] TWEntryPoint data);
public static extern ReturnCode DsmWinOld( [In, Out] TWIdentity origin, [In, Out] TWIdentity destination, DataGroups dg, DataArgumentType dat, Message msg, [In, Out] TWCallback2 data);
public static ReturnCode DsmEntry( TWIdentity origin, TWIdentity destination, DataGroups dg, DataArgumentType dat, Message msg, ref DataGroups data) { if (PlatformInfo.Current.IsWindows) { if (PlatformInfo.Current.UseNewWinDSM) { return(NativeMethods.DsmWinNew(origin, destination, dg, dat, msg, ref data)); } else { return(NativeMethods.DsmWinOld(origin, destination, dg, dat, msg, ref data)); } } else if (PlatformInfo.Current.IsLinux) { return(NativeMethods.DsmLinux(origin, destination, dg, dat, msg, ref data)); } throw new PlatformNotSupportedException(); }
public static extern ReturnCode DsmMac32( [In, Out] TW_IDENTITY origin, [In, Out] TW_IDENTITY destination, DataGroups dg, DataArgumentType dat, Message msg, ref TW_CUSTOMDSDATA data);
public static extern ReturnCode DsmWin32( [In, Out] TW_IDENTITY origin, IntPtr zero, DataGroups dg, DataArgumentType dat, Message msg, [In, Out] TW_ENTRYPOINT data);
public static extern ReturnCode DsmMac64( [In, Out] TW_IDENTITY origin, [In, Out] TW_IDENTITY destination, DataGroups dg, DataArgumentType dat, Message msg, ref TW_CALLBACK2 data);
public static extern ReturnCode DsmMac32( [In, Out] TW_IDENTITY origin, [In, Out] TW_IDENTITY destination, DataGroups dg, DataArgumentType dat, Message msg, ref TW_JPEGCOMPRESSION data);
public static extern ReturnCode DsmLinux32( [In, Out] TW_IDENTITY origin, [In, Out] TW_IDENTITY destination, DataGroups dg, DataArgumentType dat, Message msg, ref TW_IMAGEMEMXFER data);
/// <summary> /// Direct DSM_Entry call with full arguments for custom values. /// </summary> /// <param name="group">The group.</param> /// <param name="dat">The dat.</param> /// <param name="message">The message.</param> /// <param name="data">The data.</param> /// <returns></returns> public ReturnCode DsmEntry( DataGroups group, DataArgumentType dat, Message message, IntPtr data) { _session.VerifyState(3, 7, group, dat, message); return(Dsm.DsmEntry(_session.AppId, _session.CurrentSource.Identity, group, dat, message, data)); }
/// <summary> /// Initializes a new instance of the <see cref="TwainStateException"/> class. /// </summary> /// <param name="currentState">The actual state number.</param> /// <param name="minStateExpected">The minimum state allowed.</param> /// <param name="maxStateExpected">The maximum state allowed.</param> /// <param name="dataGroup">The data group used.</param> /// <param name="argumentType">The data argument type used.</param> /// <param name="twainMessage">The twain message used.</param> /// <param name="message">The message.</param> public TwainStateException(int currentState, int minStateExpected, int maxStateExpected, DataGroups dataGroup, DataArgumentType argumentType, Message twainMessage, string message) : base(default(ReturnCode), message) { ActualState = currentState; MinStateExpected = minStateExpected; MaxStateExpected = maxStateExpected; DataGroup = dataGroup; ArgumentType = argumentType; TwainMessage = twainMessage; }
ReturnCode Handle32BitCallback(TW_IDENTITY origin, TW_IDENTITY destination, DataGroups dg, DataArgumentType dat, Message msg, IntPtr data) { // from the docs this needs to return Success // before handling the msg thus BeginInvoke is used. Debug.WriteLine($"Thread {Thread.CurrentThread.ManagedThreadId}: {nameof(Handle32BitCallback)}({dg}, {dat}, {msg}, {data})"); InternalBeginInvoke(() => { Debug.WriteLine($"Thread {Thread.CurrentThread.ManagedThreadId}: in BeginInvoke {nameof(Handle32BitCallback)}({dg}, {dat}, {msg}, {data})"); HandleSourceMsg(msg); }); Debug.WriteLine($"Thread {Thread.CurrentThread.ManagedThreadId}: after BeginInvoke {nameof(Handle32BitCallback)}({dg}, {dat}, {msg}, {data})"); return(ReturnCode.Success); }
public void Constructor_Sets_Correct_Properties() { // just some non-default values to test int state = 3; int minState = 4; int maxState = 5; DataGroups dataGroup = DataGroups.Control; DataArgumentType argumentType = DataArgumentType.AudioNativeXfer; Message twainMessage = Message.Copy; string message = "THIS IS A TEST."; TwainStateException target = new TwainStateException(state, minState, maxState, dataGroup, argumentType, twainMessage, message); Assert.AreEqual(state, target.ActualState, "State mismatch."); Assert.AreEqual(minState, target.MinStateExpected, "Minimum mismatch."); Assert.AreEqual(maxState, target.MaxStateExpected, "Maximum mismatch."); Assert.AreEqual(dataGroup, target.DataGroup, "DataGroup mismatch."); Assert.AreEqual(argumentType, target.ArgumentType, "ArgumentType mismatch."); Assert.AreEqual(twainMessage, target.TwainMessage, "TwainMessage mismatch."); Assert.AreEqual(message, target.Message, "Message mismatch."); }
/// <summary> /// Capability triplet call with custom DAT and message. /// </summary> /// <param name="DAT"></param> /// <param name="message"></param> /// <param name="capability"></param> /// <returns></returns> public ReturnCode Custom(DataArgumentType DAT, Message message, ref TW_CAPABILITY capability) { if (Is32Bit) { if (IsWin) { return(NativeMethods.DsmWin32(Session.Config.App32, Session.CurrentSource.Identity32, DataGroups.Control, DAT, message, ref capability)); } if (IsLinux) { return(NativeMethods.DsmLinux32(Session.Config.App32, Session.CurrentSource.Identity32, DataGroups.Control, DAT, message, ref capability)); } if (IsMac) { return(NativeMethods.DsmMac32(Session.Config.App32, Session.CurrentSource.Identity32, DataGroups.Control, DAT, message, ref capability)); } } if (IsWin) { return(NativeMethods.DsmWin64(Session.Config.App32, Session.CurrentSource.Identity32, DataGroups.Control, DAT, message, ref capability)); } if (IsLinux) { return(NativeMethods.DsmLinux64(Session.Config.App32, Session.CurrentSource.Identity32, DataGroups.Control, DAT, message, ref capability)); } if (IsMac) { return(NativeMethods.DsmMac64(Session.Config.App32, Session.CurrentSource.Identity32, DataGroups.Control, DAT, message, ref capability)); } return(ReturnCode.Failure); }
public static extern TwainResult DsCapability([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] TwainCapability capa);
public static extern TwainResult DsmStatus([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] Status dsmstat);
public static extern TwainResult DsPendingTransfer([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] PendingXfers pxfr);
public static extern TwainResult DsImageTransfer([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, ref IntPtr hbitmap);
public static extern TwainResult DsImageInfo([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] ImageInfo imginf);
public static extern TwainResult DsUserInterface([In, Out] Identity origin, [In, Out] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, UserInterface ui);
public static extern TwainResult DsmIdentity([In, Out] Identity origin, IntPtr zeroPtr, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] Identity idds);
public static extern TwainResult DsStatus([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] Status dsmstat);
public static extern TwainResult DsmParent([In, Out] Identity origin, IntPtr zeroPtr, DataGroup dg, DataArgumentType dat, Message msg, ref IntPtr windowHandle);
public static extern TwainResult DsEvent([In, Out] Identity origin, [In, Out] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, ref Event evt);
public static extern TwainResult DsImageLayout([In, Out] Identity origin, [In, Out] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] ImageLayout imglyt);
/// <summary> /// Verifies the session is within the specified state range (inclusive). Throws /// <see cref="TwainStateException" /> if violated. /// </summary> /// <param name="session">The session.</param> /// <param name="allowedMinimum">The allowed minimum.</param> /// <param name="allowedMaximum">The allowed maximum.</param> /// <param name="group">The triplet data group.</param> /// <param name="dataArgumentType">The triplet data argument type.</param> /// <param name="message">The triplet message.</param> /// <exception cref="TwainStateException"></exception> public static void VerifyState(this ITwainSessionInternal session, int allowedMinimum, int allowedMaximum, DataGroups group, DataArgumentType dataArgumentType, Message message) { if (session.EnforceState && (session.State < allowedMinimum || session.State > allowedMaximum)) { throw new TwainStateException(session.State, allowedMinimum, allowedMaximum, group, dataArgumentType, message, string.Format(CultureInfo.InvariantCulture, "TWAIN state {0} does not match required range {1}-{2} for operation {3}-{4}-{5}.", session.State, allowedMinimum, allowedMaximum, group, dataArgumentType, message)); } }
public static extern TwainResult DsImageMemXfer([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] ImageMemXfer memxfer);