Exemplo n.º 1
0
        /// <summary>
        /// Determines the scale factor of the specified visual
        /// </summary>
        private void DetermineScaleFactor(GraphicVisual visual, NormalizeAspect normalizeAspect, double scaleTo)
        {
            var bounds = DetermineBounds(visual);

            left = bounds.Left;
            top  = bounds.Top;
            double width  = bounds.Width;
            double height = bounds.Height;

            AspectRatio = height / width;

            switch (normalizeAspect)
            {
            case NormalizeAspect.Width:
                scaleWidth       = scaleTo / width;
                this.scaleHeight = this.scaleWidth;
                break;

            case NormalizeAspect.Height:
                scaleWidth       = scaleTo / height;
                this.scaleHeight = this.scaleWidth;
                break;

            case NormalizeAspect.Both:
                scaleWidth       = scaleTo / width;
                scaleHeight      = scaleTo / height;
                scaleWidth       = height > width ? scaleHeight : scaleWidth;
                this.scaleHeight = this.scaleWidth;
                break;

            case NormalizeAspect.Individual:
                scaleWidth  = scaleTo / width;
                scaleHeight = scaleTo / height;
                break;
            }

            scaleThickness = (scaleWidth + scaleHeight) / 2;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Normalizes the given visual and creates a deep copy of the tree
 /// </summary>
 public GraphicVisual Normalize(GraphicVisual visual, NormalizeAspect normalizeType, double scaleTo)
 {
     DetermineScaleFactor(visual, normalizeType, scaleTo);
     return(Normalize(visual));
 }