/// <summary> /// When browsing for an image button is executed, this events appens /// </summary> private void OpenPng(object sender, RoutedEventArgs e) { FileManagement.open_File(ImageFileNameTextBox, "png", "C:\\Users\\Public\\Pictures"); if (string.IsNullOrEmpty(ImageFileNameTextBox.Text)) { return; } bool rightExtension = ImageHandling.ImgIsValid(ImageFileNameTextBox.Text); if (rightExtension) { spriteimg.Source = SpritePreviewer.ReturnBitmapFile(ImageFileNameTextBox.Text); spriteimg.ToolTip = "Height: " + (int)spriteimg.Source.Height + " Width: " + (int)spriteimg.Source.Width; char s = '\\'; string[] test = ImageFileNameTextBox.Text.Split(s); if (test[test.Length - 1].Equals("platformer_sprites_pixelized_mirrored.png")) { SpritesPerRowTextBox.Text = "8"; SpritesPerColumnTextBox.Text = "18"; imageXIndexTextBox.Text = "0"; imageYIndexTextBox.Text = "4"; frameCount.Text = "8"; txtAnimationDuration.Text = "0.05"; } } else { ImageFileNameTextBox.Text = ""; } }
/// <summary> /// When browsing for an xml file with a SpriteComponent, attempt to open the image associated with file. /// </summary> private void OpenPngOnBrowse() { SpriteComponent SC = EC.getEntity(xml_filename).GetComponent <SpriteComponent>(); if (SC == null) { return; } string filename = SC.TextureName; if (string.IsNullOrEmpty(filename)) { return; } bool rightExtension = ImageHandling.ImgIsValid(filename); if (rightExtension) { spriteimg.Source = SpritePreviewer.ReturnBitmapFile(filename); spriteimg.ToolTip = "Height: " + (int)spriteimg.Source.Height + " Width: " + (int)spriteimg.Source.Width; } }