public NativeGestureCoordinator (Xamarin.Forms.View targetView)
		{
			NativeRecognizers = new List<BaseNativeGestureRecognizer> ();
			TargetView = targetView;
			TargetView.InputTransparent = false;
			var renderer = TargetView.GetRenderer ();
			if (renderer == null) {
				TargetView.PropertyChanged += Recognizer_View_PropertyChanged;
			} else {
				Initialize ();
			}
		}
		public void ApplyMaskToView (Xamarin.Forms.View view, ViewMaskerType maskType)
		{
			var renderer = view.GetRenderer ();
			var nativeView = renderer.NativeView;
			if (maskType == ViewMaskerType.None) {
				view.SizeChanged -= OnSizeChanged;
				nativeView.Layer.Mask = null;
			} else {
				var maskLayer = GetMaskShape (maskType, new Xamarin.Forms.Size (view.Width, view.Height));
				maskLayer.Frame = nativeView.Bounds;
				nativeView.Layer.Mask = maskLayer;
				view.SizeChanged += OnSizeChanged;
			}
			nativeView.Tag = (int)maskType;
			
		}
Exemplo n.º 3
0
        public CustomDialog(Xamarin.Forms.View content, bool _cancelable = false)
        {
            cancelable = _cancelable;
            nativePopup = new System.Windows.Controls.Primitives.Popup();
            nativePopup.VerticalOffset = 0;
            nativePopup.HorizontalOffset = 0;

            System.Windows.Controls.Grid wrap = new System.Windows.Controls.Grid();
            var ScreenWidth = System.Windows.Application.Current.Host.Content.ActualWidth;
            var ScreenHeight = System.Windows.Application.Current.Host.Content.ActualHeight;
            wrap.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(50, 50, 50, 50));

            wrap.Height = XFPopupConst.SCREEN_HEIGHT;
            wrap.Width = XFPopupConst.SCREEN_WIDTH;

            wrap.MouseLeftButtonUp += (s, e) => {
                if (cancelable)
                {
                    nativePopup.IsOpen = false;
                }
            };

            var boder = new Border();
            boder.BorderThickness = new System.Windows.Thickness(1);
            boder.Padding = new System.Windows.Thickness(5);
            boder.BorderBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 50, 50, 50));
            boder.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 255, 255));

            boder.VerticalAlignment = VerticalAlignment.Center;
            boder.HorizontalAlignment = HorizontalAlignment.Center;

            boder.Width = content.WidthRequest + 10;
            boder.Height = content.HeightRequest + 10;
            boder.CornerRadius = new CornerRadius(5);

            var elm = (content.GetRenderer() as Panel);
            elm.VerticalAlignment = VerticalAlignment.Top;
            elm.HorizontalAlignment = HorizontalAlignment.Left;
            boder.Child = elm;

            wrap.Children.Add(boder);
            nativePopup.Child = wrap;
            nativePopup.IsOpen = false;
        }
		protected Xamarin.Forms.Point GetLocationInAncestorView (Xamarin.Forms.Point location, Xamarin.Forms.VisualElement view)
		{
			int[] nativeViewLocation = new int[2];
			NativeView.GetLocationOnScreen (nativeViewLocation);
			var nativeViewLocationOnScreen = new Xamarin.Forms.Point (nativeViewLocation [0], nativeViewLocation [1]);

			var offsetLocation = new Xamarin.Forms.Point (location.X + nativeViewLocationOnScreen.X, location.Y + nativeViewLocationOnScreen.Y);

			var targetViewRenderer = view.GetRenderer ();
			var targetView = targetViewRenderer.ViewGroup;
			int[] targetViewLocation = new int[2];
			targetView.GetLocationOnScreen (targetViewLocation);
			var nativeViewScreenLocation = new Xamarin.Forms.Point (targetViewLocation [0], targetViewLocation [1]);

			var returnPoint = offsetLocation;
			returnPoint.X -= nativeViewScreenLocation.X;
			returnPoint.Y -= nativeViewScreenLocation.Y;

//			Console.WriteLine ("offsetLocation {0} nativeViewLocationOnScreen {1} returnPoint", offsetLocation, nativeViewLocationOnScreen);
//			Console.WriteLine ("location {0} parentViewLoc {1} returnPoint {2}", location, nativeViewScreenLocation, returnPoint);
			return returnPoint;
		}
Exemplo n.º 5
0
        public void ShowTopNoti(Xamarin.Forms.Page p, View noti, int msTTL = 1500)
        {
            var render = Convert(noti, p);

            if (render != null)
            {
                var nanchor = p.GetRenderer() as Canvas;
                p.WidthRequest = nanchor.ActualWidth - 10;

                if (noti.HeightRequest <= 0)
                {
                    var size = noti.GetSizeRequest(nanchor.ActualWidth - 10, XFPopupConst.SCREEN_HEIGHT / 2);
                    if (size.Request.Height > XFPopupConst.SCREEN_HEIGHT / 2)
                    {
                        noti.HeightRequest = XFPopupConst.SCREEN_HEIGHT / 2;
                    }
                    else
                    {
                        noti.HeightRequest = size.Request.Height;
                    }
                }

                noti.Layout(new Rectangle(0, 0, noti.WidthRequest, noti.HeightRequest));

                var nativePopup = new System.Windows.Controls.Primitives.Popup();
                nativePopup.VerticalOffset = 0;
                nativePopup.HorizontalOffset = 0;

                var boder = new Border();
                boder.BorderThickness = new System.Windows.Thickness(1);
                boder.Padding = new System.Windows.Thickness(5);
                boder.BorderBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 50, 50, 50));
                boder.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 255, 255));

                boder.VerticalAlignment = VerticalAlignment.Top;
                boder.HorizontalAlignment = HorizontalAlignment.Stretch;

                boder.Width = noti.WidthRequest + 10;
                boder.Height = noti.HeightRequest + 10;
                boder.CornerRadius = new CornerRadius(5);

                var elm = (render as Panel);
                elm.VerticalAlignment = VerticalAlignment.Top;
                elm.HorizontalAlignment = HorizontalAlignment.Left;
                boder.Child = elm;

                nativePopup.Child = boder;
                nativePopup.IsOpen = true;

                //
                byte count = 0;
                var dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
                dispatcherTimer.Tick += (object sender, EventArgs e) => {
                    count++;
                    if (count >= 10) {
                        dispatcherTimer.Stop();
                        nativePopup.IsOpen = false;

                    }

                    boder.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb((byte)(255 - count * 25), 255, 255, 255));
                };

                dispatcherTimer.Interval = new TimeSpan(0, 0, 0,msTTL/10);
                dispatcherTimer.Start();
            }
        }
Exemplo n.º 6
0
        public IVisualElementRenderer Convert(Xamarin.Forms.View source, Xamarin.Forms.VisualElement valid)
        {
            //only wp allow us to get renderer directly
            IVisualElementRenderer render = source.GetRenderer();
            if (render == null)
            {
                render = RendererFactory.GetRenderer(source);
                source.SetRenderer(render);
                if (valid != null)
                {
                    var p = PlatformProperty.GetValue(valid);
                    if (p != null)
                    {
                        PlatformProperty.SetValue(source, p);
                        IsPlatformEnabledProperty.SetValue(source, true);
                    }
                }
            }

            return render;
        }
 protected Xamarin.Forms.Point GetLocationInAncestorView(Xamarin.Forms.Point location, Xamarin.Forms.VisualElement view)
 {
     var targetViewRenderer = view.GetRenderer ();
     var targetView = targetViewRenderer.ViewGroup;
     var parent = NativeView;
     var returnPoint = location;
     while (parent != null && parent != targetView) {
         returnPoint.X += parent.Left;
         returnPoint.Y += parent.Top;
         parent = NativeView.Parent as View;
     }
     return returnPoint;
 }
		public void ToggleViewShadow (Xamarin.Forms.View view, bool isOn)
		{
			var renderer = view.GetRenderer ();
			var nativeView = renderer.NativeView;
			nativeView.Layer.ShadowColor = UIColor.Black.CGColor;
			nativeView.Layer.ShadowOpacity = isOn ? 1 : 0;
			nativeView.Layer.ShadowOffset = isOn ? new CGSize (10, 10) : CGSize.Empty;
		}