Esempio n. 1
0
        /// <summary>
        /// Low-level draw method used by other rendering methods.
        /// </summary>
        /// <param name="visitor">the draw visitor</param>
        /// <param name="bounds">a bound rendering element</param>
        /// <param name="zoom">if the diagram is zoomed at all</param>
        /// <param name="viewBounds">the view bounds - the root will be centered in the bounds</param>
        protected void Draw(IDrawVisitor visitor, double zoom, Bounds bounds, Rect viewBounds)
        {
            var modelScale = zoom * model.GetScale();
            var zoomToFit  = Math.Min(viewBounds.Width / (bounds.Width * modelScale), viewBounds.Height / (bounds.Height * modelScale));
            var transform  = Matrix.Identity;

            // setup up transform
            transform.TranslatePrepend(viewBounds.CenterX(), viewBounds.CenterY());
            transform.ScalePrepend(modelScale, -modelScale);

            // default is shrink only unless specified
            if (model.GetFitToScreen() || zoomToFit < 1)
            {
                transform.ScalePrepend(zoomToFit, zoomToFit);
            }

            transform.TranslatePrepend(-(bounds.MinX + bounds.MaxX) / 2, -(bounds.MinY + bounds.MaxY) / 2);

            // not always needed
            var fontManager = new WPFFontManager
            {
                Zoom = zoomToFit
            };

            visitor.RendererModel = model;
            visitor.FontManager   = fontManager;

            visitor.Visit(bounds.Root, new MatrixTransform(transform));
        }
Esempio n. 2
0
 public virtual void AcceptDrawVisitor(int x, int y, IDrawVisitor visitor)
 {
     visitor.Visit(this, x, y);
 }