コード例 #1
0
 // Called when photo button clicked
 private void PhotoButtonOnClick(object sender, RoutedEventArgs e)
 {
     //this.sensorChooser.KinectChanged -= SensorChooserOnKinectChanged;
     this._sensor.AllFramesReady -= this._sensor_AllFramesReady;
     Photo m = new Photo("1");
     this.NavigationService.Navigate(m);
 }
コード例 #2
0
        private void SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            if (e.Result.Confidence < 0.7)
            { return; }
            string semantic = "";
            switch ( e.Result.Semantics.Value.ToString() )
            {
                case "FORWARD":
                    if (photoCount <= 9)
                    {
                        photoCount += 1;
                        Label1.Content = photoCount.ToString() + "/10";
                        Image.Source = new BitmapImage(new Uri(@"F:\KinectTest\KinectTest\KinectTest\Photo\" + photoCount.ToString() + ".jpg", UriKind.RelativeOrAbsolute));
                    }
                    break;
                case "BACKWARD":
                    if (photoCount >= 2)
                    {
                        photoCount -= 1;
                        Label1.Content = photoCount.ToString() + "/10";
                        Image.Source = new BitmapImage(new Uri(@"F:\KinectTest\KinectTest\KinectTest\Photo\" + photoCount.ToString() + ".jpg", UriKind.RelativeOrAbsolute));
                    }
                    break;
                case "ROTATE":
                    RotateCount += 1;
                    //Rotate
                    //Create source
                    BitmapImage bi = new BitmapImage();
                    //BitmapImage properties must be in a BeginInit/EndInit block
                    bi.BeginInit();
                    bi.UriSource = new Uri(@"F:\KinectTest\KinectTest\KinectTest\Photo\" + photoCount.ToString() + ".jpg", UriKind.RelativeOrAbsolute);
                    //Set image rotation
                    if (RotateCount % 4 == 1)
                    {
                        bi.Rotation = Rotation.Rotate90;
                    }
                    else if (RotateCount % 4 == 2)
                    {
                        bi.Rotation = Rotation.Rotate180;
                    }
                    else if (RotateCount % 4 == 3)
                    {
                        bi.Rotation = Rotation.Rotate270;
                    }
                    else if (RotateCount % 4 == 0)
                    {
                        bi.Rotation = Rotation.Rotate0;
                    }
                    bi.EndInit();
                    //set image source
                    Image.Source = bi;
                    break;
                case "HAND":
                            semantic = "hand";
                             if (null != this._sensor)
                            {
                                this._sensor.AudioSource.Stop();
                            }

                            if (null != this.speechEngine)
                            {
                                this.speechEngine.SpeechRecognized -= SpeechRecognized;
                                this.speechEngine.SpeechRecognitionRejected -= SpeechRejected;
                                this.speechEngine.RecognizeAsyncStop();
                            }
                            statusLabel.Content = "Loading...";
                            Photo newPhoto = new Photo("1");
                            this.NavigationService.Navigate(newPhoto);
                            break;
                case "MAIN":
                           if (null != this._sensor)
                        {
                            this._sensor.AudioSource.Stop();
                        }

                        if (null != this.speechEngine)
                        {
                            this.speechEngine.SpeechRecognized -= SpeechRecognized;
                            this.speechEngine.SpeechRecognitionRejected -= SpeechRejected;
                            this.speechEngine.RecognizeAsyncStop();
                        }
                        (Application.Current.MainWindow.FindName("mainFrame") as Frame).Source = new Uri("MainMenu.xaml", UriKind.Relative);
                        break;
                default:
                    break;
            }

            //throw new NotImplementedException();
        }