示例#1
0
        private async void button_challenge(object sender, RoutedEventArgs e)
        {
            console_output("Generating your quest...");
            buttonchallenge.IsEnabled = false;
            button.IsEnabled          = false;
            string GUI = await ExpressionTranslate.GUIrandomChallenge(hard, GUIMethod, r);

            textBoxInput.Text = GUI;
            console_output("Quest generated!\r\n");
            buttonchallenge.IsEnabled = true;
            button.IsEnabled          = true;
            hard = (hard + 1) % 3;
        }
示例#2
0
 private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (console_mode)
     {
         BaseEquation be = new BaseEquation(textBox1.Text);
         GUIMethod         = be.method;
         textBoxInput.Text = ExpressionTranslate.get_GUI(be);
         if (textBoxInput.Text != "")
         {
             textBoxInputOld = textBoxInput.Text;
         }
     }
 }
示例#3
0
 public void setnow(object sender, ConsoleMazeMain.BaseEquationEventArgs beea)
 {
     if (beea.be.equation_console != "" && beea.is_ans == false)
     {
         textBoxOutput.Text = "First answer:\r\n" + ExpressionTranslate.get_GUI(new BaseEquation(beea.be.equation_console));
     }
     else
     {
         console_output("The first answer was found:");
         console_output(beea.be.equation_console);
         int milisec = (int)DateTime.Now.Subtract(t1).TotalMilliseconds;
         console_output("First Answer Elapsed Time:" + milisec.ToString() + "ms\r\n");
     }
 }
示例#4
0
 private void textBoxInput_TextChanged(object sender, TextChangedEventArgs e)
 {
     //TODO:检查输入太长或太高
     if (!console_mode)
     {
         //为乘法匹配行数
         if (GUIMethod == BaseEquation.METHOD.MUL)
         {
             mul_special();
         }
         if (human_changing)
         {
             int checkans = ExpressionTranslate.textGUI(textBoxInput.Text);
             if (checkans != 0)
             {
                 if (checkans == 2)
                 {
                     MessageBox.Show("GUI输入不合规范,已退回上一步\r\n请检查:\r\n某行太长,最长仅限" + ExpressionTranslate.LENTH_MAX + "字符,超长请使用控制台输入方式");
                 }
                 else if (checkans == 3)
                 {
                     MessageBox.Show("GUI输入不合规范,已退回上一步\r\n请检查:\r\n行数太多,最长仅限" + ExpressionTranslate.HEIGHT_MAX + "行,超高请使用控制台输入方式");
                 }
                 else
                 {
                     MessageBox.Show("GUI输入不合规范,已退回上一步\r\n请检查:\r\n数字和字母超过了10个\r\n插入了非法符\r\n删除了重要字符\r\n算式行数不对");
                 }
                 human_changing    = false;
                 textBoxInput.Text = textBoxInputOld;
                 human_changing    = true;
             }
         }
         BaseEquation be = ExpressionTranslate.get_console(textBoxInput.Text);
         if (be != null)
         {
             textBox1.Text = be.equation_console;
         }
         else
         {
             textBox1.Text = "";
         }
         textBoxInputOld = textBoxInput.Text;
     }
 }
示例#5
0
        private async void button_Click(object sender, RoutedEventArgs e)
        {
            button.IsEnabled = false;
            //textBox2.Text = "";
            //textBox2.AppendText(textBox1.Text + "\r\n");
            console_output("Searching...");
            t1 = DateTime.Now;
            ConsoleMazeMain cmm = new ConsoleMazeMain();

            cmm.callback += setnow;
            string ans = await cmm.get_result(textBox1.Text);

            int milisec = (int)DateTime.Now.Subtract(t1).TotalMilliseconds;

            string[] anss = ans.Split(new char[1] {
                '\r'
            });
            int ans_num = (ans == "answer not found\r\n" || ans == "Wrong input\r\n") ? 0 : (anss.Length - 1);

            console_output(ans + "Quest:\r\n" + textBox1.Text + "\r\n" + ans_num.ToString() + " answer(s) was(were) found.\r\n" + "Elapsed Time:" + milisec.ToString() + "ms\r\n");
            textBoxOutput.Text = "First answer:\r\n" + ExpressionTranslate.get_GUI(new BaseEquation(anss[0]));
            button.IsEnabled   = true;
        }