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);
Example #4
0
 public static extern ReturnCode DsmLinux(
     [In, Out] TWIdentity origin,
     [In, Out] TWIdentity destination,
     DataGroups dg,
     DataArgumentType dat,
     Message msg,
     [In, Out] TWDeviceEvent data);
Example #5
0
 public static extern ReturnCode DsmWinNew(
     [In, Out] TWIdentity origin,
     IntPtr zero,
     DataGroups dg,
     DataArgumentType dat,
     Message msg,
     [In, Out] TWIdentity data);
Example #6
0
 public static extern ReturnCode DsmWinNew(
     [In, Out] TWIdentity origin,
     [In, Out] TWIdentity destination,
     DataGroups dg,
     DataArgumentType dat,
     Message msg,
     [In, Out] TWEntryPoint data);
Example #7
0
 public static extern ReturnCode DsmWinOld(
     [In, Out] TWIdentity origin,
     [In, Out] TWIdentity destination,
     DataGroups dg,
     DataArgumentType dat,
     Message msg,
     [In, Out] TWCallback2 data);
Example #8
0
 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);
Example #14
0
 /// <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));
 }
Example #15
0
 /// <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;
 }
Example #16
0
 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.");
        }
Example #18
0
        /// <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);
        }
Example #19
0
 public static extern TwainResult DsCapability([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] TwainCapability capa);
Example #20
0
 public static extern TwainResult DsmStatus([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] Status dsmstat);
Example #21
0
 public static extern TwainResult DsPendingTransfer([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] PendingXfers pxfr);
Example #22
0
 public static extern TwainResult DsImageTransfer([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, ref IntPtr hbitmap);
Example #23
0
 public static extern TwainResult DsImageTransfer([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, ref IntPtr hbitmap);
Example #24
0
 public static extern TwainResult DsImageInfo([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] ImageInfo imginf);
Example #25
0
 public static extern TwainResult DsUserInterface([In, Out] Identity origin, [In, Out] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, UserInterface ui);
Example #26
0
 public static extern TwainResult DsmIdentity([In, Out] Identity origin, IntPtr zeroPtr, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] Identity idds);
Example #27
0
 public static extern TwainResult DsStatus([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] Status dsmstat);
Example #28
0
 public static extern TwainResult DsmParent([In, Out] Identity origin, IntPtr zeroPtr, DataGroup dg, DataArgumentType dat, Message msg, ref IntPtr windowHandle);
Example #29
0
 public static extern TwainResult DsCapability([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] TwainCapability capa);
Example #30
0
 public static extern TwainResult DsEvent([In, Out] Identity origin, [In, Out] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, ref Event evt);
Example #31
0
 public static extern TwainResult DsEvent([In, Out] Identity origin, [In, Out] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, ref Event evt);
Example #32
0
 public static extern TwainResult DsImageInfo([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] ImageInfo imginf);
Example #33
0
 public static extern TwainResult DsImageLayout([In, Out] Identity origin, [In, Out] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] ImageLayout imglyt);
Example #34
0
 public static extern TwainResult DsImageLayout([In, Out] Identity origin, [In, Out] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] ImageLayout imglyt);
Example #35
0
 public static extern TwainResult DsmIdentity([In, Out] Identity origin, IntPtr zeroPtr, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] Identity idds);
Example #36
0
 /// <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));
     }
 }
Example #37
0
 public static extern TwainResult DsPendingTransfer([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] PendingXfers pxfr);
Example #38
0
 public static extern TwainResult DsImageMemXfer([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] ImageMemXfer memxfer);
Example #39
0
 public static extern TwainResult DsUserInterface([In, Out] Identity origin, [In, Out] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, UserInterface ui);
Example #40
0
 public static extern TwainResult DsmParent([In, Out] Identity origin, IntPtr zeroPtr, DataGroup dg, DataArgumentType dat, Message msg, ref IntPtr windowHandle);