/// <summary> /// Switches to the next shirt and then updates preview images by calling <see cref="DisplayPreviewImages"/> /// </summary> /// <returns>Returns the new shirt that is selected</returns> public Shirt NextShirt() { // make sure to rotate around size of shirts list this.currentShirtIndex = (this.currentShirtIndex + 1) % this.shirts.Count(); this.DisplayPreviewImages(); Shirt nextShirt = this.shirts[this.currentShirtIndex]; return(nextShirt); }
/// <summary> /// Executes when ready to go /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Event</param> private void WindowLoaded(object sender, RoutedEventArgs e) { this.BeginSpeechRecognition(); // set up shir manager and load first shirt onto skeleton this.shirtManager = new ShirtManager(ChosenShirt, PreviousShirt, NextShirt, this.Dispatcher); this.shirt = this.shirtManager.NextShirt(); // for drawing skeleton bones and joints onto body this.drawingVisual = new DrawingVisual(); this.visualHost = new VisualHost { visual = this.drawingVisual }; // Select Sensor to be used foreach (KinectSensor potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { // found a potential sensor that's connected, so now we use it this.sensor = potentialSensor; break; } } // execute only if we successfully acquired a sensor if (this.sensor == null) { return; } // enable the necessary streams this.sensor.ColorStream.Enable(); this.sensor.SkeletonStream.Enable(); this.sensor.DepthStream.Enable(); // add event handlers for the frames this.sensor.AllFramesReady += this.SensorOnAllFramesReady; try { this.sensor.Start(); } catch (IOException) { this.sensor = null; } }
/// <summary> /// Check text to see if a specific command is uttered /// </summary> /// <param name="text">Text recognized by <see cref="SpeechRecognizer"/> to be analyzed for command syntax</param> private void ProcessCommand(string text) { if (text.ToLower().Contains("next")) { this.shirt = this.shirtManager.NextShirt(); } else if (text.ToLower().Contains("back") || text.ToLower().Contains("previous")) { this.shirt = this.shirtManager.PreviousShirt(); } else if (text.ToLower().Contains("debug")) { this.DEBUG = !this.DEBUG; } }
/// <summary> /// Switch to the previous shirt /// </summary> /// <returns>Instance of newly selected shirt</returns> public Shirt PreviousShirt() { if (this.currentShirtIndex == 0) { this.currentShirtIndex = this.shirts.Count() - 1; } else { this.currentShirtIndex = this.currentShirtIndex - 1; } this.DisplayPreviewImages(); Shirt previousShirt = this.shirts[this.currentShirtIndex]; return(previousShirt); }
/// <summary> /// Loads shirts that are stored in the project resources /// </summary> /// <returns>An array of <see cref="Shirt"/> instances for the <see cref="ShirtManager"/> to keep track of</returns> private List <Shirt> InitializeShirts() { List <Shirt> loadedShirts = new List <Shirt>(); ResourceSet resources = Resources.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true); // TODO make check if the entry is of type Bitmap, cause projects could have resources that are not images foreach (DictionaryEntry entry in resources) { // Convert entry object to Bitmap Bitmap resource = (Bitmap)entry.Value; // Convert bitmap to BitmapSource file that we can display on the image BitmapSource source = LoadImageBitmapSource(resource); // Create instance of the shirt object, making sure to pass in Canvas Shirt shirt = new Shirt(this.ShirtCanvas, source); loadedShirts.Add(shirt); } return(loadedShirts); }