private void copyStorySceneCameras(CStorySceneSection storysection) { var CStoryScene = DestinationFile.GetChunkByType("CStoryScene"); var cameraInstances = (CArray)CStoryScene.GetVariableByName("cameraDefinitions"); var CStorySceneSource = SourceFile.GetChunkByType("CStoryScene"); var cameraInstancesSource = (CArray)CStorySceneSource.GetVariableByName("cameraDefinitions"); foreach (var e in storysection.sceneEventElements) { if (e != null && e is CVector && e.Type == "CStorySceneEventCustomCameraInstance") { var v = (CVector)e; var n = v.GetVariableByName("customCameraName") as CName; if (n != null) { var camera = findCameraInstance(cameraInstances, n.Value); // Doesn't exist yet, copy from source if (camera == null) { var sourceCamera = findCameraInstance(cameraInstancesSource, n.Value); if (sourceCamera != null) { cameraInstances.AddVariable(sourceCamera.Copy(this)); } } } } } }
public ActionResult AddFile(int id, HttpPostedFileBase upload) { if (upload.ContentLength > 0) { var model = new DestinationFile(); model.DestinationID = id; model.Nom = upload.FileName; model.TypeContenu = upload.ContentType; using (var reader = new BinaryReader(upload.InputStream)) { model.Contenu = reader.ReadBytes(upload.ContentLength); } db.DestinationFiles.Add(model); db.SaveChanges(); return(RedirectToAction("Edit", new { id = model.DestinationID })); } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }
private void copyDialogset(CStorySceneSection storysection) { // see if it has a change dialog set property var dlgset = storysection.GetVariableByName("dialogsetChangeTo") as CName; if (dlgset != null) { // see if we already have a dialog set with this name var destdlgset = findDialogset(DestinationFile, dlgset.Value); if (destdlgset == null) { // we dont so find the one in the source and copy it. var srcdlgset = findDialogset(SourceFile, dlgset.Value); if (srcdlgset != null) { var CStoryScene = DestinationFile.GetChunkByType("CStoryScene"); var dialogsetInstances = (CArray)CStoryScene.GetVariableByName("dialogsetInstances"); var copieddialogset = srcdlgset.Copy(this); DestinationFile.CreatePtr(dialogsetInstances, copieddialogset); var placementTag = (CTagList)copieddialogset.GetVariableByName("placementTag"); placementTag.tags.Clear(); placementTag.tags.Add((CName)DestinationFile.CreateVariable("CName").SetValue("PLAYER")); } } } }
protected static bool DeleteExistingFileIfNecessary(DestinationFile destination, ArgumentOptionCollection optionCollection, ILogger logger) { try { if (File.Exists(destination.Path)) { if (optionCollection.AllowDestinationOverwrite) { File.Delete(destination.Path); logger.WriteLog($"A destination image {destination.Path} has existed so been deleted.", LogLevel.Warn); } else { logger.WriteLog($"A destination image {destination.Path} has existed.", LogLevel.Error); return(false); } } } catch (Exception e) { logger.WriteLog($"Cannot convert an image: {e.Message}", LogLevel.Error); return(false); } return(true); }
public ActionResult AddFile(int id, HttpPostedFileBase upload) { if (upload == null) { TempData["Message"] = "Aucun fichier selectionné"; return(RedirectToAction("Edit", new { id })); } if (upload.ContentLength > 0) { var model = new DestinationFile(); model.DestinationID = id; model.Name = upload.FileName; model.ContentType = upload.ContentType; using (var reader = new BinaryReader(upload.InputStream)) { model.Content = reader.ReadBytes(upload.ContentLength); } db.DestinationFiles.Add(model); db.SaveChanges(); TempData["Message"] = "Fichier ajouté"; return(RedirectToAction("Edit", new { id = model.DestinationID })); } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }
public ActionResult DeleteFile(int id) { DestinationFile file = db.DestinationFiles.Find(id); db.DestinationFiles.Remove(file); db.SaveChanges(); TempData["Message"] = "Fichier supprimé"; return(RedirectToAction("Edit", new { id = file.DestinationID })); }
protected override IEnumerable <DestinationFile> ConvertApplicableImageThenSave( SourceFile source, ImageFileKind destinationKind, ArgumentOptionCollection optionCollection, ILogger logger) { var savedImageFiles = new List <DestinationFile>(); try { using (var powerPointApplication = new PowerPointApplication(new Application())) { var application = powerPointApplication.Application; var presentation = application.Presentations; using (var presenationFile = new PowerPointPresentation(presentation.Open( FileName: source.Path, ReadOnly: MsoTriState.msoTrue, Untitled: MsoTriState.msoTrue, WithWindow: MsoTriState.msoTrue))) { var file = presenationFile.Presentation; foreach (var slide in EnumeratePowerPointSlides(file)) { if (!optionCollection.PowerpointPageRange.Contains((uint)slide.SlideNumber)) { continue; } slide.Select(); slide.Shapes.SelectAll(); var selection = application.ActiveWindow.Selection; var shapes = selection.ShapeRange; var destinationPathForSlide = $"{Path.GetDirectoryName(source.Path)}\\{Path.GetFileNameWithoutExtension(source.Path)}{slide.SlideNumber}{destinationKind.GetExtensionWithDot()}"; var destinationForSlide = new DestinationFile(destinationPathForSlide); if (!DeleteExistingFileIfNecessary(destinationForSlide, optionCollection, logger)) { continue; } //create emf shapes.Export(destinationForSlide.Path, PpShapeFormat.ppShapeFormatEMF); savedImageFiles.Add(destinationForSlide); } } } } catch (Exception e) { logger.WriteLog($"Failed to convert powerpoint slide to emf images: {e.Message}\n{e.StackTrace}", LogLevel.Error); } return(savedImageFiles); }
public bool Execute() { string src = SourceFile.GetMetadata("FullPath"); string dest = (DestinationFile?.GetMetadata("FullPath") ?? Path.Combine(Path.GetDirectoryName(BuildEngine.ProjectFileOfTaskNode), "appsettings.json")); foreach (string path in JPath.Split(new char[] { ';', ',' }, System.StringSplitOptions.RemoveEmptyEntries)) { Json.CopyJsonProperty(src, dest, path); BuildEngine.Info($"Copied '{path}' property to '{Path.GetFileName(dest)}'"); } return(true); }
public bool Execute() { Enum.TryParse(OutputType, out FileType kind); var options = new TypescriptGeneratorSettings(Namespace, Prefix, Suffix, AsAbstract, (kind == FileType.KnockoutJs), References); if (_sourceFiles == null) { _sourceFiles = SourceFiles.Select(x => x.GetMetadata("FullPath")).ToArray(); } BuildEngine.Debug("Generating typescript models ..."); foreach (string filePath in _sourceFiles) { BuildEngine.Debug($"src: '{filePath}'"); } byte[] data; switch (kind) { default: case FileType.Model: data = TypescriptGenerator.Emit(options, _sourceFiles); break; case FileType.KnockoutJs: data = KnockoutJsGenerator.Emit(options, _sourceFiles); break; case FileType.Declaration: data = DeclarationFileGenerator.Emit(options, _sourceFiles); break; } if (string.IsNullOrEmpty(_outputFile)) { _outputFile = DestinationFile.GetMetadata("FullPath"); } string folder = Path.GetDirectoryName(_outputFile); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } File.WriteAllBytes(_outputFile, data); BuildEngine.Info($"Generated typescript file at '{_outputFile}'.", nameof(GenerateTypescriptModels)); return(true); }
protected override bool SkipTaskExecution() { //Debugger.Launch(); var ct = DestinationFile.GetMetadata("ModifiedTime"); if (string.IsNullOrEmpty(ct)) { return(false); } DateTime ctt = DateTime.Parse(ct); var pt = ProtoFile.GetMetadata("ModifiedTime"); DateTime ptt = DateTime.Parse(pt); if (ctt > ptt) { return(true); } return(false); }
private static void BackupToDestinationDirectory( SourceFile sf, string baseDir, DestinationDirectory dd, string dateFolder, CancellationToken cancellationToken) { try { var lastWrittenTimeUtc = File.GetLastWriteTimeUtc(sf.PathName); if (sf.ContentHash == null || lastWrittenTimeUtc != sf.LastWrittenTimeUtc) { sf.ContentHash = HashCalculator.GetContentHash(sf.PathName); sf.LastWrittenTimeUtc = lastWrittenTimeUtc; } var df = dd.DestinationFiles.SingleOrDefault(f => f.SourceFileId == sf.SourceFileId); var createnew = df == null; if (createnew || df.ContentHash != sf.ContentHash || !File.Exists(df.PathName)) { string destPathName = CopyToDestinationFile( dd.PathName, baseDir, dateFolder, sf.PathName, cancellationToken); if (!cancellationToken.IsCancellationRequested) { if (createnew) { df = new DestinationFile { SourceFileId = sf.SourceFileId, }; dd.DestinationFiles.Add(df); } df.PathName = destPathName; df.ContentHash = sf.ContentHash; dd.Copied += 1; } } } catch (Exception ex) { dd.CopyFailures.Add(new CopyFailure { SourceFileId = sf.SourceFileId, ErrorMessage = ex.Message }); } }
private void CleanFile() { List <string> fileToRemove = new List <string>(); if (DestinationFile != null) { fileToRemove.Add(DestinationFile.GetFullPath()); } fileToRemove = fileToRemove.Union(BuildOutput).Union(BuildAsset).ToList(); foreach (string file in fileToRemove) { if (File.Exists(file)) { if (!Program.Arguments.Quiet) { Console.WriteLine($"Cleaning file: {file}"); } File.Delete(file); } } }
/// <summary> /// This is where the work is done /// </summary> protected override void ExecuteTask() { try { //set the timestamp to the file date. DateTime fileTimeStamp = new DateTime(); if (UseTimeStamp && DestinationFile.Exists) { fileTimeStamp = DestinationFile.LastWriteTime; Log(Level.Verbose, "Local file time stamp is {0}.", fileTimeStamp.ToString(CultureInfo.InvariantCulture)); } //set up the URL connection WebRequest webRequest = GetWebRequest(Source, fileTimeStamp); WebResponse webResponse = webRequest.GetResponse(); Stream responseStream = null; // Get stream // try three times, then error out int tryCount = 1; while (true) { try { responseStream = webResponse.GetResponseStream(); break; } catch (IOException ex) { if (tryCount > 3) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("NA1125"), Source, DestinationFile.FullName), Location); } else { Log(Level.Warning, "Unable to open connection to '{0}' (try {1} of 3): " + ex.Message, Source, tryCount); } } // increment try count tryCount++; } // open file for writing BinaryWriter destWriter = new BinaryWriter(new FileStream( DestinationFile.FullName, FileMode.Create)); Log(Level.Info, "Retrieving '{0}' to '{1}'.", Source, DestinationFile.FullName); // Read in stream from URL and write data in chunks // to the dest file. int bufferSize = 100 * 1024; byte[] buffer = new byte[bufferSize]; int totalReadCount = 0; int totalBytesReadFromStream = 0; int totalBytesReadSinceLastDot = 0; do { totalReadCount = responseStream.Read(buffer, 0, bufferSize); if (totalReadCount != 0) // zero means EOF // write buffer into file { destWriter.Write(buffer, 0, totalReadCount); // increment byte counters totalBytesReadFromStream += totalReadCount; totalBytesReadSinceLastDot += totalReadCount; // display progress if (Verbose && totalBytesReadSinceLastDot > bufferSize) { if (totalBytesReadSinceLastDot == totalBytesReadFromStream) { // TO-DO !!!! //Log.Write(LogPrefix); } // TO-DO !!! //Log.Write("."); totalBytesReadSinceLastDot = 0; } } } while (totalReadCount != 0); if (totalBytesReadFromStream > bufferSize) { Log(Level.Verbose, ""); } Log(Level.Verbose, "Number of bytes read: {0}.", totalBytesReadFromStream.ToString(CultureInfo.InvariantCulture)); // clean up response streams destWriter.Close(); responseStream.Close(); // refresh file info DestinationFile.Refresh(); // check to see if we actually have a file... if (!DestinationFile.Exists) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("NA1125"), Source, DestinationFile.FullName), Location); } // if (and only if) the use file time option is set, then the // saved file now has its timestamp set to that of the downloaded file if (UseTimeStamp) { // HTTP only if (webRequest is HttpWebRequest) { HttpWebResponse httpResponse = (HttpWebResponse)webResponse; // get timestamp of remote file DateTime remoteTimestamp = httpResponse.LastModified; Log(Level.Verbose, "'{0}' last modified on {1}.", Source, remoteTimestamp.ToString(CultureInfo.InvariantCulture)); // update timestamp of local file to match that of the // remote file TouchFile(DestinationFile, remoteTimestamp); } } } catch (BuildException) { // re-throw the exception throw; } catch (WebException ex) { // If status is WebExceptionStatus.ProtocolError, // there has been a protocol error and a WebResponse // should exist. Display the protocol error. if (ex.Status == WebExceptionStatus.ProtocolError) { // test for a 304 result (HTTP only) // Get HttpWebResponse so we can check the HTTP status code HttpWebResponse httpResponse = (HttpWebResponse)ex.Response; if (httpResponse.StatusCode == HttpStatusCode.NotModified) { //not modified so no file download. just return instead //and trace out something so the user doesn't think that the //download happened when it didn't Log(Level.Verbose, "'{0}' not downloaded. Not modified since {1}.", Source, DestinationFile.LastWriteTime.ToString(CultureInfo.InvariantCulture)); return; } else { throw new BuildException(string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("NA1125"), Source, DestinationFile.FullName), Location, ex); } } else { throw new BuildException(string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("NA1125"), Source, DestinationFile.FullName), Location, ex); } } catch (Exception ex) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("NA1125"), Source, DestinationFile.FullName), Location, ex); } }
private void CopyShape() { ShapeListEntry Shape = new ShapeListEntry();; String ImageFile; String DestinationFile; int index; bool Continue; //Check if a file and a shape are selected if (lstFiles.SelectedIndex == -1 && lstShapes.SelectedIndex == -1) { MessageBox.Show("A file and a shape must be selected.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } //Get the selected items; ImageFile = "D:\\OCR\\Images\\" + lstFiles.SelectedItem; Shape = (ShapeListEntry)lstShapes.SelectedItem; //Determine a new file name for the target file DirectoryInfo di = new DirectoryInfo(Shape.SampleFolder + "\\"); FileInfo[] Files = di.GetFiles("*.bmp"); index = 1; do { Continue = false; DestinationFile = "00000000" + Convert.ToString(index); DestinationFile = DestinationFile.Substring(DestinationFile.Length - 8); DestinationFile += ".bmp"; foreach (FileInfo File in Files) { if (File.Name == DestinationFile) { Continue = true; } } index++; } while (Continue); //Copy the file DestinationFile = Shape.SampleFolder + "\\" + DestinationFile; System.IO.File.Copy(ImageFile, DestinationFile, true); //Remove the file from the filelist. object SelectedItem; SelectedItem = lstFiles.SelectedItem; lstFiles.SelectedIndex++; lstFiles.Items.Remove(SelectedItem); //Delete the original file try { System.IO.File.Delete(ImageFile); } catch (Exception e) { Console.WriteLine("Exception caught: " + e.Message); Console.WriteLine(" In: " + e.StackTrace); } }
private CR2WExportWrapper CopyChunk(CR2WExportWrapper chunk) { if (ExcludeChunks != null && ExcludeChunks.Contains(chunk.Type)) { return(null); } var chunkcopy = chunk.Copy(this); if (chunkcopy != null) { if (chunkcopy.data is CStorySceneSection) { OnCopyStorySceneSection(chunkcopy); } var CStoryScene = DestinationFile.GetChunkByType("CStoryScene"); if (CStoryScene != null) { var controlParts = CStoryScene.GetVariableByName("controlParts") as CArray; // Add this chunk to the controlParts if (controlParts != null) { switch (chunkcopy.Type) { case "CStorySceneInput": case "CStorySceneScript": case "CStorySceneFlowCondition": case "CStorySceneSection": case "CStorySceneCutsceneSection": case "CStorySceneVideoSection": case "CStorySceneRandomizer": case "CStorySceneOutput": case "CStorySceneCutscenePlayer": DestinationFile.CreatePtr(controlParts, chunkcopy); break; default: break; } } var sections = CStoryScene.GetVariableByName("sections") as CArray; // Add this chunk to the sections if (sections != null) { switch (chunkcopy.Type) { case "CStorySceneSection": case "CStorySceneCutsceneSection": case "CStorySceneVideoSection": DestinationFile.CreatePtr(sections, chunkcopy); break; default: break; } } } } return(chunkcopy); }
public void BuildContent() { try { Assets assets = new Assets(SourceFile); string relativePath = SourceFile.Replace(Program.Arguments.WorkingDirectory, "").Trim('/', '\\'); string relativePathWithoutExtension = relativePath.Contains(".") ? relativePath.Remove(relativePath.LastIndexOf('.')) : relativePath; string relativeDirWithoutExtension = relativePath.Contains("/") || relativePath.Contains("\\") ? relativePath.Remove(relativePath.LastIndexOfAny(new char[] { '/', '\\' })) : ""; string tempImporter = null; string tempProcessor = null; Dictionary <string, string> tempProcessorParam = new Dictionary <string, string>(); if (!FirstBuild) { tempImporter = Importer; tempProcessor = Processor; tempProcessorParam.Union(ProcessorParam); ProcessorParam.Clear(); if (!File.Exists(SourceFile)) { DeleteFlag = true; } else if (!BuildTool.Equals(Program.Arguments.BuildTool.ToString(), StringComparison.OrdinalIgnoreCase)) { BuildTool = Program.Arguments.BuildTool.ToString(); RebuildFlag = true; } else { string newHash; using (FileStream fileStream = new FileStream(SourceFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) newHash = fileStream.ToMD5(); if (!MetaHash.Equals(newHash, StringComparison.OrdinalIgnoreCase)) { MetaHash = newHash; RebuildFlag = true; } else { List <string> fileToCheck = new List <string>(); if (DestinationFile != null) { fileToCheck.Add(DestinationFile.GetFullPath()); } fileToCheck = fileToCheck.Union(BuildOutput).Union(BuildAsset).ToList(); foreach (string file in fileToCheck) { if (!File.Exists(file)) { RebuildFlag = true; break; } } } } } else { using (FileStream fileStream = new FileStream(SourceFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) MetaHash = fileStream.ToMD5(); } #if MonoGame if (assets.IsEffectAssets()) { // Effect Importer - MonoGame string temp; using (StreamReader reader = new StreamReader(new FileStream(SourceFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.UTF8)) temp = reader.ReadToEnd(); temp = temp.Replace("vs_1_1", Program.Arguments.Platform.Equals("DesktopGL", StringComparison.OrdinalIgnoreCase) ? "vs_2_0" : "vs_4_0"); temp = temp.Replace("vs_2_0", Program.Arguments.Platform.Equals("DesktopGL", StringComparison.OrdinalIgnoreCase) ? "vs_2_0" : "vs_4_0"); temp = temp.Replace("vs_4_0", Program.Arguments.Platform.Equals("DesktopGL", StringComparison.OrdinalIgnoreCase) ? "vs_2_0" : "vs_4_0"); temp = temp.Replace("ps_1_1", Program.Arguments.Platform.Equals("DesktopGL", StringComparison.OrdinalIgnoreCase) ? "ps_2_0" : "ps_4_0"); temp = temp.Replace("ps_2_0", Program.Arguments.Platform.Equals("DesktopGL", StringComparison.OrdinalIgnoreCase) ? "ps_2_0" : "ps_4_0"); temp = temp.Replace("ps_4_0", Program.Arguments.Platform.Equals("DesktopGL", StringComparison.OrdinalIgnoreCase) ? "ps_2_0" : "ps_4_0"); using (StreamWriter Writer = new StreamWriter(new FileStream(SourceFile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite), Encoding.UTF8) { AutoFlush = true }) Writer.Write(temp); temp = null; Importer = "EffectImporter"; Processor = "EffectProcessor"; ProcessorParam.Add("DebugMode", "Auto"); } else if (assets.IsFbxModelAssets()) { // Fbx Importer - MonoGame Importer = "FbxImporter"; Processor = "ModelProcessor"; ProcessorParam.Add("ColorKeyColor", "0,0,0,0"); ProcessorParam.Add("ColorKeyEnabled", "True"); ProcessorParam.Add("DefaultEffect", "BasicEffect"); ProcessorParam.Add("GenerateMipmaps", "True"); ProcessorParam.Add("GenerateTangentFrames", "False"); ProcessorParam.Add("PremultiplyTextureAlpha", "True"); ProcessorParam.Add("PremultiplyVertexColors", "True"); ProcessorParam.Add("ResizeTexturesToPowerOfTwo", "False"); ProcessorParam.Add("RotationX", "0"); ProcessorParam.Add("RotationY", "0"); ProcessorParam.Add("RotationZ", "0"); ProcessorParam.Add("Scale", "1"); ProcessorParam.Add("SwapWindingOrder", "False"); ProcessorParam.Add("TextureFormat", "Color"); } else if (assets.IsXModelAssets()) { // X Importer - MonoGame Importer = "XImporter"; Processor = "ModelProcessor"; ProcessorParam.Add("ColorKeyColor", "0,0,0,0"); ProcessorParam.Add("ColorKeyEnabled", "True"); ProcessorParam.Add("DefaultEffect", "BasicEffect"); ProcessorParam.Add("GenerateMipmaps", "True"); ProcessorParam.Add("GenerateTangentFrames", "False"); ProcessorParam.Add("PremultiplyTextureAlpha", "True"); ProcessorParam.Add("PremultiplyVertexColors", "True"); ProcessorParam.Add("ResizeTexturesToPowerOfTwo", "False"); ProcessorParam.Add("RotationX", "0"); ProcessorParam.Add("RotationY", "0"); ProcessorParam.Add("RotationZ", "0"); ProcessorParam.Add("Scale", "1"); ProcessorParam.Add("SwapWindingOrder", "False"); ProcessorParam.Add("TextureFormat", "Color"); } else if (assets.IsOpenModelAssets()) { // Open Asset Import Library - MonoGame Importer = "OpenAssetImporter"; Processor = "ModelProcessor"; ProcessorParam.Add("ColorKeyColor", "0,0,0,0"); ProcessorParam.Add("ColorKeyEnabled", "True"); ProcessorParam.Add("DefaultEffect", "BasicEffect"); ProcessorParam.Add("GenerateMipmaps", "True"); ProcessorParam.Add("GenerateTangentFrames", "False"); ProcessorParam.Add("PremultiplyTextureAlpha", "True"); ProcessorParam.Add("PremultiplyVertexColors", "True"); ProcessorParam.Add("ResizeTexturesToPowerOfTwo", "False"); ProcessorParam.Add("RotationX", "0"); ProcessorParam.Add("RotationY", "0"); ProcessorParam.Add("RotationZ", "0"); ProcessorParam.Add("Scale", "1"); ProcessorParam.Add("SwapWindingOrder", "False"); ProcessorParam.Add("TextureFormat", "Color"); } else if (assets.IsSpriteFontAssets()) { // Sprite Font Importer - MonoGame Importer = "FontDescriptionImporter"; Processor = "FontDescriptionProcessor"; ProcessorParam.Add("TextureFormat", "Color"); } else if (assets.IsTextureAssets()) { // Texture Importer - MonoGame if (assets.IsFontAssets()) { Importer = "TextureImporter"; Processor = "FontTextureProcessor"; ProcessorParam.Add("FirstCharacter", " "); ProcessorParam.Add("PremultiplyAlpha", "True"); ProcessorParam.Add("TextureFormat", "Color"); } else { Importer = "TextureImporter"; Processor = "TextureProcessor"; ProcessorParam.Add("ColorKeyColor", "255,0,255,255"); ProcessorParam.Add("ColorKeyEnabled", "True"); ProcessorParam.Add("GenerateMipmaps", "False"); ProcessorParam.Add("PremultiplyAlpha", "True"); ProcessorParam.Add("ResizeToPowerOfTwo", "False"); ProcessorParam.Add("MakeSquare", "False"); ProcessorParam.Add("TextureFormat", "Color"); } } else if (assets.IsMp3Assets()) { // Mp3 Importer - MonoGame if (assets.IsMusicAssets()) { Importer = "Mp3Importer"; Processor = "SongProcessor"; ProcessorParam.Add("Quality", "Low"); } else if (assets.IsSoundAssets()) { Importer = "Mp3Importer"; Processor = "SoundEffectProcessor"; ProcessorParam.Add("Quality", "Low"); } } else if (assets.IsOggAssets()) { // Ogg Importer - MonoGame if (assets.IsMusicAssets()) { Importer = "OggImporter"; Processor = "SongProcessor"; ProcessorParam.Add("Quality", "Low"); } else if (assets.IsSoundAssets()) { Importer = "OggImporter"; Processor = "SoundEffectProcessor"; ProcessorParam.Add("Quality", "Low"); } } else if (assets.IsWavAssets()) { // Wav Importer - MonoGame if (assets.IsMusicAssets()) { Importer = "WavImporter"; Processor = "SongProcessor"; ProcessorParam.Add("Quality", "Low"); } else if (assets.IsSoundAssets()) { Importer = "WavImporter"; Processor = "SoundEffectProcessor"; ProcessorParam.Add("Quality", "Low"); } } else if (assets.IsWmaAssets()) { // Wma Importer - MonoGame if (assets.IsMusicAssets()) { Importer = "WmaImporter"; Processor = "SongProcessor"; ProcessorParam.Add("Quality", "Low"); } else if (assets.IsSoundAssets()) { Importer = "WmaImporter"; Processor = "SoundEffectProcessor"; ProcessorParam.Add("Quality", "Low"); } } else if (assets.IsMp4Assets()) { // H.264 Video - MonoGame Importer = "H264Importer"; Processor = "VideoProcessor"; } else if (assets.IsWmvAssets()) { // Wmv Importer - MonoGame Importer = "WmvImporter"; Processor = "VideoProcessor"; } else if (assets.IsXMLAssets()) { // Xml Importer - MonoGame Importer = "XmlImporter"; Processor = "PassThroughProcessor"; } if (!FirstBuild) { if (Importer != null && Processor != null) { if (!tempImporter.Equals(Importer, StringComparison.OrdinalIgnoreCase) || !tempProcessor.Equals(Processor, StringComparison.OrdinalIgnoreCase) || tempProcessorParam.Select(a => a.Key + "=" + a.Value).Join(";").Equals(ProcessorParam.Select(a => a.Key + "=" + a.Value).Join(";"), StringComparison.OrdinalIgnoreCase)) { RebuildFlag = true; } } tempImporter = null; tempProcessor = null; tempProcessorParam = null; } #endif if (RebuildFlag || DeleteFlag) { CleanFile(); } if (Importer.IsNullOrEmpty() || Processor.IsNullOrEmpty()) { DestinationFile = (Program.Arguments.OutputDirectory + "/" + relativePath).GetFullPath(); } else { DestinationFile = (Program.Arguments.OutputDirectory + "/" + relativePathWithoutExtension + ".xnb").GetFullPath(); } if (RebuildFlag || Program.Arguments.Rebuild) { if (Importer.IsNullOrEmpty() || Processor.IsNullOrEmpty()) { DirectoryHelper.CreateDirectoryIfNotExists((Program.Arguments.OutputDirectory + "/" + relativeDirWithoutExtension).GetFullPath()); if (!Program.Arguments.Quiet) { Console.WriteLine("Copying: " + relativePath); } using (FileStream fileStream = new FileStream(SourceFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (FileStream fileStream2 = new FileStream((Program.Arguments.OutputDirectory + "/" + relativePath).GetFullPath(), FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite)) fileStream.CopyTo(fileStream2); } BuildSuccess = true; } else { #if MonoGame PipelineManager manager = new PipelineManager(Program.Arguments.WorkingDirectory, Program.Arguments.OutputDirectory, Program.Arguments.IntermediateDirectory) { CompressContent = Program.Arguments.Compress }; if (Program.Arguments.Platform.Equals("DesktopGL", StringComparison.OrdinalIgnoreCase)) { manager.Platform = TargetPlatform.DesktopGL; } else if (Program.Arguments.Platform.Equals("Windows", StringComparison.OrdinalIgnoreCase)) { manager.Platform = TargetPlatform.Windows; } if (Program.Arguments.Profile.Equals("Reach", StringComparison.OrdinalIgnoreCase)) { manager.Profile = GraphicsProfile.Reach; } else if (Program.Arguments.Profile.Equals("HiDef", StringComparison.OrdinalIgnoreCase)) { manager.Profile = GraphicsProfile.HiDef; } OpaqueDataDictionary Param = new OpaqueDataDictionary(); foreach (KeyValuePair <string, string> item in ProcessorParam) { Param.Add(item.Key, item.Value); } try { if (!Program.Arguments.Quiet) { Console.WriteLine("Building: " + relativePath); } PipelineBuildEvent buildResult = manager.BuildContent(SourceFile, null, Importer, Processor, Param); BuildAsset = buildResult.BuildAsset; BuildOutput = buildResult.BuildOutput; BuildSuccess = true; } catch (Exception ex) { if (!Program.Arguments.Quiet) { Console.Error.WriteLine("Content Error (" + relativePath + "): " + ex.Message); } BuildSuccess = false; } #endif } } else if (DeleteFlag) { BuildSuccess = true; } else { if (!Program.Arguments.Quiet) { Console.WriteLine("Skip: " + relativePath); } BuildSuccess = true; } } catch (Exception ex) { Console.Error.WriteLine(ex.Message); Console.Error.WriteLine(); Console.Error.WriteLine(ex.StackTrace); } }