Пример #1
0
 private void UpdateCheck()
 {
     while (true)
     {
         NewVersionExist = update.CheckVersion();
         AskUserKown     = NewVersionExist ? true : false;
         Thread.Sleep((int)(_settings.UpdateTime * 24 * 60 * 60 * 1000));
     }
 }
Пример #2
0
        public static void CheckVersion(bool showNew)
        {
            string newver = CheckUpdate.GetNewVersion(MyConfig.ReadString(MyConfig.TAG_UPDATE_URL));

            if (newver == CheckUpdate.DEFAULT)
            {   //检查失败
                if (!showNew)
                {
                    return;
                }

                MyMsg.Error(LMSG.CheckUpdateFail);
                return;
            }

            if (CheckUpdate.CheckVersion(newver, Application.ProductVersion))
            {//有最新版本
                if (!MyMsg.Question(LMSG.HaveNewVersion))
                {
                    return;
                }
            }
            else
            {//现在就是最新版本
                if (!showNew)
                {
                    return;
                }

                if (!MyMsg.Question(LMSG.NowIsNewVersion))
                {
                    return;
                }
            }
            //下载文件
            if (CheckUpdate.DownLoad(
                    MyPath.Combine(Application.StartupPath, newver + ".zip")))
            {
                MyMsg.Show(LMSG.DownloadSucceed);
            }
            else
            {
                MyMsg.Show(LMSG.DownloadFail);
            }
        }
Пример #3
0
 private void CheckAUpdateBt_Click(object sender, EventArgs e)
 {
     if (CheckAUpdateBt.Text == "立即更新")
     {
         check.ResumeSoftware();
         QuickForm.NewVersionExist = false;
     }
     else
     {
         CheckAUpdateBt.Text    = "正在检测更新...";
         CheckAUpdateBt.Enabled = false;
         new Thread(() =>
         {
             cheackLoading             = true;
             QuickForm.NewVersionExist = check.CheckVersion();
             NewVersion = QuickForm.NewVersionExist;
             if (NewVersion)
             {
                 BeginInvoke(new Action(() =>
                 {
                     UpdateLabel.Visible    = NewVersion;
                     CheckAUpdateBt.Enabled = true;
                     CheckAUpdateBt.Text    = NewVersion ? "立即更新" : "检测新版本";
                     webBrowser1.Navigate(@"C:\Program Files\菠萝工具箱\UpdateDetail.html");
                     cheackLoading = false;
                 }), null);
                 MessageBox.Show("当前存在新版本,请及时更新。");
             }
             else
             {
                 BeginInvoke(new Action(() =>
                 {
                     CheckAUpdateBt.Enabled = true;
                     CheckAUpdateBt.Text    = NewVersion ? "立即更新" : "检测新版本";
                     cheackLoading          = false;
                 }), null);
                 MessageBox.Show("当前已经是最新版本!");
             }
         }).Start();
     }
 }