public HopDetails(Hops selectedHop)
        {
            //Set the title on the navigation bar to the selected hop
            Title = "Hop Details";
            //Set the StyleId for Xamarin Test Cloud
            StyleId = "HopDetailsPage";

            //Create items for Hop specifications
            ThemedLabel hopName = new ThemedLabel {
                Text     = selectedHop.HopName,
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };
            ThemedLabel hopAA = new ThemedLabel {
                Text = "Alpha Acid: " + selectedHop.AALow + " - " + selectedHop.AAHigh + "%"
            };
            ThemedLabel hopType = new ThemedLabel {
                Text = "Type of hop: " + selectedHop.Type
            };
            ThemedLabel hopSubstitutes = new ThemedLabel {
                Text = "Substitutes: "
            };
            ThemedLabel hopDescription = new ThemedLabel {
                Text            = selectedHop.Description,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            //Create tableview for list of hop substitutes
            TableView hopSubs = new TableView();

            hopSubs.BackgroundColor = Color.Transparent;

            //Split hop substitute string into array for tableview
            string[] substitutes = selectedHop.Substitutes.Split(',');

            //Create TableRoot and TableSection
            TableRoot    list    = new TableRoot();
            TableSection section = new TableSection();

            //Create a label for each hop substitute in string array of hop substitutes
            foreach (string sub in substitutes)
            {
                WhiteTextColorLabel beerName = new WhiteTextColorLabel {
                    Text     = sub,
                    FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                    YAlign   = TextAlignment.Center,
                    XAlign   = TextAlignment.Center
                };
                //Add ViewCell containing label to TableSection
                section.Add(new ViewCell {
                    View = beerName
                });
            }
            //Add Tablesection to TableRoot
            list.Add(section);
            //Set TableRoot to TableView
            hopSubs.Root = list;

            //Create Stacklayout for content page
            StackLayout detailsLayout = new StackLayout {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Spacing         = 20,
                Padding         = new Thickness(5, 20, 5, 5),
                Children        =
                {
                    hopName,
                    hopAA,
                    hopType,
                    hopDescription,
                    hopSubstitutes,
                    hopSubs
                }
            };

            //Wrap content in scrollview
            var scrollLayer = new ScrollView();

            scrollLayer.Content = detailsLayout;

            Content = scrollLayer;
        }
Exemple #2
0
        //		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);
            };
        }
Exemple #3
0
        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,
            };
        }
Exemple #4
0
        public GrainDetailsPage(Grains selectedGrain)
        {
            //Set the title on the navigation bar to the selected hop
            Title = selectedGrain.GrainName;
            //Set the StyleId for Xamarin Test Cloud
            StyleId = selectedGrain.GrainName + "Page";

            //Create labels to hold the Grain Name
            ThemedLabel grainName = new ThemedLabel {
                Text = selectedGrain.GrainName
            };
            ThemedLabel grainNameLabel = new ThemedLabel {
                Text = "Grain Name"
            };

            //Stack the grain name labels in a vertical stacklayout
            StackLayout nameStack = new StackLayout {
                Orientation = StackOrientation.Vertical,
                Spacing     = 10,
                Padding     = new Thickness(0, 20, 0, 0),
                Children    =
                {
                    grainNameLabel,
                    grainName
                }
            };

            //Create grid for the details of the grain
            Grid layout = new Grid {
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                },
                RowDefinitions =
                {
                    new RowDefinition {
                        Height = 50
                    },
                    new RowDefinition {
                        Height = 50
                    },
                    new RowDefinition {
                        Height = 50
                    },
                    new RowDefinition {
                        Height = 50
                    },
                },
                Padding = new Thickness(30, 0, 20, 0)
            };

            //Place the elements in the grid with their details
            layout.Children.Add(new ThemedLabel {
                Text = "Points per Gallon (PPG):"
            }, 0, 0);
            layout.Children.Add(new ThemedLabel {
                Text = "Origin:"
            }, 0, 1);
            layout.Children.Add(new ThemedLabel {
                Text = "Grain Type:"
            }, 0, 2);
            layout.Children.Add(new ThemedLabel {
                Text = " SRM Color:"
            }, 0, 3);
            layout.Children.Add(new ThemedLabel {
                Text = selectedGrain.PPG.ToString()
            }, 1, 0);
            layout.Children.Add(new ThemedLabel {
                Text = selectedGrain.Origin
            }, 1, 1);
            layout.Children.Add(new ThemedLabel {
                Text = selectedGrain.Type
            }, 1, 2);
            layout.Children.Add(new ThemedLabel {
                Text = selectedGrain.srmColor.ToString()
            }, 1, 3);

            //Wrap the nameStack in a frame and place it above the grid layout
            Content = new StackLayout {
                Orientation = StackOrientation.Vertical,
                Spacing     = 20,
                Children    =
                {
                    new Frame {
                        Content = nameStack, BackgroundColor = Color.Transparent
                    },
                    layout
                }
            };
        }
Exemple #5
0
        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
                }
            };
        }