Example #1
0
        public void ZoomFocusTo(IRenderer renderer, bool maintainScale = true)
        {
            if (!renderer.Element.IsLoaded)
            {
                DispatcherEx.WaitForRender();
            }

            Point pt1 = renderer.Element.TranslatePoint(new Point(), this);
            Point pt2 = renderer.Element.TranslatePoint((Point)renderer.Element.RenderSize, this);

            Rect bound = new Rect(pt1, pt2);

            Vector blank = (Vector)this.ZoomPanel.RenderSize - (Vector)bound.Size;

            blank.X /= 2 * (maintainScale ? this.ZoomPanel.Scale : 1);
            blank.Y /= 2 * (maintainScale ? this.ZoomPanel.Scale : 1);

            bound.Inflate(blank.X, blank.Y);

            this.ZoomPanel.ZoomFit(bound, true);
        }