/// <summary> /// Handles the CardStateChanged event of the learnlogic control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="MLifter.BusinessLayer.CardStateChangedEventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev02, 2008-04-24</remarks> void learnlogic_CardStateChanged(object sender, CardStateChangedEventArgs e) { if (e is CardStateChangedNewCardEventArgs || (e is CardStateChangedShowResultEventArgs && ((CardStateChangedShowResultEventArgs)e).slideshow)) { Text = String.Format(Resources.STATUSBAR_CURRENTCHAPTER, e.dictionary.Cards.GetChapterName(e.cardid)); } else if (e is CardStateChangedShowResultEventArgs) { if (e.dictionary.Settings.SelfAssessment.Value) { Text = Resources.STATUSBAR_SELFASSESSMENT; } else { CardStateChangedShowResultEventArgs args = (CardStateChangedShowResultEventArgs)e; AnswerResult result = args.promoted ? AnswerResult.Correct : (args.result == AnswerResult.Almost ? AnswerResult.Almost : AnswerResult.Wrong); switch (result) { case AnswerResult.Correct: Text = Resources.STATUSBAR_RESPONSE_CORRECT; break; case AnswerResult.Wrong: Text = Resources.STATUSBAR_RESPONSE_INCORRECT; break; case AnswerResult.Almost: Text = Resources.STATUSBAR_RESPONSE_ALMOST; break; } } } }
/// <summary> /// Sets the button focus. /// </summary> /// <param name="e">The <see cref="MLifter.BusinessLayer.CardStateChangedEventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev02, 2009-05-07</remarks> public void SetButtonFocus(CardStateChangedEventArgs e) { if (e is CardStateChangedShowResultEventArgs) { CardStateChangedShowResultEventArgs args = (CardStateChangedShowResultEventArgs)e; if (args.slideshow) { FocusSlideshowButton(); } else { if (e.dictionary.Settings.SelfAssessment.Value) { if (args.result == AnswerResult.Correct) { SelfAssesmentFocusDoKnow(); } else { SelfAssesmentFocusDontKnow(); } } else { FocusSlideshowButton(); } } } }
/// <summary> /// Handles the CardStateChanged event of the learnlogic control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="MLifter.BusinessLayer.CardStateChangedEventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev07, 2009-04-14</remarks> void learnlogic_CardStateChanged(object sender, CardStateChangedEventArgs e) { if (e is CardStateChangedCountdownTimerEventArgs) { } else { DisableButtons(); //-- Hide / show selfAssesment buttons if (e.dictionary.Settings.SelfAssessment.Value) { ButtonSelfAssesmentVisible(true); } else { ButtonSelfAssesmentVisible(false); } //-- Enable Buttons depending on card status if (e is CardStateChangedNewCardEventArgs) { if (learnlogic.SlideShow) { ButtonSlideShow(true); } else { ButtonQuestion(true); } } if (e is CardStateChangedShowResultEventArgs) { //this should correspond properly to SetButtonFocus(CardStateChangedEventArgs e) CardStateChangedShowResultEventArgs args = (CardStateChangedShowResultEventArgs)e; if (args.slideshow) { ButtonSlideShow(true); } else { if (e.dictionary.Settings.SelfAssessment.Value) { ButtonSelfAssesment(true); } else { ButtonNext(true); } } } } }
/// <summary> /// Handles the CardStateChanged event of the learnlogic control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="MLifter.BusinessLayer.CardStateChangedEventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev02, 2008-04-24</remarks> void learnlogic_CardStateChanged(object sender, CardStateChangedEventArgs e) { if (e.dictionary.Settings.AutoplayAudio.Value) { bool example = (e as CardStateChangedEventArgs).dictionary.LearnMode == MLifter.BusinessLayer.LearnModes.Sentence; if (e is CardStateChangedNewCardEventArgs || (e is CardStateChangedShowResultEventArgs && ((CardStateChangedShowResultEventArgs)e).slideshow)) { if (e is CardStateChangedShowResultEventArgs && ((CardStateChangedShowResultEventArgs)e).preview) { return; } // [ML-1747] if (e.dictionary.LearnMode == MLifter.BusinessLayer.LearnModes.ImageRecognition) { return; } //play question side sound PlayMediaFile(e.dictionary.Cards.GetAudioFile(e.cardid, Side.Question, example), true); } if (e is CardStateChangedShowResultEventArgs) { CardStateChangedShowResultEventArgs args = (CardStateChangedShowResultEventArgs)e; if (args.preview) { return; } //play answer side sound and commentary sounds AnswerResult result = args.promoted ? AnswerResult.Correct : (args.result == AnswerResult.Almost ? AnswerResult.Almost : AnswerResult.Wrong); if (FileValid(args.dictionary.Cards.GetAudioFile(args.cardid, Side.Answer, example))) { if (result != AnswerResult.Correct) { PlayCommentarySound(args.dictionary, result, false); //not correct commentary sound is to be played before the cardaudio } PlayMediaFile(args.dictionary.Cards.GetAudioFile(args.cardid, Side.Answer, example), false); if (result == AnswerResult.Correct) { PlayCommentarySound(args.dictionary, result, false); //correct commentary sound is to be played after the cardaudio } } else //play the standalone commentary sounds only if the card sound is not available { PlayCommentarySound(args.dictionary, result, true); } } } }
/// <summary> /// Handles the CardStateChanged event of the learnlogic control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="MLifter.BusinessLayer.CardStateChangedEventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev02, 2008-04-23</remarks> void learnlogic_CardStateChanged(object sender, CardStateChangedEventArgs e) { Card card = e.dictionary.Cards.GetCardByID(e.cardid); //prepare title labels for either a new card, or the result in slideshow mode if (e is CardStateChangedNewCardEventArgs || (e is CardStateChangedShowResultEventArgs && ((CardStateChangedShowResultEventArgs)e).slideshow)) { string title = card != null ? card.CurrentAnswerCaption : string.Empty; if ((this.learnlogic == null) || (this.learnlogic.SlideShow == false)) { switch (e.dictionary.LearnMode) { case BusinessLayer.LearnModes.MultipleChoice: title = String.Format(Resources.MAINFORM_LBLANSWER_MULTI_TEXT, title); break; case BusinessLayer.LearnModes.Sentence: title = String.Format(Resources.MAINFORM_LBLANSWER_SENTENCES_TEXT, title); break; default: if (card.CurrentAnswer.Words.Count > 1) //in case of synonyms { title = String.Format(Resources.MAINFORM_LBLANSWER_DEFAULT_TEXT2, title, card.CurrentAnswer.Words.Count); } else { title = String.Format(Resources.MAINFORM_LBLANSWER_DEFAULT_TEXT1, title); } break; } } this.Title = title; } if (e is CardStateChangedNewCardEventArgs) { ComponentsHelper.IsResizing = true; //reset controls mLifterTextBox.Text = string.Empty; webBrowserAnswer.Stop(); MLifter.Components.InfoBar.CleanUpInfobars(InfoBarControl); if (generateAnswerThread != null && generateAnswerThread.IsAlive) { generateAnswerThread.Abort(); } //fix for [ML-1335] Problems with bidirectional Text (RTL languages) RightToLeft controlTextDirection = (e.dictionary.CurrentQueryDirection == EQueryDirection.Answer2Question ? card.BaseCard.Question.Culture : card.BaseCard.Answer.Culture).TextInfo.IsRightToLeft ? RightToLeft.Yes : RightToLeft.No; mLifterTextBox.RightToLeft = multipleChoice.RightToLeft = controlTextDirection; //switch main multipane according to current learn mode if (e.dictionary.LearnMode == BusinessLayer.LearnModes.MultipleChoice) { multiPaneControlMain.SelectedPage = multiPanePageMainMultipleChoice; BusinessLayer.MultipleChoice multipleChoiceQuery = e.dictionary.GetChoices(card.BaseCard); if (multipleChoiceQuery.Count > 0) { multipleChoice.Options = e.dictionary.CurrentMultipleChoiceOptions; multipleChoice.Show(multipleChoiceQuery); multipleChoice.Focus(); } } else { multiPaneControlMain.SelectedPage = multiPanePageMainTextbox; mLifterTextBox.IgnoreChars = e.dictionary.Settings.StripChars; mLifterTextBox.CaseSensitive = e.dictionary.Settings.CaseSensitive.Value; mLifterTextBox.CorrectOnTheFly = e.dictionary.Settings.CorrectOnTheFly.Value; mLifterTextBox.Synonyms = (e.dictionary.LearnMode == BusinessLayer.LearnModes.Sentence ? card.CurrentAnswerExample : card.CurrentAnswer).ToStringList(); //show synonym notification infobar if (mLifterTextBox.Synonyms.Count > 1 && learnlogic.SynonymInfoMessage) { string notificationText; if (e.dictionary.Settings.CorrectOnTheFly.Value) { notificationText = Resources.SYNONYM_PROMPT_FLY_TEXT; } else { notificationText = Resources.SYNONYM_PROMPT_TEXT; } MLifter.Components.InfoBar infobar = new MLifter.Components.InfoBar(notificationText, this.InfoBarControl, DockStyle.Top, true, true, gradientPanelAnswer); infobar.DontShowAgainChanged += new EventHandler(infobar_DontShowAgainChanged); } PositionTextBox(); mLifterTextBox.Focus(); } ComponentsHelper.IsResizing = false; Invalidate(); } else if (e is CardStateChangedShowResultEventArgs) { CardStateChangedShowResultEventArgs args = (CardStateChangedShowResultEventArgs)e; if (generateAnswerThread != null && generateAnswerThread.IsAlive) { generateAnswerThread.Abort(); } generateAnswerThread = new Thread(delegate() { this.Invoke(new MethodInvoker(delegate() { this.AnswerBrowserUrl = new Uri("about:blank"); //[ML-1621] Flicker in the answer result })); // WORKAROUND for Windows Media Player 6.4 [ML-2122] if (MLifter.Generics.Methods.IsWMP7OrGreater()) { Uri answer = MLifter.DAL.DB.DbMediaServer.DbMediaServer.PrepareAnswer(args.dictionary.DictionaryDAL.Parent, args.cardid, args.dictionary.GenerateAnswer(args.cardid, args.answer, args.promoted)); this.Invoke(new MethodInvoker(delegate() { this.AnswerBrowserUrl = answer; multiPaneControlMain.SelectedPage = multiPanePageMainViewer; if (!args.slideshow && e.dictionary.Settings.SelfAssessment.Value) { cardEventArgs = args;//this tag is needed for the submit of the answer } OnSetButtonFocus(e); })); } else { string content = args.dictionary.GenerateAnswer(args.cardid, args.answer, args.promoted); this.Invoke(new MethodInvoker(delegate() { this.AnswerBrowserContent = content; multiPaneControlMain.SelectedPage = multiPanePageMainViewer; if (!args.slideshow && e.dictionary.Settings.SelfAssessment.Value) { cardEventArgs = args;//this tag is needed for the submit of the answer } OnSetButtonFocus(e); })); } }); generateAnswerThread.IsBackground = true; generateAnswerThread.Name = "Generate Answer Thread"; generateAnswerThread.CurrentCulture = Thread.CurrentThread.CurrentCulture; generateAnswerThread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture; generateAnswerThread.Start(); } else if (e is CardStateChangedCountdownTimerEventArgs) { //submit answers in case the timer is finished CardStateChangedCountdownTimerEventArgs args = (CardStateChangedCountdownTimerEventArgs)e; if (args.TimerFinished) { if (multiPaneControlMain.SelectedPage == multiPanePageMainTextbox) { mLifterTextBox.AllowAnswerSubmit = false; mLifterTextBox.ManualOnKeyPress(new KeyPressEventArgs((char)Keys.Enter)); mLifterTextBox.AllowAnswerSubmit = true; SubmitUserInput(); } else if (multiPaneControlMain.SelectedPage == multiPanePageMainMultipleChoice) { SubmitMultipleChoice(); } else if (learnlogic.SlideShow) { SubmitSlideShow(false); } } } }