private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (_CurrentBackgroundInstance == null) { return; } Console.SetOut(_ConsoleText); switch (_CurrentBackgroundInstance.Mode) { case BackgroundWorkerMode.ProjectLoading: LoadConfigCompleted(); break; case BackgroundWorkerMode.BuildProject: break; case BackgroundWorkerMode.SendToSD: break; } _CurrentBackgroundInstance = null; menuStrip.Enabled = true; treeView.Enabled = true; }
private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorkerInstance bw = e.Argument as BackgroundWorkerInstance; if (bw == null) { return; } Console.SetOut(_ConsoleProgress); _CurrentBackgroundInstance = bw; switch (bw.Mode) { case BackgroundWorkerMode.ProjectLoading: LoadConfig(); break; case BackgroundWorkerMode.BuildProject: string exportedFolder = _ProjectManager.RebuildRFAndPatchlist((bool)bw.Object); string sdCardPath = _ProjectManager.GetSDFolder(); if (exportedFolder != string.Empty && !string.IsNullOrEmpty(sdCardPath)) { string wsName = GetWorkspaceName(exportedFolder); if (wsName == null) { string defaultName = PathHelper.FolderWorkplace.TrimEnd(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }) .Split(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }) .Last(); using (ModpackName box = new ModpackName(defaultName)) { if (box.ShowDialog() == DialogResult.OK) { _ProjectManager.SendToSD(exportedFolder, box._ModpackName); } } } else if (MessageBox.Show($"Do you want to copy your newly built modpack to your SD card or USB?\nModpack name: {wsName}", UIStrings.CAPTION_PACK_REBUILD, MessageBoxButtons.YesNo) == DialogResult.Yes) { _ProjectManager.SendToSD(exportedFolder, wsName); } } break; case BackgroundWorkerMode.SendToSD: string workspaceName = GetWorkspaceName((string)bw.Object); if (workspaceName == null) { string defaultName = PathHelper.FolderWorkplace.TrimEnd(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }) .Split(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }) .Last(); using (ModpackName box = new ModpackName(defaultName)) { if (box.ShowDialog() == DialogResult.OK) { _ProjectManager.SendToSD((string)bw.Object, box._ModpackName); } } } else { _ProjectManager.SendToSD((string)bw.Object, workspaceName); } break; } }