/// <summary> /// Converts a bounding rectangle in 'model space' into the equivalent /// bounds in 'screen space'. Used to determine how much space the model /// will take up on screen given a particular scale, zoom, and margin. /// </summary> /// <param name="modelBounds">the bounds of the model</param> /// <returns>the bounds of the diagram as drawn on screen</returns> public virtual Rect CalculateScreenBounds(Rect modelBounds) { var scale = rendererModel.GetScale(); var zoom = rendererModel.GetZoomFactor(); var margin = rendererModel.GetMargin(); var modelScreenCenter = this.ToScreenCoordinates( modelBounds.X + modelBounds.Width / 2, modelBounds.Y + modelBounds.Height / 2); var width = (scale * zoom * modelBounds.Width) + (2 * margin); var height = (scale * zoom * modelBounds.Height) + (2 * margin); return(new Rect(modelScreenCenter.X - width / 2, modelScreenCenter.Y - height / 2, width, height)); }