Exemplo n.º 1
0
 private void LoadDirectory(string directoryPath, IProjectItem parentItem)
 {
     FileInfo[] files = (new DirectoryInfo(directoryPath)).GetFiles();
     for (int i = 0; i < (int)files.Length; i++)
     {
         FileInfo fileInfo = files[i];
         if ((fileInfo.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
         {
             Microsoft.Expression.Framework.Documents.DocumentReference documentReference = Microsoft.Expression.Framework.Documents.DocumentReference.Create(fileInfo.FullName);
             IDocumentType documentType = this.GetDocumentType(fileInfo.FullName);
             this.AddItemDuringLoad(documentType, documentReference, parentItem);
         }
     }
     string[] directories = Directory.GetDirectories(directoryPath);
     for (int j = 0; j < (int)directories.Length; j++)
     {
         string str = directories[j];
         if (((new DirectoryInfo(str)).Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
         {
             IDocumentType     item = base.Services.DocumentTypes()[DocumentTypeNamesHelper.Folder];
             string            str1 = string.Concat(str, Path.DirectorySeparatorChar);
             FolderProjectItem folderProjectItem = this.AddItemDuringLoad(item, Microsoft.Expression.Framework.Documents.DocumentReference.Create(str1), parentItem) as FolderProjectItem;
             if (this.ShouldInitializeFolder(folderProjectItem))
             {
                 this.LoadDirectory(str, folderProjectItem);
             }
         }
     }
 }
Exemplo n.º 2
0
 private void EnsureDeepZoomProjectItems(IProjectItem deepZoomProjectItem)
 {
     string[] directoryExtensions = DeepZoomHelper.GetDirectoryExtensions(deepZoomProjectItem.DocumentReference.Path);
     if (directoryExtensions != null)
     {
         string[] strArrays = directoryExtensions;
         for (int i = 0; i < (int)strArrays.Length; i++)
         {
             string str = strArrays[i];
             Microsoft.Expression.Framework.Documents.DocumentReference documentReference = DeepZoomHelper.CreateDeepZoomDirectoryReference(deepZoomProjectItem.DocumentReference, str);
             IProjectItem projectItem = base.FindItem(documentReference);
             if (projectItem != null && !deepZoomProjectItem.Children.ToList <IProjectItem>().Contains(projectItem))
             {
                 this.RemoveProjectItem(projectItem, false);
                 projectItem = null;
             }
             if (projectItem == null && Microsoft.Expression.Framework.Documents.PathHelper.FileOrDirectoryExists(documentReference.Path))
             {
                 IProjectItem folderProjectItem = new FolderProjectItem(this, documentReference, base.Services.DocumentTypes()[DocumentTypeNamesHelper.Folder], base.Services, true, Microsoft.Expression.Project.FileTable.GetImageSource("Resources\\Folder_DeepZoom.png"));
                 if (this.AddProjectItem(folderProjectItem, ProjectItemEventOptions.None))
                 {
                     deepZoomProjectItem.AddChild(folderProjectItem);
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 public override ICommandBar GetContextMenu(ICommandBarCollection commandBarCollection)
 {
     if (this.IsUIBlockingFolder)
     {
         return(null);
     }
     if (base.Services.ProjectManager().CurrentSolution != null && base.Services.ProjectManager().CurrentSolution.IsSourceControlActive)
     {
         FolderProjectItem.DestroyContextMenu();
     }
     if (FolderProjectItem.contextMenu == null)
     {
         FolderProjectItem.contextMenu = commandBarCollection.AddContextMenu("Project_FolderProjectItemContextMenu");
         FolderProjectItem.contextMenu.Items.AddButton("Application_AddNewItem", StringTable.ProjectItemContextMenuAddNewItem);
         FolderProjectItem.contextMenu.Items.AddButton("Project_AddExistingItem", StringTable.ProjectItemContextMenuAddExistingItem);
         FolderProjectItem.contextMenu.Items.AddButton("Project_LinkToExistingItem", StringTable.ProjectItemContextMenuLinkToExistingItem);
         FolderProjectItem.contextMenu.Items.AddSeparator();
         ProjectManager.AddSourceControlMenuItems(FolderProjectItem.contextMenu.Items);
         FolderProjectItem.contextMenu.Items.AddSeparator();
         FolderProjectItem.contextMenu.Items.AddButton("Project_NewFolder", StringTable.ProjectItemContextMenuNewFolder);
         FolderProjectItem.contextMenu.Items.AddButton("Project_Refresh", StringTable.ProjectItemContextMenuRefresh);
         FolderProjectItem.contextMenu.Items.AddSeparator();
         FolderProjectItem.contextMenu.Items.AddButton("Project_Cut", StringTable.ProjectItemContextMenuCut);
         FolderProjectItem.contextMenu.Items.AddButton("Project_Copy", StringTable.ProjectItemContextMenuCopy);
         FolderProjectItem.contextMenu.Items.AddButton("Project_Paste", StringTable.ProjectItemContextMenuPaste);
         FolderProjectItem.contextMenu.Items.AddButton("Project_RenameProjectItem", StringTable.ProjectItemContextMenuRename);
         FolderProjectItem.contextMenu.Items.AddSeparator();
         FolderProjectItem.contextMenu.Items.AddButton("Project_DeleteProjectItem", StringTable.ProjectItemContextMenuDelete);
         FolderProjectItem.contextMenu.Items.AddSeparator();
         FolderProjectItem.contextMenu.Items.AddButton("Project_ExploreProject", StringTable.ProjectItemContextMenuExplore);
     }
     return(FolderProjectItem.contextMenu);
 }
Exemplo n.º 4
0
 private bool ShouldInitializeFolder(FolderProjectItem item)
 {
     if (item == null)
     {
         return(true);
     }
     return(!item.IsUIBlockingFolder);
 }
Exemplo n.º 5
0
        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);
                }
            }
        }
Exemplo n.º 6
0
        private void PlaceItemInFolder(IProjectItem projectItem)
        {
            string parentDirectory = Microsoft.Expression.Framework.Documents.PathHelper.GetParentDirectory(projectItem.DocumentReference.Path);

            if (!string.IsNullOrEmpty(parentDirectory))
            {
                Microsoft.Expression.Framework.Documents.DocumentReference documentReference = Microsoft.Expression.Framework.Documents.DocumentReference.Create(parentDirectory);
                if (base.DocumentReference.Equals(documentReference))
                {
                    return;
                }
                IProjectItem item = base.Items[documentReference.GetHashCode()];
                if (item == null)
                {
                    item = new FolderProjectItem(this, documentReference, base.Services.DocumentTypes()[DocumentTypeNamesHelper.Folder], base.Services);
                    base.AddProjectItem(item);
                }
                if (item.CanAddChildren)
                {
                    item.AddChild(projectItem);
                }
            }
        }