Ejemplo n.º 1
0
        private CWintabContext OpenSystemContext(bool ctrlSysCursor = true)
        {
            CWintabContext context = CWintabInfo.GetDefaultSystemContext();

            if (context == null)
            {
                return(null);
            }
            // Set system cursor if caller wants it.
            if (ctrlSysCursor)
            {
                context.Options |= (uint)ECTXOptionValues.CXO_SYSTEM;
            }
            else
            {
                context.Options &= ~(uint)ECTXOptionValues.CXO_SYSTEM;
            }
            context.Name = "BgoonLibrary Tablet Context";

            deviceID = CWintabInfo.GetDefaultDeviceIndex();
            WintabAxis tabletX = CWintabInfo.GetDeviceAxis(deviceID, EAxisDimension.AXIS_X);
            WintabAxis tabletY = CWintabInfo.GetDeviceAxis(deviceID, EAxisDimension.AXIS_Y);

            NativeRect = new GRect(tabletX.axMin, tabletY.axMin, tabletX.axMax, tabletY.axMax);

            context.OutOrgX = context.OutOrgY = 0;
            context.OutExtX = (int)(context.OutExtX * OutputExtFactor);
            context.OutExtY = (int)(context.OutExtY * OutputExtFactor);
            //context.OutOrgX = context.OutOrgY = 0;
            //context.OutExtX = MaxPos.x;
            //context.OutExtY = MaxPos.y;

            //context.OutExtY *= -1;
            return(context.Open() ? context : null);
        }
Ejemplo n.º 2
0
        private CWintabContext OpenDigitalContext(bool ctrlSysCursor = true)
        {
            CWintabContext context = CWintabInfo.GetDefaultDigitizingContext();

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

            context.Options |= (uint)ECTXOptionValues.CXO_MESSAGES;
            if (ctrlSysCursor)
            {
                context.Options |= (uint)ECTXOptionValues.CXO_SYSTEM;
            }
            context.Name = "BgoonLibrary Tablet Context";

            deviceID = CWintabInfo.GetDefaultDeviceIndex();
            WintabAxis tabletX = CWintabInfo.GetDeviceAxis(deviceID, EAxisDimension.AXIS_X);
            WintabAxis tabletY = CWintabInfo.GetDeviceAxis(deviceID, EAxisDimension.AXIS_Y);

            NativeRect = new GRect(tabletX.axMin, tabletX.axMax, tabletY.axMin, tabletY.axMax);

            context.OutOrgX = context.OutOrgY = 0;
            context.OutExtX = (int)(context.OutExtX * OutputExtFactor);
            context.OutExtY = (int)(context.OutExtY * OutputExtFactor);

            //context.OutExtY *= -1;

            return(context.Open() ? context : null);
        }
Ejemplo n.º 3
0
        ///////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Sets logContext.In and LogContext.Out
        /// </summary>
        /// <param name="logContext">Wintab context being changed</param>
        /// <param name="newTabletInRect">New tablet input rectangle (width || height zero == no change)</param>
        /// <param name="newTabletOutRect">New tablet output rectangle (width || height zero == no change)</param>

        private void SetTabletExtents(ref CWintabContext logContext, Rectangle newTabletInRect, Rectangle newTabletOutRect)
        {
            if (logContext == null)
            {
                throw new NullReferenceException("Oops - null wintab context");
            }

            if (newTabletInRect.Width != 0 && newTabletInRect.Height != 0)
            {
                logContext.InOrgX = newTabletInRect.X;
                logContext.InOrgY = newTabletInRect.Y;
                logContext.InExtX = newTabletInRect.Width;
                logContext.InExtY = newTabletInRect.Height;
            }

            if (newTabletOutRect.Width != 0 && newTabletOutRect.Height != 0)
            {
                logContext.OutOrgX = newTabletOutRect.X;
                logContext.OutOrgY = newTabletOutRect.Y;
                logContext.OutExtX = newTabletOutRect.Width;
                logContext.OutExtY = newTabletOutRect.Height;
            }

            if (logContext.OutExtY > 0)
            {
                // In Wintab, the tablet origin is lower left.  Move origin to upper left
                // so that it coincides with screen origin.
                logContext.OutExtY = -logContext.OutExtY;
            }
        }
Ejemplo n.º 4
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());
            }
        }
Ejemplo n.º 5
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());
            }
        }
Ejemplo n.º 6
0
        ///////////////////////////////////////////////////////////////////////
        private CWintabContext OpenTestSystemContext(
            int width_I = m_TABEXTX, int height_I = m_TABEXTY, bool ctrlSysCursor = true)
        {
            bool           status     = false;
            CWintabContext logContext = null;

            try
            {
                // Get the default system context.
                // Default is to receive data events.
                //logContext = CWintabInfo.GetDefaultDigitizingContext(ECTXOptionValues.CXO_MESSAGES);
                logContext = CWintabInfo.GetDefaultSystemContext(ECTXOptionValues.CXO_MESSAGES);

                // Set system cursor if caller wants it.
                if (ctrlSysCursor)
                {
                    logContext.Options |= (uint)ECTXOptionValues.CXO_SYSTEM;
                }

                if (logContext == null)
                {
                    TraceMsg("FAILED to get default digitizing context.\n");
                    return(null);
                }

                // Modify the digitizing region.
                logContext.Name = "WintabDN Event Data Context";

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

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

                logContext.OutOrgX = (int)SystemParameters.VirtualScreenLeft;
                logContext.OutOrgY = (int)SystemParameters.VirtualScreenTop;
                logContext.OutExtX = (int)SystemParameters.VirtualScreenWidth;

                // In Wintab, the tablet origin is lower left.  Move origin to upper left
                // so that it coincides with screen origin.
                logContext.OutExtY = -(int)SystemParameters.VirtualScreenHeight;


                // Open the context, which will also tell Wintab to send data packets.
                status = logContext.Open();

                TraceMsg("Context Open: " + (status ? "PASSED [ctx=" + logContext.HCtx + "]" : "FAILED") + "\n");
            }
            catch (Exception ex)
            {
                TraceMsg("OpenTestDigitizerContext ERROR: " + ex.ToString());
            }

            return(logContext);
        }
        ///////////////////////////////////////////////////////////////////////

        public void Init(CWintabContext logContext_I)
        {
            if (logContext_I == null)
            {
                throw new NullReferenceException("Oops - logContext is null!");
            }

            LogContext = logContext_I;
            InitMappingFields();
        }
Ejemplo n.º 8
0
        ///////////////////////////////////////////////////////////////////////
        private CWintabContext OpenTestSystemContext(
            int width_I = m_TABEXTX, int height_I = m_TABEXTY, bool ctrlSysCursor = true)
        {
            bool           status     = false;
            CWintabContext logContext = null;

            try
            {
                // Get the default system context.
                // Default is to receive data events.
                //logContext = CWintabInfo.GetDefaultDigitizingContext(ECTXOptionValues.CXO_MESSAGES);
                logContext = CWintabInfo.GetDefaultSystemContext(ECTXOptionValues.CXO_MESSAGES);

                // Set system cursor if caller wants it.
                if (ctrlSysCursor)
                {
                    logContext.Options |= (uint)ECTXOptionValues.CXO_SYSTEM;
                }
                else
                {
                    logContext.Options &= ~(uint)ECTXOptionValues.CXO_SYSTEM;
                }

                if (logContext == null)
                {
                    TraceMsg("FAILED to get default digitizing context.\n");
                    return(null);
                }

                // Modify the digitizing region.
                logContext.Name = "WintabDN Event Data Context";

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

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

                // SetSystemExtents() is (almost) a NO-OP redundant if you opened a system context.
                SetSystemExtents(ref logContext);

                // Open the context, which will also tell Wintab to send data packets.
                status = logContext.Open();

                TraceMsg("Context Open: " + (status ? "PASSED [ctx=" + logContext.HCtx + "]" : "FAILED") + "\n");
            }
            catch (Exception ex)
            {
                TraceMsg("OpenTestDigitizerContext ERROR: " + ex.ToString());
            }

            return(logContext);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        ///////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Opens a Wintab default system context
        /// </summary>
        /// <param name="ctrlSysCursor"></param>
        /// <returns></returns>

        private CWintabContext OpenTestSystemContext(bool ctrlSysCursor = true)
        {
            bool           status     = false;
            CWintabContext logContext = null;

            try
            {
                // Get the default system context.
                // Default is to receive data events.
                logContext = CWintabInfo.GetDefaultSystemContext(ECTXOptionValues.CXO_MESSAGES);

                // Set system cursor if caller wants it.
                if (ctrlSysCursor)
                {
                    logContext.Options |= (uint)ECTXOptionValues.CXO_SYSTEM;
                }
                else
                {
                    logContext.Options &= ~(uint)ECTXOptionValues.CXO_SYSTEM;
                }

                if (logContext == null)
                {
                    TraceMsg("FAILED to get default wintab context.\n");
                    return(null);
                }

                // ----------------------------------------------------------------------
                // Modify the tablet extents to set what part of the tablet is used.
                Rectangle newTabletInRect  = new Rectangle();
                Rectangle newTabletOutRect = new Rectangle();

                SetTabletExtents(ref logContext, newTabletInRect, newTabletOutRect);

                // ----------------------------------------------------------------------
                // Modify the system extents to control where cursor is allowed to move on desktop.
                Rectangle newScreenRect = new Rectangle();

                SetSystemExtents(ref logContext, newScreenRect);

                // Open the context, which will also tell Wintab to send data packets.
                status = logContext.Open();

                TraceMsg("Context Open: " + (status ? "PASSED [ctx=" + logContext.HCtx + "]" : "FAILED") + "\n");
            }
            catch (Exception ex)
            {
                TraceMsg("OpenTestDigitizerContext ERROR: " + ex.ToString());
            }

            return(logContext);
        }
Ejemplo n.º 11
0
        private bool InitSystemContextCapture(bool ctrlSysCursor = true)
        {
            context = OpenSystemContext(ctrlSysCursor);

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

            data = new CWintabData(context);
            data.SetWTPacketEventHandler(OnReceivePacket);
            return(true);
        }
Ejemplo n.º 12
0
        ///////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Sets logContext.Out
        /// </summary>
        /// <param name="logContext">Wintab context being changed</param>
        /// <param name="newScreenRect">New screen rectangle (width || height zero == no change)</param>

        private void SetSystemExtents(ref CWintabContext logContext, Rectangle newScreenRect)
        {
            if (logContext == null)
            {
                throw new NullReferenceException("Oops - null wintab context");
            }

            if (newScreenRect.Width != 0 && newScreenRect.Height != 0)
            {
                logContext.SysOrgX = newScreenRect.X;
                logContext.SysOrgY = newScreenRect.Y;
                logContext.SysExtX = newScreenRect.Width;
                logContext.SysExtY = newScreenRect.Height;
            }
        }
Ejemplo n.º 13
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);
     }
 }
Ejemplo n.º 14
0
        ///////////////////////////////////////////////////////////////////////
        // Sets logContext.Out
        //
        // Note:
        // SystemParameters.VirtualScreenLeft{Top} and SystemParameters.VirtualScreenWidth{Height}
        // don't always give correct answers.
        //
        // Uncomment the TODO code below that enumerates all system displays
        // if you want to customize.
        // Else assume the passed-in extents were already set by call to WTInfo,
        // in which case we still have to invert the Y extent.
        private void SetSystemExtents(ref CWintabContext logContext)
        {
            //TODO Rectangle rect = new Rectangle(int.MaxValue, int.MaxValue, int.MinValue, int.MinValue);

            //TODO foreach (Screen screen in Screen.AllScreens)
            //TODO    rect = Rectangle.Union(rect, screen.Bounds);

            //TODO logContext.OutOrgX = rect.Left;
            //TODO logContext.OutOrgY = rect.Top;
            //TODO logContext.OutExtX = rect.Width;
            //TODO logContext.OutExtY = rect.Height;

            // In Wintab, the tablet origin is lower left.  Move origin to upper left
            // so that it coincides with screen origin.
            logContext.OutExtY = -logContext.OutExtY;
        }
Ejemplo n.º 15
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());
     }
 }
Ejemplo n.º 16
0
        ///////////////////////////////////////////////////////////////////////

        private CWintabContext OpenTestDigitizerContext(
            int width_I = 0, int height_I = 0, bool ctrlSysCursor = true)
        {
            bool           status     = false;
            CWintabContext logContext = null;

            try
            {
                // Get the default digitizing context.
                // Default is to receive data events.
                logContext = CWintabInfo.GetDefaultDigitizingContext(ECTXOptionValues.CXO_MESSAGES);

                // Set system cursor if caller wants it.
                if (ctrlSysCursor)
                {
                    logContext.Options |= (uint)ECTXOptionValues.CXO_SYSTEM;
                }

                if (logContext == null)
                {
                    TraceMsg("FAILED to get default digitizing context.\n");
                    return(null);
                }

                // Modify the digitizing region.
                logContext.Name = "WintabDN Event Data Context";

                if (width_I != 0 && height_I != 0)
                {
                    // output in a grid of the specified dimensions.
                    logContext.OutOrgX = logContext.OutOrgY = 0;
                    logContext.OutExtX = width_I;
                    logContext.OutExtY = height_I;
                }

                // Open the context, which will also tell Wintab to send data packets.
                status = logContext.Open();

                TraceMsg("Context Open: " + (status ? "PASSED [ctx=" + logContext.HCtx + "]" : "FAILED") + "\n");
            }
            catch (Exception ex)
            {
                TraceMsg("OpenTestDigitizerContext ERROR: " + ex.ToString());
            }

            return(logContext);
        }
Ejemplo n.º 17
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());
     }
 }
Ejemplo n.º 18
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");
                }
            }
        }
Ejemplo n.º 19
0
        ///////////////////////////////////////////////////////////////////////
        private void Test_GetDefaultSystemContext()
        {
            CWintabContext context = CWintabInfo.GetDefaultSystemContext();

            TraceMsg("Default System Context:\n");
            TraceMsg("\tSysOrgX, SysOrgY, SysExtX, SysExtY\t[" +
                     context.SysOrgX + "," + context.SysOrgY + "," +
                     context.SysExtX + "," + context.SysExtY + "]\n");

            TraceMsg("\tInOrgX, InOrgY, InExtX, InExtY\t[" +
                     context.InOrgX + "," + context.InOrgY + "," +
                     context.InExtX + "," + context.InExtY + "]\n");

            TraceMsg("\tOutOrgX, OutOrgY, OutExtX, OutExt\t[" +
                     context.OutOrgX + "," + context.OutOrgY + "," +
                     context.OutExtX + "," + context.OutExtY + "]\n");
        }
Ejemplo n.º 20
0
        ///////////////////////////////////////////////////////////////////////
        private void Test_GetDefaultDigitizingContext()
        {
            CWintabContext context = CWintabInfo.GetDefaultDigitizingContext();

            Console.WriteLine("Default Digitizing Context:\n");
            Console.WriteLine("\tSysOrgX, SysOrgY, SysExtX, SysExtY\t[" +
                              context.SysOrgX + "," + context.SysOrgY + "," +
                              context.SysExtX + "," + context.SysExtY + "]\n");

            Console.WriteLine("\tInOrgX, InOrgY, InExtX, InExtY\t[" +
                              context.InOrgX + "," + context.InOrgY + "," +
                              context.InExtX + "," + context.InExtY + "]\n");

            Console.WriteLine("\tOutOrgX, OutOrgY, OutExtX, OutExt\t[" +
                              context.OutOrgX + "," + context.OutOrgY + "," +
                              context.OutExtX + "," + context.OutExtY + "]\n");
        }
Ejemplo n.º 21
0
        ///////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Allows user to change tablet to system mapping.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void MappingButton_Click(object sender, EventArgs e)
        {
            if (m_logContext == null)
            {
                System.Windows.Forms.MessageBox.Show("Oops - You need to run Wintab tests or Scribble before you can use this button.");
                return;
            }

            PenTestApp.MappingForm mappingDlg = new PenTestApp.MappingForm();
            mappingDlg.Init(m_logContext);
            if (DialogResult.OK == mappingDlg.ShowDialog())
            {
                // Close existing context and create a new context with the changed extents.
                CWintabContext temp   = mappingDlg.LogContext;
                Point          inOrg  = new Point(temp.InOrgX, temp.InOrgY);
                Size           inExt  = new Size(temp.InExtX, temp.InExtY);
                Point          outOrg = new Point(temp.OutOrgX, temp.OutOrgY);
                Size           outExt = new Size(temp.OutExtX, temp.OutExtY);
                Point          sysOrg = new Point(temp.SysOrgX, temp.SysOrgY);
                Size           sysExt = new Size(temp.SysExtX, temp.SysExtY);

                CloseCurrentContext();

                m_logContext = CWintabInfo.GetDefaultSystemContext(ECTXOptionValues.CXO_MESSAGES);

                if (m_logContext == null)
                {
                    throw new NullReferenceException("Oops - FAILED to get default system context.\n");
                }

                SetTabletExtents(ref m_logContext, new Rectangle(inOrg, inExt), new Rectangle(outOrg, outExt));
                SetSystemExtents(ref m_logContext, new Rectangle(sysOrg, sysExt));

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

                CreateDataObject(m_logContext);

                m_logContext.Open();
            }
        }
Ejemplo n.º 22
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());
     }
 }
Ejemplo n.º 23
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);
        }
Ejemplo n.º 24
0
        private CWintabContext OpenQueryDigitizerContext(out bool status)
        {
            status = false;
            CWintabContext logContext = null;

            try
            {
                // Get the default digitizing context.
                // Default is to receive data events.
                logContext = CWintabInfo.GetDefaultDigitizingContext(ECTXOptionValues.CXO_MESSAGES);

                // Set system cursor
                logContext.Options |= (uint)ECTXOptionValues.CXO_SYSTEM;

                if (logContext == null)
                {
                    return(null);
                }

                // Modify the digitizing region.
                logContext.Name = "WintabDN Event Data Context";

                // output in a 10000 x 10000 grid
                logContext.OutOrgX = logContext.OutOrgY = 0;
                logContext.OutExtX = 10000;
                logContext.OutExtY = 10000;


                // Open the context, which will also tell Wintab to send data packets.
                status = logContext.Open();

                // set IsConnected to the status of the tablet true = tablet ready false = tablet not found / tablet not supported
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(logContext);
        }
        //---------------------------------------------------------------------
        // 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);
        }
Ejemplo n.º 26
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;
 }
Ejemplo n.º 27
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);
            }
        }
Ejemplo n.º 28
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());
            }
        }
Ejemplo n.º 29
0
        //TODO: modify this to fit screen window
        private void Test_Context()
        {
            bool           status     = false;
            CWintabContext logContext = null;

            try
            {
                logContext = OpenTestDigitizerContext();
                if (logContext == null)
                {
                    //TODO: throw error maybe?
                    throw new Exception("Test_Context: FAILED OpenTestDigitizerContext - bailing out...\n");
                }

                status = logContext.Enable(true);
                //TraceMsg("Context Enable: " + (status ? "PASSED" : "FAILED") + "\n");

                status = logContext.SetOverlapOrder(false);
                //TraceMsg("Context SetOverlapOrder to bottom: " + (status ? "PASSED" : "FAILED") + "\n");
                status = logContext.SetOverlapOrder(true);
                //TraceMsg("Context SetOverlapOrder to top: " + (status ? "PASSED" : "FAILED") + "\n");
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
            finally
            {
                //TODO: throw exception
                //if (logContext != null)
                //{
                //    status = logContext.Close();
                //    TraceMsg("Context Close: " + (status ? "PASSED" : "FAILED") + "\n");
                //}
            }
        }
Ejemplo n.º 30
0
        ///////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Opens a test system context for data capture
        /// </summary>
        /// <param name="ctrlSysCursor_I"></param>

        private void InitSystemDataCapture(bool ctrlSysCursor_I = true)
        {
            try
            {
                // Close context from any previous test.
                CloseCurrentContext();

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

                m_logContext = OpenTestSystemContext(ctrlSysCursor_I);

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

                CreateDataObject(m_logContext);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
        }