Beispiel #1
0
        /// <summary>
        /// Loads VersionInfo from specified file.
        /// </summary>
        /// <param name="fileName">The filename.</param>
        public void Load(string fileName)
        {
            try
            {
                // Create a file stream object
                FileStream file = File.OpenRead(fileName);

                // Start Serialization
                XmlSerializer xmlSerializer
                    = new XmlSerializer(this.versionInfo.GetType());
                this.versionInfo
                    = (VersionInfo)xmlSerializer.Deserialize(file);

                file.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void CheckVersion(VersionInfo localVersionInfo, string remoteFile)
#endif
        {
            Uri webFile = new Uri(remoteFile);
            string localFile = System.IO.Path.GetTempFileName();

            if (this.DownloadFile(webFile, localFile))
            {
                string message = string.Empty;
                this.versionInfoManager.Load(localFile);
                this.versionInfo = this.versionInfoManager.VersionInformation;
                bool newVersion = false;

                if (localVersionInfo.AssemblyVersion
                    != this.versionInfo.AssemblyVersion)
                {
                    newVersion = true;
                }

                if (this.VersionChecked != null)
                {
                    NewVersionEventArgs e = new NewVersionEventArgs();
                    e.NewVersion = newVersion;
                    e.VersionInformation = this.versionInfo;
                    this.VersionChecked(this, e);
                }
            }

            File.Delete(localFile);
        }
        /// <summary>
        /// Checks the version.
        /// </summary>
        /// <param name="localVersionInfo">The local version info.</param>
        /// <param name="remoteFile">The remote file.</param>
#if DEBUG
        public void CheckVersion(VersionInfo localVersionInfo, string remoteFile)
        /// <summary>
        /// Checks the version.
        /// </summary>
        /// <param name="localVersionInfo">The local version info.</param>
        public void CheckVersion(VersionInfo localVersionInfo)
        {
            string webServer = "http://env-man.sourceforge.net/";
#if DEBUG
            string webFileName = "EnvMan.Debug";
#else
            string webFileName = "EnvMan.Release";
#endif
            string webFile = webServer + webFileName;

            this.CheckVersion(localVersionInfo, webFile);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="VersionInfoManagerTest"/> class.
 /// </summary>
 public VersionInfoManagerTest()
 {
     this.versionInfoManager = new VersionInfoManager();
     this.versionInfo = new VersionInfo();
 }
Beispiel #6
0
        /// <summary>
        /// Version Checker Handler for version checks.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Envman.VersionManager.NewVersionEventArgs"/> instance containing the event data.</param>
        private void VersionChecker_NewVersionChecked(
            object sender, NewVersionEventArgs e)
        {
            string msg = string.Empty;

            if (e.NewVersion)
            {
                this.versionInfo = e.VersionInformation;
                msg = "New version " + VersionInfo.VersionFormatter(
                    this.versionInfo.AssemblyVersion) + " released";
                this.TsmiNewVersionInfo.Text = msg;
                this.TsmiNewVersionInfo.Visible = true;

                if (this.showFrmVersionInfo)
                {
                    FrmVersionInfo versionInfoForm = new FrmVersionInfo();
                    versionInfoForm.Icon = Properties.Resources.EnvManICO;
                    versionInfoForm.Message = msg;
                    if (versionInfoForm.ShowDialog() == DialogResult.OK)
                    {
                        this.TsmiClick(this.TsmiNewVersionInfo, null);
                    }
                }
            }
            else
            {
                msg = "You have the current version.";
                if (this.showFrmVersionInfo)
                {
                    MessageBox.Show(
                        msg,
                        "EnvMan",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information);
                }
            }
        }