Ejemplo n.º 1
0
 private void DownloadProgressCallback(object sender, EventArgs e)
 {
     GitHub.RequestState state = sender as GitHub.RequestState;
     if (ThisDialog != null && ThisDialog.Visible)
     {
         if (state != null)
         {
             DeniedClose = true;
             try {
                 ThisDialog.Invoke((MethodInvoker) delegate {
                     if (state.TotalBytes > 0)
                     {
                         progress.Maximum = (int)state.TotalBytes;
                         progress.Value   = (int)state.BytesRead;
                         int proc         = (int)(state.BytesRead / (state.TotalBytes / 100));
                         DrawProgress(proc);
                     }
                 });
             } finally {
                 DeniedClose = false;
             }
         }
     }
     else
     {
         if (state != null)
         {
             state.Close();
         }
     }
 }
Ejemplo n.º 2
0
        private void DownloadTemplateCallback(object sender, EventArgs e)
        {
            GitHub.RequestState state = sender as GitHub.RequestState;

            GitHub.DownloadFileCompleted   -= DownloadTemplateCallback;
            GitHub.DownloadProgressChanged -= DownloadProgressCallback;

            if (ThisDialog != null && ThisDialog.Visible)
            {
                DeniedClose = true;
                try {
                    ThisDialog.Invoke((MethodInvoker) delegate {
                        progress.Hide();
                        btnUpdateProgram.Enabled   = true;
                        btnUpdateTemplates.Enabled = true;
                        btnUpdateTemplates.Visible = false;
                        if (HMS.ExtractZip(tmpFileTemplate, true))
                        {
                            HMSEditor.Settings.Set("TemplateLastUpdate", TemplatesDate, "Common");
                            HMSEditor.Settings.Save();
                            HMS.LoadTemplates();
                            labelNewTemplates.Text = "Обновлено";
                        }
                    });
                } finally {
                    DeniedClose = false;
                }
            }
        }
Ejemplo n.º 3
0
 private void DownloadReleaseCallback(object sender, EventArgs e)
 {
     GitHub.RequestState state = sender as GitHub.RequestState;
     GitHub.DownloadFileCompleted   -= DownloadReleaseCallback;
     GitHub.DownloadProgressChanged -= DownloadProgressCallback;
     if (ThisDialog != null && ThisDialog.Visible)
     {
         DeniedClose = true;
         try {
             ThisDialog.Invoke((MethodInvoker) delegate {
                 progress.Hide();
                 if (!AuthenticodeTools.IsTrusted(tmpFileRelease))
                 {
                     string msg = "У полученного файла не верная цифровая подпись. Обновление прервано.\n\n" +
                                  "Это может означать, что произошла подмена файла или автор забыл подписать файл. " +
                                  "Может быть временные проблемы с интернетом. В любом случае, можно попробовать " +
                                  "посетить пару мест, где знают о существовании данной программы и спросить там:\n" +
                                  "https://homemediaserver.ru/forum\nhttps://hms.lostcut.net\nhttps://github.com/WendyH/HMSEditor/issues";
                     MessageBox.Show(msg, HMSEditor.MsgCaption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                     return;
                 }
                 InstallNewFile();
             });
         } finally {
             DeniedClose = false;
         }
     }
 }