public GestureRecognizerView (Context context)
            : base(context, null, 0)
		{
			_icon = context.Resources.GetDrawable (Resource.Drawable.ic_launcher);
			_icon.SetBounds (0, 0, _icon.IntrinsicWidth, _icon.IntrinsicHeight);
			_scaleDetector = new ScaleGestureDetector (context, new MyScaleListener (this));
		}
Пример #2
0
            public static Bitmap drawableToBitmap(Android.Graphics.Drawables.Drawable drawable)
            {
                Bitmap bitmap = null;

                if (drawable is BitmapDrawable)
                {
                    BitmapDrawable bitmapDrawable = (BitmapDrawable)drawable;
                    if (bitmapDrawable.Bitmap != null)
                    {
                        return(bitmapDrawable.Bitmap);
                    }
                }

                if (drawable.IntrinsicWidth <= 0 || drawable.IntrinsicHeight <= 0)
                {
                    bitmap = Bitmap.CreateBitmap(1, 1, Bitmap.Config.Argb8888); // Single color bitmap will be created of 1x1 pixel
                }
                else
                {
                    bitmap = Bitmap.CreateBitmap(drawable.IntrinsicWidth, drawable.IntrinsicHeight, Bitmap.Config.Argb8888);
                }

                Canvas canvas = new Canvas(bitmap);

                drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
                drawable.Draw(canvas);
                return(bitmap);
            }
Пример #3
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 (facility.Location == null)
            {
                if (facility.Location.GPSCoordinates == null)
                {
                    messageDialog.SendToast("Please add an GPS coordinates");
                    isValid = false;
                }
            }
            return(isValid);
        }
Пример #4
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);
        }
Пример #5
0
        private Bitmap GetBitMapFromDrawable(Android.Graphics.Drawables.Drawable drawable)
        {
            if (drawable == null)
            {
                return(null);
            }

            if (drawable.GetType() == typeof(BitmapDrawable))
            {
                return(((BitmapDrawable)drawable).Bitmap);
            }

            try {
                Bitmap bitmap;
                if (drawable.GetType() == typeof(ColorDrawable))
                {
                    bitmap = Bitmap.CreateBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG);
                }
                else
                {
                    bitmap = Bitmap.CreateBitmap(drawable.IntrinsicWidth, drawable.IntrinsicHeight, BITMAP_CONFIG);
                }

                Canvas canvas = new Canvas(bitmap);
                drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
                drawable.Draw(canvas);
                return(bitmap);
            } catch (OutOfMemoryException e) {
                return(null);
            }
        }
Пример #6
0
        public void LoadObject(GameObjects type, Drawable tile)
        {
            Bitmap bitmap = Bitmap.CreateBitmap (objectSize, objectSize, Bitmap.Config.Argb8888);
            Canvas canvas = new Canvas (bitmap);

            tile.SetBounds (0, 0, objectSize, objectSize);
            tile.Draw (canvas);

            bitmaps [(int)type] = bitmap;
        }
Пример #7
0
            public Bitmap convertToBitmap(Android.Graphics.Drawables.Drawable drawable, int widthPixels, int heightPixels)
            {
                Bitmap mutableBitmap = Bitmap.CreateBitmap(widthPixels, heightPixels, Bitmap.Config.Argb8888);
                Canvas canvas        = new Canvas(mutableBitmap);

                drawable.SetBounds(0, 0, widthPixels, heightPixels);
                drawable.Draw(canvas);

                return(mutableBitmap);
            }
        public void OnLoaded(ImageView p0, Bitmap p1, string p2, bool p3)
        {
            _image = imageView.Drawable;
            _image.SetBounds(0, 0, _image.IntrinsicWidth, _image.IntrinsicHeight);
            _scaleDetector = new ScaleGestureDetector(_context, new MyScaleListener(this));

            var metrics = Resources.DisplayMetrics;
            _posX = GetCornerPosition(PixelConverter.PixelsToDp(metrics.WidthPixels), _image.Bounds.Width()) * (int)_scaleFactor;
            _posY = GetCornerPosition(PixelConverter.PixelsToDp(metrics.HeightPixels), _image.Bounds.Height());
        }
Пример #9
0
        public void LoadPiece(PieceType type, Drawable piece)
        {
            Bitmap bitmap = Bitmap.CreateBitmap (piece_size, piece_size, Bitmap.Config.Argb8888);
            Canvas canvas = new Canvas (bitmap);

            piece.SetBounds (0, 0, piece_size, piece_size);
            piece.Draw (canvas);

            piece_bitmaps[(int)type] = bitmap;
        }
			public MyDragShadowBuilder(View v)
				: base (v)
			{
			
				TypedArray a = v.Context.ObtainStyledAttributes (Resource.Styleable.AppTheme);
				mShadow = a.GetDrawable (Resource.Styleable.AppTheme_listDragShadowBackground);
				mShadow.Callback = v;
				mShadow.SetBounds (0, 0, v.Width, v.Height);
				a.Recycle ();
			}
		// Function to set the specified Drawable as the tile for a particular
		// integer key.
		public void LoadTile (TileType type, Drawable tile)
		{
			Bitmap bitmap = Bitmap.CreateBitmap (tile_size, tile_size, Bitmap.Config.Argb8888);
			Canvas canvas = new Canvas (bitmap);

			tile.SetBounds (0, 0, tile_size, tile_size);
			tile.Draw (canvas);

			tile_bitmaps[(int)type] = bitmap;
		}
Пример #12
0
 public static void SetHotspotBounds(Drawables.Drawable drawable, int left, int top, int right, int bottom)
 {
     if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
     {
         //We don't want the full size rect, Lollipop ripple would be too big
         int size = (right - left) / 8;
         DrawableCompat.SetHotspotBounds(drawable, left + size, top + size, right - size, bottom - size);
     }
     else
     {
         drawable.SetBounds(left, top, right, bottom);
     }
 }
Пример #13
0
        public GestureRecognizerView(Context context, String imageUrl)
            : base(context, null, 0)
        {
            _context = context;
            imageView = new ImageView(context);
            Koush.UrlImageViewHelper.SetUrlDrawable(imageView, imageUrl, Resource.Drawable.placeholder, this);
            _image = imageView.Drawable;
            _image.SetBounds(0, 0, _image.IntrinsicWidth, _image.IntrinsicHeight);

            //_scaleDetector = new ScaleGestureDetector(context, new MyScaleListener(this));

            //var metrics = Resources.DisplayMetrics;
            //_posX = GetCornerPosition(PixelConverter.PixelsToDp(metrics.WidthPixels), _image.Bounds.Width()) * (int)_scaleFactor;
            //_posY = GetCornerPosition(PixelConverter.PixelsToDp(metrics.HeightPixels), _image.Bounds.Height());
        }
Пример #14
0
		public static Bitmap DrawableToBitmap(Drawable drawable)
		{
			if (drawable is BitmapDrawable)
			{
				return ((BitmapDrawable)drawable).Bitmap;
			}

			if (drawable.IntrinsicHeight == -1 || drawable.IntrinsicHeight == -1)
				return null;

			Bitmap bitmap = Bitmap.CreateBitmap(drawable.IntrinsicWidth, drawable.IntrinsicHeight, Bitmap.Config.Argb8888);
			Canvas canvas = new Canvas(bitmap);
			drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
			drawable.Draw(canvas);

			return bitmap;
		}
Пример #15
0
        private bool ValidateForm()
        {
            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;
            bool photoIsRequired          = false;
            bool GPSCoordinatesIsRequired = false;

            if (!validation.IsRequired(buildingName.Text))
            {
                buildingName.SetError("This field is required", icon);
                isValid = false;
            }
            if (!validation.IsRequired(utilisationStatus.Text))
            {
                utilisationStatus.SetError("This field is required", icon);
                isValid = false;
            }
            if (!validation.IsRequired(constructionDescription.Text))
            {
                constructionDescription.SetError("This field is required", icon);
                isValid = false;
            }
            if (!validation.IsRequired(totalFootprintAream2.Text))
            {
                totalFootprintAream2.SetError("This field is required", icon);
                isValid = false;
            }
            if (!validation.IsRequired(totalImprovedaAeam2.Text))
            {
                totalImprovedaAeam2.SetError("This field is required", icon);
                isValid = false;
            }
            return(isValid);
        }
Пример #16
0
 private void InitializeBuildingMarker()
 {
     _buildingMarker = Resources.GetDrawable(Resource.Drawable.building_medium);
     _buildingMarker.SetBounds(0, 0, _buildingMarker.IntrinsicWidth, _buildingMarker.IntrinsicHeight);
 }
Пример #17
0
        /**
         * Convert a drawable object into a Bitmap.
         * @param drawable Drawable to extract a Bitmap from.
         * @return A Bitmap created from the drawable parameter.
         */
        public Bitmap DrawableToBitmap(Drawable drawable)
        {
            if (drawable == null)   // Don't do anything without a proper drawable
                return null;
            else if (drawable.GetType() == typeof(BitmapDrawable))    // Use the getBitmap() method instead if BitmapDrawable
                return ((BitmapDrawable)drawable).Bitmap;

            // Create Bitmap object out of the drawable
            Bitmap bitmap = Bitmap.CreateBitmap(drawable.IntrinsicWidth, drawable.IntrinsicHeight, Bitmap.Config.Argb8888);
            Canvas canvas = new Canvas(bitmap);
            drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
            drawable.Draw(canvas);

            // Return the created Bitmap
            return bitmap;
        }
		public virtual Bitmap drawableToBitmap(Drawable drawable)
		{
			if (drawable == null)
			{
				return null;
			}
			else if (drawable is BitmapDrawable)
			{
				return ((BitmapDrawable)drawable).Bitmap;
			}

			Bitmap bitmap = Bitmap.CreateBitmap(drawable.IntrinsicWidth, drawable.IntrinsicHeight, Bitmap.Config.Argb8888);
			Canvas canvas = new Canvas(bitmap);
			drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
			drawable.Draw(canvas);

			return bitmap;
		}
Пример #19
0
        public static Drawable SetAlignment(Drawable drawable, int bitset)
        {
            if (drawable != null)
            {
                int w = drawable.IntrinsicWidth;
                int h = drawable.IntrinsicHeight;

                int l = -(w >> 1);
                int r = l + w;
                int t = -(h >> 1);
                int b = t + h;
                int count = 0;
                while ((bitset != 0) && (count++ < 3))
                {
                    if ((bitset & 0x1) > 0)
                    {
                        l = -(w >> 1);
                        r = l + w;
                        bitset ^= 0x1;
                    }
                    else if ((bitset & 0x2) > 0)
                    {
                        t = -(h >> 1);
                        b = t + h;
                        bitset ^= 0x2;
                    }
                    else if ((bitset & 0x20) > 0)
                    {
                        t = -h;
                        b = 0;
                        bitset ^= 0x20;
                    }
                    else if ((bitset & 0x10) > 0)
                    {
                        t = 0;
                        b = h;
                        bitset ^= 0x10;
                    }
                    else if ((bitset & 0x8) > 0)
                    {
                        r = 0;
                        l = -w;
                        bitset ^= 0x8;
                    }
                    else if ((bitset & 0x4) > 0)
                    {
                        l = 0;
                        r = w;
                        bitset ^= 0x4;
                    }
                }
                drawable.SetBounds(l, t, r, b);
            }
            return drawable;
        }
        private Bitmap GetBitmapFromDrawable(Drawable drawable)
        {
            if (drawable == null)
            {
                return null;
            }

            var bitmapDrawable = drawable as BitmapDrawable;
            if (bitmapDrawable != null)
            {
                return bitmapDrawable.Bitmap;
            }

            try
            {
                Bitmap bitmap;

                if (drawable is ColorDrawable)
                {
                    bitmap = Bitmap.CreateBitmap(ColordrawableDimension, ColordrawableDimension, BitmapConfig);
                }
                else
                {
                    bitmap = Bitmap.CreateBitmap(drawable.IntrinsicWidth, drawable.IntrinsicHeight, BitmapConfig);
                }

                var canvas = new Canvas(bitmap);
                drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
                drawable.Draw(canvas);
                return bitmap;
            }
            catch (OutOfMemoryException)
            {
                return null;
            }
        }
Пример #21
0
        public static Bitmap DrawableToBitmap(Drawable drawable)
        {
            var bitmapDrawable = drawable as BitmapDrawable;
            if (bitmapDrawable != null)
            {
                return bitmapDrawable.Bitmap;
            }

            Bitmap bitmap;
            int width = Math.Max(drawable.IntrinsicWidth, 1);
            int height = Math.Max(drawable.IntrinsicHeight, 1);
            try
            {
                bitmap = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888);
                var canvas = new Canvas(bitmap);
                drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
                drawable.Draw(canvas);
            }
            catch (Exception)
            {
                bitmap = null;
            }

            return bitmap;
        }
Пример #22
0
        private Bitmap DrawableToBitmap(Drawable drawable)
        {
            try
            {
                if (drawable is BitmapDrawable)
                    return ((BitmapDrawable)drawable).Bitmap;

                Bitmap bitmap = Bitmap.CreateBitmap(drawable.IntrinsicWidth, drawable.IntrinsicHeight, Bitmap.Config.Argb8888);
                Canvas canvas = new Canvas(bitmap);
                drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
                drawable.Draw(canvas);

                return bitmap;
            }
            catch (Exception ex)
            {
                //FirstLog.Error(FirstApplication.ApplicationName + "Log", "ResizeBitmap: " + ex.Message);
                return null;
            }
        }
Пример #23
0
        private Bitmap getBitmapFromDrawable(Drawable drawable)
        {
            if (drawable == null)
            {
                return null;
            }

            if (drawable is BitmapDrawable)
            {
                return ((BitmapDrawable)drawable).Bitmap;
            }

            try
            {
                Bitmap bitmap;

                if (drawable is ColorDrawable)
                {
                    bitmap = Bitmap.CreateBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG);
                }
                else {
                    bitmap = Bitmap.CreateBitmap(drawable.IntrinsicWidth, drawable.IntrinsicHeight, BITMAP_CONFIG);
                }

                Canvas canvas = new Canvas(bitmap);
                drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
                drawable.Draw(canvas);
                return bitmap;
            }
            catch
            { //catch (OutOfMemoryException e) {
                return null;
            }
        }