public IBUCalculatorPage() { //Set the title on the navigation bar to the selected hop Title = "IBU Calculator"; //Set the StyleId for Xamarin Test Cloud StyleId = "IBUCalculatorPage"; table = new IBUListView { StyleId = "ibuListView", BackgroundColor = Color.Transparent, HeightRequest = (double)(App.ScreenHeight * 0.2), HasUnevenRows = true }; //Add hop button addButton = new HopThemedButton { StyleId = "addHopButton", Text = "Add Hop", WidthRequest = (double)(App.ScreenWidth * 0.8), HeightRequest = (double)(App.ScreenHeight * 0.07) }; //Create hop gravity and volume controls boilGravityEntry = new HopThemedNumberEntry { StyleId = "boilGravityEntry", Text = "1.050", WidthRequest = (double)(App.ScreenWidth * 0.3) }; boilVolumeEntry = new HopThemedNumberEntry { StyleId = "boilVolumeEntry", Text = "0", WidthRequest = (double)(App.ScreenWidth * 0.3) }; //Create gravity and volume steppers gravityStepper = new GreenStepper { StyleId = "gravityStepper", Minimum = 1.000, Maximum = 1.120, Increment = .001, Value = Convert.ToDouble(boilGravityEntry.Text), WidthRequest = (double)(App.ScreenWidth * 0.35) }; volumeStepper = new GreenStepper { StyleId = "volumeStepper", Minimum = 0, Maximum = 1000, Increment = 1, Value = Convert.ToDouble(boilVolumeEntry.Text), WidthRequest = (double)(App.ScreenWidth * 0.35) }; //Create grid to add all of the hop gravity and volume controls Grid VolumeAndGravityGrid = new Grid { ColumnDefinitions = { new ColumnDefinition { Width = Device.OnPlatform( (double)(App.ScreenWidth * 0.33), (double)(App.ScreenWidth * 0.3), (double)(App.ScreenWidth * 0.3) ) }, new ColumnDefinition { Width = (double)(App.ScreenWidth * 0.3) }, new ColumnDefinition { Width = (double)(App.ScreenWidth * 0.35) } }, }; //Boil Gravity Grid Row VolumeAndGravityGrid.Children.Add( new Label() { Text = "Boil Gravity", TextColor = Color.White, YAlign = TextAlignment.Center }, 0, 0 ); VolumeAndGravityGrid.Children.Add(boilGravityEntry, 1, 0); VolumeAndGravityGrid.Children.Add(gravityStepper, 2, 0); //Volume Grid Row VolumeAndGravityGrid.Children.Add( new Label() { Text = "Boil Volume", TextColor = Color.White, YAlign = TextAlignment.Center }, 0, 1 ); VolumeAndGravityGrid.Children.Add(boilVolumeEntry, 1, 1); VolumeAndGravityGrid.Children.Add(volumeStepper, 2, 1); //Create calculated IBU stack calculateIBUButton = new HopThemedButton { StyleId = "calculateIBUButton", Text = "Calculate IBU", WidthRequest = (double)(App.ScreenWidth * 0.8), HeightRequest = (double)(App.ScreenHeight * 0.07) }; ThemedLabel IBU = new ThemedLabel { Text = "Calculated IBU:", }; calculatedIBULabel = new ThemedLabel { Text = "0", }; StackLayout IBULabels = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { IBU, calculatedIBULabel } }; //Create calculated stacklayout StackLayout calculatedStackLayout = new StackLayout { Children = { calculateIBUButton, IBULabels }, Spacing = Device.OnPlatform( 5, 0, 5 ) }; StackLayout stack = new StackLayout { Padding = 5, Children = { new IBUListViewHeader(), table, addButton, VolumeAndGravityGrid, calculatedStackLayout } }; //Wrap the content in a scrollview Content = new ScrollView { HeightRequest = (double)(App.ScreenHeight), Content = stack, }; }
// ContentView_IBUCalcTableView table; public UITableViewController_IBUCalculatorPage() { //Set the title on the navigation bar to the selected hop Title = "IBU Calculator"; //Set the StyleId for Xamarin Test Cloud StyleId = "IBUCalculatorPage"; ContentView_IBUCalcTableView table = new ContentView_IBUCalcTableView { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, }; //Add hop button HopThemedButton addEntry = new HopThemedButton { Text = "Add Hop", WidthRequest = Device.OnPlatform(200, 250, 250), }; //Create hop gravity and volume controls HopThemedNumberEntry boilGravityEntry = new HopThemedNumberEntry { Text = "1.050" }; HopThemedNumberEntry boilVolumeEntry = new HopThemedNumberEntry { Text = "0" }; //Create gravity and volume steppers GreenStepper gravityStepper = new GreenStepper { Minimum = 1.000, Maximum = 1.120, Increment = .001, Value = Convert.ToDouble(boilGravityEntry.Text), }; GreenStepper volumeStepper = new GreenStepper { Minimum = 0, Maximum = 1000, Increment = 1, Value = Convert.ToDouble(boilVolumeEntry.Text), }; //Create grid to add all of the hop gravity and volume controls Grid VolumeAndGravityGrid = new Grid { ColumnDefinitions = { new ColumnDefinition { Width = 120 }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) } }, }; //Boil Gravity Grid Row VolumeAndGravityGrid.Children.Add( new Label() { Text = "Boil Gravity", TextColor = Color.White }, 0, 0 ); VolumeAndGravityGrid.Children.Add(boilGravityEntry, 1, 0); VolumeAndGravityGrid.Children.Add(gravityStepper, 2, 0); //Volume Grid Row VolumeAndGravityGrid.Children.Add( new Label() { Text = "Boil Volume", TextColor = Color.White }, 0, 1 ); VolumeAndGravityGrid.Children.Add(boilVolumeEntry, 1, 1); VolumeAndGravityGrid.Children.Add(volumeStepper, 2, 1); VolumeAndGravityGrid.Padding = new Thickness(0, 0, 10, 0); //Create calculated IBU stack HopThemedButton calculateIBUButton = new HopThemedButton { Text = "Calculate IBU", WidthRequest = Device.OnPlatform(200, 250, 250), }; ThemedLabel IBU = new ThemedLabel { Text = "Calculated IBU:", }; ThemedLabel calculatedIBULabel = new ThemedLabel { Text = "0", }; StackLayout IBULabels = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { IBU, calculatedIBULabel } }; //Create calculated stacklayout StackLayout calculatedStackLayout = new StackLayout { BackgroundColor = Device.OnPlatform <Color>(Color.Default, Color.Black, Color.Default), VerticalOptions = LayoutOptions.End, Children = { calculateIBUButton, IBULabels }, }; //Stack the contents of the page StackLayout pageContents = new StackLayout { Padding = new Thickness(5, 5, 5, 0), Children = { table, addEntry, VolumeAndGravityGrid, calculatedStackLayout }, }; //Wrap the content in a scrollview Content = new ScrollView { Content = pageContents }; //Stepper Controls // Connects Gravity Stepper Changes to Entry gravityStepper.ValueChanged += (sender, e) => { boilGravityEntry.Text = gravityStepper.Value.ToString(); }; // Connects Volume Steppper Changes to Entry volumeStepper.ValueChanged += (sender, e) => { boilVolumeEntry.Text = volumeStepper.Value.ToString(); }; // Connects Gravity Entry to Stepper Value boilGravityEntry.TextChanged += (sender, e) => { if (boilGravityEntry.Text != "") { gravityStepper.Value = Convert.ToDouble(boilGravityEntry.Text); } }; boilGravityEntry.Focused += (object sender, FocusEventArgs e) => { placeholder = boilGravityEntry.Text; boilGravityEntry.Text = ""; }; boilGravityEntry.Unfocused += (object sender, FocusEventArgs e) => { if (boilGravityEntry.Text == "") { boilGravityEntry.Text = placeholder; } }; //Connects Volume Entry to Stepper boilVolumeEntry.TextChanged += (sender, e) => { if (boilVolumeEntry.Text != "") { volumeStepper.Value = Convert.ToDouble(boilVolumeEntry.Text); } }; boilVolumeEntry.Focused += (object sender, FocusEventArgs e) => { placeholder = boilVolumeEntry.Text; boilVolumeEntry.Text = ""; }; boilVolumeEntry.Unfocused += (object sender, FocusEventArgs e) => { if (boilVolumeEntry.Text == "") { boilVolumeEntry.Text = placeholder; } }; //Connects Add Entry to Adding a hop page to TableView addEntry.Clicked += (sender, e) => { Navigation.PushAsync(new IBUAddHopPage(true)); }; //Calculate IBU button calculateIBUButton.Clicked += (sender, e) => { //Create HopsToBeCalculated model to pass into calculator HopsToBeCalculated hopsToCalculate = new HopsToBeCalculated { BoilGravity = boilGravityEntry, BoilVolume = boilVolumeEntry, CalculatedIBU = calculatedIBULabel }; //Pass in the HopsToBeCalculated model and send to the native UITableView MessagingCenter.Send <UITableViewController_IBUCalculatorPage, HopsToBeCalculated> (this, "CalculateIBU", hopsToCalculate); }; }
public CalculateAlcoholPercentPage() { //Set the title on the navigation bar to the selected hop Title = "Alcohol % Calculator"; //Set the StyleId for Xamarin Test Cloud StyleId = "AlcoholPercentCalculatorPage"; //Create original gravity elements ogEntry = new HopThemedNumberEntry { StyleId = "ogEntry", Text = "1.050", HorizontalOptions = LayoutOptions.FillAndExpand }; ThemedLabel ogLabel = new ThemedLabel { Text = "Original Gravity", WidthRequest = 120, HorizontalOptions = LayoutOptions.Start, }; ogStepper = new GreenStepper { StyleId = "ogStepper", Minimum = 0, Maximum = 1.12, Increment = .001, HorizontalOptions = LayoutOptions.End, Value = Convert.ToDouble(ogEntry.Text) }; //stack original gravity elements together in a horizontal block StackLayout ogStackLayout = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { ogLabel, ogEntry, ogStepper } }; //Create final gravity elements fgEntry = new HopThemedNumberEntry { StyleId = "fgEntry", Text = "1.012", HorizontalOptions = LayoutOptions.FillAndExpand }; ThemedLabel fgLabel = new ThemedLabel { Text = "Final Gravity", HorizontalOptions = LayoutOptions.Start, WidthRequest = 120, }; fgStepper = new GreenStepper { StyleId = "fgStepper", Minimum = 0, Maximum = 1.12, Increment = .001, HorizontalOptions = LayoutOptions.End, Value = Convert.ToDouble(fgEntry.Text) }; //stack final gravity elements together in a horizontal block StackLayout fgStackLayout = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { fgLabel, fgEntry, fgStepper } }; //Create alchol percentage Labels ThemedLabel AlcoholPercentLabel = new ThemedLabel { Text = "Calculated Alcohol %:", HorizontalOptions = LayoutOptions.FillAndExpand, }; AlcoholPercentCalculated = new ThemedLabel { StyleId = "calculatedAlcoholPercent", Text = "0.0%", HorizontalOptions = LayoutOptions.FillAndExpand }; //Create Alcohol % Stack StackLayout AlcoholPercentStackLayout = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { AlcoholPercentLabel, AlcoholPercentCalculated } }; //Create button to calculate alcohol percent calculateAlcoholPercent = new HopThemedButton { StyleId = "calculateAlcoholPercentButton", Text = "Calculate Alcohol Percent", BorderWidth = 1, TextColor = Color.Green, WidthRequest = (double)(App.ScreenWidth * 0.8), }; //Set content page properties. Stack elements for content Content = new StackLayout { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.CenterAndExpand, Spacing = 25, Padding = 5, Children = { ogStackLayout, fgStackLayout, AlcoholPercentStackLayout, calculateAlcoholPercent } }; }