Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Show gradient brushes in DGML. #408

Merged
merged 1 commit into from
Jan 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ sealed class CompositionObjectDgmlSerializer
static readonly Category CategoryEffectBrush = new Category("EffectBrush", Colors.LightGray);
static readonly Category CategoryEllipse = new Category("Ellipse", Colors.DarkGoldenrod);
static readonly Category CategoryEllipseAnimated = new Category("AnimatedEllipse", "Animated Ellipse", Colors.Goldenrod);
static readonly Category CategoryGradientBrush = new Category("GradientBrush", Colors.Orange);
static readonly Category CategoryGradientBrushAnimated = new Category("AnimatedGradientBrush", Colors.Red);
static readonly Category CategoryLayerVisual = new Category("LayerVisual", Colors.DarkRed);
static readonly Category CategoryLayerVisualAnimated = new Category("AnimatedLayerVisual", "Animated LayerVisual", Colors.Crimson);
static readonly Category CategoryPath = new Category("Path", Colors.DarkOrange);
Expand Down Expand Up @@ -292,11 +294,9 @@ internal void Initialize(CompositionObjectDgmlSerializer owner)
case CompositionObjectType.CompositionColorBrush:
case CompositionObjectType.CompositionColorGradientStop:
case CompositionObjectType.CompositionEllipseGeometry:
case CompositionObjectType.CompositionLinearGradientBrush:
case CompositionObjectType.CompositionGeometricClip:
case CompositionObjectType.CompositionPathGeometry:
case CompositionObjectType.CompositionPropertySet:
case CompositionObjectType.CompositionRadialGradientBrush:
case CompositionObjectType.CompositionRectangleGeometry:
case CompositionObjectType.CompositionRoundedRectangleGeometry:
case CompositionObjectType.CompositionViewBox:
Expand Down Expand Up @@ -340,6 +340,10 @@ internal void Initialize(CompositionObjectDgmlSerializer owner)
case CompositionObjectType.SpriteVisual:
Category = CategorySpriteVisual;
break;
case CompositionObjectType.CompositionLinearGradientBrush:
case CompositionObjectType.CompositionRadialGradientBrush:
Category = GetCategory((CompositionGradientBrush)obj);
break;
default:
throw new InvalidOperationException();
}
Expand Down Expand Up @@ -394,6 +398,14 @@ static Category GetCategory(CompositionSpriteShape shape)
_ => throw new InvalidOperationException(),
};
}

static Category GetCategory(CompositionGradientBrush brush)
{
var isAnimated = brush.Animators.Any() || brush.Properties.Animators.Any() ||
brush.ColorStops.Any(cs => cs.Animators.Any() || cs.Properties.Animators.Any());

return isAnimated ? CategoryGradientBrushAnimated : CategoryGradientBrush;
}
}

sealed class GroupNode
Expand Down