Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Create a module and provide an IDashboardCommand into antony’s DI Container. This command will be displayed in the RibbonBar of the Dashboard, if selector passes.

Hints

...

Example

Create a class, implement the IDashboardCommand within, and register it within the DI Container

Code Block
languagec#
services.AddTransient<IDashboardCommand, MyDashboardCommand>();
services.AddTransient<MyViewModel>();

Below a simple implementation of an IDashboardCommand showing a view to the AntUser.

Code Block

public class MyDashboardCommand: IDashboardCommand, IModuleSelector<DashboardCommandSelector>
    {
        public IModuleSelector<DashboardCommandSelector> Selector => this;
        public AntonyPriority GetPriority(DashboardCommandSelector selectorParameter) => AntonyPriority.Explicit;
        private Func<MyViewModel> _viewModel;

        public MyDashboardCommand(Func<MyViewModel> viewModel)
        {
            _viewModel = viewModel;
        }

        public AntonyCommandInfo ActionInfo => new AntonyCommandInfoBuilder()
            .WithSvgImage(Resources.logo)
            .WithDisplayName("MyViewCommand")
            .WithGeneralPageName()
            .WithGroupName("MyModule")
            .WithLargeRibbonImage()
            .Build();


        public Task ExecuteAsync(IntPtr parentWindow, IProgressReporter reporter)
        {
            var viewModel = _viewModel();
            var view = new MyView();
            view.DataContext = viewModel;

            ElementHost.EnableModelessKeyboardInterop(view); // needs a antony is WinForms
            view.Show();
            return Task.CompletedTask;
        }
        
        public event EventHandler CommandStateChanged;
        public CommandState GetCommandState() => CommandState.Normal;
    }

Conclusion

As you see, implementing an IDashboardCommandis easy. You can use this ExtensionPoint to provide a simple shortcut to external programms for example like “Open MyERP”.

You might also create some more integrated logic like open a prefilled MailWindow, create an appointment directly from dashboard and so on and so far.