Esempio n. 1
0
        public void StylusDown(RealTimeStylus sender, StylusDownData data)
        {
            Tablet tablet = sender.GetTabletFromTabletContextId(data.Stylus.TabletContextId);
            TRPoint point = new TRPoint();
            point.x = data[0]; point.y = data[1];
            // Since the packet data is in Ink Space coordinates, we need to convert to Pixels...
            point.x = (int)Math.Round((float)point.x * (float)graphics.DpiX / 2540.0F);
            point.y = (int)Math.Round((float)point.y * (float)graphics.DpiY / 2540.0F);
            switch (tablet.DeviceKind)
            {
                case TabletDeviceKind.Mouse:

                case TabletDeviceKind.Pen:
                    if (TangibleRecognizerTab.SelectedTab.Equals(LearningPhaseTab))
                    {
                        if (Math.Abs(point.x - leftLineX) <= 10)
                        {
                            prevPoint = point;
                        }
                        else if (Math.Abs(point.x - rightLineX) <= 10)
                        {
                            prevPoint = point;
                        }
                        else if (Math.Abs(point.y - topLineY) <= 10)
                        {
                            prevPoint = point;
                        }
                        else if (Math.Abs(point.y - bottomLineY) <= 10)
                        {
                            prevPoint = point;
                        }
                    }
                    break;
                case TabletDeviceKind.Touch:
                    TRPoint touchPoint = new TRPoint();
                    touchPoint.x = data[0];
                    touchPoint.y = data[1];

                    touchesOnScreen.Add(data.Stylus.Id, touchPoint);
                    tangiblePattern = (Hashtable) touchesOnScreen.Clone();
                    label1.Text = tangiblePattern.Count.ToString();
                    if (TangibleRecognizerTab.SelectedTab.Equals(DrawingTab))
                    {
                        recognizer.touchBegan(data.Stylus.Id, touchPoint);
                        VectorInt recognizedIndex = recognizer.getRecognizedObject();
                        if (recognizedIndex.Count > 0)
                        {
                            drawRecognizedObject(recognizedIndex);
                        }

                    }
                    break;
            }
        }
Esempio n. 2
0
        public void StylusUp(RealTimeStylus sender, StylusUpData data)
        {
            if(touchesOnScreen.ContainsKey(data.Stylus.Id)){
                touchesOnScreen.Remove(data.Stylus.Id);
            }
            label1.Text = "u " + tangiblePattern.Count.ToString();
            Tablet tablet = sender.GetTabletFromTabletContextId(data.Stylus.TabletContextId);
            switch (tablet.DeviceKind)
            {
                case TabletDeviceKind.Mouse:

                case TabletDeviceKind.Pen:
                    if (prevPoint == null)
                        return;
                    prevPoint.x = 0;
                    prevPoint.y = 0;
                    break;
                case TabletDeviceKind.Touch:
                    TRPoint touchPoint = new TRPoint();
                    touchPoint.x = data[0];
                    touchPoint.y = data[1];

                    if (TangibleRecognizerTab.SelectedTab.Equals(DrawingTab))
                    {
                        recognizer.touchEnded(data.Stylus.Id, touchPoint);
                    }

                    break;
            }
               /* ArrayList collectedPackets = (ArrayList)myPackets[data.Stylus.Id];
            myPackets.Remove(data.Stylus.Id);

            collectedPackets.AddRange(data.GetData());

            int[] packets = (int[])(collectedPackets.ToArray(typeof(int)));
            TabletPropertyDescriptionCollection tabletProperties =
                myRealTimeStylus.GetTabletPropertyDescriptionCollection(data.Stylus.TabletContextId);
            Stroke stroke = myInk.CreateStroke(packets, tabletProperties);
            if (stroke != null)
            {
                stroke.DrawingAttributes.Color = myDynamicRenderer.DrawingAttributes.Color;
                stroke.DrawingAttributes.Width = myDynamicRenderer.DrawingAttributes.Width;
            }*/
        }
Esempio n. 3
0
        public void Packets(RealTimeStylus sender, PacketsData data)
        {
            //((ArrayList)(myPackets[data.Stylus.Id])).AddRange(data.GetData());
            Tablet tablet = sender.GetTabletFromTabletContextId(data.Stylus.TabletContextId);
            if (previousnumber == data.Stylus.Id)
            {
               // Console.WriteLine(data.Stylus.Id);
            }
            previousnumber = data.Stylus.Id;
            switch (tablet.DeviceKind)
            {
                case TabletDeviceKind.Mouse:

                case TabletDeviceKind.Pen:
                    TRPoint point = new TRPoint();
                    point.x = data[0]; point.y = data[1];
                    // Since the packet data is in Ink Space coordinates, we need to convert to Pixels...
                    point.x = (int)Math.Round((float)point.x * (float)graphics.DpiX / 2540.0F);
                    point.y = (int)Math.Round((float)point.y * (float)graphics.DpiY / 2540.0F);
                    if(TangibleRecognizerTab.SelectedTab.Equals(LearningPhaseTab))
                    {
                        if (prevPoint == null)
                            return;
                        if (Math.Abs(leftLineX - prevPoint.x) <= 10)
                        {
                            leftLineX = (int)point.x;
                            prevPoint = point;
                            this.glLearningView.Invalidate();
                        }else if (Math.Abs(rightLineX - prevPoint.x) <= 10)
                        {
                            rightLineX = (int)point.x;
                            prevPoint = point;
                            this.glLearningView.Invalidate();
                        }
                        else if (Math.Abs(topLineY - prevPoint.y) <= 10)
                        {
                            topLineY = (int)point.y;
                            prevPoint = point;
                            this.glLearningView.Invalidate();
                        }
                        else if (Math.Abs(bottomLineY - prevPoint.y) <= 10)
                        {
                            bottomLineY = (int)point.y;
                            prevPoint = point;
                            this.glLearningView.Invalidate();
                        }
                    }
                    break;
                case TabletDeviceKind.Touch:
                    TRPoint touchPoint = new TRPoint();
                    touchPoint.x = data[0];
                    touchPoint.y = data[1];

                    if (TangibleRecognizerTab.SelectedTab.Equals(DrawingTab))
                    {
                        if (previousnumber == data.Stylus.Id)
                        {
                   //         return;
                        }
                        counter++;
                        if (counter % 5 == 0)
                        {
                            //Console.WriteLine(touchPoint.x + ":" + touchPoint.y);
                            recognizer.touchMoved(data.Stylus.Id, touchPoint);
                            VectorInt recognizedIndex = recognizer.getRecognizedObject();
                            if (recognizedIndex.Count > 0)
                            {
                                drawRecognizedObject(recognizedIndex);

                            }
                        }
                    }
                    break;
            }
               /* Tablet t = sender.GetTabletFromTabletContextId(data.Stylus.TabletContextId);
            if (sender.GetTabletFromTabletContextId(data.Stylus.TabletContextId).DeviceKind == TabletDeviceKind.Mouse)
            {
                Point point = new Point(data[0], data[1]);
                graphics.DrawEllipse(Pens.Red, point.X / 26, point.Y / 28, 10, 10);

            }*/
        }