コード例 #1
0
ファイル: AutoUpdateUI.cs プロジェクト: Robin--/RMLibUI
        public static bool Update(Uri url, bool displayNoUpdateMessage)
        {
            if (AutoUpdate.Available(url))
            {
                if (Dialog.YesNo("A new version of " + ProcessUtils.ProductName + " is available!" + Environment.NewLine + Environment.NewLine + "Your version: " + ProcessUtils.ProductVersion + Environment.NewLine + "New version: " + AutoUpdate.Version + Environment.NewLine + Environment.NewLine + AutoUpdate.Comments + Environment.NewLine + Environment.NewLine + "Do you want to download and install the newest version?" + Environment.NewLine + "(Doing so will close " + ProcessUtils.ProductName + ")", "New Version Available!") == DialogResult.Yes)
                {
                    string DownloadFile = StringUtils.PathCombine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Application.CompanyName, Path.GetFileName(AutoUpdate.Url.ToString()));
                    using (frmRMFileDownloader FD = new frmRMFileDownloader(new Uri(AutoUpdate.Url), DownloadFile))
                    {
                        if (FD.ShowDialog() == DialogResult.OK)
                        {
                            try
                            {
                                // Launch installer and return
                                Process.Start(DownloadFile);
                                return true;
                            }
                            catch (Exception)
                            {
                                // User didn't allow the installer to run, so don't quit
                                Dialog.Error("Unable to launch installer", "Error Updating");

                                // Clean up the failed installer
                                FileUtils.FileDelete(DownloadFile);
                            }
                        }
                    }
                }
            }
            else if (displayNoUpdateMessage)
            {
                Dialog.Information("You've got the latest and greatest!", "No Update Available");
            }

            return false;
        }
コード例 #2
0
        static public bool Update(Uri url, bool displayNoUpdateMessage)
        {
            if (AutoUpdate.Available(url))
            {
                if (Dialog.YesNo("A new version of " + ProcessUtils.ProductName + " is available!" + Environment.NewLine + Environment.NewLine + "Your version: " + ProcessUtils.ProductVersion + Environment.NewLine + "New version: " + AutoUpdate.Version + Environment.NewLine + Environment.NewLine + AutoUpdate.Comments + Environment.NewLine + Environment.NewLine + "Do you want to download and install the newest version?" + Environment.NewLine + "(Doing so will close " + ProcessUtils.ProductName + ")", "New Version Available!") == DialogResult.Yes)
                {
                    string DownloadFile = StringUtils.PathCombine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Application.CompanyName, Path.GetFileName(AutoUpdate.Url.ToString()));
                    using (frmRMFileDownloader FD = new frmRMFileDownloader(new Uri(AutoUpdate.Url), DownloadFile))
                    {
                        if (FD.ShowDialog() == DialogResult.OK)
                        {
                            try
                            {
                                // Launch installer and return
                                Process.Start(DownloadFile);
                                return(true);
                            }
                            catch (Exception)
                            {
                                // User didn't allow the installer to run, so don't quit
                                Dialog.Error("Unable to launch installer", "Error Updating");

                                // Clean up the failed installer
                                FileUtils.FileDelete(DownloadFile);
                            }
                        }
                    }
                }
            }
            else if (displayNoUpdateMessage)
            {
                Dialog.Information("You've got the latest and greatest!", "No Update Available");
            }

            return(false);
        }