Esempio n. 1
0
        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;
        }
Esempio n. 2
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;
        }
Esempio n. 3
0
        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;
        }
        public void MonitorView(View view)
        {
            view.PropertyChanged += (_, propArgs) =>
            {
                // subscribe to UIElement events when the attached property Renderer is set
                if (propArgs.PropertyName == Platform.RendererProperty.PropertyName)
                {

                    ViewRenderer renderer = view.GetRenderer() as ViewRenderer;
                 //   renderer.Element.BackgroundColor = Color.Red;

                    renderer.Hold += Control_Hold;
                    renderer.DoubleTap += Control_DoubleTap;
                    renderer.Tap += Control_Tap;
                    renderer.ManipulationCompleted += Control_ManipulationCompleted;
                    renderer.ManipulationStarted += Control_ManipulationStarted;
                    renderer.ManipulationDelta += Control_ManipulationDelta;
                }
            };
        }
Esempio n. 5
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);
        }