void Initialize() { orientation = ArrowOrientation.Right; arrowPaint = new Paint { Color = Color.Rgb(0x77, 0x77, 0x77), //Color = Color.Black, AntiAlias = true }; }
public void SetOrientation(ArrowOrientation orientation, bool animate = true) { Orientation = orientation; animator = ValueAnimator.OfFloat(0f, 1f); animator.SetDuration(250); animator.Update += (sender, e) => Alpha = (float)e.Animation.AnimatedValue; animator.AnimationEnd += (sender, e) => { animator.RemoveAllListeners(); animator = null; }; animator.Start(); }
public void DrawArrow(Rectangle r, ArrowOrientation orientation, bool color) { int height = r.P2.Y - r.P1.Y; int width = r.P2.X - r.P1.X; float inc = 0; if (orientation == ArrowOrientation.Left || orientation == ArrowOrientation.Right) { inc = (((float)height) / 2.0f) / ((float)width); } else { inc = (((float)width) / 2.0f) / ((float)height); } if (orientation == ArrowOrientation.Left) { for (int i = 0; i < width; i++) { SetPixel((int)(r.P1.X + i), (int)(r.P1.Y + height / 2), color); int points = (int)(inc * (float)i) + 1; for (int j = 0; j < points; j++) { SetPixel((int)(r.P1.X + i), (int)(r.P1.Y + height / 2 + j), color); SetPixel((int)(r.P1.X + i), (int)(r.P1.Y + height / 2 - j), color); } } } if (orientation == ArrowOrientation.Right) { for (int i = 0; i < width; i++) { SetPixel((int)(r.P2.X - i), (int)(r.P1.Y + height / 2), color); int points = (int)(inc * (float)i) + 1; for (int j = 0; j < points; j++) { SetPixel((int)(r.P2.X - i), (int)(r.P1.Y + height / 2 + j), color); SetPixel((int)(r.P2.X - i), (int)(r.P1.Y + height / 2 - j), color); } } } if (orientation == ArrowOrientation.Up) { for (int i = 0; i < height; i++) { SetPixel((int)(r.P1.X + width / 2), (int)(r.P1.Y + i), color); int points = (int)(inc * (float)i) + 1; for (int j = 0; j < points; j++) { SetPixel((int)(r.P1.X + width / 2 + j), (int)(r.P1.Y + i), color); SetPixel((int)(r.P1.X + width / 2 - j), (int)(r.P1.Y + i), color); } } } if (orientation == ArrowOrientation.Down) { for (int i = 0; i < height; i++) { SetPixel((int)(r.P1.X + width / 2), (int)(r.P2.Y - i), color); int points = (int)(inc * (float)i) + 1; for (int j = 0; j < points; j++) { SetPixel((int)(r.P1.X + width / 2 + j), (int)(r.P2.Y - i), color); SetPixel((int)(r.P1.X + width / 2 - j), (int)(r.P2.Y - i), color); } } } }
public void SetOrientation(ArrowOrientation orientation, bool animate = true) { Orientation = orientation; animator = ValueAnimator.OfFloat (0f, 1f); animator.SetDuration (250); animator.Update += (sender, e) => Alpha = (float)e.Animation.AnimatedValue; animator.AnimationEnd += (sender, e) => { animator.RemoveAllListeners (); animator = null; }; animator.Start (); }
void Initialize() { orientation = ArrowOrientation.Right; arrowPaint = new Paint { Color = Color.Rgb (0x77, 0x77, 0x77), //Color = Color.Black, AntiAlias = true }; }
public void DrawArrow(Rectangle r, ArrowOrientation orientation, bool color) { int height = r.P2.Y - r.P1.Y; int width = r.P2.X - r.P1.X; float inc = 0; if (orientation == ArrowOrientation.Left || orientation == ArrowOrientation.Right) { inc = (((float)height) / 2.0f) / ((float)width); } else { inc = (((float)width) / 2.0f) / ((float)height); } if (orientation == ArrowOrientation.Left) { for (int i = 0; i < width; i++) { SetPixel ((int)(r.P1.X + i), (int)(r.P1.Y + height/2), color); int points = (int)(inc*(float)i)+1; for (int j = 0; j < points; j++) { SetPixel ((int)(r.P1.X + i), (int)(r.P1.Y + height / 2 +j), color); SetPixel ((int)(r.P1.X + i), (int)(r.P1.Y + height / 2 -j), color); } } } if (orientation == ArrowOrientation.Right) { for (int i = 0; i < width; i++) { SetPixel ((int)(r.P2.X - i), (int)(r.P1.Y + height/2), color); int points = (int)(inc*(float)i)+1; for (int j = 0; j < points; j++) { SetPixel ((int)(r.P2.X -i), (int)(r.P1.Y + height / 2 +j), color); SetPixel ((int)(r.P2.X -i), (int)(r.P1.Y + height / 2 -j), color); } } } if (orientation == ArrowOrientation.Up) { for (int i = 0; i < height; i++) { SetPixel ((int)(r.P1.X + width/2), (int)(r.P1.Y + i), color); int points = (int)(inc*(float)i)+1; for (int j = 0; j < points; j++) { SetPixel ((int)(r.P1.X + width/2+j), (int)(r.P1.Y + i), color); SetPixel ((int)(r.P1.X + width/2-j), (int)(r.P1.Y + i), color); } } } if (orientation == ArrowOrientation.Down) { for (int i = 0; i < height; i++) { SetPixel ((int)(r.P1.X + width/2), (int)(r.P2.Y -i), color); int points = (int)(inc*(float)i)+1; for (int j = 0; j < points; j++) { SetPixel ((int)(r.P1.X + width/2+j), (int)(r.P2.Y - i), color); SetPixel ((int)(r.P1.X + width/2-j), (int)(r.P2.Y - i), color); } } } }
public Arrow(ArrowOrientation orientation) { Orientation = orientation; }