using NTwain.Data; using NTwain.Triplets; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading; namespace NTwain { /// /// General interface for a TWAIN session. /// public interface ITwainSession : IEnumerable, INotifyPropertyChanged { /// /// [Experimental] Gets or sets the optional synchronization context when not specifying a on . /// This allows events to be raised on the thread associated with the context. This is experimental is not recommended for use. /// /// /// The synchronization context. /// SynchronizationContext SynchronizationContext { get; set; } /// /// Gets or sets a value indicating whether calls to triplets will verify the current twain session state. /// /// /// true if state value is enforced; otherwise, false. /// bool EnforceState { get; set; } /// /// Gets the currently open source. /// /// /// The current source. /// DataSource CurrentSource { get; } /// /// Gets or sets the default source for this application. /// While this can be get as long as the session is open, /// it can only be set at State 3. /// /// /// The default source. /// DataSource DefaultSource { get; set; } /// /// Gets the current state number as defined by the TWAIN spec. /// /// The state. int State { get; } /// /// Quick flag to check if the DSM has been opened. /// bool IsDsmOpen { get; } /// /// Quick flag to check if a source has been opened. /// bool IsSourceOpen { get; } /// /// Quick flag to check if a source has been enabled. /// bool IsSourceEnabled { get; } /// /// Quick flag to check if a source is in the transferring state. /// bool IsTransferring { get; } /// /// Try to show the built-in source selector dialog and return the selected source. /// This is not recommended and is only included for completeness. /// /// DataSource ShowSourceSelector(); /// /// Opens the data source manager. This must be the first method used /// before using other TWAIN functions. Calls to this must be followed by /// when done with a TWAIN session. /// /// ReturnCode Open(); /// /// Opens the data source manager. This must be the first method used /// before using other TWAIN functions. Calls to this must be followed by /// when done with a TWAIN session. /// /// The message loop hook. /// ReturnCode Open(MessageLoopHook messageLoopHook); /// /// Closes the data source manager. /// /// ReturnCode Close(); /// /// Forces the stepping down of an opened source when things gets out of control. /// Used when session state and source state become out of sync. /// /// State of the target. void ForceStepDown(int targetState); /// /// Gets list of sources available in the system. /// /// IEnumerable GetSources(); /// /// Quick shortcut to open a source. /// /// Name of the source. /// ReturnCode OpenSource(string sourceName); /// /// Gets the manager status. Only call this at state 2 or higher. /// /// TWStatus GetStatus(); /// /// Gets the manager status. Only call this at state 3 or higher. /// /// TWStatusUtf8 GetStatusUtf8(); /// /// Occurs when has changed. /// event EventHandler StateChanged; /// /// Occurs when has changed. /// event EventHandler SourceChanged; /// /// Occurs when source has been disabled (back to state 4). /// event EventHandler SourceDisabled; /// /// Occurs when the source has generated an event. /// event EventHandler DeviceEvent; /// /// Occurs when a data transfer is ready. /// event EventHandler TransferReady; /// /// Occurs when data has been transferred. /// event EventHandler DataTransferred; /// /// Occurs when an error has been encountered during transfer. /// event EventHandler TransferError; } }