public void RemoveFile(Uri path, out String consoleOutput) { VectorFile file = null; foreach (VectorFile f in currentSettings.Files) { if (f.FilePath.Equals(path)) { file = f; } } if (file != null) { currentSettings.Files.Remove(file); nodeStore.RemoveNode(file); consoleOutput = "File removed."; } else { consoleOutput = "Could not remove file: File has not been added to this configuration."; } }
public void AddFile(Uri path, String name, out String consoleOutput) { VectorFile toAdd = new VectorFile(); toAdd.FilePath = path; toAdd.Name = name; String absolutePath = new Uri(currentSettings.FileLocation, path).AbsolutePath; if (File.Exists(absolutePath)) { //Check if this FileInfo newFile = new FileInfo(absolutePath); bool alreadyExists = false; foreach (VectorFile f in currentSettings.Files) { if (newFile.FullName.Equals(new FileInfo(new Uri(currentSettings.FileLocation, f.FilePath).AbsolutePath).FullName)) { alreadyExists = true; } } if (alreadyExists) { consoleOutput = "Could not add file: Already listed."; } else { consoleOutput = "Added file."; currentSettings.Files.Add(toAdd); nodeStore.AddNode(toAdd); } } else { consoleOutput = "Could not add file: Does not exist at " + absolutePath; } }
public void Export(VectorFile f, out String output) { output = ""; String[] split = f.Options.Split(' '); String args = ""; foreach (String o in split) { if (o.Length != 0) { args += " " + o; } } String[] globalSplit = Settings.GlobalOptions.Split(' '); foreach (String o in globalSplit) { if (o.Length != 0) { args += " " + o; } } String outfileStart = " -outfile \"" + new Uri(Settings.FileLocation, Settings.ExportDirectory).AbsolutePath + "/"; String outfileEnd = f.Name + ".png" + "\""; String file = " \"" + new Uri(Settings.FileLocation, f.FilePath).AbsolutePath + "\""; List <String> execList = new List <String> (); if (f.ExportColorArt) { execList.Add(args + outfileStart + "color_" + outfileEnd + " -nolineart" + file); } if (f.ExportLineArt) { execList.Add(args + outfileStart + "line_" + outfileEnd + " -nocolorart" + file); } if (f.ExportMerged) { execList.Add(args + outfileStart + outfileEnd + file); } foreach (String execArgs in execList) { Process p = new Process(); ProcessStartInfo pci = new ProcessStartInfo(cfgController.config.ToonBoomDirectoryLocation + "/utransform.exe", execArgs); output += "Executing: " + cfgController.config.ToonBoomDirectoryLocation + "/utransform.exe " + execArgs + "\n"; pci.RedirectStandardOutput = true; pci.RedirectStandardError = true; pci.CreateNoWindow = true; pci.UseShellExecute = false; p.StartInfo = pci; String asyncOut = ""; p.OutputDataReceived += (object sender, DataReceivedEventArgs e) => asyncOut += e.Data + "\n"; p.ErrorDataReceived += (object sender, DataReceivedEventArgs e) => asyncOut += e.Data + "\n"; p.Start(); p.BeginOutputReadLine(); p.BeginErrorReadLine(); p.WaitForExit(); output += asyncOut; } }