public static extern ReturnCode DsmWinNew( [In, Out] TWIdentity origin, [In, Out] TWIdentity destination, DataGroups dg, DataArgumentType dat, Message msg, [In, Out] TWUserInterface data);
/// <summary> /// Enables the source to start transferring. /// </summary> /// <param name="mode">The mode.</param> /// <param name="modal">if set to <c>true</c> any driver UI will display as modal.</param> /// <param name="windowHandle">The window handle if modal.</param> /// <returns></returns> ReturnCode ITwainSessionInternal.EnableSource(SourceEnableMode mode, bool modal, IntPtr windowHandle) { _closeRequested = false; DisableReason = Message.Null; var rc = ReturnCode.Failure; _msgLoopHook?.Invoke(() => { PlatformInfo.Current.Log.Debug("Thread {0}: EnableSource with {1}.", Thread.CurrentThread.ManagedThreadId, mode); _twui = new TWUserInterface(); _twui.ShowUI = mode == SourceEnableMode.ShowUI; _twui.ModalUI = modal; _twui.hParent = windowHandle; if (mode == SourceEnableMode.ShowUIOnly) { rc = ((ITwainSessionInternal)this).DGControl.UserInterface.EnableDSUIOnly(_twui); } else { rc = ((ITwainSessionInternal)this).DGControl.UserInterface.EnableDS(_twui); } }); return(rc); }
/// <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); }
/// <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); } }
public static ReturnCode DsmEntry( TWIdentity origin, TWIdentity destination, Message msg, TWUserInterface data) { if (PlatformInfo.Current.IsWindows) { if (PlatformInfo.Current.UseNewWinDSM) { return(NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data)); } else { return(NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data)); } } else if (PlatformInfo.Current.IsLinux) { return(NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data)); } throw new PlatformNotSupportedException(); }