// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) 2014 OxyPlot contributors // // // Represents a control that displays a . // // -------------------------------------------------------------------------------------------------------------------- using Avalonia; using Avalonia.Media; namespace OxyPlot.Avalonia { using global::Avalonia.Metadata; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Globalization; /// /// Represents a control that displays a . /// /// This file contains dependency properties used for defining the Plot in XAML. These properties are only used when Model is null. In this case an internal PlotModel is created and the dependency properties are copied from the control to the internal PlotModel. public partial class Plot { /// /// Identifies the dependency property. /// public static readonly StyledProperty CultureProperty = AvaloniaProperty.Register(nameof(Culture), null); /// /// Identifies the dependency property. /// public static readonly StyledProperty IsLegendVisibleProperty = AvaloniaProperty.Register(nameof(IsLegendVisible), true); /// /// Identifies the dependency property. /// public static readonly StyledProperty SelectionColorProperty = AvaloniaProperty.Register(nameof(SelectionColor), Colors.Yellow); /// /// Identifies the dependency property. /// public static readonly StyledProperty> RenderingDecoratorProperty = AvaloniaProperty.Register>(nameof(RenderingDecorator), null); /// /// Identifies the dependency property. /// public static readonly StyledProperty SubtitleFontProperty = AvaloniaProperty.Register(nameof(SubtitleFont), null); /// /// Identifies the dependency property. /// public static readonly StyledProperty TitleColorProperty = AvaloniaProperty.Register(nameof(TitleColor), MoreColors.Automatic); /// /// Identifies the dependency property. /// public static readonly StyledProperty SubtitleColorProperty = AvaloniaProperty.Register(nameof(SubtitleColor), MoreColors.Automatic); /// /// Identifies the dependency property. /// public static readonly StyledProperty DefaultFontProperty = AvaloniaProperty.Register(nameof(DefaultFont), "Segoe UI"); /// /// Identifies the dependency property. /// public static readonly StyledProperty DefaultFontSizeProperty = AvaloniaProperty.Register(nameof(DefaultFontSize), 12d); /// /// Identifies the dependency property. /// public static readonly StyledProperty> DefaultColorsProperty = AvaloniaProperty.Register>(nameof(DefaultColors), new[] { Color.FromRgb(0x4E, 0x9A, 0x06), Color.FromRgb(0xC8, 0x8D, 0x00), Color.FromRgb(0xCC, 0x00, 0x00), Color.FromRgb(0x20, 0x4A, 0x87), Colors.Red, Colors.Orange, Colors.Yellow, Colors.Green, Colors.Blue, Colors.Indigo, Colors.Violet }); /// /// Identifies the dependency property. /// public static readonly StyledProperty AxisTierDistanceProperty = AvaloniaProperty.Register(nameof(AxisTierDistance), 4d); /// /// Identifies the dependency property. /// public static readonly StyledProperty PlotAreaBackgroundProperty = AvaloniaProperty.Register(nameof(PlotAreaBackground), null); /// /// Identifies the dependency property. /// public static readonly StyledProperty PlotAreaBorderColorProperty = AvaloniaProperty.Register(nameof(PlotAreaBorderColor), Colors.Black); /// /// Identifies the dependency property. /// public static readonly StyledProperty PlotAreaBorderThicknessProperty = AvaloniaProperty.Register(nameof(PlotAreaBorderThickness), new Thickness(1.0)); /// /// Identifies the dependency property. /// public static readonly StyledProperty PlotMarginsProperty = AvaloniaProperty.Register(nameof(PlotMargins), new Thickness(double.NaN)); /// /// Identifies the dependency property. /// public static readonly StyledProperty PlotTypeProperty = AvaloniaProperty.Register(nameof(PlotType), PlotType.XY); /// /// Identifies the dependency property. /// public static readonly StyledProperty SubtitleFontSizeProperty = AvaloniaProperty.Register(nameof(SubtitleFontSize), 14.0); /// /// Identifies the dependency property. /// public static readonly StyledProperty SubtitleFontWeightProperty = AvaloniaProperty.Register(nameof(SubtitleFontWeight), FontWeight.Normal); /// /// Identifies the dependency property. /// public static readonly StyledProperty SubtitleProperty = AvaloniaProperty.Register(nameof(Subtitle), null); /// /// Identifies the dependency property. /// public static readonly StyledProperty TextColorProperty = AvaloniaProperty.Register(nameof(TextColor), Colors.Black); /// /// Identifies the dependency property. /// public static readonly StyledProperty TitleAlignmentProperty = AvaloniaProperty.Register(nameof(TitleHorizontalAlignment), TitleHorizontalAlignment.CenteredWithinPlotArea); /// /// Identifies the dependency property. /// public static readonly StyledProperty TitleFontProperty = AvaloniaProperty.Register(nameof(TitleFont), null); /// /// Identifies the dependency property. /// public static readonly StyledProperty TitleFontSizeProperty = AvaloniaProperty.Register(nameof(TitleFontSize), 18.0); /// /// Identifies the dependency property. /// public static readonly StyledProperty TitleFontWeightProperty = AvaloniaProperty.Register(nameof(TitleFontWeight), FontWeight.Bold); /// /// Identifies the dependency property. /// public static readonly StyledProperty TitlePaddingProperty = AvaloniaProperty.Register(nameof(TitlePadding), 6.0); /// /// Identifies the dependency property. /// public static readonly StyledProperty TitleProperty = AvaloniaProperty.Register(nameof(Title), null); /// /// Identifies the dependency property. /// public static readonly StyledProperty TitleToolTipProperty = AvaloniaProperty.Register(nameof(TitleToolTip), null); /// /// Identifies the dependency property. /// public static readonly StyledProperty InvalidateFlagProperty = AvaloniaProperty.Register(nameof(InvalidateFlag), 0); /// /// Initializes static members of the class. /// static Plot() { PaddingProperty.OverrideDefaultValue(new Thickness(8)); PaddingProperty.Changed.AddClassHandler(AppearanceChanged); CultureProperty.Changed.AddClassHandler(AppearanceChanged); IsLegendVisibleProperty.Changed.AddClassHandler(AppearanceChanged); SelectionColorProperty.Changed.AddClassHandler(AppearanceChanged); RenderingDecoratorProperty.Changed.AddClassHandler(AppearanceChanged); SubtitleFontProperty.Changed.AddClassHandler(AppearanceChanged); TitleColorProperty.Changed.AddClassHandler(AppearanceChanged); SubtitleColorProperty.Changed.AddClassHandler(AppearanceChanged); DefaultFontProperty.Changed.AddClassHandler(AppearanceChanged); DefaultFontSizeProperty.Changed.AddClassHandler(AppearanceChanged); DefaultColorsProperty.Changed.AddClassHandler(AppearanceChanged); AxisTierDistanceProperty.Changed.AddClassHandler(AppearanceChanged); PlotAreaBackgroundProperty.Changed.AddClassHandler(AppearanceChanged); PlotAreaBorderColorProperty.Changed.AddClassHandler(AppearanceChanged); PlotAreaBorderThicknessProperty.Changed.AddClassHandler(AppearanceChanged); PlotMarginsProperty.Changed.AddClassHandler(AppearanceChanged); PlotTypeProperty.Changed.AddClassHandler(AppearanceChanged); SubtitleFontSizeProperty.Changed.AddClassHandler(AppearanceChanged); SubtitleFontWeightProperty.Changed.AddClassHandler(AppearanceChanged); SubtitleProperty.Changed.AddClassHandler(AppearanceChanged); TextColorProperty.Changed.AddClassHandler(AppearanceChanged); TitleAlignmentProperty.Changed.AddClassHandler(AppearanceChanged); TitleFontProperty.Changed.AddClassHandler(AppearanceChanged); TitleFontSizeProperty.Changed.AddClassHandler(AppearanceChanged); TitleFontWeightProperty.Changed.AddClassHandler(AppearanceChanged); TitlePaddingProperty.Changed.AddClassHandler(AppearanceChanged); TitleProperty.Changed.AddClassHandler(AppearanceChanged); TitleToolTipProperty.Changed.AddClassHandler(AppearanceChanged); InvalidateFlagProperty.Changed.AddClassHandler((s, e) => s.InvalidateFlagChanged()); } /// /// The annotations. /// private readonly ObservableCollection annotations; /// /// The axes. /// private readonly ObservableCollection axes; /// /// The series. /// private readonly ObservableCollection series; /// /// The legends. /// private readonly ObservableCollection legends; /// /// Gets the axes. /// /// The axes. public Collection Axes { get { return axes; } } /// /// Gets or sets Culture. /// public CultureInfo Culture { get { return GetValue(CultureProperty); } set { SetValue(CultureProperty, value); } } /// /// Gets or sets a value indicating whether IsLegendVisible. /// public bool IsLegendVisible { get { return GetValue(IsLegendVisibleProperty); } set { SetValue(IsLegendVisibleProperty, value); } } /// /// Gets or sets the default font. /// public string DefaultFont { get { return GetValue(DefaultFontProperty); } set { SetValue(DefaultFontProperty, value); } } /// /// Gets or sets the default font size. /// public double DefaultFontSize { get { return GetValue(DefaultFontSizeProperty); } set { SetValue(DefaultFontSizeProperty, value); } } /// /// Gets or sets the default colors. /// public IList DefaultColors { get { return GetValue(DefaultColorsProperty); } set { SetValue(DefaultColorsProperty, value); } } /// /// Gets or sets the axis tier distance. /// public double AxisTierDistance { get { return GetValue(AxisTierDistanceProperty); } set { SetValue(AxisTierDistanceProperty, value); } } /// /// Gets or sets the color of selected elements. /// public Color SelectionColor { get { return GetValue(SelectionColorProperty); } set { SetValue(SelectionColorProperty, value); } } /// /// Gets or sets a rendering decorator. /// public Func RenderingDecorator { get { return GetValue(RenderingDecoratorProperty); } set { SetValue(RenderingDecoratorProperty, value); } } /// /// Gets or sets the font of the subtitles. /// public string SubtitleFont { get { return GetValue(SubtitleFontProperty); } set { SetValue(SubtitleFontProperty, value); } } /// /// Gets or sets the color of the titles. /// public Color TitleColor { get { return GetValue(TitleColorProperty); } set { SetValue(TitleColorProperty, value); } } /// /// Gets or sets the color of the subtitles. /// public Color SubtitleColor { get { return GetValue(SubtitleColorProperty); } set { SetValue(SubtitleColorProperty, value); } } /// /// Gets or sets the background brush of the Plot area. /// /// The brush. public Brush PlotAreaBackground { get { return GetValue(PlotAreaBackgroundProperty); } set { SetValue(PlotAreaBackgroundProperty, value); } } /// /// Gets or sets the color of the Plot area border. /// /// The color of the Plot area border. public Color PlotAreaBorderColor { get { return GetValue(PlotAreaBorderColorProperty); } set { SetValue(PlotAreaBorderColorProperty, value); } } /// /// Gets or sets the thickness of the Plot area border. /// /// The thickness of the Plot area border. public Thickness PlotAreaBorderThickness { get { return GetValue(PlotAreaBorderThicknessProperty); } set { SetValue(PlotAreaBorderThicknessProperty, value); } } /// /// Gets or sets the Plot margins. /// /// The Plot margins. public Thickness PlotMargins { get { return GetValue(PlotMarginsProperty); } set { SetValue(PlotMarginsProperty, value); } } /// /// Gets or sets PlotType. /// public PlotType PlotType { get { return GetValue(PlotTypeProperty); } set { SetValue(PlotTypeProperty, value); } } /// /// Gets the series. /// /// The series. [Content] public Collection Series { get { return series; } } /// /// Gets the legends. /// /// The legends. public Collection Legends { get { return legends; } } /// /// Gets or sets the subtitle. /// /// The subtitle. public string Subtitle { get { return GetValue(SubtitleProperty); } set { SetValue(SubtitleProperty, value); } } /// /// Gets or sets the font size of the subtitle. /// public double SubtitleFontSize { get { return GetValue(SubtitleFontSizeProperty); } set { SetValue(SubtitleFontSizeProperty, value); } } /// /// Gets or sets the font weight of the subtitle. /// public FontWeight SubtitleFontWeight { get { return GetValue(SubtitleFontWeightProperty); } set { SetValue(SubtitleFontWeightProperty, value); } } /// /// Gets or sets text color. /// public Color TextColor { get { return GetValue(TextColorProperty); } set { SetValue(TextColorProperty, value); } } /// /// Gets or sets the title. /// /// The title. public string Title { get { return GetValue(TitleProperty); } set { SetValue(TitleProperty, value); } } /// /// Gets or sets the title tool tip. /// /// The title tool tip. public string TitleToolTip { get { return GetValue(TitleToolTipProperty); } set { SetValue(TitleToolTipProperty, value); } } /// /// Gets or sets the horizontal alignment of the title and subtitle. /// /// /// The alignment. /// public TitleHorizontalAlignment TitleHorizontalAlignment { get { return GetValue(TitleAlignmentProperty); } set { SetValue(TitleAlignmentProperty, value); } } /// /// Gets or sets font of the title. /// public string TitleFont { get { return GetValue(TitleFontProperty); } set { SetValue(TitleFontProperty, value); } } /// /// Gets or sets font size of the title. /// public double TitleFontSize { get { return GetValue(TitleFontSizeProperty); } set { SetValue(TitleFontSizeProperty, value); } } /// /// Gets or sets font weight of the title. /// public FontWeight TitleFontWeight { get { return GetValue(TitleFontWeightProperty); } set { SetValue(TitleFontWeightProperty, value); } } /// /// Gets or sets padding around the title. /// public double TitlePadding { get { return GetValue(TitlePaddingProperty); } set { SetValue(TitlePaddingProperty, value); } } /// /// Gets or sets the refresh flag (an integer value). When the flag is changed, the Plot will be refreshed. /// /// The refresh value. public int InvalidateFlag { get { return GetValue(InvalidateFlagProperty); } set { SetValue(InvalidateFlagProperty, value); } } /// /// Invalidates the Plot control/view when the property is changed. /// private void InvalidateFlagChanged() { InvalidatePlot(); } } }