예제 #1
0
        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();
        }
예제 #2
0
 private void LicenseForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (!LicenseInfo.IsValid())
     {
         Properties.Settings.Default.LicenseKey = "";
     }
 }
예제 #3
0
        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;
            }
        }
예제 #4
0
        private void ToggleLicenseError()
        {
            LicenseInfo.ReadFromSettings();

            if (LicenseInfo.IsValid())
            {
                licenseErrorLabel.Hide();
            }
            else
            {
                licenseErrorLabel.Show();
            }
        }
예제 #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";
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
        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();
        }