protected override void OnElementChanged(ElementChangedEventArgs <MultilineEntry> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                nativeEditText = new EditText(Forms.Context);

                var element = e.NewElement as MultilineEntry;
                var font    = Typeface.CreateFromAsset(Forms.Context.ApplicationContext.Assets, "MuseoSansCyrl_0.otf");
                nativeEditText.Typeface     = font;
                nativeEditText.TextSize     = 14f;
                nativeEditText.TextChanged += NativeEditor_TextChanged;

                nativeEditText.Background = Context.GetDrawable(Resource.Drawable.MultilineEntryLayout);
                nativeEditText.Hint       = element.MyText;
                nativeEditText.SetHintTextColor(Xam.Color.Gray.ToAndroid());
                nativeEditText.Enabled = true;
                nativeEditText.SetLines(4);
                nativeEditText.SetMinLines(4);

                // background drawable
                var backgroundDrawable = (Andrd.Drawables.LayerDrawable)nativeEditText.Background;
                Andrd.Drawables.GradientDrawable bottomline = (Andrd.Drawables.GradientDrawable)backgroundDrawable.FindDrawableByLayerId(Resource.Id.bottomline);
                Andrd.Color strokeColor = element.BottomLineColor.ToAndroid();
                bottomline.SetStroke(bottomline.IntrinsicWidth, strokeColor);

                SetNativeControl(nativeEditText);
            }
        }
Exemplo n.º 2
0
        public PMButton(Context context) : base(context)
        {
            Gravity = Android.Views.GravityFlags.Center;
            SetTextColor(Color.White);

            var background = new Android.Graphics.Drawables.GradientDrawable();

            background.SetColor(Colors.ActionBar.ToArgb());
            background.SetCornerRadius(5);

            Background = background;
        }
        void SetCornerRadius(int radius)
        {
#if __IOS__
            Layer.CornerRadius = radius;
#elif __ANDROID__
            var existing = View.BackgroundColor.ToNativeColor();

            var drawable = new Android.Graphics.Drawables.GradientDrawable();
            drawable.SetCornerRadius(View.CornerRadius * Forms.Context.Resources.DisplayMetrics.Density);
            drawable.SetColor(existing.ToArgb());

            Background = drawable;
#endif
        }
Exemplo n.º 4
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName == CustomEditor.PlaceholderProperty.PropertyName)
            {
                var element = this.Element as CustomEditor;
                this.Control.Hint = element.Placeholder;
                this.Control.SetHintTextColor(ag.Color.ParseColor("#e5e5e5"));
            }

            if (Control != null)
            {
                Graphicss.Drawables.GradientDrawable gd = new Graphicss.Drawables.GradientDrawable();
                gd.SetColor(global::Android.Graphics.Color.Transparent);
                gd.SetStroke(2, global::Android.Graphics.Color.Gray);
                this.Control.SetBackgroundDrawable(gd);
            }
        }
Exemplo n.º 5
0
        protected override void OnElementChanged(ElementChangedEventArgs <RoundedBoxView> e)
        {
            if (Control == null)
            {
                var nativeControl = new Android.Views.View(Context);
                controlBackground        = new Android.Graphics.Drawables.GradientDrawable();
                nativeControl.Background = controlBackground;
                nativeControl.Click     += OnClick;
                SetNativeControl(nativeControl);
            }

            if (e.NewElement != null)
            {
                // Formsコントロールのプロパティ値を反映
                UpdateRadius();
                UpdateColor();
            }

            base.OnElementChanged(e);
        }
        private void UpdateColors()
        {
            var element = Element as CustomSwitch;

            var track = new Android.Graphics.Drawables.GradientDrawable();

            track.SetColor(element.TrackColor.ToAndroid());
            track.SetSize((int)Element.Width, (int)Element.Height);
            Control.TrackDrawable = track;

            var thumb = new Android.Graphics.Drawables.GradientDrawable();

            if (Element.IsToggled)
            {
                thumb.SetColor(element.OnThumbColor.ToAndroid());
            }
            else
            {
                thumb.SetColor(element.OffThumbColor.ToAndroid());
            }

            Control.ThumbDrawable = thumb;
        }
Exemplo n.º 7
0
        protected override void OnElementChanged(ElementChangedEventArgs <Editor> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                var element = e.NewElement as CustomEditor;
                this.Control.Hint = element.Placeholder;
                this.Control.SetHintTextColor(ag.Color.Gray);
                this.Control.SetBackgroundColor(global::Android.Graphics.Color.White);
                this.Control.SetCursorVisible(true);
                //if (Control != null)
                //{
                Graphicss.Drawables.GradientDrawable gd = new Graphicss.Drawables.GradientDrawable();
                gd.SetColor(global::Android.Graphics.Color.Transparent);
                gd.SetStroke(2, global::Android.Graphics.Color.Gray);
                this.Control.SetBackgroundDrawable(gd);
                //}
                //	this.Control.Background = this.Resources.GetDrawable(Resource.Drawable.withBorder);
            }

            // This line do the trick
            //			Control.FocusChange += Control_FocusChange;
        }
Exemplo n.º 8
0
        public PMButton(Context context)
            : base(context)
        {
            Gravity = Android.Views.GravityFlags.Center;
            SetTextColor(Color.White);

            var background = new Android.Graphics.Drawables.GradientDrawable();
            background.SetColor(Colors.ActionBar.ToArgb());
            background.SetCornerRadius(5);

            Background = background;
        }
Exemplo n.º 9
0
        public async Task Show(TopAlert alert)
        {
            await Stop();

            this._Token = new CancellationTokenSource();

            this._Delay = alert.Duration;

            var            activity      = Xamarin.Forms.Forms.Context as Android.App.Activity;
            IWindowManager windowManager = Xamarin.Forms.Forms.Context.GetSystemService(Android.App.Service.WindowService).JavaCast <IWindowManager>();

            this._Layout = (LinearLayout)activity.LayoutInflater.Inflate(Resource.Layout.AlertBox, null, false);
            this._Layout.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            var submain = this._Layout.FindViewById <LinearLayout> (Resource.Id.linearLayout3);

            submain.SetBackgroundColor(alert.BackgroundColor.ToAndroid());

            var main = _Layout.FindViewById <LinearLayout> (Resource.Id.linearLayout1);

            var id = Xamarin.Forms.Forms.Context.Resources.GetIdentifier("alertborder", "drawable", Xamarin.Forms.Forms.Context.PackageName);

            Android.Graphics.Drawables.GradientDrawable drawable =
                Xamarin.Forms.Forms.Context.Resources.GetDrawable(id).JavaCast <Android.Graphics.Drawables.GradientDrawable>();


            var text = submain.FindViewById <TextView> (Resource.Id.textView1);

            text.SetTextColor(alert.TextColor.ToAndroid());
            text.Text = alert.Text;

            if (alert.TextSize > 0)
            {
                text.TextSize = alert.TextSize;
            }

            drawable.SetColor(alert.BorderColor.ToAndroid());
            drawable.SetCornerRadius(alert.BorderWidth);
            main.SetBackground(drawable);

            //activity.ActionBar.Hide ();

            var actionBarHeight = activity.ActionBar.Height;

            var intent = alert.Intent;

            var p = new WindowManagerLayoutParams(
                windowManager.DefaultDisplay.Width - intent * 2,
                (alert.AlertHeight < 0 ? 200 : (int)alert.AlertHeight),
                WindowManagerTypes.SystemAlert,
                0 | WindowManagerFlags.NotFocusable,
                Android.Graphics.Format.Translucent);

            var yOffset = alert.TopOffset;

            p.Gravity = GravityFlags.Top | GravityFlags.Left;
            p.X       = intent;
            p.Y       = alert.TopOffset + yOffset + (activity.ActionBar.IsShowing ? actionBarHeight : 0);
            p.Height  = (alert.AlertHeight < 0 ? 200 : (int)alert.AlertHeight);
            windowManager.AddView(_Layout, p);

            this._Layout.Touch += LayoutTouched;

            Task.Run(async() => {
                await Task.Delay(alert.Duration, this._Token.Token);

                if (this._Token != null && this._Token.IsCancellationRequested == false)
                {
                    if (alert.FadeOut)
                    {
                        Xamarin.Forms.Device.BeginInvokeOnMainThread(() => {
                            // this works
                            this._fadeOut = ObjectAnimator.OfFloat(_Layout, "alpha", 1f, 0f);
                            this._fadeOut.SetDuration(1000);
                            this._fadeOut.AnimationEnd += _fadeOut_AnimationEnd;
                            this._Set = new AnimatorSet();
                            this._Set.Play(_fadeOut);
                            this._Set.Start();
                        });
                    }
                    else
                    {
                        Stop();
                    }
                }
            });
        }