Ejemplo n.º 1
0
 void SetState(TextEditMode mode) {
     if (currentMode == mode) return;
     switch (mode) {
         case TextEditMode.EditText:
             pnTitle.Visible = true;
             richEdit.ReadOnly = false;
             paragraphBar.Visible = true;
             fontBar.Visible = true;
             pnSaveChanges.Visible = true;
             pnQuestion.Visible = false;
             break;
         case TextEditMode.EditTest:
             UpdateTestPieces();
             pnTitle.Visible = false;
             richEdit.ReadOnly = true;
             paragraphBar.Visible = false;
             fontBar.Visible = false;
             pnSaveChanges.Visible = true;
             pnQuestion.Visible = true;
             break;
         default:
             currentTest = null;
             currentPieces = null;
             UpdateTestPieces();
             pnTitle.Visible = false;
             richEdit.ReadOnly = true;
             paragraphBar.Visible = false;
             fontBar.Visible = false;
             pnSaveChanges.Visible = false;
             pnQuestion.Visible = false;
             break;
     }
     currentMode = mode;
 }
Ejemplo n.º 2
0
 private void sbEditTest_Click(object sender, EventArgs e) {
     if (lbTests.SelectedItem == null) return;
     GramTest selectedTest = (GramTest)lbTests.SelectedItem;
     if (currentTest == selectedTest) {
         return;
     }
     if (currentMode == TextEditMode.EditTest) {
         SetState(TextEditMode.Main);
     }
     currentTest = selectedTest;
     currentPieces = selectedTest.Pieces == null ? new List<TextPiece>() : new List<TextPiece>(selectedTest.Pieces);
     teTestTitle.Text = selectedTest.Title;
     edQuestion.Text = selectedTest.Question;
     edPromt.Text = selectedTest.Promt;
     SetState(TextEditMode.EditTest);
 }
Ejemplo n.º 3
0
 private void sbNewTest_Click(object sender, EventArgs e) {
     GramTest newTest = new GramTest(uow);
     object maxNum = gramText.Evaluate(CriteriaOperator.Parse("[Tests].Max(Num)"));
     newTest.Num = maxNum == null ? 1 : ((int)maxNum) + 1;
     gramText.Tests.Add(newTest);
     if (currentMode == TextEditMode.EditTest) {
         SetState(TextEditMode.Main);
     }
     currentTest = newTest;
     currentPieces = newTest.Pieces == null ? new List<TextPiece>() : new List<TextPiece>(newTest.Pieces);
     teTestTitle.Text = newTest.Title;
     edQuestion.Text = newTest.Question;
     edPromt.Text = newTest.Promt;
     SetState(TextEditMode.EditTest);
 }