Example #1
0
        private void registerButton_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            foreach (TextBox element in textBoxes)
            {
                if (element.TextLength == 4)
                {
                    int index = Array.IndexOf(textBoxes, element);
                    if (index != textBoxes.Length - 1)
                    {
                        sb.Append(element.Text + "-");
                    }
                    else
                    {
                        sb.Append(element.Text);
                    }
                }
                else
                {
                    MessageBox.Show(rm.GetString("incompleteKey"));
                    break;
                }
            }

            if (sb.Length == 24)
            {
                LicenseCheck.activateSoftware(sb.ToString());
                licenseStatusOk = true;
                Properties.Settings.Default.block = false;
                this.Close();
            }
        }
Example #2
0
        public static void checkLicenseFile()
        {
            System.Resources.ResourceManager rm = null;
            rm = new System.Resources.ResourceManager("QuestionannaireApp.Localization", Assembly.GetExecutingAssembly());
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Properties.Settings.Default.culture);

            using (IsolatedStorageFile isolatedStorageFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null))
            {
                try
                {
                    using (IsolatedStorageFileStream isolatedStorageFileStream = new IsolatedStorageFileStream("license.lic", System.IO.FileMode.Open, isolatedStorageFile))
                    {
                        using (System.IO.StreamReader sr = new System.IO.StreamReader(isolatedStorageFileStream))
                        {
                            var activated = LicenseCheck.isActivated(sr.ReadLine());
                            if (!activated)
                            {
                                MessageBox.Show(rm.GetString("activationExpired"), rm.GetString("activation"), MessageBoxButtons.OK);
                                Properties.Settings.Default.block = true;
                            }
                            else
                            {
                                Properties.Settings.Default.block = false;
                            }
                        }
                    }
                }

                catch
                {
                    if (CheckForInternetConnection() == true && !isolatedStorageFile.FileExists("license.lic"))
                    {
                        License license = new License();
                        license.ShowDialog();
                    }
                    else if (CheckForInternetConnection() == false && !isolatedStorageFile.FileExists("license.lic"))
                    {
                        Properties.Settings.Default.block = true;
                    }
                    else
                    {
                        Properties.Settings.Default.block = false;
                    }
                }
            }
        }