public override SetLearnModeResult SetLearnMode(LearnModes mode, bool isSubstituteDenied, int timeoutMs) { SetLearnModeResult res = null; res = (SetLearnModeResult)Execute(new SetLearnModeSlaveOperation(mode, SetAssignStatusSignal, timeoutMs)); return(res); }
public override ActionToken SetLearnMode(LearnModes mode, bool isSubstituteDenied, int timeoutMs, Action <IActionItem> completedCallback) { ActionToken ret = null; SetLearnModeSlaveOperation oper = new SetLearnModeSlaveOperation(mode, SetAssignStatusSignal, timeoutMs); learnModeOperation = oper; ret = ExecuteAsync(oper, completedCallback); return(ret); }
public SetLearnModeControllerOperation(LearnModes mode, Action <NodeStatuses> nodeStatusCallback, int timeoutMs) : base(true, CommandTypes.CmdZWaveSetLearnMode, true) { Mode = mode; TimeoutMs = timeoutMs; NodeStatusCallback = nodeStatusCallback; if (TimeoutMs <= 0) { TimeoutMs = TIMEOUT; } }
public SetLearnModeSlaveOperation(LearnModes mode, Action <AssignStatuses> assignStatusCallback, int timeoutMs) : base(true, CommandTypes.CmdZWaveSetLearnMode, true) { Mode = mode; TimeoutMs = timeoutMs; AssignStatusCallback = assignStatusCallback; if (TimeoutMs <= 0) { TimeoutMs = TIMEOUT; } }
public override SetLearnModeResult SetLearnMode(LearnModes mode, bool isSubstituteDenied, int timeoutMs) { SetLearnModeResult ret = null; ResetNodeStatusSignals(); var action = new SetLearnModeControllerOperation(mode, SetNodeStatusSignal, timeoutMs); if (isSubstituteDenied) { action.SubstituteSettings.SetFlag(SubstituteFlags.DenySecurity); } ret = (SetLearnModeResult)Execute(action); return(ret); }
public override ActionToken SetLearnMode(LearnModes mode, bool isSubstituteDenied, int timeoutMs, Action <IActionItem> completedCallback) { ActionToken ret = null; ResetNodeStatusSignals(); SetLearnModeControllerOperation action = new SetLearnModeControllerOperation(mode, SetNodeStatusSignal, timeoutMs); if (isSubstituteDenied) { action.SubstituteSettings.SetFlag(SubstituteFlags.DenySecurity); } learnModeOperation = action; ret = ExecuteAsync(action, completedCallback); return(ret); }
/// <summary> /// Initializes a new instance of the <see cref="StackCard"/> class. /// </summary> /// <param name="card">The card.</param> /// <param name="result">The result.</param> /// <param name="promoted">if set to <c>true</c> [promoted].</param> /// <param name="queryDirection">The query direction.</param> /// <param name="learnMode">The learn mode.</param> /// <param name="asked">The asked.</param> /// <param name="answered">The answered.</param> /// <param name="questionCulture">The question culture.</param> /// <param name="answerculture">The answerculture.</param> /// <remarks>Documented by Dev02, 2008-07-17</remarks> public StackCard(ICard card, AnswerResult result, bool promoted, EQueryDirection queryDirection, LearnModes learnMode, DateTime asked, DateTime answered, CultureInfo questionCulture, CultureInfo answerculture, string answer, int obox, int nbox, bool canDem, Dictionary lm, int cs) { m_Card = card; m_Result = result; m_Promoted = promoted; m_QueryDirection = queryDirection; m_LearnMode = learnMode; m_CardAsked = asked; m_CardAnswered = answered; m_QuestionCulture = questionCulture; m_AnswerCulture = answerculture; m_answer = answer; m_newBox = nbox; m_oldBox = obox; m_canceledDemote = canDem; m_lm = lm; m_correctSynonyms = cs; }
/// <summary> /// Gets the next cardNode. /// </summary> /// <param name="BoxNr">The box nr.</param> /// <returns></returns> /// <remarks>Documented by Dev05, 2007-09-03</remarks> private ICard GetNextCard(int BoxNr) { learnMode = GetNextLearnMode(); currentQueryDirection = GetNextQueryDirection(); List<QueryStruct> queryStructs = new List<QueryStruct>(); //add user.Dictionary.MultipleChoice to user.Dictionary.CurrentMultipleChoice CurrentMultipleChoiceOptions = new QueryMultipleChoiceOptions(); CurrentMultipleChoiceOptions.AllowMultipleCorrectAnswers = MultipleChoiceOptions.AllowMultipleCorrectAnswers; CurrentMultipleChoiceOptions.AllowRandomDistractors = MultipleChoiceOptions.AllowRandomDistractors; CurrentMultipleChoiceOptions.MaxNumberOfCorrectAnswers = MultipleChoiceOptions.MaxNumberOfCorrectAnswers; CurrentMultipleChoiceOptions.NumberOfChoices = MultipleChoiceOptions.NumberOfChoices; if (QueryChapters.Count == Chapters.Chapters.Count) queryStructs.Add(new QueryStruct(-1, BoxNr, QueryCardState.Active)); else { foreach (int chapter in QueryChapters) queryStructs.Add(new QueryStruct(chapter, BoxNr, QueryCardState.Active)); } List<ICard> cards; if ((BoxNr == 0) && Settings.RandomPool.GetValueOrDefault()) { cards = dictionary.Cards.GetCards(queryStructs.ToArray(), QueryOrder.Random, QueryOrderDir.Ascending, 1); } else cards = dictionary.Cards.GetCards(queryStructs.ToArray(), QueryOrder.Timestamp, QueryOrderDir.Ascending, 1); if (cards.Count > 0) { CurrentBox = cards[0].Box; return cards[0]; } else return null; }
public override ActionToken SetLearnMode(LearnModes mode, int timeoutMs, Action <IActionItem> completedCallback) { return(SetLearnMode(mode, false, timeoutMs, completedCallback)); }
public override SetLearnModeResult SetLearnMode(LearnModes mode, int timeoutMs) { return(SetLearnMode(mode, false, timeoutMs)); }
/// <summary> /// Asks a new card. /// </summary> /// <remarks>Documented by Dev02, 2008-04-23</remarks> private void AskNextCard() { if (!UserSessionAlive) return; if (Dictionary == null || Dictionary.Settings == null) return; //check wether it's time to enable the snooze mode if (!SnoozeModeActive && Dictionary.Settings.SnoozeOptions != null && Dictionary.Settings.SnoozeOptions.SnoozeMode.HasValue) { if (cardStack.CheckSnooze(Dictionary.Settings.SnoozeOptions)) { if (Dictionary.Settings.SnoozeOptions.SnoozeMode == MLifter.DAL.Interfaces.ESnoozeMode.SendToTray) { this.SnoozeModeActive = true; return; } if (Dictionary.Settings.SnoozeOptions.SnoozeMode == MLifter.DAL.Interfaces.ESnoozeMode.QuitProgram) { if (SnoozeModeQuitProgram != null) { SnoozeModeQuitProgram(this, EventArgs.Empty); return; } } } } //get next card ICard cCard = SlideShow ? Dictionary.GetNextSlide() : Dictionary.GetNextCard(); if (cCard == null) { currentCardID = -1; OnUserDialog(new UserNotifyDialogEventArgs(Dictionary, -1, UserNotifyDialogEventArgs.NotifyDialogKind.NoWords)); OnLearningModuleOptionsChanged(); return; } currentCardID = cCard.Id; //Use card / chapter settings if (!SlideShow) { hasLearnModeChangedAndNotifyUser = false; originalLearnMode = Dictionary.LearnMode; int currentChapterId = cCard.Chapter; CheckAndAdjustSettings(Dictionary.Chapters.GetChapterByID(currentChapterId).Settings); CheckAndAdjustSettings(cCard.Settings); //check if there are enough choices available for mutliple choice hasMultipleChoiceLearnModeChanged = false; if (Dictionary.LearnMode == LearnModes.MultipleChoice && !Dictionary.ChoicesAvailable(cCard, Dictionary.CurrentMultipleChoiceOptions.NumberOfChoices.Value)) { hasMultipleChoiceLearnModeChanged = true; Dictionary.LearnMode = LearnModes.Word; //switch to fail-safe word mode } //check if image / audio is available, switch back to fail-safe word mode otherwise if ((Dictionary.LearnMode == LearnModes.ImageRecognition && !Dictionary.Cards.ImageAvailable(cCard, Side.Question)) || (Dictionary.LearnMode == LearnModes.ListeningComprehension && !Dictionary.Cards.AudioAvailable(cCard, Side.Question)) || (Dictionary.LearnMode == LearnModes.Sentence && !Dictionary.Cards.SentenceAvailable(cCard, Side.Answer))) { originalLearnMode = Dictionary.LearnMode; hasLearnModeChangedAndNotifyUser = true; Dictionary.LearnMode = LearnModes.Word; } } else { //disable timer if enabled if (Dictionary.Settings.EnableTimer.HasValue && Dictionary.Settings.EnableTimer.Value) StopCountdownTimer(); } Debug.WriteLine("New card asked: " + currentCardID); //save timestamp currentCardAsked = DateTime.Now.ToUniversalTime(); //set the current directory for the browsers if (!String.IsNullOrEmpty(Dictionary.DirectoryName)) System.IO.Directory.SetCurrentDirectory(Dictionary.DirectoryName); //fire the event to load the new card if (SlideShow) OnCardStateChanged(new CardStateChangedShowResultEventArgs(Dictionary, currentCardID, true, AnswerResult.Correct, string.Empty, SlideShow, false)); else OnCardStateChanged(new CardStateChangedNewCardEventArgs(Dictionary, currentCardID)); //activate countdown timer if (Dictionary.Settings.EnableTimer.HasValue && Dictionary.Settings.EnableTimer.Value && !SlideShow) { //determine the countdown timer out of the card Card currentCard = new Card(cCard, Dictionary); int countdownseconds = 0; if (currentCard != null && currentCard.CurrentAnswer != null) countdownseconds = currentCard.CurrentAnswer.ToQuotedString().Length + 10 * currentCard.CurrentAnswer.Words.Count; if (countdownseconds < CountDownTimerMinimum) countdownseconds = CountDownTimerMinimum; CardStateChangedCountdownTimerEventArgs args = new CardStateChangedCountdownTimerEventArgs(Dictionary, currentCardID, countdownseconds); OnCardStateChanged(args); //deactivate countdown timer StopCountdownTimer(); //set up new timer countdownTimer = new Timer(); countdownTimer.Tag = args; countdownTimer.Interval = 1000; countdownTimer.Tick += new EventHandler(countdownTimer_Tick); countdownTimer.Start(); } #region Show all Infobars at least if (hasLearnModeChangedAndNotifyUser && !SlideShow) OnUserDialog(new UserNotifyDialogEventArgs(Dictionary, currentCardID, UserNotifyDialogEventArgs.NotifyDialogKind.SelectedLearnModeNotAllowed, originalLearnMode)); if (hasMultipleChoiceLearnModeChanged && !SlideShow) OnUserDialog(new UserNotifyDialogEventArgs(Dictionary, currentCardID, UserNotifyDialogEventArgs.NotifyDialogKind.NotEnoughMultipleChoices)); #endregion }
/// <summary> /// If a learn mode is assigned from the track control, we deselect the sample. /// </summary> /// <param name="mode"></param> private void LearnMode(LearnModes mode) { SelectedSample = null; }