/// <summary> /// Add Animation for now /// </summary> private void AddAnimation_Click(object sender, RoutedEventArgs e) { try { var imageFilename = ImageFileNameTextBox.Text; var name = (string)((ListBoxItem)cbAnimNames.SelectedItem).Content; // txtboxAnimationName.Text; var spr = Convert.ToInt32(SpritesPerRowTextBox.Text); var spc = Convert.ToInt32(SpritesPerColumnTextBox.Text); var imgIndexX = Convert.ToInt32(imageXIndexTextBox.Text); var imgIndexY = Convert.ToInt32(imageYIndexTextBox.Text); var frmCount = Convert.ToInt32(frameCount.Text); var dur = Convert.ToSingle(txtAnimationDuration.Text); Bitmap imgsrc = new Bitmap(ImageFileNameTextBox.Text); int width = (int)(imgsrc.Width / spr); int height = (int)(imgsrc.Height / spc); SpriteComponent SC = EC.getEntity(xml_filename).GetComponent <SpriteComponent>(); if (SC != null) { if (SC.faAnimations.ContainsKey(name)) { SC.RemoveAnimationWithName(name); } SC.AddAnimation(name, imgIndexX * width, imgIndexY * height, width, height, dur, frmCount, (int)(imgsrc.Width)); HitboxAnalyzer.IntializeAutomaticHurtBoxes(imgsrc, SC.faAnimations[name]); SC.TextureName = imageFilename; } System.Windows.MessageBox.Show("New animation added, be sure to click \"Save XML\" for changes to take effect.", "Success", MessageBoxButton.OK, MessageBoxImage.None); } catch { System.Windows.MessageBox.Show("Did not add new animation. You may have left a textbox unfilled, or did not load an XML file.", "Failure", MessageBoxButton.OK, MessageBoxImage.Error); } }