Пример #1
0
        private MenuItem CreateMenuItemWidget(IJournalAction action)
        {
            MenuItem menuItem = new MenuItem(action.Title);

            menuItem.Activated += (sender, e) => {
                action.ExecuteAction(GetSelectedItems());
            };

            actionsSensitivity.Add(() => {
                menuItem.Sensitive = action.GetSensitivity(GetSelectedItems());
            });

            actionsVisibility.Add(() => {
                menuItem.Visible = action.GetVisibility(GetSelectedItems());
            });

            if (action.ChildActions.Any())
            {
                foreach (var childAction in action.ChildActions)
                {
                    menuItem.Add(CreateMenuItemWidget(childAction));
                }
            }

            return(menuItem);
        }
Пример #2
0
        private static void CreatePopupMenuActionsRecursively(Menu menu, IJournalAction popupAction, object[] selected)
        {
            var item = new MenuItem(popupAction.Title);

            item.Sensitive = popupAction.GetSensitivity(selected);
            item.Visible   = popupAction.GetVisibility(selected);

            if (popupAction.ChildActions.Any())
            {
                var subMenu = new Menu();
                foreach (var childAction in popupAction.ChildActions)
                {
                    CreatePopupMenuActionsRecursively(subMenu, childAction, selected);
                }
                item.Submenu = subMenu;
            }
            //Действия выполняются только для самых последних дочерних JournalActions
            else
            {
                item.ButtonPressEvent += (o, args) =>
                {
                    if (args.Event.Button == (uint)GtkMouseButton.Left)
                    {
                        popupAction.ExecuteAction(selected);
                    }
                };
            }
            menu.Add(item);
        }
Пример #3
0
        private MenuItem CreatePopupMenuItem(IJournalAction journalAction)
        {
            MenuItem menuItem = new MenuItem(journalAction.Title);

            menuItem.Activated += (sender, e) => { journalAction.ExecuteAction(GetSelectedItems()); };
            menuItem.Sensitive  = journalAction.GetSensitivity(GetSelectedItems());
            menuItem.Visible    = journalAction.GetVisibility(GetSelectedItems());
            foreach (var childAction in journalAction.ChildActions)
            {
                menuItem.Add(CreatePopupMenuItem(childAction));
            }
            return(menuItem);
        }