public CLFormsEntry() { this.Padding = 0.0; this.RelativePadding = 0.0; this.TextScale = 1.0f; string fontFamily = null; double namedSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)); switch (Device.RuntimePlatform) { default: break; case Device.Android: fontFamily = "fonts/PressStart2P.ttf#PressStart2P"; namedSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)) * 0.8; break; case Device.iOS: fontFamily = "PressStart2P"; namedSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)) * 0.8; break; case Device.WinPhone: case Device.UWP: fontFamily = "Assets/Fonts/PressStart2P.ttf#Press Start 2P"; namedSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)) * 0.5; break; } this.FontFamily = fontFamily; this.FontSize = namedSize; this.BackgroundColor = Color.Transparent; this.TextColor = Color.FromRgb(0, 170, 0); this.HorizontalTextAlignment = TextAlignment.Start; this.TextChanged += (sender, ev) => { CLFormsEntry entry = (sender as CLFormsEntry); string text = ev.NewTextValue; int limit = this.LettersLimit; if (limit > 0 && text.Length > limit) { text = text.Remove(limit); entry.Text = text; } }; }
private View [] InitHackyViews() { var colour = Color.FromRgba(0.0, 0.0, 0.0, 1.0); var tapFieldBoxView = new BoxView() { Color = Color.Transparent }; var bestScoreLabel = new CLFormsLabel() { Text = "0", TextColor = colour, HorizontalTextAlignment = TextAlignment.End }; var userScoreLabel = new CLFormsLabel() { Text = "0", TextColor = colour, HorizontalTextAlignment = TextAlignment.End }; var menuLabel = new CLFormsLabel() { Text = App.Strings.Menu, TextColor = colour }; var startLabel = new CLFormsLabel() { Text = App.Strings.Restart, TextColor = colour }; var resultsLabel = new CLFormsLabel() { Text = App.Strings.Results, TextColor = colour }; var nameEntry = new CLFormsEntry() { Text = "", Keyboard = Keyboard.Text, // IsVisible = false, LettersLimit = 11 }; return(new View [] { tapFieldBoxView, bestScoreLabel, userScoreLabel, menuLabel, startLabel, resultsLabel, nameEntry }); }