tijian_jichuang/Code/SmartUpdater/UpdateUI.cs

798 lines
25 KiB
C#
Raw Permalink Normal View History

2025-02-20 11:54:48 +08:00
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Threading;
using System.IO;
using EAS.Distributed;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using EAS.Security;
namespace EAS.Distributed
{
public partial class UpdateUI : System.Windows.Forms.Form
{
Thread updateThread = null;
Thread killThread = null;
DateTime lastTime = DateTime.MinValue;
DateTime sTime = DateTime.MinValue;
SmartConfig sc1 = null; //ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SmartConfig sc2 = null; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
IList<SmartFile> updateList = new List<SmartFile>();
IList<SmartFile> deleteList = new List<SmartFile>();
bool bComplete = false;
bool m_Kill = true;
public UpdateUI()
{
InitializeComponent();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad (e);
if(XUpdate.Instance.Title.Length > 0)
this.Text = XUpdate.Instance.Title;
this.progressBar.Maximum = 0;
this.progressBar.Minimum = 0;
this.statusErrors.Text = "0<><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
this.statusTasks.Text = "0<><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
//1.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̡߳<DFB3>
this.updateThread = new Thread(new ThreadStart(this.AutoUpdate));
this.updateThread.Start();
#if DEBUG
using (TextLogger loggger = new TextLogger())
{
loggger.Debug(XUpdate.Instance.GetBaseDirectory());
}
#endif
//2.<2E><><EFBFBD><EFBFBD>һ<EFBFBD>̣߳<DFB3>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>Ӧ<EFBFBD>ý<EFBFBD><C3BD>̡<EFBFBD>
this.killThread = new Thread(new ThreadStart(() =>
{
while (m_Kill)
{
string baseDirectory = XUpdate.Instance.GetBaseDirectory();
Process[] process = System.Diagnostics.Process.GetProcesses();
foreach (var item in process)
{
//A.<2E><><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (item.Id == Process.GetCurrentProcess().Id) //<2F><><EFBFBD><EFBFBD>
{
continue;
}
bool exists = false;
#region //A2.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򣬹ر<F2A3ACB9>֮<EFBFBD><D6AE>
string pName = item.ProcessName;
if (pName.EndsWith("*32"))
{
pName = pName.Substring(0, pName.Length - 3).Trim();
}
#if DEBUG
using (TextLogger loggger = new TextLogger { Path = Path.Combine(baseDirectory, "logs"), FileName = "kill.log" })
{
loggger.Info(pName);
}
#endif
exists = string.Compare(Path.GetFileNameWithoutExtension(XUpdate.Instance.Application), item.ProcessName, true) == 0;
if (!exists)
{
exists = string.Compare(Path.GetFileName(XUpdate.Instance.Application), item.ProcessName, true) == 0;
}
#endregion
if (!exists)
{
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˱<EFBFBD>Ŀ¼<EFBFBD><EFBFBD>dll
//B.<2E><>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><E5B5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>64λ<34><CEBB>
ProcessModuleCollection ProcessModule = null;
try
{
ProcessModule = item.Modules;
}
catch { }
if (ProcessModule != null)
{
List<ProcessModule> vList = new List<System.Diagnostics.ProcessModule>();
foreach (ProcessModule pModule in ProcessModule)
{
vList.Add(pModule);
}
try
{
vList.Add(item.MainModule);
}
catch { }
#region 32λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Kill<EFBFBD><EFBFBD>
//2.<2E>ж<EFBFBD><D0B6><EFBFBD>ҪKill?
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD>Ŀ¼֮<C2BC>е<EFBFBD><D0B5>ļ<EFBFBD><C4BC>Ľ<EFBFBD><C4BD>̾<EFBFBD>ǿ<EFBFBD><C7BF><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>
foreach (ProcessModule pModule in vList) //ѭ<><D1AD>ɨ<EFBFBD><C9A8>ģ<EFBFBD>
{
#region ѭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>
string modueFile = string.Empty;
try
{
modueFile = pModule.FileName;
}
catch { }
#if DEBUG
//using (TextLogger loggger = new TextLogger { Path = Path.Combine(baseDirectory, "logs"), FileName = "kill.log" })
//{
// loggger.Info(modueFile);
//}
#endif
if (string.Compare(Path.GetDirectoryName(modueFile), baseDirectory, true) == 0)
{
exists = true;
break;
}
#endregion
}
#endregion
}
#endregion
}
if (exists) //ִ<><D6B4>Kill<6C><6C>
{
#region ִ<EFBFBD><EFBFBD>Kill
try
{
item.Kill();
}
catch (System.Exception exc)
{
#if DEBUG
using (TextLogger loggger = new TextLogger { Path = Path.Combine(baseDirectory, "logs"),FileName ="kill.log" })
{
loggger.Error(exc);
}
#endif
}
#endregion
}
}
//<2F><>ͣ100<30><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
System.Threading.Thread.Sleep(50);
}
}));
killThread.Start();
}
bool CloseComplete
{
get
{
return this.checkCloseComplete.Checked;
}
set
{
this.checkCloseComplete.Checked = value;
}
}
#region UI֪ͨ
int progressMax = 0;
int progressPos = 0;
string _message = string.Empty;
bool _error = false;
void UpdateMessage(string message,bool error)
{
_message = message;
_error = error;
ChangeMessage();
}
void ChangeMessage()
{
try
{
if (this.InvokeRequired)
{
this.Invoke(new MethodInvoker(this.ChangeMessage));
return;
}
this.statusMessage.Text = _message.Trim() + "...";
this.labelMessage.Text = _message.Trim() + "...";
ListViewItem item = null;
if (!_error)
{
item = this.listTasks.Items.Add(_message, 1);
this.statusTasks.Text = this.listTasks.Items.Count.ToString() + "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
this.listTasks.Update();
}
else
{
string msg = _message.Replace("\n", "");
item = this.listErrors.Items.Add(_message, 0);
this.statusErrors.Text = this.listErrors.Items.Count.ToString() + "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
this.listErrors.Update();
}
}
catch { }
}
void UpdateProgress(int pos,int total)
{
progressMax = total;
progressPos = pos;
ChangeProgress();
}
void ChangeProgress()
{
try
{
if (this.InvokeRequired)
{
this.Invoke(new MethodInvoker(this.ChangeProgress));
return;
}
this.progressBar.Maximum = progressMax;
this.progressBar.Value = progressPos;
}
catch { }
}
void ShowClose()
{
try
{
if (this.InvokeRequired)
{
this.Invoke(new MethodInvoker(this.ShowClose));
return;
}
this.btnCancel.Visible = false;
this.btnClose.Visible = true;
}
catch { }
}
#endregion
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>¡<EFBFBD>
/// </summary>
/// <returns></returns>
bool CheckUpdate()
{
updateList.Clear();
//<2F>ж<EFBFBD>
if (!XUpdate.Instance.AllowUpdate)
{
this.UpdateMessage("ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>", true);
this.UpdateProgress(500,500);
this.bComplete = false;
return false;
}
if (XUpdate.Instance.Service == null)
{
try
{
XUpdate.GetService();
}
catch(System.Exception exc)
{
this.UpdateMessage("<22><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + exc.Message, false);
this.UpdateProgress(500,500);
this.bComplete = false;
return false;
}
}
if (XUpdate.Instance.Service == null)
{
this.bComplete = false;
return false;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
string file = Path.Combine(XUpdate.Instance.GetBaseDirectory(), SmartConfig.DefaultConfgiFile);
if (File.Exists(file))
{
try
{
sc1 = XUpdate.LoadSmartAssemblyList();
lastTime = sc1.Time;
}
catch
{
this.UpdateProgress(500, 500);
this.bComplete = false;
return false;
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5B5A5>
this.GenUpdateList();
bool update = this.updateList.Count>0;
if (!update)
{
this.UpdateMessage("ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>°汾", false);
string buffer = XUpdate.Instance.Service.GetSmartUpdateConfig();
sc2 = SmartConfig.LoadXML(buffer);
string configFile = Path.Combine(XUpdate.Instance.GetBaseDirectory(), SmartConfig.DefaultConfgiFile);
SmartConfig.Save(this.sc2, configFile);
this.UpdateProgress(500,500);
this.bComplete = true;
}
return update;
}
/// <summary>
/// <20><><EFBFBD>ɸ<EFBFBD><C9B8><EFBFBD><EFBFBD><EFBFBD><E5B5A5>
/// </summary>
/// <returns></returns>
void GenUpdateList()
{
updateList = new List<SmartFile>();
//A1.ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>
if (sc1 == null)
{
sc1 = new SmartConfig();
}
//B.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
try
{
string buffer = XUpdate.Instance.Service.GetSmartUpdateConfig();
sc2 = SmartConfig.LoadXML(buffer);
}
catch (System.Exception exc)
{
this.UpdateMessage("<22><><EFBFBD>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5B5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + exc.Message, true);
this.UpdateProgress(500,500);
return;
}
if (sc2 == null)
sc2 = new SmartConfig();
//X1.<2E><>Զ<EFBFBD><D4B6>֮<EFBFBD><D6AE>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD>ų<EFBFBD><C5B3>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD>嵥֮<E5B5A5>в<EFBFBD><D0B2><EFBFBD>ʱ<EFBFBD><CAB1>û<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD>ļ<EFBFBD>¼<EFBFBD><C2BC>
foreach (SmartFile item in sc2.Files)
{
var sFile = sc1.Files
.Where(p => string.Compare(p.FileName, item.FileName, true) == 0)
.FirstOrDefault();
if (sFile == null)
{
updateList.Add(item);
}
else if(sFile.Time!=item.Time)
{
updateList.Add(item);
}
}
//X2.<2E><>Զ<EFBFBD><D4B6><EFBFBD>嵥֮<E5B5A5>е<EFBFBD><D0B5>DZ<EFBFBD><C7B1><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
string baseDirectory = XUpdate.Instance.GetBaseDirectory();
foreach (SmartFile item in sc2.Files)
{
string descFile = Path.Combine(baseDirectory, item.FileName);
if (!File.Exists(descFile))
{
int count = updateList
.Where(p => string.Compare(p.FileName, item.FileName, true) == 0)
.Count();
if (count == 0)
{
updateList.Add(item);
}
}
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><E5B5A5>
/// </summary>
/// <remarks>
/// ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>ijЩ<C4B3>ļ<EFBFBD><C4BC>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD>
/// </remarks>
/// <returns></returns>
void GenDeleteList()
{
//<2F><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򼯵<EFBFBD>һ<EFBFBD><D2BB>Key-Value֮<65><D6AE>
Dictionary<string, SmartFile> smartFiles = new Dictionary<string, SmartFile>();
foreach (SmartFile item in sc2.Files)
{
if (!smartFiles.ContainsKey(item.FileName))
{
smartFiles.Add(item.FileName, item);
}
}
//<2F><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD>嵥֮<E5B5A5>У<EFBFBD><D0A3><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>嵥֮<E5B5A5>еġ<D0B5>
foreach (SmartFile item in sc1.Files)
{
if (!smartFiles.ContainsKey(item.FileName))
{
deleteList.Add(item);
}
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
/// </summary>
/// <param name="sf"></param>
void DownFile(SmartFile sf)
{
string downDirectory = XUpdate.Instance.GetDownDirectory();
if (!Directory.Exists(downDirectory))
Directory.CreateDirectory(downDirectory);
try
{
XUpdate.GetService();
byte[] buffer = XUpdate.Instance.Service.DownloadSmartFile(sf.FileName);
buffer = Compressor.Decompress(buffer);
string fileName = Path.Combine(downDirectory, sf.FileName);
//<2F><><EFBFBD>ļ<EFBFBD><C4BC>еĴ<D0B5><C4B4><EFBFBD><EFBFBD><EFBFBD>
string xPath = Path.GetDirectoryName(fileName);
if (!Directory.Exists(xPath))
{
try
{
Directory.CreateDirectory(xPath);
}
catch { }
}
//д<>ļ<EFBFBD><C4BC><EFBFBD>
File.WriteAllBytes(fileName, buffer);
}
catch (System.Exception exc)
{
this.UpdateMessage("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"+Path.GetFileName(sf.FileName)+"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + exc.Message, true);
return;
}
}
/// <summary>
/// <20>ƶ<EFBFBD><C6B6>ļ<EFBFBD><C4BC><EFBFBD>
/// </summary>
void MoveFiles()
{
string downDirectory = XUpdate.Instance.GetDownDirectory();
string baseDirectory = XUpdate.Instance.GetBaseDirectory();
if (!Directory.Exists(downDirectory))
return;
//1.<2E>ƶ<EFBFBD><C6B6>ļ<EFBFBD>
foreach (SmartFile sf in this.updateList)
{
string sourceFile = Path.Combine(downDirectory, sf.FileName);
string descFile = Path.Combine(baseDirectory, sf.FileName);
//<2F><><EFBFBD>ļ<EFBFBD><C4BC>еĴ<D0B5><C4B4><EFBFBD><EFBFBD><EFBFBD>
string xPath = Path.GetDirectoryName(descFile);
if (!Directory.Exists(xPath))
{
try
{
Directory.CreateDirectory(xPath);
}
catch { }
}
if (File.Exists(sourceFile) && File.Exists(descFile))
{
try
{
File.Delete(descFile);
}
catch { }
}
if (File.Exists(sourceFile))
{
string dt = Path.GetDirectoryName(descFile);
if (!Directory.Exists(dt))
try
{
Directory.CreateDirectory(dt);
}
catch { }
try
{
File.Move(sourceFile, descFile);
}
catch { }
}
}
//2.ɾ<><C9BE>Ŀ¼
string[] files = Directory.GetFiles(downDirectory, "*.*", SearchOption.AllDirectories);
foreach (string file in files)
{
try
{
File.Delete(file);
}
catch { }
}
files = Directory.GetDirectories(downDirectory, "*.*", SearchOption.AllDirectories);
foreach (string file in files)
{
try
{
Directory.Delete(file);
}
catch { }
}
if (Directory.Exists(downDirectory))
try
{
Directory.Delete(downDirectory);
}
catch { }
//3.ɾ<><C9BE><EFBFBD>ļ<EFBFBD>
foreach (SmartFile sf in this.deleteList)
{
string descFile = Path.Combine(baseDirectory, sf.FileName);
if (File.Exists(descFile) &&
!sf.FileName.EndsWith("EAS.SmartUpdater.exe", StringComparison.CurrentCultureIgnoreCase) &&
!sf.FileName.EndsWith("update.ini", StringComparison.CurrentCultureIgnoreCase))
{
try
{
File.Delete(descFile);
}
catch { }
}
}
//д<><D0B4><EFBFBD><EFBFBD>
string configFile = Path.Combine(XUpdate.Instance.GetBaseDirectory(), SmartConfig.DefaultConfgiFile);
SmartConfig.Save(this.sc2, configFile);
}
void OnDataTransmit(System.EventArgs e)
{
UpdateMessage("<22>ж<EFBFBD>ϵͳ<CFB5>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>", false);
this.UpdateProgress(1, 500);
bool update = this.CheckUpdate();
if (!update)
{
return;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>µij<C2B5><C4B3><EFBFBD><EFBFBD><EFBFBD>
this.UpdateMessage("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>嵥", false);
this.UpdateProgress(2, 500);
this.GenUpdateList();
this.GenDeleteList();
if (this.updateList.Count == 0 && this.deleteList.Count == 0)
{
this.UpdateMessage(<><C3BB><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>", false);
this.UpdateProgress(500, 500);
//д<><D0B4><EFBFBD><EFBFBD>
string configFile = Path.Combine(XUpdate.Instance.GetBaseDirectory(), SmartConfig.DefaultConfgiFile);
SmartConfig.Save(this.sc2, configFile);
this.bComplete = true;
//<2F><>ֹKill<6C><6C><EFBFBD><EFBFBD>
this.m_Kill = false;
System.Threading.Thread.Sleep(100);
//<2F>ر<EFBFBD>
btnClose_Click(this.btnClose, e);
return;
}
#region //ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
foreach (var sf in this.updateList)
{
string vDirectory = XUpdate.Instance.GetBaseDirectory();
string vFile = Path.Combine(vDirectory, sf.FileName);
if (File.Exists(vFile) &&
!sf.FileName.EndsWith("EAS.SmartUpdater.exe", StringComparison.CurrentCultureIgnoreCase) &&
!sf.FileName.EndsWith("update.ini", StringComparison.CurrentCultureIgnoreCase))
{
try
{
File.Delete(vFile);
}
catch { }
}
}
#endregion
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>µij<C2B5><C4B3><EFBFBD><EFBFBD><EFBFBD>
this.UpdateMessage(<><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>", false);
this.UpdateProgress(3, 500);
int xProgress = 5 * this.updateList.Count + 10;
int index = 1;
foreach (SmartFile sf in this.updateList)
{
this.UpdateMessage(<><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + Path.GetFileName(sf.FileName) + "", false);
this.DownFile(sf);
this.UpdateMessage(Path.GetFileName(sf.FileName) + "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", false);
this.UpdateProgress(5 * index, xProgress);
index++;
}
//
this.UpdateMessage(<><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ", false);
this.MoveFiles();
this.UpdateProgress(xProgress - 5, xProgress);
if (sc2.StartEx.Length > 0)
{
string cmd = XUpdate.Instance.GetBaseDirectory() + " " + sc2.StartEx;
System.Diagnostics.Process.Start(cmd);
}
//<2F><>ֹKill<6C><6C><EFBFBD><EFBFBD>
this.m_Kill = false;
System.Threading.Thread.Sleep(100);
this.UpdateMessage("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", false);
this.UpdateProgress(xProgress, xProgress);
this.bComplete = true;
}
void AutoUpdate()
{
bComplete = false;
try
{
this.OnDataTransmit(new System.EventArgs());
if (this.checkCloseComplete.Checked)
{
//this.Close();
System.Windows.Forms.Application.Exit();
}
}
catch (System.Threading.ThreadAbortException abortExc)
{
this.UpdateMessage(abortExc.Message, true);
}
catch (System.Exception exc)
{
this.UpdateMessage(exc.Message, true);
}
finally
{
this.ShowClose();
}
}
private void btnDetails_Click(object sender, System.EventArgs e)
{
if(this.buttonDetails.Text == "<< <20><>ϸ")
{
this.buttonDetails.Text = "<22><>ϸ >>";
this.tabControl.Visible = false;
this.Height = this.Height - this.tabControl.Height;
}
else
{
this.buttonDetails.Text = "<< <20><>ϸ";
tabControl.Visible = true;
this.Height = this.Height + this.tabControl.Height;
}
}
private void btnCancel_Click(object sender, System.EventArgs e)
{
this.btnCancel.Enabled = false;
Cursor = Cursors.WaitCursor;
try
{
this.updateThread.Abort();
}
catch { }
this.m_Kill = false;
System.Threading.Thread.Sleep(100);
Cursor = Cursors.Default;
this.UpdateMessage("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>", true);
this.btnClose.Visible = true;
tabControl.SelectedIndex = 1;
}
private void btnClose_Click(object sender, System.EventArgs e)
{
this.m_Kill = false;
System.Threading.Thread.Sleep(100);
if (this.bComplete)
{
if (this.updateList.Count >= 1)
{
MessageBox.Show(this, "ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + this.updateList.Count + "<22><>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD>ģ<EFBFBD>飬Ӧ<E9A3AC>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!", "ϵͳ<CFB5><CDB3>ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Thread m_StartThread = new Thread(new ThreadStart(() =>
{
try
{
System.Diagnostics.Process.Start(XUpdate.Instance.Application);
}
catch { }
}));
m_StartThread.Start();
}
//this.Close();
System.Windows.Forms.Application.Exit();
}
private void listErrors_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(this.listErrors.SelectedItems.Count > 0)
{
this.textError.Text = this.listErrors.SelectedItems[0].Text;
}
else
{
this.textError.Text = string.Empty;
}
}
private void UpdateUI_Load(object sender, EventArgs e)
{
}
}
}