public override IEnumerable <Conditional <IRenderCommand> > Flatten(FlattenContext context) { foreach (var location in Location.Flatten(context)) { foreach (var alignment in Alignment) { foreach (var rotation in Rotation) { var command = new RenderText( location.Value, alignment.Value, TextRuns) { Rotation = rotation.Value, }; var conditions = ConditionTreeBuilder.And(new[] { location.Conditions, alignment.Conditions, rotation.Conditions, }); yield return(new Conditional <IRenderCommand>(command, conditions)); } } } }
public IEnumerable <Conditional <ComponentPoint> > Flatten(FlattenContext context) { var allOffsets = Offsets.Select(x => x.Flatten(context)); foreach (var offsets in allOffsets.CartesianProduct()) { double xOffset = offsets.Where(x => x.Value.Axis == OffsetAxis.X != context.AutoRotate.Mirror).Sum(x => x.Value.Offset); double yOffset = offsets.Where(x => x.Value.Axis == OffsetAxis.Y != context.AutoRotate.Mirror).Sum(x => x.Value.Offset); var point = new ComponentPoint(RelativeToX, RelativeToX, new Vector(xOffset, yOffset)).Flip(context.AutoRotate.FlipType, context.AutoRotate.FlipState); var conditions = ConditionTreeBuilder.And(offsets.Select(x => x.Conditions)); yield return(new Conditional <ComponentPoint>(point, conditions)); } }
public override IEnumerable <Conditional <IRenderCommand> > Flatten(FlattenContext context) { foreach (var location in Location.Flatten(context)) { foreach (var width in Width) { var conditions = ConditionTreeBuilder.And(new[] { location.Conditions, width.Conditions, }); var command = new Rectangle( location.Value, width.Value, Height, StrokeThickness, Fill); yield return(new Conditional <IRenderCommand>(command, conditions)); } } }
public IEnumerable <Conditional <ConnectionDescription> > Flatten(FlattenContext context) { foreach (var start in Start.Flatten(context)) { foreach (var end in End.Flatten(context)) { foreach (var edge in Edge) { var conditions = ConditionTreeBuilder.And( start.Conditions, end.Conditions, edge.Conditions); var connection = new ConnectionDescription( start.Value, end.Value, edge.Value, Name); yield return(new Conditional <ConnectionDescription>(connection, conditions)); } } } }