public DashboardViewModel(IMediator mediator, IAppContext context, IContextMenuViewModel contextMenuViewModel)
 {
     Context = context;
     ContextMenuViewModel = contextMenuViewModel;
     Commands.Add("OpenContextMenu", new Command(async ctx => contextMenuViewModel.Items = await mediator.Send(DynamicContextMenu.Request.Create(ctx ?? context.Session.Widget))));
     Commands.Add("CloseContextMenu", new Command(_ => contextMenuViewModel.Clear()));
     Commands.Add("Delete", new Command(async widget => await mediator.Send(new DeleteWidget.Request(widget as IWidget))));
     Commands.Add("MoveUp", new Command(w => ((IWidget)w).MoveUp(), w => w is IWidget movable && movable.CanMoveUp()));
     Commands.Add("MoveDown", new Command(w => ((IWidget)w).MoveDown(), w => w is IWidget movable && movable.CanMoveDown()));
 }
Beispiel #2
0
        public DashboardViewModel(IMediator mediator, IAppContext context, IContextMenuViewModel contextMenuViewModel)
        {
            Context              = context;
            Mediator             = mediator;
            ContextMenuViewModel = contextMenuViewModel;

            Commands.Add("OpenContextMenu", new Command(async ctx => ContextMenuViewModel.Items = await Mediator.Send(DynamicContextMenu.Request.Create(ctx ?? Context.Session.Widget)).ConfigureAwait(false)));
            Commands.Add("CloseContextMenu", new Command(_ => ContextMenuViewModel.Clear()));
            Commands.Add("Delete", new Command(async widget => await Mediator.Send(new DeleteWidget.Request(widget as IWidget))));
            Commands.Add("Refresh", new Command(_ => Task.Run(async() => await mediator.Send(new TriggerJob.Request(context.Session.Widget)))));
            Commands.Add("MoveUp", new Command(w => ((IWidget)w).MoveUp(), w => w is IWidget movable && movable.CanMoveUp()));
            Commands.Add("MoveDown", new Command(w => ((IWidget)w).MoveDown(), w => w is IWidget movable && movable.CanMoveDown()));
        }