/// <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>
 /// Pause at current imgIndex frame
 /// </summary>
 private void Pause_ButtonClick(object sender, RoutedEventArgs e)
 {
     //Go to previous frame and then iterate back to the frame you were at
     imgIndex -= 1;
     imgIndex  = SpritePreviewer.PlayNextFrame(imgIndex, imageYIndexTextBox, imageXIndexTextBox, frameCount,
                                               SpritesPerRowTextBox, ImageFileNameTextBox, SpritesPerColumnTextBox, Test_Img);
     _CurrentPlaying = false;
 }
 /// <summary>
 /// reset the image frame back to the beginning
 /// </summary>
 private void Stop_ButtonClick(object sender, RoutedEventArgs e)
 {
     //Set imgIndex to -1 so the next frame is 0 (the start)
     if (InputHandling.isNumeric(imageXIndexTextBox, imageYIndexTextBox, SpritesPerColumnTextBox, SpritesPerRowTextBox))
     {
         imgIndex = -1;
         imgIndex = SpritePreviewer.PlayNextFrame(imgIndex, imageYIndexTextBox, imageXIndexTextBox, frameCount,
                                                  SpritesPerRowTextBox, ImageFileNameTextBox, SpritesPerColumnTextBox, Test_Img);
         _CurrentPlaying = false;
     }
 }
 void _BackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     while (_CurrentPlaying)
     {
         this.Dispatcher.BeginInvoke((Action) delegate()
         {
             imgIndex = SpritePreviewer.PlayNextFrame(imgIndex, imageYIndexTextBox, imageXIndexTextBox, frameCount,
                                                      SpritesPerRowTextBox, ImageFileNameTextBox, SpritesPerColumnTextBox, Test_Img);
         });
         System.Threading.Thread.Sleep(duration);
     }
 }
        /// <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;
            }
        }