/// <summary> /// Initializes a new instance of the <see cref="DesktopMainWindow"/> class. /// </summary> public DesktopMainWindow() { this.InitializeComponent(); // initialize the sensor chooser and UI this.sensorChooser = new KinectSensorChooser(); this.sensorChooser.KinectChanged += SensorChooserOnKinectChanged; this.sensorChooserUi.KinectSensorChooser = this.sensorChooser; this.sensorChooser.Start(); // Bind listner to scrollviwer scroll position change, and check scroll viewer position this.UpdatePagingButtonState(); scrollViewer.ScrollChanged += (o, e) => this.UpdatePagingButtonState(); this.WindowState = System.Windows.WindowState.Maximized; speechControl = new KinectSpeechControl(this.sensorChooser.Kinect); repository = new SkeletonStateRepository(); this.kinectRegion.Repository = repository; grammar = speechControl.CreateGrammarFromResource(Properties.Resources.WindowGrammar); StartEvents(); }
void MainWindow_Loaded(object sender, RoutedEventArgs e) { kinectControl = new KinectControl(gestureRecognition, skeletonRepository); kinectControl.ColorFrameGot += this.UpdateImage; kinectControl.SkeletonRecognized += SkeletonReady; try { kinectControl.StartKinect(); } catch(KinectNotFoundException exception) { Output.WriteToDebugOrConsole(exception.Message); this.Close(); } //Application.Current.Exit += new ExitEventHandler(Current_Exit); this.Closed += Current_Exit; speechControl = kinectControl.ReturnSpeechControl(); grammar = createGrammar(mode); speechControl.InitializeSpeechRecognition(grammar); speechControl.SpeechRecognized += this.SpeechRecognized; speechControl.SpeechHypothesized += this.SpeechHypothesized; }