private void ConvertImagesClick(object sender, RoutedEventArgs e) { string outputPath = "output/"; outputPath = ImageTools.openDirectorySelectDialog("Conversion Export Folder"); if (string.IsNullOrEmpty(outputPath) || !Directory.Exists(outputPath)) { return; } foreach (TextureConversionEntry entry in MainWindow.instance.ConvertRecords) { string inputName = entry.ImageName; string outputName = outputPath + "/" + inputName.Substring(inputName.LastIndexOf("\\") + 1);//output/xxx.png outputName = outputName.Substring(0, outputName.Length - 4) + ".dds"; Process process = new Process(); process.StartInfo.FileName = "nvdxt.exe"; int format = entry.Format == "DXT1" ? 1 : entry.Format == "DXT5" ? 5 : 6; process.StartInfo.Arguments = getDDSCommand(inputName, outputName, format); process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = false; process.Start(); process.WaitForExit(); process.Close(); } MainWindow.instance.ConvertRecords.Clear(); }
private void loadCommands() { Predicate <object> canAddImage = (a) => true; Action <object> addImage = (a) => { string img1 = ImageTools.openFileSelectDialog("Primary Texture"); string img2 = ImageTools.openFileSelectDialog("Second Texture"); TextureCombineEntry entry = new TextureCombineEntry(); entry.Image1Path = img1; entry.Image2Path = img2; TextureEntries.Add(entry); ConvertBatchCommand.FireCanExecuteChanged(); }; AddImageCommand = new CommandBase <object>(canAddImage, addImage); Predicate <object> canDeleteImage = (a) => SelectedEntries.Count > 0; Action <object> deleteImage = (a) => { ConvertBatchCommand.FireCanExecuteChanged(); }; DeleteImageCommand = new CommandBase <object>(canDeleteImage, deleteImage); Predicate <object> canSelectFolder = (a) => true; Action <object> selectFolder = (a) => { string outputPath = "output/"; outputPath = ImageTools.openDirectorySelectDialog("Conversion Export Folder"); ExportFolderPath = outputPath; ConvertBatchCommand.FireCanExecuteChanged(); }; SelectFolderCommand = new CommandBase <object>(canSelectFolder, selectFolder); Predicate <object> canConvertbatch = (a) => true;// TextureEntries.Count > 0 && !string.IsNullOrEmpty(exportFolderPath); Action <object> convertBatch = (a) => { foreach (TextureCombineEntry entry in TextureEntries) { entry.performConversion(ExportFolderPath); } }; ConvertBatchCommand = new CommandBase <object>(canConvertbatch, convertBatch); Predicate <object> canSetToAO = (a) => true; Action <object> setToAO = (a) => { }; SetSelectedToAOCombineCommand = new CommandBase <object>(canSetToAO, setToAO); }