protected override void OnSizeChanged(int w, int h, int oldw, int oldh) { base.OnSizeChanged(w, h, oldw, oldh); // get width and height of navigation bar // Navigation bar bounds (width & height) mNavigationBarWidth = Width; mNavigationBarHeight = Height; differenceOfScreen = Height - tabHeight; // the coordinates (x,y) of the start point before curve //mFirstCurveStartPoint.Set((mNavigationBarWidth / 2) - (CURVE_CIRCLE_RADIUS * 2) - (CURVE_CIRCLE_RADIUS / 3), differenceOfScreen); //// the coordinates (x,y) of the end point after curve //mFirstCurveEndPoint.Set(mNavigationBarWidth / 2, CURVE_CIRCLE_RADIUS + (CURVE_CIRCLE_RADIUS / 4) + differenceOfScreen); //// same thing for the second curve //mSecondCurveStartPoint = mFirstCurveEndPoint; //mSecondCurveEndPoint.Set((mNavigationBarWidth / 2) + (CURVE_CIRCLE_RADIUS * 2) + (CURVE_CIRCLE_RADIUS / 3), differenceOfScreen); //// the coordinates (x,y) of the 1st control point on a cubic curve //mFirstCurveControlPoint1.Set(mFirstCurveStartPoint.X + CURVE_CIRCLE_RADIUS + (CURVE_CIRCLE_RADIUS / 4), mFirstCurveStartPoint.Y); //// the coordinates (x,y) of the 2nd control point on a cubic curve //mFirstCurveControlPoint2.Set(mFirstCurveEndPoint.X - (CURVE_CIRCLE_RADIUS * 2) + CURVE_CIRCLE_RADIUS, mFirstCurveEndPoint.Y); //mSecondCurveControlPoint1.Set(mSecondCurveStartPoint.X + (CURVE_CIRCLE_RADIUS * 2) - CURVE_CIRCLE_RADIUS, mSecondCurveStartPoint.Y); //mSecondCurveControlPoint2.Set(mSecondCurveEndPoint.X - (CURVE_CIRCLE_RADIUS + (CURVE_CIRCLE_RADIUS / 4)), mSecondCurveEndPoint.Y); var x1 = (mNavigationBarWidth - CURVE_CIRCLE_RADIUS * 2) / 2; var r = CURVE_CIRCLE_RADIUS / 2; var R = CURVE_CIRCLE_RADIUS; mFirstCurveStartPoint.Set(x1 - r / 3, differenceOfScreen); mFirstCurveEndPoint.Set(x1 + r, differenceOfScreen + r + r / 3); mSecondCurveStartPoint = mFirstCurveEndPoint; mSecondCurveEndPoint.Set(x1 + R + 2 * r / 3, differenceOfScreen); mFirstCurveControlPoint1.Set(x1 + r, differenceOfScreen); mFirstCurveControlPoint2.Set(x1 + r, differenceOfScreen + r + r / 3); mSecondCurveControlPoint1.Set(x1 + r + r / 2, differenceOfScreen + r + r / 3); mSecondCurveControlPoint2.Set(x1 + r + r / 2, differenceOfScreen); }
protected override void OnSizeChanged(int w, int h, int oldw, int oldh) { base.OnSizeChanged(w, h, oldw, oldh); this.Measure((int)MeasureSpecMode.Unspecified, (int)MeasureSpecMode.Unspecified); CURVE_CIRCLE_RADIUS = this.MeasuredHeight / 2; mNavigationBarWidth = Width; mNavigationBarHeight = Height; // the coordinates (x,y) of the start point before curve mFirstCurveStartPoint.Set((mNavigationBarWidth / 2) - (CURVE_CIRCLE_RADIUS * 2) - (CURVE_CIRCLE_RADIUS / 3), 0); // the coordinates (x,y) of the end point after curve mFirstCurveEndPoint.Set(mNavigationBarWidth / 2, CURVE_CIRCLE_RADIUS + (CURVE_CIRCLE_RADIUS / 4)); // same thing for the second curve mSecondCurveStartPoint = mFirstCurveEndPoint; mSecondCurveEndPoint.Set((mNavigationBarWidth / 2) + (CURVE_CIRCLE_RADIUS * 2) + (CURVE_CIRCLE_RADIUS / 3), 0); // the coordinates (x,y) of the 1st control point on a cubic curve mFirstCurveControlPoint1.Set(mFirstCurveStartPoint.X + CURVE_CIRCLE_RADIUS + (CURVE_CIRCLE_RADIUS / 4), mFirstCurveStartPoint.Y); // the coordinates (x,y) of the 2nd control point on a cubic curve mFirstCurveControlPoint2.Set(mFirstCurveEndPoint.X - (CURVE_CIRCLE_RADIUS * 2) + CURVE_CIRCLE_RADIUS, mFirstCurveEndPoint.Y); mSecondCurveControlPoint1.Set(mSecondCurveStartPoint.X + (CURVE_CIRCLE_RADIUS * 2) - CURVE_CIRCLE_RADIUS, mSecondCurveStartPoint.Y); mSecondCurveControlPoint2.Set(mSecondCurveEndPoint.X - (CURVE_CIRCLE_RADIUS + (CURVE_CIRCLE_RADIUS / 4)), mSecondCurveEndPoint.Y); mPath.Reset(); mPath.MoveTo(0, 0); mPath.LineTo(mFirstCurveStartPoint.X, mFirstCurveStartPoint.Y); mPath.CubicTo(mFirstCurveControlPoint1.X, mFirstCurveControlPoint1.Y, mFirstCurveControlPoint2.X, mFirstCurveControlPoint2.Y, mFirstCurveEndPoint.X, mFirstCurveEndPoint.Y); mPath.CubicTo(mSecondCurveControlPoint1.X, mSecondCurveControlPoint1.Y, mSecondCurveControlPoint2.X, mSecondCurveControlPoint2.Y, mSecondCurveEndPoint.X, mSecondCurveEndPoint.Y); mPath.LineTo(mNavigationBarWidth, 0); mPath.LineTo(mNavigationBarWidth, mNavigationBarHeight); mPath.LineTo(0, mNavigationBarHeight); mPath.Close(); }
// Defines a callback that sends the drag shadow dimensions and touch point back to the system. public override void OnProvideShadowMetrics(Android.Graphics.Point outShadowSize, Android.Graphics.Point outShadowTouchPoint) { double rotationRad = Java.Lang.Math.ToRadians(View.Rotation); int w = (int)(View.Width * View.ScaleX); int h = (int)(View.Height * View.ScaleY); double s = Java.Lang.Math.Abs(Java.Lang.Math.Sin(rotationRad)); double c = Java.Lang.Math.Abs(Java.Lang.Math.Cos(rotationRad)); //calculate the size of the canvas //width = view's width*cos(rad)+height*sin(rad) width = (int)(w * c + h * s); //height = view's width*sin(rad)+height*cos(rad) height = (int)(w * s + h * c); outShadowSize.Set(width, height); // Sets the touch point's position to be in the middle of the drag shadow outShadowTouchPoint.Set(outShadowSize.X / 2, outShadowSize.Y / 2); }
public override void OnProvideShadowMetrics (Point size, Point touch) { //Dimensions of View int width = View.Width; int height = View.Height; //Assigning dimensions to drawable shadow.SetBounds (0, 0, width, height); //Establishing the dimensions to Shadow Builder size.Set (width, height); //Defining position to Shadow Builder while dragging touch.Set(width/2, height/2); }
public override void OnProvideShadowMetrics(Point shadowSize, Point shadowTouchPoint) { width = View.Width; height = View.Height; shadowSize.Set (width * 2, height * 2); // touch point is in the middle of the (height, width) top-right rect shadowTouchPoint.Set (width + width / 2 - centerOffset, height / 2 + centerOffset); }
public override void OnProvideShadowMetrics (Point size, Point touch) { //Obtenemos las dimenciones de nuestro vista(view) que estamos arrastrando int width = View.Width; int height = View.Height; //Le asignamos esas dimenciones a nuestro Drawable shadow.SetBounds (0, 0, width, height); //De igual forma establecemos las dimenciones de nuestro ShadownBuilder size.Set (width, height); //Definimos la posicion que se colocara nuestro ShadownBuilder cuando lo estemos arrastrando touch.Set(width/2, height/2); }