Пример #1
0
        private void HandleTabletData(object sender, MessageReceivedEventArgs e)
        {
            CWintabData m_wtData  = ti.getWintabData();
            UInt32      m_maxPkts = ti.getMaxPackets();

            if (m_wtData == null)
            {
                return;
            }

            try
            {
                if (m_maxPkts == 1)
                {
                    uint         pktID = (uint)e.Message.WParam;
                    WintabPacket pkt   = m_wtData.GetDataPacket((uint)e.Message.LParam, pktID);

                    if (pkt.pkContext != 0)
                    {
                        int pressure = (int)pkt.pkNormalPressure;
                        ss.setTabletPressure(pressure);
                    }
                }
            }
            catch (Exception err)
            {
                ss.setTabletConnected(false);
                Console.WriteLine(err.InnerException);
            }
        }
Пример #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
        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());
            }
        }
Пример #4
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);
        }
Пример #5
0
        private bool InitSystemContextCapture(bool ctrlSysCursor = true)
        {
            context = OpenSystemContext(ctrlSysCursor);

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

            data = new CWintabData(context);
            data.SetWTPacketEventHandler(OnReceivePacket);
            return(true);
        }
Пример #6
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    winTabData = null;
                }

                winTabContext?.Close();
                disposedValue = true;
            }
        }
Пример #7
0
 ///////////////////////////////////////////////////////////////////////
 public void CloseCurrentContext()
 {
     try
     {
         if (m_logContext != null)
         {
             m_logContext.Close();
             m_logContext = null;
             m_wtData     = null;
         }
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show(ex.ToString());
     }
 }
Пример #8
0
 private void CloseCurrentContext()
 {
     try
     {
         if (m_logContext != null)
         {
             m_logContext.Close();
             m_logContext = null;
             m_wtData     = null;
         }
     }
     catch (Exception ex)
     {
         Log.Fatal(ex.Message);
     }
 }
        /// <summary>
        /// Restore the tablet control functions and close Wintab context.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ExtensionTestForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (m_wtData != null)
            {
                m_wtData.RemoveWTPacketEventHandler(MyWTPacketEventHandler);
                m_wtData = null;
            }
            if (mLogContext != null && mLogContext.HCtx != 0)
            {
                foreach (var tabletIdx in mTabletList)
                {
                    RemoveOverridesForTablet(tabletIdx);
                }

                mLogContext.Close();
            }
        }
Пример #10
0
        ///////////////////////////////////////////////////////////////////////

        private void Test_DataPacketQueueSize()
        {
            bool           status     = false;
            UInt32         numPackets = 0;
            CWintabContext logContext = null;

            try
            {
                logContext = OpenTestDigitizerContext();
                //logContext = OpenTestDigitizerContext(m_TABEXTX, m_TABEXTY);

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

                CWintabData wtData = new CWintabData(logContext);
                TraceMsg("Creating CWintabData object: " + (wtData != null ? "PASSED" : "FAILED") + "\n");
                if (wtData == null)
                {
                    throw new Exception("Could not create CWintabData object.");
                }

                numPackets = wtData.GetPacketQueueSize();
                TraceMsg("Initial packet queue size: " + numPackets + "\n");

                status = wtData.SetPacketQueueSize(17);
                TraceMsg("Setting packet queue size: " + (status ? "PASSED" : "FAILED") + "\n");

                numPackets = wtData.GetPacketQueueSize();
                TraceMsg("Modified packet queue size: " + numPackets + "\n");
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
            finally
            {
                if (logContext != null)
                {
                    status = logContext.Close();
                    TraceMsg("Context Close: " + (status ? "PASSED" : "FAILED") + "\n");
                }
            }
        }
Пример #11
0
 ///////////////////////////////////////////////////////////////////////
 private void CloseCurrentContext()
 {
     try
     {
         TraceMsg("Closing context...\n");
         if (m_logContext != null)
         {
             m_logContext.Close();
             m_logContext = null;
             m_wtData     = null;
         }
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show(ex.ToString());
     }
 }
Пример #12
0
 private void CloseCurrentContext()
 {
     try
     {
         Console.WriteLine("Closing context...\n");
         if (m_logContext != null)
         {
             m_logContext.Close();
             m_logContext = null;
             m_wtData     = null;
         }
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show(new Form()
         {
             WindowState = FormWindowState.Maximized, TopMost = true
         }, ex.ToString());
     }
 }
Пример #13
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);
        }
Пример #14
0
 public void CaptureStop()
 {
     if (!IsRunning)
     {
         return;
     }
     try {
         if (context != null)
         {
             context.Close();
         }
         IsRunning = false;
         for (int i = 0; i < taskList.Count; ++i)
         {
             taskList[i].Stop();
         }
         taskList.Clear();
     } catch (Exception ex) {
     }
     context = null;
     data    = null;
 }
        //---------------------------------------------------------------------
        // 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);
        }
Пример #16
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);
            }
        }
Пример #17
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());
            }
        }
Пример #18
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);
        }