async void E_Clicked (object sender, EventArgs e) { const string text1 ="Example words 1: あ – の"; const string text2 ="Example words 2: は – ん"; const string text3 = "Example words 1: が – ぞ"; const string text4 = "Example words 2: だ – ぽ"; const string text5 = "Example words 1: ア - ノ"; const string text6 = "Example words 2: ハ - ン"; const string text7 = "Example words 1: ガ – ゾ"; const string text8 = "Example words 2: ダ – ポ"; const string text9 = "Example words: ティ – ヴュ"; const string testTitle = "Select a test"; string buttonText1=text1, buttonText2=text2; testProgress = 0; switch (mode) { case "Dakuten Hiragana": buttonText1 = text3; buttonText2 = text4; break; case "Basic Katakana": buttonText1 = text5; buttonText2 = text6; break; case "Dakuten Katakana": buttonText1=text7; buttonText2 = text8; break; case "Transcription Katakana": buttonText1=text9; break; } if ((Button)sender == testButton [0]) { var action=""; if(monoMode==true) action=await DisplayActionSheet (testTitle, "Cancel", null, "Syllables", buttonText1, buttonText2, "Shuffled table"); else action=await DisplayActionSheet (testTitle, "Cancel", null, "Syllables", "Example Words", "Shuffled table"); switch (action) { case "Syllables": addDrill (); StudyCard.drillRightCount = 0; StudyCard.initDrillCount = drillList.Count; if (drillList [0].GetType () == typeof(ExampleCard)) { ExampleCard orgCard = (ExampleCard)drillList [0]; ExampleCard firstCard = new ExampleCard (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableCard)) { SyllableCard orgCard = (SyllableCard)drillList [0]; SyllableCard firstCard = new SyllableCard (orgCard.mCharacter, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case text1: addExamples (0, false, mode); StudyCard.drillRightCount = 0; StudyCard.initDrillCount = drillList.Count; if (drillList [0].GetType () == typeof(ExampleCard)) { ExampleCard orgCard = (ExampleCard)drillList [0]; ExampleCard firstCard = new ExampleCard (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableCard)) { SyllableCard orgCard = (SyllableCard)drillList [0]; SyllableCard firstCard = new SyllableCard (orgCard.mCharacter, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case text2: addExamples (1, false, mode); StudyCard.drillRightCount = 0; StudyCard.initDrillCount = drillList.Count; if (drillList [0].GetType () == typeof(ExampleCard)) { ExampleCard orgCard = (ExampleCard)drillList [0]; ExampleCard firstCard = new ExampleCard (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableCard)) { SyllableCard orgCard = (SyllableCard)drillList [0]; SyllableCard firstCard = new SyllableCard (orgCard.mCharacter, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case text3: addExamples (0, false, mode); StudyCard.drillRightCount = 0; StudyCard.initDrillCount = drillList.Count; if (drillList [0].GetType () == typeof(ExampleCard)) { ExampleCard orgCard = (ExampleCard)drillList [0]; ExampleCard firstCard = new ExampleCard (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableCard)) { SyllableCard orgCard = (SyllableCard)drillList [0]; SyllableCard firstCard = new SyllableCard (orgCard.mCharacter, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case text4: addExamples (1, false, mode); StudyCard.drillRightCount = 0; StudyCard.initDrillCount = drillList.Count; if (drillList [0].GetType () == typeof(ExampleCard)) { ExampleCard orgCard = (ExampleCard)drillList [0]; ExampleCard firstCard = new ExampleCard (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableCard)) { SyllableCard orgCard = (SyllableCard)drillList [0]; SyllableCard firstCard = new SyllableCard (orgCard.mCharacter, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case text5: addExamples (0, false, mode); StudyCard.drillRightCount = 0; StudyCard.initDrillCount = drillList.Count; if (drillList [0].GetType () == typeof(ExampleCard)) { ExampleCard orgCard = (ExampleCard)drillList [0]; ExampleCard firstCard = new ExampleCard (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableCard)) { SyllableCard orgCard = (SyllableCard)drillList [0]; SyllableCard firstCard = new SyllableCard (orgCard.mCharacter, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case text6: addExamples (1, false, mode); StudyCard.drillRightCount = 0; StudyCard.initDrillCount = drillList.Count; if (drillList [0].GetType () == typeof(ExampleCard)) { ExampleCard orgCard = (ExampleCard)drillList [0]; ExampleCard firstCard = new ExampleCard (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableCard)) { SyllableCard orgCard = (SyllableCard)drillList [0]; SyllableCard firstCard = new SyllableCard (orgCard.mCharacter, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case text7: addExamples (0, false, mode); StudyCard.drillRightCount = 0; StudyCard.initDrillCount = drillList.Count; if (drillList [0].GetType () == typeof(ExampleCard)) { ExampleCard orgCard = (ExampleCard)drillList [0]; ExampleCard firstCard = new ExampleCard (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableCard)) { SyllableCard orgCard = (SyllableCard)drillList [0]; SyllableCard firstCard = new SyllableCard (orgCard.mCharacter, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case text8: addExamples (1, false, mode); StudyCard.drillRightCount = 0; StudyCard.initDrillCount = drillList.Count; if (drillList [0].GetType () == typeof(ExampleCard)) { ExampleCard orgCard = (ExampleCard)drillList [0]; ExampleCard firstCard = new ExampleCard (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableCard)) { SyllableCard orgCard = (SyllableCard)drillList [0]; SyllableCard firstCard = new SyllableCard (orgCard.mCharacter, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case "Example Words": addExamples (0, false, mode); StudyCard.drillRightCount = 0; StudyCard.initDrillCount = drillList.Count; if (drillList [0].GetType () == typeof(ExampleCard)) { ExampleCard orgCard = (ExampleCard)drillList [0]; ExampleCard firstCard = new ExampleCard (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableCard)) { SyllableCard orgCard = (SyllableCard)drillList [0]; SyllableCard firstCard = new SyllableCard (orgCard.mCharacter, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case "Shuffled table": await Navigation.PushAsync (new Shuffled (mode, monoMode)); break; } } else if ((Button)sender == testButton [1]) { var action = ""; if(monoMode==true) action = await DisplayActionSheet (testTitle, "Cancel", null, "Syllables", buttonText1, buttonText2); else action = await DisplayActionSheet (testTitle, "Cancel", null, "Syllables", "Example Words"); switch (action) { case "Syllables": addRomajiDrill (); StudyCard.initDrillCount=drillList.Count; StudyCard.drillRightCount = 0; if (drillList [0].GetType () == typeof(ExCardfront)) { ExCardfront orgCard = (ExCardfront)drillList [0]; ExCardfront firstCard = new ExCardfront (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableRCard)) { SyllableRCard orgCard = (SyllableRCard)drillList [0]; SyllableRCard firstCard = new SyllableRCard (orgCard.mKana, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case text1: addExamples (0, true, mode); StudyCard.initDrillCount=drillList.Count; StudyCard.drillRightCount = 0; if (drillList [0].GetType () == typeof(ExCardfront)) { ExCardfront orgCard = (ExCardfront)drillList [0]; ExCardfront firstCard = new ExCardfront (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableRCard)) { SyllableRCard orgCard = (SyllableRCard)drillList [0]; SyllableRCard firstCard = new SyllableRCard (orgCard.mKana, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case text2: addExamples (1,true,mode); StudyCard.initDrillCount=drillList.Count; StudyCard.drillRightCount = 0; if (drillList [0].GetType () == typeof(ExCardfront)) { ExCardfront orgCard = (ExCardfront)drillList [0]; ExCardfront firstCard = new ExCardfront (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableRCard)) { SyllableRCard orgCard = (SyllableRCard)drillList [0]; SyllableRCard firstCard = new SyllableRCard (orgCard.mKana, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case text3: addExamples (0,true,mode); StudyCard.initDrillCount=drillList.Count; StudyCard.drillRightCount = 0; if (drillList [0].GetType () == typeof(ExCardfront)) { ExCardfront orgCard = (ExCardfront)drillList [0]; ExCardfront firstCard = new ExCardfront (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableRCard)) { SyllableRCard orgCard = (SyllableRCard)drillList [0]; SyllableRCard firstCard = new SyllableRCard (orgCard.mKana, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case text4: addExamples (1,true,mode); StudyCard.initDrillCount=drillList.Count; StudyCard.drillRightCount = 0; if (drillList [0].GetType () == typeof(ExCardfront)) { ExCardfront orgCard = (ExCardfront)drillList [0]; ExCardfront firstCard = new ExCardfront (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableRCard)) { SyllableRCard orgCard = (SyllableRCard)drillList [0]; SyllableRCard firstCard = new SyllableRCard (orgCard.mKana, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case text5: addExamples (0,true,mode); StudyCard.initDrillCount=drillList.Count; StudyCard.drillRightCount = 0; if (drillList [0].GetType () == typeof(ExCardfront)) { ExCardfront orgCard = (ExCardfront)drillList [0]; ExCardfront firstCard = new ExCardfront (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableRCard)) { SyllableRCard orgCard = (SyllableRCard)drillList [0]; SyllableRCard firstCard = new SyllableRCard (orgCard.mKana, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case text6: addExamples (1,true,mode); StudyCard.initDrillCount=drillList.Count; StudyCard.drillRightCount = 0; if (drillList [0].GetType () == typeof(ExCardfront)) { ExCardfront orgCard = (ExCardfront)drillList [0]; ExCardfront firstCard = new ExCardfront (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableRCard)) { SyllableRCard orgCard = (SyllableRCard)drillList [0]; SyllableRCard firstCard = new SyllableRCard (orgCard.mKana, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case text7: addExamples (0,true,mode); StudyCard.initDrillCount=drillList.Count; StudyCard.drillRightCount = 0; if (drillList [0].GetType () == typeof(ExCardfront)) { ExCardfront orgCard = (ExCardfront)drillList [0]; ExCardfront firstCard = new ExCardfront (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableRCard)) { SyllableRCard orgCard = (SyllableRCard)drillList [0]; SyllableRCard firstCard = new SyllableRCard (orgCard.mKana, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case text8: addExamples (1,true,mode); StudyCard.initDrillCount=drillList.Count; StudyCard.drillRightCount = 0; if (drillList [0].GetType () == typeof(ExCardfront)) { ExCardfront orgCard = (ExCardfront)drillList [0]; ExCardfront firstCard = new ExCardfront (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableRCard)) { SyllableRCard orgCard = (SyllableRCard)drillList [0]; SyllableRCard firstCard = new SyllableRCard (orgCard.mKana, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; case "Example Words": addExamples (0,true,mode); StudyCard.initDrillCount=drillList.Count; StudyCard.drillRightCount = 0; if (drillList [0].GetType () == typeof(ExCardfront)) { ExCardfront orgCard = (ExCardfront)drillList [0]; ExCardfront firstCard = new ExCardfront (orgCard.mKey, orgCard.mValue, 0); await Navigation.PushAsync (firstCard); } else if (drillList [0].GetType () == typeof(SyllableRCard)) { SyllableRCard orgCard = (SyllableRCard)drillList [0]; SyllableRCard firstCard = new SyllableRCard (orgCard.mKana, orgCard.mRoot, 0); await Navigation.PushAsync (firstCard); } break; } } else { var action = await DisplayActionSheet (testTitle, "Cancel", null, "Fill in the blanks", "Timed recognition"); switch (action) { case "Fill in the blanks": if (mode == "Basic Hiragana" && monoMode == true) addFillDrill (1); else if (mode == "Basic Hiragana" && monoMode == false) addFillDrill (2); else if (mode == "Dakuten Hiragana" && monoMode == true) addFillDrill (3); else if (mode == "Dakuten Hiragana" && monoMode == false) addFillDrill (4); else if (mode == "Basic Katakana" && monoMode == true) addFillDrill (5); else if (mode == "Basic Katakana" && monoMode == false) addFillDrill (6); else if (mode == "Dakuten Katakana" && monoMode == true) addFillDrill (7); else if (mode == "Dakuten Katakana" && monoMode == false) addFillDrill (8); else if (mode == "Transcription Katakana") addFillDrill (9); if (fillList.Count > 0) { FillBlanks.initCount = fillList.Count; FillBlanks.rightCount = 0; FillBlanks.progress = 0; await Navigation.PushAsync (new FillBlanks(0)); } break; case "Timed recognition": if (mode == "Basic Hiragana" && monoMode == true) addTimeDrill (1); else if (mode == "Basic Hiragana" && monoMode == false) addTimeDrill (2); else if (mode == "Dakuten Hiragana" && monoMode == true) addTimeDrill (3); else if (mode == "Dakuten Hiragana" && monoMode == false) addTimeDrill (4); else if (mode == "Basic Katakana" && monoMode == true) addTimeDrill (5); else if (mode == "Basic Katakana" && monoMode == false) addTimeDrill (6); else if (mode == "Dakuten Katakana" && monoMode == true) addTimeDrill (7); else if (mode == "Dakuten Katakana" && monoMode == false) addTimeDrill (8); else if (mode == "Transcription Katakana") addTimeDrill (9); if (timeList.Count > 0) { Timed.initCount = timeList.Count; Timed.rightCount = 0; Timed.progress = 0; Timed.sw.Restart (); await Navigation.PushAsync (new Timed (0)); } break; } } }
public SyllableBackCard (string kana,StudyCard root,ContentPage drillMode) { NavigationPage.SetHasBackButton (this, false); if(drillMode.GetType () == typeof(SyllableRCard)) Title = Character.getCategory(kana)+" Writing"; else if(drillMode.GetType () == typeof(SyllableCard)) Title = Character.getCategory(kana)+" Reading"; string mode = Character.cData [Character.kana_lookup (kana.Split('\n')[0].Split('/')[0])]; string pronun = Character.kana_to_romaji (kana); pronun = pronun.Replace (" ", "_"); if(Settings.voice) DependencyService.Get<IAudio>().PlayMp3File("Audio/SC/sc_"+pronun+".mp3"); Label left = new Label { Text = "x", BackgroundColor = Color.Red, YAlign = TextAlignment.Center, XAlign = TextAlignment.Center, FontSize = 20 }; Label right = new Label { Text = "✓", BackgroundColor = Color.Green, YAlign = TextAlignment.Center, XAlign = TextAlignment.Center, FontSize = 20 }; Grid grid = new Grid { VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, RowDefinitions = { new RowDefinition { Height = new GridLength (1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength (1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength (1, GridUnitType.Star) }, }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength (6, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) }, } }; if (mode.Length > 0) { string[] strArray = mode.Split ('/'); string header = strArray [0].Split ('\n')[0]; //Big letter grid.Children.Add (new Label { Text = strArray [0], XAlign = TextAlignment.Center, YAlign = TextAlignment.Center, FontSize = 100-header.Length*20, }, 1, 0); grid.Children.Add (new Label { Text = strArray [1], XAlign = TextAlignment.Center, YAlign = TextAlignment.Center, FontSize = 40, TextColor = Color.Maroon }, 1, 2); if (drillMode.GetType () == typeof(SyllableRCard)) { Image writingImg = new Image (); writingImg.Source=ImageSource.FromFile(DependencyService.Get<IPicture> ().GetPictureFromDisk ("Writing")); grid.Children.Add (writingImg, 1, 1); } grid.Children.Add (left, 0, 1, 0, 3); grid.Children.Add (right, 2, 3, 0, 3); } // grid.Padding = new Thickness (0, Device.OnPlatform (20, 0, 0), 0, 10); Content = grid; var leftTapRecognizer = new TapGestureRecognizer (); left.GestureRecognizers.Add (leftTapRecognizer); leftTapRecognizer.Tapped += (s, e) => { if (root.GetType () == typeof(TestPage)) { ((TestPage)root).wrongCount++; } root.drillList.Add (drillMode); root.testProgress++; if(root.drillList[root.testProgress].GetType()==typeof(SyllableCard)) { SyllableCard orgCard=(SyllableCard)root.drillList[root.testProgress]; SyllableCard nextCard = new SyllableCard(orgCard.mCharacter,orgCard.mRoot, StudyCard.drillRightCount); Navigation.InsertPageBefore(nextCard,this); } else if(root.drillList[root.testProgress].GetType()==typeof(SyllableRCard)) { SyllableRCard orgCard=(SyllableRCard)root.drillList[root.testProgress]; SyllableRCard nextCard = new SyllableRCard (orgCard.mKana, orgCard.mRoot, StudyCard.drillRightCount); Navigation.InsertPageBefore(nextCard,this); } Navigation.PopAsync (); DependencyService.Get<IPicture> ().DeletePictureFromDisk ("Writing"); }; var rightTapRecognizer = new TapGestureRecognizer (); right.GestureRecognizers.Add (rightTapRecognizer); rightTapRecognizer.Tapped += async (s, e) => { DependencyService.Get<IPicture> ().DeletePictureFromDisk ("Writing"); StudyCard.drillRightCount++; if (root.testProgress == root.drillList.Count - 1) { var result = await DisplayAlert ("Congratulations!", "You have completed this test", "OK", "Results"); if (result == false) { await DisplayAlert (((TestPage)root).wrongCount.ToString ()+" incorrect responses", "You required " + ((TestPage)root).wrongCount.ToString () + " retries to answer all questions correctly.", "OK"); } await Navigation.PopAsync (); } else { root.testProgress++; if(root.drillList[root.testProgress].GetType()==typeof(SyllableCard)) { SyllableCard orgCard=(SyllableCard)root.drillList[root.testProgress]; SyllableCard nextCard = new SyllableCard(orgCard.mCharacter,orgCard.mRoot, StudyCard.drillRightCount); Navigation.InsertPageBefore(nextCard,this); } else if(root.drillList[root.testProgress].GetType()==typeof(SyllableRCard)) { SyllableRCard orgCard=(SyllableRCard)root.drillList[root.testProgress]; SyllableRCard nextCard = new SyllableRCard (orgCard.mKana, orgCard.mRoot, StudyCard.drillRightCount); Navigation.InsertPageBefore(nextCard,this); } await Navigation.PopAsync (); } }; }