示例#1
0
 /// <summary>
 /// Closes data source
 /// </summary>
 public void CloseDS()
 {
     if (m_srcDs.Id != IntPtr.Zero)
     {
         TwUserInterface guif = new TwUserInterface();
         DSuserif(m_appId, m_srcDs, TwDG.Control, TwDAT.UserInterface, TwMSG.DisableDS, guif);
         DSMident(m_appId, IntPtr.Zero, TwDG.Control, TwDAT.Identity, TwMSG.CloseDS, m_srcDs);
     }
     m_srcDs.Id = IntPtr.Zero;
 }
示例#2
0
        /// <summary>
        /// Acquires image from scanner
        /// </summary>
        /// <param name="defaltSettings"></param>
        /// <param name="imprinterText">String to print. It's null or empty if no Imprinting</param>
        public void Acquire(bool defaltSettings, string imprinterText)
        {
            Debug.Assert(string.IsNullOrEmpty(imprinterText) || Encoding.ASCII.GetByteCount(imprinterText) < 256);

            UseImprinter = !string.IsNullOrEmpty(imprinterText);

            CloseDS();

            CloseDSM();

            Init(m_hWnd);

            CheckAndThrow(DSMident(m_appId, IntPtr.Zero, TwDG.Control, TwDAT.Identity, TwMSG.OpenDS, m_srcDs), "Cannot open DS");

            var cap = new TwCapability(TwCap.CAP_XFERCOUNT, 1);

            CheckCloseAndThrow(DScap(m_appId, m_srcDs, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap), "Cannot set cap CAP_XFERCOUNT");

            cap = new TwCapability(TwCap.CAP_SUPPORTEDSIZES, 0);
            CheckCloseAndThrow(DScap(m_appId, m_srcDs, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap), "Cannot set cap CAP_SUPPORTEDSIZES");
            var layout = new TwImageLayout();

            CheckCloseAndThrow(DSilayout(m_appId, m_srcDs, TwDG.Image, TwDAT.ImageLayout, TwMSG.Get, layout), "Cannot get ImageLayout");

            //Use Imprinter
            cap = new TwCapability(TwCap.CAP_PRINTER, TWPR_IMPRINTERBOTTOMAFTER);
            if (Check(DScap(m_appId, m_srcDs, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap)))
            {
                cap = new TwCapability(TwCap.CAP_PRINTERENABLED, (imprinterText.IsNullOrEmpty() ? FALSE : TRUE));
                CheckCloseAndThrow(DScap(m_appId, m_srcDs, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap), "Cannot set cap CAP_PRINTERENABLED");

                if (!imprinterText.IsNullOrEmpty())
                {
                    cap = new TwCapability(TwCap.CAP_PRINTERMODE, TWPM_SINGLESTRING);
                    CheckCloseAndThrow(DScap(m_appId, m_srcDs, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap), "Cannot set cap CAP_PRINTERMODE");

                    cap = new TwCapability(TwCap.CAP_PRINTERSTRING, imprinterText, TwType.Str255);
                    CheckCloseAndThrow(DScap(m_appId, m_srcDs, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap), "Cannot set cap CAP_PRINTERSTRING");
                }
            }

            var guif = new TwUserInterface();

            guif.ShowUI     = (short)(defaltSettings ? FALSE : TRUE);
            guif.ModalUI    = 1;
            guif.ParentHand = m_hWnd;
            CheckCloseAndThrow(DSuserif(m_appId, m_srcDs, TwDG.Control, TwDAT.UserInterface, TwMSG.EnableDS, guif), "Cannot enable DS");
        }
示例#3
0
 private static extern TwRC DSuserif([In, Out] TwIdentity origin, [In, Out] TwIdentity dest, TwDG dg, TwDAT dat, TwMSG msg, TwUserInterface guif);