예제 #1
0
    public static void InitialiseCount(LeapInterface leap, GestureSpace space, StartMenu menu)
    {
        // Create gesture detector
        CountDetector count = new CountDetector(leap, space);

        // Register regions of interest
        ActivityROIs.ConnectROIs(count);
        count.RegisterObserver(menu);
    }
        public void CountComplete(Leap.Vector pos, ROI roi, DateTime time, int count, CountDetector cd, List<IParentObserver> observers)
        {
            switch (count)
            {
                case 1:
                    foreach (IParentObserver observer in observers)
                    {
                        if (observer is IGestureObserver)
                        {
                            IGestureObserver ig = (IGestureObserver)observer;
                            cd.UnregisterObserver(ig);
                            break;
                        }
                    }
                    cd.RegisterObserver(musicScreen);
                    System.Media.SoundPlayer musicSound = new System.Media.SoundPlayer(@"C:\Users\Gerard\Documents\Visual Studio 2013\Projects\InCarGestureApplication\InCarGestureApplication\Menu\Audio\Audio Feedback\Music.wav");
                    musicSound.Play();

                    mw.Dispatcher.Invoke((Action)(() => {
                        //mw.window.Children.Clear();
                        mw.window.Children.Remove(mw.window.Children[mw.window.Children.Count - 1]);
                        mw.window.Children.Add(musicScreen);

                    }));
                    break;
                case 2:
                    foreach (IParentObserver observer in observers)
                    {
                        if (observer is IGestureObserver)
                        {
                            IGestureObserver ig = (IGestureObserver)observer;
                            cd.UnregisterObserver(ig);
                            break;
                        }
                    }
                    cd.RegisterObserver(gpsScreen);
                    System.Media.SoundPlayer gpsSound = new System.Media.SoundPlayer(@"C:\Users\Gerard\Documents\Visual Studio 2013\Projects\InCarGestureApplication\InCarGestureApplication\Menu\Audio\Audio Feedback\GPS.wav");
                    gpsSound.Play();
                    mw.Dispatcher.Invoke((Action)(() => {
                        //mw.window.Children.Clear();
                        mw.window.Children.Remove(mw.window.Children[mw.window.Children.Count - 1]);
                        mw.window.Children.Add(gpsScreen);
                        //gpsScreen.setWindow(mw);
                    }));
                    break;
                case 3:
                    foreach (IParentObserver observer in observers)
                    {
                        if (observer is IGestureObserver)
                        {
                            IGestureObserver ig = (IGestureObserver)observer;
                            cd.UnregisterObserver(ig);
                            break;
                        }
                    }
                    cd.RegisterObserver(contactScreen);
                    System.Media.SoundPlayer contactSound = new System.Media.SoundPlayer(@"C:\Users\Gerard\Documents\Visual Studio 2013\Projects\InCarGestureApplication\InCarGestureApplication\Menu\Audio\Audio Feedback\Phonebook.wav");
                    contactSound.Play();
                    mw.Dispatcher.Invoke((Action)(() => {
                        //mw.window.Children.Clear();
                        mw.window.Children.Remove(mw.window.Children[mw.window.Children.Count - 1]);
                        mw.window.Children.Add(contactScreen);
                    }));
                    break;
                case 4:
                    foreach (IParentObserver observer in observers)
                    {
                        if (observer is IGestureObserver)
                        {
                            IGestureObserver ig = (IGestureObserver)observer;
                            cd.UnregisterObserver(ig);
                            break;
                        }
                    }
                    cd.RegisterObserver(extrasScreen);
                    System.Media.SoundPlayer extraSound = new System.Media.SoundPlayer(@"C:\Users\Gerard\Documents\Visual Studio 2013\Projects\InCarGestureApplication\InCarGestureApplication\Menu\Audio\Audio Feedback\Extras.wav");
                    extraSound.Play();

                    mw.Dispatcher.Invoke((Action)(() =>
                    {
                        //mw.window.Children.Clear();
                        mw.window.Children.Remove(mw.window.Children[mw.window.Children.Count - 1]);
                        mw.window.Children.Add(extrasScreen);
                    }));
                    break;
                default:
                    break;
            }
        }