Esempio n. 1
0
        public bool AcceptLicenses(IEnumerable <IPackage> packages)
        {
            LicenseAcceptanceDialog dialog = CreateLicenseAcceptanceDialog(packages);
            int result = MessageService.ShowCustomDialog(dialog);

            return(result == (int)Gtk.ResponseType.Ok);
        }
Esempio n. 2
0
        protected override Task RunPackageOperationAsync(Func <Task> operationFactory)
        {
            EnableVisualStyles();
            EventHandler <RequiringLicenseAcceptanceEventArgs> requiringLicenseHandler = null;

            using var dialog        = new PackageOperationDialog { ShowInTaskbar = true };
            requiringLicenseHandler = (sender, e) =>
            {
                if (dialog.InvokeRequired)
                {
                    dialog.Invoke(requiringLicenseHandler, sender, e);
                }
                else
                {
                    using var licenseDialog = new LicenseAcceptanceDialog(e.LicensePackages);
                    e.LicenseAccepted       = licenseDialog.ShowDialog() == DialogResult.Yes;
                }
            };

            dialog.RegisterEventLogger((EventLogger)PackageManager.Logger);
            PackageManager.RequiringLicenseAcceptance += requiringLicenseHandler;
            try
            {
                var operation = operationFactory();
                operation.ContinueWith(task =>
                {
                    if (task.IsFaulted)
                    {
                        if (task.Exception is AggregateException ex)
                        {
                            PackageManager.Logger.LogError(ex.InnerException.Message);
                        }
                    }
                    else
                    {
                        dialog.BeginInvoke((Action)dialog.Close);
                    }
                });
                dialog.ShowDialog();
                return(operation);
            }
            finally { PackageManager.RequiringLicenseAcceptance -= requiringLicenseHandler; }
        }