/// <summary> /// Gets the view position given the specified camera bounds. /// </summary> /// <param name="bounds"> /// The bounds for which the view position will be computed. /// </param> /// <returns>The view position.</returns> public virtual PointFx GetViewPosition(RectangleFx bounds) { PointFx pos = PointFx.Empty; if (camera != null) { // First we compute the union of all the layers RectangleFx layerBounds = UnionOfLayerFullBounds; // Then we put the bounds into camera coordinates and // union the camera bounds if (!layerBounds.IsEmpty) { layerBounds = camera.ViewToLocal(layerBounds); } layerBounds = RectangleFxtensions.Union(layerBounds, bounds); pos = new PointFx((int)(bounds.X - layerBounds.X + 0.5), (int)(bounds.Y - layerBounds.Y + 0.5)); } return(pos); }