Browse Source

fix(installer): 🚨 remove warnings of installer

tags/v0.1.0
Timothy Liu 3 years ago
parent
commit
28283f9eb2
2 changed files with 33 additions and 22 deletions
  1. +18
    -17
      installer/Installer/Model.cs
  2. +15
    -5
      installer/Installer/ViewModel.cs

+ 18
- 17
installer/Installer/Model.cs View File

@@ -835,7 +835,7 @@ namespace Downloader
private static void Download()
{
Tencent_cos_download Downloader = new Tencent_cos_download();
int newFile = 0, updateFile = 0;
int newFile = 0;
int totalnew = newFileName.Count, totalupdate = updateFileName.Count;
filenum = totalnew + totalupdate;
updateFailed.Clear();
@@ -1573,24 +1573,25 @@ namespace Downloader
ServerDebugAndPythonVisit,
}

// !!! 目前此类的各个静态成员从未被赋值过
public class RunInfo //UI需要在调用Launch函数前保证其中数据已经更新并有效
{
static public RunMode mode;
static public string? IP;
static public int port;
static public int studentCount;
static public int trickerCount;
static public int gameTimeSec;
static public string? playbackFileName;
static public int characterID;
static public int type;
static public bool saveDebugLog;
static public bool showDebugLog;
static public bool warningOnly;
static public bool visiting;
static public int occupation;
static public List<int>? playerId = new List<int>(); //两者长度必须与studentCount + trickerCount一致
static public List<string>? filePath = new List<string>();
public static RunMode mode = default;
public static string? IP = null;
public static int port = 0;
public static int studentCount = 0;
public static int trickerCount = 0;
public static int gameTimeSec = 0;
public static string? playbackFileName = null;
public static int characterID = 0;
public static int type = 0;
public static bool saveDebugLog = false;
public static bool showDebugLog = false;
public static bool warningOnly = false;
public static bool visiting = false;
public static int occupation = 0;
public static List<int>? playerId = new List<int>(); //两者长度必须与studentCount + trickerCount一致
public static List<string>? filePath = new List<string>();
}

/// <summary>


+ 15
- 5
installer/Installer/ViewModel.cs View File

@@ -20,8 +20,8 @@ namespace starter.viewmodel.settings
public class SettingsViewModel : NotificationObject
{
//定义BackgroundWorker
BackgroundWorker asyncDownloader;
BackgroundWorker asyncUpdater;
BackgroundWorker? asyncDownloader;
BackgroundWorker? asyncUpdater;
BackgroundWorker asyncInitializer;
/// <summary>
/// Model object
@@ -202,6 +202,11 @@ namespace starter.viewmodel.settings

private void AsyncUpdater_DoWork(object? sender, DoWorkEventArgs e)
{
if (asyncUpdater is null)
{
throw new InvalidOperationException("asyncUpdater is null");
}

if (asyncUpdater.CancellationPending)
{
e.Cancel = true;
@@ -230,6 +235,11 @@ namespace starter.viewmodel.settings

private void AsyncDownloader_DoWork(object? sender, DoWorkEventArgs e)
{
if (asyncDownloader is null)
{
throw new InvalidOperationException("asyncDownloader is null");
}

if (asyncDownloader.CancellationPending)
{
e.Cancel = true;
@@ -710,7 +720,7 @@ namespace starter.viewmodel.settings
{
Status = SettingsModel.Status.successful;
}*/
if (asyncDownloader.IsBusy)
if (asyncDownloader?.IsBusy ?? true)
return;
else
{
@@ -776,7 +786,7 @@ namespace starter.viewmodel.settings
}
else
Status = SettingsModel.Status.error;*/
if (asyncUpdater.IsBusy)
if (asyncUpdater?.IsBusy ?? true)
return;
else
asyncUpdater.RunWorkerAsync("Manual");
@@ -905,7 +915,7 @@ namespace starter.viewmodel.settings
{
Status = SettingsModel.Status.working;
this.RaisePropertyChanged("ProgressVis");
if (asyncUpdater.IsBusy)
if (asyncUpdater?.IsBusy ?? true)
return;
else
asyncUpdater.RunWorkerAsync("Auto");


Loading…
Cancel
Save