// TODO: Resolve async void private async void OnCanvasTap(TwinTechs.Gestures.BaseGestureRecognizer recognizer, TwinTechs.Gestures.GestureRecognizerState state) { var tapRecognizer = recognizer as TwinTechs.Gestures.TapGestureRecognizer; var view = recognizer.View; var positionInView = recognizer.LocationInView (view); var positionInParentView = recognizer.LocationInView (view.ParentView); var shapeViewModel = await ViewModel.GenerateRandomShapeAsync (); var shapeView = new ShapeView () { BindingContext = shapeViewModel }; shapeView.SetBinding (ShapeView.ColorProperty, "Color"); shapeView.SetBinding (ShapeView.ImageUrlProperty, "ImageUrl"); shapeView.SetBinding (ShapeView.ShapeProperty, "Shape"); shapeView.SetBinding (ShapeView.TitleProperty, "Title"); shapeView.SetBinding (ShapeView.OnDoubleTapProperty, "RefreshShape"); AbsoluteLayout.SetLayoutFlags (shapeView, AbsoluteLayoutFlags.None); AbsoluteLayout.SetLayoutBounds (shapeView, new Rectangle (x: positionInView.X, y: positionInView.Y, height: 200f, width: 50f)); Canvas.Children.Add (shapeView); // ViewModel.PlaceShape(new PointF(sender.X); }
private void OnScrolled( Object sender, TwinTechs.Controls.ControlScrollEventArgs e) { if (e.Delta > 0) { if (mActiveButtonIndex + 1 != mCategoryIndexList.Count) { int productCellIndex = mCategoryIndexList [mActiveButtonIndex + 1]; if (e.CurrentRow * 2 >= productCellIndex) { mActiveButtonIndex += 1; ChangeSelectedButton (); } } } else { if (mActiveButtonIndex != -0) { int productCellIndex = mCategoryIndexList [mActiveButtonIndex ]; if (e.CurrentRow * 2 <= productCellIndex) { mActiveButtonIndex -= 1; ChangeSelectedButton (); } } } }
/*private async Task WaitUntilCorrespondingSubCategoryLoaded(int productCellIndex) { mParent.mActivityIndicator.IsRunning = true; ProductScrollView.IsVisible = false; while (ProductGrid.Children.Count-2 < productCellIndex) { await Task.Delay (100); } mParent.mActivityIndicator.IsRunning = false; ProductScrollView.IsVisible = true; }*/ /* private void PopulateTopSelling() { } */ private void OnScrolled( Object sender, TwinTechs.Controls.ControlScrollEventArgs e) { if (e.Delta > 0) { if (mActiveButtonIndex + 1 != mCategoryIndexList.Count) { int productCellIndex = mCategoryIndexList [mActiveButtonIndex + 1]; if (e.CurrentRow * 2 >= productCellIndex) { mActiveButtonIndex += 1; ChangeSelectedButton (); } } } else { if (mActiveButtonIndex != -0) { int productCellIndex = mCategoryIndexList [mActiveButtonIndex ]; if (e.CurrentRow * 2 <= productCellIndex) { mActiveButtonIndex -= 1; ChangeSelectedButton (); } } } /*if (DecideIfIsUpOrDown (sender as ScrollView) == "Down") { if (mActiveButtonIndex + 1 != mCategoryIndexList.Count) { int productCellIndex = mCategoryIndexList [mActiveButtonIndex + 1]; try { double top = ProductGrid.Children.ElementAt (productCellIndex).Bounds.Top; if (ProductScrollView.ScrollY > top) { mActiveButtonIndex += 1; ChangeSelectedButton(); } } catch { System.Diagnostics.Debug.WriteLine ("Something is wrong with Product Number in Grid"); } } if ( ProductScrollView.ScrollY >= ProductGrid.Children.ElementAt (mLastLoadedIndex).Bounds.Bottom-50 ) { int endIndex = (int)Math.Ceiling (ProductScrollView.ScrollY / (int)Math.Floor(ProductGrid.Children.ElementAt(0).Height-MyDevice.ViewPadding/2)) * 2 - 1; if (endIndex >= ProductGrid.Children.Count) { endIndex = ProductGrid.Children.Count - 1; } mLastLoadedIndex = endIndex; } }else { if (mActiveButtonIndex != 0) { int productCellIndex = mCategoryIndexList [mActiveButtonIndex]; try{ double top = ProductGrid.Children.ElementAt (productCellIndex).Bounds.Top; if (ProductScrollView.ScrollY < top) { mActiveButtonIndex -= 1; ChangeSelectedButton(); } } catch{ System.Diagnostics.Debug.WriteLine ("Something is wrong with Product Number in Grid"); } } if (mLastLoadedIndex >= ProductGrid.Children.Count) mLastLoadedIndex = ProductGrid.Children.Count - 1; if (ProductScrollView.ScrollY <= ProductGrid.Children.ElementAt (mLastLoadedIndex).Bounds.Top) { int endIndex = (int)Math.Floor (ProductScrollView.ScrollY / (int)Math.Floor(ProductGrid.Children.ElementAt(0).Height-MyDevice.ViewPadding/2)) * 2 - 1; if (endIndex < 0) { endIndex = 0; } else if( endIndex >= ProductGrid.Children.Count ) endIndex = ProductGrid.Children.Count - 1; mLastLoadedIndex = endIndex; } }*/ }
void OnItemSelected(object sender, TwinTechs.GridEventArgs<object> e) { var item = e.Value as MediaItem; DisplayAlert ("you selected an item", item.Name, "Ok"); }
void MediaItemsListView_OnScroll (object sender, TwinTechs.Controls.ControlScrollEventArgs e) { _scrollPosition = e.CurrentY; }