Example #1
0
        public Task <ChocolateyDialogController> ShowChocolateyDialogAsync(
            string title,
            bool isCancelable            = false,
            MetroDialogSettings settings = null)
        {
            return(Dispatcher.Invoke(async() =>
            {
                // create the dialog control
                var dialog = new ChocolateyDialog(this, _configService.GetEffectiveConfiguration().ShowConsoleOutput ?? false)
                {
                    Title = title,
                    IsCancelable = isCancelable,
                    OutputBufferCollection = _progressService.Output
                };

                if (settings == null)
                {
                    settings = MetroDialogOptions;
                    settings.NegativeButtonText = L(nameof(Properties.Resources.ChocolateyDialog_Cancel));
                    settings.AffirmativeButtonText = L(nameof(Properties.Resources.ChocolateyDialog_OK));
                }

                dialog.NegativeButtonText = settings.NegativeButtonText;

                await this.ShowMetroDialogAsync(dialog);
                return new ChocolateyDialogController(dialog, () => this.HideMetroDialogAsync(dialog));
            }));
        }
        internal ChocolateyDialogController(ChocolateyDialog dialog, Func <Task> closeCallBack)
        {
            WrappedDialog = dialog;
            CloseCallback = closeCallBack;

            IsOpen = dialog.IsVisible;

            WrappedDialog.PART_NegativeButton.Dispatcher.Invoke(
                () => { WrappedDialog.PART_NegativeButton.Click += PART_NegativeButton_Click; });
        }