public void CloseSrc() { twainDefs.TwRC rc = 0; try { if (srcds.Id != IntPtr.Zero) { twainDefs.TwUserInterface guif = new twainDefs.TwUserInterface(); rc = DSuserif(appid, srcds, twainDefs.TwDG.Control, twainDefs.TwDAT.UserInterface, twainDefs.TwMSG.DisableDS, guif); rc = DSMident(appid, IntPtr.Zero, twainDefs.TwDG.Control, twainDefs.TwDAT.Identity, twainDefs.TwMSG.CloseDS, srcds); } } catch (Exception e) { MessageBox.Show(e.ToString()); } }
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); }
// // 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); }
private static extern twainDefs.TwRC DSuserif([In, Out] twainDefs.TwIdentity origin, [In, Out] twainDefs.TwIdentity dest, twainDefs.TwDG dg, twainDefs.TwDAT dat, twainDefs.TwMSG msg, twainDefs.TwUserInterface guif);