public static MenuItem Construct(IContextualOperationContext coc)
        {
            MenuItem miResult = new MenuItem
            {
                Header = OperationClient.GetText(coc.Type, coc.OperationInfo.OperationSymbol),
                Icon   = OperationClient.GetImage(coc.Type, coc.OperationInfo.OperationSymbol).ToSmallImage(),
                Tag    = coc,
            };

            if (coc.OperationSettings != null && coc.OperationSettings.Order != 0)
            {
                Common.SetOrder(miResult, coc.OperationSettings.Order);
            }

            if (coc.CanExecute != null)
            {
                miResult.ToolTip   = coc.CanExecute;
                miResult.IsEnabled = false;
                ToolTipService.SetShowOnDisabled(miResult, true);
                AutomationProperties.SetHelpText(miResult, coc.CanExecute);
            }

            miResult.Click += (object sender, RoutedEventArgs e) =>
            {
                coc.SearchControl.SetDirtySelectedItems();

                if (coc.OperationSettings != null && coc.OperationSettings.HasClick)
                {
                    coc.OperationSettings.OnClick(coc);
                }
                else
                {
                    if (coc.ConfirmMessage())
                    {
                        Entity result = (Entity) new ConstructorContext(coc.SearchControl, coc.OperationInfo).SurroundConstructUntyped(coc.OperationInfo.ReturnType, ctx =>
                                                                                                                                       Server.Return((IOperationServer s) => s.ConstructFromMany(coc.SearchControl.SelectedItems.ToList(), coc.Type, coc.OperationInfo.OperationSymbol, ctx.Args)));

                        if (result != null)
                        {
                            Navigator.Navigate(result);
                        }
                        else
                        {
                            MessageBox.Show(Window.GetWindow(coc.SearchControl), OperationMessage.TheOperation0DidNotReturnAnEntity.NiceToString().FormatWith(coc.OperationInfo.OperationSymbol.NiceToString()));
                        }
                    }
                }
            };

            return(miResult);
        }
        public static MenuItem Construct(IContextualOperationContext coc)
        { 
            MenuItem miResult = new MenuItem
            {
                Header = OperationClient.GetText(coc.Type, coc.OperationInfo.OperationSymbol),
                Icon = OperationClient.GetImage(coc.Type, coc.OperationInfo.OperationSymbol).ToSmallImage(),
                Tag = coc,
            };

            if (coc.OperationSettings != null && coc.OperationSettings.Order != 0)
                Common.SetOrder(miResult, coc.OperationSettings.Order);

            if (coc.CanExecute != null)
            {
                miResult.ToolTip = coc.CanExecute;
                miResult.IsEnabled = false;
                ToolTipService.SetShowOnDisabled(miResult, true);
                AutomationProperties.SetHelpText(miResult, coc.CanExecute);
            }

            miResult.Click += (object sender, RoutedEventArgs e) =>
            {
                coc.SearchControl.SetDirtySelectedItems();

                if (coc.OperationSettings != null && coc.OperationSettings.HasClick)
                    coc.OperationSettings.OnClick(coc);
                else
                {
                    if (coc.ConfirmMessage())
                    {
                        Entity result = (Entity)new ConstructorContext(coc.SearchControl, coc.OperationInfo).SurroundConstructUntyped(coc.OperationInfo.ReturnType, ctx =>
                            Server.Return((IOperationServer s) => s.ConstructFromMany(coc.SearchControl.SelectedItems.ToList(), coc.Type, coc.OperationInfo.OperationSymbol, ctx.Args)));

                        if (result != null)
                            Navigator.Navigate(result);
                        else
                            MessageBox.Show(Window.GetWindow(coc.SearchControl), OperationMessage.TheOperation0DidNotReturnAnEntity.NiceToString().FormatWith(coc.OperationInfo.OperationSymbol.NiceToString()));
                    }
                }
            };

            return miResult;
        }
示例#3
0
        public static MenuItem Construct(IContextualOperationContext coc)
        {
            MenuItem miResult = new MenuItem
            {
                Header = coc.OperationSettings?.Text ?? coc.OperationInfo.OperationSymbol.NiceToString(),
                Icon   = coc.OperationSettings?.Icon.ToSmallImage(),
                Tag    = coc,
            };

            if (coc.CanExecute != null)
            {
                miResult.ToolTip   = coc.CanExecute;
                miResult.IsEnabled = false;
                ToolTipService.SetShowOnDisabled(miResult, true);
                AutomationProperties.SetHelpText(miResult, coc.CanExecute);
            }

            coc.SenderMenuItem = miResult;

            miResult.Click += (object sender, RoutedEventArgs e) =>
            {
                coc.SearchControl.SetDirtySelectedItems();

                if (coc.OperationSettings != null && coc.OperationSettings.HasClick)
                {
                    coc.OperationSettings.OnClick(coc);
                }
                else
                {
                    if (coc.ConfirmMessage())
                    {
                        IEntity entity = Server.Return((IProcessServer s) => s.CreatePackageOperation(coc.Entities.ToList(), coc.OperationInfo.OperationSymbol));

                        Navigator.Navigate(entity);
                    }
                }
            };

            return(miResult);
        }
        public static MenuItem Construct(IContextualOperationContext coc)
        {
            MenuItem miResult = new MenuItem
            {
                Header = coc.OperationSettings?.Text ?? coc.OperationInfo.OperationSymbol.NiceToString(),
                Icon = coc.OperationSettings?.Icon.ToSmallImage(),
                Tag = coc,
            };

            if (coc.CanExecute != null)
            {
                miResult.ToolTip = coc.CanExecute;
                miResult.IsEnabled = false;
                ToolTipService.SetShowOnDisabled(miResult, true);
                AutomationProperties.SetHelpText(miResult, coc.CanExecute);
            }

            coc.SenderMenuItem = miResult;

            miResult.Click += (object sender, RoutedEventArgs e) =>
            {
                coc.SearchControl.SetDirtySelectedItems();

                if (coc.OperationSettings != null && coc.OperationSettings.HasClick)
                    coc.OperationSettings.OnClick(coc);
                else
                {
                    if (coc.ConfirmMessage())
                    {
                        IEntity entity = Server.Return((IProcessServer s) => s.CreatePackageOperation(coc.Entities.ToList(), coc.OperationInfo.OperationSymbol));

                        Navigator.Navigate(entity);
                    }
                }
            };

            return miResult;
        }
示例#5
0
        protected virtual JsFunction DefaultEntityClick(IContextualOperationContext ctx)
        {
            if (ctx.UntypedEntites.Count() == 1)
            {
                switch (ctx.OperationInfo.OperationType)
                {
                case OperationType.Execute:
                    return(JsModule.Operations["executeDefaultContextual"](ctx.Options()));

                case OperationType.Delete:
                    return(JsModule.Operations["deleteDefaultContextual"](ctx.Options()));

                case OperationType.ConstructorFrom:
                    return(JsModule.Operations["constructFromDefaultContextual"](ctx.Options(), JsFunction.Event));

                default:
                    throw new InvalidOperationException("Invalid Operation Type '{0}' in the construction of the operation '{1}'".FormatWith(ctx.OperationInfo.OperationType.ToString(), ctx.OperationInfo.OperationSymbol));
                }
            }
            else
            {
                switch (ctx.OperationInfo.OperationType)
                {
                case OperationType.Execute:
                    return(JsModule.Operations["executeDefaultContextualMultiple"](ctx.Options()));

                case OperationType.Delete:
                    return(JsModule.Operations["deleteDefaultContextualMultiple"](ctx.Options()));

                case OperationType.ConstructorFrom:
                    return(JsModule.Operations["constructFromDefaultContextualMultiple"](ctx.Options(), JsFunction.Event));

                default:
                    throw new InvalidOperationException("Invalid Operation Type '{0}' in the construction of the operation '{1}'".FormatWith(ctx.OperationInfo.OperationType.ToString(), ctx.OperationInfo.OperationSymbol));
                }
            }
        }
示例#6
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);
        }
示例#7
0
 public override bool OnIsVisible(IContextualOperationContext ctx)
 {
     return(IsVisible((ContextualOperationContext <T>)ctx));
 }
示例#8
0
 public override void OnClick(IContextualOperationContext ctx)
 {
     Click((ContextualOperationContext <T>)ctx);
 }
示例#9
0
 public abstract bool OnIsVisible(IContextualOperationContext ctx);
示例#10
0
 public abstract void OnClick(IContextualOperationContext ctx);
示例#11
0
        public static MenuItem Construct(IContextualOperationContext coc)
        {
            MenuItem miResult = new MenuItem()
            {
                Header = coc.OperationSettings?.Text ?? coc.OperationInfo.OperationSymbol.NiceToString(),
                Icon = coc.OperationSettings?.Icon.ToSmallImage(),
                Tag = coc,
            };

            if (coc.OperationSettings != null && coc.OperationSettings.Order != 0)
                Common.SetOrder(miResult, coc.OperationSettings.Order);

            if (coc.CanExecute != null)
            {
                miResult.ToolTip = coc.CanExecute;
                miResult.IsEnabled = false;
                ToolTipService.SetShowOnDisabled(miResult, true);
                AutomationProperties.SetHelpText(miResult, coc.CanExecute);
            }

            miResult.Click += (object sender, RoutedEventArgs e) =>
            {
                coc.SearchControl.SetDirtySelectedItems();

                if (coc.OperationSettings != null && coc.OperationSettings.HasClick)
                    coc.OperationSettings.OnClick(coc);
                else
                {
                    var lite = coc.SearchControl.SelectedItems.Single();

                    if (coc.ConfirmMessage())
                    {
                        switch (coc.OperationInfo.OperationType)
                        {
                            case OperationType.Execute:
                                Server.Return((IOperationServer os) => os.ExecuteOperationLite(lite, coc.OperationInfo.OperationSymbol));
                                break;
                            case OperationType.Delete:
                                Server.Execute((IOperationServer os) => os.DeleteLite(lite, coc.OperationInfo.OperationSymbol));
                                break;
                            case OperationType.ConstructorFrom:
                                {
                                    var result = (Entity)new ConstructorContext(coc.SearchControl, coc.OperationInfo).SurroundConstructUntyped(coc.OperationInfo.ReturnType, ctx =>
                                        Server.Return((IOperationServer os) => os.ConstructFromLite(lite, coc.OperationInfo.OperationSymbol)));

                                    if (result == null)
                                    {
                                        MessageBox.Show(Window.GetWindow(miResult), 
                                            OperationMessage.TheOperation0DidNotReturnAnEntity.NiceToString(coc.OperationInfo.OperationSymbol.NiceToString()));
                                    }
                                    else
                                    {
                                        if (Navigator.IsNavigable(result, true))
                                            Navigator.Navigate(result);
                                    };
                                    break;
                                }
                            case OperationType.Constructor:
                            case OperationType.ConstructorFromMany:
                                throw new InvalidOperationException("Unexpected operation type");
                        }
                    }
                }
            };

            return miResult;
        }
示例#12
0
 public override JsFunction OnClick(IContextualOperationContext ctx)
 {
     return(Click((ContextualOperationContext <T>)ctx));
 }
示例#13
0
 public abstract JsFunction OnClick(IContextualOperationContext ctx);
示例#14
0
        public static MenuItem Construct(IContextualOperationContext coc)
        {
            MenuItem miResult = new MenuItem()
            {
                Header = coc.OperationSettings?.Text ?? coc.OperationInfo.OperationSymbol.NiceToString(),
                Icon   = coc.OperationSettings?.Icon.ToSmallImage(),
                Tag    = coc,
            };

            if (coc.OperationSettings != null && coc.OperationSettings.Order != 0)
            {
                Common.SetOrder(miResult, coc.OperationSettings.Order);
            }

            if (coc.CanExecute != null)
            {
                miResult.ToolTip   = coc.CanExecute;
                miResult.IsEnabled = false;
                ToolTipService.SetShowOnDisabled(miResult, true);
                AutomationProperties.SetHelpText(miResult, coc.CanExecute);
            }

            miResult.Click += (object sender, RoutedEventArgs e) =>
            {
                coc.SearchControl.SetDirtySelectedItems();

                if (coc.OperationSettings != null && coc.OperationSettings.HasClick)
                {
                    coc.OperationSettings.OnClick(coc);
                }
                else
                {
                    var lite = coc.SearchControl.SelectedItems.Single();

                    if (coc.ConfirmMessage())
                    {
                        switch (coc.OperationInfo.OperationType)
                        {
                        case OperationType.Execute:
                            Server.Return((IOperationServer os) => os.ExecuteOperationLite(lite, coc.OperationInfo.OperationSymbol));
                            break;

                        case OperationType.Delete:
                            Server.Execute((IOperationServer os) => os.DeleteLite(lite, coc.OperationInfo.OperationSymbol));
                            break;

                        case OperationType.ConstructorFrom:
                        {
                            var result = (Entity) new ConstructorContext(coc.SearchControl, coc.OperationInfo).SurroundConstructUntyped(coc.OperationInfo.ReturnType, ctx =>
                                                                                                                                        Server.Return((IOperationServer os) => os.ConstructFromLite(lite, coc.OperationInfo.OperationSymbol)));

                            if (result == null)
                            {
                                MessageBox.Show(Window.GetWindow(miResult),
                                                OperationMessage.TheOperation0DidNotReturnAnEntity.NiceToString(coc.OperationInfo.OperationSymbol.NiceToString()));
                            }
                            else
                            {
                                if (Navigator.IsNavigable(result, true))
                                {
                                    Navigator.Navigate(result);
                                }
                            };
                            break;
                        }

                        case OperationType.Constructor:
                        case OperationType.ConstructorFromMany:
                            throw new InvalidOperationException("Unexpected operation type");
                        }
                    }
                }
            };

            return(miResult);
        }