Пример #1
0
        private void InitDataCapture(EventHandler <MessageReceivedEventArgs> handler, int ctxWidth_I = m_TABEXTX, int ctxHeight_I = m_TABEXTY, bool ctrlSysCursor_I = true)
        {
            try
            {
                // Close context from any previous test.
                CloseCurrentContext();

                Console.WriteLine("Opening context...\n");

                m_logContext = OpenTestSystemContext(ctxWidth_I, ctxHeight_I, ctrlSysCursor_I);

                if (m_logContext == null)
                {
                    Console.WriteLine("Test_DataPacketQueueSize: FAILED OpenTestSystemContext - bailing out...\n");
                    return;
                }

                // Create a data object and set its WT_PACKET handler.
                m_wtData = new CWintabData(m_logContext);
                m_wtData.SetWTPacketEventHandler(handler);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(new Form()
                {
                    WindowState = FormWindowState.Maximized, TopMost = true
                }, ex.ToString());
            }
        }
Пример #2
0
        ///////////////////////////////////////////////////////////////////////
        // Helper functions
        //

        ///////////////////////////////////////////////////////////////////////
        private void InitDataCapture(
            int ctxWidth_I = m_TABEXTX, int ctxHeight_I = m_TABEXTY, bool ctrlSysCursor_I = true)
        {
            try
            {
                // Close context from any previous test.
                CloseCurrentContext();

                TraceMsg("Opening context...\n");

                m_logContext = OpenTestSystemContext(ctxWidth_I, ctxHeight_I, ctrlSysCursor_I);

                if (m_logContext == null)
                {
                    TraceMsg("Test_DataPacketQueueSize: FAILED OpenTestSystemContext - bailing out...\n");
                    return;
                }

                // Create a data object and set its WT_PACKET handler.
                m_wtData = new CWintabData(m_logContext);
                m_wtData.SetWTPacketEventHandler(MyWTPacketEventHandler);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
        }
Пример #3
0
        ///////////////////////////////////////////////////////////////////////
        // Helper functions
        //

        ///////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Cretes a Wintab data context using a default event handler.
        /// </summary>
        /// <param name="logContext_I"></param>

        private void CreateDataObject(CWintabContext logContext_I)
        {
            if (logContext_I == null)
            {
                throw new NullReferenceException("Oops - NULL wintab context when setting data handler");
            }

            // Create a data object and set its WT_PACKET handler.
            m_wtData = new CWintabData(m_logContext);
            m_wtData.SetWTPacketEventHandler(MyWTPacketEventHandler);
        }
Пример #4
0
        private bool InitSystemContextCapture(bool ctrlSysCursor = true)
        {
            context = OpenSystemContext(ctrlSysCursor);

            if (context == null)
            {
                return(false);
            }

            data = new CWintabData(context);
            data.SetWTPacketEventHandler(OnReceivePacket);
            return(true);
        }
Пример #5
0
        public bool TryConnect()
        {
            bool status = true;

            try
            {
                CloseCurrentContext();

                m_logContext = OpenQueryDigitizerContext(out status);

                m_wtData = new CWintabData(m_logContext);
                m_wtData.SetWTPacketEventHandler(HandlePenMessage);
            }
            catch (Exception ex)
            {
                status = false;
                Log.Fatal(ex.ToString());
            }

            return(status);
        }
        //---------------------------------------------------------------------
        // Prepare to take tablet input
        //---------------------------------------------------------------------
        private void PrepareForTabletInput(object sender, EventArgs e)
        {
            // Set up the tablet context
            CWintabContext context = new CWintabContext();

            context = CWintabInfo.GetDefaultDigitizingContext(ECTXOptionValues.CXO_MESSAGES);

            // Allow the mouse to move
            context.Options |= (uint)ECTXOptionValues.CXO_SYSTEM;

            context.Name    = "Tablet event data context";
            context.OutOrgX = 0;
            context.OutOrgY = 0;
            context.OutExtX = 1000;
            context.OutExtY = 1000;

            bool status = context.Open();

            // Prepare to take data
            data = new CWintabData(context);
            data.SetWTPacketEventHandler(TabletEventHandler);
        }
Пример #7
0
        /// <summary>
        /// Tries initializing the tablet reading logic. Returns false on failure.
        /// </summary>
        public bool Start()
        {
            try
            {
                winTabContext = CWintabInfo.GetDefaultSystemContext(ECTXOptionValues.CXO_MESSAGES | ECTXOptionValues.CXO_SYSTEM);
                winTabData    = new CWintabData(winTabContext);

                // Failed to get the system context
                if (winTabContext == null)
                {
                    return(false);
                }

                winTabContext.Name = "DynamicDraw Tablet Event Data Context";

                WintabAxis tabletX = CWintabInfo.GetTabletAxis(EAxisDimension.AXIS_X);
                WintabAxis tabletY = CWintabInfo.GetTabletAxis(EAxisDimension.AXIS_Y);

                winTabContext.InOrgX = 0;
                winTabContext.InOrgY = 0;
                winTabContext.InExtX = tabletX.axMax;
                winTabContext.InExtY = tabletY.axMax;

                // Tablet origin is usually lower left, invert it to be upper left to match screen coord system.
                winTabContext.OutExtY = -winTabContext.OutExtY;

                bool didOpen = winTabContext.Open();

                winTabData.SetWTPacketEventHandler(UpdateTabletData);

                return(true);
            }
            catch (DllNotFoundException)
            {
                // winTab32.dll is missing. Tablet users will have it; non-tablet users don't need it.
                return(false);
            }
        }
Пример #8
0
        ///////////////////////////////////////////////////////////////////////
        // Helper functions
        //

        ///////////////////////////////////////////////////////////////////////
        public void InitDataCapture(Screen forScreen, int ctxWidth_I = m_TABEXTX, int ctxHeight_I = m_TABEXTY, bool ctrlSysCursor_I = true)
        {
            try
            {
                // Close context from any previous test.
                CloseCurrentContext();

                m_logContext = OpenTestSystemContext(forScreen, ctxWidth_I, ctxHeight_I, ctrlSysCursor_I);

                if (m_logContext == null)
                {
                    return;
                }

                // Create a data object and set its WT_PACKET handler.
                m_wtData = new CWintabData(m_logContext);
                m_wtData.SetWTPacketEventHandler(MyWTPacketEventHandler);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
        }
Пример #9
0
        private bool InitWintab()
        {
            bool status = false;

            try
            {
                mLogContext = CWintabInfo.GetDefaultDigitizingContext(ECTXOptionValues.CXO_MESSAGES);
                if (mLogContext == null)
                {
                    return(false);
                    //throw new Exception("Oops - FAILED GetDefaultDigitizingContext");
                }

                // Control system cursor.
                mLogContext.Options |= (UInt32)ECTXOptionValues.CXO_SYSTEM;

                // Verify which extensions are available for targeting.
                // Once we know what the tablet supports, we can set up the data packet
                // definition to be sent events from those control types.

                // All tablets should have at least expresskeys.
                mExpKeysMask = CWintabExtensions.GetWTExtensionMask(EWTXExtensionTag.WTX_EXPKEYS2);

                if (mExpKeysMask > 0)
                {
                    mLogContext.PktData |= (WTPKT)mExpKeysMask;
                }
                else
                {
                    Debug.WriteLine("InitWintab: WTX_EXPKEYS2 mask not found!");
                    throw new Exception("Oops - FAILED GetWTExtensionMask for WTX_EXPKEYS2");
                }

                // It's not an error if either / both of these are zero.  It simply means
                // that those control types are not supported.
                mTouchRingMask = CWintabExtensions.GetWTExtensionMask(EWTXExtensionTag.WTX_TOUCHRING);
                if (mTouchRingMask > 0)
                {
                    mLogContext.PktData |= (WTPKT)mTouchRingMask;
                }

                mTouchStripMask = CWintabExtensions.GetWTExtensionMask(EWTXExtensionTag.WTX_TOUCHSTRIP);
                if (mTouchStripMask > 0)
                {
                    mLogContext.PktData |= (WTPKT)mTouchStripMask;
                }

                status = mLogContext.Open();
                if (!status)
                {
                    //throw new Exception("Oops - failed logContext.Open()");
                    return(false);
                }

                // Setup controls and overrides for first tablet.
                SetupControlsForTablet(mTabletIndexDefault);

                // Create a data object and set its WT_PACKET handler.
                m_wtData = new CWintabData(mLogContext);
                m_wtData.SetWTPacketEventHandler(MyWTPacketEventHandler);
            }
            catch (Exception ex)
            {
                MessageBox.Show("FormExtTestApp: InitWintab: " + ex.ToString());
            }

            return(true);
        }