コード例 #1
0
        /// <summary>
        /// Handles the Click event of the CreatePageLayoutContentTypeNodeExtension control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Microsoft.VisualStudio.SharePoint.MenuItemEventArgs" /> instance containing the event data.</param>
        void CreatePageLayoutContentTypeNodeExtension_Click(object sender, Microsoft.VisualStudio.SharePoint.MenuItemEventArgs e)
        {
            IExplorerNode ctNode = e.Owner as IExplorerNode;

            if (ctNode != null)
            {
                IContentTypeNodeInfo ctInfo = ctNode.Annotations.GetValue <IContentTypeNodeInfo>();

                string pageLayoutContents = ctNode.Context.SharePointConnection.ExecuteCommand <string, string>(ContentTypeSharePointCommandIds.CreatePageLayoutCommand, ctInfo.Name);
                DTEManager.CreateNewTextFile(SafeContentTypeName(ctInfo.Name) + ".aspx", pageLayoutContents);
            }
        }
コード例 #2
0
        /// <summary>
        /// Opens the file menu item click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="MenuItemEventArgs" /> instance containing the event data.</param>
        protected virtual void OpenFileMenuItemClick(object sender, MenuItemEventArgs e)
        {
            IExplorerNode fileNode     = e.Owner as IExplorerNode;
            var           fileNodeInfo = fileNode.Annotations.GetValue <FileNodeInfo>();

            DTEManager.SetStatus(CKSProperties.FileUtilities_OpeningFile);

            string fileContents = fileNode.Context.SharePointConnection.ExecuteCommand <FileNodeInfo, string>(FileSharePointCommandIds.GetFileContentsCommand, fileNodeInfo);

            DTEManager.CreateNewTextFile(fileNodeInfo.Name, fileContents);

            DTEManager.SetStatus(CKSProperties.FileUtilities_FileSuccessfullyOpened);
        }
コード例 #3
0
        /// <summary>
        /// Creates the files nodes.
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        public static void CreateFilesNodes(IExplorerNode parentNode)
        {
            DTEManager.SetStatus(CKSProperties.FileNodeTypeProvider_RetrievingFolders);
            FolderNodeInfo[] folders = parentNode.Context.SharePointConnection.ExecuteCommand <FolderNodeInfo, FolderNodeInfo[]>(FileSharePointCommandIds.GetFoldersCommand, parentNode.Annotations.GetValue <FolderNodeInfo>());
            DTEManager.SetStatus(CKSProperties.FileNodeTypeProvider_RetrievingFiles);
            FileNodeInfo[] files = parentNode.Context.SharePointConnection.ExecuteCommand <FolderNodeInfo, FileNodeInfo[]>(FileSharePointCommandIds.GetFilesCommand, parentNode.Annotations.GetValue <FolderNodeInfo>());

            if (folders != null)
            {
                foreach (FolderNodeInfo folder in folders)
                {
                    var annotations = new Dictionary <object, object>
                    {
                        { typeof(FolderNodeInfo), folder }
                    };

                    string nodeTypeId = ExplorerNodeIds.FolderNode;

                    IExplorerNode fileNode = parentNode.ChildNodes.Add(nodeTypeId, folder.Name, annotations);
                }
            }

            if (files != null)
            {
                foreach (FileNodeInfo file in files)
                {
                    var annotations = new Dictionary <object, object>
                    {
                        { typeof(FileNodeInfo), file }
                    };

                    string nodeTypeId = ExplorerNodeIds.FileNode;

                    IExplorerNode fileNode = parentNode.ChildNodes.Add(nodeTypeId, file.Name, annotations);
                    fileNode.DoubleClick += delegate(object sender, ExplorerNodeEventArgs e)
                    {
                        var fileNodeInfo = e.Node.Annotations.GetValue <FileNodeInfo>();

                        DTEManager.SetStatus(CKSProperties.FileUtilities_OpeningFile);

                        string fileContents = fileNode.Context.SharePointConnection.ExecuteCommand <FileNodeInfo, string>(FileSharePointCommandIds.GetFileContentsCommand, fileNodeInfo);
                        DTEManager.CreateNewTextFile(fileNodeInfo.Name, fileContents);

                        DTEManager.SetStatus(CKSProperties.FileUtilities_FileSuccessfullyOpened);
                    };
                    SetExplorerNodeIcon(file, fileNode);
                }
            }

            DTEManager.SetStatus(String.Empty);
        }
        /// <summary>
        /// Handles the Click event of the exportMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MenuItemEventArgs" /> instance containing the event data.</param>
        void exportMenuItem_Click(object sender, MenuItemEventArgs e)
        {
            IExplorerNode pageNode = e.Owner as IExplorerNode;

            if (pageNode != null)
            {
                PublishingPageInfo pageInfo = pageNode.Annotations.GetValue <PublishingPageInfo>();
                if (pageInfo != null)
                {
                    string pageXml = pageNode.Context.SharePointConnection.ExecuteCommand <PublishingPageInfo, string>(PublishingPageCommandIds.ExportToXml, pageInfo);
                    DTEManager.CreateNewTextFile(String.Format("{0}.xml", pageInfo.Name), pageXml);
                }
            }
        }
 /// <summary>
 /// Handles the Click event of the getTemplatePageMenuItem control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="MenuItemEventArgs" /> instance containing the event data.</param>
 void getTemplatePageMenuItem_Click(object sender, MenuItemEventArgs e)
 {
     DTEManager.CreateNewTextFile("TemplatePage.aspx", CKSProperties.TemplatePage);
 }