public void Load() { var image = this.LoadImage(); var pixelColors = image.CopyPixels(); var pixelsSource = PixelsSource.FromPixelColors(pixelColors); var dialogViewModel = new DialogViewModel(); Texture outputTexture = null; dialogViewModel.AddTask ( (taskContext) => { try { taskContext.UpdateMessage("Trying to load file."); var textureProfile = this.LoadTextureProfile(pixelsSource); outputTexture = new Texture(image, textureProfile); } catch (Exception ex) { taskContext.UpdateMessage($"Error loading file: {ex.Message}"); return; } taskContext.UpdateProgress(100); } ); this.windowManager.ShowDialog(dialogViewModel); this.OutputTexture = outputTexture; this.TryClose(this.OutputTexture != null); }
public void SaveTextureProfile(string outputFile) { if (!this.CanWriteTextureProfile || this.dialogViewModel != null) { return; } this.dialogViewModel = new DialogViewModel(); bool success = true; this.dialogViewModel.AddTask ( (taskContext) => { try { new TextureProfileWriter().SaveTextureProfile(outputFile, this.texture.GetTextureProfile()); } catch (Exception ex) { taskContext.UpdateMessage($"Error writing texture profile: {ex.Message}"); success = false; } taskContext.UpdateProgress(100); } ); this.windowManager.ShowDialog(this.dialogViewModel); this.dialogViewModel = null; if (success) { this.SavedFile = outputFile; this.TryClose(true); } }
public void SaveSourceTexture(string outputFile) { if (string.IsNullOrEmpty(outputFile) || this.dialogViewModel != null || this.sourceTexture == null) { return; } this.dialogViewModel = new DialogViewModel(); this.dialogViewModel.AddTask ( (taskContext) => { try { new TextureProfileWriter().SaveTextureProfile(outputFile, this.sourceTexture.Model.GetTextureProfile()); } catch (Exception ex) { taskContext.UpdateMessage($"Error writing texture profile: {ex.Message}"); } taskContext.UpdateProgress(100); } ); this.windowManager.ShowDialog(this.dialogViewModel); this.dialogViewModel = null; }
public void LoadModel(string fileName) { var dialogViewModel = new DialogViewModel(); HelixToolkitScene scene = null; dialogViewModel.AddTask ( (taskContext) => { taskContext.UpdateMessage($"Loading model {Path.GetFileNameWithoutExtension(fileName)}"); var loader = new Importer(); scene = loader.Load(fileName); taskContext.UpdateProgress(100); } ); this.windowManager.ShowDialog(dialogViewModel); GroupModel.Clear(); if (scene != null) { this.sceneNode = scene.Root; GroupModel.AddNode(this.sceneNode); this.SetSceneMaterials(); } }
public void GenerateTextureProfile() { if (this.transparencyColor == null || this.dialogViewModel != null) { return; } var textureProcessor = new TextureProcessor(); this.dialogViewModel = new DialogViewModel(); var pixelColors = this.sourceImage.CopyPixels(); TextureProfile textureProfile = null; this.dialogViewModel.AddTask ( async(taskContext) => { textureProfile = await textureProcessor.GenerateTextureProfileAsync(pixelColors, this.transparencyColor, this.dialogViewModel, taskContext); } ); this.windowManager.ShowDialog(this.dialogViewModel); this.dialogViewModel = null; this.Texture = new Texture(this.originalSource, textureProfile); this.DrawTextureOnOutput(); }