Exemple #1
0
        public bool Setup()
        {
            twainDefs.TwRC rc = 0;
            CloseSrc();

            if (appid.Id == IntPtr.Zero)
            {
                Init(hwnd);

                if (appid.Id == IntPtr.Zero)
                {
                    return(false);
                }
            }

            rc = DSMident(appid, IntPtr.Zero, twainDefs.TwDG.Control, twainDefs.TwDAT.Identity, twainDefs.TwMSG.OpenDS, srcds);

            if (rc != twainDefs.TwRC.Success)
            {
                return(false);
            }

            twainDefs.TwCapability cap = new twainDefs.TwCapability(twainDefs.TwCap.CAP_ENABLEDSUIONLY);
            rc = DScap(appid, srcds, twainDefs.TwDG.Control, twainDefs.TwDAT.Capability, twainDefs.TwMSG.Get, cap);

            if (rc != twainDefs.TwRC.Success)
            {
                CloseSrc();
                return(false);
            }

            twainDefs.TwUserInterface guif = new twainDefs.TwUserInterface();
            guif.ShowUI     = 1;
            guif.ModalUI    = 0;
            guif.ParentHand = hwnd;
            rc = DSuserif(appid, srcds, twainDefs.TwDG.Control, twainDefs.TwDAT.UserInterface, twainDefs.TwMSG.EnableDSUIOnly, guif);

            if (rc != twainDefs.TwRC.Success)
            {
                CloseSrc();
                return(false);
            }

            return(true);
        }
Exemple #2
0
        //
        // Function Acquire(int);
        //
        // aNumberOfPages : -1 duplex and multipage scanning support
        //                : 1 or greater scan that many images in.
        //
        public bool Acquire(short aNumberOfPages)
        {
            twainDefs.TwRC rc = 0;
            CloseSrc();
            if (appid.Id == IntPtr.Zero)
            {
                Init(hwnd);
                if (appid.Id == IntPtr.Zero)
                {
                    return(false);
                }
            }

            rc = DSMident(appid, IntPtr.Zero, twainDefs.TwDG.Control, twainDefs.TwDAT.Identity, twainDefs.TwMSG.OpenDS, srcds);

            if (rc != twainDefs.TwRC.Success)
            {
                return(false);
            }

            rc = SetImageLayout(1, 0, 1, 0, 6, 65, 7, 15);
            twainDefs.TwCapability cap = new twainDefs.TwCapability(twainDefs.TwCap.XferCount, aNumberOfPages);
            rc = DScap(appid, srcds, twainDefs.TwDG.Control, twainDefs.TwDAT.Capability, twainDefs.TwMSG.Set, cap);

            if (rc != twainDefs.TwRC.Success)
            {
                CloseSrc();
                return(false);
            }

            twainDefs.TwUserInterface guif = new twainDefs.TwUserInterface();
            guif.ShowUI     = 1;
            guif.ModalUI    = 1;
            guif.ParentHand = hwnd;
            rc = DSuserif(appid, srcds, twainDefs.TwDG.Control, twainDefs.TwDAT.UserInterface, twainDefs.TwMSG.EnableDS, guif);

            if (rc != twainDefs.TwRC.Success)
            {
                CloseSrc();
                return(false);
            }

            return(true);
        }
Exemple #3
0
 private static extern twainDefs.TwRC DScap([In, Out] twainDefs.TwIdentity origin, [In] twainDefs.TwIdentity dest, twainDefs.TwDG dg, twainDefs.TwDAT dat, twainDefs.TwMSG msg, [In, Out] twainDefs.TwCapability capa);