コード例 #1
0
ファイル: WintabInput.cs プロジェクト: Bgoon/GKit
        private void OnReceivePacket(object sender, MessageReceivedEventArgs e)
        {
            //6~7ms rate
            if (data == null || !IsRunning)
            {
                return;
            }
            try {
                uint pktID = (uint)e.Message.WParam;
                packet = data.GetDataPacket(pktID);
                if (packet.pkContext.IsValid)
                {
                    lock (dataWriteLock) {
                        MarkActive();

                        pressure = (float)packet.pkNormalPressure / maxNormalPressure;
                        distance = (float)packet.pkZ / maxTangentPressure;
                        position = new Vector2(packet.pkX, packet.pkY) / OutputExtFactor;

                        position.y = systemRect.yMax - position.y + systemRect.yMin;
                    }
                }
            } catch (Exception ex) {
                GDebug.Log(ex.ToString(), GLogLevel.Warnning);
            }
        }
コード例 #2
0
ファイル: Canvas.cs プロジェクト: CoffeeRoll/Paint-Program
        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);
            }
        }
コード例 #3
0
ファイル: TabletLaunch.cs プロジェクト: niallb/DTTPresent
        public void MyWTPacketEventHandler(Object sender_I, MessageReceivedEventArgs eventArgs_I)
        {
            if (m_maxPkts == 1)
            {
                uint         pktID = (uint)eventArgs_I.Message.WParam;
                WintabPacket pkt   = m_wtData.GetDataPacket((uint)eventArgs_I.Message.LParam, pktID);
                //WintabPacket pkt = m_wtData.GetDataPacket(pktID);

                if ((pkt.pkContext != 0) && ((pkt.pkX != lastX) || (pkt.pkY != lastY)))
                {
                    lastX = pkt.pkX;
                    lastY = pkt.pkY;
                    lastZ = pkt.pkZ;
                    //Cursor.Position = new Point(lastX/10, lastY/10);
                    Point pt = pa.PointToClient(new Point(pkt.pkX, pkt.pkY));
                    // Point pt = pa.PointToClient(new Point(lastX / 10, lastY / 10));
                    pa.showPointer(pt.X, pt.Y);
                    uint m_pressure = pkt.pkNormalPressure;

                    textBox1.Text  = "Bamboo point " + pkt.pkX.ToString() + ", " + pkt.pkY.ToString() + ", Z:" + pkt.pkZ.ToString() + ", p:" + m_pressure.ToString();
                    textBox1.Text += "\r\nTP:" + pkt.pkTangentPressure.ToString();
                    textBox1.Text += "\r\nTime:" + pkt.pkTime.ToString();
                    textBox1.Text += "\r\nContext:" + pkt.pkContext.ToString();
                    textBox1.Text += "\r\nStatus:" + pkt.pkStatus.ToString();
                    textBox1.Text += "\r\n" + pt.X.ToString() + "," + pt.Y.ToString();
                    textBox1.Text += "\r\nHWND = " + eventArgs_I.Message.HWnd.ToString();

                    if (m_pressure > 1)
                    {
                        if (drawing)
                        {
                            pa.DrawTo(pt.X, pt.Y, (int)m_pressure);
                        }
                        else
                        {
                            drawing = true;
                            pa.startDrawing(pt.X, pt.Y, (int)m_pressure);
                        }
                        //    mouse_event(MOUSEEVENTF_LEFTDOWN, (uint)Cursor.Position.X, (uint)Cursor.Position.Y, 0, 0);
                    }
                    else
                    {
                        if (drawing)
                        {
                            drawing = false;
                            pa.endDrawing();
                        }
                        //  mouse_event(MOUSEEVENTF_LEFTUP, (uint)Cursor.Position.X, (uint)Cursor.Position.Y, 0, 0);
                    }
                    //textBox1.Text = "Data: X=" + lastX.ToString() + "; Y=" + lastY.ToString() + "; Z=" + lastZ.ToString() + "; P=" + m_pressure.ToString()+"\r\n";
                    //textBox1.SelectionStart = textBox1.Text.Length;
                    //textBox1.ScrollToCaret();
                    //m_pkTime = pkt.pkTime;
                }
            }
        }
コード例 #4
0
        //---------------------------------------------------------------------
        // Tablet event handler
        //---------------------------------------------------------------------
        private void TabletEventHandler(object sender, MessageReceivedEventArgs args)
        {
            uint         pktID = (uint)args.Message.WParam;
            WintabPacket pkt   = data.GetDataPacket(pktID);

            if (pkt.pkNormalPressure.pkAbsoluteNormalPressure > 0)
            {
                tabletPressure = (float)pkt.pkNormalPressure.pkAbsoluteNormalPressure / 1024.0f;
            }
        }
        //---------------------------------------------------------------------
        // Tablet event handler
        //---------------------------------------------------------------------
        private void TabletEventHandler(object sender, MessageReceivedEventArgs args)
        {
            uint         pktID = (uint)args.Message.WParam;
            WintabPacket pkt   = data.GetDataPacket(pktID);

            if (pkt.pkNormalPressure.pkAbsoluteNormalPressure > 0)
            {
                if (lastPressure > 0)
                {
                    m_session.GuiInput_TabletMove(sender, pkt);
                }
                else
                {
                    m_session.GuiInput_TabletDown(sender, pkt);
                }
            }
            else if (pkt.pkNormalPressure.pkAbsoluteNormalPressure == 0 && lastPressure > 0)
            {
                m_session.GuiInput_TabletUp(sender, pkt);
            }
        }
コード例 #6
0
        /// <summary>
        /// Fires all callbacks attached to the TabletDataReceived event each step that data is received.
        /// </summary>
        private void UpdateTabletData(object emptySender, MessageReceivedEventArgs message)
        {
            if (winTabData == null)
            {
                return;
            }

            try
            {
                uint         packetId = (uint)message.Message.WParam;
                WintabPacket packet   = winTabData.GetDataPacket(message.Message.LParam, packetId);

                if (packet.pkContext.IsValid)
                {
                    TabletDataReceived?.Invoke(packet);
                }
            }
            catch
            {
                // Ignore, logging would be too frequent.
            }
        }
コード例 #7
0
        private void HandlePenMessage(Object sender_I, MessageReceivedEventArgs eventArgs_I)
        {
            if (m_wtData == null)
            {
                return;
            }

            try
            {
                uint         pktID = (uint)eventArgs_I.Message.WParam;
                WintabPacket pkt   = m_wtData.GetDataPacket(pktID);
                if (pkt.pkContext != 0)
                {
                    // Normalize data between 0 and 40
                    float normalizedValue = (40f - 0f) / ((float)CWintabInfo.GetMaxPressure() - 0f) * ((float)pkt.pkNormalPressure.pkAbsoluteNormalPressure - (float)CWintabInfo.GetMaxPressure()) + 40f;
                    TabletPressure = normalizedValue;
                }
            }
            catch (Exception ex)
            {
                Log.Fatal(ex.Message);
            }
        }
コード例 #8
0
ファイル: TestForm.cs プロジェクト: vvvv/WintabDN
        ///////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Called when Wintab WT_PACKET events are received.
        /// </summary>
        /// <param name="sender_I">The EventMessage object sending the report.</param>
        /// <param name="eventArgs_I">eventArgs_I.Message.WParam contains ID of packet containing the data.</param>
        public void MyWTPacketEventHandler(Object sender_I, MessageReceivedEventArgs eventArgs_I)
        {
            //System.Diagnostics.Debug.WriteLine("Received WT_PACKET event");
            if (m_wtData == null)
            {
                return;
            }

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

                    if (pkt.pkContext.IsValid)
                    {
                        m_pkX      = pkt.pkX;
                        m_pkY      = pkt.pkY;
                        m_pressure = pkt.pkNormalPressure;

                        Trace.WriteLine("SCREEN: pkX: " + pkt.pkX + ", pkY:" + pkt.pkY + ", pressure: " + pkt.pkNormalPressure);

                        m_pkTime = pkt.pkTime;

                        if (m_graphics == null)
                        {
                            // display data mode
                            TraceMsg("Received WT_PACKET event[" + pktID + "]: X/Y/P = " +
                                     pkt.pkX + " / " + pkt.pkY + " / " + pkt.pkNormalPressure + "\n");
                        }
                        else
                        {
                            // scribble mode
                            int clientWidth  = scribblePanel.Width;
                            int clientHeight = scribblePanel.Height;

                            // m_pkX and m_pkY are in screen (system) coordinates.

                            Point clientPoint = scribblePanel.PointToClient(new Point(m_pkX, m_pkY));
                            Trace.WriteLine("CLIENT:   X: " + clientPoint.X + ", Y:" + clientPoint.Y);

                            if (m_lastPoint.Equals(Point.Empty))
                            {
                                m_lastPoint  = clientPoint;
                                m_pkTimeLast = m_pkTime;
                            }

                            m_pen.Width = (float)(m_pressure / 200);

                            if (m_pressure > 0)
                            {
                                if (m_pkTime - m_pkTimeLast < 5)
                                {
                                    m_graphics.DrawRectangle(m_pen, clientPoint.X, clientPoint.Y, 1, 1);
                                }
                                else
                                {
                                    m_graphics.DrawLine(m_pen, clientPoint, m_lastPoint);
                                }
                            }

                            m_lastPoint  = clientPoint;
                            m_pkTimeLast = m_pkTime;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("FAILED to get packet data: " + ex.ToString());
            }
        }
コード例 #9
0
        public void MyWTPacketEventHandler(Object sender_I, MessageReceivedEventArgs eventArgs_I)
        {
            //System.Diagnostics.Debug.WriteLine("Received WT_PACKET event");
            if (m_wtData == null)
            {
                return;
            }

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

                    if (pkt.pkContext != 0)
                    {
                        m_pkX          = pkt.pkX;
                        m_pkY          = pkt.pkY;
                        m_pkTime       = pkt.PKrealTime;
                        m_pressure     = pkt.pkNormalPressure;
                        m_serialNumber = pkt.pkSerialNumber;


                        //TODO: time and pressure are UINT- think about how to not convert that - also something about minuses
                        int       col;
                        ArrayList dataMat = new ArrayList();
                        dataMat.Add(m_serialNumber);
                        dataMat.Add(m_pkX);
                        dataMat.Add(m_pkY);
                        dataMat.Add(m_pressure);
                        dataMat.Add(m_pkTime.ToString());// - m_pkTimeLast);
                        dataMat.Add(called);
                        //dataMat.Add(pkt.pkStatus);
                        //long[] dataMat = new long[] { curpoint, m_pkX, m_pkY, m_pressure, m_pkTime };

                        //TODO: update the trial numbers
                        //int trialNum = 1;
                        string dataFileName = Path.Combine(DataFolder, DataFileBase) + "_Trial_" + Convert.ToString(numOfTrial) + ".txt";

                        //long ticks = DateTime.UtcNow.Ticks - DateTime.Parse("01/01/1970 00:00:00").Ticks;
                        //ticks /= 10000000; //Convert windows ticks to seconds
                        //String timeStamp = ticks.ToString();

                        using (StreamWriter dataFile =
                                   new StreamWriter(dataFileName, true))
                        {
                            for (col = 0; col < 6; ++col)
                            {
                                dataFile.Write("{0:d4}\t", dataMat[col]);
                            }
                            dataFile.WriteLine();
                        }

                        m_pkTimeLast = m_pkTime;

                        // enable scribbling on screen
                        //with packets one at a time
                        if (m_graphics == null)
                        {
                        }
                        else
                        {
                            // scribble mode
                            int clientWidth  = scribblePanel.Width;
                            int clientHeight = scribblePanel.Height;

                            // m_pkX and m_pkY are in screen (system) coordinates.

                            Point clientPoint = scribblePanel.PointToClient(new Point((int)m_pkX, (int)m_pkY));
                            //Trace.WriteLine("CLIENT:   X: " + clientPoint.X + ", Y:" + clientPoint.Y);

                            if (m_lastPoint.Equals(Point.Empty))
                            {
                                m_lastPoint  = clientPoint;
                                m_pkTimeLast = m_pkTime;
                            }

                            m_pen.Width = (float)(m_pressure / 200);

                            if (m_pressure > 0)
                            {
                                m_graphics.DrawLine(m_pen, clientPoint, m_lastPoint);
                            }

                            m_lastPoint = clientPoint;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("FAILED to get packet data: " + ex.ToString());
            }
        }
コード例 #10
0
ファイル: TabletLaunch.cs プロジェクト: niallb/DTTPresent
        public void MyWTPacketEventHandler(Object sender_I, MessageReceivedEventArgs eventArgs_I)
        {
            try
            {
                if ((m_maxPkts == 1) && (m_wtData != null))
                {
                    uint pktID = (uint)eventArgs_I.Message.WParam;
                    //WintabPacketExt pkt2 = m_wtData.GetDataPacketExt((uint)eventArgs_I.Message.LParam, pktID);
                    WintabPacket pkt = m_wtData.GetDataPacket((uint)eventArgs_I.Message.LParam, pktID);
                    //WintabPacket pkt = m_wtData.GetDataPacket(pktID);
                    if (textBox1 != null)
                    {
                        textBox1.Text = "Bamboo point " + pkt.pkX.ToString() + ", " + pkt.pkY.ToString() + ", Z:" + pkt.pkZ.ToString() + ", p:" + pkt.pkNormalPressure.ToString();

                        textBox1.Text += "\r\nMouse: " + Cursor.Position.X.ToString() + ", " + Cursor.Position.Y.ToString();
                    }
                    if ((pkt.pkContext != 0) && ((pkt.pkX != lastX) || (pkt.pkY != lastY)))
                    {
                        capturing = pkt.pkZ < 512;


                        lastX = pkt.pkX;
                        lastY = pkt.pkY;
                        lastZ = pkt.pkZ;

                        // New version to use cursor to correct offset
                        PointF pt;
                        if (zpNeedsInit && capturing)
                        {
                            /*PointF detected = new PointF(pkt.pkX / MultFactor, pkt.pkY / MultFactor);
                             * pt = pa.PointToClient(new Point(Cursor.Position.X, Cursor.Position.Y));
                             * zp2 = new PointF(pt.X - detected.X, pt.Y - detected.Y);*/
                            zp2         = pa.PointToClient(new Point(0, 0));
                            pt          = new PointF(pkt.pkX / MultFactor + zp2.X, pkt.pkY / MultFactor + zp2.Y);
                            zpNeedsInit = false;
                        }
                        else
                        {
                            pt = new PointF(pkt.pkX / MultFactor + zp2.X, pkt.pkY / MultFactor + zp2.Y);
                        }//*/

                        //Cursor.Position = new Point(lastX/10, lastY/10);
                        //Point zp = pa.PointToClient(new Point(0,0));
                        //PointF pt = Cursor.Position.X, (uint)Cursor.Position.Y

                        // The version that works well at home...
                        //   PointF pt = new PointF(pkt.pkX / MultFactor + zp.X, pkt.pkY / MultFactor + zp.Y);

                        // Point pt = pa.PointToClient(new Point(lastX / 10, lastY / 10));
                        //Using mouse co-ords
                        //PointF pt = pa.PointToClient(new Point(Cursor.Position.X, Cursor.Position.Y));
                        pa.showPointer((int)pt.X, (int)pt.Y);
                        uint m_pressure = pkt.pkNormalPressure;

                        if (textBox1 != null)
                        {
                            textBox1.Text += "\r\n" + pt.X.ToString() + "," + pt.Y.ToString();
                            textBox1.Text += "\r\nHWND = " + eventArgs_I.Message.HWnd.ToString();
                            textBox1.Text += "\r\nTime = " + pkt.pkTime.ToString();
                        }
                        if (m_pressure > 1)
                        {
                            if (pa.drawing)
                            {
                                pa.DrawTo(pt.X, pt.Y, (int)m_pressure);
                                //pa.DrawTo((uint)Cursor.Position.X, (uint)Cursor.Position.Y, (int)m_pressure);
                            }
                            else
                            {
                                pa.startDrawing(pt.X, pt.Y, (int)m_pressure);
                                //pa.startDrawing((uint)Cursor.Position.X, (uint)Cursor.Position.Y, (int)m_pressure);
                            }
                            //    mouse_event(MOUSEEVENTF_LEFTDOWN, (uint)Cursor.Position.X, (uint)Cursor.Position.Y, 0, 0);
                        }
                        else
                        {
                            if (pa.drawing)
                            {
                                pa.endDrawing();
                            }
                            //  mouse_event(MOUSEEVENTF_LEFTUP, (uint)Cursor.Position.X, (uint)Cursor.Position.Y, 0, 0);
                        }
                        //textBox1.Text = "Data: X=" + lastX.ToString() + "; Y=" + lastY.ToString() + "; Z=" + lastZ.ToString() + "; P=" + m_pressure.ToString()+"\r\n";
                        //textBox1.SelectionStart = textBox1.Text.Length;
                        //textBox1.ScrollToCaret();
                        //m_pkTime = pkt.pkTime;
                    }
                }
            }
            catch (Exception ex)
            {
                // MessageBox.Show("Lost tablet context.");
            }
        }
コード例 #11
0
        ///////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Called when Wintab WT_PACKET events are received.
        /// </summary>
        /// <param name="sender_I">The EventMessage object sending the report.</param>
        /// <param name="eventArgs_I">eventArgs_I.Message.WParam contains ID of packet containing the data.</param>

        public void MyWTPacketEventHandler(Object sender_I, MessageReceivedEventArgs eventArgs_I)
        {
            if (m_wtData == null)
            {
                return;
            }

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

                    if (pkt.pkContext != 0)
                    {
                        m_pkX      = pkt.pkX;
                        m_pkY      = pkt.pkY;
                        m_pressure = pkt.pkNormalPressure;

                        //Trace.WriteLine("SCREEN: pkX: " + pkt.pkX + ", pkY:" + pkt.pkY + ", pressure: " + pkt.pkNormalPressure);

                        m_pkTime = pkt.pkTime;

                        if (m_graphics == null)
                        {
                            // display data mode
                            TraceMsg("Received WT_PACKET event[" + pktID + "]: X/Y/P = " +
                                     pkt.pkX + " / " + pkt.pkY + " / " + pkt.pkNormalPressure + "\n");
                        }
                        else
                        {
                            Point clientPoint = testSplitContainer.Panel2.PointToClient(new Point(m_pkX, m_pkY));
                            //Trace.WriteLine("CLIENT:   X: " + clientPoint.X + ", Y:" + clientPoint.Y);

                            if (m_lastPoint.Equals(Point.Empty))
                            {
                                m_lastPoint  = clientPoint;
                                m_pkTimeLast = m_pkTime;
                            }

                            float width  = (float)m_pressure / (float)m_maxPressure;
                            int   penIdx = (int)(width * 10) - 1; if (penIdx < 0)
                            {
                                penIdx = 0;
                            }
                            //Debug.WriteLine($"pressure: {m_pressure}; width:{m_pen.Width}; penIdx: {penIdx}");

                            if (m_pressure > 0)
                            {
                                m_graphics.DrawLine(m_drawPens[penIdx], clientPoint, m_lastPoint);
                            }

                            m_lastPoint  = clientPoint;
                            m_pkTimeLast = m_pkTime;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("FAILED to get packet data: " + ex.ToString());
            }
        }
コード例 #12
0
ファイル: TestForm.cs プロジェクト: SHAREVIEW/624-Final
        ///////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Called when Wintab WT_PACKET events are received.
        /// </summary>
        /// <param name="sender_I">The EventMessage object sending the report.</param>
        /// <param name="eventArgs_I">eventArgs_I.Message.WParam contains ID of packet containing the data.</param>
        public void MyWTPacketEventHandler(Object sender_I, MessageReceivedEventArgs eventArgs_I)
        {
            //System.Diagnostics.Debug.WriteLine("Received WT_PACKET event");
            if (m_wtData == null)
            {
                return;
            }

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

                    if (pkt.pkContext != 0)
                    {
                        m_pkX      = pkt.pkX;
                        m_pkY      = pkt.pkY;
                        m_pressure = pkt.pkNormalPressure;

                        //Trace.WriteLine("SCREEN: pkX: " + pkt.pkX + ", pkY:" + pkt.pkY + ", pressure: " + pkt.pkNormalPressure);

                        m_pkTime = pkt.pkTime;
                        //Console.WriteLine("time: " + m_pkTime);
                        if (m_graphics == null)
                        {
                            // display data mode
                            TraceMsg("Received WT_PACKET event[" + pktID + "]: X/Y/P = " +
                                     pkt.pkX + " / " + pkt.pkY + " / " + pkt.pkNormalPressure + "\n");
                        }
                        else
                        {
                            // scribble mode
                            int clientWidth  = scribblePanel.Width;
                            int clientHeight = scribblePanel.Height;

                            // m_pkX and m_pkY are in screen (system) coordinates.

                            /*
                             * //Converts the program to use relative coordinates.
                             * System.Drawing.Rectangle workingRectangle = Screen.PrimaryScreen.WorkingArea;
                             *
                             * double percentX = m_pkX / (double)workingRectangle.Width;
                             * double percentY = m_pkY / (double)workingRectangle.Height;
                             *
                             * int newX = (int)(percentX * clientWidth);
                             * int newY = (int)(percentY * clientHeight);
                             *
                             * Point clientPoint = new Point(newX, newY);
                             */


                            Point clientPoint = scribblePanel.PointToClient(new Point(m_pkX, m_pkY));

                            if (clientPoint.X < 0)
                            {
                                return;
                            }
                            if (clientPoint.Y < 0)
                            {
                                return;
                            }

                            if (clientPoint.X > scribblePanel.Width)
                            {
                                return;
                            }
                            if (clientPoint.Y > scribblePanel.Height)
                            {
                                return;
                            }

                            //Trace.WriteLine("CLIENT:   X: " + clientPoint.X + ", Y:" + clientPoint.Y);

                            if (m_lastPoint.Equals(Point.Empty))
                            {
                                m_lastPoint  = clientPoint;
                                m_pkTimeLast = m_pkTime;
                            }

                            //m_pen.Width = (float)(m_pressure / 200);
                            m_pen.Width = (float)3.0;

                            if (m_pressure > 0 && screenEnabled)
                            {
                                if (!timeoutTimer.Enabled && timeoutEnabled && currentSeq != 0)
                                {
                                    timeoutTimer.Start();
                                }
                                if (compareTimer.Enabled)
                                {
                                    compareTimer.Stop();
                                }

                                uint unixTimestamp = (uint)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds;

                                if (m_pkTime - m_pkTimeLast > 50)
                                {
                                    Console.WriteLine("new stroke");
                                    m_graphics.DrawRectangle(m_pen, clientPoint.X, clientPoint.Y, 1, 1);
                                    strokeNum++;
                                    DrawPoint dp = new DrawPoint(clientPoint.X, clientPoint.Y, strokeNum, unixTimestamp, m_pressure);
                                    TR.AddStartPoint(dp);
                                    m_lastPoint  = clientPoint;
                                    m_pkTimeLast = m_pkTime;
                                }
                                else
                                {
                                    m_graphics.DrawLine(m_pen, clientPoint, m_lastPoint);
                                    DrawPoint dp = new DrawPoint(clientPoint.X, clientPoint.Y, strokeNum, unixTimestamp, m_pressure);
                                    TR.AddPoint(dp);
                                    compareTimer.Start();
                                    m_lastPoint  = clientPoint;
                                    m_pkTimeLast = m_pkTime;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("FAILED to get packet data: " + ex.ToString());
            }
        }