|
|
@@ -22,6 +22,7 @@ namespace starter.viewmodel.settings |
|
|
//定义BackgroundWorker |
|
|
//定义BackgroundWorker |
|
|
BackgroundWorker asyncDownloader; |
|
|
BackgroundWorker asyncDownloader; |
|
|
BackgroundWorker asyncUpdater; |
|
|
BackgroundWorker asyncUpdater; |
|
|
|
|
|
BackgroundWorker asyncInitializer; |
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// Model object |
|
|
/// Model object |
|
|
/// </summary> |
|
|
/// </summary> |
|
|
@@ -38,7 +39,7 @@ namespace starter.viewmodel.settings |
|
|
Status = SettingsModel.Status.working; |
|
|
Status = SettingsModel.Status.working; |
|
|
string currentDirectory = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule?.FileName) |
|
|
string currentDirectory = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule?.FileName) |
|
|
?? throw new Exception("Fail to get current directory"); |
|
|
?? throw new Exception("Fail to get current directory"); |
|
|
MessageBox.Show("更新器工作正常"); |
|
|
|
|
|
|
|
|
//MessageBox.Show("更新器工作正常"); |
|
|
if (!Program.Tencent_cos_download.SelfUpdateDismissed()) |
|
|
if (!Program.Tencent_cos_download.SelfUpdateDismissed()) |
|
|
{ |
|
|
{ |
|
|
switch (Program.Tencent_cos_download.CheckSelfVersion()) |
|
|
switch (Program.Tencent_cos_download.CheckSelfVersion()) |
|
|
@@ -53,49 +54,91 @@ namespace starter.viewmodel.settings |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//实例化BackgroundWorker |
|
|
|
|
|
asyncDownloader = new BackgroundWorker(); |
|
|
|
|
|
asyncUpdater = new BackgroundWorker(); |
|
|
|
|
|
//指示BackgroundWorker是否可以报告进度更新 |
|
|
|
|
|
//当该属性值为True是,将可以成功调用ReportProgress方法,否则将引发InvalidOperationException异常。 |
|
|
|
|
|
asyncDownloader.WorkerReportsProgress = true; |
|
|
|
|
|
asyncUpdater.WorkerReportsProgress = true; |
|
|
|
|
|
//挂载方法: |
|
|
|
|
|
asyncDownloader.DoWork += AsyncDownloader_DoWork; |
|
|
|
|
|
asyncUpdater.DoWork += AsyncUpdater_DoWork; |
|
|
|
|
|
//完成通知器: |
|
|
|
|
|
asyncDownloader.RunWorkerCompleted += AsyncDownloader_RunWorkerCompleted; |
|
|
|
|
|
asyncUpdater.RunWorkerCompleted += AsyncUpdater_RunWorkerCompleted; |
|
|
|
|
|
|
|
|
|
|
|
UpdateInfoVis = Visibility.Collapsed; |
|
|
UpdateInfoVis = Visibility.Collapsed; |
|
|
|
|
|
|
|
|
if (Downloader.Program.Tencent_cos_download.CheckAlreadyDownload()) |
|
|
|
|
|
|
|
|
asyncInitializer = new BackgroundWorker(); |
|
|
|
|
|
asyncInitializer.WorkerReportsProgress = true; |
|
|
|
|
|
asyncInitializer.DoWork += AsyncInitializer_DoWork; |
|
|
|
|
|
asyncInitializer.RunWorkerCompleted += AsyncInitializer_RunWorkerCompleted; |
|
|
|
|
|
|
|
|
|
|
|
asyncInitializer.RunWorkerAsync(); |
|
|
|
|
|
Status = SettingsModel.Status.initializing; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void AsyncInitializer_RunWorkerCompleted(object? sender, RunWorkerCompletedEventArgs e) |
|
|
|
|
|
{ |
|
|
|
|
|
if (e.Result == null) |
|
|
|
|
|
{ |
|
|
|
|
|
Status = SettingsModel.Status.error; |
|
|
|
|
|
} |
|
|
|
|
|
else if ((int)e.Result == 1) |
|
|
{ |
|
|
{ |
|
|
obj.checkUpdate(); |
|
|
|
|
|
Status = SettingsModel.Status.login; |
|
|
Status = SettingsModel.Status.login; |
|
|
this.RaisePropertyChanged("WindowWidth"); |
|
|
|
|
|
this.RaisePropertyChanged("LaunchVis"); |
|
|
this.RaisePropertyChanged("LaunchVis"); |
|
|
if (obj.RecallUser()) |
|
|
|
|
|
RememberMe = true; |
|
|
|
|
|
else |
|
|
|
|
|
RememberMe = false; |
|
|
|
|
|
this.RaisePropertyChanged("RememberMe"); |
|
|
this.RaisePropertyChanged("RememberMe"); |
|
|
this.RaisePropertyChanged("SwitchOSBtnCont"); |
|
|
this.RaisePropertyChanged("SwitchOSBtnCont"); |
|
|
//在启动时立刻检查更新,确保选手启动最新版选手包 |
|
|
|
|
|
//若有更新,将启动键改为更新键; |
|
|
|
|
|
//相应地,使用login界面启动; |
|
|
|
|
|
//结构:上方为登录框架,下方有“修改选手包”按钮 |
|
|
|
|
|
|
|
|
|
|
|
//下面几行是用来运行测试的代码 |
|
|
|
|
|
//Program.RunProgram.StartServerForDebug("0.0.0.0",8888,4,1,600,"video"); |
|
|
|
|
|
//Program.RunProgram.RunCpp("127.0.0.1",8888,4,1,false,true,false); |
|
|
|
|
|
//Program.RunProgram.RunGUIClient("127.0.0.1", 8888, 0, true); |
|
|
|
|
|
|
|
|
this.RaisePropertyChanged("UpdateBtnCont"); |
|
|
|
|
|
this.RaisePropertyChanged("LaunchBtnCont"); |
|
|
|
|
|
this.RaisePropertyChanged("Updateinfo"); |
|
|
|
|
|
this.RaisePropertyChanged("UpdatePlanned"); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
Route = Environment.GetEnvironmentVariable("USERPROFILE") + "\\THUAI6"; |
|
|
Route = Environment.GetEnvironmentVariable("USERPROFILE") + "\\THUAI6"; |
|
|
Status = SettingsModel.Status.newUser; |
|
|
Status = SettingsModel.Status.newUser; |
|
|
this.RaisePropertyChanged("WindowWidth"); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void AsyncInitializer_DoWork(object? sender, DoWorkEventArgs e) |
|
|
|
|
|
{ |
|
|
|
|
|
if (asyncInitializer.CancellationPending) |
|
|
|
|
|
{ |
|
|
|
|
|
Status = SettingsModel.Status.error; |
|
|
|
|
|
e.Cancel = true; |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
//实例化BackgroundWorker |
|
|
|
|
|
asyncDownloader = new BackgroundWorker(); |
|
|
|
|
|
asyncUpdater = new BackgroundWorker(); |
|
|
|
|
|
//指示BackgroundWorker是否可以报告进度更新 |
|
|
|
|
|
//当该属性值为True是,将可以成功调用ReportProgress方法,否则将引发InvalidOperationException异常。 |
|
|
|
|
|
asyncDownloader.WorkerReportsProgress = true; |
|
|
|
|
|
asyncUpdater.WorkerReportsProgress = true; |
|
|
|
|
|
//挂载方法: |
|
|
|
|
|
asyncDownloader.DoWork += AsyncDownloader_DoWork; |
|
|
|
|
|
asyncUpdater.DoWork += AsyncUpdater_DoWork; |
|
|
|
|
|
//完成通知器: |
|
|
|
|
|
asyncDownloader.RunWorkerCompleted += AsyncDownloader_RunWorkerCompleted; |
|
|
|
|
|
asyncUpdater.RunWorkerCompleted += AsyncUpdater_RunWorkerCompleted; |
|
|
|
|
|
|
|
|
|
|
|
if (Downloader.Program.Tencent_cos_download.CheckAlreadyDownload()) |
|
|
|
|
|
{ |
|
|
|
|
|
obj.checkUpdate(); |
|
|
|
|
|
|
|
|
|
|
|
if (obj.RecallUser()) |
|
|
|
|
|
RememberMe = true; |
|
|
|
|
|
else |
|
|
|
|
|
RememberMe = false; |
|
|
|
|
|
|
|
|
|
|
|
//在启动时立刻检查更新,确保选手启动最新版选手包 |
|
|
|
|
|
//若有更新,将启动键改为更新键; |
|
|
|
|
|
//相应地,使用login界面启动; |
|
|
|
|
|
//结构:上方为登录框架,下方有“修改选手包”按钮 |
|
|
|
|
|
|
|
|
|
|
|
//下面几行是用来运行测试的代码 |
|
|
|
|
|
//Program.RunProgram.StartServerForDebug("0.0.0.0",8888,4,1,600,"video"); |
|
|
|
|
|
//Program.RunProgram.RunCpp("127.0.0.1",8888,4,1,false,true,false); |
|
|
|
|
|
//Program.RunProgram.RunGUIClient("127.0.0.1", 8888, 0, true); |
|
|
|
|
|
|
|
|
|
|
|
e.Result = 1; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
e.Result = 2; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -153,6 +196,7 @@ namespace starter.viewmodel.settings |
|
|
this.RaisePropertyChanged("UpdateInfo"); |
|
|
this.RaisePropertyChanged("UpdateInfo"); |
|
|
this.RaisePropertyChanged("LaunchBtnCont"); |
|
|
this.RaisePropertyChanged("LaunchBtnCont"); |
|
|
} |
|
|
} |
|
|
|
|
|
this.RaisePropertyChanged("UpdatePlanned"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -257,6 +301,7 @@ namespace starter.viewmodel.settings |
|
|
this.RaisePropertyChanged("LaunchVis"); |
|
|
this.RaisePropertyChanged("LaunchVis"); |
|
|
this.RaisePropertyChanged("NewUserVis"); |
|
|
this.RaisePropertyChanged("NewUserVis"); |
|
|
this.RaisePropertyChanged("ConfirmBtnCont"); |
|
|
this.RaisePropertyChanged("ConfirmBtnCont"); |
|
|
|
|
|
this.RaisePropertyChanged("ProcessingIntro"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
public string Intro |
|
|
public string Intro |
|
|
@@ -298,6 +343,21 @@ namespace starter.viewmodel.settings |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
public string ProcessingIntro |
|
|
|
|
|
{ |
|
|
|
|
|
get |
|
|
|
|
|
{ |
|
|
|
|
|
switch (Status) |
|
|
|
|
|
{ |
|
|
|
|
|
case SettingsModel.Status.working: |
|
|
|
|
|
return "正在下载"; |
|
|
|
|
|
case SettingsModel.Status.initializing: |
|
|
|
|
|
return "正在检查更新"; |
|
|
|
|
|
default: |
|
|
|
|
|
return ""; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
public string AbortOrSelLanguage |
|
|
public string AbortOrSelLanguage |
|
|
{ |
|
|
{ |
|
|
get |
|
|
get |
|
|
@@ -453,7 +513,7 @@ namespace starter.viewmodel.settings |
|
|
{ |
|
|
{ |
|
|
get |
|
|
get |
|
|
{ |
|
|
{ |
|
|
return Status == SettingsModel.Status.working ? Visibility.Visible : Visibility.Collapsed; |
|
|
|
|
|
|
|
|
return (Status == SettingsModel.Status.working || Status == SettingsModel.Status.initializing) ? Visibility.Visible : Visibility.Collapsed; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
public Visibility CompleteVis |
|
|
public Visibility CompleteVis |
|
|
@@ -508,6 +568,13 @@ namespace starter.viewmodel.settings |
|
|
return obj.status == SettingsModel.Status.login && (!obj.UpdatePlanned) ? Visibility.Visible : Visibility.Collapsed; |
|
|
return obj.status == SettingsModel.Status.login && (!obj.UpdatePlanned) ? Visibility.Visible : Visibility.Collapsed; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
public Visibility CfgVis |
|
|
|
|
|
{ |
|
|
|
|
|
get |
|
|
|
|
|
{ |
|
|
|
|
|
return obj.status == SettingsModel.Status.launch ? Visibility.Visible : Visibility.Collapsed; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public string UpdateBtnCont |
|
|
public string UpdateBtnCont |
|
|
{ |
|
|
{ |
|
|
@@ -534,9 +601,9 @@ namespace starter.viewmodel.settings |
|
|
if (obj.UpdatePlanned) |
|
|
if (obj.UpdatePlanned) |
|
|
ans = "更新"; |
|
|
ans = "更新"; |
|
|
else if (obj.launchLanguage == SettingsModel.LaunchLanguage.cpp) |
|
|
else if (obj.launchLanguage == SettingsModel.LaunchLanguage.cpp) |
|
|
ans = "启动c++包"; |
|
|
|
|
|
|
|
|
ans = "启动选手包"; |
|
|
else |
|
|
else |
|
|
ans = "启动python包"; |
|
|
|
|
|
|
|
|
ans = "启动选手包"; |
|
|
return ans; |
|
|
return ans; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@@ -570,6 +637,11 @@ namespace starter.viewmodel.settings |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public bool UpdatePlanned |
|
|
|
|
|
{ |
|
|
|
|
|
get { return obj.UpdatePlanned; } |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public string RouteSelectWindow(string type) |
|
|
public string RouteSelectWindow(string type) |
|
|
{ |
|
|
{ |
|
|
if (type == "Folder") |
|
|
if (type == "Folder") |
|
|
@@ -719,6 +791,7 @@ namespace starter.viewmodel.settings |
|
|
this.RaisePropertyChanged("UpdateBtnCont"); |
|
|
this.RaisePropertyChanged("UpdateBtnCont"); |
|
|
this.RaisePropertyChanged("UpdateInfo"); |
|
|
this.RaisePropertyChanged("UpdateInfo"); |
|
|
this.RaisePropertyChanged("LaunchVis"); |
|
|
this.RaisePropertyChanged("LaunchVis"); |
|
|
|
|
|
this.RaisePropertyChanged("UpdatePlanned"); |
|
|
} |
|
|
} |
|
|
})); |
|
|
})); |
|
|
} |
|
|
} |
|
|
|