public TexturePreviewController(string imagePath, TexturePreviewViewModel viewModel, PackFileService packFileService)
        {
            _imagePath       = imagePath;
            _viewModel       = viewModel;
            _packFileService = packFileService;

            _scene = new SceneContainer();
            _scene.Components.Add(new ResourceLibary(_scene, packFileService));
            _scene.ForceCreate();


            _resourceLib     = _scene.GetComponent <ResourceLibary>();
            _textureRenderer = new TextureToTextureRenderer(_scene.GraphicsDevice, new SpriteBatch(_scene.GraphicsDevice), _resourceLib);
            CreateImage();
        }
        public static void CreateVindow(string imagePath, PackFileService packFileService)
        {
            TexturePreviewViewModel viewModel = new TexturePreviewViewModel()
            {
                Format = "DDS0",
                Name   = imagePath,
                //Height = 512,
                //Width = 1024,
            };

            using (var controller = new TexturePreviewController(imagePath, viewModel, packFileService))
            {
                var containingWindow = new Window();
                containingWindow.Title   = "Texture Preview Window";
                containingWindow.Content = new TexturePreviewView()
                {
                    DataContext = viewModel
                };
                containingWindow.ShowDialog();
            }
        }
        void DisplayTexture(TexureType type, string path)
        {
            try
            {
                var img    = LoadTextureAsTexture2d(path);
                var wpfImg = ImageToBitmap(img);
                var ff     = BitmapToImageSource(wpfImg);
                TexturePreviewView view = new TexturePreviewView();
                var dataContext         = new TexturePreviewViewModel()
                {
                    Format = "DDS0",
                    Name   = "MyTestImage.png",
                    Height = 512,
                    Width  = 1024
                };
                view.DataContext = dataContext;
                var w = new Window();

                w.Title = "Texture Preview Window";

                /*var bitmap = new Bitmap(dataContext.Width, dataContext.Height);
                 * using (Graphics gfx = Graphics.FromImage(bitmap))
                 * using (SolidBrush brush = new SolidBrush(System.Drawing.Color.FromArgb(255, 0, 0)))
                 * {
                 *  gfx.FillRectangle(brush, 0, 0, dataContext.Width, dataContext.Height);
                 * }*/
                dataContext.Image = ff;
                w.Content         = view;
                w.ShowDialog();
            }
            catch (Exception e)
            {
            }
            return;

            /*Texture2D t = _resourceLibary.LoadTexture(path, null);
             * Microsoft.Xna.Framework.Color[] colorArray = new Microsoft.Xna.Framework.Color[t.Width * t.Height];
             * try
             * {
             *   t.GetData(0, new Microsoft.Xna.Framework.Rectangle(0,0, t.Width, t.Height), colorArray, 0, t.Width * t.Height);
             * }
             * catch (Exception e)
             * { }*/

            return;

            /* TexturePreviewView view = new TexturePreviewView();
             * var dataContext = new TexturePreviewViewModel()
             * {
             *   Format = "DDS0",
             *   Name = "MyTestImage.png",
             *   Height = 512,
             *   Width = 1024
             * };
             * view.DataContext = dataContext;
             * var w = new Window();
             * w.Title = "Texture Preview Window";
             *
             * var bitmap = new Bitmap(dataContext.Width, dataContext.Height);
             * using (Graphics gfx = Graphics.FromImage(bitmap))
             * using (SolidBrush brush = new SolidBrush(System.Drawing.Color.FromArgb(255, 0, 0)))
             * {
             *   gfx.FillRectangle(brush, 0, 0, dataContext.Width, dataContext.Height);
             * }
             * dataContext.Image = BitmapToImageSource(bitmap);
             * w.Content = view;
             * w.ShowDialog();*/
        }