using AvalonStudio.Commands;
using AvalonStudio.Extensibility;
using AvalonStudio.Shell;
using ReactiveUI;
using System.Composition;

namespace ShellExampleApp.Commands
{
    internal class HelpCommands
    {
        [ExportCommandDefinition("Help.About")]
        public CommandDefinition AboutCommand { get; }

        private IShell _shell;

        [ImportingConstructor]
        public HelpCommands(CommandIconService commandIconService)
        {
            _shell = IoC.Get<IShell>();

            AboutCommand = new CommandDefinition(
                "About", commandIconService.GetCompletionKindImage("Undo"), ReactiveCommand.Create(ShowAboutDialog));
        }

        private void ShowAboutDialog()
        {
            _shell.ModalDialog = new AboutDialogViewModel();
            _shell.ModalDialog.ShowDialogAsync();
        }
    }
}
