public VerticalOptionsDemoPage() { Color[] colors = { Color.Yellow, Color.Blue }; int flipFlopper = 0; IEnumerable <Label> labels = from field in typeof(LayoutOptions).GetRuntimeFields() where field.IsPublic && field.IsStatic orderby((LayoutOptions)field.GetValue(null)).Alignment select new Label { Text = "VerticalOptions = " + field.Name, VerticalOptions = (LayoutOptions)field.GetValue(null), HorizontalTextAlignment = TextAlignment.Center, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), TextColor = colors[flipFlopper], BackgroundColor = colors[flipFlopper = 1 - flipFlopper] }; var stackLayout = new StackLayout(); foreach (var label in labels) { stackLayout.Children.Add(label); } Padding = new Thickness(0, DevicePadding.Top(), 0, 0); Content = stackLayout; }
public BlackCatPage() { var mainStack = new StackLayout(); var textStack = new StackLayout { Padding = new Thickness(5), Spacing = 10 }; var assembly = GetType().GetTypeInfo().Assembly; string resource = "PortableApp.Assets.Texts.TheBlackCat.txt"; using (Stream stream = assembly.GetManifestResourceStream(resource)) { using (StreamReader reader = new StreamReader(stream)) { bool gotTitle = false; string line; while ((line = reader.ReadLine()) != null) { var label = new Label { Text = line, TextColor = Color.Black }; if (!gotTitle) { label.HorizontalOptions = LayoutOptions.Center; label.FontSize = Device.GetNamedSize(NamedSize.Medium, label); label.FontAttributes = FontAttributes.Bold; mainStack.Children.Add(label); gotTitle = true; } else { textStack.Children.Add(label); } } } } var scrollView = new ScrollView { Content = textStack, VerticalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(5, 0) }; mainStack.Children.Add(scrollView); Content = mainStack; BackgroundColor = Color.White; Padding = new Thickness(0, DevicePadding.Top(), 0, 0); }
public EstimatedFontSizePage() { label = new Label(); Padding = new Thickness(0, DevicePadding.Top(), 0, 0); var contentView = new ContentView { Content = label }; contentView.SizeChanged += OnContentViewSizeChanged; Content = contentView; }
public EmpiricalFontSizePage() { label = new Label(); Padding = new Thickness(5, DevicePadding.Top(5), 5, 5); var contentView = new ContentView { Content = label }; contentView.SizeChanged += OnContentViewSizeChanged; Content = contentView; }
public TwoButtonsPage() { addButton = new Button { Text = "Add", HorizontalOptions = LayoutOptions.CenterAndExpand }; addButton.Clicked += OnButtonClicked; removeButton = new Button { Text = "Remove", HorizontalOptions = LayoutOptions.CenterAndExpand, IsEnabled = false }; removeButton.Clicked += OnButtonClicked; Padding = new Thickness(5, DevicePadding.Top(5), 5, 0); Content = new StackLayout { Children = { new StackLayout { Orientation = StackOrientation.Horizontal, Children = { addButton, removeButton } }, new ScrollView { VerticalOptions = LayoutOptions.FillAndExpand, Content = loggerLayout } } }; }
public ColorLoopPage() { var colors = new[] { new { value = Color.White, name = "White" }, new { value = Color.Silver, name = "Silver" }, new { value = Color.Gray, name = "Gray" }, new { value = Color.Black, name = "Black" }, new { value = Color.Red, name = "Red" }, new { value = Color.Maroon, name = "Maroon" }, new { value = Color.Yellow, name = "Yellow" }, new { value = Color.Olive, name = "Olive" }, new { value = Color.Lime, name = "Lime" }, new { value = Color.Green, name = "Green" }, new { value = Color.Aqua, name = "Aqua" }, new { value = Color.Teal, name = "Teal" }, new { value = Color.Blue, name = "Blue" }, new { value = Color.Navy, name = "Navy" }, new { value = Color.Pink, name = "Pink" }, new { value = Color.Fuchsia, name = "Fuchsia" }, new { value = Color.Purple, name = "Purple" } }; var stackLayout = new StackLayout(); foreach (var color in colors) { stackLayout.Children.Add( new Label { Text = color.name, TextColor = color.value, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) }); } Padding = new Thickness(5, DevicePadding.Top(), 5, 5); Content = stackLayout; }
public BaskervillesPage() { Content = new Label { VerticalOptions = LayoutOptions.Center, Text = "Mr. Sherlock Holmes, who was usually very late in " + "the mornings, save upon those not infrequent " + "occasions when he was up all night, was seated at " + "the breakfast table. I stood upon the hearth-rug " + "and picked up the stick which our visitor had left " + "behind him the night before. It was a fine, thick " + "piece of wood, bulbous-headed, of the sort which " + "is known as a \u201CPenang lawyer.\u201D Just " + "under the head was a broad silver band, nearly an " + "inch across, \u201CTo James Mortimer, M.R.C.S., " + "from his friends of the C.C.H.,\u201D was engraved " + "upon it, with the date \u201C1884.\u201D It was " + "just such a stick as the old-fashioned family " + "practitioner used to carry\u2014dignified, solid, " + "and reassuring." }; Padding = new Thickness(5, DevicePadding.Top(), 5, 5); }
public ColorBlocksPage() { var stackLayout = new StackLayout(); foreach (var info in typeof(Color).GetRuntimeFields()) { if (info.GetCustomAttribute <ObsoleteAttribute>() != null) { continue; } if (info.IsPublic && info.IsStatic && info.FieldType == typeof(Color)) { stackLayout.Children.Add(CreateColorView((Color)info.GetValue(null), info.Name)); } } Padding = new Thickness(5, DevicePadding.Top(), 5, 5); Content = new ScrollView { Content = stackLayout }; }