// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2014 OxyPlot contributors
//
//
// Represents a control that displays a .
//
// --------------------------------------------------------------------------------------------------------------------
using Avalonia;
namespace OxyPlot.Avalonia
{
using global::Avalonia.Controls;
///
/// Represents a control that displays a .
///
public partial class Legend : Control
{
///
/// The internal model.
///
private readonly Legends.Legend InternalLegend;
///
/// Initializes static members of the class.
///
public Legend()
{
this.InternalLegend = new Legends.Legend();
}
///
/// Synchronize properties in the internal Plot model
///
private void SynchronizeProperties()
{
var m = this.InternalLegend;
m.LegendTextColor = this.LegendTextColor.ToOxyColor();
m.LegendTitle = this.LegendTitle;
m.LegendTitleColor = this.LegendTitleColor.ToOxyColor();
m.LegendTitleFont = this.LegendTitleFont;
m.LegendTitleFontSize = this.LegendTitleFontSize;
m.LegendTitleFontWeight = (int)this.LegendTitleFontWeight;
m.LegendFont = this.LegendFont;
m.LegendFontSize = this.LegendFontSize;
m.LegendFontWeight = (int)this.LegendFontWeight;
m.LegendSymbolLength = this.LegendSymbolLength;
m.LegendSymbolMargin = this.LegendSymbolMargin;
m.LegendPadding = this.LegendPadding;
m.LegendColumnSpacing = this.LegendColumnSpacing;
m.LegendItemSpacing = this.LegendItemSpacing;
m.LegendLineSpacing = this.LegendLineSpacing;
m.LegendMargin = this.LegendMargin;
m.LegendMaxHeight = this.LegendMaxHeight;
m.LegendMaxWidth = this.LegendMaxWidth;
m.LegendBackground = this.LegendBackground.ToOxyColor();
m.LegendBorder = this.LegendBorder.ToOxyColor();
m.LegendBorderThickness = this.LegendBorderThickness;
m.LegendPlacement = this.LegendPlacement;
m.LegendPosition = this.LegendPosition;
m.LegendOrientation = this.LegendOrientation;
m.LegendItemOrder = this.LegendItemOrder;
m.LegendItemAlignment = this.LegendItemAlignment.ToHorizontalAlignment();
m.LegendSymbolPlacement = this.LegendSymbolPlacement;
m.IsLegendVisible = this.IsLegendVisible;
m.EdgeRenderingMode = this.EdgeRenderingMode;
}
///
/// Handles changes in appearance.
///
/// The sender.
/// The instance containing the event data.
protected static void AppearanceChanged(AvaloniaObject d, AvaloniaPropertyChangedEventArgs e)
{
((Legend)d).OnVisualChanged();
}
///
/// The on visual changed handler.
///
protected void OnVisualChanged()
{
(this.Parent as IPlot)?.ElementAppearanceChanged(this);
}
///
/// Handles changes in data.
///
/// The sender.
/// The instance containing the event data.
protected static void DataChanged(AvaloniaObject d, AvaloniaPropertyChangedEventArgs e)
{
((Legend)d).OnDataChanged();
}
///
/// The on data changed handler.
///
protected void OnDataChanged()
{
(this.Parent as IPlot)?.ElementDataChanged(this);
}
static Legend()
{
IsLegendVisibleProperty.Changed.AddClassHandler