private IProjectItem GetUpdatedItem(IProjectItem item, FileInfo fileInfo, CreationOptions creationOptions) { IDocumentType documentType = this.GetDocumentType(item.DocumentReference.Path); if (item.DocumentType == documentType) { return(null); } if (item.DocumentType == base.Services.DocumentTypes()[DocumentTypeNamesHelper.Xml] && documentType == base.Services.DocumentTypes()[DocumentTypeNamesHelper.DeepZoom]) { string[] directoryExtensions = DeepZoomHelper.GetDirectoryExtensions(item.DocumentReference.Path); for (int i = 0; i < (int)directoryExtensions.Length; i++) { string str = directoryExtensions[i]; Microsoft.Expression.Framework.Documents.DocumentReference documentReference = DeepZoomHelper.CreateDeepZoomDirectoryReference(item.DocumentReference, str); IProjectItem projectItem = base.FindItem(documentReference); if (projectItem != null) { this.RemoveProjectItem(projectItem, false); } } } this.RemoveProjectItem(item, false); DocumentCreationInfo documentCreationInfo = new DocumentCreationInfo() { TargetPath = fileInfo.FullName, CreationOptions = creationOptions, DocumentType = documentType }; return(base.AddItem(documentCreationInfo)); }
protected override IEnumerable <IProjectItem> AddAssetFolder(string sourceFolder, string targetFolder, bool link) { sourceFolder = Microsoft.Expression.Framework.Documents.PathHelper.EnsurePathEndsInDirectorySeparator(sourceFolder); targetFolder = Microsoft.Expression.Framework.Documents.PathHelper.EnsurePathEndsInDirectorySeparator(targetFolder); IEnumerable <IProjectItem> array = Enumerable.Empty <IProjectItem>(); ProjectManager.CopyDirectory(sourceFolder, targetFolder, true); IProjectItem projectItem = base.Items.FindMatchByUrl <IProjectItem>(targetFolder); if (projectItem != null) { array = projectItem.Descendants.OfType <IProjectItem>().ToArray <IProjectItem>(); } else { IDocumentType item = base.Services.DocumentTypes()[DocumentTypeNamesHelper.Folder]; DocumentCreationInfo documentCreationInfo = new DocumentCreationInfo() { DocumentType = item, TargetPath = targetFolder }; projectItem = base.AddItem(documentCreationInfo); } this.RefreshChildren(projectItem, true); return(projectItem.Descendants.OfType <IProjectItem>().Except <IProjectItem>(array)); }
private void RefreshDirectory(string directoryPath, bool selectNewlyCreatedItems) { if (!Microsoft.Expression.Framework.Documents.PathHelper.DirectoryExists(directoryPath)) { return; } CreationOptions creationOption = (selectNewlyCreatedItems ? CreationOptions.None : CreationOptions.DoNotSelectCreatedItems); foreach (FileInfo fileInfo in (new DirectoryInfo(directoryPath)).EnumerateFiles()) { if ((fileInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) { continue; } Microsoft.Expression.Framework.Documents.DocumentReference documentReference = Microsoft.Expression.Framework.Documents.DocumentReference.Create(fileInfo.FullName); IProjectItem projectItem = base.FindItem(documentReference); if (projectItem != null) { IProjectItem updatedItem = this.GetUpdatedItem(projectItem, fileInfo, creationOption); projectItem = (updatedItem != null ? updatedItem : projectItem); } else { IDocumentType documentType = this.GetDocumentType(fileInfo.FullName); DocumentCreationInfo documentCreationInfo = new DocumentCreationInfo() { TargetPath = fileInfo.FullName, CreationOptions = creationOption, DocumentType = documentType }; projectItem = base.CreateProjectItemIfNeeded(documentCreationInfo); if (projectItem == null) { continue; } this.AddProjectItem(projectItem, ProjectItemEventOptions.None); } } foreach (string str in Directory.EnumerateDirectories(directoryPath)) { if (!this.ShouldInitializeFolder(base.FindItem(Microsoft.Expression.Framework.Documents.DocumentReference.Create(str)) as FolderProjectItem)) { continue; } this.RefreshDirectory(str, selectNewlyCreatedItems); } if (directoryPath != base.ProjectRoot.Path) { Microsoft.Expression.Framework.Documents.DocumentReference documentReference1 = Microsoft.Expression.Framework.Documents.DocumentReference.Create(string.Concat(directoryPath, Path.DirectorySeparatorChar)); if (base.FindItem(documentReference1) == null) { IProjectItem folderProjectItem = new FolderProjectItem(this, documentReference1, base.Services.DocumentTypes()[DocumentTypeNamesHelper.Folder], base.Services); base.AddProjectItem(folderProjectItem); } } }
private bool CopyItems(IProject activeProject, IEnumerable <CutBuffer.CopyInformation> itemsToCopy) { List <DocumentCreationInfo> documentCreationInfos = new List <DocumentCreationInfo>(); foreach (CutBuffer.CopyInformation copyInformation in itemsToCopy) { if (!Microsoft.Expression.Framework.Documents.PathHelper.FileExists(copyInformation.SourcePath)) { if (!Microsoft.Expression.Framework.Documents.PathHelper.DirectoryExists(copyInformation.SourcePath)) { continue; } List <string> strs = new List <string>() { "" }; this.AppendAllSubfolders(copyInformation.SourcePath, "", strs); foreach (string str in strs) { string str1 = Microsoft.Expression.Framework.Documents.PathHelper.ResolveCombinedPath(copyInformation.SourcePath, str); string str2 = Microsoft.Expression.Framework.Documents.PathHelper.ResolveCombinedPath(copyInformation.DestinationPath, str); DocumentCreationInfo documentCreationInfo = new DocumentCreationInfo() { DocumentType = this.Services.DocumentTypeManager().DocumentTypes[DocumentTypeNamesHelper.Folder], SourcePath = str1, TargetPath = str2 }; documentCreationInfos.Add(documentCreationInfo); documentCreationInfos.AddRange(this.CopyFolderFiles(str1, str2)); } } else { DocumentCreationInfo documentCreationInfo1 = new DocumentCreationInfo() { SourcePath = copyInformation.SourcePath, TargetPath = copyInformation.DestinationPath }; documentCreationInfos.Add(documentCreationInfo1); } } IEnumerable <IProjectItem> projectItems = activeProject.AddItems(documentCreationInfos); if (itemsToCopy.CountIsLessThan <CutBuffer.CopyInformation>(1)) { return(true); } if (projectItems == null) { return(false); } return(projectItems.CountIsMoreThan <IProjectItem>(0)); }
private List <DocumentCreationInfo> CopyFolderFiles(string copiedFolder, string folderToBeWritten) { List <DocumentCreationInfo> documentCreationInfos = new List <DocumentCreationInfo>(); string[] files = Directory.GetFiles(copiedFolder); for (int i = 0; i < (int)files.Length; i++) { string str = files[i]; string str1 = Microsoft.Expression.Framework.Documents.PathHelper.ResolveCombinedPath(folderToBeWritten, Microsoft.Expression.Framework.Documents.PathHelper.GetFileOrDirectoryName(str)); DocumentCreationInfo documentCreationInfo = new DocumentCreationInfo() { SourcePath = str, TargetPath = str1 }; documentCreationInfos.Add(documentCreationInfo); } return(documentCreationInfos); }
public static IProjectItem AddImageDataFromClipboard(IProjectManager projectManager, IProject project) { InteropBitmap data; IProjectItem projectItem; try { data = (InteropBitmap)Clipboard.GetData(DataFormats.Bitmap); goto Label0; } catch (OutOfMemoryException outOfMemoryException) { LowMemoryMessage.Show(); projectItem = null; } return(projectItem); Label0: if (data == null) { return(null); } FormatConvertedBitmap formatConvertedBitmap = new FormatConvertedBitmap(data, PixelFormats.Bgr32, null, 0); string str = projectManager.TargetFolderForProject(project); string availableFilePath = ProjectPathHelper.GetAvailableFilePath("Image.png", str, null); using (FileStream fileStream = new FileStream(availableFilePath, FileMode.Create, FileAccess.Write)) { PngBitmapEncoder pngBitmapEncoder = new PngBitmapEncoder(); pngBitmapEncoder.Frames.Add(BitmapFrame.Create(formatConvertedBitmap)); pngBitmapEncoder.Save(fileStream); fileStream.Close(); } DocumentCreationInfo documentCreationInfo = new DocumentCreationInfo() { SourcePath = availableFilePath, TargetPath = availableFilePath }; return(project.AddItem(documentCreationInfo)); }