private StackLayout CreatePalletStack() { BuildColorPallete(); var stack = new StackLayout { Spacing = PalleteSpacing, Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.FillAndExpand }; stack.SizeChanged += OnStackSizeChanged; foreach (var button in ColorPallete.Select(color => new Button { Text = color.Key, TextColor = GetTextColor(color.Value), BackgroundColor = color.Value, Font = Font.BoldSystemFontOfSize(NamedSize.Medium), })) { button.Clicked += OnButtonClicked; stack.Children.Add(button); } return(stack); }
protected override void Init() { var generatedImage = new Image { Aspect = Aspect.AspectFit }; var btn = new Button { Text = "generate" }; btn.Clicked += (sender, e) => { var source = GenerateBmp(60, 60, Color.Red); generatedImage.Source = source; }; Content = new StackLayout { Children = { btn, #pragma warning disable 618 new Label { Text = "GeneratedImage",Font = Font.BoldSystemFontOfSize(NamedSize.Medium) }, #pragma warning restore 618 generatedImage }, Padding = new Thickness(0, 20, 0, 0), VerticalOptions = LayoutOptions.StartAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand }; }
View CreateColorView(Color color, string name) { return(new Frame { OutlineColor = Color.Accent, Padding = new Thickness(5), Content = new StackLayout { Orientation = StackOrientation.Horizontal, Spacing = 15, Children = { new BoxView { Color = color }, new Label { Text = name, Font = Font.BoldSystemFontOfSize(NamedSize.Medium), VerticalOptions = LayoutOptions.Center }, new Label { Text = String.Format("{0:X2}-{1:X2}-{2:X2}", (int)(255 * color.R), (int)(255 * color.G), (int)(255 * color.B)), VerticalOptions = LayoutOptions.Center, IsVisible = color != Color.Default } } } }); }
public ActivityIndicatorDemoPage() { Label header = new Label { Text = "ActivityIndicator", Font = Font.BoldSystemFontOfSize(40), HorizontalOptions = LayoutOptions.Center }; ActivityIndicator activityIndicator = new ActivityIndicator { Color = Device.OnPlatform(Color.Black, Color.Default, Color.Default), IsRunning = true, VerticalOptions = LayoutOptions.CenterAndExpand }; // Accomodate iPhone status bar. this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); // Build the page. this.Content = new StackLayout { Children = { header, activityIndicator } }; }
public BoxViewDemoPage() { Label header = new Label { Text = "BoxView", Font = Font.BoldSystemFontOfSize(50), HorizontalOptions = LayoutOptions.Center }; BoxView boxView = new BoxView { Color = Color.Accent, WidthRequest = 150, HeightRequest = 150, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand }; // Accomodate iPhone status bar. this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); // Build the page. this.Content = new StackLayout { Children = { header, boxView } }; }
public SpotListPage() { Title = "Spots"; Label header = new Label { Text = "Welcome Matt!", Font = Font.BoldSystemFontOfSize(30), HorizontalOptions = LayoutOptions.Center }; spotListView = new ListView() { ItemsSource = MineAppServices.Current.NearSpots }; var cell = new DataTemplate(typeof(TextCell)); cell.SetBinding(TextCell.TextProperty, "Name"); cell.SetBinding(TextCell.DetailProperty, "Description"); Content = new StackLayout() { Children = { header, spotListView } }; }
public static StackLayout GetAnswers_byUsers_forMulible(int progress, int j, List <User> userNames, string choice) { StackLayout stackTotal = new StackLayout() { Spacing = 4, Children = { new Label { Text = j + "- " + choice, FontSize = 19, HorizontalOptions = LayoutOptions.StartAndExpand }, } }; for (int i = 0; i < userNames.Count; i++) { StackLayout stack = new StackLayout() { Orientation = StackOrientation.Horizontal, Children = { new Label { Text = "- " + Surveys_Manager.Lang.Resource.AnsweredBy, FontSize = 17, HorizontalOptions = LayoutOptions.StartAndExpand }, new Label { Text = " " + userNames.ElementAt(i).UserName, TextColor = Color.FromHex("4597f3"), FontSize = 18, FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.End } } }; stackTotal.Children.Add(stack); } stackTotal.Children.Add( new Grid { Children = { new CrossPieChartView { Progress = progress, ProgressColor = Color.Green, ProgressBackgroundColor = Color.FromHex("#EEEEEEEE"), StrokeThickness = Device.OnPlatform(10, 20, 80), Radius = Device.OnPlatform(100, 180, 160) }, new Label { Text = progress + "%", Font = Font.BoldSystemFontOfSize(NamedSize.Large), FontSize = 70, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, TextColor = Color.Black } } }); stackTotal.Children.Add(new Label { BackgroundColor = Color.FromHex("a7cefb"), HeightRequest = 2 }); return(stackTotal); }
public IngredientView() { Button back = new Button { Text = "Back", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start }; back.Clicked += (sender, e) => { Navigation.PopModalAsync(); }; var client = new HttpClient(); string url = "http://api.kitchen.support/pantry?offset=0&limit=30&api_token="; string token = DependencyService.Get <localDataInterface>().load("token"); url += token; var response = client.GetStringAsync(new Uri(url)); var ye = response.Result; List <ingredient> ingredients = parseIngredients(response.Result); Label header = new Label { Text = "Your Ingredients", Font = Font.BoldSystemFontOfSize(50), HorizontalOptions = LayoutOptions.Center }; listview = new ListView { RowHeight = 30 }; listview.ItemsSource = ingredients; listview.ItemTemplate = new DataTemplate(typeof(TextCell)); listview.ItemTemplate.SetBinding(TextCell.TextProperty, ".term"); Button button = new Button(); button.Text = "Add Ingredient"; button.Clicked += (sender, e) => { ingredient newIngredient = new ingredient(); Navigation.PushModalAsync(new AddIngredient(newIngredient)); }; // Build the page. this.Content = new StackLayout { Children = { back, header, listview, button } }; }
public WebViewDemoPage() { Label header = new Label { Text = "WebView", Font = Font.BoldSystemFontOfSize(50), HorizontalOptions = LayoutOptions.Center }; WebView webView = new WebView { Source = new UrlWebViewSource { Url = "http://blog.xamarin.com/", }, VerticalOptions = LayoutOptions.FillAndExpand }; // Accomodate iPhone status bar. this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); // Build the page. this.Content = new StackLayout { Children = { header, webView } }; }
/// <summary> /// Makes a ContentPage with samples of PieCharts. /// </summary> /// <returns></returns> public ContentPage GetPageWithPieChart() { // The root page of your application var contentPage = new ContentPage { Content = new Grid { Children = { new CrossPieChartView { Progress = 10, ProgressColor = Color.Green, ProgressBackgroundColor = Color.FromHex("#EEEEEEEE"), StrokeThickness = Device.OnPlatform(10, 20, 80), Radius = Device.OnPlatform(100, 180, 160), BackgroundColor = Color.White }, new Label { Text = "10%", Font = Font.BoldSystemFontOfSize(NamedSize.Large), FontSize = 70, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, TextColor = Color.Black } } } }; return(contentPage); }
public LoadResourceXml() { #region How to load an XML file embedded resource var assembly = typeof(LoadResourceText).GetTypeInfo().Assembly; Stream stream = assembly.GetManifestResourceStream("WorkingWithFiles.PCLXmlResource.xml"); List <Monkey> monkeys; using (var reader = new System.IO.StreamReader(stream)) { var serializer = new XmlSerializer(typeof(List <Monkey>)); monkeys = (List <Monkey>)serializer.Deserialize(reader); } #endregion var listView = new ListView(); listView.ItemsSource = monkeys; Content = new StackLayout { Padding = new Thickness(0, 20, 0, 0), VerticalOptions = LayoutOptions.StartAndExpand, Children = { new Label { Text = "Embedded Resource XML File (PCL)", Font = Font.BoldSystemFontOfSize(NamedSize.Medium) } , listView } }; // NOTE: use for debugging, not in released app code! //foreach (var res in assembly.GetManifestResourceNames()) // System.Diagnostics.Debug.WriteLine("found resource: " + res); }
public LabelDemoPage() { Label header = new Label { Text = "Label", Font = Font.BoldSystemFontOfSize(50), HorizontalOptions = LayoutOptions.Center }; Label label = new Label { Text = "Xamarin.Forms is a cross-platform natively " + "backed UI toolkit abstraction that allows " + "developers to easily create user interfaces " + "that can be shared across Android, iOS, and " + "Windows Phone.", Font = Font.SystemFontOfSize(NamedSize.Large), VerticalOptions = LayoutOptions.CenterAndExpand }; // Accomodate iPhone status bar. this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); // Build the page. this.Content = new StackLayout { Children = { header, label } }; }
public MainPageCode() { BackgroundColor = Color.Silver; Label header = new Label { Text = "Press button to start 2 min. 'alarm'", Font = Font.BoldSystemFontOfSize(20), HorizontalOptions = LayoutOptions.Center }; Button button = new Button { Text = "Click Me!", Font = Font.SystemFontOfSize(NamedSize.Large), BorderWidth = 1, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand }; button.Clicked += BtnAlarm_Clicked; // Accomodate iPhone status bar. this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); // Build the page. this.Content = new StackLayout { Children = { header, button } }; }
void OnStackSizeChanged(object sender, EventArgs args) { double width = stackLayout.Width; double height = stackLayout.Height; if (width <= 0 || height <= 0) { return; } // Orient StackLayout based on portrait/landscape mode. stackLayout.Orientation = (width < height) ? StackOrientation.Vertical : StackOrientation.Horizontal; // Calculate square size and position based on stack size. squareSize = Math.Min(width, height) / NUM; absoluteLayout.WidthRequest = NUM * squareSize; absoluteLayout.HeightRequest = NUM * squareSize; Font font = Font.BoldSystemFontOfSize(0.4 * squareSize); foreach (View view in absoluteLayout.Children) { XuzzleSquare square = (XuzzleSquare)view; square.Font = font; AbsoluteLayout.SetLayoutBounds(square, new Rectangle(square.Col * squareSize, square.Row * squareSize, squareSize, squareSize)); } }
public LoadResourceText() { var editor = new Label { Text = "loading...", HeightRequest = 300 }; #region How to load a text file embedded resource var assembly = typeof(LoadResourceText).GetTypeInfo().Assembly; Stream stream = assembly.GetManifestResourceStream("WorkingWithFiles.PCLTextResource.txt"); string text = ""; using (var reader = new System.IO.StreamReader(stream)) { text = reader.ReadToEnd(); } #endregion editor.Text = text; Content = new StackLayout { Padding = new Thickness(0, 20, 0, 0), VerticalOptions = LayoutOptions.StartAndExpand, Children = { new Label { Text = "Embedded Resource Text File (PCL)", Font = Font.BoldSystemFontOfSize(NamedSize.Medium) } , editor } }; // NOTE: use for debugging, not in released app code! //foreach (var res in assembly.GetManifestResourceNames()) // System.Diagnostics.Debug.WriteLine("found resource: " + res); }
private void insere_layout_na_pagina() { Label header = new Label { Text = "Button", Font = Font.BoldSystemFontOfSize(50), HorizontalOptions = LayoutOptions.Center }; Button button = new Button { BorderWidth = 1, Text = "Click Me!", Font = Font.SystemFontOfSize(NamedSize.Large), HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand }; button.Clicked += OnButtonClicked; // Build the page. this.Content = new StackLayout { Children = { header, button } }; }
public Welcome() { var layout = new StackLayout { Padding = 10 }; var label2 = new Label { Text = "In " + Helpers.Global.Industry, Font = Font.BoldSystemFontOfSize(NamedSize.Large), TextColor = Color.White, VerticalOptions = LayoutOptions.CenterAndExpand, XAlign = TextAlignment.Center, YAlign = TextAlignment.Start, }; layout.Children.Add(label2); var label = new Label { Text = String.Format("Welcome {0}. Start swipping to find out your new career", Helpers.Global.UserName), Font = Font.BoldSystemFontOfSize(NamedSize.Large), TextColor = Color.White, VerticalOptions = LayoutOptions.CenterAndExpand, XAlign = TextAlignment.Center, YAlign = TextAlignment.Center, }; layout.Children.Add(label); BackgroundImage = "Puphome.png"; Content = new ScrollView { Content = layout }; }
public FrameDemoPage() { Label header = new Label { Text = "Frame", Font = Font.BoldSystemFontOfSize(50), HorizontalOptions = LayoutOptions.Center }; Frame frame = new Frame { OutlineColor = Color.Accent, HasShadow = true, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand, Content = new Label { Text = "I've been framed!" } }; // Accomodate iPhone status bar. this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); // Build the page. this.Content = new StackLayout { Children = { header, frame } }; }
protected override void Init() { Label header = new Label { Text = "Should not see blue", #pragma warning disable 618 Font = Font.BoldSystemFontOfSize(40), #pragma warning restore 618 HorizontalOptions = LayoutOptions.Center, TextColor = Color.Black }; StackLayout stack = new StackLayout { BackgroundColor = Color.White, VerticalOptions = LayoutOptions.FillAndExpand, Spacing = 10, Children = { header, LblMsg, } }; Content = new ScrollView { BackgroundColor = Color.Blue, VerticalOptions = LayoutOptions.FillAndExpand, Orientation = ScrollOrientation.Vertical, Content = stack }; }
public EmbeddedImages() { var embeddedImage = new Image { Aspect = Aspect.AspectFit }; // resource identifiers start with assembly-name DOT filename embeddedImage.Source = ImageSource.FromResource("WorkingWithImages.beach.jpg"); Content = new StackLayout { Children = { new Label { Text = "ImageSource.FromResource", Font = Font.BoldSystemFontOfSize(NamedSize.Medium) }, embeddedImage, new Label { Text = "WorkingWithImages.beach.jpg embedded resource" } }, Padding = new Thickness(0, 20, 0, 0), VerticalOptions = LayoutOptions.StartAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand }; // NOTE: use for debugging, not in released app code! //var assembly = typeof(EmbeddedImages).GetTypeInfo().Assembly; //foreach (var res in assembly.GetManifestResourceNames()) // System.Diagnostics.Debug.WriteLine("found resource: " + res); }
/// <summary> /// Initializes a new instance of the <see cref="MainCsPage"/> class. /// </summary> public MainCsPage() { this.Title = "Google Login"; this.BackgroundColor = Color.White; var loginButton = new Button { Text = "Login with Google", TextColor = Color.White, BackgroundColor = Color.FromHex("#db4437"), #pragma warning disable CS0618 // Type or member is obsolete Font = Font.BoldSystemFontOfSize(26), #pragma warning restore CS0618 // Type or member is obsolete FontSize = 26 }; loginButton.Clicked += this.LoginWithFacebook_Clicked; this.Content = new StackLayout { Orientation = StackOrientation.Vertical, Children = { new Label { Text = "Login with Google API", FontSize = 66, TextColor = Color.Black }, loginButton } }; }
public TableViewMenuDemoPage() { Label header = new Label { Text = "TableView for a menu", Font = Font.BoldSystemFontOfSize(30), HorizontalOptions = LayoutOptions.Center }; TableView tableView = new TableView { Intent = TableIntent.Menu, Root = new TableRoot { new TableSection("Views for Presentation") { new TextCell { Text = "Label", Command = new Command(async() => await Navigation.PushAsync(new LabelDemoPage())) }, new TextCell { Text = "Image", Command = new Command(async() => await Navigation.PushAsync(new ImageDemoPage())) }, new TextCell { Text = "BoxView", Command = new Command(async() => await Navigation.PushAsync(new BoxViewDemoPage())) }, new TextCell { Text = "WebView", Command = new Command(async() => await Navigation.PushAsync(new WebViewDemoPage())) }, } } }; // Accomodate iPhone status bar. this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); // Build the page. this.Content = new StackLayout { Children = { header, tableView } }; }
public HomeView() { // Accomodate iPhone status bar. //new BindablePicker(); this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); this.Content = new StackLayout { Children = { new Label { Text = "Home", Font = Font.BoldSystemFontOfSize(40), HorizontalOptions = LayoutOptions.Center }, new ScrollView { Content = new StackLayout{ HorizontalOptions = LayoutOptions.CenterAndExpand, Children = { this.Nav <BarCodeViewModel>("BarCode Scanning"), this.Nav <UserDialogViewModel>("User Dialogs"), this.Nav <DeviceInfoViewModel>("Device Information"), this.Nav <NetworkViewModel>("Network"), this.Nav <SettingsViewModel>("Settings"), this.Nav <PhoneViewModel>("Phone Call"), this.Nav <SmsViewModel>("Send SMS"), this.Nav <MailViewModel>("Send E-Mail"), this.Nav <LocationViewModel>("Location"), this.Nav <PhotoViewModel>("Camera/Photo Gallery"), this.Nav <SignatureListViewModel>("Signature Pad") } } } } }; }
public Mentor() { var layout = new StackLayout { Padding = 10 }; var label = new Label { Text = "Welcome to the Mentor Page.", Font = Font.BoldSystemFontOfSize(NamedSize.Large), TextColor = Color.White, VerticalOptions = LayoutOptions.CenterAndExpand, XAlign = TextAlignment.Center, YAlign = TextAlignment.Center, }; layout.Children.Add(label); var button = new Button { Text = "See first Mentor", TextColor = Color.White }; button.Clicked += delegate { Navigation.PushAsync(new MentorOne()); }; layout.Children.Add(button); BackgroundImage = "mentors.png"; Content = new ScrollView { Content = layout }; }
public TimePickerDemoPage() { Label header = new Label { Text = "TimePicker", Font = Font.BoldSystemFontOfSize(50), HorizontalOptions = LayoutOptions.Center }; TimePicker timePicker = new TimePicker { Format = "T", VerticalOptions = LayoutOptions.CenterAndExpand }; // Accomodate iPhone status bar. this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); // Build the page. this.Content = new StackLayout { Children = { header, timePicker } }; }
void OnStackSizeChanged(object sender, EventArgs args) { double width = stackLayout.Width; double height = stackLayout.Height; if (width <= 0 || height <= 0) { return; } stackLayout.Orientation = (width < height) ? StackOrientation.Vertical : StackOrientation.Horizontal; squareSize = Math.Min(width, height) / NUM; absoluteLayout.WidthRequest = NUM * squareSize; absoluteLayout.HeightRequest = NUM * squareSize; Font font = Font.BoldSystemFontOfSize(squareSize / 3); foreach (View view in absoluteLayout.Children) { Square square = (Square)view; square.Font = font; AbsoluteLayout.SetLayoutBounds(square, new Rectangle(square.Col * squareSize, square.Row * squareSize, squareSize, squareSize)); } }
public MainCsPage() { Title = "Google Login"; BackgroundColor = Color.White; var loginButton = new Button { Text = "Login with Google", TextColor = Color.White, BackgroundColor = Color.FromHex("#db4437"), Font = Font.BoldSystemFontOfSize(26), FontSize = 26 }; loginButton.Clicked += LoginWithFacebook_Clicked; Content = new StackLayout { Orientation = StackOrientation.Vertical, Children = { new Label { Text = "Login with Google API", FontSize = 66, TextColor = Color.Black }, loginButton } }; }
public LocalImages() { var beachImage = new Image { WidthRequest = 300, HeightRequest = 300 }; beachImage.Source = ImageSource.FromFile("waterfront.jpg"); beachImage.Aspect = Aspect.AspectFit; Content = new StackLayout { Children = { new Label { Text = "ImageSource.FromFile", Font = Font.BoldSystemFontOfSize(NamedSize.Medium) }, beachImage, new Label { Text = "waterfront.jpg has been added each application project: iOS, Android and Windows Phone. On iOS and Android multiple resolutions are supplied and resolved at runtime." } }, Padding = new Thickness(0, 20, 0, 0), VerticalOptions = LayoutOptions.StartAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand }; }
public EditorDemoPage() { Label header = new Label { Text = "Editor", Font = Font.BoldSystemFontOfSize(50), HorizontalOptions = LayoutOptions.Center }; Editor editor = new Editor { VerticalOptions = LayoutOptions.FillAndExpand }; // Accomodate iPhone status bar. this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); // Build the page. this.Content = new StackLayout { Children = { header, editor } }; }
public RecipeMenu() { this.Title = " Kitchen.Support"; Button back = new Button { Text = "back", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start }; back.Clicked += (sender, e) => { Navigation.PopModalAsync(); }; Label header = new Label { Text = "Recipe Main Menu", Font = Font.BoldSystemFontOfSize(50), }; var tapHead = new TapGestureRecognizer(); tapHead.Tapped += (sender, e) => { Navigation.PushModalAsync(new NavigationPage(new RecipeInterface())); }; header.GestureRecognizers.Add(tapHead); Button stream = new Button { Text = "Recipe Stream", BackgroundColor = Color.FromHex("77D065") }; stream.Clicked += (sender, e) => { Navigation.PushModalAsync(new NavigationPage(new RecipeStream())); }; Button search = new Button { Text = "Recipe Search", BackgroundColor = Color.FromHex("77D065") }; search.Clicked += (sender, e) => { Navigation.PushModalAsync(new NavigationPage(new RecipeSearch())); }; Content = new StackLayout { Spacing = 20, Padding = 50, VerticalOptions = LayoutOptions.Center, Children = { back, header, stream, search } }; }