public void btnFavfileOutput(bool fType81 = true, bool SolSet = false, bool SolSet2 = false) { string LRecord; string fNameFav = "SDK_Favorite.txt"; var tokSrc = new CancellationTokenSource(); //procedures for suspension GNPXApp000.SlvMtdCList[0] = true; //use all methods UPuzzle pGP = GNPX_Eng.pGP; GNPX_Eng.AnMan.Set_CellFreeB(); GNPX_Eng.sudokAnalyzerAuto(tokSrc.Token); string prbMessage; int difLvl = GNPX_Eng.GetDifficultyLevel(out prbMessage); using (var fpW = new StreamWriter(fNameFav, true, Encoding.UTF8)){ if (fType81) { LRecord = ""; pGP.BDL.ForEach(q => { LRecord += Max(q.No, 0).ToString(); }); LRecord = LRecord.Replace("0", "."); LRecord += $" {(pGP.ID+1)} {pGP.DifLevel} \"{pGP.Name}\""; if (SolSet && SolSet2) { LRecord += $" \"{SetSolution(pGP,SolSet2:true,SolAll:true)}\""; //解を出力 } if (pGP.TimeStamp != null) { LRecord += $" \"{pGP.TimeStamp}\""; } } else { LRecord = $"{pGP.ID+1}, {GNPX_Eng.pGP.DifLevel} \"{pGP.Name}\", \"{prbMessage}\""; fpW.WriteLine(LRecord); for (int r = 0; r < 9; r++) { int n = pGP.BDL[r * 9 + 0].No; LRecord = n.ToString(); for (int c = 1; c < 9; c++) { n = pGP.BDL[r * 9 + c].No; LRecord += $", {n}"; } LRecord += "\r"; } } fpW.WriteLine(LRecord); } GNPXApp000.SlvMtdCList[0] = false;//use selected methods }
public void SDK_FileOutput(string fName, bool append, bool fType81, bool SolSort, bool SolSet, bool SolSet2) { if (SDKProbLst.Count == 0) { return; } SDK_Ctrl.MltProblem = 1; SDK_Ctrl.lvlLow = 0; SDK_Ctrl.lvlHgh = 999; string LRecord, solMessage = ""; GNPXApp000.SlvMtdCList[0] = true; //use all methods var tokSrc = new CancellationTokenSource(); //for suspension int m = 0; SDKProbLst.ForEach(p => p.ID = (m++)); //▼▼▼ToDo Make problem management class IEnumerable <UPuzzle> qry; if (SolSort) { qry = from p in SDKProbLst orderby p.DifLevel ascending select p; } else { qry = from p in SDKProbLst select p; } using (StreamWriter fpW = new StreamWriter(fName, append, Encoding.UTF8)){ foreach (var P in qry) { //===== Preparation ===== solMessage = ""; if (SolSet) { solMessage = SetSolution(GP: P, SolSet2: SolSet2, SolAll: SolSet); //output Solution UPuzzle GP, bool SolSet2, bool SolAll=false } if (fType81) { //Solution(tytpe:line) LRecord = ""; P.BDL.ForEach(q => { LRecord += Max(q.No, 0).ToString(); }); LRecord = LRecord.Replace("0", "."); LRecord += $" {(P.ID+1)} {P.DifLevel} \"{P.Name}\""; if (SolSet && SolSet2) { LRecord += $" \"{SetSolution(P,SolSet2:true,SolAll:true)}\""; //解出力 } if (pGP.TimeStamp != null) { LRecord += $" \"{pGP.TimeStamp}\""; } fpW.WriteLine(LRecord); } else //problem_name and Solution(tytpe:matrix) { LRecord = $"{(P.ID+1)}, {P.DifLevel}, \"{P.Name}\", {solMessage}"; fpW.WriteLine(LRecord); for (int r = 0; r < 9; r++) { int n = P.BDL[r * 9 + 0].No; if (!SolSet && n < 0) { n = 0; } LRecord = n.ToString(); for (int c = 1; c < 9; c++) { n = P.BDL[r * 9 + c].No; if (!SolSet && n < 0) { n = 0; } LRecord += ", " + n.ToString(); } fpW.WriteLine(LRecord); } } } } GNPXApp000.SlvMtdCList[0] = false; //restore method selection }