protected override bool AcceptLicenseAgreement(IEnumerable <IPackageSearchMetadata> licensePackages)
        {
            var eventArgs = new RequiringLicenseAcceptanceEventArgs(licensePackages);

            RequiringLicenseAcceptance?.Invoke(this, eventArgs);
            return(eventArgs.LicenseAccepted);
        }
        protected virtual void OnRequiringLicenseAcceptance(RequiringLicenseAcceptanceEventArgs e)
        {
            var handler = RequiringLicenseAcceptance;

            if (handler != null)
            {
                handler(this, e);
            }
        }
        private bool ShowLicenseAgreement(IEnumerable <PackageOperation> operations)
        {
            var licensePackages = (from operation in operations
                                   where operation.Action == PackageAction.Install &&
                                   operation.Package.RequireLicenseAcceptance &&
                                   !LocalRepository.Exists(operation.Package)
                                   select operation.Package)
                                  .ToList();

            if (licensePackages.Any())
            {
                var licenseAcceptanceEventArgs = new RequiringLicenseAcceptanceEventArgs(licensePackages);
                OnRequiringLicenseAcceptance(licenseAcceptanceEventArgs);
                return(licenseAcceptanceEventArgs.LicenseAccepted);
            }

            return(true);
        }
Example #4
0
 void packageManager_RequiringLicenseAcceptance(object sender, RequiringLicenseAcceptanceEventArgs e)
 {
     if (control.InvokeRequired)
     {
         control.Invoke((EventHandler <RequiringLicenseAcceptanceEventArgs>)packageManager_RequiringLicenseAcceptance, sender, e);
     }
     else
     {
         if (operationDialog == null)
         {
             return;
         }
         operationDialog.Hide();
         using (var licenseDialog = new LicenseAcceptanceDialog(e.LicensePackages))
         {
             e.LicenseAccepted = licenseDialog.ShowDialog(control) == DialogResult.Yes;
             if (e.LicenseAccepted)
             {
                 operationDialog.Show();
             }
         }
     }
 }