/// <summary>
        /// 从配置文件中加载菜单
        /// </summary>
        public AccordionLayout GetMenu()
        {
            var accordionLayout = new AccordionLayout(new AccordionLayout.Config { Animate = true, CollapseFirst = true });
            if (String.IsNullOrEmpty(_configFile))
                throw new Exception("the path can not be null");

            var doc = XElement.Parse(_contentProvider.GetAllText(_configFile));
            var menus = doc.Descendants("menu");
            foreach (var menu in menus)
            {
                var menuPanel = new MenuPanel(new MenuPanel.Config { Title = menu.Attribute("title").Value });
                foreach (var submenu in menu.Descendants("submenu"))
                {
                    var menuItem = new MenuItem
                                       {
                                           Text = submenu.Attribute("title").Value,
                                           Icon = (Icon)(Convert.ToInt32(submenu.Attribute("icon").Value))
                                       };

                    menuItem.CustomConfig.Add(new ConfigItem
                                                  {
                                                      Name = "url",
                                                      Value = submenu.Attribute("url").Value,
                                                      Mode = ParameterMode.Value
                                                  });

                    menuPanel.Menu.Items.Add(menuItem);
                }
                menuPanel.Menu.Listeners.Click.Handler = "Egaplay.Ext.addTab({ title: menuItem.text, url: menuItem.url, icon: menuItem.iconCls });";
                accordionLayout.Items.Add(menuPanel);
            }
            return accordionLayout;
        }
示例#2
0
        private Ext.Net.Panel GetmenuPanel(string systemid, string systemName)
        {
            try
            { UserInfo  userinfo = Session["userinfo"] as UserInfo;
              DataTable dtdir    = settingManager.GetUserSettingContent(systemid, "0", userinfo.UserCode);

              Ext.Net.Panel panelMenu = new Ext.Net.Panel();
              panelMenu.Layout = "Accordion";
              panelMenu.Header = false;
              panelMenu.Border = false;
              if (dtdir != null)
              {
                  for (int i = 0; i < dtdir.Rows.Count; i++)
                  {
                      Ext.Net.MenuPanel menuPanelItems = new Ext.Net.MenuPanel();
                      menuPanelItems.ID     = "Nav" + dtdir.Rows[i][1].ToString();
                      menuPanelItems.Title  = dtdir.Rows[i][2].ToString();
                      menuPanelItems.Icon   = (Icon)Enum.Parse(typeof(Icon), dtdir.Rows[i][5].ToString(), true);
                      menuPanelItems.Border = false;
                      Ext.Net.MenuPanel menuPanel = IninPage(i, systemid, menuPanelItems, dtdir.Rows[i][1].ToString(), userinfo.UserCode);
                      if (menuPanel != null)
                      {
                          panelMenu.Items.Add(menuPanel);
                      }
                      OpenDefaultPage();
                  }
              }

              return(panelMenu); }
            catch (Exception ex)
            {
                ILog.WriteErrorLog(ex);
                return(null);
            }
        }
        /// <summary>
        ///
        /// </summary>
        public MenuPanel.Builder MenuPanel(MenuPanel component)
        {
#if MVC
            component.ViewContext = this.HtmlHelper != null ? this.HtmlHelper.ViewContext : null;
#endif
            return(new MenuPanel.Builder(component));
        }
示例#4
0
        private Ext.Net.MenuPanel IninPage(int flag, string sysid, Ext.Net.MenuPanel pnlMenu, string contentId, string usercode)
        {
            try
            {
                if (string.IsNullOrEmpty(contentId))
                {
                    return(pnlMenu);
                }

                UserManager userManager = new UserManager();
                DataTable   dt          = userManager.GetDirectory(sysid, contentId, usercode);
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Ext.Net.MenuItem menuItem = new Ext.Net.MenuItem();
                        menuItem.ID   = "Menu" + dt.Rows[i][0].ToString();
                        menuItem.Text = dt.Rows[i][1].ToString();
                        menuItem.Attributes["title"] = pnlMenu.Title + "|" + dt.Rows[i][2].ToString();
                        menuItem.Icon = (Icon)Enum.Parse(typeof(Icon), dt.Rows[i][5].ToString(), true);
                        menuItem.Listeners.Click.Fn = "MenuItemClick";
                        pnlMenu.Menu.Items.Add(menuItem);
                        if (muIndex == -1)
                        {
                            muIndex = flag;
                        }
                        if (flag == muIndex && i == 0)
                        {
                            CurrentSelectMenu.Value = menuItem.Attributes["title"] + "," + menuItem.Text;//设置默认显示第一个
                        }
                        if (dt.Rows[i][7].ToString() == "1")
                        {
                            CurrentSelectMenu.Value = menuItem.Attributes["title"] + "," + menuItem.Text;//设置显示设置默认页
                        }
                    }
                    return(pnlMenu);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                ILog.WriteErrorLog(ex);
                return(null);
            }
        }
示例#5
0
        protected void Test()
        {
            using (BaglantiCumlesi db = new BaglantiCumlesi())
            {
                try
                {
                    #region Layer 0
                    List <tbl_sbt_menu> Layer0 = (from p in db.tbl_sbt_menu
                                                  where p.menu_id == 0
                                                  select p).ToList <tbl_sbt_menu>();

                    if (Layer0.Any())
                    {
                        #region Create Null Instance
                        Ext.Net.Menu M = null;
                        Ext.Net.ComponentMenuItem CMI = null;
                        Ext.Net.Container         C   = null;
                        Ext.Net.MenuPanel         MP  = null;
                        Ext.Net.MenuItem          MI  = null;
                        Ext.Net.MenuSeparator     MS  = null;
                        #endregion

                        #region Layer 0 Loop
                        foreach (var i in Layer0)
                        {
                            #region Button
                            Ext.Net.Button B = new Ext.Net.Button();
                            B.ID   = "Button" + i.id;
                            B.Text = i.ad;
                            #endregion

                            #region Layer 1
                            List <tbl_sbt_menu> Layer1 = (from p in db.tbl_sbt_menu
                                                          where p.menu_id == i.id
                                                          select p).ToList <tbl_sbt_menu>();

                            if (Layer1.Any())
                            {
                                #region Menu
                                M               = new Ext.Net.Menu();
                                M.ID            = "Menu" + i.id;
                                M.ShowSeparator = false;
                                #endregion

                                #region Component Menu i
                                CMI       = new Ext.Net.ComponentMenuItem();
                                CMI.ID    = "ComponentMenuItem" + i.id;
                                CMI.Shift = false;
                                #endregion

                                #region Container
                                C                = new Ext.Net.Container();
                                C.ID             = "Container" + i.id;
                                C.AutoWidth      = true;
                                C.AutoHeight     = true;
                                C.AnchorVertical = "100%";
                                C.Layout         = "ColumnLayout";
                                #endregion

                                #region Layer 1 Loop
                                foreach (var t in Layer1)
                                {
                                    #region MenuPanel
                                    MP                    = new Ext.Net.MenuPanel();
                                    MP.ID                 = "MenuPanel" + t.id;
                                    MP.Title              = t.ad;
                                    MP.Margins            = "10 10 10 10";
                                    MP.Menu.ID            = "Menu" + t.id;
                                    MP.Menu.ShowSeparator = false;
                                    #endregion

                                    #region Layer 2
                                    List <tbl_sbt_menu> Layer2 = (from p in db.tbl_sbt_menu
                                                                  where p.menu_id == t.id
                                                                  select p).ToList <tbl_sbt_menu>();

                                    if (Layer2.Any())
                                    {
                                        int LastID = Layer2[Layer2.Count - 1].id;

                                        #region Layer 2 Loop
                                        foreach (var y in Layer2)
                                        {
                                            #region Menu i
                                            MI      = new Ext.Net.MenuItem();
                                            MI.ID   = "MenuItem" + y.id;
                                            MI.Text = y.ad;

                                            #region URL Check
                                            if (!string.IsNullOrEmpty(y.url))
                                            {
                                                MI.Icon = Ext.Net.Icon.StarGold;
                                                MI.Listeners.Click.Handler = "TabEkle(TabPanel1, '" + MI.ID + "', '" + y.url + "', '" + MP.ID + "', '" + y.ad + "')";
                                            }
                                            else
                                            {
                                                MI.Icon     = Ext.Net.Icon.StarHalfGrey;
                                                MI.Disabled = true;
                                            }
                                            #endregion

                                            #endregion

                                            if (y.id != LastID)
                                            {
                                                #region Menu Separator
                                                MS    = new Ext.Net.MenuSeparator();
                                                MS.ID = "MenuSeparator" + y.id;
                                                #endregion
                                            }

                                            #region Adding
                                            MP.Menu.Items.Add(MI);
                                            #endregion

                                            if (y.id != LastID)
                                            {
                                                #region Adding
                                                MP.Menu.Items.Add(MS);
                                                #endregion
                                            }
                                        }
                                        #endregion
                                    }
                                    #endregion

                                    #region Adding
                                    C.Items.Add(MP);
                                    #endregion
                                }
                                #endregion

                                #region Adding
                                CMI.Component.Add(C);
                                M.Items.Add(CMI);
                                B.Menu.Add(M);
                                #endregion
                            }
                            else
                            {
                                B.StandOut = true;
                            }
                            #endregion

                            #region Adding
                            MenuToolbar.Items.Add(B);
                            #endregion
                        }
                        #endregion
                    }
                    #endregion
                }
                catch
                {
                }

                /*
                 * try
                 * {
                 *  //http://www.superstarcoders.com/blogs/posts/recursive-hierarchical-joins-in-c-sharp-and-linq.aspx
                 *
                 *  IEnumerable<DeepNodeData> nodes = elements.RecursiveJoin(
                 *      element => element.Id,
                 *      element => element.ParentId,
                 *      (FlatData element, int index, int depth, IEnumerable<DeepNodeData> children) =>
                 *      {
                 *          return new DeepNodeData()
                 *          {
                 *              Text = element.Text,
                 *              Children = children,
                 *              Depth = depth
                 *          };
                 *      });
                 *
                 *  foreach (var i in nodes)
                 *  {
                 *
                 *  }
                 *
                 *  var q = (from p in db.tbl_sbt_menu
                 *           select new
                 *           {
                 *               ParentID = p.menu_id,
                 *               child = from c in db.tbl_sbt_menu
                 *                       where c.menu_id == p.id
                 *                       select new
                 *                           {
                 *                               ChildID = c.id,
                 *                               ParentID = c.menu_id
                 *                           }
                 *           });
                 *
                 *  //var abc = q.Select(p=>p.child).fir
                 *
                 * }
                 * catch
                 * {
                 *
                 * }
                 */
            }
        }
示例#6
0
 /// <summary>
 ///
 /// </summary>
 public MenuPanel.Builder MenuPanel(MenuPanel component)
 {
     return(new MenuPanel.Builder(component));
 }