Example #1
0
        /// <summary>
        /// Berechnet die Summe der Entfernungen der Einzelsegmente eines TuioCursors.
        /// In anderen Worten, die bisher zurückgelegte Entfernung einer Berührung
        /// </summary>
        /// <param name="self">Der TuioCursor</param>
        /// <returns>Die berechnete Entfernung, in Pixel</returns>
        public static float getTotalDistanceInPixel(this TuioCursor self, GestureManager manager)
        {
            float     dist = 0;
            TuioPoint last = null;

            foreach (TuioPoint tp in self.getPath())
            {
                if (last != null)
                {
                    dist += tp.GetPixelDistance(last, manager);
                }
                last = tp;
            }
            return(dist);
        }
Example #2
0
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values == null || values.Length != 3)
            {
                return(new Thickness(0, 0, 0, 0));
            }
            if (values[0] == DependencyProperty.UnsetValue)
            {
                return(new Thickness(0, 0, 0, 0));
            }

            List <TuioPoint> path       = (List <TuioPoint>)values[0];
            TuioPoint        currentPos = path.Last();

            return(new Thickness(currentPos.getScreenX((int)Surface.Instance.ActualWidth), currentPos.getScreenY((int)Surface.Instance.ActualHeight), 0, 0));
        }
Example #3
0
        /// <summary>
        /// Berechnet die Summe der Entfernungen der Einzelsegmente eines TuioCursors.
        /// In anderen Worten, die bisher zurückgelegte Entfernung einer Berührung
        /// </summary>
        /// <param name="self">Der TuioCursor</param>
        /// <returns>Die berechnete Entfernung, in Relation zur Bildschirmgröße (0 bis 1)</returns>
        public static float getTotalDistance(this TuioCursor self)
        {
            float            dist      = 0;
            TuioPoint        last      = null;
            List <TuioPoint> allPoints = self.getPath();

            for (int i = 0; i < allPoints.Count; i++)
            {
                TuioPoint tp = allPoints[i];
                if (last != null)
                {
                    dist += tp.getDistance(last);
                }
                last = tp;
            }
            return(dist);
        }
Example #4
0
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values == null || values.Length != 2)
            {
                return(0);
            }
            if (values[0] == DependencyProperty.UnsetValue)
            {
                return(0);
            }

            List <TuioPoint> path       = (List <TuioPoint>)values[0];
            TuioPoint        currentPos = path.Last();

            double posX = currentPos.getScreenX((int)Surface.Instance.ActualWidth);
            double posY = currentPos.getScreenY((int)Surface.Instance.ActualHeight);

            return((String)values[1] == "X" ? posX : posY);
        }
Example #5
0
    protected override void OnPaintBackground(PaintEventArgs pevent)
    {
        // Getting the graphics object
        Graphics g = pevent.Graphics;

        g.FillRectangle(whiteBrush, new Rectangle(0, 0, width, height));

        // draw the cursor path
        if (cursorList.Count > 0)
        {
            lock (cursorSync) {
                foreach (TuioCursor tcur in cursorList.Values)
                {
                    List <TuioPoint> path          = tcur.Path;
                    TuioPoint        current_point = path[0];

                    for (int i = 0; i < path.Count; i++)
                    {
                        TuioPoint next_point = path[i];
                        g.DrawLine(fingerPen, current_point.getScreenX(width), current_point.getScreenY(height), next_point.getScreenX(width), next_point.getScreenY(height));
                        current_point = next_point;
                    }
                    g.FillEllipse(grayBrush, current_point.getScreenX(width) - height / 100, current_point.getScreenY(height) - height / 100, height / 50, height / 50);
                    Font font = new Font("Arial", 10.0f);
                    g.DrawString(tcur.CursorID + "", font, blackBrush, new PointF(tcur.getScreenX(width) - 10, tcur.getScreenY(height) - 10));
                }
            }
        }

        // draw the objects
        if (objectList.Count > 0)
        {
            lock (objectSync) {
                foreach (TuioDemoObject tobject in objectList.Values)
                {
                    tobject.paint(g);
                }
            }
        }
    }
Example #6
0
        public void OnTimerEvent(object source, EventArgs e)
        {
            // Console.WriteLine(System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName) + "\\" + service_name);
            VisualFeedback.Children.Clear();
            if (cursorList.Count > 0)
            {
                lock (cursorSync)
                {
                    foreach (TuioCursor tcur in cursorList.Values)
                    {
                        List <TuioPoint> path          = tcur.getPath();
                        TuioPoint        current_point = path[0];

                        for (int i = 0; i < path.Count; i++)
                        {
                            TuioPoint next_point = path[i];
                            current_point = next_point;
                        }
                        double x;
                        double y;

                        if (invert_horizontal.IsChecked == true)
                        {
                            x = VisualFeedback.Width - (current_point.getScreenX((int)VisualFeedback.Width) - VisualFeedback.Height / 100);
                        }
                        else
                        {
                            x = current_point.getScreenX((int)VisualFeedback.Width) - VisualFeedback.Height / 100;
                        }
                        if (invert_verticle.IsChecked == true)
                        {
                            y = VisualFeedback.Height - (current_point.getScreenY((int)VisualFeedback.Height) - VisualFeedback.Height / 100);
                        }
                        else
                        {
                            y = current_point.getScreenY((int)VisualFeedback.Height) - VisualFeedback.Height / 100;
                        }
                        try
                        {
                            if (xrangemin != 0 || xrangemax != 1)
                            {
                                double xrange = xrangemax - xrangemin;
                                x = xrangemin + (xrange * x);
                            }
                            if (yrangemin != 0 || yrangemax != 1)
                            {
                                double yrange = yrangemax - yrangemin;
                                y = yrangemin + (yrange * y);
                            }
                            if (Convert.ToInt32(x_offset.Text) != 0)
                            {
                                x = x + (int)VisualFeedback.Width * Convert.ToInt32(x_offset.Text) / 100;
                            }
                            if (Convert.ToInt32(y_offset.Text) != 0)
                            {
                                y = y + (int)VisualFeedback.Height * Convert.ToInt32(y_offset.Text) / 100;
                            }
                        }
                        catch
                        {
                        }
                        if (swap_xy.IsChecked == true)
                        {
                            double tmp = y;
                            y = x;
                            x = tmp;
                        }


                        Ellipse ellipse = new Ellipse
                        {
                            Fill    = new SolidColorBrush(Colors.CadetBlue),
                            Width   = 15,
                            Height  = 15,
                            Opacity = 1,
                            Margin  = new Thickness(x, y, 0, 0)
                        };


                        VisualFeedback.Children.Add(ellipse);

                        //Font font = new Font("Arial", 10.0f);
                        //      Sensor1.DrawString(tcur.getCursorID() + "", font, blackBrush, new PointF(tcur.getScreenX(width) - 10, tcur.getScreenY(height) - 10));
                    }
                }
            }
            else
            {
                l2         = new System.Windows.Controls.Label();
                l2.Content = "Touch Your Sensor";
                VisualFeedback.Children.Add(l2);
                Canvas.SetLeft(l2, 35);
                Canvas.SetTop(l2, 130);
            }
        }
Example #7
0
    protected override void OnPaintBackground(PaintEventArgs pevent)
    {
        // Getting the graphics object
        Graphics g = pevent.Graphics;

        g.FillRectangle(bgrBrush, new Rectangle(0, 0, width, height));

        // draw the cursor path
        if (cursorList.Count > 0)
        {
            lock (cursorList) {
                foreach (TuioCursor tcur in cursorList.Values)
                {
                    List <TuioPoint> path          = tcur.Path;
                    TuioPoint        current_point = path[0];

                    for (int i = 0; i < path.Count; i++)
                    {
                        TuioPoint next_point = path[i];
                        g.DrawLine(curPen, current_point.getScreenX(width), current_point.getScreenY(height), next_point.getScreenX(width), next_point.getScreenY(height));
                        current_point = next_point;
                    }
                    g.FillEllipse(curBrush, current_point.getScreenX(width) - height / 100, current_point.getScreenY(height) - height / 100, height / 50, height / 50);
                    g.DrawString(tcur.CursorID + "", font, fntBrush, new PointF(tcur.getScreenX(width) - 10, tcur.getScreenY(height) - 10));
                }
            }
        }

        // draw the objects
        if (objectList.Count > 0)
        {
            lock (objectList) {
                foreach (TuioObject tobj in objectList.Values)
                {
                    int ox   = tobj.getScreenX(width);
                    int oy   = tobj.getScreenY(height);
                    int size = height / 10;

                    g.TranslateTransform(ox, oy);
                    g.RotateTransform((float)(tobj.Angle / Math.PI * 180.0f));
                    g.TranslateTransform(-ox, -oy);

                    g.FillRectangle(objBrush, new Rectangle(ox - size / 2, oy - size / 2, size, size));

                    g.TranslateTransform(ox, oy);
                    g.RotateTransform(-1 * (float)(tobj.Angle / Math.PI * 180.0f));
                    g.TranslateTransform(-ox, -oy);

                    g.DrawString(tobj.SymbolID + "", font, fntBrush, new PointF(ox - 10, oy - 10));
                }
            }
        }

        // draw the blobs
        if (blobList.Count > 0)
        {
            lock (blobList) {
                foreach (TuioBlob tblb in blobList.Values)
                {
                    int   bx = tblb.getScreenX(width);
                    int   by = tblb.getScreenY(height);
                    float bw = tblb.Width * width;
                    float bh = tblb.Height * height;

                    g.TranslateTransform(bx, by);
                    g.RotateTransform((float)(tblb.Angle / Math.PI * 180.0f));
                    g.TranslateTransform(-bx, -by);

                    g.FillEllipse(blbBrush, bx - bw / 2, by - bh / 2, bw, bh);

                    g.TranslateTransform(bx, by);
                    g.RotateTransform(-1 * (float)(tblb.Angle / Math.PI * 180.0f));
                    g.TranslateTransform(-bx, -by);

                    g.DrawString(tblb.BlobID + "", font, fntBrush, new PointF(bx, by));
                }
            }
        }
    }
Example #8
0
 public static Vector2 GetScreenPositionFromRelativePosition(TuioPoint tuioPoint)
 {
     return(new Vector2(tuioPoint.getScreenX(Instance.m_tuioSettings.TargetScreenWidth), Instance.m_tuioSettings.TargetScreenHeight - tuioPoint.getScreenY(Instance.m_tuioSettings.TargetScreenHeight)));
 }