예제 #1
0
        public static void RunMenu <T>(T instance)
        {
            var menu = new ConzapMenu();
            var type = typeof(T);
            var menuItemAttributedMethods = type.GetMethods().
                                            Where(m => m.GetCustomAttributes(typeof(ConzapMenuItemAttribute), true).Count() > 0);

            foreach (var menuItemMethod in menuItemAttributedMethods)
            {
                ConzapMenuItemAttribute metaData = menuItemMethod.GetCustomAttributes(typeof(ConzapMenuItemAttribute), true)[0] as ConzapMenuItemAttribute;
                var index          = metaData.Index;
                var header         = metaData.Header;
                var delegateAction = (Action)menuItemMethod.CreateDelegate(typeof(Action), instance);
                menu.Add(header, delegateAction);
            }
            menu.Run();
        }
예제 #2
0
        public static void RunMenu(params ConzapMenuItem[] menuItems)
        {
            var menu = new ConzapMenu(menuItems.ToList());

            menu.Run();
        }