private RenderTargetBitmap bmpPD = new RenderTargetBitmap(176, 176, 96, 96, PixelFormats.Default);//176=18*9+2*4+1*6 private void _Display_CreateProblem() { txbNoOfTrials.Text = GNP00.SDKCntrl.LoopCC.ToString(); txbNoOfTrialsCum.Text = SDK_Ctrl.TLoopCC.ToString(); txbBasicPattern.Text = GNP00.SDKCntrl.PatternCC.ToString(); int n = gamGen05.Text.ToInt(); lblNoOfProblems1.Content = (n - _ProgressPer).ToString(); UPuzzle pGP = GNP00.pGP; if (pGP != null) { int nn = GNP00.SDKProbLst.Count; if (nn > 0) { txtProbNo.Text = nn.ToString(); txtProbName.Text = GNP00.SDKProbLst.Last().Name; nUDDifficultyLevel.Text = pGP.DifLevel.ToString(); } } string st = AnalyzerLapElaped; Lbl_onAnalyzerTS.Content = st; Lbl_onAnalyzerTSM.Content = st; txbEpapsedTimeTS3.Text = st; if (__DispMode != null && __DispMode != "") { _SetScreenProblem(); displayTimer.Stop(); AnalyzerLap.Stop(); btnCreateProblemMlt.Content = pRes.btnCreateProblemMlt; } __DispMode = ""; if ((bool)chbCreateProblemEx2.IsChecked) { SDKGrp.GBPatternDigit(bmpPD, Sol99sta); } else { bmpPD.Clear(); } PB_BasePatDig.Source = bmpPD; }
private void _Display_AnalyzeProb() { //WriteLine("----------------"+__DispMode); if (__DispMode == "Canceled") { shortMessage("cancellation accepted", new sysWin.Point(120, 188), Colors.Red, 3000); lblUnderAnalysis.Foreground = Brushes.LightCoral; Lbl_onAnalyzerM.Foreground = Brushes.LightCoral; displayTimer.Stop(); } else if (__DispMode == "Complated") { lblUnderAnalysis.Content = pRes.msgAnalysisComplate; if ((string)SDK_Ctrl.MltAnsOption["abortResult"] != "") { Lbl_onAnalyzerM.Content = SDK_Ctrl.MltAnsOption["abortResult"]; } else { Lbl_onAnalyzerM.Content = pRes.msgAnalysisComplate; Lbl_onAnalyzerM.Foreground = Brushes.LightBlue; if ((bool)chbDifficultySetting.IsChecked) { string prbMessage; int DifLevel = GNP00.GNPX_Eng.GetDifficultyLevel(out prbMessage); pGP.DifLevel = DifLevel; } } btnSolve.Content = pRes.btnSolve; btnMultiSolve.Content = pRes.btnMultiSolve; btnMultiSolve.IsEnabled = true; lblUnderAnalysis.Foreground = Brushes.LightBlue; _Set_DGViewMethodCounter(); //Aggregation of methods string msgST = pGP.Sol_ResultLong; if (!ErrorStopB) { lblAnalyzerResult.Text = msgST; } if (msgST.LastIndexOf("anti-rule") >= 0 || msgST.LastIndexOf("Unparsable") >= 0) { } displayTimer.Stop(); } else { if (!ErrorStopB) { lblAnalyzerResult.Text = GNPZ_Engin.GNPX_AnalyzerMessage; } Lbl_onAnalyzerM.Content = pRes.lblUnderAnalysis + " : " + GNPZ_Engin.GNPX_AnalyzerMessage; } if (UPP != null && UPP.Count > 0) { try{ if (__DispMode == "Complated") { LstBxMltAns.ItemsSource = null; } LstBxMltAns.ItemsSource = UPP; if (__DispMode == "Complated") { LstBxMltAns.ScrollIntoView(UPP.First()); selXUPP = 0; AnalyzerLap.Stop(); } else { LstBxMltAns.ScrollIntoView(UPP.Last()); selXUPP = UPP.Count - 1; } LstBxMltAns.SelectedIndex = selXUPP; var Q = (UProbS)LstBxMltAns.SelectedItem; if (Q == null) { Q = UPP[0]; } lblAnalyzerResultM.Text = "[" + (Q.IDmp1) + "] " + Q.Sol_ResultLong; } catch (Exception e) { WriteLine(e.Message); WriteLine(e.StackTrace); } } string st = AnalyzerLapElaped; Lbl_onAnalyzerTS.Content = st; Lbl_onAnalyzerTSM.Content = st; txbEpapsedTimeTS3.Text = st; btnSolveUp.Content = pRes.btnSolveUp; if (GNPZ_Engin.GNPX_AnalyzerMessage.Contains("sys")) { lblAnalyzerResultM.Text = GNPZ_Engin.GNPX_AnalyzerMessage; } this.Cursor = Cursors.Arrow; if (__DispMode == "Complated") { _SetScreenProblem(); } OnWork = 0; // __DispMode=""; }
private void btnSDKAnalyzerAuto_Click(object sender, RoutedEventArgs e) { if (OnWork == 1) { return; } GNP00.AnalyzerMode = "SolveUp"; GNP00.GNPX_Eng.MethodLst_Run.ForEach(P => P.UsedCC = 0); if ((string)btnSolveUp.Content == pRes.msgSuspend) { tokSrc.Cancel(); try{ taskSDK.Wait(); } catch (AggregateException) { __DispMode = "Canceled"; } displayTimer.Start(); OnWork = 0; } else { List <UCell> pBDL = pGP.BDL; if (pBDL.Count(p => p.No == 0) == 0) //complate { _SetScreenProblem(); goto AnalyzerEnd; } if (pBDL.Any(p => (p.No == 0 && p.FreeB == 0))) //No Solution { lblAnalyzerResult.Text = pRes.msgNoSolution; goto AnalyzerEnd; } OnWork = 2; btnSolveUp.Content = null; btnSolveUp.Content = pRes.msgSuspend; lblUnderAnalysis.Content = pRes.lblUnderAnalysis; lblUnderAnalysis.Foreground = Brushes.Orange; int mc = GNP00.GNPX_Eng.Set_MethodLst_Run( ); if (mc <= 0) { GNP00.ResetMethodList(); } _ResetAnalizer(true); //Clear Analysis Result GNP00.GNPX_Eng.AnalyzerCounterReset(); GNPZ_Engin.SolInfoB = false; SDK_Ctrl.lvlLow = 0; SDK_Ctrl.lvlHgh = 999; //============================================================== tokSrc = new CancellationTokenSource(); CancellationToken ct = tokSrc.Token; taskSDK = new Task(() => GNP00.SDKCntrl.AnalyzerRealAuto(ct), ct); taskSDK.ContinueWith(t => task_SDKsolverAuto_Completed()); AnalyzerLap.Reset(); taskSDK.Start(); //-------------------------------------------------------------- this.Cursor = Cursors.Wait; AnalyzerLap.Start(); __DispMode = ""; AnalyzerEnd: displayTimer.Start(); return; } }
private void SuDoKuSolver() { try{ lblUnderAnalysis.Foreground = Brushes.LightGreen; Lbl_onAnalyzerM.Foreground = Brushes.LightGreen; if ((string)btnSolve.Content != pRes.msgSuspend) { int mc = GNP00.GNPX_Eng.Set_MethodLst_Run( ); if (mc <= 0) { GNP00.ResetMethodList(); } lblUnderAnalysis.Visibility = Visibility.Visible; Lbl_onAnalyzerM.Visibility = Visibility.Visible; //GNPZ_Engin.SolInfoB = false; if (GNP00.SDKCntrl.retNZ == 0) { GNP00.SDKCntrl.LoopCC = 0; } SDK_Ctrl.MltProblem = 1; //single SDK_Ctrl.lvlLow = 0; SDK_Ctrl.lvlHgh = 999; GNP00.SDKCntrl.CbxDspNumRandmize = false; GNP00.SDKCntrl.GenLStyp = 1; GNPXApp000.chbConfirmMultipleCells = (bool)chbConfirmMultipleCells.IsChecked; GNPZ_Engin.SolInfoB = true; AnalyzerLap.Reset(); if (GNP00.AnalyzerMode == "Solve" || GNP00.AnalyzerMode == "MultiSolve") { if (GNP00.pGP.SolCode < 0) { GNP00.pGP.SolCode = 0; } ErrorStopB = !_cellFixSub(); List <UCell> pBDL = pGP.BDL; if (pBDL.Count(p => p.No == 0) == 0) //analysis completed { _SetScreenProblem(); goto AnalyzerEnd; } OnWork = 1; txbStepCC.Text = (++AnalyzerCC).ToString(); btnSolve.Content = pRes.msgSuspend; lblUnderAnalysis.Content = pRes.lblUnderAnalysis; txbStepMCC.Text = txbStepCC.Text; btnMultiSolve.Content = btnSolve.Content; Lbl_onAnalyzerM.Content = lblUnderAnalysis.Content; lblUnderAnalysis.Foreground = Brushes.Orange; Lbl_onAnalyzerM.Foreground = Brushes.Orange; Lbl_onAnalyzerTS.Content = ""; Lbl_onAnalyzerTSM.Content = ""; this.Cursor = Cursors.Wait; if (!ErrorStopB) { __DispMode = ""; AnalyzerLap.Start(); //============================================================== tokSrc = new CancellationTokenSource(); //for Cancellation taskSDK = new Task(() => GNP00.SDKCntrl.AnalyzerReal(tokSrc.Token), tokSrc.Token); taskSDK.ContinueWith(t => task_SDKsolver_Completed()); //procedures used on completion taskSDK.Start(); } else { __DispMode = "Complated"; } if (GNP00.AnalyzerMode != "MultiSolve") { displayTimer.Start(); // <- To avoid unresolved operation trouble. } // displayTimer.Start(); //-------------------------------------------------------------- } else { try{ tokSrc.Cancel(); taskSDK.Wait(); btnSolve.Content = pRes.btnSolve; } catch (AggregateException e2) { WriteLine(e2.Message); __DispMode = "Canceled"; } } AnalyzerEnd: return; } } catch (Exception ex) { WriteLine(ex.Message); WriteLine(ex.StackTrace); } }
private void btnP13Start_Click(object sender, RoutedEventArgs e) { btnAnalyzerResetAll_Click(this, e); //SDK_Ctrl.UGPMan=null; //Terminate task. Included in the above processing #if !DEBUG int GL = GNPXApp000.GMthdOption["GeneralLogicOn"].ToInt(); if (GL > 0) { shortMessage("GeneralLogic is unenable.", new sysWin.Point(450, 150), Colors.Red, 3000); return; } #endif if ((string)btnCreateProblemMlt.Content == pRes.btnCreateProblemMlt) { __DispMode = null; GNP00.SDKCntrl.LoopCC = 0; btnCreateProblemMlt.Content = pRes.msgSuspend; // GNPZ_Engin.SolInfoB = false; if (GNP00.SDKCntrl.retNZ == 0) { GNP00.SDKCntrl.LoopCC = 0; } GNP00.SDKCntrl.CbxDspNumRandmize = (bool)chbRandomizingNumbers.IsChecked; GNP00.SDKCntrl.GenLStyp = int.Parse(GenLStyp.Text); GNP00.SDKCntrl.CbxNextLSpattern = (bool)chbChangeBasicPattenOnSuccess.IsChecked; //if((bool)chbCreateProblemEx2.IsChecked && (int)gamGen02.Value>5){ gamGen02.Value=5; } SDK_Ctrl.lvlLow = (int)gamGen01.Value; SDK_Ctrl.lvlHgh = (int)gamGen02.Value; SDK_Ctrl.FilePut_GenPrb = false; //(bool)chbFileOutputOnSuccess.IsChecked; int n = gamGen05.Text.ToInt(); n = Max(Min(n, 100000000), 0); SDK_Ctrl.MltProblem = _ProgressPer = n; SDK_Ctrl.GenLS_turbo = (bool)GenLS_turbo.IsChecked; displayTimer.Start(); AnalyzerLap.Start(); //============================================================================================== 20181031 AnalyzerBaseV2.__SimpleAnalizerB__ = true; //(bool)chbCreateProblemEx2.IsChecked; tokSrc = new CancellationTokenSource(); //procedures for suspension taskSDK = new Task(() => GNP00.SDKCntrl.SDK_ProblemMakerReal(tokSrc.Token), tokSrc.Token); taskSDK.ContinueWith(t => btnP13Start2Complated()); //Completion process taskSDK.Start(); //---------------------------------------------------------------------------------------------- 20181031 } else //"Suspend" { try{ AnalyzerBaseV2.__SimpleAnalizerB__ = false; chbCreateProblemEx2.IsEnabled = true; shortMessage("cancellation accepted", new sysWin.Point(120, 188), Colors.Red, 2000); tokSrc.Cancel(); GNP00.CurrentPrbNo = 999999999; _SetScreenProblem( ); btnCreateProblemMlt.Content = pRes.btnCreateProblemMlt; } catch (AggregateException) { __DispMode = "Canceled"; } } return; }