public void UseTexture(bool value, TexureType type) { if (_useTextures.ContainsKey(type)) { _useTextures[type].SetValue(value); } }
public void SetTexture(Texture2D texture, TexureType type) { if (_textures.ContainsKey(type)) { _textures[type].SetValue(texture); } }
public TextureViewModel(Rmv2MeshNode meshNode, PackFileService packfileService, TexureType texureType) { _packfileService = packfileService; _meshNode = meshNode; _texureType = texureType; Path = _meshNode.MeshModel.GetTexture(texureType)?.Path; PreviewCommand = new RelayCommand(() => TexturePreviewController.CreateVindow(Path, _packfileService)); BrowseCommand = new RelayCommand(BrowseTexture); RemoveCommand = new RelayCommand(RemoveTexture); }
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();*/ }