public KanaCard (string kana,StudyCard root) { this.root = root; this.Title = kana; mCharacter = kana; Grid grid = new Grid { HorizontalOptions=LayoutOptions.Fill, VerticalOptions=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)} } }; Button backButton = new Button{ Text = "→", HorizontalOptions= LayoutOptions.End,VerticalOptions=LayoutOptions.Start, FontSize = 50 }; grid.Children.Add(backButton,0,0); String displayString = kana.Split ('\n') [0]; displayString.Remove (0); Label kanaLabel = new Label { Text = displayString, VerticalOptions = LayoutOptions.Center, HorizontalOptions=LayoutOptions.Center }; if(Device.Idiom==TargetIdiom.Tablet) kanaLabel.FontSize = 200 -10* displayString.Length; else kanaLabel.FontSize = 150 -10* displayString.Length; grid.Children.Add (kanaLabel, 0, 1); grid.Children.Add (new Label(), 0, 2); Content = grid; Padding = new Thickness(10, Device.OnPlatform(10, 0, 0), 10, 10); backButton.Clicked+= BackButton_Clicked; }
public Study (string mode,StudyCard root,int rowIndex=0,int singlemode=0) { collapseMode = false; mRowIndex = rowIndex; kanaExamples=new List<View>(); var rowTapRecognizer = new TapGestureRecognizer(); romaziExamples=new List<View>(); labelFormatted = new Label (){Text="\t"}; notesLabel = new Label (){XAlign = TextAlignment.Start, YAlign = TextAlignment.Center, BackgroundColor = Color.Gray, TextColor=Color.White, Text="Notes" }; mRoot = root; if (collapseMode == true) { itemCollapse = new ToolbarItem { Icon = "collapse.png", Order = ToolbarItemOrder.Primary, Command = new Command (() => collapse ()) }; labelFormatted.IsVisible = true; notesLabel.IsVisible = true; } else if (collapseMode == false) { itemCollapse = new ToolbarItem { Icon = "uncollapse.png", Order = ToolbarItemOrder.Primary, Command = new Command (() => collapse ()) }; labelFormatted.IsVisible = false; notesLabel.IsVisible = false; } Debug.WriteLine (collapseMode); romaziLabel= new Label { XAlign = TextAlignment.Center, YAlign = TextAlignment.Center, FontAttributes=FontAttributes.Bold, FontSize = 30, TextColor = Color.FromHex("8B0000") }; Button prevButton = new Button { HorizontalOptions = LayoutOptions.StartAndExpand, Text = "<", FontSize=30, TextColor= Color.FromHex("2B3359") }; Button nextButton = new Button { HorizontalOptions = LayoutOptions.EndAndExpand, Text = ">", FontSize=30, TextColor= Color.FromHex("2B3359") }; prevButton.Clicked += PrevButton_Clicked; nextButton.Clicked += NextButton_Clicked; if (mode == "row") { grid = new Grid { 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) } }, }; Dictionary<string,string> dic = new Dictionary<string,string> (); foreach (string e in RowData.rowData[rowIndex]) { if (e.Length > 0 && e != "b") { string a = e.Split ('\n') [0].Replace ('/', '\n'); string b = e.Split ('\n') [1].Replace ('/', '\n'); dic.Add (a,b); grid.ColumnDefinitions.Add (new ColumnDefinition ()); } } int i = 0; string[] romanArray = new string[dic.Count]; string[] japanArray = new string[dic.Count]; dic.Keys.CopyTo (romanArray, 0); dic.Values.CopyTo (japanArray, 0); int fontSize1=20,fontSize2=20; if (Device.Idiom == TargetIdiom.Tablet) { fontSize1 = 45; fontSize2 = 35; } else { if (romanArray.Length >= 6) fontSize1 = 15; } foreach (string e in romanArray) { grid.Children.Add (new Label { Text = e, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.CenterAndExpand, FontSize = fontSize1, XAlign=TextAlignment.Center, YAlign=TextAlignment.Start, }, i, 1); i++; } i = 0; foreach (string e in japanArray) { grid.Children.Add (new Label { Text = e, VerticalOptions = LayoutOptions.Fill, XAlign=TextAlignment.Center, YAlign=TextAlignment.Start, FontSize=fontSize2 }, i, 2); i++; } grid.Children.Add (new Label { Text = "Take a moment to familiarize yourself with this row of characters, then proceed to the individual review cards.", TextColor = Color.Gray, XAlign=TextAlignment.Center, YAlign=TextAlignment.Center, }, 0, dic.Count, 0, 1); grid.Padding = new Thickness (10, Device.OnPlatform (20, 0, 0), 10, 10); } else { ToolbarItems.Add(itemCollapse); grid = new Grid { RowDefinitions = { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = 30 }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength (5, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) }, } }; if (mode.Length > 0) { strArray = mode.Split ('/'); //Big letter int fontSize=80-strArray[0].Length*5; grid.Children.Add (new Label { Text = strArray [0], XAlign = TextAlignment.Center, YAlign = TextAlignment.Center, FontSize=fontSize }, 1, 1); //Kana this.Title = strArray [0]; mPronun = strArray [1]; romaziLabel.Text = mPronun; grid.Children.Add (romaziLabel,1,2); // handwriting icon Image handwriting=new Image(){Source=ImageSource.FromResource("KeystotheKana.Resources.favicon.writing.png"),Aspect=Aspect.AspectFit}; grid.Children.Add (handwriting, 0, 2); var handwritingTapRecognizer = new TapGestureRecognizer (); //Display study page for each kana handwritingTapRecognizer.Tapped += (s, e) => { Navigation.PushAsync (new DrawPage (strArray [0]){ }); }; handwriting.GestureRecognizers.Add (handwritingTapRecognizer); if (strArray [2].Length > 0) { grid.Children.Add (notesLabel, 0, 3, 3, 4); //Generating Italic text string[] italicArray = strArray [2].Split ('<'); int j = 0; var fs = new FormattedString (); foreach (string e in italicArray) { if (j % 2 == 0) { fs.Spans.Add (new Span { Text = e, FontSize = 20 }); } else { fs.Spans.Add (new Span { Text = e, ForegroundColor = Color.Gray, FontSize = 20, FontAttributes = FontAttributes.Italic, }); } j++; } labelFormatted.FormattedText = fs; grid.Children.Add (labelFormatted, 0, 3, 4, 5); } // Examples Section if (strArray [3].Length > 0) { Grid subgrid = new Grid { BackgroundColor=Color.Gray, RowSpacing=1, VerticalOptions=LayoutOptions.CenterAndExpand, }; int rowCount = 0; for (int i = 0; i < 6; i++) { if (strArray [i * 2 + 3].Length > 0) rowCount++; } if (rowCount == 1) { subgrid.RowDefinitions.Add (new RowDefinition { Height = GridLength.Auto }); subgrid.RowDefinitions.Add (new RowDefinition { Height =90}); } else { for (int i = 0; i < rowCount; i++) subgrid.RowDefinitions.Add (new RowDefinition { Height = GridLength.Auto }); } Debug.WriteLine ("RowCount="+subgrid.RowDefinitions.Count); subgrid.Children.Add (new Label { Text = "Examples", XAlign = TextAlignment.Start, BackgroundColor = Color.Gray, TextColor=Color.White }, 0, 3, 0, 1); StackLayout kanalayout=null; for (int i = 0; i < rowCount; i++) { int rowFontSize=20; if (strArray [i * 2 + 3].Length > 0) { string kanaPart = strArray [i * 2 + 3].Split (' ') [0]; string romajiPart = strArray [i * 2 + 3].Substring(strArray [i * 2 + 3].Split (' ') [0].Length); Label kanaLabel = new Label (){ Text = kanaPart, FontSize = rowFontSize }; Label romajiLabel=new Label(){Text=romajiPart,TextColor=Color.FromHex("8B0000"), FontAttributes = FontAttributes.Bold,FontSize=rowFontSize}; kanalayout=new StackLayout (){ Children = {kanaLabel , romajiLabel},Orientation=StackOrientation.Horizontal}; kanaLabel.GestureRecognizers.Add (rowTapRecognizer); kanaExamples.Add (romajiLabel); } if (strArray [i * 2 + 4].Length > 0) { var fs = new FormattedString (); fs.Spans.Add (new Span { Text = strArray [i * 2 + 4], FontSize = 20 }); Label romaziExample = new Label { FormattedText = fs, BackgroundColor = Color.White, VerticalOptions = LayoutOptions.Start }; if (strArray [i * 2 + 4] == "giga- (109)") { StackLayout sublayout=new StackLayout (){ Children = { new Label(){Text="giga- (10"}, new Label(){Text="9",VerticalOptions=LayoutOptions.Start,FontSize=8},new Label(){Text=")"}},Orientation=StackOrientation.Horizontal}; subgrid.Children.Add (new StackLayout (){ Children = { kanalayout, sublayout }, BackgroundColor = Color.White }, 0, 3, i+1, i + 2); romaziExamples.Add (sublayout); } else if (strArray [i * 2 + 4] == "hecto- (102)") { StackLayout sublayout=new StackLayout (){ Children = { new Label(){Text="hecto- (10"}, new Label(){Text="2",VerticalOptions=LayoutOptions.Start,FontSize=8},new Label(){Text=")"}},Orientation=StackOrientation.Horizontal}; subgrid.Children.Add (new StackLayout (){ Children = { kanalayout, sublayout }, BackgroundColor = Color.White }, 0, 3, i+1, i + 2); romaziExamples.Add (sublayout); } else if (strArray [i * 2 + 4] == "mega- (106)") { StackLayout sublayout=new StackLayout (){ Children = { new Label(){Text="mega- (10"}, new Label(){Text="6",VerticalOptions=LayoutOptions.Start,FontSize=8},new Label(){Text=")"}},Orientation=StackOrientation.Horizontal}; subgrid.Children.Add (new StackLayout (){ Children = { kanalayout, sublayout }, BackgroundColor = Color.White }, 0, 3, i+1, i + 2); romaziExamples.Add (sublayout); } else { subgrid.Children.Add (new StackLayout (){ Children = { kanalayout, romaziExample }, BackgroundColor = Color.White }, 0, 3, i+1, i + 2); romaziExamples.Add (romaziExample); } } } //subgrid.Padding = new Thickness (0, 0, 0, 2); foreach (View e in romaziExamples) e.IsVisible = collapseMode; foreach (View e in kanaExamples) e.IsVisible = collapseMode; grid.Children.Add (new ScrollView(){Content=subgrid}, 0, 3, 5, 6); } } rowTapRecognizer.Tapped += (s, e) => { string kana=((Label)s).Text.ToString().Split(' ')[0]; if(Settings.voice) DependencyService.Get<IAudio>().PlayMp3File("Audio/Examples/"+kana+".mp3"); }; //collapseMode = false; grid.Padding = new Thickness (10, Device.OnPlatform (20, 0, 0), 10, 10); } bottomBar = new StackLayout { VerticalOptions = LayoutOptions.EndAndExpand, Orientation = StackOrientation.Horizontal, BackgroundColor=Color.FromHex("649cef"), Children = { prevButton, nextButton }, }; StackLayout contentLayout = new StackLayout { Orientation = StackOrientation.Vertical, Children = { new ScrollView{ Content = grid }, } }; if (singlemode == 0) contentLayout.Children.Add (bottomBar); Content = contentLayout; }
public BackCard (string kana,StudyCard root,ContentPage drillMode) { NavigationPage.SetHasBackButton (this, false); this.Title = kana; string mode = Character.cData [Character.kana_lookup (kana.Split('\n')[0])]; string pronun = Character.kana_to_romaji (kana.Split('\n')[0]); 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); if (drillMode.GetType () == typeof(Cardfront)) { Image writingImg = new Image (); writingImg.Source=ImageSource.FromFile(DependencyService.Get<IPicture> ().GetPictureFromDisk ("Writing")); grid.Children.Add (writingImg, 1, 1); } grid.Children.Add (new Label { Text = strArray [1], XAlign = TextAlignment.Center, YAlign = TextAlignment.Center, FontSize = 40, TextColor = Color.Maroon }, 1, 2); grid.Children.Add (left, 0, 1, 0, 3); grid.Children.Add (right, 2, 3, 0, 3); // handwriting var leftTapRecognizer = new TapGestureRecognizer (); left.GestureRecognizers.Add (leftTapRecognizer); leftTapRecognizer.Tapped += (s, e) => { DependencyService.Get<IPicture> ().DeletePictureFromDisk ("Writing"); int index=root.drillList.LastIndexOf(drillMode); if(drillMode.GetType()==typeof(Cardfront)) { drillMode=new Cardfront(((Cardfront)drillMode).mCharacter,root); } root.drillList.Add(drillMode); index++; Navigation.InsertPageBefore(root.drillList[index],this); Navigation.PopAsync(); }; var rightTapRecognizer = new TapGestureRecognizer (); right.GestureRecognizers.Add (rightTapRecognizer); rightTapRecognizer.Tapped += async (s, e) => { DependencyService.Get<IPicture> ().DeletePictureFromDisk ("Writing"); int index=root.drillList.LastIndexOf(drillMode); if(index==root.drillList.Count-1) { root.addDrill(); if(root.drillList.Count==0) { // Navigation.PopAsync(); root.addDrill(); } else { index=0; Navigation.InsertPageBefore(root.drillList[0],this); await Navigation.PopAsync(); } } else { index++; Navigation.InsertPageBefore(root.drillList[index],this); await Navigation.PopAsync(); } }; } Content = grid; }
public Cardfront (string character,StudyCard root) { DisplayAlert ("writingcard", "WritingCard", "ok"); var palleteFrame = BuildDrawingFrame (); gridView = new ContentView { Content = palleteFrame, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; Button butErase = new Button { Text = " Erase ", HorizontalOptions = LayoutOptions.End, VerticalOptions=LayoutOptions.Center, BorderWidth=1 }; butErase.Clicked += ButErase_Clicked; grid= new Grid { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition { Height = GridLength.Auto}, new RowDefinition { Height = GridLength.Auto}, new RowDefinition { Height = new GridLength (2, GridUnitType.Star) }, new RowDefinition { Height = new GridLength (1, GridUnitType.Star) }, new RowDefinition {Height = GridLength.Auto}, }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) }, }, Children = { {new Label { Text="Tap outside writing field when done\nUse landscape view for maximum width (tablet only)", XAlign=TextAlignment.Center, YAlign=TextAlignment.Center, TextColor=Color.Gray }, 0,0 }, {butErase,0,1}, {gridView, 0,2 }, {new Label { Text = Character.kana_to_romaji(character), XAlign=TextAlignment.Center, FontSize = 50, YAlign=TextAlignment.Center, },0,3 }, }, Padding=5 }; //backButton.Clicked += async BackButton_Clicked; mCharacter = character; mRoot = root; Content = grid; // Accomodate iPhone status bar. Padding = new Thickness (10, Device.OnPlatform (20, 0, 0), 10, 10); //NavigationPage.SetHasBackButton (this, false); this.Title = "Writing"; var tapGestureRecognizer = new TapGestureRecognizer (); tapGestureRecognizer.Tapped+= TapGestureRecognizer_Tapped; this.Content.GestureRecognizers.Add (tapGestureRecognizer); }
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 (); } }; }
public ExBackCard (string key,string value,StudyCard root,ContentPage drillMode,string kanaMode) { NavigationPage.SetHasBackButton (this, false); this.Title = key.Split(' ')[0]; if (kanaMode.Length > 0) { //changes the title on test mode if (drillMode.GetType () == typeof(ExCardfront)) this.Title = kanaMode.Split (' ') [1] + " Writing"; else if (drillMode.GetType () == typeof(ExampleCard)) this.Title = kanaMode.Split (' ') [1] + " Reading"; } int fontSize1 = 40,fontSize2=20; if (Device.Idiom == TargetIdiom.Tablet) { fontSize1 = 80; fontSize2 = 30; } 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, 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) }, } }; grid.Children.Add (left, 0, 1, 0, 4); grid.Children.Add (right, 2, 3, 0, 4); if (drillMode.GetType () == typeof(ExCardfront)) { Image writingImg = new Image (); writingImg.Source=ImageSource.FromFile(DependencyService.Get<IPicture> ().GetPictureFromDisk ("Writing")); grid.Children.Add (writingImg, 1, 1); } string kanaStr = key.Split (' ') [0]; string romStr = key.Substring (kanaStr.Length+1); if(Settings.voice) DependencyService.Get<IAudio>().PlayMp3File("Audio/Examples/"+kanaStr+".mp3"); grid.Children.Add(new Label{Text=kanaStr,XAlign=TextAlignment.Center,YAlign=TextAlignment.Center,FontSize=fontSize1-kanaStr.Length*2},1,0); grid.Children.Add(new Label{Text=romStr,XAlign=TextAlignment.Center,YAlign=TextAlignment.Center,FontSize=fontSize1-romStr.Length-2,TextColor=Color.Maroon},1,2); string english, english1, english2; if (value == "giga- (109)") { english = "giga- (10"; english1 = "9"; english2 = ")"; } else if (value == "hecto- (102)") { english = "hecto- (10"; english1 = "2"; english2 = ")"; } else if (value == "mega- (106)") { english = "mega- (10"; english1 = "6"; english2 = ")"; } else { english = value; english1 = ""; english2 = ""; } Label englishLabel = new Label (){Text=english,FontSize=fontSize2,XAlign=TextAlignment.Center,YAlign=TextAlignment.Center}; StackLayout sublayout; if (english1.Length > 0) { Label englishLabel1 = new Label () { Text = english1, XAlign = TextAlignment.Center, FontSize = (int)fontSize2 * 0.4, YAlign=TextAlignment.Start }; Label englishLabel2 = new Label (){ FontSize = fontSize2, Text = english2, XAlign = TextAlignment.Center}; sublayout = new StackLayout () { Children = { englishLabel, englishLabel1, englishLabel2 }, Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center }; grid.Children.Add (sublayout, 1, 3); } else { grid.Children.Add(englishLabel,1,3); } Content = grid; var leftTapRecognizer = new TapGestureRecognizer (); left.GestureRecognizers.Add (leftTapRecognizer); leftTapRecognizer.Tapped += (s, e) => { DependencyService.Get<IPicture> ().DeletePictureFromDisk ("Writing"); if(root.GetType()==typeof(CompMenu)) { ((CompMenu)root).wrongCount++; if(drillMode.GetType()==typeof(ExCardfront)) { root.wdrillList.Add(drillMode); CompMenu.wIndex++; ExCardfront orgCard = (ExCardfront)root.wdrillList [CompMenu.wIndex]; ExCardfront nextCard = new ExCardfront (orgCard.mKey, orgCard.mValue, CompMenu.wIndex); Navigation.InsertPageBefore(nextCard,this); } else { root.drillList.Add(drillMode); CompMenu.rIndex++; ExampleCard orgCard = (ExampleCard)root.drillList [CompMenu.rIndex]; ExampleCard nextCard = new ExampleCard (orgCard.mKey, orgCard.mValue, CompMenu.rIndex); Navigation.InsertPageBefore(nextCard,this); } } else { root.testProgress++; if(root.GetType()==typeof(TestPage)) ((TestPage)root).wrongCount++; root.drillList.Add(drillMode); if(root.drillList[root.testProgress].GetType()==typeof(ExampleCard)) { ExampleCard orgCard=(ExampleCard)root.drillList[root.testProgress]; ExampleCard nextCard = new ExampleCard(orgCard.mKey,orgCard.mValue, StudyCard.drillRightCount); Navigation.InsertPageBefore(nextCard,this); } else if(root.drillList[root.testProgress].GetType()==typeof(ExCardfront)) { ExCardfront orgCard=(ExCardfront)root.drillList[root.testProgress]; ExCardfront nextCard = new ExCardfront(orgCard.mKey,orgCard.mValue, StudyCard.drillRightCount); Navigation.InsertPageBefore(nextCard,this); } } Navigation.PopAsync(); }; var rightTapRecognizer = new TapGestureRecognizer (); right.GestureRecognizers.Add (rightTapRecognizer); rightTapRecognizer.Tapped += async (s, e) => { DependencyService.Get<IPicture> ().DeletePictureFromDisk ("Writing"); StudyCard.drillRightCount++; if(root.GetType()!=typeof(CompMenu)) //Test mode { if(root.testProgress==root.drillList.Count-1) { if(root.GetType()!=typeof(TestPage)) // End of test page { root.addDrill(); root.testProgress=0; if(drillMode.GetType()==typeof(ExampleCard)) { Navigation.InsertPageBefore(root.drillList[0],this); await Navigation.PopAsync(); } } else { 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(ExampleCard)) { ExampleCard orgCard=(ExampleCard)root.drillList[root.testProgress]; ExampleCard nextCard = new ExampleCard(orgCard.mKey,orgCard.mValue, StudyCard.drillRightCount); Navigation.InsertPageBefore(nextCard,this); } else if(root.drillList[root.testProgress].GetType()==typeof(ExCardfront)) { ExCardfront orgCard=(ExCardfront)root.drillList[root.testProgress]; ExCardfront nextCard = new ExCardfront(orgCard.mKey,orgCard.mValue, StudyCard.drillRightCount); Navigation.InsertPageBefore(nextCard,this); } await Navigation.PopAsync(); } } else //CompMenu mode { if(drillMode.GetType()==typeof(ExampleCard)) { if(CompMenu.rIndex==root.drillList.Count-1) { var result = await DisplayAlert ("Congratulations!", "You have completed this test", "OK", "Results"); if (result == false) { await DisplayAlert (((CompMenu)root).wrongCount.ToString () +" incorrect responses", "You required " + ((CompMenu)root).wrongCount.ToString () + " retries to answer all questions correctly.", "OK"); } CompMenu.rIndex=0; CompMenu.disableIndex(); root.testProgress=0; } else { CompMenu.rIndex++; CompMenu.rrightCount++; ExampleCard orgCard = (ExampleCard)root.drillList [CompMenu.rIndex]; ExampleCard nextCard = new ExampleCard (orgCard.mKey, orgCard.mValue, CompMenu.rIndex); Navigation.InsertPageBefore(nextCard,this); } await Navigation.PopAsync(); } else if(drillMode.GetType()==typeof(ExCardfront)) { if(CompMenu.wIndex==root.wdrillList.Count-1) { var result = await DisplayAlert ("Congratulations!", "You have completed this test", "OK", "Results"); if (result == false) { await DisplayAlert (((CompMenu)root).wrongCount.ToString () +" incorrect responses", "You required " + ((CompMenu)root).wrongCount.ToString () + " retries to answer all questions correctly.", "OK"); } await Navigation.PopAsync (); CompMenu.wIndex=0; CompMenu.disableIndex(); root.testProgress=0; } else { CompMenu.wIndex++; CompMenu.wrightCount++; ExCardfront orgCard = (ExCardfront)root.wdrillList [CompMenu.wIndex]; ExCardfront nextCard = new ExCardfront (orgCard.mKey, orgCard.mValue, CompMenu.wIndex); Navigation.InsertPageBefore(nextCard,this); } await Navigation.PopAsync(); } } }; }