private bool ValidateForm()
        {
            Validations validation = new Validations();

            Android.Graphics.Drawables.Drawable icon = Resources.GetDrawable(Resource.Drawable.error);
            icon.SetBounds(0, 0, icon.IntrinsicWidth, icon.IntrinsicHeight);

            FormIsValid = true;

            if (!validation.IsValidEmail(username.Text))
            {
                username.SetError("Invalid username", icon);
                FormIsValid = false;
            }
            if (!validation.IsRequired(username.Text))
            {
                username.SetError("This field is required", icon);
                FormIsValid = false;
            }

            if (!validation.IsRequired(password.Text))
            {
                password.SetError("This field is required", icon);
                FormIsValid = false;
            }

            return(FormIsValid);
        }
Esempio n. 2
0
        private bool ValidateDeedInfo()
        {
            Validations   validation    = new Validations();
            MessageDialog messageDialog = new MessageDialog();

            Android.Graphics.Drawables.Drawable icon = Resources.GetDrawable(Resource.Drawable.error);
            icon.SetBounds(0, 0, icon.IntrinsicWidth, icon.IntrinsicHeight);

            bool isValid = true;

            if (!validation.IsRequired(erfNumber.Text))
            {
                erfNumber.SetError("This field is required", icon);
                isValid = false;
            }
            if (!validation.IsRequired(titleDeedNumber.Text))
            {
                titleDeedNumber.SetError("This field is required", icon);
                isValid = false;
            }
            if (!validation.IsRequired(extentm2.Text))
            {
                extentm2.SetError("This field is required", icon);
                isValid = false;
            }
            if (!validation.IsRequired(ownerInformation.Text))
            {
                ownerInformation.SetError("This field is required", icon);
                isValid = false;
            }
            return(isValid);
        }
        private bool ValidateForm()
        {
            Validations validation = new Validations();

            Android.Graphics.Drawables.Drawable icon = Resources.GetDrawable(Resource.Drawable.error);
            icon.SetBounds(0, 0, icon.IntrinsicWidth, icon.IntrinsicHeight);

            FormIsValid = true;

            if (!validation.IsValidPhone(courierMobileNumber.Text))
            {
                courierMobileNumber.SetError("Invaild phone number", icon);
                FormIsValid = false;
            }
            if (!validation.IsRequired(pricePerKM.Text))
            {
                pricePerKM.SetError("This field is required", icon);
                FormIsValid = false;
            }

            if (!validation.IsRequired(displayName.Text))
            {
                displayName.SetError("This field is required", icon);
                FormIsValid = false;
            }
            return(FormIsValid);
        }
Esempio n. 4
0
        /// <summary>
        /// 缩放图片
        /// </summary>
        /// <param name="drawable"></param>
        /// <param name="maxWidth"></param>
        /// <returns></returns>
        private Bitmap ScalingDrawable(Android.Graphics.Drawables.Drawable drawable, int maxWidth)
        {
            if (drawable == null || drawable.IntrinsicWidth == 0 || drawable.IntrinsicHeight == 0)
            {
                return(null);
            }

            int width  = drawable.IntrinsicWidth;
            int height = drawable.IntrinsicHeight;

            try
            {
                Bitmap image  = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888);
                Canvas canvas = new Canvas(image);
                drawable.SetBounds(0, 0, width, height);
                drawable.Draw(canvas);
                // 精确缩放
                if (maxWidth <= 0 || width <= maxWidth)
                {
                    return(image);
                }

                float  scale  = maxWidth / (float)width;
                Matrix matrix = new Matrix();
                matrix.PostScale(scale, scale);
                Bitmap resizeImage = Bitmap.CreateBitmap(image, 0, 0, width, height, matrix, true);
                image.Recycle();
                return(resizeImage);
            }
            catch (OutOfMemoryError)
            {
                return(null);
            }
        }
Esempio n. 5
0
        protected void InitRadioButtons(string[,] aLaunchExtensions, string aUrl, string aResourceID, RadioGroup aRadioGroup)
        {
            aRadioGroup.RemoveAllViews();

            SortedList <int, RadioButton> _myList = new SortedList <int, RadioButton>();

            for (int i = 0; i < aLaunchExtensions.GetLength(0); i++)
            {
                string _curS     = aLaunchExtensions[i, 0];
                string _curParam = aLaunchExtensions[i, 1];

                RadioButton _button = new RadioButton(this);
                _button.Text = string.Format("{0} [{1}]", _curS, _curParam);
                _button.Tag  = i;

                string _resourceName = aResourceID + _curParam;
                if (_resourceName == aResourceID)
                {
                    _resourceName = aResourceID + "nothing";
                }
                ;

                // int _resourceID = Resources.GetIdentifier(_resourceName, "drawable", this.PackageName);
                if (_resourceName != "nothing")
                {
                    try
                    {
                        var _resourceID = (int)typeof(Resource.Drawable).GetField(_resourceName).GetValue(null);
                        if (_resourceID > 0)
                        {
                            Android.Graphics.Drawables.Drawable _d = Resources.GetDrawable(_resourceID);
                            _d.SetBounds(0, 0, 120, 120);
                            _button.SetCompoundDrawables(_d, null, null, null);
                        }
                        ;
                    }
                    catch { };
                }
                ;
                aRadioGroup.AddView(_button);

                if ((aUrl.IndexOf(_curParam) >= 0) && (_curParam != ""))
                {
                    _myList.Add(_curParam.Length, _button);
                }
                ;
            }
            ;

            if (_myList.Count > 0)
            {
                RadioButton _button = _myList.Values[_myList.Count() - 1];
                aRadioGroup.Check(_button.Id);
            }
            ;
        }
Esempio n. 6
0
        private bool ValidateForm()
        {
            Validations validation = new Validations();

            Android.Graphics.Drawables.Drawable icon = Resources.GetDrawable(Resource.Drawable.error);
            icon.SetBounds(0, 0, icon.IntrinsicWidth, icon.IntrinsicHeight);

            bool formIsValid = true;

            if (!validation.IsRequired(message.Text))
            {
                message.SetError("This field is required", icon);
                formIsValid = false;
            }
            return(formIsValid);
        }
        private bool ValidateForm()
        {
            Validations validation = new Validations();

            Android.Graphics.Drawables.Drawable icon = Resources.GetDrawable(Resource.Drawable.error);
            icon.SetBounds(0, 0, icon.IntrinsicWidth, icon.IntrinsicHeight);

            FormIsValid = true;

            if (!validation.IsValidEmail(username.Text))
            {
                username.SetError("Invalid email address", icon);
                FormIsValid = false;
            }

            if (!validation.IsValidPassword(password.Text))
            {
                password.SetError("Password cannot be empty and length must be greater than 6 characters", icon);
                FormIsValid = false;
            }
            if (!validation.IsValidPassword(confirmPassword.Text))
            {
                confirmPassword.SetError("Password cannot be empty and length must be greater than 6 characters", icon);
                FormIsValid = false;
            }

            if (!validation.IsValidOTP(oneTimePin.Text))
            {
                oneTimePin.SetError("Invalid one time pin", icon);
                FormIsValid = false;
            }

            if (confirmPassword.Text != password.Text)
            {
                confirmPassword.SetError("Password and confirm password don't match", icon);
                FormIsValid = false;
            }

            return(FormIsValid);
        }
Esempio n. 8
0
        private bool ValidateLocation()
        {
            Validations   validation    = new Validations();
            MessageDialog messageDialog = new MessageDialog();

            Android.Graphics.Drawables.Drawable icon = Resources.GetDrawable(Resource.Drawable.error);
            icon.SetBounds(0, 0, icon.IntrinsicWidth, icon.IntrinsicHeight);

            bool isValid = true;

            if (!validation.IsRequired(streetAddress.Text))
            {
                streetAddress.SetError("This field is required", icon);
                isValid = false;
            }
            if (!validation.IsRequired(suburb.Text))
            {
                suburb.SetError("This field is required", icon);
                isValid = false;
            }
            if (Location == null)
            {
                if (Location.GPSCoordinates == null)
                {
                    messageDialog.SendToast("Please add an GPS coordinates");
                    isValid = false;
                }
            }
            else
            {
                if (Location.GPSCoordinates == null)
                {
                    messageDialog.SendToast("Please add an GPS coordinates");
                    isValid = false;
                }
            }
            return(isValid);
        }
Esempio n. 9
0
        private bool ValidateForm()
        {
            Validations validation = new Validations();

            Android.Graphics.Drawables.Drawable icon = Resources.GetDrawable(Resource.Drawable.error);
            icon.SetBounds(0, 0, icon.IntrinsicWidth, icon.IntrinsicHeight);

            bool formIsValid = true;

            if (!validation.IsValidEmail(username.Text))
            {
                username.SetError("Invalid email address", icon);
                formIsValid = false;
            }

            if (!validation.IsValidPassword(password.Text))
            {
                password.SetError("Password cannot be empty and length must be greater than 6 characters", icon);
                formIsValid = false;
            }

            return(formIsValid);
        }
Esempio n. 10
0
        private bool ValidateForm()
        {
            Validations validation = new Validations();

            Android.Graphics.Drawables.Drawable icon = Resources.GetDrawable(Resource.Drawable.error);
            icon.SetBounds(0, 0, icon.IntrinsicWidth, icon.IntrinsicHeight);

            bool formIsValid = true;

            if (vehiclebodytype.SelectedItem.ToString() == "Select Vehicle Body Type")
            {
                MessageDialog messageDialog = new MessageDialog();
                messageDialog.SendToast("Please Select Vehicle Body Type");
                formIsValid = false;
            }

            if (!validation.IsValidEmail(email.Text))
            {
                email.SetError("Invalid email address", icon);
                formIsValid = false;
            }

            if (!validation.IsValidPhone(phone.Text))
            {
                phone.SetError("Invaild phone number", icon);
                formIsValid = false;
            }
            if (!validation.IsRequired(name.Text))
            {
                name.SetError("This field is required", icon);
                formIsValid = false;
            }
            if (!validation.IsRequired(pickupLocation.Text))
            {
                pickupLocation.SetError("This field is required", icon);
                formIsValid = false;
            }
            else
            {
                var pickupLocationPlaceId = PickUpLocations.FirstOrDefault(l => l.Description.Trim() == pickupLocation.Text.Trim());
                if (pickupLocationPlaceId == null)
                {
                    pickupLocation.SetError("Unable to get your pick up location", icon);
                    formIsValid = false;
                }
                else
                {
                    fromLocation = GetLocationDetails(pickupLocationPlaceId.PlaceId, pickupLocation.Text.Trim());
                }
            }
            if (!validation.IsRequired(dropLocation.Text))
            {
                dropLocation.SetError("This field is required", icon);
                formIsValid = false;
            }
            else
            {
                var dropLocationPlaceId = DropLocations.FirstOrDefault(l => l.Description.Trim() == dropLocation.Text.Trim());
                if (dropLocationPlaceId == null)
                {
                    dropLocation.SetError("Unable to get your drop location", icon);
                    formIsValid = false;
                }
                else
                {
                    tolocation = GetLocationDetails(dropLocationPlaceId.PlaceId, pickupLocation.Text.Trim());
                }
            }

            return(formIsValid);
        }
Esempio n. 11
0
        private bool ValidateForm()
        {
            Validations validation = new Validations();

            Android.Graphics.Drawables.Drawable icon = Resources.GetDrawable(Resource.Drawable.error);
            icon.SetBounds(0, 0, icon.IntrinsicWidth, icon.IntrinsicHeight);

            FormIsValid = true;

            if (string.IsNullOrEmpty(Logo))
            {
                MessageDialog messageDialog = new MessageDialog();
                messageDialog.SendToast("Select Profile Picture");
                FormIsValid = false;
            }

            if (mSelectedItems == null)
            {
                MessageDialog messageDialog = new MessageDialog();
                messageDialog.SendToast("Please Choose Your Vehicle Body Type");
                FormIsValid = false;
            }

            if (!validation.IsValidEmail(username.Text))
            {
                username.SetError("Invalid email address", icon);
                FormIsValid = false;
            }

            if (!validation.IsValidPassword(password.Text))
            {
                password.SetError("Password cannot be empty and length must be greater than 6 characters", icon);
                FormIsValid = false;
            }

            if (!validation.IsValidPassword(confirmPassword.Text))
            {
                confirmPassword.SetError("Password cannot be empty and length must be greater than 6 characters", icon);
                FormIsValid = false;
            }

            if (confirmPassword.Text != password.Text)
            {
                confirmPassword.SetError("Password and confirm password don't match", icon);
                FormIsValid = false;
            }

            if (!validation.IsValidPhone(courierMobileNumber.Text))
            {
                courierMobileNumber.SetError("Invaild phone number", icon);
                FormIsValid = false;
            }
            if (!validation.IsRequired(pricePerKM.Text))
            {
                pricePerKM.SetError("This field is required", icon);
                FormIsValid = false;
            }

            if (!validation.IsRequired(displayName.Text))
            {
                displayName.SetError("This field is required", icon);
                FormIsValid = false;
            }
            return(FormIsValid);
        }
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            int saveCount = canvas.Save();

            RectF arcBounds = mTempBounds;

            arcBounds.Set(bounds);
            arcBounds.Inset(mStrokeXInset, mStrokeYInset);

            mCurrentProgressBounds.Set(arcBounds.Left, arcBounds.Bottom - 2 * mCenterRadius, arcBounds.Right, arcBounds.Bottom);

            //Draw loading Drawable
            mLoadingDrawable.SetBounds((int)arcBounds.CenterX() - mLoadingDrawable.IntrinsicWidth / 2, 0, (int)arcBounds.CenterX() + mLoadingDrawable.IntrinsicWidth / 2, mLoadingDrawable.IntrinsicHeight);
            mLoadingDrawable.Draw(canvas);

            //Draw progress background
            float progressInset = mCenterRadius - mProgressCenterRadius;
            RectF progressRect  = new RectF(mCurrentProgressBounds);

            //sub DEFAULT_STROKE_INTERVAL, otherwise will have a interval between progress background and progress outline
            progressRect.Inset(progressInset - DEFAULT_STROKE_INTERVAL, progressInset - DEFAULT_STROKE_INTERVAL);
            mPaint.Color = new Color(mProgressBgColor);
            mPaint.SetStyle(Paint.Style.Fill);
            canvas.DrawRoundRect(progressRect, mProgressCenterRadius, mProgressCenterRadius, mPaint);

            //Draw progress
            mPaint.Color = new Color(mProgressColor);
            mPaint.SetStyle(Paint.Style.Fill);
            canvas.DrawPath(CreateProgressPath(mProgress, mProgressCenterRadius, progressRect), mPaint);

            //Draw leaves
            for (int i = 0; i < mLeafHolders.Count; i++)
            {
                int        leafSaveCount = canvas.Save();
                LeafHolder leafHolder    = mLeafHolders[i];
                Rect       leafBounds    = leafHolder.mLeafRect;

                canvas.Rotate(leafHolder.mLeafRotation, leafBounds.CenterX(), leafBounds.CenterY());
                mLeafDrawable.Bounds = leafBounds;
                mLeafDrawable.Draw(canvas);

                canvas.RestoreToCount(leafSaveCount);
            }

            //Draw progress background outline,
            //after Drawing the leaves and then Draw the outline of the progress background can
            //prevent the leaves from flying to the outside
            RectF progressOutlineRect        = new RectF(mCurrentProgressBounds);
            float progressOutlineStrokeInset = (mCenterRadius - mProgressCenterRadius) / 2.0f;

            progressOutlineRect.Inset(progressOutlineStrokeInset, progressOutlineStrokeInset);
            mPaint.SetStyle(Paint.Style.Stroke);
            mPaint.Color       = new Color(mProgressBgColor);
            mPaint.StrokeWidth = mCenterRadius - mProgressCenterRadius;
            canvas.DrawRoundRect(progressOutlineRect, mCenterRadius, mCenterRadius, mPaint);

            //Draw electric fan outline
            float electricFanCenterX = arcBounds.Right - mCenterRadius;
            float electricFanCenterY = arcBounds.Bottom - mCenterRadius;

            mPaint.Color = new Color(mElectricFanOutlineColor);
            mPaint.SetStyle(Paint.Style.Stroke);
            mPaint.StrokeWidth = mStrokeWidth;
            canvas.DrawCircle(arcBounds.Right - mCenterRadius, arcBounds.Bottom - mCenterRadius, mCenterRadius - mStrokeWidth / 2.0f, mPaint);

            //Draw electric background
            mPaint.Color = new Color(mElectricFanBgColor);
            mPaint.SetStyle(Paint.Style.Fill);
            canvas.DrawCircle(arcBounds.Right - mCenterRadius, arcBounds.Bottom - mCenterRadius, mCenterRadius - mStrokeWidth + DEFAULT_STROKE_INTERVAL, mPaint);

            //Draw electric fan
            int rotateSaveCount = canvas.Save();

            canvas.Rotate(mRotation, electricFanCenterX, electricFanCenterY);
            mElectricFanDrawable.SetBounds((int)(electricFanCenterX - mElectricFanDrawable.IntrinsicWidth / 2 * mScale), (int)(electricFanCenterY - mElectricFanDrawable.IntrinsicHeight / 2 * mScale), (int)(electricFanCenterX + mElectricFanDrawable.IntrinsicWidth / 2 * mScale), (int)(electricFanCenterY + mElectricFanDrawable.IntrinsicHeight / 2 * mScale));
            mElectricFanDrawable.Draw(canvas);
            canvas.RestoreToCount(rotateSaveCount);

            //Draw 100% text
            if (mScale < 1.0f)
            {
                mPaint.TextSize = mTextSize * (1 - mScale);
                mPaint.Color    = new Color(mElectricFanOutlineColor);
                Rect textRect = new Rect();
                mPaint.GetTextBounds(PERCENTAGE_100, 0, PERCENTAGE_100.Length, textRect);
                canvas.DrawText(PERCENTAGE_100, electricFanCenterX - textRect.Width() / 2.0f, electricFanCenterY + textRect.Height() / 2.0f, mPaint);
            }

            canvas.RestoreToCount(saveCount);
        }