private void openLicenseDialog_FileOk(object sender, CancelEventArgs e)
        {
            var timer = new Timer()
            {
                Interval = 1
            };

            timer.Tick += (sender_, e_) =>
            {
                timer.Stop();

                try
                {
                    LicenseInfo.ReadFromFile(openLicenseDialog.FileName);

                    if (LicenseInfo.IsValid())
                    {
                        ReloadLicenseInfo();
                        ValidateRemotely();
                    }
                }
                catch (Exception x)
                {
                    MessageBox.Show(this, x.Message, "Błąd wczytywania klucza licencyjnego", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    ReloadLicenseInfo();
                }
            };

            timer.Start();
        }
 private void LicenseForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (!LicenseInfo.IsValid())
     {
         Properties.Settings.Default.LicenseKey = "";
     }
 }
        private void ValidateRemotely()
        {
            errorLabel.BackColor = Color.Orange;
            errorLabel.Text      = "Trwa walidacja licencji...";

            Enabled = false;

            try
            {
                LicenseInfo.ValidateRemotely();
            }
            catch (Exception x)
            {
                if (LicenseInfo.IsValid())
                {
                    LicenseInfo.Error = "VALIDATION";
                }

                throw x;
            }
            finally
            {
                Enabled = true;
            }
        }
Exemple #4
0
        private void ToggleLicenseError()
        {
            LicenseInfo.ReadFromSettings();

            if (LicenseInfo.IsValid())
            {
                licenseErrorLabel.Hide();
            }
            else
            {
                licenseErrorLabel.Show();
            }
        }
Exemple #5
0
        public AboutForm()
        {
            InitializeComponent();

            var version = ApplicationDeployment.IsNetworkDeployed
                ? ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString()
                : Application.ProductVersion;

            productVersionLabel.Text = Application.ProductName + " v" + version;
            productLabel.Text        = Application.ProductName;
            versionLabel.Text        = "Wersja: " + version;
            copyrightLabel.Text      = "© " + DateTime.Today.Year + " " + Application.CompanyName;
            licenseeLabel.Text       = LicenseInfo.IsValid() ? LicenseInfo.Licensee : "BRAK LICENCJI";
        }
        private void ReloadLicenseInfo()
        {
            openLicenseButton.Enabled = LicenseInfo.Error != "NO_SERVER";

            idValue.Text       = LicenseInfo.Id;
            productValue.Text  = LicenseInfo.Product;
            versionValue.Text  = LicenseInfo.Version;
            dateValue.Text     = LicenseInfo.Date;
            licenseeValue.Text = LicenseInfo.Licensee;

            if (LicenseInfo.IsValid())
            {
                ShowErrorMessage(true, "OK!");
            }
            else
            {
                ShowErrorMessage(false, LicenseInfo.ErrorMessage);
            }
        }
        private void licenseServerTextBox_TextChanged(object sender, EventArgs e)
        {
            Uri uri = null;

            try
            {
                uri = new Uri(licenseServerTextBox.Text, UriKind.Absolute);

                if (uri.Scheme != "http")
                {
                    throw new Exception();
                }

                Properties.Settings.Default.LicenseServer = "http://" + uri.Authority;
            }
            catch (Exception)
            {
                Properties.Settings.Default.LicenseServer = "";
            }

            LicenseInfo.Reset();
            ReloadLicenseInfo();
        }