protected override EvasObject OnGetContent(Cell cell, string part) { if (part == MainContentPart) { var entryCell = cell as EntryCell; int pixelHeight = Forms.ConvertToScaledPixel(entryCell.RenderHeight); pixelHeight = pixelHeight > 0 ? pixelHeight : Forms.ConvertToPixel(s_defaultHeight); var label = new Label() { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, VerticalTextAlignment = TextAlignment.Center, FontSize = -1 }; label.SetBinding(Label.TextProperty, new Binding(EntryCell.LabelProperty.PropertyName)); label.SetBinding(Label.TextColorProperty, new Binding(EntryCell.LabelColorProperty.PropertyName, converter: new DefaultColorConverter())); var entry = new Entry() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, FontSize = -1, }; entry.SetBinding(Entry.TextProperty, new Binding(EntryCell.TextProperty.PropertyName, BindingMode.TwoWay)); entry.SetBinding(Entry.PlaceholderProperty, new Binding(EntryCell.PlaceholderProperty.PropertyName)); entry.SetBinding(InputView.KeyboardProperty, new Binding(EntryCell.KeyboardProperty.PropertyName)); entry.SetBinding(Entry.HorizontalTextAlignmentProperty, new Binding(EntryCell.HorizontalTextAlignmentProperty.PropertyName)); var layout = new StackLayout() { Orientation = StackOrientation.Horizontal, Children = { label, entry } }; layout.Parent = cell; layout.BindingContext = entryCell; layout.MinimumHeightRequest = Forms.ConvertToScaledDP(pixelHeight); var renderer = Platform.GetOrCreateRenderer(layout); (renderer as LayoutRenderer)?.RegisterOnLayoutUpdated(); var nativeView = renderer.NativeView; nativeView.PropagateEvents = false; nativeView.MinimumHeight = pixelHeight; _cacheCandidate[nativeView] = layout; nativeView.Deleted += (sender, e) => { _cacheCandidate.Remove(sender as EvasObject); }; return(nativeView); } return(null); }
protected override void OnCompleted(View sender, object data) { if (Recognizer is SwipeGestureRecognizer swipeGesture) { var lineData = (GestureLayer.LineData)data; (swipeGesture as ISwipeGestureController)?.SendSwipe(sender, Forms.ConvertToScaledDP(lineData.X2 - lineData.X1), Forms.ConvertToScaledDP(lineData.Y2 - lineData.Y1)); (swipeGesture as ISwipeGestureController)?.DetectSwipe(sender, swipeGesture.Direction); } }
static double ComputeAbsoluteY(VisualElement e) { var parentY = 0.0; if (e.RealParent is VisualElement ve) { if (CompressedLayout.GetIsHeadless(e.RealParent)) { parentY = ComputeAbsoluteY(ve); } else { parentY = Forms.ConvertToScaledDP(Platform.GetRenderer(e.RealParent).GetNativeContentGeometry().Y); } } return(e.Y + parentY); }
void InitializeFlyout() { ((IShellController)Element).StructureChanged += OnShellStructureChanged; View flyoutHeader = ((IShellController)Element).FlyoutHeader; if (flyoutHeader != null) { var headerView = Platform.GetOrCreateRenderer(flyoutHeader); (headerView as LayoutRenderer)?.RegisterOnLayoutUpdated(); Size request = flyoutHeader.Measure(Forms.ConvertToScaledDP(_native.NavigationView.MinimumWidth), Forms.ConvertToScaledDP(_native.NavigationView.MinimumHeight)).Request; headerView.NativeView.MinimumHeight = Forms.ConvertToScaledPixel(request.Height); _native.NavigationView.Header = headerView.NativeView; } BuildMenu(); _native.NavigationView.MenuItemSelected += OnItemSelected; }
static double ComputeAbsoluteY(VisualElement e) { return(e.Y + ((e.RealParent is VisualElement) && !(e.RealParent is ListView || e.RealParent is ItemsView) ? Forms.ConvertToScaledDP(Platform.GetRenderer(e.RealParent).GetNativeContentGeometry().Y) : 0.0)); }
static double ComputeAbsoluteX(VisualElement e) { return(e.X + ((e.RealParent is VisualElement) ? Forms.ConvertToScaledDP(Platform.GetRenderer(e.RealParent).GetNativeContentGeometry().X) : 0.0)); }
void OnMoved(GestureLayer.MomentumData moment) { if (SwipeDirection == 0) { var direction = SwipeDirectionHelper.GetSwipeDirection(new Point(moment.X1, moment.Y1), new Point(moment.X2, moment.Y2)); if (HasRightItems && direction == SwipeDirection.Left) { SwipeDirection = SwipeDirection.Left; } else if (HasLeftItems && direction == SwipeDirection.Right) { SwipeDirection = SwipeDirection.Right; } else if (HasTopItems && direction == SwipeDirection.Down) { SwipeDirection = SwipeDirection.Down; } else if (HasBottomItems && direction == SwipeDirection.Up) { SwipeDirection = SwipeDirection.Up; } else { return; } UpdateItems(); ((ISwipeViewController)Element).SendSwipeStarted(new SwipeStartedEventArgs(SwipeDirection)); } var offset = GetSwipeOffset(moment); if (IsNegativeDirection) { if (offset > 0) { offset = 0; } } else { if (offset < 0) { offset = 0; } } if (Math.Abs(offset) > MaximumSwipeSize) { offset = MaximumSwipeSize * (offset < 0 ? -1 : 1); } var toDragBound = NativeView.Geometry; if (IsHorizontalSwipe) { toDragBound.X += offset; } else { toDragBound.Y += offset; } Platform.GetRenderer(SwipeView.Content).NativeView.Geometry = toDragBound; ((ISwipeViewController)Element).SendSwipeChanging(new SwipeChangingEventArgs(SwipeDirection, Forms.ConvertToScaledDP(offset))); }
public static Size ToDP(this ESize size) { return(new Size(Forms.ConvertToScaledDP(size.Width), Forms.ConvertToScaledDP(size.Height))); }
public static Rectangle ToDP(this ERect rect) { return(new Rectangle(Forms.ConvertToScaledDP(rect.X), Forms.ConvertToScaledDP(rect.Y), Forms.ConvertToScaledDP(rect.Width), Forms.ConvertToScaledDP(rect.Height))); }
protected override void OnMoved(View sender, object data) { var lineData = (GestureLayer.MomentumData)data; (Recognizer as IPanGestureController)?.SendPan(sender, Forms.ConvertToScaledDP(lineData.X2 - lineData.X1), Forms.ConvertToScaledDP(lineData.Y2 - lineData.Y1), _currentPanGestureId); }
static double ComputeAbsoluteX(VisualElement e) { return(e.X + ((e.RealParent is VisualElement) && !(e.RealParent is ListView) ? Forms.ConvertToScaledDP(Platform.GetRenderer(e.RealParent).NativeView.Geometry.X) : 0.0)); }