Ejemplo n.º 1
0
 private void createSubMenu(MenuCollection menuCollection, DataTable dt, string p)
 {
     DataRow[] rows = dt.Select("parentid='" + p + "'");
     if (rows == null || rows.Length == 0)
     {
         return;
     }
     Ext.Net.Menu menu = new Ext.Net.Menu();
     foreach (DataRow row in rows)
     {
         sysprog          prog = ConvertHelper.RowToObject <sysprog>(row);
         Ext.Net.MenuItem item = new Ext.Net.MenuItem(prog.ProgName);
         if (prog.IsGroup == "1")
         {
             item.Icon = Icon.Folder;
             createSubMenu(item.Menu, dt, prog.id);
         }
         else
         {
             item.Icon = Icon.ApplicationForm;
             item.Listeners.Click.Handler = "showmodule(#{MyDesktop},'" + prog.id + "');";
         }
         menu.Add(item);
     }
     menuCollection.Add(menu);
 }
Ejemplo n.º 2
0
        private void PivotMenu_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.IsInDesignTool)
            {
                // Some design-time data
                var processMenu = new ProcessAreaItem();
                processMenu.Title = "Process Area 1";

                for (int index = 1; index < 6; index++)
                {
                    var activityItem = new ActivityItem();
                    activityItem.Title = "Activity " + index.ToString();
                    processMenu.Add(activityItem);
                }

                MenuCollection menuCollection = new MenuCollection();
                menuCollection.Add(processMenu);

                processMenu       = new ProcessAreaItem();
                processMenu.Title = "Process Area 2";

                for (int index = 1; index < 6; index++)
                {
                    var activityItem = new ActivityItem();
                    activityItem.Title = "Activity " + index.ToString();
                    processMenu.Add(activityItem);
                }

                menuCollection.Add(processMenu);

                this.ItemsSource = menuCollection;
            }
            else
            {
                MenuCollection menu = ApplicationEx.Instance.ApplicationMenu;

                if (ShouldMakeSingleLevelMenu(menu))
                {
                    menu = MakeSingleLevelMenu(menu);
                }

                this.ItemsSource = menu;
            }
        }
Ejemplo n.º 3
0
 public static MenuCollection GetRootCategories()
 {
     MenuCollection rootMenus = new MenuCollection();
     foreach (Menu menu in GetMenuData())
     {
         if (menu.ParentId == 0)
             rootMenus.Add(menu);
     }
     return rootMenus;
 }
        public override IHierarchicalEnumerable Select()
        {
            MenuCollection collection = new MenuCollection();
            foreach (Menu menu in Common.GetMenuData())
            {
                if (menu.ParentId == 0)
                    collection.Add(menu);
            }

            return collection;
        }
Ejemplo n.º 5
0
        public static MenuCollection GetMenuCollection()
        {
            string         _Folder  = daitiphu.common.tinhnang.IOHelper.GetDirectory("~/App_Data/XML/");
            string         fileName = _Folder;
            MenuCollection menus    = new MenuCollection();

            try
            {
                fileName = _Folder + ConfigurationManager.AppSettings["xmlMenuFile"].ToString();

                if (File.Exists(fileName))
                {
                    DataSet ds = new DataSet();
                    ds.ReadXml(fileName);
                    int i = 0;
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        menus.Add(new MenuModel()
                        {
                            MenuID       = dr["MenuID"].ToString(),
                            MenuDesc     = dr["MenuDesc"].ToString(),
                            Path         = dr["Path"].ToString(),
                            ParentMenuID = dr["ParentMenuID"].ToString()
                        });
                        i++;
                    }
                }
            }
            catch (Exception objEx)
            {
                menus.Add(new MenuModel()
                {
                    MenuID   = "0",
                    MenuDesc = objEx.Message + "/" + fileName,
                    //Path = dr["Path"].ToString(),
                    //  ParentMenuID = dr["ParentMenuID"].ToString()
                });
            }
            return(menus);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 添加菜单、命令到系统缓存中
        /// </summary>
        /// <param name="modelID">模块ID</param>
        /// <returns></returns>
        public static void AddMenuToCache(IMenu model)
        {
            if (Cache.CustomCache.Contains(SystemString.菜单栏))
            {
                MenuStrip MainMenu = (MenuStrip)Cache.CustomCache[SystemString.菜单栏];

                MenuStrip ModelMenu = model.MainMenu;
                IModule   Model     = model as IModule;
                String    modelID   = Model.BizID;

                Dictionary <string, ToolStripItem[]> MenuCollection = null;
                if (Cache.CustomCache.Contains(MenuKey))
                {
                    MenuCollection = (Dictionary <string, ToolStripItem[]>)Cache.CustomCache[MenuKey];
                }
                else
                {
                    MenuCollection = new Dictionary <string, ToolStripItem[]>();
                    Cache.CustomCache.Add(MenuKey, MenuCollection);
                }

                ToolStripItem[] WillAddedItems = new ToolStripItem[ModelMenu.Items.Count];
                ModelMenu.Items.CopyTo(WillAddedItems, 0);
                MenuCollection.Add(modelID, WillAddedItems);
            }

            if (Cache.CustomCache.Contains(SystemString.工具栏))
            {
                ToolStrip MainTool = (ToolStrip)Cache.CustomCache[SystemString.工具栏];

                ToolStrip ModelCommand = model.MainTool;
                IModule   Model        = model as IModule;
                String    modelID      = Model.BizID;

                Dictionary <string, ToolStripItem[]> CommandCollection = null;
                if (Cache.CustomCache.Contains(CommandKey))
                {
                    CommandCollection = Cache.CustomCache[CommandKey] as Dictionary <string, ToolStripItem[]>;
                }
                else
                {
                    CommandCollection = new Dictionary <string, ToolStripItem[]>();
                    Cache.CustomCache.Add(CommandKey, CommandCollection);
                }

                ToolStripItem[] WillAddedCommands = new ToolStripItem[ModelCommand.Items.Count];
                ModelCommand.Items.CopyTo(WillAddedCommands, 0);
                CommandCollection.Add(modelID, WillAddedCommands);
            }
        }
Ejemplo n.º 7
0
        private MenuCollection MakeSingleLevelMenu(MenuCollection menuCollection)
        {
            MenuCollection newMenu = new MenuCollection();

            var mainMenuItem = new Expanz.ThinRIA.Core.MenuItem();
            mainMenuItem.Title = "main menu";

            newMenu.Add(mainMenuItem);

            foreach (var menuItem in menuCollection)
            {
                mainMenuItem.Add(menuItem[0]);
            }

            return newMenu;
        }
Ejemplo n.º 8
0
        public void AddMenu(IMenu menu)
        {
            if (m_Menus == null)
            {
                return;
            }

            if (m_Menus.Count >= m_MenuCap)
            {
                Console.WriteLine("Client: {0}: Exceeded menu cap, disconnecting...", this);
                Dispose();
            }
            else
            {
                m_Menus.Add(menu);
            }
        }
Ejemplo n.º 9
0
        private MenuCollection MakeSingleLevelMenu(MenuCollection menuCollection)
        {
            MenuCollection newMenu = new MenuCollection();

            var mainMenuItem = new Expanz.ThinRIA.Core.MenuItem();

            mainMenuItem.Title = "main menu";

            newMenu.Add(mainMenuItem);

            foreach (var menuItem in menuCollection)
            {
                mainMenuItem.Add(menuItem[0]);
            }

            return(newMenu);
        }
Ejemplo n.º 10
0
        public void AddMenu(IMenu menu)
        {
            if (m_Menus == null)
            {
                return;
            }

            if (m_Menus.Count >= m_MenuCap)
            {
                log.WarnFormat("Client: {0}: Exceeded menu cap, disconnecting...",
                               this);
                Dispose();
            }
            else
            {
                m_Menus.Add(menu);
            }
        }
Ejemplo n.º 11
0
        private void PivotMenu_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.IsInDesignTool)
            {
                // Some design-time data
                var processMenu = new ProcessAreaItem();
                processMenu.Title = "Process Area 1";

                for (int index = 1; index < 6; index++)
                {
                    var activityItem = new ActivityItem();
                    activityItem.Title = "Activity " + index.ToString();
                    processMenu.Add(activityItem);
                }

                MenuCollection menuCollection = new MenuCollection();
                menuCollection.Add(processMenu);

                processMenu = new ProcessAreaItem();
                processMenu.Title = "Process Area 2";

                for (int index = 1; index < 6; index++)
                {
                    var activityItem = new ActivityItem();
                    activityItem.Title = "Activity " + index.ToString();
                    processMenu.Add(activityItem);
                }

                menuCollection.Add(processMenu);

                this.ItemsSource = menuCollection;
            }
            else
            {
                MenuCollection menu = ApplicationEx.Instance.ApplicationMenu;

                if (ShouldMakeSingleLevelMenu(menu))
                    menu = MakeSingleLevelMenu(menu);

                this.ItemsSource = menu;
            }
        }
Ejemplo n.º 12
0
        public ActionResult Main()
        {
            var user = SysService.GetCurrentUser();

            if (user == null)
            {
                return(Redirect("Account/Login"));
            }

            if (user.UserID.Equals("U00001"))
            {
                return(View(AppConfig.Current.Menus));
            }

            var userPages = SysService.GetUserPages(user.UserID);
            Dictionary <string, Page> pages = new Dictionary <string, Page>();

            foreach (var group in AppConfig.Current.PageGroups)
            {
                foreach (var item in group.Pages)
                {
                    pages[item.PageID] = item;
                }
            }

            Func <Menu, bool> isUserPage = (m) =>
            {
                if (string.IsNullOrWhiteSpace(m.Src))
                {
                    return(true);
                }

                if (!m.Src.StartsWith("Page", StringComparison.OrdinalIgnoreCase))
                {
                    return(true);
                }

                if (m.Src.Length < 11)
                {
                    return(true);
                }
                var pageID = m.Src.Substring(5, 6);

                var userPage = userPages.FirstOrDefault(p => p.PageID.Equals(pageID, StringComparison.OrdinalIgnoreCase));
                if (userPage == null)
                {
                    return(false);
                }

                Page page = pages.GetDictionaryValue(pageID, null);
                if (page == null)
                {
                    return(false);
                }

                var index      = m.Src.IndexOf('?');
                var actionName = m.Src.Length < 12 ? "Index" :
                                 index > 0 ? m.Src.Substring(12, index - 12) :
                                 m.Src.Substring(12);
                var action = page.Config.Actions.FirstOrDefault(a => a.Name.Equals(actionName, StringComparison.OrdinalIgnoreCase));
                if (action == null)
                {
                    return(false);
                }

                if (action.ActionValue == 0)
                {
                    return(true);
                }

                return((userPage.ActionValue & action.ActionValue) == action.ActionValue);
            };

            MenuCollection menus    = new MenuCollection();
            Menu           topmenus = new Menu();

            foreach (var topm in AppConfig.Current.Menus)
            {
                var menu = new Menu {
                    Title = topm.Title, Name = topm.Name
                };
                foreach (var group in topm.Menus)
                {
                    var smenus = group.Menus.Where(m => isUserPage(m)).ToList();
                    if (smenus.Count == 0)
                    {
                        continue;
                    }
                    var tmenu = new Menu {
                        Title = group.Title, Name = group.Name
                    };
                    smenus.AddToCollection(tmenu.Menus);
                    menu.Menus.Add(tmenu);
                    //menusAdd(tmenu);
                }
                menus.Add(menu);
            }

            //foreach (var group in topmenus.Menus)
            //{


            //    var menu = new Menu { Title = group.Title, Name= group.Name };
            //    smenus.AddToCollection(menu.Menus);
            //    menus.Add(menu);
            //}

            return(View(menus));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Returns the ContextMenu used when the user Right-Click on a selected cell.
        /// </summary>
        /// <returns></returns>
        public virtual MenuCollection GetContextMenus()
        {
            MenuCollection l_Array = new MenuCollection();

            bool l_EnableCopyPasteSelection = false;

            if ((m_Grid.ContextMenuStyle & ContextMenuStyle.CopyPasteSelection) == ContextMenuStyle.CopyPasteSelection)
            {
                l_EnableCopyPasteSelection = true;
            }

            bool l_EnableClearSelection = false;

            if ((m_Grid.ContextMenuStyle & ContextMenuStyle.ClearSelection) == ContextMenuStyle.ClearSelection)
            {
                l_EnableClearSelection = true;
            }

//			bool l_EnablePropertySelection = false;
//			if ( (m_Grid.ContextMenuStyle & ContextMenuStyle.PropertySelection) == ContextMenuStyle.PropertySelection)
//				l_EnablePropertySelection = true;

            if (m_ContextMenuItems != null && m_ContextMenuItems.Count > 0)
            {
                foreach (MenuItem m in m_ContextMenuItems)
                {
                    l_Array.Add(m);
                }

                if (l_EnableClearSelection || l_EnableCopyPasteSelection)                  //|| l_EnablePropertySelection)
                {
                    l_Array.Add(new MenuItem("-"));
                }
            }

            if (l_EnableCopyPasteSelection)
            {
//				//CUT (not implemented)
//				MenuItem l_mnCut = new MenuItemImage("Cut", new EventHandler(Selection_Cut), m_MenuImageList, m_iImageCut);
//				l_mnCut.Enabled = false;
//				l_Array.Add(l_mnCut);

                //COPY
                MenuItem l_mnCopy = new MenuItemImage("Copy", new EventHandler(Selection_Copy), m_MenuImageList, m_iImageCopy);
                l_Array.Add(l_mnCopy);

                //PASTE
                MenuItem l_mnPaste = new MenuItemImage("Paste", new EventHandler(Selection_Paste), m_MenuImageList, m_iImagePaste);
                l_mnPaste.Enabled = IsValidClipboardForPaste();
                l_Array.Add(l_mnPaste);
            }

            if (l_EnableClearSelection)
            {
                if (l_EnableCopyPasteSelection)                // && l_EnablePropertySelection)
                {
                    l_Array.Add(new MenuItem("-"));
                }

                MenuItem l_mnClear = new MenuItemImage("Clear", new EventHandler(Selection_ClearValues), m_MenuImageList, m_iImageClear);
                l_Array.Add(l_mnClear);
            }
//			if (l_EnablePropertySelection)
//			{
//				MenuItem l_mnFormatCells = new MenuItem("Format Cells ...", new EventHandler(Selection_FormatCells));
//				m_Grid.SetMenuImage(l_mnFormatCells,m_iImageFormatCells);
//				l_Array.Add(l_mnFormatCells);
//			}

            return(l_Array);
        }
Ejemplo n.º 14
0
        public static MenuCollection GetMenuData()
        {
            // Simulate going to the database or pulling from a local cache
            if (collection == null)
            {

                collection = new MenuCollection();
                collection.Add(new Menu(1, 0, "File"));
                collection.Add(new Menu(2, 0, "Edit"));
                collection.Add(new Menu(3, 0, "View"));

                collection.Add(new Menu(10, 1, "New"));
                collection.Add(new Menu(11, 1, "Open"));
                collection.Add(new Menu(12, 1, "Add"));

                collection.Add(new Menu(20, 2, "Cut"));
                collection.Add(new Menu(21, 2, "Copy"));
                collection.Add(new Menu(22, 2, "Paste"));

                collection.Add(new Menu(101, 10, "Project"));
                collection.Add(new Menu(102, 10, "Solution"));
            }

            return collection;
        }