You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.2 KiB
C#

using Microsoft.Win32;
using System;
using System.IO;
using System.Windows.Forms;
namespace AutoUpdater
{
public partial class MainForm : Form
{
private VersionObject versionObject = null;
public MainForm(VersionObject vobject)
{
InitializeComponent();
this.versionObject = vobject;
this.labelUpdate.Text = string.Format(this.labelUpdate.Text , versionObject.NewVersionNum);
this.labelDescription.Text = string.Format(this.labelDescription.Text ,versionObject.VersionNum);
this.updateInfo.Text = versionObject.UploadLog;
this.buttonSkip.Visible = (versionObject.ForceUpload==0);
}
private void buttonUpdate_Click(object sender , EventArgs e)
{
Global.Instance.isUpdate = versionObject.HasNew;
Global.Instance.CurrentVersion = versionObject.VersionNum;
Global.Instance.NewVersion = versionObject.NewVersionNum;
Global.Instance.StartApplication = versionObject.StartApplication;
var urls = new DownloadURLCollection();
string dest = Path.Combine(AppDomain.CurrentDomain.BaseDirectory , @"update\");
var url = versionObject.DfsAccessDomain + "/" + versionObject.UploadFile;
urls.Add(new DownloadURL(url , dest));
Global.Instance.Urls = urls;
Global.Instance.DownloadPath = dest;
var downloadFileName = versionObject.UploadFile.Substring(versionObject.UploadFile.LastIndexOf('/') + 1);
Global.Instance.DownloadFileName = downloadFileName;
this.DialogResult = DialogResult.OK;
}
protected override void WndProc(ref Message m)
{
const int WM_SYSCOMMAND = 0x0112;
const int SC_CLOSE = 0xF060;
if (m.Msg == WM_SYSCOMMAND && (int)m.WParam == SC_CLOSE)
{
if(versionObject.ForceUpload == 1)
{
return;
}
}
base.WndProc(ref m);
}
private void buttonSkip_Click(object sender , EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
}
}