public Tasker.Conclusion ShowFoldersManager(Tasker tasker, Object syncObject = null) { if (tasker.HostForm.Disposing) { return(Tasker.Conclusion.Undefined); } if (tasker.HostForm.InvokeRequired) { return((Tasker.Conclusion)tasker.HostForm.Invoke(new Func <Tasker, Object, Tasker.Conclusion>(ShowFoldersManager), new object[] { tasker, syncObject })); } tasker.SetStatus(Resources.RunningFoldersManager); try { using (FoldersManagerForm form = new FoldersManagerForm(Games, MainForm.StaticRef)) { tasker.PushState(Tasker.State.Paused); var result = form.ShowDialog() == DialogResult.OK ? Tasker.Conclusion.Success : Tasker.Conclusion.Abort; tasker.PopState(); return(result); } } catch (InvalidOperationException) { } return(Tasker.Conclusion.Abort); }
public override void Execute() { ReportStatus("Importing all selected games in library"); IOrderedEnumerable <NesMiniApplication> selectedGames = Manager.GameManager.GetInstance().getSelectedGames(); int processed = 0; NesMenuCollection nmc = new NesMenuCollection(); foreach (NesMiniApplication mn in selectedGames) { nmc.Add(mn); string localRom = System.IO.Path.Combine(mn.GamePath, mn.RomFile); if (!System.IO.Directory.Exists(TempRomFolder)) { System.IO.Directory.CreateDirectory(TempRomFolder); } string gameName = mn.Name; string fileName = System.IO.Path.GetFileNameWithoutExtension(mn.RomFile); string ext = System.IO.Path.GetExtension(mn.RomFile); string destRom = System.IO.Path.Combine(TempRomFolder, MakeValidFileName(gameName + ext)); if (mn.RomFile.Trim() != "") { System.IO.File.Copy(localRom, destRom); _AppToRom[mn] = Manager.RomManager.getInstance().AddRom(destRom); System.IO.File.Delete(destRom); } string coverExt = System.IO.Path.GetExtension(mn.IconPath); string destIcon = System.IO.Path.Combine(TempRomFolder, MakeValidFileName(gameName + coverExt)); if (System.IO.File.Exists(mn.IconPath)) { if (System.IO.File.Exists(destIcon)) { System.IO.File.Delete(destIcon); } System.IO.File.Copy(mn.IconPath, destIcon); _AppToCover[mn] = Manager.CoverManager.getInstance().AddCover(destIcon); System.IO.File.Delete(destIcon); } else { } processed++; ReportProgress(processed * 100 / selectedGames.Count()); Console.Write(mn.RomFile); } ReportStatus("Loading folder structure"); ReportProgress(0); if (ConfigIni.FoldersMode != NesMenuCollection.SplitStyle.Custom) { nmc.Split(ConfigIni.FoldersMode, ConfigIni.MaxGamesPerFolder); } else { FoldersManagerForm fm = new FoldersManagerForm(nmc, true); nmc.AddBack(); } Manager.BookManager.Book theBook = Manager.BookManager.getInstance().GetBookByName("HakchiImport"); theBook.Pages.Clear(); Manager.BookManager.Page rootPage = theBook.AddPage("0"); ReportStatus("Creating pages"); AddMenu(nmc, rootPage, theBook); ReportCompleted(); }