public void OnCopy(string sourceFile) { // Make sure the source file is relative to the project. var projectDir = ProjectDirectory + Path.DirectorySeparatorChar; sourceFile = PathHelper.GetRelativePath(projectDir, sourceFile); // Remove duplicates... keep this new one. var previous = _project.ContentItems.FirstOrDefault(e => e.OriginalPath.Equals(sourceFile)); if (previous != null) { _project.ContentItems.Remove(previous); } // Create the item for processing later. var item = new ContentItem { BuildAction = BuildAction.Copy, OriginalPath = sourceFile, ProcessorParams = new OpaqueDataDictionary(), Exists = File.Exists(projectDir + sourceFile) }; _project.ContentItems.Add(item); // Copy the current processor parameters blind as we // will validate and remove invalid parameters during // the build process later. foreach (var pair in _processorParams) { item.ProcessorParams.Add(pair.Key, pair.Value); } }
public bool AddContent(string sourceFile, bool skipDuplicates) { string link = null; if (sourceFile.Contains(";")) { var split = sourceFile.Split(';'); sourceFile = split[0]; if (split.Length > 0) { link = split[1]; } } // Make sure the source file is relative to the project. var projectDir = ProjectDirectory + Path.DirectorySeparatorChar; sourceFile = PathHelper.GetRelativePath(projectDir, sourceFile); // Do we have a duplicate? var previous = _project.ContentItems.FindIndex(e => string.Equals(e.OriginalPath, sourceFile, StringComparison.InvariantCultureIgnoreCase)); if (previous != -1) { if (skipDuplicates) { return(false); } // Replace the duplicate. _project.ContentItems.RemoveAt(previous); } // Create the item for processing later. var item = new ContentItem { Observer = _observer, BuildAction = BuildAction.Build, OriginalPath = sourceFile, DestinationPath = string.IsNullOrEmpty(link) ? sourceFile : link, ImporterName = Importer, ProcessorName = Processor, ProcessorParams = new OpaqueDataDictionary() }; _project.ContentItems.Add(item); // Copy the current processor parameters blind as we // will validate and remove invalid parameters during // the build process later. foreach (var pair in _processorParams) { item.ProcessorParams.Add(pair.Key, pair.Value); } return(true); }
private bool IncludeFiles(List <IncludeItem> items, string initialDirectory, string[] files, ref bool repeat, ref IncludeType action) { var relative = Utils.GetRelativePath(initialDirectory, ProjectLocation); foreach (var file in files) { var item = new IncludeItem { SourcePath = file }; if (file.StartsWith(ProjectLocation)) { // If the file is in the same directory as the .mgcb file, just add it and skip showing file dialogs item.RelativeDestPath = PathHelper.GetRelativePath(ProjectLocation, file); item.IncludeType = IncludeType.Link; } else { item.RelativeDestPath = Path.Combine(relative, Path.GetFileName(file)); if (!repeat) { if (!View.CopyOrLinkFile(file, File.Exists(Path.Combine(ProjectLocation, item.RelativeDestPath)), out action, out repeat)) { return(false); } } if (action == IncludeType.Skip) { continue; } if (action == IncludeType.Copy && File.Exists(Path.Combine(ProjectLocation, item.RelativeDestPath))) { item.IncludeType = IncludeType.Link; } else { item.IncludeType = action; } } items.Add(item); } return(true); }
public void OnCopy(string sourceFile) { string link = null; if (sourceFile.Contains(";")) { var split = sourceFile.Split(';'); sourceFile = split[0]; if (split.Length > 0) { link = split[1]; } } // Make sure the source file is relative to the project. var projectDir = ProjectDirectory + Path.DirectorySeparatorChar; sourceFile = PathHelper.GetRelativePath(projectDir, sourceFile); // Remove duplicates... keep this new one. var previous = _project.ContentItems.FirstOrDefault(e => e.OriginalPath.Equals(sourceFile)); if (previous != null) { _project.ContentItems.Remove(previous); } // Create the item for processing later. var item = new ContentItem { BuildAction = BuildAction.Copy, OriginalPath = sourceFile, DestinationPath = string.IsNullOrEmpty(link) ? sourceFile : link, ProcessorParams = new OpaqueDataDictionary() }; _project.ContentItems.Add(item); // Copy the current processor parameters blind as we // will validate and remove invalid parameters during // the build process later. foreach (var pair in _processorParams) { item.ProcessorParams.Add(pair.Key, pair.Value); } }
void SetExists(string path, bool exist) { if (_project != null) { var projectDir = _project.Location + Path.DirectorySeparatorChar; IProjectItem item = GetItem(PathHelper.GetRelativePath(projectDir, path)); if (item != null) { if (item.Exists == !exist) { item.Exists = exist; View.ItemExistanceChanged(item); } } } }