Exemple #1
0
        private void LaunchButton_Click(object sender, EventArgs e)
        {
            FileInfo licenseFile = new FileInfo(GetLicenseFilePath());

            if (!licenseFile.Exists)
            {
                InvalidLicense();
                return;
            }

            string code  = string.Empty;
            bool   valid = HorizonLicenses.CheckForLicense("Alpha", licenseFile.FullName, ref code);

            if (!valid)
            {
                MessageBox.Show(this, "Invalid license: " + HorizonLicenses.LastError, "License Error", MessageBoxButtons.OK);
                return;
            }

            string binPath = Path.Combine(GameDir.FullName, "bin");

            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.Arguments        = "";
            startInfo.FileName         = "Horizons.exe";
            startInfo.UseShellExecute  = true;
            startInfo.WorkingDirectory = binPath;
            startInfo.CreateNoWindow   = true;
            this.WindowState           = FormWindowState.Minimized;

            Process.Start(startInfo);

            Close();
        }
Exemple #2
0
        internal static string GetProductCode()
        {
            string pCode = string.Empty;

            HorizonLicenses.CheckForLicense("Alpha", GetLicenseFilePath(), ref pCode);
            return(pCode);
        }
Exemple #3
0
        private bool ValidateLicense()
        {
            bool ret = HorizonLicenses.CheckForLicense("Alpha", GetLicenseFilePath(), ref UpMan.ProductCode);

            if (!ret)
            {
                InvalidLicense();
            }

            return(ret);
        }
Exemple #4
0
        private void Application_Idle(object sender, EventArgs e)
        {
            if (!IsLicensed())
            {
                // show license dialog
                Application.Idle -= Application_Idle;

                LicenseEntryDialog licenseDialog = new LicenseEntryDialog();
                if (licenseDialog.ShowDialog(this) != DialogResult.OK)
                {
                    InvalidLicense();
                }
                else
                {
                    FileInfo licenseFile = new FileInfo(GetLicenseFilePath());
                    if (!licenseFile.Directory.Exists)
                    {
                        licenseFile.Directory.Create();
                    }

                    if (!licenseFile.Exists)
                    {
                        HorizonLicenses.WriteLicenseFile(licenseFile, HorizonLicenses.CreateLicenseString(licenseDialog.LicenseCode, "Alpha", licenseFile.FullName));
                    }
                }

                if (IsLicensed())
                {
                    ValidateLicense();

                    if (IsValdInstall())
                    {
                        PushLog("Valid install detected, Launch when ready");
                        LaunchButton.Enabled   = true;
                        SettingsButton.Enabled = true;
                        CheckMusic();
                        NewsButton_Click(sender, e);
                    }
                    else
                    {
                        PushLog("Invalid install detected, forcing update");
                        SettingsButton.Enabled = HasSettings();
                        CheckMusic();
                        UpdateButton_Click(sender, e);
                    }
                }
            }
        }