Example #1
0
        public void CombinatorCombinesAdditionalProperties()
        {
            LineSeriesConfigurator a = new();
            LineSeriesConfigurator b = new();

            Expression <Func <LineSeries, string?> > propertyExpression = ls => ls.LabelFormatString;
            const string format = "ABC";

            a.SetAdditional(propertyExpression, format);

            // Property only set on a
            Combinator <LineSeriesConfigurator> combinator = new(a, b);

            LineSeriesConfigurator combined = combinator.Combine();

            ConfigurableProperty <string>?combinedProperty = combined.AdditionalProperties.Get(propertyExpression);

            Assert.NotNull(combinedProperty);
            Assert.True(combinedProperty !.IsSet);
            Assert.Equal(format, combinedProperty.Value);

            // Property set on a AND b, should take the value from a and ignore b
            b.SetAdditional(propertyExpression, "ANOTHER RANDOM VALUE");

            combinator = new Combinator <LineSeriesConfigurator>(a, b);

            combined = combinator.Combine();

            combinedProperty = combined.AdditionalProperties.Get(propertyExpression);
            Assert.NotNull(combinedProperty);
            Assert.True(combinedProperty !.IsSet);
            Assert.Equal(format, combinedProperty.Value);
        }
Example #2
0
        public void CombinatorCombinesChildConfigurators()
        {
            LineSeriesConfigurator a = new();
            LineSeriesConfigurator b = new();

            OxyColor         lineColour = OxyColors.Brown;
            const MarkerType markerType = MarkerType.Star;

            a.Line.Color.Set(lineColour);
            b.Marker.Type.Set(markerType);

            Combinator <LineSeriesConfigurator> combinator = new(a, b);
            LineSeriesConfigurator combined = combinator.Combine();

            Assert.True(combined.Line.Color.IsSet);
            Assert.True(combined.Marker.Type.IsSet);
            Assert.Equal(lineColour, combined.Line.Color.Value);
            Assert.Equal(markerType, combined.Marker.Type.Value);
        }
Example #3
0
        public void CombinatorCanAddLessDerivedTypes()
        {
            LineSeriesConfigurator   a = new();
            XyAxisSeriesConfigurator b = new();

            OxyColor   lineColour = OxyColors.Brown;
            const bool secondaryX = true;

            a.Line.Color.Set(lineColour);
            b.UseSecondaryXAxis.Set(secondaryX);

            Combinator <LineSeriesConfigurator> combinator = new(a, b);
            LineSeriesConfigurator combined = combinator.Combine();

            Assert.True(combined.Line.Color.IsSet);
            Assert.True(combined.UseSecondaryXAxis.IsSet);
            Assert.Equal(lineColour, combined.Line.Color.Value);
            Assert.Equal(secondaryX, combined.UseSecondaryXAxis.Value);
        }
Example #4
0
 /// <summary>
 /// Configures the <paramref name="series"/> using the information in <paramref name="configurator"/>.
 /// </summary>
 /// <param name="series">The <see cref="LineSeries"/> to configure.</param>
 /// <param name="configurator">The configuration to apply.</param>
 public static void Configure(this LineSeries series, LineSeriesConfigurator configurator)
 => configurator.Configure(series);
Example #5
0
 /// <summary>
 ///     Setup the series to use the secondary X axis.
 /// </summary>
 /// <param name="series">The series to configure.</param>
 public static LineSeriesConfigurator UseSecondaryXAxis(this LineSeriesConfigurator series)
 => series.UseSecondaryXAxis <LineSeriesConfigurator, LineSeries>();
Example #6
0
 /// <summary>
 ///     Sets the series title.
 /// </summary>
 /// <param name="series">The series to configure.</param>
 /// <param name="title">The title.</param>
 public static LineSeriesConfigurator SetTitle(this LineSeriesConfigurator series, string title)
 => series.SetTitle <LineSeriesConfigurator, LineSeries>(title);
Example #7
0
 /// <summary>
 ///     Configure the marker.
 /// </summary>
 /// <param name="series">The series to configure.</param>
 /// <param name="configure">Configures the marker.</param>
 public static LineSeriesConfigurator WithMarker(this LineSeriesConfigurator series,
                                                 Action <MarkerConfigurator>?configure)
 => series.With(s => s.Marker, configure);
Example #8
0
 /// <summary>
 ///     Configure the line.
 /// </summary>
 /// <param name="series">The series to configure.</param>
 /// <param name="configure">Configures the line.</param>
 public static LineSeriesConfigurator WithLine(this LineSeriesConfigurator series,
                                               Action <LineConfigurator>?configure)
 => series.With(s => s.Line, configure);