示例#1
0
        public void CloseSrc()
        {
            TwReturnCode returnCode;

            if (srcds.Id != IntPtr.Zero)
            {
                var guif = new TwUserInterface();
                returnCode = DSuserif(appid, srcds, TwDG.Control, TwData.UserInterface, TwMessageCode.DisableDS, guif);
                returnCode = DSMident(appid, IntPtr.Zero, TwDG.Control, TwData.Identity, TwMessageCode.CloseDS, srcds);
            }
        }
示例#2
0
        public bool Acquire()
        {
            TwReturnCode returnCode;

            CloseSrc();
            if (appid.Id == IntPtr.Zero)
            {
                Init(hwnd);
                if (appid.Id == IntPtr.Zero)
                {
                    throw new InvalidOperationException("Init call falied");
                }
            }
            returnCode = DSMident(appid, IntPtr.Zero, TwDG.Control, TwData.Identity, TwMessageCode.OpenDS, srcds);
            if (returnCode != TwReturnCode.Success)
            {
                throw new InvalidOperationException("DSMident call falied");
            }

            var guif = new TwUserInterface
            {
                ShowUI     = 1,
                ModalUI    = 1,
                ParentHand = hwnd
            };

            returnCode = DSuserif(appid, srcds, TwDG.Control, TwData.UserInterface, TwMessageCode.EnableDS, guif);
            if (returnCode != TwReturnCode.Success)
            {
                CloseSrc();
                if (returnCode == TwReturnCode.Cancel)
                {
                    return(false);
                }
                throw new InvalidOperationException("DSuserif call falied");
            }
            return(true);
        }
示例#3
0
 private static extern TwReturnCode DSuserif([In, Out] TwIdentity origin, [In, Out] TwIdentity dest, TwDG dg, TwData data, TwMessageCode messageCode, TwUserInterface guif);
示例#4
0
文件: TwainLib.cs 项目: v0id24/naps2
 private static extern TwReturnCode DSuserif([In, Out] TwIdentity origin, [In, Out] TwIdentity dest, TwDG dg, TwData data, TwMessageCode messageCode, TwUserInterface guif);
示例#5
0
文件: TwainLib.cs 项目: v0id24/naps2
 public void CloseSrc()
 {
     TwReturnCode returnCode;
     if (srcds.Id != IntPtr.Zero)
     {
         var guif = new TwUserInterface();
         returnCode = DSuserif(appid, srcds, TwDG.Control, TwData.UserInterface, TwMessageCode.DisableDS, guif);
         returnCode = DSMident(appid, IntPtr.Zero, TwDG.Control, TwData.Identity, TwMessageCode.CloseDS, srcds);
     }
 }
示例#6
0
文件: TwainLib.cs 项目: v0id24/naps2
        public bool Acquire()
        {
            TwReturnCode returnCode;
            CloseSrc();
            if (appid.Id == IntPtr.Zero)
            {
                Init(hwnd);
                if (appid.Id == IntPtr.Zero)
                    throw new InvalidOperationException("Init call falied");
            }
            returnCode = DSMident(appid, IntPtr.Zero, TwDG.Control, TwData.Identity, TwMessageCode.OpenDS, srcds);
            if (returnCode != TwReturnCode.Success)
                throw new InvalidOperationException("DSMident call falied");

            var guif = new TwUserInterface
            {
                ShowUI = 1,
                ModalUI = 1,
                ParentHand = hwnd
            };
            returnCode = DSuserif(appid, srcds, TwDG.Control, TwData.UserInterface, TwMessageCode.EnableDS, guif);
            if (returnCode != TwReturnCode.Success)
            {
                CloseSrc();
                if (returnCode == TwReturnCode.Cancel)
                {
                    return false;
                }
                throw new InvalidOperationException("DSuserif call falied");
            }
            return true;
        }