public void CloseSrc() { if (this.srcds.Id != IntPtr.Zero) { TwUserInterface guif = new TwUserInterface(); TwRC twRC = Twain.DSuserif(this.appid, this.srcds, TwDG.Control, TwDAT.UserInterface, TwMSG.DisableDS, guif); twRC = Twain.DSMident(this.appid, IntPtr.Zero, TwDG.Control, TwDAT.Identity, TwMSG.CloseDS, this.srcds); } }
public void Acquire() { this.CloseSrc(); if (this.appid.Id == IntPtr.Zero) { this.Init(this.hwnd); if (this.appid.Id == IntPtr.Zero) { return; } } TwRC twRC = Twain.DSMident(this.appid, IntPtr.Zero, TwDG.Control, TwDAT.Identity, TwMSG.OpenDS, this.srcds); if (twRC == TwRC.Success) { TwCapability capa = new TwCapability(TwCap.IPixelType, 0, TwType.UInt16); twRC = Twain.DScap(this.appid, this.srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capa); if (twRC != TwRC.Success) { this.CloseSrc(); } else { TwCapability capa2 = new TwCapability(TwCap.RESOLUTION, 200, TwType.Fix32); twRC = Twain.DScap(this.appid, this.srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capa2); if (twRC != TwRC.Success) { this.CloseSrc(); } else { TwCapability capa3 = new TwCapability(TwCap.XferCount, 1, TwType.Int16); twRC = Twain.DScap(this.appid, this.srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capa3); if (twRC != TwRC.Success) { this.CloseSrc(); } else { TwUserInterface twUserInterface = new TwUserInterface(); twUserInterface.ShowUI = 1; twUserInterface.ModalUI = 1; twUserInterface.ParentHand = this.hwnd; twRC = Twain.DSuserif(this.appid, this.srcds, TwDG.Control, TwDAT.UserInterface, TwMSG.EnableDS, twUserInterface); if (twRC != TwRC.Success) { this.CloseSrc(); } } } } } }