private void Add_Word_Click(object sender, RoutedEventArgs e)
        {
            string
                s0 = TB_Add1.Text.Trim(),
                s1 = TB_Add2.Text.Trim();

            if (s0.Length != 0 && s1.Length != 0)
            {
                var
                    todb = new WordMap {
                    Word = s0, Meaning = s1
                };
                words_.InsertSorted(todb, x => x.Word);
                // Show the first dialog.
                new PluginWordsRecord("English", todb.Id).ShowDialog();
                new PluginWordsRecord("Russian", todb.Id).ShowDialog();
                MP3Recorder.Mix(
                    "./Clips/" + todb.Id.ToString() + "_English_Russian.mp3",
                    "./Raw/" + todb.Id.ToString() + "_English.mp3",
                    "./Raw/" + todb.Id.ToString() + "_Russian.mp3");
                MP3Recorder.Mix(
                    "./Clips/" + todb.Id.ToString() + "_Russian_English.mp3",
                    "./Raw/" + todb.Id.ToString() + "_Russian.mp3",
                    "./Raw/" + todb.Id.ToString() + "_English.mp3");
            }
            TB_Add1.Text = "";
            TB_Add2.Text = "";
            TB_Add1.Focus();
        }
Example #2
0
 private static int GetAccuracy(WordMap w)
 {
     // "accuracy = right - wrong", "right = total - wrong".  An accuracy
     // > 0 means more right than wrong, < 0 means more wrong than right,
     // == 0 means exactly even.
     return w.Shown - w.Wrong - w.Wrong;
 }
Example #3
0
 public override void Init(SQLiteConnection db)
 {
     startTime_   = DateTime.MinValue;
     currentWord_ = null;
     showAnswer_  = true;
     dirty_       = true;
 }
Example #4
0

        
Example #5
0
        void OnItemPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            WordMap item = sender as WordMap;

            if (item != null)
            {
                db_.Update(item);
            }
        }
Example #6
0
        public override bool Update(double tick)
        {
            DateTime now = DateTime.Now;

            if (showAnswer_)
            {
                if ((now - startTime_).TotalSeconds >= ANSWER_SECONDS)
                {
                    // Change the word.
                    if (words_.Count == 0)
                    {
                        currentWord_ = nullWord_;
                    }
                    else
                    {
                        currentWord_ = WordSelection.Select(words_);
                    }
                    startTime_   = now;
                    showMeaning_ = rand_.Next(2) == 1;
                    showAnswer_  = false;
                    dirty_       = false;
                    return(true);
                }
            }
            else
            {
                if ((now - startTime_).TotalSeconds >= DISPLAY_SECONDS)
                {
                    // Change the word.
                    showAnswer_  = true;
                    showMeaning_ = !showMeaning_;
                    dirty_       = false;
                    return(true);
                }
            }
            if (toSave_ != null)
            {
                toSave_.Right = right_;
                toSave_       = null;
                right_        = false;
            }
            if (dirty_)
            {
                dirty_ = false;
                return(true);
            }
            return(false);
        }
Example #7
0
 private static int GetLikelihood(WordMap w, int upper)
 {
     return upper - GetAccuracy(w) + 1;
 }
Example #8
0
 private void OnNo(object sender, EventArgs e)
 {
     startTime_ = DateTime.Now.AddSeconds(-ANSWER_SECONDS);
     toSave_    = currentWord_;
 }
Example #9
0

        
Example #10
0
 public override void Init(SQLiteConnection db)
 {
     startTime_ = DateTime.MinValue;
     currentWord_ = null;
     showAnswer_ = true;
     dirty_ = true;
 }
Example #11
0
 private void OnYes(object sender, EventArgs e)
 {
     startTime_ = DateTime.Now.AddSeconds(-ANSWER_SECONDS);
     toSave_ = currentWord_;
     right_ = true;
 }
Example #12
0
 public override bool Update(double tick)
 {
     DateTime now = DateTime.Now;
     if (showAnswer_)
     {
         if ((now - startTime_).TotalSeconds >= ANSWER_SECONDS)
         {
             // Change the word.
             if (words_.Count == 0)
                 currentWord_ = nullWord_;
             else
                 currentWord_ = WordSelection.Select(words_);
             startTime_ = now;
             showMeaning_ = rand_.Next(2) == 1;
             showAnswer_ = false;
             dirty_ = false;
             return true;
         }
     }
     else
     {
         if ((now - startTime_).TotalSeconds >= DISPLAY_SECONDS)
         {
             // Change the word.
             showAnswer_ = true;
             showMeaning_ = !showMeaning_;
             dirty_ = false;
             return true;
         }
     }
     if (toSave_ != null)
     {
         toSave_.Right = right_;
         toSave_ = null;
         right_ = false;
     }
     if (dirty_)
     {
         dirty_ = false;
         return true;
     }
     return false;
 }