Esempio n. 1
0
        public void Wlacz(TRYB_KONTROLI_RUCHOW t, bool wlacz_kinect, MAGICZNE_ZAKLECIE magia)
        {
            this.tryb         = t;
            this.wlacz_kinect = wlacz_kinect;

            this.magia = magia;
            if (magia != null)
            {
                magia.efekt_zaklecia(canvas1);
            }

            muz = new MUZYKA();
            muz.lista_odtwarzania(mediaElement1);

            Point[] p = { new Point(0, 0) };
            tryb.analiza_cwiczenia(progressBar2, p);
            czas_calkowity = tryb.czas_treningu;

            czas_t = new Thread(czas_treningu);
            czas_t.Start();

            media_active = true;
            watek_czas   = true;
        }
Esempio n. 2
0
        private void DrawPoint(Skeleton szkielet)
        {
            kinect_active = true;

            using (DrawingContext dc = this.drawingGroup.Open())
            {
                // Draw a transparent background to set the render size
                dc.DrawRectangle(Brushes.Black, null, new Rect(0.0, 0.0, RenderWidth, RenderHeight));

                this.DrawBone(szkielet, dc, JointType.ShoulderCenter, JointType.ElbowLeft);
                this.DrawBone(szkielet, dc, JointType.ShoulderCenter, JointType.ElbowRight);
                this.DrawBone(szkielet, dc, JointType.ElbowLeft, JointType.HandLeft);
                this.DrawBone(szkielet, dc, JointType.ElbowRight, JointType.HandRight);
                this.DrawBone(szkielet, dc, JointType.HipCenter, JointType.FootLeft);
                this.DrawBone(szkielet, dc, JointType.HipCenter, JointType.FootRight);
                this.DrawBone(szkielet, dc, JointType.ShoulderCenter, JointType.Head);
                this.DrawBone(szkielet, dc, JointType.ShoulderCenter, JointType.HipCenter);

                dc.DrawEllipse(Brushes.Red, null, this.SkeletonPointToScreen(szkielet.Joints[JointType.Head].Position), JointThickness, JointThickness);

                dc.DrawEllipse(Brushes.Gray, null, this.SkeletonPointToScreen(szkielet.Joints[JointType.HandLeft].Position), JointThickness, JointThickness);

                dc.DrawEllipse(Brushes.Gray, null, this.SkeletonPointToScreen(szkielet.Joints[JointType.HandRight].Position), JointThickness, JointThickness);

                dc.DrawEllipse(Brushes.HotPink, null, this.SkeletonPointToScreen(szkielet.Joints[JointType.FootLeft].Position), JointThickness, JointThickness);

                dc.DrawEllipse(Brushes.HotPink, null, this.SkeletonPointToScreen(szkielet.Joints[JointType.FootRight].Position), JointThickness, JointThickness);

                dc.DrawEllipse(Brushes.Green, null, this.SkeletonPointToScreen(szkielet.Joints[JointType.HipCenter].Position), JointThickness, JointThickness);

                dc.DrawEllipse(Brushes.Aqua, null, this.SkeletonPointToScreen(szkielet.Joints[JointType.ShoulderCenter].Position), 2, 2);

                dc.DrawEllipse(Brushes.Aqua, null, this.SkeletonPointToScreen(szkielet.Joints[JointType.ElbowLeft].Position), 2, 2);

                dc.DrawEllipse(Brushes.Aqua, null, this.SkeletonPointToScreen(szkielet.Joints[JointType.ElbowRight].Position), 2, 2);
            }

            Joint[] joints =
            {
                szkielet.Joints[JointType.Head],
                szkielet.Joints[JointType.HandLeft],
                szkielet.Joints[JointType.HandRight],
                szkielet.Joints[JointType.FootLeft],
                szkielet.Joints[JointType.FootRight],
                szkielet.Joints[JointType.HipCenter],
                szkielet.Joints[JointType.ShoulderCenter],
                szkielet.Joints[JointType.ElbowLeft],
                szkielet.Joints[JointType.ElbowRight]
            };

            Point [] points = new Point [joints.Length];
            for (int i = 0; i < joints.Length; i++)
            {
                points[i] = SkeletonPointToScreen(joints[i].Position);
            }

            if (tryb.analiza_cwiczenia(progressBar2, points) && wlacz_kinect)
            {
                b_zakoncz.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }

            Joint joint = szkielet.Joints[JointType.FootLeft];
            Point punkt = new Point(0, 0);

            if (joint.TrackingState == JointTrackingState.Tracked || joint.TrackingState == JointTrackingState.Inferred)
            {
                punkt = SkeletonPointToScreen(joint.Position);

                Canvas.SetLeft(progressBar3, punkt.X - 9.5);
                Canvas.SetTop(progressBar3, punkt.Y - 12);
            }
            else
            {
                return;
            }

            Point b = canvas1.TranslatePoint(punkt, b_zakoncz);

            b.X = b.X - 7;
            b.Y = b.Y - 7;

            if (b.X >= 0 && b.Y >= 0 && b_zakoncz.Width >= b.X && b_zakoncz.Height >= b.Y)
            {
                if (!watek && wlacz_kinect)
                {
                    b_zakoncz.RaiseEvent(new MouseEventArgs(Mouse.PrimaryDevice, 0)
                    {
                        RoutedEvent = Mouse.MouseEnterEvent
                    });

                    try
                    {
                        watek = true;
                        progressBar3.Visibility = Visibility.Visible;

                        t1 = new Thread(czekaj);
                        t1.Start();
                    }
                    catch { }
                }
            }
            else
            {
                if (watek)
                {
                    if (t1.IsAlive == true)
                    {
                        t1.Abort();

                        progressBar3.Visibility = Visibility.Hidden;
                        watek = false;
                    }
                }
            }
        }
Esempio n. 3
0
        public void Wlacz(TRYB_KONTROLI_RUCHOW t, bool wlacz_kinect, MAGICZNE_ZAKLECIE magia)
        {
            this.tryb = t;
            this.wlacz_kinect = wlacz_kinect;

            this.magia = magia;
            if (magia != null)
            {
                magia.efekt_zaklecia(canvas1);
            }

            muz = new MUZYKA();
            muz.lista_odtwarzania(mediaElement1);

            Point[] p = { new Point(0, 0) };
            tryb.analiza_cwiczenia(progressBar2, p);
            czas_calkowity = tryb.czas_treningu;

            czas_t = new Thread(czas_treningu);
            czas_t.Start();

            media_active = true;
            watek_czas = true;
        }