private void CheckForUpdate()
        {
            up = new Update(new Uri("http://www.imageglass.org/checkforupdate"), tempDir + "update.xml");

            if (File.Exists(tempDir + "update.xml"))
            {
                File.Delete(tempDir + "update.xml");
            }

            lblUpdateVersion.Text = "Version: " + up.Info.NewVersion.ToString();
            lblUpdateVersionType.Text = "Version type: " + up.Info.VersionType;
            lblUpdateImportance.Text = "Importance: " + up.Info.Level;
            lblUpdateSize.Text = "Size: " + up.Info.Size;
            lblUpdatePubDate.Text = "Publish date: " + up.Info.PublishDate.ToString("MMM d, yyyy");

            this.Text = "";

            if (up.CheckForUpdate(GlobalSetting.StartUpDir + "ImageGlass.exe"))
            {
                if (up.Info.VersionType.ToLower() == "stable")
                {
                    this.Text = "Your ImageGlass is outdate!";
                }

                picStatus.Image = igcmd.Properties.Resources.warning;
                btnDownload.Enabled = true;
            }
            else
            {
                btnDownload.Enabled = false;
                picStatus.Image = igcmd.Properties.Resources.ok;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Check for update
        /// </summary>
        public static void AutoUpdate()
        {
            Update up = new Update(new Uri("http://www.imageglass.org/checkforupdate"),
                GlobalSetting.StartUpDir + "update.xml");

            if (File.Exists(GlobalSetting.StartUpDir + "update.xml"))
            {
                File.Delete(GlobalSetting.StartUpDir + "update.xml");
            }

            //save last update
            GlobalSetting.SetConfig("AutoUpdate", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"));

            if (up.CheckForUpdate(Application.StartupPath + "\\ImageGlass.exe") &&
                up.Info.VersionType.ToLower() == "stable")
            {
                frmCheckForUpdate f = new frmCheckForUpdate();
                f.ShowDialog();
            }

            Application.Exit();
        }
        private void CheckForUpdate()
        {
            up = new Update(new Uri("http://www.imageglass.org/checkforupdate"), tempDir + "update.xml");

            if (File.Exists(tempDir + "update.xml"))
            {
                File.Delete(tempDir + "update.xml");
            }

            if (up.IsError)
            {
                this.Size = this.MaximumSize;
                lblUpdateVersion.Text = "Please visit http://imageglass.org/download to check for updates.";
                lblUpdateVersionType.Text =
                    lblUpdateImportance.Text =
                    lblUpdateSize.Text =
                    lblUpdatePubDate.Text =
                    lnkUpdateReadMore.Text =
                    String.Empty;

                lblStatus.Text = "Unable to check for current version online.";
                lblStatus.ForeColor = Color.FromArgb(241, 89, 58);
                picStatus.Image = igcmd.Properties.Resources.warning;
            }
            else
            {
                this.Size = this.MinimumSize;
                lblUpdateVersion.Text = "Version: " + up.Info.NewVersion.ToString();
                lblUpdateVersionType.Text = "Version type: " + up.Info.VersionType;
                lblUpdateImportance.Text = "Importance: " + up.Info.Level;
                lblUpdateSize.Text = "Size: " + up.Info.Size;
                lblUpdatePubDate.Text = "Publish date: " + up.Info.PublishDate.ToString("MMM d, yyyy");
                lnkUpdateReadMore.Text = "Read more...";

                if (up.CheckForUpdate(GlobalSetting.StartUpDir + "ImageGlass.exe"))
                {
                    if (up.Info.VersionType.ToLower() == "stable")
                    {
                        lblStatus.Text = "ImageGlass is out of date!";
                        lblStatus.ForeColor = Color.FromArgb(241, 89, 58);
                    }
                    else
                    {
                        lblStatus.Text = "ImageGlass is up to date!";
                        lblStatus.ForeColor = Color.FromArgb(23, 131, 238);
                    }
                    picStatus.Image = igcmd.Properties.Resources.warning;
                    btnDownload.Enabled = true;
                }
                else
                {
                    lblStatus.Text = "ImageGlass is up to date!";
                    lblStatus.ForeColor = Color.FromArgb(23, 131, 238);
                    btnDownload.Enabled = false;
                    picStatus.Image = igcmd.Properties.Resources.ok;
                }
            }

            //save last update
            GlobalSetting.SetConfig("AutoUpdate", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"));
        }