public ABCTextPage() { InitializeComponent(); if (Test.current.probiha) { Uspesnost = Test.current.procentHotovo; } else { Uspesnost = "Správně : " + Statistika.Current.Procent_uspesnost.ToString() + "%"; Pokracovat_butt.IsEnabled = true; } Otazka otzk = NactiOtazku(); BodyInt = otzk.Bodu; Body = otzk.Bodu.ToString(); if (otzk.Bodu == 1) { Body += " bod"; } else if (otzk.Bodu < 5) { Body += " body"; } else { Body += " bodů"; } Ukol = otzk.Ukol.Replace("\n", "").Trim(); while (Ukol.Contains(" ")) { Ukol = Ukol.Replace(" ", " "); } NeupravenyText = otzk.Text; Text = FormatovacTextu.Uprav(otzk.Text); int index = 1; foreach (String moznost in otzk.Moznosti.Moznost) { kontrolaDelegates.Add(delegate { KontrolaOdpovedi(moznost.Trim()[0], otzk.Spravna[0]); }); Button button = new Button { Text = Regex.Replace(moznost, @"\s+", " "), VerticalOptions = Xamarin.Forms.LayoutOptions.Center, StyleClass = new List <string>() { "Tlacitko_odpoved" } }; myStackLayout.Children.Insert(index + 3, button); button.Clicked += kontrolaDelegates[index - 1]; index++; } BindingContext = this; }
public OtevrenaTextPage() { InitializeComponent(); if (Test.current.probiha) { Uspesnost = Test.current.procentHotovo; } else { Uspesnost = "Správně : " + Statistika.Current.Procent_uspesnost.ToString() + "%"; Pokracovat_butt.IsEnabled = true; } Otazka otzk = NactiOtazku(); Body = otzk.Bodu.ToString(); BodyInt = otzk.Bodu; Spravna = otzk.Spravna.Trim().ToLower(); if (otzk.Bodu == 1) { Body += " bod"; } else if (otzk.Bodu < 5) { Body += " body"; } else { Body += " bodů"; } Ukol = otzk.Ukol.Replace("\n", " ").Trim(); while (Ukol.Contains(" ")) { Ukol = Ukol.Replace(" ", " "); } NeupravenyText = otzk.Text; Text = FormatovacTextu.Uprav(otzk.Text); BindingContext = this; }
public AnoNeTextPage() { InitializeComponent(); if (Test.current.probiha) { Uspesnost = Test.current.procentHotovo; } else { Uspesnost = "Správně : " + Statistika.Current.Procent_uspesnost.ToString() + "%"; Pokracovat_butt.IsEnabled = true; } Otazka otzk = NactiOtazku(); Body = otzk.Bodu.ToString(); Spravne = otzk.Spravna; if (otzk.Bodu == 1) { Body += " bod"; } else if (otzk.Bodu < 5) { Body += " body"; } else { Body += " bodů"; } Ukol = otzk.Ukol.Replace("\n", " ").Replace(" ", " ").Trim(); while (Ukol.Contains(" ")) { Ukol = Ukol.Replace(" ", " "); } NeupravenyText = otzk.Text; Text = FormatovacTextu.Uprav(otzk.Text); foreach (string m in otzk.Moznosti.Moznost) { string moznost = m.Replace("\n", " "); while (moznost.Contains(" ") || moznost.Contains(" ")) { moznost = moznost.Replace(" ", " ").Replace(" ", " "); } moznosti.Add(moznost); } //Vložení úkolů a switchů pro volbu int index = 0; foreach (String moznost in moznosti) { StackLayout layout = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; FontSizeConverter fontSizeConverter = new FontSizeConverter(); Label label = new Label { Text = moznost.Replace("\n", " ").Replace(" ", " ").Trim(), TextColor = Color.Black, FontSize = (Double)fontSizeConverter.ConvertFromInvariantString("Small"), //VerticalOptions = Xamarin.Forms.LayoutOptions.Center, Margin = new Thickness(15, 1, 0, 0), HorizontalOptions = LayoutOptions.StartAndExpand }; layout.Children.Add(label); Switch switchA = new Switch(); layout.Children.Add(switchA); HlavniStackLayout.Children.Insert(index + 5, layout); index++; } BindingContext = this; }