// If the cropping rectangle's size changed significantly, change the // view's center and scale according to the cropping rectangle. private void centerBasedOnHighlightView(HighlightView hv) { Rect drawRect = hv.DrawRect; float width = drawRect.Width(); float height = drawRect.Height(); float thisWidth = Width; float thisHeight = Height; float z1 = thisWidth / width * .6F; float z2 = thisHeight / height * .6F; float zoom = Math.Min(z1, z2); zoom = zoom * this.GetScale(); zoom = Math.Max(1F, zoom); if ((Math.Abs(zoom - GetScale()) / zoom) > .1) { float[] coordinates = new float[] { hv.CropRect.CenterX(), hv.CropRect.CenterY() }; ImageMatrix.MapPoints(coordinates); ZoomTo(zoom, coordinates[0], coordinates[1], 300F); } ensureVisible(hv); }
private PointF MapPoint(PointF point) { var imageX = ToImageValue(point.X); var imageY = ToImageValue(point.Y); var pointArray = new[] { imageX, imageY }; ImageMatrix.MapPoints(pointArray); var mappedPoint = new PointF(pointArray[0], pointArray[1]); return(mappedPoint); }
// If the cropping rectangle's size changed significantly, change the // view's center and scale according to the cropping rectangle. private void CenterBasedOnHighlightView(HighlightView hv) { float width = hv.DrawRect.Width(); float height = hv.DrawRect.Height(); float thisWidth = Width; float thisHeight = Height; var z1 = thisWidth / width * .6F; var z2 = thisHeight / height * .6F; var zoom = Math.Max(1F, ((Math.Min(z1, z2)) * GetScale())); if ((Math.Abs(zoom - GetScale()) / zoom) > .1) { float[] coordinates = { hv.CropRect.CenterX(), hv.CropRect.CenterY() }; ImageMatrix.MapPoints(coordinates); ZoomTo(zoom, coordinates[0], coordinates[1], 300F); } EnsureVisible(hv); }