コード例 #1
0
        protected internal virtual ToolBarButton CreateToolBarButton(IEntityOperationContext ctx, EntityOperationGroup group)
        {
            var result = new ToolBarButton(ctx.Context.Prefix, ctx.OperationInfo.OperationSymbol.Key.Replace(".", "_"))
            {
                Style = ctx.OperationSettings?.Style ?? EntityOperationSettingsBase.AutoStyleFunction(ctx.OperationInfo),

                Tooltip = ctx.CanExecute,
                Enabled = ctx.CanExecute == null,
                Order   = ctx.OperationSettings != null ? ctx.OperationSettings.Order : 0,

                Text      = ctx.OperationSettings?.Text ?? (group == null || group.SimplifyName == null ? ctx.OperationInfo.OperationSymbol.NiceToString() : group.SimplifyName(ctx.OperationInfo.OperationSymbol.NiceToString())),
                OnClick   = ((ctx.OperationSettings != null && ctx.OperationSettings.HasClick) ? ctx.OperationSettings.OnClick(ctx) ?? DefaultClick(ctx) : DefaultClick(ctx)),
                HtmlProps = { { "data-operation", ctx.OperationInfo.OperationSymbol.Key } },

                Tag = ctx,
            };

            if (CustomizeToolBarButton != null)
            {
                return(CustomizeToolBarButton(result));
            }

            return(result);
        }
コード例 #2
0
        public virtual MenuItem CreateContextual(IContextualOperationContext ctx, Func <IContextualOperationContext, JsFunction> defaultClick)
        {
            var result = new MenuItem(ctx.Context.Prefix, ctx.OperationInfo.OperationSymbol.Key.Replace(".", "_"))
            {
                Style = ctx.OperationSettings?.Style ?? ctx.EntityOperationSettings?.Style ?? EntityOperationSettingsBase.AutoStyleFunction(ctx.OperationInfo),

                Tooltip = ctx.CanExecute,
                Enabled = ctx.CanExecute == null,

                Order = ctx.OperationSettings != null ? ctx.OperationSettings.Order : 0,

                Text    = ctx.OperationSettings?.Text ?? ctx.OperationInfo.OperationSymbol.NiceToString(),
                OnClick = ((ctx.OperationSettings != null && ctx.OperationSettings.HasClick) ? ctx.OperationSettings.OnClick(ctx) ?? defaultClick(ctx) : defaultClick(ctx)),

                Tag = ctx,
            };

            if (CustomizeMenuItem != null)
            {
                return(CustomizeMenuItem(result));
            }

            return(result);
        }