Exemple #1
0
        private void calibButton_Click(object sender, EventArgs e)
        {
            //Get the position of the finger/palm (supposedly centered)
            fingerCenter = new float[3] {
                controller.Frame().Hands[0].Fingers[1].TipPosition.x,
                                   controller.Frame().Hands[0].Fingers[1].TipPosition.y,
                                   controller.Frame().Hands[0].Fingers[1].TipPosition.z
            };
            palmCenter = new float[3] {
                controller.Frame().Hands[0].PalmPosition.x,
                                   controller.Frame().Hands[0].PalmPosition.y,
                                   controller.Frame().Hands[0].PalmPosition.z
            };
            //startButton1.Visible = true;
            //startButton1.Focus();

            vertSmallUpRightPos = new PointF(fingerCenter[0] + 64, fingerCenter[1] + 36);
            vertSmallBotLeftPos = new PointF(fingerCenter[0] - 64, fingerCenter[1] - 36);
            vertLargeUpRightPos = new PointF(fingerCenter[0] + 256, fingerCenter[1] + 128);
            vertLargeBotLeftPos = new PointF(fingerCenter[0] - 256, fingerCenter[1] - 128);
            horSmallUpRightPos  = new PointF(fingerCenter[0] + 40, fingerCenter[2] - 22);
            horSmallBotLeftPos  = new PointF(fingerCenter[0] - 40, fingerCenter[2] + 22);
            horLargeUpRightPos  = new PointF(fingerCenter[0] + 80, fingerCenter[2] - 45);
            horLargeBotLeftPos  = new PointF(fingerCenter[0] - 80, fingerCenter[2] + 45);

            pvertSmallUpRightPos = new PointF(fingerCenter[0] + 64, fingerCenter[1] + 36);
            pvertSmallBotLeftPos = new PointF(fingerCenter[0] - 64, fingerCenter[1] - 36);
            pvertLargeUpRightPos = new PointF(fingerCenter[0] + 256, fingerCenter[1] + 128);
            pvertLargeBotLeftPos = new PointF(fingerCenter[0] - 256, fingerCenter[1] - 128);
            phorSmallUpRightPos  = new PointF(fingerCenter[0] + 40, fingerCenter[2] - 22);
            phorSmallBotLeftPos  = new PointF(fingerCenter[0] - 40, fingerCenter[2] + 22);
            phorLargeUpRightPos  = new PointF(fingerCenter[0] + 80, fingerCenter[2] - 45);
            phorLargeBotLeftPos  = new PointF(fingerCenter[0] - 80, fingerCenter[2] + 45);

            calibButton.Visible = false;
            startupMenu startupMenu = new startupMenu();

            startupMenu.Show();
            this.Hide();
        }
        private void fittsButton_Click(object sender, EventArgs e)
        {
            if (!diagnostics.finished)
            {
                //diagnostics.calcID(this.Size.Height / 2, fittsButton.Width);
                double time = timer1.ElapsedMilliseconds;  //Get the current time on the stopwatch
                //diagnostics.calcIP(time);  //Get the IP from the time and established ID
                float newAngle = new float();
                newAngle = (float)(((Math.Atan2(fittsButton.Location.X - this.Size.Width * 0.5, this.Size.Height * 0.5 - fittsButton.Location.Y)) + ((4 * Math.PI) / 6))); //(arctan(y/x) + 2pi/3) % pi

                //Debugging
                label42.Text = Math.Atan2(fittsButton.Location.X - this.Size.Width * 0.5, this.Size.Height * 0.5 - fittsButton.Location.Y).ToString(); //Doesn't work?
                label44.Text = (Math.Atan2(fittsButton.Location.X - this.Size.Width * 0.5, this.Size.Height * 0.5 - fittsButton.Location.Y) + ((4 * Math.PI) / 6)).ToString();
                label46.Text = ((5 * Math.PI) / 6).ToString();

                //Writing the info to fittsOutput
                fittsOut.WriteLine(diagnostics.dump(time, fittsButton.Location, Cursor.Position));

                //Setting button location
                fittsButton.Location = new Point(Convert.ToInt32((this.Size.Width * 0.5) + fittsRadius * Math.Cos(newAngle)),   // R*cos(theta) + translation
                                                 Convert.ToInt32((this.Size.Height * 0.5) + fittsRadius * Math.Sin(newAngle))); // R*sin(theta) + translation

                timer1.Reset();
                timer1.Start();

                //Debugging
                label36.Text = fittsButton.Location.ToString();
                label38.Text = Math.Atan2((this.Size.Height * 0.5 - fittsButton.Location.Y), (fittsButton.Location.X - this.Size.Width * 0.5)).ToString();
                label40.Text = new Point(Convert.ToInt32(fittsButton.Location.X - this.Size.Width * 0.5), Convert.ToInt32(this.Size.Height * 0.5 - fittsButton.Location.Y)).ToString();
            }
            else
            {
                fittsButton.Visible = false;
                startupMenu startMenu = new startupMenu();
                startMenu.Show();
                this.Close();
            }
        }