private static void OnItemsSourceModified(object sender, object oldValue, object newValue) { BubbleView bv = (BubbleView)sender; if (newValue != null) { Session sess = (Session)newValue; bv._kilos.Text = sess.TotalWeight.ToString(); bv._time.Text = sess.Starts.ToString(); bv._fishes.Text = sess.TotalCatches.ToString(); } }
public CustomToolbar() { _mainLayout = new AbsoluteLayout() { BackgroundColor = Color.Transparent, }; //adding all the backgrounds Image bubblesBackground = new Image() { Source = "bubblesbackground.png", Aspect = Aspect.AspectFill, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, IsVisible = false, InputTransparent = true, }; AbsoluteLayout.SetLayoutFlags(bubblesBackground, AbsoluteLayoutFlags.All); AbsoluteLayout.SetLayoutBounds(bubblesBackground, new Rectangle(0, 0, 1, 1)); _water3 = new Image() { Source = "water3.png", Aspect = Aspect.AspectFill, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, InputTransparent = true, }; AbsoluteLayout.SetLayoutFlags(_water3, AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.HeightProportional); AbsoluteLayout.SetLayoutBounds(_water3, new Rectangle(0.5, 0, 3 * Device.Info.PixelScreenSize.Width, 1)); _water2 = new Image() { Source = "water2.png", Aspect = Aspect.AspectFill, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, InputTransparent = true, }; AbsoluteLayout.SetLayoutFlags(_water2, AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.HeightProportional); AbsoluteLayout.SetLayoutBounds(_water2, new Rectangle(0.5, 0, 3 * Device.Info.PixelScreenSize.Width, 1)); _water1 = new Image() { Source = "water1.png", Aspect = Aspect.AspectFill, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, InputTransparent = true, }; AbsoluteLayout.SetLayoutFlags(_water1, AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.HeightProportional); AbsoluteLayout.SetLayoutBounds(_water1, new Rectangle(0.5, 0, 3 * Device.Info.PixelScreenSize.Width, 1)); //creating menu layout _menuLayout = new StackLayout() { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, TranslationY = 110, }; AbsoluteLayout.SetLayoutFlags(_menuLayout, AbsoluteLayoutFlags.All); AbsoluteLayout.SetLayoutBounds(_menuLayout, new Rectangle(0, 0, 1, 1)); Grid menuGrid = new Grid() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, }; ColumnDefinition c1 = new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }; ColumnDefinition c2 = new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }; ColumnDefinition c3 = new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }; ColumnDefinition c4 = new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }; menuGrid.ColumnDefinitions.Add(c1); menuGrid.ColumnDefinitions.Add(c2); menuGrid.ColumnDefinitions.Add(c3); menuGrid.ColumnDefinitions.Add(c4); CustomImageButton addFish = new CustomImageButton() { Source = "addfish.png", BackgroundColor = Color.Transparent, Margin = new Thickness(10, 30, 10, 0), }; addFish.FadeTo(0.85); CustomImageButton viewSession = new CustomImageButton() { Source = "viewsession.png", BackgroundColor = Color.Transparent, Margin = new Thickness(10, 30, 10, 0) }; viewSession.FadeTo(0.85); CustomImageButton stopSession = new CustomImageButton() { Source = "stopsession.png", BackgroundColor = Color.Transparent, Margin = new Thickness(10, 30, 10, 0) }; stopSession.FadeTo(0.85); _bubbleView = new BubbleView() { VerticalOptions = LayoutOptions.Start, Margin = new Thickness(10, 30, 10, 10), InputTransparent = true, }; _bubbleView.FadeTo(0.85); menuGrid.Children.Add(addFish, 0, 0); menuGrid.Children.Add(viewSession, 1, 0); menuGrid.Children.Add(stopSession, 2, 0); menuGrid.Children.Add(_bubbleView, 3, 0); _menuLayout.Children.Add(menuGrid); //creating fish button _fishButton = new CustomImageButton() { Source = "thon_center.png", BackgroundColor = Color.Transparent, }; AbsoluteLayout.SetLayoutFlags(_fishButton, AbsoluteLayoutFlags.PositionProportional); AbsoluteLayout.SetLayoutBounds(_fishButton, new Rectangle(0.5, 0, -1, -1)); _mainLayout.Children.Add(_water3); _mainLayout.Children.Add(_water2); _mainLayout.Children.Add(_water1); _mainLayout.Children.Add(bubblesBackground); _mainLayout.Children.Add(_menuLayout); _mainLayout.Children.Add(_fishButton); this.Content = _mainLayout; this.TranslationY = 150; this.IsVisible = false; //event handlers _fishButton.ItemSwipped += ToggleMenu; addFish.ItemTapped += FireAddFishCommand; viewSession.ItemTapped += FireViewSessionCommand; stopSession.ItemTapped += FireStopSessionCommand; }