Esempio n. 1
0
		public TranKata (string romajiMode)
		{
			rowArray=new List<string[]>();
			drillCount = 212;
			rowCount = 54;
			NavigationPage.SetBackButtonTitle (this, "Table");
			//kana variables
			this.romajiM=romajiMode;

			int i=0;
			foreach(string[] e in rowData)
			{
				if (romajiMode == "Show Romaji") {
					rowData [i] = vRowData [i];
				}
				rowArray.Add (rowData [i]);
				i++;
				
			}

			//Study Button
			ToolbarItem itemStudy = new ToolbarItem {
				Text = "Study",
				Order = ToolbarItemOrder.Primary,
				Command = new Command (() => showStudyPage("Transcr. Katakana"))
			};
			ToolbarItems.Add(itemStudy);
			ToolbarItem itemCollapse;
			if (romajiMode == "Hide Romaji") {
				itemCollapse = new ToolbarItem {
					Icon = "uncollapse.png",
					Order = ToolbarItemOrder.Primary,
					Command = new Command (() => switchMode(romajiMode))
				};
				ToolbarItems.Add(itemCollapse);
			}
			else{
				itemCollapse = new ToolbarItem {
					Icon = "collapse.png",
					Order = ToolbarItemOrder.Primary,
					Command = new Command (() => switchMode(romajiMode))
				};
				ToolbarItems.Add(itemCollapse);
			}
				
			grid = new Grid {
				VerticalOptions = LayoutOptions.Fill,
				HorizontalOptions=LayoutOptions.Fill,
				RowDefinitions = {
					new RowDefinition { Height = GridLength.Auto },
					new RowDefinition { Height = GridLength.Auto },
					new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
					new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
					new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
					new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
					new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
					new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
					new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
					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 (3, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
				}
			};
			 

			// Tap recognizers for letters
			var letterTapRecognizer = new TapGestureRecognizer();
			//Display study page for each kana
			letterTapRecognizer.Tapped += (s, e) => {
				string kana=((Label)s).FormattedText.ToString();
				Navigation.PushAsync (new Study (Character.cData[Character.kana_lookup(kana.Split('\n')[0])],this,0,1){ });
			};

			var monoColTapRecognizer = new TapGestureRecognizer();
			monoColTapRecognizer.Tapped += (s, e) => {
				StudyCarousel studyPage = new StudyCarousel (((Label)s).Text+" Row");
				rowCount=rowList[((Label)s).Text];
				drillCount=rowCount*4;
				addDrill();
				addRow (studyPage);
				studyPage.Children.Add(drillList[0]);
				drillList.RemoveAt(0);
				Navigation.PushAsync (studyPage);
			};
				
			grid.ColumnSpacing = 1;
			grid.RowSpacing = 1;
			Label headerLabel = new Label () {
				Text = "\u2022Tap \"Study\" to begin\n\u2022Tap consonants to select specific rows to study\n\u2022Tap kana to study specific characters\n\u2022Use bracketed romaji for keyboard input\n\u2022Alternative kana spellings in parentheses\n",
				TextColor = Color.Gray,
				XAlign = TextAlignment.Start,
				FontSize=12,
			};
			grid.Children.Add (headerLabel, 0, 9, 0, 1);
			int j = 0;
			string[] vowelRow = {"","A", "I", "U", "E", "O","","YU","YE"} ;
			foreach (string e in vowelRow) 
			{
				if (e.Length > 0) {
					grid.Children.Add (new LetterLabel {
						BackgroundColor = Color.FromHex ("639630"),
						Text = e,
						TextColor = Color.White,
					}, j, 1);
				}
				j++;
			}
			string[] consotantMonoCol = {"Kw", "S", "Z", "T","Ts","D","F","Y","W","V"} ;
			j = 1;
			foreach (string e in consotantMonoCol) {
				j++;
				Label monoLabel = new Label {
					BackgroundColor = Color.FromHex ("639630"),
					Text = e,
					TextColor = Color.White,
					XAlign = TextAlignment.Center,
					YAlign = TextAlignment.Center
				};
				monoLabel.GestureRecognizers.Add (monoColTapRecognizer);
				grid.Children.Add (monoLabel, 0, j);
				rowList.Add (e, j +52);
				
			}

			int r = 2;
			int[] fontSize = new int[]{15,10,13,9};

			if (Device.Idiom == TargetIdiom.Tablet) {
				 fontSize = new int[]{30,20,25,18};
			}
			foreach(string[]rows in rowArray)
			{
				j = 0;
				foreach(string e in rows)
				{
					j++;
					char[] splitters = new char[]{ '/', '\n'};
				//	string replacement =e.Replace('/','\n');
					string [] strArray=e.Split (splitters);
					FormattedString fs=new FormattedString();
					for (int k = 0; k < strArray.Length; k++) {
						fs.Spans.Add (new Span { Text = strArray [k]+"\n", FontSize = fontSize[k] });
						
					}

					Label letter= new LetterLabel {
						FormattedText=fs,
					};
					if (e != "") {
						letter.GestureRecognizers.Add (letterTapRecognizer);
						grid.Children.Add (letter, j, r);
					}
				}
				r++;
			}
			//Accomodate iPhone status bar.
			this.Padding = new Thickness(5, Device.OnPlatform(0, 0, 0), 5, 0);
			this.Content = new ScrollView{Content=grid};
			this.Title = "Transcr. Katakana";

		}
Esempio n. 2
0
		void showToolBar()
		{
			int fontSize;

			addHeadings();
			int k=0, r=2;
			if (mode == "Transcription Katakana") 
			{
				int[] tfontSize = new int[]{15,10,13,9};

				if (Device.Idiom == TargetIdiom.Tablet) {
					tfontSize = new int[]{30,20,25,18};
				}
				r = 1;
				fontSize = 15;
				if (romajiMode == false) {
					char[] splitters = new char[]{ '/', '\n'};
					foreach (string[]rows in rowArray) {
						k = 1;
						foreach (string e in rows) {
							if (!string.IsNullOrEmpty (e)) {
								if (e.Length > 0 && e != "b") {
									string[] strArray = e.Split (splitters);
									FormattedString fs = new FormattedString ();
									for (int l = 0; l < strArray.Length; l++) {
										fs.Spans.Add (new Span { Text = strArray [l] + "\n", FontSize = tfontSize [l] });
									}
									LetterLabel letter = new LetterLabel {
										FontSize = fontSize,
										FormattedText = fs,
									};
									grid.Children.Add (letter, k, r);
								}
							}
							k++;
						}
						r++;
					}
				} else {
					foreach (string[]rows in kanaArray) {
						k = 1;
						foreach (string e in rows) {
							
							if (!string.IsNullOrEmpty (e)) {
								if (e.Length > 0 && e != "b") {
									string[] strArray = e.Split ('\n');
									FormattedString fs = new FormattedString ();
									for (int l = 0; l < strArray.Length; l++) {
										fs.Spans.Add (new Span { Text = strArray [l] + "\n", FontSize = tfontSize [l] });
									}
									LetterLabel letter = new LetterLabel {
										FontSize = fontSize,
										FormattedText = fs,
									};
									grid.Children.Add (letter, k, r);
								}
							}
							k++;
						}
						r++;
					}
				}
			} else {
				if (romajiMode == false) {
					fontSize = 15;
					foreach (string[]rows in rowArray) {
						k = 1;
						foreach (string e in rows) {

							LetterLabel letter = new LetterLabel {
								FontSize = fontSize,
								Text = e,
							};

							if (e != "" && e != "b") {
								if (r == rowArray.Count + 1 && monoMode == true && (mode == "Basic Hiragana" || mode == "Basic Katakana"))
									grid.Children.Add (letter, 0, 1, r, r + 1);
								else
									grid.Children.Add (letter, k, r);
							}
							k++;
						}
						r++;
					}
				} else if (romajiMode == true) {
				
					fontSize = 30;
					foreach (string[]rows in kanaArray) {
						k = 1;
						foreach (string e in rows) {
							LetterLabel letter = new LetterLabel {
								Text = e,
								FontSize = fontSize
							};

							if (e != "" && e != "b") {
								if (r == kanaArray.Count + 1 && monoMode == true && (mode == "Basic Hiragana" || mode == "Basic Katakana"))
									grid.Children.Add (letter, 0, 1, r, r + 1);
								else
									grid.Children.Add (letter, k, r);
							}
							k++;
						}
						r++;
					}
				}
			}
		}
Esempio n. 3
0
		public void addHeadings()
		{
			if (mode == "Transcription Katakana") {
				int j = 0;
				string[] vowelRow = {"","A", "I", "U", "E", "O","","YU","YE"} ;
				foreach (string e in vowelRow) 
				{
					if (e.Length > 0) {
						grid.Children.Add (new LetterLabel {
							BackgroundColor = Color.FromHex ("639630"),
							Text = e,
							TextColor = Color.White,
						}, j, 0);
					}
					j++;
				}
				string[] consotantMonoCol = {"Kw", "S", "Z", "T","Ts","D","F","Y","W","V"} ;
				j = 0;
				foreach (string e in consotantMonoCol) {
					j++;
					Label monoLabel = new Label {
						BackgroundColor = Color.FromHex ("639630"),
						Text = e,
						TextColor = Color.White,
						XAlign = TextAlignment.Center,
						YAlign = TextAlignment.Center
					};
					grid.Children.Add (monoLabel, 0, j);
				}

			} else {
				if (monoMode) {
					var fs = new FormattedString ();
					fs.Spans.Add (new Span { Text = "Monographs", ForegroundColor = Color.White });
					if (mode == "Basic Hiragana" || mode == "Basic Katakana")
						fs.Spans.Add (new Span {
							Text = "\n(Gojūon)",
							ForegroundColor = Color.White,
							FontAttributes = FontAttributes.Italic
						});
					grid.Children.Add (new Label {
						BackgroundColor = Color.FromHex ("2B3359"),
						FormattedText = fs,
						TextColor = Color.White,
						XAlign = TextAlignment.Center,
						YAlign = TextAlignment.Center
					}, 1, 6, 0, 1);
							
					int i = 0;

					string[] vowelRow = { "", "A", "I", "U", "E", "O" };
					foreach (string e in vowelRow) {
						if (e != "") {
							grid.Children.Add (new LetterLabel {
								BackgroundColor = Color.FromHex ("639630"),
								Text = e,
								TextColor = Color.White,
							}, i, 1);

						}
						i++;
					}

					string[] consotantMonoCol = { "∅", "K", "S", "T", "N", "H", "M", "Y", "R", "W" };
					if (mode == "Dakuten Hiragana" || mode == "Dakuten Katakana") {
						consotantMonoCol = new string[]{ "G", "Z", "D", "B", "P" };
					}
						
					i = 1;
					foreach (string e in consotantMonoCol) {
						i++;
						Label monoLabel = new Label {
							BackgroundColor = Color.FromHex ("639630"),
							Text = e,
							TextColor = Color.White,
							XAlign = TextAlignment.Center,
							YAlign = TextAlignment.Center
						};

						grid.Children.Add (monoLabel, 0, i);
					}

				} else {
					var fs2 = new FormattedString ();
					fs2.Spans.Add (new Span { Text = "Digraphs", ForegroundColor = Color.White });
					if (mode == "Basic Hiragana" || mode == "Basic Katakana")
						fs2.Spans.Add (new Span { Text = "\n(Yōon)", ForegroundColor = Color.White, FontAttributes = FontAttributes.Italic });
					grid.Children.Add (new Label {
						BackgroundColor = Color.FromHex ("2B3359"),
						FormattedText = fs2,
						TextColor = Color.White,
						XAlign = TextAlignment.Center,
						YAlign = TextAlignment.Center
					}, 1, 4, 0, 1);
					int i = 0;
					string[] vowelRow = { "", "YA", "YU", "YO" };
					foreach (string e in vowelRow) {
						if (e != "") {
							grid.Children.Add (new LetterLabel {
								BackgroundColor = Color.FromHex ("639630"),
								Text = e,
								TextColor = Color.White,
							}, i, 1);

						}
						i++;
					}
					string[] consotantDiaCol = { "", "K", "S", "T", "N", "H", "M", "", "R" };
					if (mode == "Dakuten Hiragana" || mode == "Dakuten Katakana") {
						consotantDiaCol = new string[] { "", "G", "Z", "D", "B", "P" };
					}
					i = 0;
					int j = 0;
					foreach (string e in consotantDiaCol) {
						i++;
						LetterLabel diaLabel;
						if (e != "") {
							diaLabel = new LetterLabel {
								BackgroundColor = Color.FromHex ("639630"),
								Text = e,
								TextColor = Color.White,
							};

							grid.Children.Add (diaLabel, 0, i);
							j++;
						}

					}
				}
			}
		}
Esempio n. 4
0
		public VoicedHira (string romajiMode)
		{
			drillCount = 68;
			rowCount = 18;
			NavigationPage.SetBackButtonTitle (this, "Table");
			//kana variables
			this.romajiM=romajiMode;
			double fontSize=new LetterLabel().FontSize;
			if (romajiMode == "Hide Romaji") {
				gRow = vRowData[0];
				zRow = vRowData[1];
				dRow = vRowData[2];
				bRow = vRowData[3];
				pRow = vRowData[4];
			}
			else {
				if (Device.Idiom == TargetIdiom.Tablet)
					fontSize = fontSize * 2;
			}
			//Study Button
			ToolbarItem itemStudy = new ToolbarItem {
				Text = "Study",
				Order = ToolbarItemOrder.Primary,
				Command = new Command (() => showStudyPage("Dakuten Hiragana"))
			};
			ToolbarItems.Add(itemStudy);
			ToolbarItem itemCollapse;
			if (romajiMode == "Hide Romaji") {
				itemCollapse = new ToolbarItem {
					Icon = "collapse.png",
					Order = ToolbarItemOrder.Primary,
					Command = new Command (() => switchMode(romajiMode))
				};
				ToolbarItems.Add(itemCollapse);
			}
			else if (romajiMode == "Show Romaji") {
				itemCollapse = new ToolbarItem {
					Icon = "uncollapse.png",
					Order = ToolbarItemOrder.Primary,
					Command = new Command (() => switchMode(romajiMode))
				};
				ToolbarItems.Add(itemCollapse);
			}
				
			grid = new Grid {
				VerticalOptions = LayoutOptions.Fill,
				RowDefinitions = {
					new RowDefinition { Height = GridLength.Auto },
					new RowDefinition { Height = GridLength.Auto },
					new RowDefinition { Height = GridLength.Auto  },
					new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
					new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
					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 (2, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },

				}
			};
			 

			// Tap recognizers for letters
			var letterTapRecognizer = new TapGestureRecognizer();
			//Display study page for each kana
			letterTapRecognizer.Tapped += (s, e) => {

				string kana;
				if(string.IsNullOrEmpty (((Label)s).Text))
					kana=((Label)s).FormattedText.ToString();

				else
					kana=((Label)s).Text;
				Navigation.PushAsync (new Study (Character.cData[Character.kana_lookup(kana.Split('\n')[0])],this,0,1){ });
			};


			var monoColTapRecognizer = new TapGestureRecognizer();
			monoColTapRecognizer.Tapped += (s, e) => {
				StudyCarousel studyPage = new StudyCarousel (((Label)s).Text+" Row");
				rowCount=rowList[((Label)s).Text]+17;
				drillCount=rowCount*4;
				addDrill();
				addRow (studyPage);
				studyPage.Children.Add(drillList[0]);
				drillList.RemoveAt(0);
				Navigation.PushAsync (studyPage);
			};
			var diaColTapRecognizer = new TapGestureRecognizer();
			diaColTapRecognizer.Tapped += (s, e) => {
				StudyCarousel studyPage = new StudyCarousel (((Label)s).Text+" Row");
				rowCount=rowList[((Label)s).Text+"2"]+17;
				drillCount=rowCount*4;
				addDrill();
				addRow (studyPage);

				studyPage.Children.Add(drillList[0]);
				drillList.RemoveAt(0);
				Navigation.PushAsync (studyPage);
			};
	
			grid.ColumnSpacing = 1;
			grid.RowSpacing = 1;

			var fs = new FormattedString ();
			fs.Spans.Add (new Span { Text="Monographs", ForegroundColor = Color.White });

			grid.Children.Add (new Label () {
				Text = "\u2022Tap \"Study\" to begin\n\u2022Tap consonants to select specific rows to study\n\u2022Tap kana to study specific characters\n\u2022Use bracketed romaji for keyboard input\n\u2022Gray font indicates obsolete or seldom used kana\n",
				TextColor = Color.Gray,
				XAlign=TextAlignment.Start,
				FontSize=12,
					
			}, 0, 10, 0, 1);
			grid.Children.Add(new Label {
				BackgroundColor = Color.FromHex("2B3359"),
				FormattedText = fs,
				TextColor=Color.White,
				XAlign = TextAlignment.Center,
				YAlign = TextAlignment.Center
				}, 1,6,1,2);

			var fs2 = new FormattedString ();
			fs2.Spans.Add (new Span { Text="Digraphs", ForegroundColor = Color.White });

			grid.Children.Add(new Label {
				BackgroundColor = Color.FromHex("2B3359"),
				FormattedText = fs2,
				TextColor=Color.White,
				XAlign = TextAlignment.Center,
				YAlign = TextAlignment.Center
				}, 7,10,1,2);
			int i = 0;

			string[] vowelRow = {"","A", "I", "U", "E", "O","","YA","YU","YO"} ;
			foreach (string e in vowelRow) {
				if (e != "") {
					grid.Children.Add (new LetterLabel {
						BackgroundColor = Color.FromHex ("639630"),
						Text = e,
						TextColor = Color.White,
					}, i, 2);

				}
				i++;
			}
			string[] consotantMonoCol = {"G", "Z", "D", "B","P"} ;
			i = 2;
			foreach (string e in consotantMonoCol) {
				i++;
				Label monoLabel = new Label {
					BackgroundColor = Color.FromHex ("639630"),
					Text = e,
					TextColor = Color.White,
					XAlign = TextAlignment.Center,
					YAlign = TextAlignment.Center
				};
				monoLabel.GestureRecognizers.Add (monoColTapRecognizer);
				grid.Children.Add (monoLabel, 0, i);
				rowList.Add (e, i - 2);
				
			}
			string[] consotantDiaCol = {"G", "Z", "D", "B","P"} ;
			i = 2;
			int j = 0;
			foreach (string e in consotantDiaCol) {
				i++;
				LetterLabel diaLabel;
				diaLabel = new LetterLabel {
					BackgroundColor = Color.FromHex ("639630"),
					Text = e,
					TextColor = Color.White,
				};
				grid.Children.Add (diaLabel, 6, i);
				if(i!=5)
				{
					diaLabel.GestureRecognizers.Add (diaColTapRecognizer);
					rowList.Add (e+"2", j+6);
					j++;
				}
			}

			i = 0;
			foreach(string e in gRow)
			{
				i++;
				LetterLabel letter= new LetterLabel {
					Text = e,
					FontSize=fontSize
				};
				if (e != "") {
					letter.GestureRecognizers.Add (letterTapRecognizer);
					grid.Children.Add (letter, i, 3);
				}
			}


			//K row

			i = 0;
			foreach(string e in zRow)
			{
				i++;
				if (e != "") {
					LetterLabel letter= new LetterLabel {
						Text = e,
						FontSize=fontSize
					};
					letter.GestureRecognizers.Add (letterTapRecognizer);
					grid.Children.Add (letter, i, 4);
				}
			}
			//S row

			i = 0;
			foreach(string e in dRow)
			{	
				i++;
				if (e != "") {
					string[]strArray=e.Split('/');
					FormattedString fs3=new FormattedString();
					fs3.Spans.Add(new Span(){Text=strArray[0],FontSize=fontSize});
					if(strArray.Length>1)
						fs3.Spans.Add(new Span(){Text="\n"+strArray[1],FontSize=fontSize-5});
					LetterLabel letter = new LetterLabel {
						FormattedText=fs3

					};
					if (i < 7) {
						letter.GestureRecognizers.Add (letterTapRecognizer);
					} else {
						letter.IsEnabled = false;
						letter.TextColor = Color.Gray;
					}
					grid.Children.Add (letter, i, 5);
				}
			}

			//T row

			i = 0;
			foreach(string e in bRow)
			{
				i++;
				if (e != "") {
					LetterLabel letter= new LetterLabel {
						Text = e,
						FontSize=fontSize
					};
					letter.GestureRecognizers.Add (letterTapRecognizer);
					grid.Children.Add (letter, i, 6);
				}
			}
			//N row

			i = 0;
			foreach(string e in pRow)
			{
				i++;
				if (e != "") {
					LetterLabel letter= new LetterLabel {
						Text = e,
						FontSize=fontSize
					};
					letter.GestureRecognizers.Add (letterTapRecognizer);
					grid.Children.Add (letter, i, 7);
				}
			}
			//H row


			//Accomodate iPhone status bar.
			//this.Padding = new Thickness(5, Device.OnPlatform(0, 0, 0), 5, 0);

			//Build the page.
			//grid.BackgroundColor=Device.OnPlatform(Color.Black,Color.White,Color.White);
			this.Content = new ScrollView{Content=grid};
			this.Title = "Dakuten Hiragana";

		}
Esempio n. 5
0
		public UnvoicedHira (string romajiMode)
		{
			drillCount = 0;
			rowCount = 0;
			NavigationPage.SetBackButtonTitle (this, "Table");
			//kana variables
			this.romajiM=romajiMode;
			double fontSize=new LetterLabel().FontSize;
			if (romajiMode == "Hide Romaji") {
				nullMonoRow = uvRowData [0];
				kRow = uvRowData [1];
				sRow = uvRowData [2];
				tRow = uvRowData [3];
				nRow = uvRowData [4];
				hRow = uvRowData [5];
				mRow = uvRowData [6];
				yRow = uvRowData [7];
				rRow = uvRowData [8];
				wRow = uvRowData [9];
			} else {
				if (Device.Idiom == TargetIdiom.Tablet)
					fontSize = fontSize * 2;
			}

			//Study Button
			ToolbarItem itemStudy = new ToolbarItem {
				Text = "Study",
				Order = ToolbarItemOrder.Primary,
				Command = new Command (() => showStudyPage("Basic Hiragana"))
			};
			ToolbarItems.Add(itemStudy);
			ToolbarItem itemCollapse;
			if (romajiMode == "Hide Romaji") {
				itemCollapse = new ToolbarItem {
					
					Icon = "collapse.png",
					Order = ToolbarItemOrder.Primary,
					Command = new Command (() => switchMode(romajiMode))
				};
				ToolbarItems.Add(itemCollapse);
			}
			else if (romajiMode == "Show Romaji") {
				itemCollapse = new ToolbarItem {
					
					Icon = "uncollapse.png",
					Order = ToolbarItemOrder.Primary,
					Command = new Command (() => switchMode(romajiMode)),

				};
				ToolbarItems.Add(itemCollapse);

			}

			if (romajiMode == "Show Romaji") {
				grid = new Grid {
					VerticalOptions = LayoutOptions.Fill,
					RowDefinitions = {
						new RowDefinition { Height = GridLength.Auto },
						new RowDefinition { Height = GridLength.Auto },
						new RowDefinition { Height = GridLength.Auto  },
						new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
						new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
						new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
						new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
						new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
						new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
						new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
						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 (2, GridUnitType.Star) },
						new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
						new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
						new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
						new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
						new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
						new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
						new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
						new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
						new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },

					}
				};
			} else {
				if (Device.Idiom == TargetIdiom.Tablet) {
					grid = new Grid {
						VerticalOptions = LayoutOptions.Fill,
						RowDefinitions = {
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto  },
							new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
							new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
							new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
							new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
							new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
							new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
							new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
							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 (2, GridUnitType.Star) },
							new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
							new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
							new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
							new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
							new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
							new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
							new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
							new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
							new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },

						}
					};
				} else {
					grid = new Grid {
						VerticalOptions = LayoutOptions.Fill,
						RowDefinitions = {
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
						},
						ColumnDefinitions = {
							new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
							new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
							new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
							new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
							new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
							new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
							new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
							new ColumnDefinition { Width = new GridLength (4, GridUnitType.Star) },
							new ColumnDefinition { Width = new GridLength (4, GridUnitType.Star) },
							new ColumnDefinition { Width = new GridLength (4, GridUnitType.Star) },
						}
					};
				}
			}

			// Tap recognizers for letters
			var letterTapRecognizer = new TapGestureRecognizer();
			//Display study page for each kana
			letterTapRecognizer.Tapped += (s, e) => {
				
				string kana=((Label)s).Text;
				if(kana==null)
					kana=((Label)s).FormattedText.ToString();
				Navigation.PushAsync (new Study (Character.cData[Character.kana_lookup(kana.Split('\n')[0])],this,0,1){ });
			};

			var monoColTapRecognizer = new TapGestureRecognizer();
			monoColTapRecognizer.Tapped += (s, e) => {
				StudyCarousel studyPage = new StudyCarousel (((Label)s).Text+" Row");
				rowCount=rowList[((Label)s).Text];
				drillCount=rowCount*4;

				addDrill();
				addRow (studyPage);
				studyPage.Children.Add(drillList[0]);
				drillList.RemoveAt(0);
				Navigation.PushAsync (studyPage);
			};
			var diaColTapRecognizer = new TapGestureRecognizer();
			diaColTapRecognizer.Tapped += (s, e) => {
				StudyCarousel studyPage = new StudyCarousel (((Label)s).Text+" Row");
				rowCount=rowList[((Label)s).Text+"2"];
				drillCount=rowCount*4;
				addDrill();
				addRow (studyPage);

				studyPage.Children.Add(drillList[0]);
				drillList.RemoveAt(0);
				Navigation.PushAsync (studyPage);
			};
	
			grid.ColumnSpacing = 1;
			grid.RowSpacing = 1;

			var fs = new FormattedString ();
			fs.Spans.Add (new Span { Text="Monographs\n", ForegroundColor = Color.White });
			fs.Spans.Add (new Span { Text="(Gojūon)", ForegroundColor = Color.White, FontAttributes = FontAttributes.Italic });
			Label headerLabel = new Label () {
				Text = "\u2022Tap \"Study\" to begin\n\u2022Tap consonants to select specific rows to study\n\u2022Tap kana to study specific characters\n\u2022Gray font indicates obsolete or seldom used kana\n",
				TextColor = Color.Gray,
				XAlign = TextAlignment.Start,
				FontSize=12,
			};
			grid.Children.Add (headerLabel, 0, 10, 0, 1);

			grid.Children.Add(new Label {
				BackgroundColor = Color.FromHex("2B3359"),
				FormattedText = fs,
				TextColor=Color.White,
				XAlign = TextAlignment.Center,
				YAlign = TextAlignment.Center
				}, 1,6,1,2);

			var fs2 = new FormattedString ();
			fs2.Spans.Add (new Span { Text="Digraphs\n", ForegroundColor = Color.White });
			fs2.Spans.Add (new Span { Text="(Yōon)", ForegroundColor = Color.White, FontAttributes = FontAttributes.Italic });
			grid.Children.Add(new Label {
				BackgroundColor = Color.FromHex("2B3359"),
				FormattedText = fs2,
				TextColor=Color.White,
				XAlign = TextAlignment.Center,
				YAlign = TextAlignment.Center
				}, 7,10,1,2);
			int i = 0;

			string[] vowelRow = {"","A", "I", "U", "E", "O","","YA","YU","YO"} ;
			foreach (string e in vowelRow) {
				if (e != "") {
					grid.Children.Add (new LetterLabel {
						BackgroundColor = Color.FromHex ("639630"),
						Text = e,
						TextColor = Color.White,
					}, i, 2);

				}
				i++;
			}
			string[] consotantMonoCol = {"∅", "K", "S", "T", "N","H","M","Y","R","W"} ;
			i = 2;
			foreach (string e in consotantMonoCol) {
				i++;
				Label monoLabel = new Label {
					BackgroundColor = Color.FromHex ("639630"),
					Text = e,
					TextColor = Color.White,
					XAlign = TextAlignment.Center,
					YAlign = TextAlignment.Center
				};
				monoLabel.GestureRecognizers.Add (monoColTapRecognizer);
				grid.Children.Add (monoLabel, 0, i);
				rowList.Add (e, i - 3);
				
			}
			string[] consotantDiaCol = {"", "K", "S", "T", "N","H","M","","R",""} ;
			i = 2;
			int j = 0;
			foreach (string e in consotantDiaCol) {
				i++;
				LetterLabel diaLabel;
				if (e != "") {
					diaLabel = new LetterLabel {
						BackgroundColor = Color.FromHex ("639630"),
						Text = e,
						TextColor = Color.White,
					};
					diaLabel.GestureRecognizers.Add (diaColTapRecognizer);
					grid.Children.Add (diaLabel, 6, i);
					rowList.Add (e+"2", j+11);
					j++;
				}

			}

			i = 0;
			foreach(string e in nullMonoRow)
			{
				i++;
				LetterLabel letter= new LetterLabel {
					Text = e,
					FontSize=fontSize
				};
				if (e != "") {
					letter.GestureRecognizers.Add (letterTapRecognizer);
					grid.Children.Add (letter, i, 3);
				}
			}
			for(i=7;i<10;i++)
			{
				grid.Children.Add(new BoxView {
					Color=Color.FromHex("BFBFBF")
				}, i,3);
			}

			//K row

			i = 0;

			foreach(string e in kRow)
			{
				i++;
				if (e != "") {
					LetterLabel letter= new LetterLabel {
						Text = e,
						FontSize=fontSize
					};
					letter.GestureRecognizers.Add (letterTapRecognizer);
					grid.Children.Add (letter, i, 4);
				}
			}
			//S row

			i = 0;
			foreach(string e in sRow)
			{
				i++;
				if (e != "") {
					LetterLabel letter= new LetterLabel {
						Text = e,
						FontSize=fontSize
					};
					letter.GestureRecognizers.Add (letterTapRecognizer);
					grid.Children.Add (letter, i, 5);
				}
			}

			//T row

			i = 0;
			foreach(string e in tRow)
			{
				i++;
				if (e != "") {
					LetterLabel letter= new LetterLabel {
						Text = e,
						FontSize=fontSize
					};
					letter.GestureRecognizers.Add (letterTapRecognizer);
					grid.Children.Add (letter, i, 6);
				}
			}
			//N row

			i = 0;
			foreach(string e in nRow)
			{
				i++;
				if (e != "") {
					LetterLabel letter= new LetterLabel {
						Text = e,
						FontSize=fontSize
					};
					letter.GestureRecognizers.Add (letterTapRecognizer);
					grid.Children.Add (letter, i, 7);
				}
			}
			//H row

			i = 0;
			foreach(string e in hRow)
			{
				i++;
				if (e != "") {
					LetterLabel letter= new LetterLabel {
						Text = e,
						FontSize=fontSize
					};
					letter.GestureRecognizers.Add (letterTapRecognizer);
					grid.Children.Add (letter, i, 8);
				}
			}
			//M row

			i = 0;
			foreach(string e in mRow)
			{
				i++;
				if (e != "") {
					
					LetterLabel letter= new LetterLabel {
						Text = e,
						FontSize=fontSize
					};
					letter.GestureRecognizers.Add (letterTapRecognizer);
					if (i == 8) {
						letter.TextColor = Color.Gray;
						letter.IsEnabled = false;
						letter.GestureRecognizers.Remove (letterTapRecognizer);
					}

					grid.Children.Add (letter, i, 9);
				}
			}
			//Y row

			i = 0;
			foreach(string e in yRow)
			{
				i++;
				if (e != "" && e!="b") {
					LetterLabel letter= new LetterLabel {
						Text = e,
						FontSize=fontSize
					};
					letter.GestureRecognizers.Add (letterTapRecognizer);
					grid.Children.Add (letter, i, 10);
				}
				if (e == "b") {
					grid.Children.Add (new BoxView {
						Color = Color.FromHex("BFBFBF")
					}, i, 10);
				}
			}

			//R row

			i = 0;
			foreach(string e in rRow)
			{
				i++;
				if (e != "") {
					LetterLabel letter= new LetterLabel {
						Text = e,
						FontSize=fontSize
					};

					letter.GestureRecognizers.Add (letterTapRecognizer);
					grid.Children.Add (letter, i, 11);
				}
			}

			//W row

			i = 0;
			foreach(string e in wRow)
			{
				i++;
				if (e != "" && e!="b") {
					LetterLabel letter= new LetterLabel {
						
					};
					if(i==5)
					{
						char[] splitters = new char[]{ '/', '\n'};
						string [] strArray=e.Split (splitters);
						FormattedString fs3=new FormattedString();
						fs3.Spans.Add (new Span { Text = strArray [0],FontSize=fontSize});
						if(strArray.Length>1)
							fs3.Spans.Add (new Span { Text ="\n"+strArray [1], FontSize = fontSize-4 });
						letter.FormattedText=fs3;
					}
					else
					{
						letter.Text=e;
						letter.FontSize = fontSize;
					}
					letter.GestureRecognizers.Add (letterTapRecognizer);
					if (i == 2 || i == 4) {
						letter.TextColor = Color.Gray;
						letter.IsEnabled = false;
						letter.GestureRecognizers.Remove (letterTapRecognizer);
					}
					grid.Children.Add (letter, i, 12);
				}
				if (e == "b") {
					grid.Children.Add (new BoxView {
						Color = Color.FromHex("BFBFBF")
					}, i, 12);
				}
			}

			string nText="ん\nn";
			if (romajiMode == "Show Romaji")
				nText = "ん";
			LetterLabel nletter=new LetterLabel (){Text=nText,HorizontalOptions=LayoutOptions.FillAndExpand,FontSize=fontSize};
			nletter.GestureRecognizers.Add (letterTapRecognizer);
			grid.Children.Add (nletter, 0, 1, 13, 14);
			//Accomodate iPhone status bar.
			//this.Padding = new Thickness(5, Device.OnPlatform(0, 0, 0), 5, 0);

			//Build the page.
			//grid.BackgroundColor=Device.OnPlatform(Color.Black,Color.White,Color.White);
			this.Content = new ScrollView{Content=grid};
			this.Title = "Basic Hiragana";

		}
Esempio n. 6
0
		void showToolBar()
		{
			grid = new Grid {
				VerticalOptions = LayoutOptions.Fill,
				HorizontalOptions=LayoutOptions.Fill,					
			};

			grid.ColumnSpacing = 1;
			grid.RowSpacing = 1;
			for (int i = 0; i <= endRow-startRow-1; i++)
				grid.RowDefinitions.Add (new RowDefinition { Height = new GridLength (1, GridUnitType.Star) });
			for (int j = 0; j < colCount; j++)
				grid.ColumnDefinitions.Add (new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) }); 

			int k=0, r=0;
			List<string> strArray = new List<string> ();
			if (romajiMode == false)
				strArray = rowArray;
			else
				strArray = kanaArray;
			for(int i=0;i<strArray.Count;i++)
			{
				string e = strArray [rndArray [i]];
				LetterLabel letter = new LetterLabel {
					Text = e,
					BackgroundColor=Color.White
				};
				if (romajiMode == true)
					letter.FontSize = 30;
				if (e != "" && e != "b") {
					grid.Children.Add (letter, k, r);
				}
				k++;
				if (k == colCount) {
					k = 0;
					r++;
				}
			}

			grid.Padding = new Thickness (5, Device.OnPlatform (0, 5, 5), 5, 0);
			this.Content =new ScrollView{Content=grid};
		}