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; }
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; }
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)); } } }
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); }
public override bool OnIsVisible(IContextualOperationContext ctx) { return(IsVisible((ContextualOperationContext <T>)ctx)); }
public override void OnClick(IContextualOperationContext ctx) { Click((ContextualOperationContext <T>)ctx); }
public abstract bool OnIsVisible(IContextualOperationContext ctx);
public abstract void OnClick(IContextualOperationContext ctx);
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; }
public override JsFunction OnClick(IContextualOperationContext ctx) { return(Click((ContextualOperationContext <T>)ctx)); }
public abstract JsFunction OnClick(IContextualOperationContext ctx);
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); }