Пример #1
0
        /// <summary>
        /// This operation is used to initiate the transfer of an image from the Source to the application via
        /// the disk-file transfer mechanism. It causes the transfer to begin.
        /// </summary>
        /// <returns></returns>
        public ReturnCode Get()
        {
            Session.VerifyState(6, 6, DataGroups.Image, DataArgumentType.ImageFileXfer, Message.Get);
            IntPtr z = IntPtr.Zero;

            return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataGroups.Image, DataArgumentType.ImageFileXfer, Message.Get, ref z));
        }
Пример #2
0
 /// <summary>
 /// Translate the contents of a TW_STATUS structure received from a Source into a localized UTF-8
 /// encoded string.
 /// </summary>
 /// <param name="status">The status.</param>
 /// <returns></returns>
 public ReturnCode GetSource(TWStatus status, out TWStatusUtf8 utf8status)
 {
     utf8status = new TWStatusUtf8 {
         Status = status
     };
     Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.StatusUtf8, Message.Get);
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, status));
 }
Пример #3
0
 /// <summary>
 /// Translate the contents of a TW_STATUS structure received from the manager into a localized UTF-8
 /// encoded string.
 /// </summary>
 /// <param name="status">The status.</param>
 /// <returns></returns>
 public ReturnCode GetManager(TWStatus status, out TWStatusUtf8 utf8status)
 {
     utf8status = new TWStatusUtf8 {
         Status = status
     };
     Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.StatusUtf8, Message.Get);
     return(Dsm.DsmEntry(Session.AppId, null, Message.Get, status));
 }
Пример #4
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));
 }
Пример #5
0
        /// <summary>
        /// Causes the Source Manager to initialize itself. This operation must be executed before any other
        /// operations will be accepted by the Source Manager.
        /// </summary>
        /// <param name="handle">The handle. On Windows = points to the window handle (hWnd) that will act as the Source’s
        /// "parent". On Macintosh = should be a NULL value.</param>
        /// <returns></returns>
        public ReturnCode OpenDsm(IntPtr handle)
        {
            Session.VerifyState(1, 2, DataGroups.Control, DataArgumentType.Parent, Message.OpenDSM);
            var rc = Dsm.DsmEntry(Session.AppId, null, DataGroups.Control, DataArgumentType.Parent, Message.OpenDSM, ref handle);

            if (rc == ReturnCode.Success)
            {
                Session.ChangeState(3, true);
            }
            return(rc);
        }
Пример #6
0
        /// <summary>
        /// This operation causes the Source’s user interface, if displayed during the
        /// EnableDS operation, to be lowered. The Source is returned to
        /// State 4, where capability negotiation can again occur. The application can invoke this operation
        /// either because it wants to shut down the current session, or in response to the Source "posting"
        /// a CloseDSReq event to it. Rarely, the application may need to close the Source because an
        /// error condition was detected.
        /// </summary>
        /// <param name="userInterface">The user interface.</param>
        /// <returns></returns>
        public ReturnCode DisableDS(TWUserInterface userInterface)
        {
            Session.VerifyState(5, 5, DataGroups.Control, DataArgumentType.UserInterface, Message.DisableDS);
            var rc = Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.DisableDS, userInterface);

            if (rc == ReturnCode.Success)
            {
                Session.ChangeState(4, true);
            }
            return(rc);
        }
Пример #7
0
        /// <summary>
        /// Loads the specified Source into main memory and causes its initialization.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <returns></returns>
        public ReturnCode OpenDS(DataSource source)
        {
            Session.VerifyState(3, 3, DataGroups.Control, DataArgumentType.Identity, Message.OpenDS);
            var rc = Dsm.DsmEntry(Session.AppId, Message.OpenDS, source.Identity);

            if (rc == ReturnCode.Success)
            {
                Session.ChangeCurrentSource(source);
                Session.ChangeState(4, true);
            }
            return(rc);
        }
Пример #8
0
        /// <summary>
        /// When an application is finished with a Source, it must formally close the session between them
        /// using this operation. This is necessary in case the Source only supports connection with a single
        /// application (many desktop scanners will behave this way). A Source such as this cannot be
        /// accessed by other applications until its current session is terminated.
        /// </summary>
        /// <returns></returns>
        public ReturnCode CloseDS()
        {
            Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Identity, Message.CloseDS);
            var rc = Dsm.DsmEntry(Session.AppId, Message.CloseDS, Session.CurrentSource.Identity);

            if (rc == ReturnCode.Success)
            {
                Session.ChangeCurrentSource(null);
                Session.ChangeState(3, true);
            }
            return(rc);
        }
Пример #9
0
 /// <summary>
 /// This operation is used by applications
 /// that wish to display the source user interface to allow the user to manipulate the sources current
 /// settings for DPI, paper size, etc. but not acquire an image.
 /// </summary>
 /// <param name="userInterface">The user interface.</param>
 /// <returns></returns>
 public ReturnCode EnableDSUIOnly(TWUserInterface userInterface)
 {
     Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.UserInterface, Message.EnableDSUIOnly);
     using (var pending = Session.GetPendingStateChanger(5))
     {
         var rc = Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.EnableDSUIOnly, userInterface);
         if (rc == ReturnCode.Success)
         {
             pending.Commit();
         }
         return(rc);
     }
 }
Пример #10
0
 public ReturnCode GetLabelEnum(ushort customDAT, TWCapability capability)
 {
     Session.VerifyState(4, 4, DataGroups.Control, (DataArgumentType)customDAT, Message.GetLabelEnum);
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, (DataArgumentType)customDAT, Message.GetLabelEnum, capability));
 }
Пример #11
0
 /// <summary>
 /// Causes the Source to transform any RGB data according to the response curves specified by the
 /// application.
 /// </summary>
 /// <param name="response">The response.</param>
 /// <returns></returns>
 public ReturnCode Set(TWRgbResponse response)
 {
     Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.RgbResponse, Message.Set);
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Set, response));
 }
Пример #12
0
 /// <summary>
 /// Returns a label suitable for use in a GUI, for instance "Resolution:"
 /// for ICapXRESOLUTION.
 /// </summary>
 /// <param name="capability">The capability.</param>
 /// <returns></returns>
 public ReturnCode GetLabel(TWCapability capability)
 {
     Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.GetLabel);
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataArgumentType.Capability, Message.GetLabel, capability));
 }
Пример #13
0
 /// <summary>
 /// Causes the transfer of an audio data from the Source to the application, via the Native
 /// transfer mechanism, to begin. The resulting data is stored in main memory in a single block.
 /// The data is stored in AIFF format on the Macintosh and as a WAV format under Microsoft
 /// Windows. The size of the audio snippet that can be transferred is limited to the size of the
 /// memory block that can be allocated by the Source.
 /// </summary>
 /// <param name="handle">The handle.</param>
 /// <returns></returns>
 public ReturnCode Get(ref IntPtr handle)
 {
     Session.VerifyState(6, 6, DataGroups.Audio, DataArgumentType.AudioNativeXfer, Message.Get);
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity,
                         DataGroups.Audio, DataArgumentType.AudioNativeXfer, Message.Get, ref handle));
 }
Пример #14
0
 /// <summary>
 /// PASSTHRU is intended for the use of Source writers writing diagnostic applications. It allows
 /// raw communication with the currently selected device in the Source.
 /// </summary>
 /// <param name="sourcePassThru">The source pass thru.</param>
 /// <returns></returns>
 public ReturnCode PassThrough(TWPassThru sourcePassThru)
 {
     Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.PassThru, Message.PassThru);
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.PassThru, sourcePassThru));
 }
Пример #15
0
 public ReturnCode Reset(out TWFilter filter)
 {
     Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.Filter, Message.Reset);
     filter = new TWFilter();
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Reset, filter));
 }
Пример #16
0
 public ReturnCode GetDefault(out TWPalette8 palette)
 {
     Session.VerifyState(4, 6, DataGroups.Image, DataArgumentType.Palette8, Message.GetDefault);
     palette = new TWPalette8();
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.GetDefault, palette));
 }
Пример #17
0
 /// <summary>
 /// This operation requests that the Source adopt the specified palette for use with all subsequent
 /// palette transfers. The application should be careful to supply a palette that matches the bit
 /// depth of the Source. The Source is not required to adopt this palette. The application should be
 /// careful to check the return value from this operation.
 /// </summary>
 /// <param name="palette">The palette.</param>
 /// <returns></returns>
 public ReturnCode Set(TWPalette8 palette)
 {
     Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.Palette8, Message.Set);
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Set, palette));
 }
Пример #18
0
 public ReturnCode GetDefault(out TWSetupFileXfer setupFileXfer)
 {
     Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.SetupFileXfer, Message.GetDefault);
     setupFileXfer = new TWSetupFileXfer();
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.GetDefault, setupFileXfer));
 }
Пример #19
0
 /// <summary>
 /// Returns the Source’s support status of this capability.
 /// </summary>
 /// <param name="capability">The capability.</param>
 /// <returns></returns>
 public ReturnCode QuerySupport(TWCapability capability)
 {
     Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.QuerySupport);
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataArgumentType.Capability, Message.QuerySupport, capability));
 }
Пример #20
0
 public ReturnCode Set(TWSetupFileXfer setupFileXfer)
 {
     Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.SetupFileXfer, Message.Set);
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Set, setupFileXfer));
 }
Пример #21
0
 public ReturnCode Reset(out TWGrayResponse response)
 {
     Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.GrayResponse, Message.Reset);
     response = new TWGrayResponse();
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Reset, response));
 }
Пример #22
0
 /// <summary>
 /// This operation is used by the application to set the current settings for a data source to a
 /// previous state as defined by the data contained in the customData data structure. The actual
 /// format of the data is data source dependent and not defined by TWAIN.
 /// </summary>
 /// <param name="customData">The custom data.</param>
 /// <returns></returns>
 public ReturnCode Set(TWCustomDSData customData)
 {
     Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.CustomDSData, Message.Set);
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Set, customData));
 }
Пример #23
0
 public ReturnCode SetConstraint(ushort customDAT, TWCapability capability)
 {
     Session.VerifyState(4, 7, DataGroups.Control, (DataArgumentType)customDAT, Message.SetConstraint);
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, (DataArgumentType)customDAT, Message.SetConstraint, capability));
 }
Пример #24
0
 public ReturnCode Get(ref TWMemory profile)
 {
     Session.VerifyState(6, 7, DataGroups.Image, DataArgumentType.IccProfile, Message.Get);
     profile = new TWMemory();
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataArgumentType.IccProfile, Message.Get, ref profile));
 }
Пример #25
0
 public ReturnCode Get(out TWDeviceEvent sourceDeviceEvent)
 {
     Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.DeviceEvent, Message.Get);
     sourceDeviceEvent = new TWDeviceEvent();
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, sourceDeviceEvent));
 }
Пример #26
0
 /// <summary>
 /// This operation is used by the application to query the data source for extended image attributes.
 /// The application is responsible for creating and disiposing the info object.
 /// </summary>
 /// <param name="info">The information.</param>
 /// <returns></returns>
 public ReturnCode Get(TWExtImageInfo info)
 {
     Session.VerifyState(7, 7, DataGroups.Image, DataArgumentType.ExtImageInfo, Message.Get);
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, info));
 }
Пример #27
0
 /// <summary>
 /// The application may obtain the next Source that are currently available on the system which
 /// match the application’s supported groups.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <returns></returns>
 public ReturnCode GetNext(out TWIdentity source)
 {
     Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.Identity, Message.GetNext);
     source = new TWIdentity();
     return(Dsm.DsmEntry(Session.AppId, Message.GetNext, source));
 }
Пример #28
0
 /// <summary>
 /// Sets the number of pending transfers in the Source to zero.
 /// </summary>
 /// <param name="pendingXfers">The pending xfers.</param>
 /// <returns></returns>
 internal ReturnCode Reset(TWPendingXfers pendingXfers)
 {
     Session.VerifyState(6, 6, DataGroups.Control, DataArgumentType.PendingXfers, Message.Reset);
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Reset, pendingXfers));
 }
Пример #29
0
 /// <summary>
 /// It allows an application to set the
 /// default TWAIN driver, which is reported back by GetDefault.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <returns></returns>
 public ReturnCode Set(TWIdentity source)
 {
     Session.VerifyState(3, 3, DataGroups.Control, DataArgumentType.Identity, Message.Set);
     return(Dsm.DsmEntry(Session.AppId, Message.Set, source));
 }
Пример #30
0
 /// <summary>
 /// If CapAutoScan is TRUE, this command will stop the operation of the scanner’s automatic
 /// feeder. No other action is taken.
 /// </summary>
 /// <param name="pendingXfers">The pending xfers.</param>
 /// <returns></returns>
 public ReturnCode StopFeeder(TWPendingXfers pendingXfers)
 {
     Session.VerifyState(6, 6, DataGroups.Control, DataArgumentType.PendingXfers, Message.StopFeeder);
     return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.StopFeeder, pendingXfers));
 }