Esempio n. 1
0
		private void btnAddLicenseSet_Click(object sender, RoutedEventArgs e)
		{
			if (IsLicenseSetFormValid())
			{
				var licSet = from ls in License.LicenseSets
										 where ls.Name == txtLicenseSetName.Text.Trim()
										 select ls;

				if (licSet.Count() > 0)
				{
					MessageBox.Show(string.Format("LicenseSet name [{0}] is already in use in this project.", txtLicenseSetName.Text.Trim()));
					return;
				}

				if (((KeyGeneratorTypes)cboLicenseKeyType.SelectedItem) == KeyGeneratorTypes.StaticSmall && License.LicenseSets.Count >= 1)
				{
					MessageBox.Show("The Small Static Key Generator only supports a maximum of 1 license set.");
					return;
				}

				LicenseSet l = new LicenseSet();
				l.Name = txtLicenseSetName.Text.Trim();

				LicenseKeyTypeFlag flag = new LicenseKeyTypeFlag();

				if (chkSingleUser.IsChecked.HasValue && chkSingleUser.IsChecked.Value)
					flag = LicenseKeyTypeFlag.SingleUser;

				if (chkMultiUser.IsChecked.HasValue && chkMultiUser.IsChecked.Value)
					flag = flag | LicenseKeyTypeFlag.MultiUser;

				if (chkHardwareLock.IsChecked.HasValue && chkHardwareLock.IsChecked.Value)
					flag = flag | LicenseKeyTypeFlag.HardwareLock;

				if (chkUnlimited.IsChecked.HasValue && chkUnlimited.IsChecked.Value)
					flag = flag | LicenseKeyTypeFlag.Unlimited;

				if (chkEnterprise.IsChecked.HasValue && chkEnterprise.IsChecked.Value)
					flag = flag | LicenseKeyTypeFlag.Enterprise;

				l.SupportedLicenseTypes = flag;

				if (String.IsNullOrEmpty(txtMaxUsers.Text) == false)
					l.MaxUsers = int.Parse(txtMaxUsers.Text);

				if (chkIsLicenseSetUpgradeOnly.IsChecked.HasValue)
					l.IsUpgradeOnly = chkIsLicenseSetUpgradeOnly.IsChecked.Value;
				else
					l.IsUpgradeOnly = false;

				License.LicenseSets.Add(l);
				License.RaisePropertyChanged("LicenseSets");

				ResetNewLicenseSetForm();
				SyncData();

			}
			else
			{
				MessageBox.Show("Please fix the errors in the New License Set form and try again.");
			}
		}
Esempio n. 2
0
        private void btnAddLicenseSet_Click(object sender, RoutedEventArgs e)
        {
            if (IsLicenseSetFormValid())
            {
                var licSet = from ls in License.LicenseSets
                             where ls.Name == txtLicenseSetName.Text.Trim()
                             select ls;

                if (licSet.Count() > 0)
                {
                    MessageBox.Show(string.Format("LicenseSet name [{0}] is already in use in this project.", txtLicenseSetName.Text.Trim()));
                    return;
                }

                if (((KeyGeneratorTypes)cboLicenseKeyType.SelectedItem) == KeyGeneratorTypes.StaticSmall && License.LicenseSets.Count >= 1)
                {
                    MessageBox.Show("The Small Static Key Generator only supports a maximum of 1 license set.");
                    return;
                }

                LicenseSet l = new LicenseSet();
                l.Name = txtLicenseSetName.Text.Trim();

                LicenseKeyTypeFlag flag = new LicenseKeyTypeFlag();

                if (chkSingleUser.IsChecked.HasValue && chkSingleUser.IsChecked.Value)
                {
                    flag = LicenseKeyTypeFlag.SingleUser;
                }

                if (chkMultiUser.IsChecked.HasValue && chkMultiUser.IsChecked.Value)
                {
                    flag = flag | LicenseKeyTypeFlag.MultiUser;
                }

                if (chkHardwareLock.IsChecked.HasValue && chkHardwareLock.IsChecked.Value)
                {
                    flag = flag | LicenseKeyTypeFlag.HardwareLock;
                }

                if (chkUnlimited.IsChecked.HasValue && chkUnlimited.IsChecked.Value)
                {
                    flag = flag | LicenseKeyTypeFlag.Unlimited;
                }

                if (chkEnterprise.IsChecked.HasValue && chkEnterprise.IsChecked.Value)
                {
                    flag = flag | LicenseKeyTypeFlag.Enterprise;
                }

                l.SupportedLicenseTypes = flag;

                if (String.IsNullOrEmpty(txtMaxUsers.Text) == false)
                {
                    l.MaxUsers = int.Parse(txtMaxUsers.Text);
                }

                if (chkIsLicenseSetUpgradeOnly.IsChecked.HasValue)
                {
                    l.IsUpgradeOnly = chkIsLicenseSetUpgradeOnly.IsChecked.Value;
                }
                else
                {
                    l.IsUpgradeOnly = false;
                }

                License.LicenseSets.Add(l);
                License.RaisePropertyChanged("LicenseSets");

                ResetNewLicenseSetForm();
                SyncData();
            }
            else
            {
                MessageBox.Show("Please fix the errors in the New License Set form and try again.");
            }
        }