Ejemplo n.º 1
0
 /// <summary>
 /// 手动输入的答案合法则可以往下跳
 /// </summary>
 /// <param name="p"></param>
 /// <returns>CanExecute</returns>
 private bool tbMannualKeyDownCommandCanExrcute(ExCommandParameter p)
 {
     return string.IsNullOrEmpty(IsValid("MannualAnwser"));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 手动输入按下下方向键,跳到下一题
 /// </summary>
 /// <param name="p"></param>
 private void ExecutetbMannualPreviewKeyDownCommand(ExCommandParameter p)
 {
     KeyEventArgs e = p.EventArgs as KeyEventArgs;
     if (e.Key == Key.Down)
     {
         GetNextListBoxIndex();
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 手动输入按下Enter键跳到下一题
 /// </summary>
 /// <param name="p"></param>
 private void ExecutetbMannualKeyDownCommand(ExCommandParameter p)
 {
     KeyEventArgs e = p.EventArgs as KeyEventArgs;
     if (e.Key == Key.Enter && !string.IsNullOrEmpty(MannualAnwser))
     {
         if (QuestionInfo.QuestionTypeID != 1)
         {
             //bool isNumberExist = false;//检测输入的答案选项是否存在
             foreach (Control c in Controls)
             {
                 if (c is RadioButton)
                 {
                     RadioButton rbtn = c as RadioButton;
                     if (rbtn.Name == string.Format("rbtn{0}", MannualAnwser.ToString()))
                     {
                         rbtn.IsChecked = true;
                         //isNumberExist = true;
                     }
                 }
             }
             //if (!isNumberExist)
             //{
             //    Status.Instance.ShowStatus(string.Format("第{0}个选项不存在", MannualAnwser));
             //}
         }
         else
         {
             string[] values = this.MannualAnwser.Split('.');
             if (values.Length == 1)//全数字,无“.”分隔
             {
                 char[] charNumbers = MannualAnwser.ToCharArray();
                 foreach (Control c in Controls)
                 {
                     if (c is CheckBox)
                     {
                         CheckBox cb = c as CheckBox;
                         foreach (char ch in charNumbers)
                         {
                             if (cb.Name == string.Format("cb{0}", ch.ToString()))
                             {
                                 cb.IsChecked = true;
                             }
                         }
                     }
                 }
             }
             else
             {
                 for (int i = 0; i < values.Length; i++)
                 {
                     foreach (Control c in Controls)
                     {
                         if (c is CheckBox)
                         {
                             CheckBox cb = c as CheckBox;
                             if (cb.Name == string.Format("cb{0}", values[i]))
                             {
                                 cb.IsChecked = true;
                             }
                         }
                     }
                 }
             }
         }
         if ((QuestionInfo.QuestionTypeID == 0 || QuestionInfo.QuestionTypeID == 1) && QuestionInfo.OtherOption)
         {
             foreach (Control c in Controls)
             {
                 if (c is TextBox)
                 {
                     TextBox tb = c as TextBox;
                     Keyboard.Focus(tb);
                     tb.SelectAll();
                 }
             }
         }
         else if (QuestionInfo.QuestionTypeID == 2 || QuestionInfo.QuestionTypeID == 3 || ((QuestionInfo.QuestionTypeID == 0 || QuestionInfo.QuestionTypeID == 1) && !QuestionInfo.OtherOption))
         {
             GetNextListBoxIndex();
         }
     }
     if (e.Key == Key.Enter && string.IsNullOrEmpty(MannualAnwser))
     {
         if ((QuestionInfo.QuestionTypeID == 0 || QuestionInfo.QuestionTypeID == 1) && QuestionInfo.OtherOption)
         {
             foreach (Control c in Controls)
             {
                 if (c is TextBox)
                 {
                     TextBox tb = c as TextBox;
                     Keyboard.Focus(tb);
                     tb.SelectAll();
                 }
             }
         }
         else if (QuestionInfo.QuestionTypeID == 2 || QuestionInfo.QuestionTypeID == 3 || ((QuestionInfo.QuestionTypeID == 0 || QuestionInfo.QuestionTypeID == 1) && !QuestionInfo.OtherOption))
         {
             GetNextListBoxIndex();
         }
     }
 }