View on GitHub

SARAFF SOFTWARE

All products / Saraff.Twain.DS / Contents

OnEnableDS

If showUI is true, the Source should display its user interface and wait for the user to initiate an acquisition. If showUI is false, the Source should immediately begin acquiring data based on its current configuration (a device that requires the user to push a button on the device,such as a hand-scanner,will be “armed” by this operation and will assert MSG_XFERREADY as soon as the Source has data ready for transfer). The Source should fail any attempt to set a capability value (TWRC_FAILURE / TWCC_SEQERROR) until it returns to State 4 (unless an exception approval exists via a CAP_EXTENDEDCAPS agreement).

Note: If the application has set showUI or CAP_INDICATORS to true, then the Source is responsible for presenting the user with appropriate progress indicators regarding the acquisition and transfer process. If showUI is set to true, CAP_INDICATORS is ignored and progress and errors are always shown.

Note: It is strongly recommended that all Sources support being enabled without their User Interface if the application requests (showUI = false). But if your Source cannot be used without its User Interface, it should enable showing the Source User Interface (just as if showUI = true) but return TWRC_CHECKSTATUS. All Sources, however, must support the CAP_UICONTROLLABLE. This capability reports whether or not a Source allows showUI = false. An application can use this capability to know whether the Source-supplied user interface can be suppressed before it is displayed.

Syntax

protected virtual void OnEnableDS(bool showUI, bool modalUI, IntPtr hwnd)

Parameters

Examples

protected override void OnEnableDS(bool showUI,bool modalUI,IntPtr hwnd) {
    try {
        this._Screen=System.Windows.Forms.Screen.FromHandle(hwnd);
    } catch {
        this._Screen=System.Windows.Forms.Screen.PrimaryScreen;
    }
    if(showUI) {
       this._acquireForm=new Forms.AcquireForm(new Forms.AcquireForm.Args {
            Resolution=(float)this[TwCap.XResolution].Value,
            PixelType=(TwPixelType)this[TwCap.IPixelType].Value,
            FeederEnable=(bool)this[TwCap.FeederEnabled].Value,
            XferCount=(short)this[TwCap.XferCount].Value,
            BitDepth=(ushort)this[TwCap.BitDepth].Value
        });
        this._acquireForm.FormClosed+=(sender,e) => {
            this.OnCloseDSReq();
        };
        this._acquireForm.AcquireRequred+=(sender,e) => {
            this[TwCap.XResolution].Value=e.Args.Resolution;
            this[TwCap.YResolution].Value=e.Args.Resolution;
            this[TwCap.IPixelType].Value=e.Args.PixelType;
            this[TwCap.FeederEnabled].Value=e.Args.FeederEnable;
            this[(TwCap)0x8001].Value=(short)e.Args.XferCount;
            this[TwCap.BitDepth].Value=(ushort)e.Args.BitDepth;
            this.OnXferReady();
        };
        this._acquireForm.Show(System.Windows.Forms.Control.FromHandle(hwnd));
    } else {
        this.OnXferReady();
    }

    base.OnEnableDS(showUI,modalUI,hwnd);
}