Пример #1
0
        void Init()
        {
            Bezier.Dispatcher = Dispatcher;

            completionTimer = new Timer(250);
            completionTimer.Elapsed += completionTimer_Elapsed;
            UserCurve.Visibility = Visibility.Hidden;
            RefCurve.Visibility = Visibility.Hidden;

            stopwatch = new Stopwatch();
            tComplete = new TextBlock
            {
                FontSize = 128,
                Foreground = Brushes.Black,
                Text = "Session complete!",
                RenderTransform = new TranslateTransform() { X = 500, Y = 300 }
            };
            gazeRadius =(int)( CrossHair.Width / 2);

            knotPoints = new Dictionary<TouchDevice, IDot>();
            userDots = new List<IDot>();
            refDots = new List<IDot>();
            #if TRACKER
            Loaded += SplineTask_Loaded;
            #endif
            TouchDown += ellipse_TouchDown;
            TouchMove += ellipse_TouchMove;
            LostTouchCapture += ellipse_LostTouchCapture;

            //bConnect.TouchUp += (sender, e) => tracker.Connect();
            //bStart.TouchUp += (sender, e) => tracker.StartTracking();
            bDots.Click += (sender, e) => ShowRefDots();
            bNew.Click += delegate
            {
                int[] condition = conditions[Test.BezierIndex % conditions.Count];
                NewSession();
                lCondition.Visibility = Visibility.Visible;
                lCondition.Text = gazeOn ? "Manual + Gaze condition" : "Manual only";
                lCondition.Text += "\nTrial: " + (Test.Count + 1);

                CountDownWpf countdownTimer = new CountDownWpf();
                countdownTimer.Elapsed += delegate
                {
                    Dispatcher.BeginInvoke(new Action(delegate
                                                      {
            #if TRACKER
                                                          if (gazeOn)
                                                            {
                                                                tracker.Connect();
                                                                tracker.StartTracking();
                                                          }
                                                          CrossHair.Visibility = gazeOn ? Visibility.Visible : Visibility.Hidden;
            #endif
                                                          UserCurve.Visibility = Visibility.Visible;
                                                          RefCurve.Visibility = Visibility.Visible;
                                                          ShowUserDots();

                                                          //if (condition[2] == 0)
                                                          //    ShowRefDots();
                                                          lCondition.Visibility = Visibility.Hidden;
                                                          ToggleButtons();

                        Canvas.Children.Remove(
                            countdownTimer);
                        countdownTimer.Reset();
                        stopwatch.Start();
                    }
                                               ));

                };
                Canvas.Children.Add(countdownTimer);
                countdownTimer.Start();
                if (Canvas.Children.Contains(tComplete))
                    Canvas.Children.Remove(tComplete);

            };

            //test
            bStop.TouchUp += delegate
                           {
                               if (stopwatch.IsRunning)
                                   CompleteSession();
                               TrackerEvent.Misc.Write(string.Format("BezierSession {0} aborted", Test.BezierIndex));
                               //NewSession();
                           };
        }
Пример #2
0
        void StartNew()
        {
            CountDownWpf countdownTimer = new CountDownWpf();
            countdownTimer.Elapsed += delegate
            {
                Dispatcher.BeginInvoke(new Action(delegate
                {
                    eyeArea.Visibility = lFingerArea.Visibility = rFingerArea.Visibility = Visibility.Hidden;

                    lCondition.Visibility = Visibility.Hidden;

                    ToggleButtons();
                    NewSession();
                    Canvas.Children.Remove(
                        countdownTimer);
                    countdownTimer.Reset();
                    clock.Start();
                    startTime = DateTime.Now;
                    stopwatch.Start();
                }));
            };
            Canvas.Children.Add(countdownTimer);
            countdownTimer.Start();
        }