Exemple #1
0
 public void OnTransitionStart(Android.Transitions.Transition transition)
 {
     _startingType = _container.LayerType;
     if (_startingType != LayerType.Hardware && !_container.IsDisposed())
     {
         _container.SetLayerType(LayerType.Hardware, null);
     }
 }
 /// <summary>
 /// set default values of View
 /// </summary>
 /// <param name="value">Value.</param>
 public static AV.View DefaultSettings(this AV.View value)
 {
     value.SetLayerType(AV.LayerType.Software, null);
     value.DrawingCacheEnabled = true;
     value.DrawingCacheQuality = AV.DrawingCacheQuality.High;
     //value.Focusable = true;
     return(value);
 }
Exemple #3
0
        public static Bitmap ConvertViewToBitmap(Android.Views.View v)
        {
            v.SetLayerType(LayerType.Hardware, null);
            v.DrawingCacheEnabled = true;

            v.Measure(Android.Views.View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified), Android.Views.View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified));
            v.Layout(0, 0, v.MeasuredWidth, v.MeasuredHeight);

            v.BuildDrawingCache(true);
            Bitmap b = Bitmap.CreateBitmap(v.GetDrawingCache(true));

            v.DrawingCacheEnabled = false; // clear drawing cache
            return(b);
        }
Exemple #4
0
        public static Drawable GenerateBackgroundWithShadow(RoundedCornerStackLayout control, Android.Views.View child, Android.Graphics.Color backgroundColor,
                                                            Android.Graphics.Color shadowColor,
                                                            int elevation,
                                                            GravityFlags shadowGravity)
        {
            var radii = GetRadii(control);

            int DY;

            switch (shadowGravity)
            {
            case GravityFlags.Center:
                DY = 0;
                break;

            case GravityFlags.Top:
                DY = -1 * elevation / 3;
                break;

            default:
            case GravityFlags.Bottom:
                DY = elevation / 3;
                break;
            }

            var shapeDrawable = new ShapeDrawable();

            shapeDrawable.Paint.Color = backgroundColor;
            shapeDrawable.Paint.SetShadowLayer(elevation, 0, DY, shadowColor);

            child.SetLayerType(LayerType.Software, shapeDrawable.Paint);

            shapeDrawable.Shape = new RoundRectShape(radii, null, null);

            var drawable = new LayerDrawable(new Drawable[] { shapeDrawable });

            drawable.SetLayerInset(0, elevation, elevation, elevation, elevation);

            child.Background = drawable;
            return(drawable);
        }
		public static void setLayerType(View view, int layerType) {
			view.SetLayerType((LayerType)layerType, null);
            
		}
        public Boolean OnTouch(View v, MotionEvent ev)
        {
            if (_box != null)
            {
                v.SetLayerType(LayerType.Software, null);
                switch (ev.Action)
                {
                    case MotionEventActions.Down:
                        if (_touchState != TouchState.Result)
                        {
                            _touchState = TouchState.None;
                        }
                        int x = (int)ev.GetX();
                        int y = (int)ev.GetY();
                        Android.Graphics.Point cursor = new Android.Graphics.Point(x, y);
                        Android.Graphics.Point leftBot = new Android.Graphics.Point((int)(_box.MidX - _box.Width / 2), (int)(_box.MidY + _box.Height / 2));
                        Android.Graphics.Point rightBot = new Android.Graphics.Point((int)(_box.MidX + _box.Width / 2), (int)(_box.MidY + _box.Height / 2));
                        Android.Graphics.Point rightTop = new Android.Graphics.Point((int)(_box.MidX + _box.Width / 2), (int)(_box.MidY - _box.Height / 2));
                        double botLine = BitmapHelpers.LineToCursorDistance(cursor, leftBot, rightBot);
                        double rightLine = BitmapHelpers.LineToCursorDistance(cursor, rightTop, rightBot);
                        //Choose an binarized image and start OCR
                        if (_touchState == TouchState.Result)
                        {
							if (x <= screenWidth / 2 && y <= screenHeight / 3)
                            {
                                threshhold = threshholds[0];
                            }
							else if (x > screenWidth / 2 && y <= screenHeight / 3)
                            {
                                threshhold = threshholds[1];
                            }
							else if (x <= screenWidth / 2 && y <= screenHeight * 2 / 3)
                            {
                                threshhold = threshholds[2];
                            }
							else if (x > screenWidth / 2 && y <= screenHeight * 2 / 3)
                            {
                                threshhold = threshholds[3];
                            }
							else if (x <= screenWidth / 2 && y <= screenHeight)
                            {
                                threshhold = threshholds[4];
                            }
							else if (x > screenWidth / 2 && y <= screenHeight)
                            {
                                threshhold = threshholds[5];
                            }
                            _surfaceBox.SetOnTouchListener(null);
                            if (!_processDialog.IsShowing)
                            {
                                _processDialog.SetMessage("Waiting for character recognition...");
                                _processDialog.Show();
                            }
                            PerformResult();
                        }
                        //Move box over camera
                        else if (botLine <= lineDistance && rightLine <= lineDistance)
                        {
                            _touchState = TouchState.Mixed;
                        }
                        else if (botLine <= lineDistance)
                        {
                            _touchState = TouchState.Horizontal;
                        }
                        else if (rightLine <= lineDistance)
                        {
                            _touchState = TouchState.Vertical;
                        }
                        else if (x >= _box.MidX - _box.Width / 2 && x <= _box.MidX + _box.Width / 2 && y >= _box.MidY - _box.Height / 2 && y <= _box.MidY + _box.Height / 2)
                        {
                            _touchState = TouchState.Moving;
                        }
                        touchStartX = x;
                        touchStartY = y;
                        break;
                    case MotionEventActions.Move:
                        if (_touchState == TouchState.Moving)
                        {
                            _box.MidX += ev.GetX() - touchStartX;
                            _box.MidY += ev.GetY() - touchStartY;
                        }
                        else if (_touchState == TouchState.Horizontal)
                        {
                            _box.Height += ev.GetY() - touchStartY;
                        }
                        else if (_touchState == TouchState.Vertical)
                        {
                            _box.Width += ev.GetX() - touchStartX;
                        }
                        else if (_touchState == TouchState.Mixed)
                        {
                            _box.Width += ev.GetX() - touchStartX;
                            _box.Height += ev.GetY() - touchStartY;
                        }
                        touchStartX = ev.GetX();
                        touchStartY = ev.GetY();
                        break;
                    case MotionEventActions.Up:
                        if (_touchState == TouchState.Moving)
                        {
                            if (hasAutoFocus && focusReady)
                            {
                                _camera.AutoFocus(this);
                            }
                        }
                        _touchState = TouchState.None;
                        break;
                }
            }
            return false;
        }
        private void ManageLayer(View v, bool enableHardware)
        {
            if (!IsHoneycomb)
            {
                return;
            }

            var layerType = enableHardware ? LayerType.Hardware : LayerType.None;
            if (layerType != v.LayerType)
            {
                v.SetLayerType(layerType, null);
            }
        }