protected override void CreateChildControls()
        {
            base.CreateChildControls();

            SPWeb web = SPContext.Current.Web;

            // Menu options
            SubMenuTemplate subMenuTemplate = new SubMenuTemplate();
            subMenuTemplate.ID = "CustomSubMenu";
            subMenuTemplate.Text = "Pages demo";
            subMenuTemplate.Description = "Pages demo - Application page and site page";
            subMenuTemplate.MenuGroupId = 1; // Id of group in menu. Value of 1 means that it will be placed in first group (with Edit Page item)
            subMenuTemplate.Sequence = 1;

            // Menu items (commands)
            MenuItemTemplate template1 = new MenuItemTemplate();
            template1.ID = "FirstMenuItem";
            template1.Text = "First Application Page";
            template1.Sequence = 1;
            template1.ClientOnClickNavigateUrl = web.Url + FirstMenuItemUrl;

            MenuItemTemplate template2 = new MenuItemTemplate();
            template2.ID = "SecondMenuItem";
            template2.Text = "Site page";
            template2.Sequence = 2;
            template2.ClientOnClickNavigateUrl = web.Url + SecondMenuItemUrl;

            // Add controls
            subMenuTemplate.Controls.Add(template1);
            subMenuTemplate.Controls.Add(template2);

            this.Controls.Add(subMenuTemplate);
        }
Esempio n. 2
0
        private void AddEditAgilePlannerMenu(string projectCenter, string taskCenter, bool enableWp, SPWeb web)
        {
            if (projectCenter != string.Empty && (projectCenter == sListName || taskCenter == sListName) && enableWp)
            {
                var list = web.Lists[projectCenter];
                if (list.Items.Count == 1)
                {
                    var li   = list.Items[0];
                    var menu = new MenuItemTemplate
                    {
                        Text                = "Edit In Agile Planner",
                        Description         = "Edit your attached schedule using Agile Planner.",
                        ImageUrl            = "/_layouts/images/epmlivelogo.gif",
                        ClientOnClickScript = string.Format(
                            "javascript:window.open('{0}/_layouts/epmlive/agile/tasks.aspx?ID={1}&source={2}','', config='width=' + screen.width + ',height=' + screen.height + ',top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=yes'); return false;",
                            web.ServerRelativeUrl,
                            li.ID,
                            HttpUtility.UrlEncode(HttpContext.Current.Request.ServerVariables["URL"]))
                    };

                    Controls.Add(menu);
                }
                else if (list.Items.Count > 1)
                {
                    var menuWp = new SubMenuTemplate
                    {
                        Text        = "Edit In Agile Planner",
                        Description = "Edit your attached schedule using Agile Planner.",
                        ImageUrl    = "/_layouts/images/epmlivelogo.gif"
                    };

                    Controls.Add(menuWp);

                    var query = new SPQuery
                    {
                        Query = "<OrderBy><FieldRef Name='Title'/></OrderBy>"
                    };

                    foreach (SPListItem li in list.GetItems(query))
                    {
                        var menu1 = new MenuItemTemplate
                        {
                            Text = li.Title,
                            ClientOnClickScript = string.Format(
                                "javascript:window.open('{0}/_layouts/epmlive/agile/tasks.aspx?ID={1}&source={2}','', config='width=' + screen.width + ',height=' + screen.height + ',top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=yes'); return false;",
                                web.ServerRelativeUrl,
                                li.ID,
                                HttpUtility.UrlEncode(HttpContext.Current.Request.ServerVariables["URL"]))
                        };

                        menuWp.Controls.Add(menu1);
                    }
                }
            }
        }
        internal void AddMenuItems(ControlCollection controls, IDictionary ctls)
        {
            string           tmp, img;
            IDictionary      ctl, subCtls;
            MenuItemTemplate menuItem;
            SubMenuTemplate  subMenu;

            foreach (DictionaryEntry entry in ctls)
            {
                if ((ctl = entry.Value as IDictionary) != null)
                {
                    if (((subCtls = ctl ["items"] as IDictionary) != null) && (subCtls.Count > 0))
                    {
                        subMenu = new SubMenuTemplate()
                        {
                            ID          = entry.Key + string.Empty,
                            Description = ctl ["desc"] + string.Empty,
                            Text        = ctl ["title"] + string.Empty
                        };
                        if (!string.IsNullOrEmpty(img = ctl ["img"] + string.Empty))
                        {
                            subMenu.ImageUrl = img;
                        }
                        AddMenuItems(subMenu.Controls, subCtls);
                        controls.Add(subMenu);
                    }
                    else if (!string.IsNullOrEmpty(tmp = ctl ["click"] + string.Empty))
                    {
                        menuItem = new MenuItemTemplate(ctl ["title"] + string.Empty)
                        {
                            Description = ctl ["desc"] + string.Empty,
                            ID          = entry.Key + string.Empty
                        };
                        if (!string.IsNullOrEmpty(img = ctl ["img"] + string.Empty))
                        {
                            menuItem.ImageUrl = img;
                        }
                        menuItem.ClientOnClickScript = tmp;
                        controls.Add(menuItem);
                    }
                }
                else
                {
                    controls.Add(new MenuSeparatorTemplate()
                    {
                        ID = entry.Key + string.Empty
                    });
                }
            }
        }
Esempio n. 4
0
 private static void AddTasksMenu(SPWeb web, SPListItem listItem, SubMenuTemplate menuWP)
 {
     if (web.Site.Features[new Guid(SiteFeaturesGuid)] != null)
     {
         var menuItemTemplate = new MenuItemTemplate
         {
             Text = listItem.Title,
             ClientOnClickScript = string.Format(
                 "javascript:window.open('{0}/_layouts/epmlive/tasks.aspx?ID={1}&source={2}','', config='width=' + screen.width + ',height=' + screen.height + ',top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=yes'); return false;",
                 web.ServerRelativeUrl,
                 listItem.ID,
                 HttpUtility.UrlEncode(HttpContext.Current.Request.ServerVariables["URL"]))
         };
         menuWP.Controls.Add(menuItemTemplate);
     }
 }
Esempio n. 5
0
        private void AddEditProjectMenus(bool hasProject, bool disablePlan, SPWeb web, SPList list, bool eProject)
        {
            var menu = new SubMenuTemplate
            {
                Text        = "Edit With Project",
                Description = "Edit your attached schedule using Microsoft Office Project.",
                ImageUrl    = "/_layouts/images/project2007logo.gif"
            };

            if (hasProject)
            {
                Controls.Add(menu);
            }

            var menuWP = new SubMenuTemplate();

            if (!disablePlan)
            {
                if (web.Site.Features[new Guid(SiteFeaturesGuid)] != null)
                {
                    menuWP.Text        = "Edit In Work Planner";
                    menuWP.Description = "Edit your attached schedule using Work Planner.";
                    menuWP.ImageUrl    = "/_layouts/images/epmlivelogo.gif";

                    Controls.Add(menuWP);
                }
            }
            var query = new SPQuery
            {
                Query = "<OrderBy><FieldRef Name='Title'/></OrderBy>"
            };

            foreach (SPListItem listItem in list.GetItems(query))
            {
                AddGetProjectsMenu(hasProject, eProject, listItem, web, list, menu);
                AddTasksMenu(web, listItem, menuWP);
            }
        }
Esempio n. 6
0
        private static void AddGetProjectsMenu(bool hasProject, bool eProject, SPListItem listItem, SPWeb web, SPList list, SubMenuTemplate menu)
        {
            if (hasProject)
            {
                MenuItemTemplate menuItemTemplate;

                if (eProject)
                {
                    menuItemTemplate = new MenuItemTemplate
                    {
                        Text = listItem.Title,
                        ClientOnClickScript = string.Format(
                            "javascript:window.open('{0}/_layouts/epmlive/getpsproject.aspx?listID={1}&amp;itemID={2}','', config='height=250,width=350, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no'); return false",
                            web.ServerRelativeUrl,
                            list.ID,
                            listItem.ID)
                    };
                    menu.Controls.Add(menuItemTemplate);
                }
                else
                {
                    menuItemTemplate = new MenuItemTemplate
                    {
                        Text = listItem.Title,
                        ClientOnClickScript = string.Format(
                            "javascript:window.open('{0}/_layouts/epmlive/getproject.aspx?listID={1}&amp;ID={2}','', config='height=100,width=350, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no'); return false",
                            web.ServerRelativeUrl,
                            list.ID,
                            listItem.ID)
                    };
                    menu.Controls.Add(menuItemTemplate);
                }
            }
        }