protected override void OnElementChanged(ElementChangedEventArgs <Button> e)
        {
            base.OnElementChanged(e);
            if (e.OldElement != null)
            {
                _myButton = e.OldElement as SizedButton;
            }
            if (e.NewElement != null)
            {
                _myButton = e.NewElement as SizedButton;
            }
            if (Element != null)
            {
                _myButton = Element as SizedButton;
            }

            if (Control != null)
            {
                _androidButton = Control;
                _androidButton.AddOnLayoutChangeListener(this);
            }
            else
            {
                _androidButton = CreateNativeControl();
                SetNativeControl(_androidButton);
            }

            if (_myButton != null)
            {
                //         _androidButton.SetPadding((int)_myButton.Padding.Left, (int)_myButton.Padding.Top,
                //(int)_myButton.Padding.Right, (int)_myButton.Padding.Bottom);
                //         _androidButton.SetWidth(_androidButton.Width + ((int)_myButton.Padding.Left + (int)_myButton.Padding.Right));


                _androidButton.SetIncludeFontPadding(false);
            }
            //_androidButton.SetPadding((int) _myButton.Padding.Left, (int) _myButton.Padding.Top,
            //    (int) _myButton.Padding.Right, (int) _myButton.Padding.Bottom);
            _androidButton.SetMinimumHeight(0);
            _androidButton.SetMinimumWidth(0);
        }
示例#2
0
        protected override void OnElementChanged(ElementChangedEventArgs <Button> e)
        {
            base.OnElementChanged(e);
            if (e.OldElement != null)
            {
                _myButton = e.OldElement as SizedButton;
            }
            if (e.NewElement != null)
            {
                _myButton = e.NewElement as SizedButton;
            }
            if (Element != null)
            {
                _myButton = Element as SizedButton;
            }

            if (Control != null)
            {
                _androidButton = Control;
            }
            else
            {
                _androidButton = CreateNativeControl();
                SetNativeControl(_androidButton);
            }

            if (_myButton != null)
            {
                _androidButton.Elevation = _myButton.Elevation;
                if (!_myButton.Capitalize)
                {
                    _androidButton.SetSupportAllCaps(false);
                }
                if (_myButton.BackgroundColor == Color.Transparent)
                {
                    _androidButton.Background = Context.GetDrawable(Resource.Drawable.abc_btn_borderless_material);
                }
            }
        }
示例#3
0
        public void StartRide_Clicked(object sender, EventArgs e)
        {
            SizedButton rideBtn = ((SizedButton)sender);

            if (!IsRideOngoing)
            {
                IsRideOngoing    = true;
                TempImage.Source = rideBtn.Image;
                rideBtn.Image    = null;
                rideBtn.Text     = "Starting...";
                int  seconds       = 0;
                Task incrementTask = Task.Run(() =>
                {
                    Device.StartTimer(TimeSpan.FromSeconds(1), () =>
                    {
                        if ((IsRideOngoing && !IsCalculatingDist) || (!IsRideOngoing && IsCalculatingDist))
                        {
                            seconds = seconds + 1;
                            // Ensure that seconds is less than TimeSpan.MaxValue.TotalSeconds to avoid an exception
                            TimeSpan time = TimeSpan.FromSeconds(seconds);

                            //here backslash is must to tell that colon is
                            //not the part of format, it just a character that we want in output
                            string str   = time.ToString(@"hh\:mm\:ss");
                            rideBtn.Text = str;
                            return(true);
                        }

                        rideBtn.Image = (FileImageSource)TempImage.Source;
                        return(false);
                    });
                });
            }
            else
            {
                IsRideOngoing = false;
            }
        }