Ejemplo n.º 1
0
        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; });
        }
        internal ChocolateyDialogController(ChocolateyDialog dialog, Func<Task> closeCallBack)
        {
            this.WrappedDialog = dialog;
            this.CloseCallback = closeCallBack;

            this.IsOpen = dialog.IsVisible;

            this.WrappedDialog.PART_NegativeButton.Dispatcher.Invoke(new Action(() =>
            {
                this.WrappedDialog.PART_NegativeButton.Click += PART_NegativeButton_Click;
            }));
        }
Ejemplo n.º 3
0
        public Task<ChocolateyDialogController> ShowChocolateyDialogAsync(string title, bool isCancelable = false, MetroDialogSettings settings = null)
        {
            return (Task<ChocolateyDialogController>)Dispatcher.Invoke(new Func<Task<ChocolateyDialogController>>(async () =>
            {
                // create the dialog control
                var dialog = new ChocolateyDialog(this)
                {
                    Title = title,
                    IsCancelable = isCancelable,
                    OutputBufferCollection = _progressService.Output
                };

                if (settings == null)
                {
                    settings = MetroDialogOptions;
                }

                dialog.NegativeButtonText = settings.NegativeButtonText;

                await this.ShowMetroDialogAsync(dialog);
                return new ChocolateyDialogController(dialog, () => this.HideMetroDialogAsync(dialog));
            }));
        }
Ejemplo n.º 4
0
        public async Task StartLoading(string title = null, bool isCancelable = false)
        {
            using (await this._lock.LockAsync())
            {
                var currentCount = Interlocked.Increment(ref this._loadingItems);
                if (currentCount == 1)
                {
                    var chocoDialg = new ChocolateyDialog(this.MainWindow);

                    this._progressController = await this.MainWindow.ShowChocolateyDialogAsync(title, isCancelable);
                    this._progressController.SetIndeterminate();
                    if (isCancelable)
                    {
                        this._cst = new CancellationTokenSource();
                        this._progressController.OnCanceled += dialog =>
                        {
                            if (this._cst != null)
                            {
                                _cst.Cancel();
                            }
                        };
                    }

                    this._output.Clear();

                    this._isLoading = true;
                    this.NotifyPropertyChanged("IsLoading");
                }
            }
        }