示例#1
0
        /// <summary>
        /// Generate a new FrmUpdater form.
        /// </summary>
        /// <param name="update">The Update that should be loaded.</param>
        /// <param name="language">The current Language.</param>
        public FrmUpdater(Update update, Language language)
        {
            InitializeComponent();
            _update = update;
            _webClient = new WebClient();
            _language = language;

            _webClient.DownloadFileCompleted += Completed;
            _webClient.DownloadProgressChanged += ProgressChanged;
        }
示例#2
0
        /// <summary>
        /// Generate a new FrmUpdater form.
        /// </summary>
        /// <param name="update">The Update that should be loaded.</param>
        /// <param name="language">The current Language.</param>
        public FrmUpdater(Update update, Language language)
        {
            InitializeComponent();
            _update = update;
            _webClient = new WebClient();
            _language = language;

            _webClient.DownloadFileCompleted += Completed;
            _webClient.DownloadProgressChanged += ProgressChanged;

            _extension = _update.UpdateUrl.Substring(_update.UpdateUrl.Length - 4, 4);
        }
示例#3
0
 /// <summary>
 /// Generate a new FrmMain form.
 /// </summary>
 /// <param name="args">A collection of arguments.</param>
 public FrmMain(string[] args)
 {
     InitializeComponent();
     try
     {
         _lvlManager = new ListViewLockerManager();
         _languageManager = new LanguageManager();
         _update = new Update();
         if (Properties.Settings.Default.Language == 5)
         {
             _languageManager.LoadLanguage(Properties.Settings.Default.LanguagePath);
         }
         else
         {
             _languageManager.LoadLanguage();
         }
         LanguageSwitch();
     }
     catch (Exception ex)
     {
         MessageBoxAdv.Show(ex.Message, "DeadLock", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     _args = args;
 }
示例#4
0
        /// <summary>
        /// Check if there are updates available for the program.
        /// </summary>
        /// <param name="showError">Show errors.</param>
        /// <param name="showNoUpdates">Show a MessageBox when there are no updates available.</param>
        private void Update(bool showError, bool showNoUpdates)
        {
            Language l = _languageManager.GetLanguage();
            try
            {
                WebClient wc = new WebClient();
                string xml = wc.DownloadString("http://codedead.com/Software/DeadLock/update.xml");

                XmlSerializer serializer = new XmlSerializer(_update.GetType());
                using (MemoryStream stream = new MemoryStream())
                {
                    StreamWriter writer = new StreamWriter(stream);
                    writer.Write(xml);
                    writer.Flush();
                    stream.Position = 0;
                    _update = (Update)serializer.Deserialize(stream);
                    writer.Dispose();
                }
                if (_update.CheckForUpdate())
                {
                    if (MessageBoxAdv.Show(l.MsgVersion + " " + _update.GetUpdateVersion() + " " + l.MsgAvailable + Environment.NewLine + l.MsgDownloadNewVersion, "DeadLock", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        new FrmUpdater(_update, _languageManager.GetLanguage()).ShowDialog();
                    }
                }
                else
                {
                    if (showNoUpdates)
                    {
                        MessageBoxAdv.Show(l.MsgLatestVersionAlreadyInstalled, "DeadLock", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                if (showError)
                {
                    MessageBoxAdv.Show(ex.Message, "DeadLock", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }