private void AddWrongWord(DictonaryWords translatedWord) { if (!ListWrongyWords.Contains(translatedWord)) { ListWrongyWords.Add(translatedWord); } }
private void StartGame() { try { var dictonaryWords = new DictonaryWords() { Language = Language }; if (ListDictonaryWords == null) { ListDictonaryWords = DictonaryManager.PrepareWordList(repository.GetRecords(), dictonaryWords); if (ListDictonaryWords.Count < 4) { var toast = Toast.MakeText(this, "Please enter word. There is not enough WordList for starting game.", ToastLength.Short); toast.Show(); LoadMain(); return; } GameResultCalculation.ElapsedStropWatch.Start(); var toast1 = Toast.MakeText(this, String.Format("Game started!!! {0} Word", ListDictonaryWords.Count), ToastLength.Short); toast1.Show(); } VisibleClearForm(GameLevel); var RandomWords = DictonaryManager.PrepareWordList(repository.GetRecords(), dictonaryWords); switch (GameLevel) { case GameLevels.Easy: ListButton = GenerateRandom(4); break; case GameLevels.Medium: ListButton = GenerateRandom(5); break; case GameLevels.Hard: ListButton = GenerateRandom(6); break; } SetGuessWordButtons(RandomWords); } catch (Exception ex) { var toast = Toast.MakeText(this, ex.Message, ToastLength.Short); toast.Show(); } }
private void listView_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e) { e.View.Animate() .SetDuration(500) .Alpha(0) .WithEndAction(new Runnable(() => { e.View.Alpha = 1f; var LinearLayoutDictionaryListRowButtonDelete = e.View.FindViewById <LinearLayout>(Resource.Id.LinearLayoutDictionaryListRowButtonDelete); var LinearLayoutDictionaryListRowButtonEdit = e.View.FindViewById <LinearLayout>(Resource.Id.LinearLayoutDictionaryListRowButtonEdit); var DictonaryRowWord = e.View.FindViewById <TextView>(Resource.Id.DictonaryRowWord); var DictionaryListRowDelete = e.View.FindViewById <ImageView>(Resource.Id.DictionaryListRowDelete); var DictionaryListRowEdit = e.View.FindViewById <ImageView>(Resource.Id.DictionaryListRowEdit); LinearLayoutDictionaryListRowButtonDelete.Visibility = ViewStates.Visible; LinearLayoutDictionaryListRowButtonEdit.Visibility = ViewStates.Visible; DictionaryListRowDelete.Click += (o, args) => { var callDialog = new AlertDialog.Builder(this.Activity); callDialog.SetMessage("Are you sure to delete " + DictonaryRowWord.Text + "?"); callDialog.SetNegativeButton("Cancel", delegate { }); callDialog.SetNeutralButton("Delete", delegate { var DictonaryRowWordID = e.View.FindViewById <TextView>(Resource.Id.DictonaryRowWordID); DictonaryWords item = new DictonaryWords() { ID = Convert.ToInt32(DictonaryRowWordID.Text) }; repository.Delete(item); LoadList(); } ); callDialog.Show(); }; DictionaryListRowEdit.Click += (o, args) => { var DictonaryRowWordID = e.View.FindViewById <TextView>(Resource.Id.DictonaryRowWordID); var intent = new Intent(); intent.SetClass(this.Activity, typeof(DictionaryActivity)); intent.PutExtra("wordId", Convert.ToInt32(DictonaryRowWordID.Text)); StartActivityForResult(intent, 100); }; })); //var DictonaryRowWordID = e.View.FindViewById<TextView>(Resource.Id.DictonaryRowWordID); //var intent = new Intent(); //intent.SetClass(this.Activity, typeof(DictionaryActivity)); //intent.PutExtra("wordId", Convert.ToInt32(DictonaryRowWordID.Text)); //StartActivityForResult(intent, 100); }
public DictonaryWords GetRecord(DictonaryWords dictonaryWords) { try { var db = new SQLiteConnection(path); var records = db.Table <DictonaryWords>().Where(a => a.ID == dictonaryWords.ID); return(records.First()); } catch (SQLiteException) { return(null); } }
private void DictionaryAddButton_Click(object sender, EventArgs e) { if (CheckForm()) { DictonaryWords dictonaryWords = new DictonaryWords() { Language = spinner.SelectedItem.ToString(), Word = WordText.Text, TranslatedWord = TranslatedWordText.Text }; repository.Insert(dictonaryWords); ClearForm(); } }
private void LoadList() { var dictonaryWords = new DictonaryWords() { Language = GetLanguage }; ListDictonaryWords = DictonaryManager.PrepareWordList(repository.GetRecords(), dictonaryWords); if (ListDictonaryWords != null) { _dictonaryListAdapter = new DictonaryListAdapter(this.Activity, ListDictonaryWords.OrderBy(a => a.Language).ThenBy(b => b.Word).ThenBy(c => c.TranslatedWord).ToList()); listView.Adapter = _dictonaryListAdapter; ListCount.Text = $"{ListDictonaryWords.Count} Word"; } }
private void SetWord() { if (Intent.Extras.GetInt("wordId") != 0) { item = new DictonaryWords() { ID = Intent.Extras.GetInt("wordId") }; item = repository.GetRecord(item); WordText.Text = item.Word; TranslatedWordText.Text = item.TranslatedWord; DictionaryAddButton.Text = "UPDATE"; spinner.SetSelection(1); DictionaryDeleteButton.Visibility = ViewStates.Visible; } }
private void SetGuessWordButtons(List <DictonaryWords> RandomWords) { TrueRandomNumber = random.Next(ListDictonaryWords.Count); TrueWord = ListDictonaryWords[TrueRandomNumber]; DictionaryGameFROMButton.Text = TrueWord.Word; Button randomButton = GetRandomButton(ListButton[0]); randomButton.Text = TrueWord.TranslatedWord; var TrueWordindx = GetTrueWordindxIndx(RandomWords); RandomWords.RemoveAt(TrueWordindx); randomNumber = random.Next(RandomWords.Count); randomButton = GetRandomButton(ListButton[1]); randomButton.Text = RandomWords[randomNumber].TranslatedWord; RandomWords.RemoveAt(randomNumber); randomNumber = random.Next(RandomWords.Count); randomButton = GetRandomButton(ListButton[2]); randomButton.Text = RandomWords[randomNumber].TranslatedWord; RandomWords.RemoveAt(randomNumber); randomNumber = random.Next(RandomWords.Count); randomButton = GetRandomButton(ListButton[3]); randomButton.Text = RandomWords[randomNumber].TranslatedWord; RandomWords.RemoveAt(randomNumber); if ((GameLevel == GameLevels.Medium) || (GameLevel == GameLevels.Hard)) { randomNumber = random.Next(RandomWords.Count); randomButton = GetRandomButton(ListButton[4]); randomButton.Text = RandomWords[randomNumber].TranslatedWord; RandomWords.RemoveAt(randomNumber); } if (GameLevel == GameLevels.Hard) { randomNumber = random.Next(RandomWords.Count); randomButton = GetRandomButton(ListButton[5]); randomButton.Text = RandomWords[randomNumber].TranslatedWord; RandomWords.RemoveAt(randomNumber); } }
public static List <DictonaryWords> PrepareWordList(List <DictonaryWords> listWords, DictonaryWords words) { var lst = new List <DictonaryWords>(); foreach (DictonaryWords item in listWords) { if (item.Language != words.Language) { lst.Add(new DictonaryWords() { ID = item.ID, Word = item.TranslatedWord, TranslatedWord = item.Word, Language = item.Language }); } else { lst.Add(item); } } return(lst); }