static void Main(string[] args)
        {
            MenuCollection menus = MenuGenerator.CreateMenuCollection();

            menus.ShowMenu(1);
            Console.ReadKey();
        }
Beispiel #2
0
        public NetState(Socket socket, MessagePump messagePump)
        {
            m_Socket      = socket;
            m_Buffer      = new ByteQueue();
            m_Seeded      = false;
            m_Running     = false;
            m_RecvBuffer  = m_ReceiveBufferPool.AquireBuffer();
            m_MessagePump = messagePump;
            m_Gumps       = new GumpCollection();
            m_HuePickers  = new HuePickerCollection();
            m_Menus       = new MenuCollection();
            m_Trades      = new ArrayList();

            m_SendQueue = new SendQueue();

            m_NextCheckActivity = DateTime.Now + TimeSpan.FromMinutes(0.5);

            m_Instances.Add(this);

            try{ m_Address = ((IPEndPoint)m_Socket.RemoteEndPoint).Address; m_ToString = m_Address.ToString(); }
            catch { m_Address = IPAddress.None; m_ToString = "(error)"; }

            if (m_CreatedCallback != null)
            {
                m_CreatedCallback(this);
            }
        }
        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;
        }
Beispiel #4
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);
 }
Beispiel #5
0
        public override void OnContextMenuPopUp(CellContext sender, ContextMenuEventArgs e)
        {
            base.OnContextMenuPopUp(sender, e);

            Models.IContextMenu modelMenu;
            modelMenu = (Models.IContextMenu)sender.Cell.Model.FindModel(typeof(Models.IContextMenu));
            if (modelMenu != null)
            {
                MenuCollection l_Menus = modelMenu.GetContextMenu(sender);
                if (l_Menus != null && l_Menus.Count > 0)
                {
                    if (e.ContextMenu.Count > 0)
                    {
                        System.Windows.Forms.MenuItem l_menuBreak = new System.Windows.Forms.MenuItem();
                        l_menuBreak.Text = "-";
                        e.ContextMenu.Add(l_menuBreak);
                    }

                    foreach (System.Windows.Forms.MenuItem m in l_Menus)
                    {
                        e.ContextMenu.Add(m);
                    }
                }
            }
        }
Beispiel #6
0
        private static void HandleMenu(Action defaultAction)
        {
            // ReSharper disable once JoinDeclarationAndInitializer
            bool throwError;

#if DEBUG
            throwError = true;
#else
            throwError = false;
#endif
            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            var menu = new MenuCollection(GetCopyrightMessage(), throwError)
            {
                defaultAction,
#if !DEBUG
                InstallService,
                UnInstallService,
#else
                DebuggerHelper.CallDebugger,
                //XmlTraceSourceSample
                //ConfigReader,
                //SchemaReader,
                //Draft.TraceTester
#endif
            };
            menu.Run();
        }
Beispiel #7
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();
        }
Beispiel #8
0
        //public static ResourceManager language;
        static void Main(string[] args)
        {
            //ResourceManager rm = new ResourceManager("English.resx", Assembly.GetExecutingAssembly()); // learn what this is - reflection

            Console.WriteLine(Language.welcome_message);

            SchoolModel school = new SchoolModel();
            SchoolController schoolController = new SchoolController(school);

            /* ROOT OF ALL MENU */
            MenuItem generate = new MenuItem(Language.generate_students_teachers_and_classes, null, null);
            MenuItem show     = new MenuItem(Language.show, null, null);
            MenuItem actions = new MenuItem(Language.actions, null, null);
            MenuItem[] rootItems = { generate,show, actions };
            MenuCollection root = new MenuCollection(rootItems, null);

            /* Generate Methods for generate */
            MenuItem generateTeachers = new MenuItem(Language.generate_teachers,null, () => { schoolController.generateTeachersToQueue();});
            MenuItem generateStudents = new MenuItem(Language.generate_students, null, () => { schoolController.generateStudentsToQueue(); });
            MenuItem execute = new MenuItem(Language.execute,null, () => { schoolController.execute();});
            MenuItem[] generateMenuItems = {generateTeachers, generateStudents, execute};
            MenuCollection generateStudentTeachersAndClasses = new MenuCollection(generateMenuItems,root); // yet null, we need construct it

            /* Generate Methods for show */
            MenuItem showAllClasses = new MenuItem(Language._class, null, schoolController.showAllClasses);
            MenuItem showAllTeachers = new MenuItem(Language.teachers , null, schoolController.showAllTeachers);
            MenuItem showAllStudents = new MenuItem(Language.students, null, schoolController.showAllStudents);
            MenuItem showAllStudentsSortedByName = new MenuItem(Language.all_teachers_by_name, null, schoolController.showAllStudentsSortedByFirstName);
            MenuItem showAllTeachersRegex = new MenuItem(Language.show_all_teachers_matching_regex, null, schoolController.searchThroughTeachersRegex);

            MenuItem[] presentation = { showAllClasses, showAllTeachers, showAllStudents, showAllStudentsSortedByName, showAllTeachersRegex };
            MenuCollection showMenuCollection = new MenuCollection(presentation, root);

            /* Generate Methods for action */

            /*MenuItem addClass = new MenuItem(Language,addClass, null, schoolController.hireTEacher);
            MenuItem removeClass = new MenuItem(Language.remove_class, null, schoolController.hireTEacher);
            */

            MenuItem addTeacher = new MenuItem(Language.hire_teacher, null, schoolController.hireTeacher);
            MenuItem layOffTeacher = new MenuItem(Language.lay_off_teacher, null, schoolController.laOffTeacher);

            /*
            MenuItem addStudent = new MenuItem(Language.admit_student, null, schoolController.deleteTeacher);
            MenuItem layOffStudent = new MenuItem(Language.lay_off_student, null, schoolController.deleteTeacher);
            */
            MenuItem[] actionsMenuItems = { addTeacher, layOffTeacher };
            MenuCollection actionsMenuCollection = new MenuCollection(actionsMenuItems, root);  // ASK ABOUT STYLE   mainMenu actions  --or-- mainMenu actionsMainMenu

            generate.subMenu = generateStudentTeachersAndClasses;  // link rootITEM to the sub menu...
            show.subMenu = showMenuCollection;
            actions.subMenu = actionsMenuCollection;

            MenuCollectionController mCC = new MenuCollectionController(root);
            mCC.interact();
        }
 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;
        }
Beispiel #11
0
        public static MenuCollection CreateMenuCollection()
        {
            MenuCollection collection = new MenuCollection();

            //Declarative way of building a menu, there are also generator methods you can use.
            return(new MenuCollection()
            {
                Menus =
                {
                    new Menu()
                    {
                        // give the menu an identifier
                        MenuId = 1,
                        MenuItems =
                        {
                            new MenuItem()
                            {
                                Text = "Open Sub Menu",
                                // if you want to link to another menu, then set the other menu's id
                                SubMenuId = 2
                            },
                            new MenuItem()
                            {
                                Text = "Print hello world!",
                                //or if you want to perform an action, set the Action property
                                Action = () => Console.WriteLine("Hello World!")
                            }
                        }
                    },
                    new Menu()
                    {
                        MenuId = 2,
                        MenuItems =
                        {
                            new MenuItem()
                            {
                                Text = "Print Hello",
                                Action = () => Console.WriteLine("Hello")
                            },
                            new MenuItem()
                            {
                                Text = "Print Goodbye",
                                Action = () => Console.WriteLine("Goodbye")
                            },
                            new MenuItem()
                            {
                                Text = "Back to the top menu",
                                SubMenuId = 1
                            }
                        }
                    }
                }
            });
        }
Beispiel #12
0
        protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            CMS.Menu dv = (CMS.Menu)e.Item.DataItem;
            if (dv.Childs.Count != 0)
            {
                Repeater       repeater2     = (Repeater)e.Item.FindControl("Repeater2");
                MenuCollection listMenuChild = MenuCollection.GetMenuChildCollection(dv.Id);

                repeater2.DataSource = listMenuChild.GetBindingSource();
                repeater2.DataBind();
            }
        }
Beispiel #13
0
        /// <summary>
        /// WelcomeScreen constructor.
        /// </summary>
        /// <param name="i_ScreensManager">Screen manager.</param>
        public WelcomeScreen(ScreensManager i_ScreensManager)
            : base(i_ScreensManager, @"Backgrounds\BG_Space01_1024x768")
        {
            int midX = Game.Window.ClientBounds.Width / 2;

            string[] options = new string[3];
            options[0]       = "Press 'Enter' to start play";
            options[1]       = "Press 'Esc' to close the game";
            options[2]       = "Press 'N' to view main menu";
            m_menuCollection = new MenuCollection(i_ScreensManager.Game, options, null, sr_linesGapProportion);
            addConstComponents(m_menuCollection);
        }
        /// <summary>
        /// Adding guiding labels.
        /// </summary>
        private void addKeysLabels()
        {
            string[] options = new string[3];
            options[0] = "Press 'Esc' to close the game";
            options[1] = "Press 'Home' to restart";
            options[2] = "Press 'N' to view main menu";
            int            thridHeightScreen = Game.Window.ClientBounds.Height / 3;
            Rectangle      screenBoundries   = new Rectangle(0, 2 * thridHeightScreen, Game.Window.ClientBounds.Width, thridHeightScreen);
            MenuCollection keysOptions       = new MenuCollection(ScreensManager.Game, options, screenBoundries, 0.5f);

            keysOptions.Enabled = false;
            AddComponents(keysOptions);
        }
        private void BuildMenu()
        {
            (string Text, Icon Icon) = Id.IsEmpty() ? ("Create", IconHelper.Add) : ("Save", IconHelper.Save);

            MenuCollection = new MenuCollection()
            {
                new MenuButton(Text, async() => await Save(), Icon, CanSave),
                new MenuDivider(),
                !Id.IsEmpty() ? new MenuButton("Delete", async() => await ShowDeleteDialog(), IconHelper.Delete, true) : null,
                !Id.IsEmpty() ? new MenuDivider() : null,
                new MenuItem("Cancel", NavigationHelper.Metadata.MetadataPage(), IconHelper.Cancel, true),
            };
        }
Beispiel #16
0
        /// <summary>
        /// Fired when the contextmenu is showed
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPopup(EventArgs e)
        {
            this.MenuItems.Clear();

            base.OnPopup(e);

            MenuCollection l_Menus = m_Grid.GetGridContextMenus();

            for (int i = 0; i < l_Menus.Count; i++)
            {
                MenuItems.Add(l_Menus[i]);
            }
        }
Beispiel #17
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);
            }
        }
        protected override void OnParametersSet()
        {
            base.OnParametersSet();

            Context = StateCacheService.GetOrCreate(() => new RunContext <MetadataRecord>());

            MenuCollection = new MenuCollection()
            {
                new MenuItem("Create", NavigationHelper.Metadata.NewMetadataPage(), IconHelper.Create, true),
                new MenuDivider(),
                new MenuButton("Refresh", async() => await GetLinks(), IconHelper.Reload, true),
                new MenuButton("Clear search", ResetSearch, IconHelper.Reset, true),
            };
        }
Beispiel #19
0
        private void LoadTabControl()
        {
            Guid menuParent;

            using (var con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PSCPortalConnectionString"].ConnectionString))
            {
                var com = new SqlCommand {
                    Connection = con
                };
                con.Open();
                com.CommandType = CommandType.Text;
                com.Parameters.AddWithValue("@dataId", Portlet.PortletInstance.Id);
                com.CommandText = "Select MenuId from PortletMenu p INNER JOIN MenuMaster m ON p.MenuMasterId =  m.MenuMasterId Where DataId = @dataId";
                menuParent      = com.ExecuteScalar() != null ? new Guid(com.ExecuteScalar().ToString()) : Guid.Empty;
            }
            if (menuParent == Guid.Empty)
            {
                return;
            }
            MenuCollection listMenu = MenuCollection.GetMenuChildCollection(menuParent);

            radTabMenu.Tabs.Clear();
            radMultiPageMenu.PageViews.Clear();
            BusinessObjectHierarchicalCollection childs = listMenu.Search(o => ((Menu)o).Id == menuParent).Childs;

            if (childs.Count > 0)
            {
                for (int i = 0; i < childs.Count; i++)
                {
                    var tab = new RadTab();
                    var sub = (Menu)childs[i];
                    if (sub == null)
                    {
                        return;
                    }
                    tab.Text = sub.Name;
                    radTabMenu.Tabs.Add(tab);
                    var pvTopic = new RadPageView {
                        ID = "pvSub" + i
                    };
                    radMultiPageMenu.PageViews.Add(pvTopic);
                    const string userControlName = "Portlets/TabMenu/SubPanelBar.ascx";
                    var          userControl     = (SubPanelBar)Page.LoadControl(userControlName);
                    pvTopic.Controls.Add(userControl);
                    userControl.Menu = sub;
                    userControl.LoadData();
                }
            }
        }
        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;
        }
        private bool ShouldMakeSingleLevelMenu(MenuCollection menuCollection)
        {
            // If every category has only 1 item, then merge all the items
            // into a single level menu
            bool useSingleLevelMenu = true;

            foreach (var menuItem in menuCollection)
            {
                if (menuItem.Count > 1 || menuItem[0].Count != 0 || menuItem[0].IsCategory)
                {
                    useSingleLevelMenu = false;
                    break;
                }
            }

            return(useSingleLevelMenu);
        }
        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);
        }
        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;
            }
        }
        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;
            }
        }
Beispiel #25
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;
                            }
                        }
                    }
                }
            }
        }
Beispiel #26
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);
        }
Beispiel #27
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)
     {
     }
 }
Beispiel #28
0
        public override void OnContextMenuPopUp(PositionContextMenuEventArgs e)
        {
            base.OnContextMenuPopUp(e);
            if (e.Cell is ICellContextMenu)
            {
                ICellContextMenu l_ContextMenu = (ICellContextMenu)e.Cell;
                MenuCollection   l_Menus       = l_ContextMenu.GetContextMenu(e.Position);
                if (l_Menus != null && l_Menus.Count > 0)
                {
                    if (e.ContextMenu.Count > 0)
                    {
                        System.Windows.Forms.MenuItem l_menuBreak = new System.Windows.Forms.MenuItem("-");
                        e.ContextMenu.Add(l_menuBreak);
                    }

                    foreach (System.Windows.Forms.MenuItem m in l_Menus)
                    {
                        e.ContextMenu.Add(m);
                    }
                }
            }
        }
Beispiel #29
0
        private void TestOku()
        {
            //= PostgreSqlConnectionProvider.GetConnectionString("192.168.2.19", 5432, "whm", "whm123", "WHM");
            DataComponent data = new DataComponent();
            data.DatabaseType = DatabaseTypes.PostgreSQL;
            //data.DataSource = "192.168.2.19";
            data.ConnectionString = "Server=192.168.2.19;User Id=whm;Password=whm123;Database=WHM;Port=5432";
            //data.Database = "WHM";
            //data.Username = "******";
            //data.Password = "******";
            data.Open();

            MenuCollection mnuCol = new MenuCollection();
            mnuCol.Load(data);
            if (mnuCol.Count > 0)
            {
                foreach (var mnu in mnuCol)
                {
                    Console.WriteLine(mnu.Id);
                }
            }

            //data.GetDataTable();
        }
 public MenuCollectionController(MenuCollection root)
 {
     this.root = root;
 }
Beispiel #31
0
        public MenuCollection BuildSidebarMenu(string menuTitle, string selected)
        {
            var associateMenuTitles = new List <string> {
                "Associates", "New Hires", "Terminations", "Changed"
            };
            var adminMenuTitles = new List <string> {
                "Admin", "Activity Log", "Job Codes", "Roles", "Rules", "Reports", "Settings"
            };

            var items = new List <MenuRoutedLink>();

            items.Add(new MenuRoutedLink {
                Text = "Home", Action = "Index", Controller = "Home"
            });
            items.Add(new MenuRoutedLink
            {
                Text       = "Associates",
                Action     = "Index",
                Controller = "People"
            });

            if (associateMenuTitles.Any(x => x.Equals(selected)))
            {
                items.Add(new MenuRoutedLink {
                    Text = "New Hires", Action = "ReviewQueue", Controller = "People", RouteValuesCollection = new { status = "Hire" }, Indented = 2
                });
                items.Add(new MenuRoutedLink {
                    Text = "Terminations", Action = "ReviewQueue", Controller = "People", RouteValuesCollection = new { status = "Fire" }, Indented = 2
                });
                items.Add(new MenuRoutedLink {
                    Text = "Changed", Action = "ReviewQueue", Controller = "People", RouteValuesCollection = new { status = "Changed" }, Indented = 2
                });
            }

            items.Add(new MenuRoutedLink {
                Text = "Admin", Action = "Index", Controller = "Admin"
            });

            if (adminMenuTitles.Any(x => x.Equals(selected)))
            {
                if (IsAdmin)
                {
                    items.Add(new MenuRoutedLink {
                        Text = "Activity Log", Action = "ActivityLog", Controller = "Admin", Indented = 2
                    });

                    var ruleAdmin = Settings.GetValueAsBool(Artifacts.Constants.R1SMSystemName, "RuleEngineAllow");

                    if (ruleAdmin)
                    {
                        items.Add(new MenuRoutedLink
                        {
                            Text       = "Job Codes",
                            Action     = "JobCodes",
                            Controller = "Admin",
                            Indented   = 2
                        });
                        items.Add(new MenuRoutedLink
                        {
                            Text       = "Roles",
                            Action     = "Index",
                            Controller = "Roles",
                            Indented   = 2
                        });
                        items.Add(new MenuRoutedLink
                        {
                            Text       = "Rules",
                            Action     = "Index",
                            Controller = "JCLRule",
                            Indented   = 2
                        });
                        items.Add(new MenuRoutedLink
                        {
                            Text       = "Reports",
                            Action     = "Reports",
                            Controller = "Admin",
                            Indented   = 2
                        });
                    }
                    items.Add(new MenuRoutedLink
                    {
                        Text       = "Settings",
                        Action     = "Index",
                        Controller = "Settings",
                        Indented   = 2
                    });
                }
            }

            var menu = new MenuCollection
            {
                Title            = menuTitle,
                SelectedMenuText = selected,
                LinkCollection   = items
            };

            return(menu);
        }
Beispiel #32
0
 public MenuItem(string description, MenuCollection subMenu, Action action)
 {
     this.description = description;
     this.subMenu = subMenu;
     this.action = action;
 }
Beispiel #33
0
        private void RemoveObjects()
        {
            try
            {
                string loggedUser = Session["username"] as string;
#if DEBUG
                if (loggedUser == "DEVELOPER")
                {
                    return;
                }
#endif

                UsuarioLogic usuariologic = new UsuarioLogic();

                List <COCASJOL.DATAACCESS.privilegio> privs = usuariologic.GetPrivilegiosDeUsuario(loggedUser);

                XmlDocument doc = new XmlDocument();
                doc.Load(Server.MapPath(System.Configuration.ConfigurationManager.AppSettings.Get("privilegesXML")));

                XmlNodeList nodes = doc.SelectNodes("privilegios/privilege");

                DesktopShortcuts            listDS = this.MyDesktop.Shortcuts;
                DesktopModulesCollection    listDM = this.MyDesktop.Modules;
                ItemsCollection <Component> listIC = this.MyDesktop.StartMenu.Items;

                if (privs.Count == 0)
                {
                    listDS.Clear();
                    listDM.Clear();
                    listIC.Clear();
                }
                else
                {
                    foreach (XmlNode node in nodes)
                    {
                        XmlNode keyNode      = node.SelectSingleNode("key");
                        XmlNode moduleNode   = node.SelectSingleNode("module");
                        XmlNode shortcutNode = node.SelectSingleNode("shortcut");
                        XmlNode menuitemNode = node.SelectSingleNode("menuitem");

                        string key      = keyNode.InnerText.Replace("\t", "").Replace("\r\n", "").Replace("\n", "").Trim();
                        string module   = moduleNode.InnerText.Replace("\t", "").Replace("\r\n", "").Replace("\n", "").Trim();
                        string shortcut = shortcutNode.InnerText.Replace("\t", "").Replace("\r\n", "").Replace("\n", "").Trim();
                        string menuitem = menuitemNode.InnerText.Replace("\t", "").Replace("\r\n", "").Replace("\n", "").Trim();

                        var query = from p in privs.AsParallel()
                                    where p.PRIV_LLAVE == key
                                    select p;

                        if (query.Count() == 0)
                        {
                            for (int x = 0; x < listDS.Count; x++)
                            {
                                DesktopShortcut ds = listDS.ElementAt(x);

                                if (ds.ShortcutID == shortcut)
                                {
                                    listDS.Remove(ds);
                                }
                            }

                            for (int x = 0; x < listDM.Count; x++)
                            {
                                DesktopModule dm = listDM.ElementAt(x);

                                if (dm.ModuleID == module)
                                {
                                    listDM.Remove(dm);
                                }
                            }

                            for (int x = 0; x < listIC.Count; x++)
                            {
                                Component item = listIC.ElementAt(x);

                                if (item is Ext.Net.MenuItem)
                                {
                                    Ext.Net.MenuItem menuItem = (Ext.Net.MenuItem)item;

                                    if (menuItem.Menu.Count > 0)
                                    {
                                        MenuCollection menu = menuItem.Menu;

                                        for (int y = 0; y < menu.Primary.Items.Count; y++)
                                        {
                                            Component itm = menu.Primary.Items.ElementAt(y);
                                            if (itm.ID == menuitem)
                                            {
                                                menu.Primary.Items.Remove(itm);
                                            }
                                        }
                                    }

                                    if (menuItem.Menu.Primary.Items.Count == 0)
                                    {
                                        listIC.Remove(menuItem);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al remover objetos sin acceso.", ex);
                throw;
            }
        }
Beispiel #34
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));
        }
 private void selectItem(int i)
 {
     MenuItem selectedItem = this.root.getMenuItem(i);
     if (selectedItem.subMenu == null)  // How can I overcome this by encapsulation ?
     {
         //Console.WriteLine("sub is null");
         selectedItem.action();
         //this.interact();  // What happend where when it wasn't commented out
     }
     else
     {
         //Console.WriteLine("sub is NOT null");
         this.root = selectedItem.subMenu;
     }
 }
 public MenuBarViewModel()
 {
     Menus = new MenuCollection();
 }
Beispiel #37
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);
        }
Beispiel #38
0
 public PositionContextMenuEventArgs(Position p_Position, Cells.ICellVirtual p_Cell, MenuCollection p_ContextMenu) : base(p_Position, p_Cell)
 {
     m_ContextMenu = p_ContextMenu;
 }
Beispiel #39
0
        /// <summary>
        /// 显示菜单、命令到主窗口中
        /// </summary>
        /// <param name="modelID">模块</param>
        /// <returns></returns>
        public static void ShowMenuAtMainForm(String modelID, ToolStripMenuItem[] ExistingMenuItem)
        {
            if (Cache.CustomCache.Contains(SystemString.菜单栏))
            {
                MenuStrip MainMenu = (MenuStrip)Cache.CustomCache[SystemString.菜单栏];

                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);
                }

                MainMenu.Items.Clear();
                MainMenu.Items.AddRange(ExistingMenuItem);

                ToolStripItem[] WillAddedItems = null;
                if (MenuCollection.ContainsKey(modelID))
                {
                    WillAddedItems = MenuCollection[modelID];
                }

                if (WillAddedItems != null)
                {
                    for (int i = 0; i < WillAddedItems.Length; i++)
                    {
                        WillAddedItems[i].ImageTransparentColor = Color.White;
                        MainMenu.Items.Insert(0, WillAddedItems[i]);
                    }
                }
            }

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

                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);
                }

                MainTool.Items.Clear();

                ToolStripItem[] WillAddedCommands = null;
                if (CommandCollection.ContainsKey(modelID))
                {
                    WillAddedCommands = CommandCollection[modelID];
                }

                if (WillAddedCommands != null)
                {
                    MainTool.SuspendLayout();
                    for (int i = 0; i < WillAddedCommands.Length; i++)
                    {
                        WillAddedCommands[i].TextImageRelation     = TextImageRelation.ImageAboveText;
                        WillAddedCommands[i].ImageTransparentColor = Color.White;
                        WillAddedCommands[i].Font = new Font("宋体", 9);

                        MainTool.Items.Add(WillAddedCommands[i]);
                    }
                    MainTool.ResumeLayout();
                }
            }
        }
Beispiel #40
0
 public ViewModel()
 {
     WeekMenus = new WeekMenuCollection();
     Menus = new MenuCollection();
 }
 private bool newMenu(MenuCollection root)
 {
     this.root = root;
     return !(this.root == null);
 }
Beispiel #42
0
 public MenuBarViewModel()
 {
     Menus = new MenuCollection();
 }
        private bool ShouldMakeSingleLevelMenu(MenuCollection menuCollection)
        {
            // If every category has only 1 item, then merge all the items
            // into a single level menu
            bool useSingleLevelMenu = true;

            foreach (var menuItem in menuCollection)
            {
                if (menuItem.Count > 1 || menuItem[0].Count != 0 || menuItem[0].IsCategory)
                {
                    useSingleLevelMenu = false;
                    break;
                }
            }

            return useSingleLevelMenu;
        }