コード例 #1
0
ファイル: FormAbout.cs プロジェクト: clarencemorse/myzilla
        private void FormAbout_Load(object sender, EventArgs e)
        {
            this.GetAssemblyAttributes ();

            this.Text = _assemblyTitle;

            ApplicationVersion appVersion = new ApplicationVersion(_assemblyVersion);

            labelVersion.Text += appVersion.ToString();

            lnkCompanyName.Text  = _assemblyCompany;

            labelCopyright.Text = _assemblyCopyright;
        }
コード例 #2
0
        public static int Comparison(ApplicationVersion version1, ApplicationVersion version2)
        {
            if (version1.PrimaryVersion < version2.PrimaryVersion ||
                (version1.PrimaryVersion == version2.PrimaryVersion && version1.SecondaryVersion < version2.SecondaryVersion) ||
                (version1.PrimaryVersion == version2.PrimaryVersion && version1.SecondaryVersion == version2.SecondaryVersion && version1.BuildNr < version2.BuildNr))
            {
                return(-1);
            }

            else if (version1.PrimaryVersion == version2.PrimaryVersion && version1.SecondaryVersion == version2.SecondaryVersion && version1.BuildNr == version2.BuildNr)
            {
                return(0);
            }

            else if (version1.PrimaryVersion > version2.PrimaryVersion ||
                     (version1.PrimaryVersion == version2.PrimaryVersion && version1.SecondaryVersion > version2.SecondaryVersion) ||
                     (version1.PrimaryVersion == version2.PrimaryVersion && version1.SecondaryVersion == version2.SecondaryVersion && version1.BuildNr > version2.BuildNr))
            {
                return(1);
            }

            return(0);
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: clarencemorse/myzilla
        // Callback method must have the same signature as the
        // AsyncCallback delegate.
        private void CallbackCheckForNewMyZillaVersion(IAsyncResult ar)
        {
            // Retrieve the delegate.
            AsyncCheckForNewMyZillaVersion dlgt = (AsyncCheckForNewMyZillaVersion)ar.AsyncState;

            // Call EndInvoke to retrieve the results.
            object[] result = dlgt.EndInvoke(ar);

            string publishedMyZillaVersion = result[0] as string;
            bool forceCheck = (result[1] == null ? false : (bool)result[1]);
            Form owner = result[2] as Form;

            if (!String.IsNullOrEmpty(publishedMyZillaVersion))
            {
                ApplicationVersion publishedVersion = new ApplicationVersion(publishedMyZillaVersion);
                ApplicationVersion applicationInstanceVersion = new ApplicationVersion(Application.ProductVersion);

                MyZillaSettingsDataSet _appSettings = MyZillaSettingsDataSet.CreateInstance(Utils.UserAppDataPath);

                MyZillaSettingsDataSet.GlobalSettingsRow settings = _appSettings.GetGlobalSettings();

                if (forceCheck || (publishedVersion > (new ApplicationVersion(settings.LastMyZillaVersion))))
                {

                    if (publishedVersion > applicationInstanceVersion)
                    {
                        FormNewVersion newVersion = new FormNewVersion(publishedVersion.ToString());

                        if (this.InvokeRequired)
                        {
                            this.BeginInvoke(new MethodInvoker(delegate()
                            {
                                newVersion.ShowDialog(this);
                            }));
                        }
                    }
                    else
                    {
                        if (forceCheck)
                        {
                            if (owner.InvokeRequired)
                            {
                                this.BeginInvoke(new MethodInvoker(delegate()
                                {
                                    MessageBox.Show(owner, "No update is available!", "MyZilla", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }));

                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
 public static bool operator ==(ApplicationVersion version1, ApplicationVersion version2)
 {
     return(ApplicationVersion.Comparison(version1, version2) == 0);
 }
コード例 #5
0
        public static int Comparison(ApplicationVersion version1, ApplicationVersion version2)
        {
            if (version1.PrimaryVersion < version2.PrimaryVersion
                || (version1.PrimaryVersion == version2.PrimaryVersion && version1.SecondaryVersion < version2.SecondaryVersion)
                || (version1.PrimaryVersion == version2.PrimaryVersion && version1.SecondaryVersion == version2.SecondaryVersion && version1.BuildNr < version2.BuildNr))

                return -1;

            else if (version1.PrimaryVersion == version2.PrimaryVersion && version1.SecondaryVersion == version2.SecondaryVersion && version1.BuildNr == version2.BuildNr)

                return 0;

            else if (version1.PrimaryVersion > version2.PrimaryVersion
               || (version1.PrimaryVersion == version2.PrimaryVersion && version1.SecondaryVersion > version2.SecondaryVersion)
               || (version1.PrimaryVersion == version2.PrimaryVersion && version1.SecondaryVersion == version2.SecondaryVersion && version1.BuildNr > version2.BuildNr))

                return 1;

            return 0;
        }