示例#1
0
        public AboutUI(StartupOptions startup_options)
        {
            InitializeComponent();

            m_licence      = new Licence(startup_options.LicenceFilepath);
            m_installed_on = InstalledOn(startup_options);
            m_timer        = new Timer {
                Interval = 1000
            };

            // Version info
            m_edit_version.Text = string.Format(
                "{0} {1}" +
                "Version: {2}" +
                "Built: {3}" +
                "All Rights Reserved"
                , Util.GetAssemblyAttribute <AssemblyCompanyAttribute>().Company
                , Util.GetAssemblyAttribute <AssemblyCopyrightAttribute>().Copyright + Environment.NewLine
                , Util.AssemblyVersion() + Environment.NewLine
                , Util.AssemblyTimestamp() + Environment.NewLine
                );
            m_edit_version.Select(0, 0);

            // Version history
            m_btn_version_history.Click += (s, a) =>
            {
                HelpUI.ShowDialog(this, HelpUI.EContent.Html, "Version History", Resources.version_history);
            };

            // Update the text fields
            m_timer.Tick   += (s, a) => UpdateUI();
            m_timer.Enabled = true;

            UpdateUI();
        }
示例#2
0
 public Licence(Licence rhs)
 {
     LicenceHolder  = rhs.LicenceHolder;
     EmailAddress   = rhs.EmailAddress;
     Company        = rhs.Company;
     VersionMask    = rhs.VersionMask;
     ActivationCode = rhs.ActivationCode;
     Changed        = false;
 }
示例#3
0
        /// <summary>Update the UI</summary>
        private void UpdateUI(object sender = null, EventArgs args = null)
        {
            var lic = new Licence(m_main.StartupOptions.LicenceFilepath);

            m_tb_name.Text     = lic.LicenceHolder;
            m_tb_email.Text    = lic.EmailAddress;
            m_tb_company.Text  = lic.Company;
            m_tb_versions.Text = lic.VersionMask;

            m_lbl_valid.Text =
                lic.Valid ? "Valid Licence" :
                lic.IsFreeLicence ? "Free Licence" :
                lic.NotForThisVersion ? "Old Licence" :
                "Invalid licence";

            m_lbl_valid.BackColor =
                lic.Valid ? Color.LightGreen :
                lic.IsFreeLicence ? Color.LightGreen :
                Color.LightSalmon;
        }
示例#4
0
        /// <summary>Browse to the licence file</summary>
        private void LocateLicenceFile()
        {
            // Prompt for the user to find the licence file
            var filepath = (string)null;

            using (var dlg = new OpenFileDialog {
                Title = "Locate Licence File", Filter = "RyLogViewer Licence File|licence.xml"
            })
            {
                if (dlg.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }
                filepath = dlg.FileName;
            }

            try
            {
                // Check the licence
                var lic = new Licence(filepath);
                if (lic.Valid)
                {
                    // If there is an existing licence file, confirm overwrite
                    if (Path_.FileExists(m_main.StartupOptions.LicenceFilepath))
                    {
                        // Read the existing licence
                        var existing_lic = (Licence)null;
                        try { existing_lic = new Licence(m_main.StartupOptions.LicenceFilepath); } catch { }
                        if (existing_lic != null && existing_lic.Valid)
                        {
                            // Prompt if about to override an existing valid licence
                            var res = MsgBox.Show(this,
                                                  $"An existing valid licence already exists:\r\n" +
                                                  $"Licence Holder: {existing_lic.LicenceHolder}\r\n" +
                                                  $"Email Address: {existing_lic.EmailAddress}\r\n" +
                                                  "\r\n" +
                                                  "Do you want to replace this licence?",
                                                  Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            if (res != DialogResult.Yes)
                            {
                                return;
                            }
                        }

                        // Write the licence to the expected location
                        lic.WriteLicenceFile(m_main.StartupOptions.LicenceFilepath);
                        UpdateUI();

                        // Say thank you
                        MsgBox.Show(this,
                                    "Thank you for activating " + Application.ProductName + ".\r\n" +
                                    "Your support is greatly appreciated."
                                    , "Activation Successful"
                                    , MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    return;
                }

                // Valid licence but not for this version
                if (lic.NotForThisVersion)
                {
                    MsgBox.Show(this,
                                "This licence is for an older version of " + Application.ProductName + ".\r\n" +
                                "\r\n" +
                                "Please consider purchasing a new licence for this version.\r\n" +
                                "If you believe this to be an error, please contact '" + Constants.SupportEmail + "' for support."
                                , "Licence Out of Date"
                                , MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                // Do nothing with free licences
                if (lic.IsFreeLicence)
                {
                    MsgBox.Show(this,
                                "This licence is the free edition licence.\r\n" +
                                "\r\n" +
                                "Please consider purchasing a licence for this version.\r\n" +
                                "If you believe this to be an error, please contact '" + Constants.SupportEmail + "' for support."
                                , "Free Edition Licence"
                                , MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                // Licence is invalid
                MsgBox.Show(this,
                            "This licence file is invalid.\r\n" +
                            "\r\n" +
                            "If you believe this to be an error, please contact '" + Constants.SupportEmail + "' for support."
                            , "Activation Failed"
                            , MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MsgBox.Show(this, $"Failed to locate and import a valid licence file\r\n{ex.Message}", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }