コード例 #1
0
ファイル: SuDokuMainForm.cs プロジェクト: mnandi/SuDokuGit
 private void buttonStartGame_Click(object sender, EventArgs e)
 {
     if (gameState == 0)                         //	0=not playing / 1=playing / -1-play stopped
     //	not playing - check game
     {
         int nerr = gameTable.CheckTable(true);
         if (nerr > 0)
         {
             string msgid   = chlang.GetLocalizedString("MB_msg_errtable");
             string msgtype = chlang.GetLocalizedString("MB_caption_err");
             MessageBox.Show(msgid, msgtype, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         //	not playing - start game
         buttonStartGame.Text                = "Játék leállítása";
         buttonClearGame.Text                = "Lépés törlése";
         buttonFillGame.Text                 = "Lejátszás törlése";
         buttonSaveGame.Text                 = "Megállítás";
         comboGameType.Enabled               =
             numericLevel.Enabled            =
                 comboGameName.Enabled       =
                     textGameComment.Enabled = false;
         buttonList = new List <int[]>();
         gameTable.ClearSelects();
         gameState = 1;
     }
     else
     {
         //	playing - stop game
         buttonStartGame.Text                = "--> Játék indítása";
         buttonClearGame.Text                = "Tábla törlése";
         buttonFillGame.Text                 = "Tábla kitöltése";
         buttonSaveGame.Text                 = "Játék mentése";
         comboGameType.Enabled               =
             numericLevel.Enabled            =
                 comboGameName.Enabled       =
                     textGameComment.Enabled = true;
         //	remove gamed cells
         int count = buttonList.Count;
         for (int ii = 0; ii < count; ii++)
         {
             gameTable.cell(buttonList[ii][0], buttonList[ii][1]).fixNum = 0;
         }
         pictureTable_Resize(null, null);
         gameState = 0;
     }
 }
コード例 #2
0
ファイル: SuDokuMainForm.cs プロジェクト: mnandi/SuDokuGit
        private int AnalyzeResult(solvetype type)
        {
            GameTable gameTableSave = gameTable.DeepClone(gameTable);
            sresult   sret          = SuSolve(type);
            //		-1	- no solution
            //		 0	- solved
            //		>0	- other solve error
            string msgid;
            string msgtype;

            switch (sret)
            {
            case sresult.SOLVE_FEWDATA:
                msgid   = chlang.GetLocalizedString("MB_msg_errfill");
                msgtype = chlang.GetLocalizedString("MB_caption_err");
                MessageBox.Show(msgid, msgtype, MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case sresult.SOLVE_IMPOSSIBLE:                      //		"Lehetetlen megoldás"
                msgid   = chlang.GetLocalizedString("MB_msg_NOresult");
                msgtype = chlang.GetLocalizedString("MB_caption_err");
                MessageBox.Show(msgid, msgtype, MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case sresult.SOLVE_CANCELLED:
                msgid   = chlang.GetLocalizedString("MB_msg_stopped");
                msgtype = chlang.GetLocalizedString("MB_caption_err");
                MessageBox.Show(msgid, msgtype, MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case sresult.SOLVE_OK:                                      //	-1	"Jó megoldás !"
                //	Returns:
                if (type == solvetype.MAKERESULT)
                {
                    pictureTable_Resize(null, null);
                    msgid   = chlang.GetLocalizedString("MB_msg_result");
                    msgtype = chlang.GetLocalizedString("MB_caption_result");
                }
                else
                {
                    msgid   = chlang.GetLocalizedString("MB_msg_solvable");
                    msgtype = chlang.GetLocalizedString("MB_caption_result");
                }
                MessageBox.Show(msgid, msgtype, MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;

            case sresult.SOLVE_NORESULT:                        //	 0	"Hiba, nincs megoldás"
                msgid   = chlang.GetLocalizedString("MB_msg_NOresult");
                msgtype = chlang.GetLocalizedString("MB_caption_err");
                MessageBox.Show(msgid, msgtype, MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case sresult.SOLVE_ONERESULT:                       //	1	"1 megoldás"
                msgid   = chlang.GetLocalizedString("MB_msg_1result");
                msgtype = chlang.GetLocalizedString("MB_caption_result");
                MessageBox.Show(msgid, msgtype, MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;

            case sresult.SOLVE_MORERESULT:                      //	>15	"Több megoldás"
                msgid   = string.Format(chlang.GetLocalizedString("MB_msg_MANYresult"), (int)sret);
                msgtype = chlang.GetLocalizedString("MB_caption_result");
                MessageBox.Show(msgid, msgtype, MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;

            default:                                                                    //	<15	"Több megoldás"
                msgid   = string.Format(chlang.GetLocalizedString("MB_msg_NBresult"), (int)sret);
                msgtype = chlang.GetLocalizedString("MB_caption_result");
                MessageBox.Show(msgid, msgtype, MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;
            }
            gameTable     = gameTableSave;
            gameTableSave = null;
            gameTable.ClearSelects();
            pictureTable_Resize(null, null);
            return((int)sret);
        }