Example #1
0
        private static void DisplayDefaultLicenseAcceptDialog(PackageLicenseAgreementEventArgs args)
        {
            LicenseAcceptDialog licenseDialog = new LicenseAcceptDialog
            {
                DescriptionText = string.Format(GeneralRes.LicenseAcceptDialog_PackageDesc, args.PackageName),
                LicenseUrl      = args.LicenseUrl
            };

            Form         invokeForm = DualityEditorApp.MainForm ?? Application.OpenForms.OfType <Form>().FirstOrDefault();
            DialogResult result     = invokeForm.InvokeEx(main => licenseDialog.ShowDialog());

            if (result == DialogResult.OK)
            {
                args.AcceptLicense();
            }
        }
Example #2
0
        private bool CheckLicenseAgreement(PackageInfo package)
        {
            if (package.RequireLicenseAcceptance)
            {
                // On the very first install, do not display additional license agreement dialogs
                // because all the packages being installed are the default ones.
                if (this.setup.IsFirstInstall)
                {
                    return(true);
                }

                bool agreed;
                if (!this.licenseAccepted.TryGetValue(package.Name, out agreed) || !agreed)
                {
                    PackageLicenseAgreementEventArgs args = new PackageLicenseAgreementEventArgs(
                        package.Name,
                        package.LicenseUrl,
                        package.RequireLicenseAcceptance);

                    if (this.PackageLicenseAcceptRequired != null)
                    {
                        this.PackageLicenseAcceptRequired(this, args);
                    }
                    else
                    {
                        DisplayDefaultLicenseAcceptDialog(args);
                    }

                    agreed = args.IsLicenseAccepted;
                    this.licenseAccepted[package.Name] = agreed;
                }

                if (!agreed)
                {
                    return(false);
                }
            }

            return(true);
        }
Example #3
0
		private bool CheckLicenseAgreement(NuGet.IPackage package)
		{
			if (package.RequireLicenseAcceptance)
			{
				// On the very first install, do not display additional license agreement dialogs
				// because all the packages being installed are the default ones.
				if (this.firstInstall)
					return true;

				bool agreed;
				if (!this.licenseAcceptedCache.TryGetValue(package, out agreed) || !agreed)
				{
					PackageLicenseAgreementEventArgs args = new PackageLicenseAgreementEventArgs(
						new PackageName(package.Id, package.Version.Version),
						package.LicenseUrl,
						package.RequireLicenseAcceptance);

					if (this.PackageLicenseAcceptRequired != null)
						this.PackageLicenseAcceptRequired(this, args);
					else
						DisplayDefaultLicenseAcceptDialog(args);

					agreed = args.IsLicenseAccepted;
					this.licenseAcceptedCache[package] = agreed;
				}

				if (!agreed)
				{ 
					return false;
				}
			}

			return true;
		}
Example #4
0
		private static void DisplayDefaultLicenseAcceptDialog(PackageLicenseAgreementEventArgs args)
		{
			LicenseAcceptDialog licenseDialog = new LicenseAcceptDialog
			{
				DescriptionText = string.Format(GeneralRes.LicenseAcceptDialog_PackageDesc, args.PackageName),
				LicenseUrl = args.LicenseUrl
			};

			Form invokeForm = DualityEditorApp.MainForm ?? Application.OpenForms.OfType<Form>().FirstOrDefault();
			DialogResult result = invokeForm.InvokeEx(main => licenseDialog.ShowDialog());
			if (result == DialogResult.OK)
			{
				args.AcceptLicense();
			}
		}