void imgProcessDelay_Tick(object sender, EventArgs e) { if (imgProcessDelay != null) { imgProcessDelay.Tick -= imgProcessDelay_Tick; imgProcessDelay.Stop(); imgProcessDelay = null; } MainWindow.showPlayerOverlays(); userImage.Source = MainWindow.colorImageBitmap; currentFocus = afterFocus; if (currentFocus == playerFocus.Picture) { startCaptureAnim(); } }
void kinectGuideTimer_Tick(object sender, EventArgs e) { currentFocus = playerFocus.KinectGuide; MainWindow.SFXMenu.Play(); if (kinectGuideTimer != null) { kinectGuideTimer.Stop(); kinectGuideTimer.Tick -= kinectGuideTimer_Tick; kinectGuideTimer = null; } MainWindow.animateSlide(kinectGuideCanvas, false, false, -150, 0.5); kinectGuideCanvas.Visibility = System.Windows.Visibility.Visible; imgDimmer.Visibility = System.Windows.Visibility.Visible; imgMenuMovementGuide.Visibility = System.Windows.Visibility.Visible; MainWindow.animateFade(imgDimmer, 0, 0.5,0.5); MainWindow.hidePlayerOverlays(); menuPosition = 0; Canvas.SetTop(kinectGuideCanvas, 0); //Listen for swipe gesture handMovements.LeftSwipeRight += new EventHandler<handMovements.GestureEventArgs>(handMovements_LeftSwipeRight); menuMovementTimer = new DispatcherTimer(); menuMovementTimer.Interval = TimeSpan.FromMilliseconds(500); menuMovementTimer.Tick += new EventHandler(menuMovementTimer_Tick); menuMovementTimer.Start(); }
private void exitKinectGuide() { if (currentFocus == playerFocus.KinectGuide) { Canvas.SetTop(kinectGuideCanvas, 60 * menuPosition); MainWindow.animateSlide(kinectGuideCanvas, true, false, -150, 0.5); MainWindow.animateFade(imgDimmer, 0.5, 0, 0.5); imgMenuMovementGuide.Visibility = System.Windows.Visibility.Hidden; MainWindow.showPlayerOverlays(); currentFocus = playerFocus.None; //Remove menu nav tick if (menuMovementTimer != null) { menuMovementTimer.Stop(); menuMovementTimer.Tick -= menuMovementTimer_Tick; menuMovementTimer = null; } } }
private void hideHelpVisual() { if (helpVisual != null) { currentFocus = playerFocus.None; MainWindow.showPlayerOverlays(); MainWindow.animateFade(imgDimmer, 0.75, 0, 0.5); MainWindow.animateSlide(helpVisual, true); helpVisual = null; } }
private void checkTutorial(MainWindow.Tutorials tutorial) { if (MainWindow.availableTutorials.ContainsKey(tutorial) && !MainWindow.availableTutorials[tutorial].seen) { MainCanvas.Children.Add(MainWindow.availableTutorials[tutorial].tutImage); MainWindow.availableTutorials[tutorial].tutImage.Width = MainCanvas.ActualWidth; imgDimmer.Visibility = System.Windows.Visibility.Visible; MainWindow.animateFade(imgDimmer, 0, 0.5, 0.5); MainWindow.animateFade(MainWindow.availableTutorials[tutorial].tutImage, 0, 1, 0.5); handMovements.LeftSwipeRight += dismissTutorial; MainWindow.hidePlayerOverlays(); MainWindow.activeTutorial = tutorial; currentFocus = playerFocus.Tutorial; MainWindow.availableTutorials[tutorial].seen = true; } }
void dismissTutorial(object sender, handMovements.GestureEventArgs e) { handMovements.LeftSwipeRight -= dismissTutorial; handMovements.LeftSwipeRightStatus[MainWindow.gestureSkeletonKey] = false; MainWindow.animateFade(imgDimmer, 0.5, 0, 0.5); MainWindow.animateSlide(MainWindow.availableTutorials[MainWindow.activeTutorial].tutImage, true, false, 50, 0.5); MainWindow.Tutorials previousTutorial = MainWindow.activeTutorial; MainWindow.activeTutorial = MainWindow.Tutorials.None; currentFocus = playerFocus.None; MainWindow.showPlayerOverlays(); if (previousTutorial == MainWindow.Tutorials.WallOfSound) { checkTutorial(MainWindow.Tutorials.KinectGuide); } else if (previousTutorial == MainWindow.Tutorials.KinectGuide) { checkTutorial(MainWindow.Tutorials.VoiceRecognition); } }
void takeAPicture() { if (currentFocus == playerFocus.None) { currentFocus = playerFocus.Picture; toggleRGB(ColorImageFormat.RgbResolution1280x960Fps12,currentFocus); Storyboard sb = this.FindResource("photoPrep") as Storyboard; sb.AutoReverse = false; sb.Begin(); Storyboard sb2 = this.FindResource("photoLoading") as Storyboard; sb2.Begin(); } }
private void toggleRGB(ColorImageFormat format, playerFocus processFocus, int delay = 3000) { if (MainWindow.sensor.ColorStream.Format != format) { MainWindow.hidePlayerOverlays(); MainWindow.sensor.ColorStream.Enable(format); MainWindow.colorImageBitmap = new WriteableBitmap(MainWindow.sensor.ColorStream.FrameWidth, MainWindow.sensor.ColorStream.FrameHeight, 96, 96, PixelFormats.Bgr32, null); MainWindow.colorImageBitmapRect = new Int32Rect(0, 0, MainWindow.sensor.ColorStream.FrameWidth, MainWindow.sensor.ColorStream.FrameHeight); MainWindow.colorImageStride = MainWindow.sensor.ColorStream.FrameWidth * MainWindow.sensor.ColorStream.FrameBytesPerPixel; afterFocus = processFocus; imgProcessDelay = new DispatcherTimer(); imgProcessDelay.Interval = TimeSpan.FromMilliseconds(delay); imgProcessDelay.Tick += new EventHandler(imgProcessDelay_Tick); imgProcessDelay.Start(); } }
private void showHelpVisual() { if (helpVisual == null) { currentFocus = playerFocus.VoiceHelp; MainWindow.hidePlayerOverlays(); helpVisual = new Image(); helpVisual.Source = new BitmapImage(new Uri("/Moto;component/images/tutorials/voice-help-wos.png", UriKind.Relative)); if (!MainCanvas.Children.Contains(helpVisual)) { MainCanvas.Children.Add(helpVisual); } helpVisual.Width = MainCanvas.ActualWidth; imgDimmer.Visibility = System.Windows.Visibility.Visible; MainWindow.animateFade(imgDimmer, 0, 0.75, 0.5); MainWindow.animateSlide(helpVisual); } }
private void startCaptureAnim() { Storyboard sb2 = this.FindResource("photoPrep") as Storyboard; sb2.AutoReverse = true; sb2.Begin(this, true); sb2.Seek(this, new TimeSpan(0, 0, 0), TimeSeekOrigin.Duration); Storyboard sb3 = this.FindResource("photoLoading") as Storyboard; sb2.Stop(); currentFocus = playerFocus.Picture; imgGetReady.Visibility = Visibility.Visible; imgCamera.Visibility = Visibility.Visible; pictureCountdown = new DispatcherTimer(); pictureCountdown.Interval = TimeSpan.FromSeconds(3); pictureCountdown.Tick += new EventHandler(pictureCountdown_Tick); pictureCountdown.Start(); Canvas.SetZIndex(imgCamera, 1); Canvas.SetZIndex(imgGetReady, 1); Storyboard sb = this.FindResource("cameraCountdown") as Storyboard; sb.Begin(); }
private void Page_Loaded(object sender, RoutedEventArgs e) { userImage.Source = MainWindow.colorImageBitmap; //Listening for when our frames are ready MainWindow.sensor.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(sensor_AllFramesReady); //Create dictionary definitions for all the Media Players available generateMediaPlayers(); handMovements.KinectGuideGesture += new EventHandler<handMovements.GestureEventArgs>(handMovements_KinectGuideGesture); KinectSensor.KinectSensors.StatusChanged += new EventHandler<StatusChangedEventArgs>(KinectSensors_StatusChanged); setupVoice(); setupVoiceVisuals(); setupKinectGuide(); currentFocus = playerFocus.None; processExistingSkeletons(MainWindow.activeSkeletons); checkTutorial(MainWindow.Tutorials.BandMode); this.FocusVisualStyle = null; this.Focus(); }
//Metronome code private void listenForMetronome(object sender, EventArgs e) { if (MainWindow.activeSkeletons.ContainsKey(MainWindow.gestureSkeletonKey)) { currentFocus = playerFocus.Metronome; if (MainWindow.activeSkeletons[MainWindow.gestureSkeletonKey].skeleton != null) { if (Math.Abs(MainWindow.activeSkeletons[MainWindow.gestureSkeletonKey].skeleton.Joints[JointType.HandLeft].Position.X - MainWindow.activeSkeletons[MainWindow.gestureSkeletonKey].skeleton.Joints[JointType.HandRight].Position.X) < 0.1 && !beatSet) { //Set the beat beatSet = true; metronome.metronomeBeat(); resetBeatSetTimeout(metronome.theMetronome.Interval); } else if (Math.Abs(MainWindow.activeSkeletons[MainWindow.gestureSkeletonKey].skeleton.Joints[JointType.HandLeft].Position.X - MainWindow.activeSkeletons[MainWindow.gestureSkeletonKey].skeleton.Joints[JointType.HandRight].Position.X) > 0.25) { beatSet = false; } } else { MainWindow.sensor.AllFramesReady -= listenForMetronome; } } }
void handMovements_LeftSwipeRight(object sender, handMovements.GestureEventArgs e) { if (e.Trigger == handMovements.UserDecisions.Triggered) { MainWindow.SFXSuccess.Play(); exitKinectGuide(); switch (kinectGuideMenu[menuPosition]) { case menuOptions.GoBack: returnToStart(); break; case menuOptions.TakeAPicture: takeAPicture(); break; case menuOptions.Metronome: currentFocus = playerFocus.Metronome; metronome.destroyMetronome(); MainWindow.sensor.AllFramesReady -= listenForMetronome; metronome.setupMetronome(); MainWindow.sensor.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(listenForMetronome); checkTutorial(MainWindow.Tutorials.Metronome); break; case menuOptions.Guitar: switchInstrument(MainWindow.activeSkeletons[MainWindow.gestureSkeletonKey], instrumentList.GuitarRight, MainWindow.PlayerMode.Acoustic); break; case menuOptions.LeftyGuitar: switchInstrument(MainWindow.activeSkeletons[MainWindow.gestureSkeletonKey], instrumentList.GuitarLeft, MainWindow.PlayerMode.Acoustic); break; case menuOptions.ElectricGuitar: switchInstrument(MainWindow.activeSkeletons[MainWindow.gestureSkeletonKey], instrumentList.GuitarRight, MainWindow.PlayerMode.Electric); break; case menuOptions.LeftyElectricGuitar: switchInstrument(MainWindow.activeSkeletons[MainWindow.gestureSkeletonKey], instrumentList.GuitarLeft, MainWindow.PlayerMode.Electric); break; case menuOptions.Drum: switchInstrument(MainWindow.activeSkeletons[MainWindow.gestureSkeletonKey], instrumentList.Drums); break; case menuOptions.Keyboard: switchInstrument(MainWindow.activeSkeletons[MainWindow.gestureSkeletonKey], instrumentList.Keyboard); break; case menuOptions.Triangle: switchInstrument(MainWindow.activeSkeletons[MainWindow.gestureSkeletonKey], instrumentList.Triangle); break; } } else { //Stop listening and reset the flag for next time handMovements.LeftSwipeRight -= handMovements_LeftSwipeRight; handMovements.LeftSwipeRightStatus[MainWindow.gestureSkeletonKey] = false; } }
void beatSetTimeout_Tick(object sender, EventArgs e) { //Stop listening for the metronome currentFocus = playerFocus.None; MainWindow.sensor.AllFramesReady -= listenForMetronome; beatSetTimeout.Tick -= beatSetTimeout_Tick; beatSetTimeout = null; }
void voiceGoDoThis(SpeechRecognizer.SaidSomethingEventArgs voiceCommand) { if (voiceCommand.Verb != SpeechRecognizer.Verbs.ReturnToStart || voiceCommand.Verb != SpeechRecognizer.Verbs.Close) { MainWindow.mySpeechRecognizer.switchGrammar(new Choices[] { MainWindow.mySpeechRecognizer.instrumentChoices, MainWindow.mySpeechRecognizer.kinectMotorChoices }, true, true); } int skeletonId = MainWindow.findVoiceCommandPlayer(MainWindow.sensor.AudioSource.SoundSourceAngle); switch (voiceCommand.Verb) { case SpeechRecognizer.Verbs.DrumsSwitch: if (MainWindow.activeSkeletons.ContainsKey(skeletonId)) { switchInstrument(MainWindow.activeSkeletons[skeletonId], instrumentList.Drums); } break; case SpeechRecognizer.Verbs.GuitarSwitch: if (MainWindow.activeSkeletons.ContainsKey(skeletonId)) { switchInstrument(MainWindow.activeSkeletons[skeletonId], instrumentList.GuitarRight, MainWindow.PlayerMode.Acoustic); } break; case SpeechRecognizer.Verbs.LeftyGuitarSwitch: if (MainWindow.activeSkeletons.ContainsKey(skeletonId)) { switchInstrument(MainWindow.activeSkeletons[skeletonId], instrumentList.GuitarLeft, MainWindow.PlayerMode.Acoustic); } break; case SpeechRecognizer.Verbs.ElectricGuitarSwitch: if (MainWindow.activeSkeletons.ContainsKey(skeletonId)) { switchInstrument(MainWindow.activeSkeletons[skeletonId], instrumentList.GuitarRight, MainWindow.PlayerMode.Electric); } break; case SpeechRecognizer.Verbs.LeftyElectricGuitarSwitch: if (MainWindow.activeSkeletons.ContainsKey(skeletonId)) { switchInstrument(MainWindow.activeSkeletons[skeletonId], instrumentList.GuitarLeft, MainWindow.PlayerMode.Electric); } break; case SpeechRecognizer.Verbs.KeyboardSwitch: if (MainWindow.activeSkeletons.ContainsKey(skeletonId)) { switchInstrument(MainWindow.activeSkeletons[skeletonId], instrumentList.Keyboard); } break; case SpeechRecognizer.Verbs.TriangleSwitch: if (MainWindow.activeSkeletons.ContainsKey(skeletonId)) { switchInstrument(MainWindow.activeSkeletons[skeletonId], instrumentList.Triangle); } break; case SpeechRecognizer.Verbs.StartMetronome: currentFocus = playerFocus.Metronome; metronome.destroyMetronome(); MainWindow.sensor.AllFramesReady -= listenForMetronome; metronome.setupMetronome(); checkTutorial(MainWindow.Tutorials.Metronome); MainWindow.sensor.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(listenForMetronome); break; case SpeechRecognizer.Verbs.StopMetronome: metronome.destroyMetronome(); MainWindow.sensor.AllFramesReady -= listenForMetronome; break; case SpeechRecognizer.Verbs.BackToInstruments: break; case SpeechRecognizer.Verbs.Capture: takeAPicture(); break; case SpeechRecognizer.Verbs.KinectUp: MainWindow.adjustKinectAngle(8); break; case SpeechRecognizer.Verbs.KinectUpSmall: MainWindow.adjustKinectAngle(4); break; case SpeechRecognizer.Verbs.KinectDown: MainWindow.adjustKinectAngle(-8); break; case SpeechRecognizer.Verbs.KinectDownSmall: MainWindow.adjustKinectAngle(-4); break; case SpeechRecognizer.Verbs.ReturnToStart: returnToStart(); break; case SpeechRecognizer.Verbs.Close: Application.Current.Shutdown(); break; } MainWindow.mySpeechRecognizer.toggleListening(false); }