/// <summary> /// Measures a view and sets the output buffer to (x, y, width, height). /// Measurements are relative to the RootView. /// </summary> /// <param name="tag">The view tag.</param> /// <param name="outputBuffer">The output buffer.</param> public void Measure(int tag, double[] outputBuffer) { DispatcherHelpers.AssertOnDispatcher(); var view = default(Widget); if (!_tagsToViews.TryGetValue(tag, out view)) { throw new ArgumentOutOfRangeException(nameof(tag)); } var viewManager = default(IViewManager); if (!_tagsToViewManagers.TryGetValue(tag, out viewManager)) { throw new InvalidOperationException( Invariant($"Could not find view manager for tag '{tag}.")); } var rootView = RootViewHelper.GetRootView(view); if (rootView == null) { throw new InvalidOperationException( Invariant($"Native view '{tag}' is no longer on screen.")); } // TODO: better way to get relative position? //var Widget = view.As<Widget>(); //var rootTransform = Widget.TransformToVisual(rootView); /* #if WINDOWS_UWP * var positionInRoot = rootTransform.TransformPoint(new Point(0, 0)); #else * //var positionInRoot = rootTransform.Transform(new Point(0, 0)); * Point point = new Point(); // adapt to the new encapsulation of ElmSharp * point.X = 0; * point.Y = 0; * var positionInRoot = rootTransform.Transform(point); #endif */ var dimensions = viewManager.GetDimensions(rootView); //outputBuffer[0] = positionInRoot.X; //outputBuffer[1] = positionInRoot.Y; outputBuffer[2] = dimensions.Width; outputBuffer[3] = dimensions.Height; }
private void OnPointerExited(object sender, PointerRoutedEventArgs e) { var view = (TFrameworkElement)sender; var hasBoxOnlyParent = RootViewHelper.GetReactViewHierarchy(view) .Skip(1) // Skip the current view .Any(v => v.GetPointerEvents() == PointerEvents.BoxOnly); if (!hasBoxOnlyParent) { view.GetReactContext() .GetNativeModule <UIManagerModule>() .EventDispatcher .DispatchEvent( new PointerEnterExitEvent(TouchEventType.Exited, view.GetTag())); } }
/// <summary> /// Measures a view and sets the output buffer to (x, y, width, height). /// Measurements are relative to the RootView. /// </summary> /// <param name="tag">The view tag.</param> /// <param name="outputBuffer">The output buffer.</param> public void Measure(int tag, double[] outputBuffer) { DispatcherHelpers.AssertOnDispatcher(); var view = default(DependencyObject); if (!_tagsToViews.TryGetValue(tag, out view)) { throw new ArgumentOutOfRangeException(nameof(tag)); } var viewManager = default(IViewManager); if (!_tagsToViewManagers.TryGetValue(tag, out viewManager)) { throw new InvalidOperationException( Invariant($"Could not find view manager for tag '{tag}.")); } var rootView = RootViewHelper.GetRootView(view); if (rootView == null) { throw new InvalidOperationException( Invariant($"Native view '{tag}' is no longer on screen.")); } // TODO: better way to get relative position? var uiElement = view.As <UIElement>(); var rootTransform = uiElement.TransformToVisual(rootView); #if WINDOWS_UWP var positionInRoot = rootTransform.TransformPoint(new Point(0, 0)); #else var positionInRoot = rootTransform.Transform(new Point(0, 0)); #endif var dimensions = viewManager.GetDimensions(uiElement); outputBuffer[0] = positionInRoot.X; outputBuffer[1] = positionInRoot.Y; outputBuffer[2] = dimensions.Width; outputBuffer[3] = dimensions.Height; }