//------------------------------------
        private void loadTextures()
        {
            if (m_atlasTextureDirectory == null || m_atlasTextureDirectory == string.Empty)
            {
                MessageBox.Show("Invalid texture directory, textures will not be loaded");
                return;
            }

            //get all json files in directory
            var files = Directory.GetFiles(m_atlasTextureDirectory);
            files = filterJson(files);
            if(files.Length < 1)
            {
                MessageBox.Show("No json files were found in texture directory.");
                return;
            }
            
            //for each file parse into sprite sheet object
            m_spriteSheets.Clear();
            foreach(string file in files)
            {
                loadFile(file);
            }

            //for each sprite sheet load image and cut into frames
            foreach(SpriteSheet s in m_spriteSheets)
            {
                string imagePath = m_atlasTextureDirectory + "\\" + s.meta.image;
                if(File.Exists(imagePath))
                {
                    var ext = Path.GetExtension(imagePath);
                    if(ext != ".png" && ext != ".jpg")
                    {
                        MessageBox.Show(ext + "\n File format not supported. Please use .png or .jpg");
                        return;
                    }

                    Bitmap bitmap = (Bitmap)Bitmap.FromFile(imagePath);
                    foreach(Frame frame in s.frames)
                    {
                        Rectangle subrect = new Rectangle(frame.frame.x, frame.frame.y, frame.frame.w, frame.frame.h);
                        if(frame.rotated) //width and height are swapped!!
                        {
                            var i = subrect.Width;
                            subrect.Width = subrect.Height;
                            subrect.Height = i;
                        }

                        //save the frame data as a subrect for sfml sprites
                        frame.subrect = new SFML.Graphics.IntRect(subrect.Left, subrect.Top, subrect.Width, subrect.Height);

                        try
                        {
                            frame.largeImage = bitmap.Clone(subrect, bitmap.PixelFormat);
                            if (frame.rotated)
                            {
                                frame.largeImage.RotateFlip(RotateFlipType.Rotate270FlipNone);
                            }
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message + "\nAre you trying to create a sub image which is out of bounds?", "Cropping Sprite Sheet");
                        }
                        frame.smallImage = new Bitmap(frame.largeImage, new System.Drawing.Size(frame.largeImage.Size.Width / 2, frame.largeImage.Size.Height / 2));
                        frame.parentSheet = s;
                    }
                }
                else
                {
                    MessageBox.Show(imagePath + "\nFile Not Found");
                    return;
                }

                if (m_spriteSheets.Count > 0 && m_spriteSheets[0].frames.Count > 0) 
                    m_selectedFrame = m_spriteSheets[0].frames[0];
            }
        }
 private void selectFrame(string spriteSheet, string frameName)
 {
     foreach(SpriteSheet ss in m_spriteSheets)
     {
         if(ss.meta.image == spriteSheet)
         {
             foreach(Frame f in ss.frames)
             {
                 if(f.filename == frameName)
                 {
                     m_selectedFrame = f;
                     return;
                 }
             }
         }
     }
 }