Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Guid menuMasterId = new Guid();

            using (
                SqlConnection con =
                    new SqlConnection(
                        System.Configuration.ConfigurationManager.ConnectionStrings["PSCPortalConnectionString"]
                        .ConnectionString))
            {
                SqlCommand com = new SqlCommand {
                    Connection = con
                };
                con.Open();
                com.CommandType = CommandType.Text;
                com.Parameters.AddWithValue("@dataId", Portlet.PortletInstance.Id);
                com.CommandText = "Select MenuMasterId from PortletMenu Where DataId=@dataId";
                if (com.ExecuteScalar() != null)
                {
                    menuMasterId = new Guid(com.ExecuteScalar().ToString());
                }
            }
            rptMennu.DataSource =
                MenuCollection.GetMenuCollection(new MenuMaster {
                Id = menuMasterId
            }).GetBindingSource();
            rptMennu.DataBind();
        }
Ejemplo n.º 2
0
        private void bindMenu_Click(object sender, EventArgs e)
        {
            var collection  = MenuCollection.GetMenuCollection();
            var mainControl = (MenuStrip)GetMainControlByName("menuBar1");

            foreach (var item in collection)
            {
                var isMatch = false;
                foreach (object component in mainControl.Items)
                {
                    if (isMatch)
                    {
                        break;
                    }

                    if (((INamedBindable)component).Name == item.Name)
                    {
                        ((IBindableComponent)component).DataBindings.Add("Text", item, "Text");
                        ((IBindableComponent)component).DataBindings.Add("ToolTipText", item, "ToolTipText");
                        ((IBindableComponent)component).DataBindings.Add("Enabled", item, "Enabled");
                        ((IBindableComponent)component).DataBindings.Add("Visible", item, "Visible");
                        isMatch = true;
                    }
                    else if (component.GetType() == typeof(ToolStripMenuItem))
                    {
                        foreach (ToolStripMenuItem subControl in ((ToolStripMenuItem)component).DropDownItems)
                        {
                            if (subControl.Name == item.Name)
                            {
                                subControl.DataBindings.Add("Text", item, "Text");
                                subControl.DataBindings.Add("ToolTipText", item, "ToolTipText");
                                subControl.DataBindings.Add("Enabled", item, "Enabled");
                                subControl.DataBindings.Add("Visible", item, "Visible");
                                isMatch = true;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
 protected void LoadData()
 {
     try
     {
         string     rootId     = Request.QueryString["menuId"].ToString();
         MenuMaster menuMaster = MenuMasterList.Where(s => s.Id.ToString() == rootId).Single();
         MenuMasterName = menuMaster.Name;
         MenuCollection     collection = MenuCollection.GetMenuCollection(menuMaster);
         List <SiteMapNode> result     = new List <SiteMapNode>();
         PSCPortal.Framework.Core.BusinessObjectTreeBindingSource bindingResource = collection.GetBindingSource();
         foreach (PSCPortal.Framework.Core.BusinessObjectHierarchical mc in bindingResource)
         {
             result.Add(GetSiteNodeFromMenu((PSCPortal.CMS.Menu)mc.Item));
         }
         JavaScriptSerializer js = new JavaScriptSerializer();
         TreeNodesLinkList = js.Serialize(result);
         DataBind();
     }
     catch (Exception e)
     {
     }
 }