示例#1
0
        public LaytonAboutForm(LaytonProductKey productKey, string bitmap, string icon, string version)
        {
            // Save inoput arguments
            _productKey     = productKey;
            _aboutBitmap    = bitmap;
            _productIcon    = icon;
            _productVersion = version;

            // Initialize the form
            InitializeComponent();
            try
            {
                // set the form's background image and icon
                Bitmap bgImage = new Bitmap(bitmap);
                this.BackgroundImage = bgImage;
                this.Size            = bgImage.Size;

                // set the form's icon
                this.Icon = new Icon(icon);
            }
            catch
            {
                // Use existing default images
            }
            this.versionLabel.Text = version;
            UpdateLicensing();
            AddModules();
        }
        private void registerButton_Click(object sender, EventArgs e)
        {
            if (companyNameTextBox.Text == null || companyNameTextBox.Text == "")
            {
                MessageBox.Show("Please enter a value for the Company Name.", "Product Registration", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (companyIdTextBox.Text == null || companyIdTextBox.Text == "")
            {
                MessageBox.Show("Please enter a value for the Company ID.", "Product Registration", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (productKeyTextBox.Text == null || productKeyTextBox.Text == "")
            {
                MessageBox.Show("Please enter a value for the Product Key.", "Product Registration", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            int companyID;

            try
            {
                companyID = Convert.ToInt32(companyIdTextBox.Text);
            }
            catch
            {
                MessageBox.Show("Please enter a valid value for the Company ID.", "Product Registration", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            LaytonProductKey newKey = new LaytonProductKey(productKeyTextBox.Text, productKey.ProductID, companyNameTextBox.Text, companyID, "");

            if (newKey.IsTrial)
            {
                MessageBox.Show("The registration information you have provided is invalid. If you feel this is a mistake, please contact support.", "Product Registration", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                // save the registration information
                // get the name of the application running
                string applicationName = Path.GetFileName(Application.ExecutablePath);

                // ...and from that get it's configuration file
                Configuration config = ConfigurationManager.OpenExeConfiguration(applicationName);

                // Save settings back into here
                config.AppSettings.Settings["ProductKey"].Value  = newKey.ProductKey;
                config.AppSettings.Settings["CompanyName"].Value = newKey.CompanyName;
                config.AppSettings.Settings["CompanyID"].Value   = newKey.CompanyID.ToString();
                config.AppSettings.Settings["Code2"].Value       = LaytonProductKey.GenerateCode2();
                config.Save();

                MessageBox.Show("Successful registration! Press OK to continue.", "Product Registration");
                productKey        = newKey;
                this.DialogResult = DialogResult.OK;
                Close();
            }
        }
        public LaytonRegistrationForm(LaytonProductKey productKey, string image, string icon)
        {
            InitializeComponent();
            this.productKey   = productKey;
            this.DialogResult = DialogResult.Cancel;

            try
            {
                // set the form's background image and icon
                Bitmap bgImage = new Bitmap(image);
                this.BackgroundImage = bgImage;
                this.Size            = bgImage.Size;

                // set the form's icon
                this.Icon = new Icon(icon);
            }
            catch
            {
                // use the default layton images
            }
            AddLicensing();
        }