Exemplo n.º 1
0
        private void OnBeforeContextMenu(object sender, CfxOnBeforeContextMenuEventArgs e)
        {
            var model = e.Model;

            for (var index = model.Count - 1; index >= 0; index--)
            {
                if (!CfxContextMenu.IsEdition(model.GetCommandIdAt(index)))
                {
                    model.RemoveAt(index);
                }
            }

            if (model.Count != 0)
            {
                return;
            }

            var rank = (int)ContextMenuId.MENU_ID_USER_FIRST;

            _Commands.ForEach(command =>
            {
                model.AddItem(rank, command.Name);
                model.SetEnabled(rank++, command.Enabled);
            });
            _MenuSeparatorIndex.ForEach(index => model.InsertSeparatorAt(index));
        }
Exemplo n.º 2
0
        private void ContextMenuHandler_OnContextMenuCommand(object sender, CfxOnContextMenuCommandEventArgs e)
        {
            if (!CfxContextMenu.IsUserDefined(e.CommandId))
            {
                return;
            }

            var command = _Commands[e.CommandId - (int)ContextMenuId.MENU_ID_USER_FIRST].Command;

            command.Invoke();
        }