Beispiel #1
0
        public static string ToTransform(this ITransformIcon icon)
        {
            var sb = new StringBuilder();

            ApplyTransform(icon, sb);
            return(sb.ToString());
        }
Beispiel #2
0
        public static bool ApplyTransform(this ITransformIcon icon, StringBuilder sb, Action?changing = null)
        {
            var hasChanges = false;

            if (icon.Grow > 0.001)
            {
                AddSpaceIfChanged(ref hasChanges, sb, changing);
                sb.Append($"grow-{icon.Grow:F2}");
            }

            if (icon.Shrink > 0.001)
            {
                AddSpaceIfChanged(ref hasChanges, sb, changing);
                sb.Append($"shrink-{icon.Shrink:F2}");
            }

            if (Math.Abs(icon.Rotate) > 0.001)
            {
                AddSpaceIfChanged(ref hasChanges, sb, changing);
                sb.Append($"rotate-{icon.Rotate:F2}");
            }

            if (icon.Up > 0.001)
            {
                AddSpaceIfChanged(ref hasChanges, sb, changing);
                sb.Append($"up-{icon.Up:F2}");
            }

            if (icon.Down > 0.001)
            {
                AddSpaceIfChanged(ref hasChanges, sb, changing);
                sb.Append($"down-{icon.Down:F2}");
            }

            if (icon.Left > 0.001)
            {
                AddSpaceIfChanged(ref hasChanges, sb, changing);
                sb.Append($"left-{icon.Left:F2}");
            }

            if (icon.Right > 0.001)
            {
                AddSpaceIfChanged(ref hasChanges, sb, changing);
                sb.Append($"right-{icon.Right:F2}");
            }

            if (icon.Flip.HasValue && icon.Flip != IconFlip.None)
            {
                AddSpaceIfChanged(ref hasChanges, sb, changing);
                sb.Append(Icon.ToString(icon.Flip.Value));
            }

            return(hasChanges);
        }