//The MIT License(MIT)
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//The above copyright notice and this permission notice shall be included in all
//copies or substantial portions of the Software.
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//SOFTWARE.
using System;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Diagnostics;
using System.Windows.Forms.Integration;
using System.Windows.Media;
using LiveCharts.Events;
using LiveCharts.Wpf;
using UserControl = System.Windows.Controls.UserControl;
namespace LiveCharts.WinForms
{
///
///
///
///
[Designer("System.Windows.Forms.Design.ControlDesigner, System.Design")]
[DesignerSerializer("System.ComponentModel.Design.Serialization.TypeCodeDomSerializer , System.Design", "System.ComponentModel.Design.Serialization.CodeDomSerializer, System.Design")]
public class CartesianChart : ElementHost
{
///
/// The WPF base
///
protected readonly Wpf.CartesianChart WpfBase = new Wpf.CartesianChart();
///
/// Initializes a new instance of the class.
///
public CartesianChart()
{
Child = WpfBase;
//workaround for windows 7 focus issue
//https://github.com/beto-rodriguez/Live-Charts/issues/515
HostContainer.MouseEnter += (sender, args) =>
{
Focus();
};
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
{
WpfBase.Series = WpfBase.GetDesignerModeCollection();
}
}
///
/// Occurs when the users clicks any point in the chart
///
public event DataClickHandler DataClick
{
add { WpfBase.DataClick += value; }
remove { WpfBase.DataClick += value; }
}
///
/// Occurs when the users hovers over any point in the chart
///
public event DataHoverHandler DataHover
{
add { WpfBase.DataHover += value; }
remove { WpfBase.DataHover += value; }
}
///
/// Occurs every time the chart updates
///
public event UpdaterTickHandler UpdaterTick
{
add { WpfBase.UpdaterTick += value; }
remove { WpfBase.UpdaterTick += value; }
}
#region ChartProperties
///
/// Gets the base.
///
///
/// The base.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Wpf.CartesianChart Base { get { return WpfBase; } }
///
/// Gets or sets the axis y.
///
///
/// The axis y.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public AxesCollection AxisY
{
get { return WpfBase.AxisY; }
set { WpfBase.AxisY = value; }
}
///
/// Gets or sets the axis x.
///
///
/// The axis x.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public AxesCollection AxisX
{
get { return WpfBase.AxisX; }
set { WpfBase.AxisX = value; }
}
///
/// Gets or sets the default legend.
///
///
/// The default legend.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public UserControl DefaultLegend
{
get { return WpfBase.ChartLegend; }
set { WpfBase.ChartLegend = value; }
}
///
/// Gets or sets the zoom.
///
///
/// The zoom.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public ZoomingOptions Zoom
{
get { return WpfBase.Zoom; }
set { WpfBase.Zoom = value; }
}
///
/// Gets or sets the pan.
///
///
/// The pan.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public PanningOptions Pan
{
get { return WpfBase.Pan; }
set { WpfBase.Pan = value; }
}
///
/// Gets or sets the legend location.
///
///
/// The legend location.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public LegendLocation LegendLocation
{
get { return WpfBase.LegendLocation; }
set { WpfBase.LegendLocation = value; }
}
///
/// Gets or sets the series.
///
///
/// The series.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public SeriesCollection Series
{
get { return WpfBase.Series; }
set { WpfBase.Series = value; }
}
///
/// Gets or sets the animations speed.
///
///
/// The animations speed.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public TimeSpan AnimationsSpeed
{
get { return WpfBase.AnimationsSpeed; }
set { WpfBase.AnimationsSpeed = value; }
}
///
/// Gets or sets a value indicating whether [disable animations].
///
///
/// true if [disable animations]; otherwise, false.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool DisableAnimations
{
get { return WpfBase.DisableAnimations; }
set { WpfBase.DisableAnimations = value; }
}
///
/// Gets or sets the data tooltip.
///
///
/// The data tooltip.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public UserControl DataTooltip
{
get { return WpfBase.DataTooltip; }
set { WpfBase.DataTooltip = value; }
}
///
/// Gets or sets a value indicating whether this is hoverable.
///
///
/// true if hoverable; otherwise, false.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool Hoverable
{
get { return Base.Hoverable; }
set { Base.Hoverable = value; }
}
///
/// Gets or sets the scroll mode.
///
///
/// The scroll mode.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public ScrollMode ScrollMode { get { return Base.ScrollMode; } set { Base.ScrollMode = value; } }
///
/// Gets or sets the scroll horizontal from.
///
///
/// The scroll horizontal from.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public double ScrollHorizontalFrom
{
get { return Base.ScrollHorizontalFrom; }
set { Base.ScrollHorizontalFrom = value; }
}
///
/// Gets or sets the scroll horizontal to.
///
///
/// The scroll horizontal to.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public double ScrollHorizontalTo
{
get { return Base.ScrollHorizontalTo; }
set { Base.ScrollHorizontalTo = value; }
}
///
/// Gets or sets the scroll vertical from.
///
///
/// The scroll vertical from.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public double ScrollVerticalFrom
{
get { return Base.ScrollVerticalFrom; }
set { Base.ScrollVerticalFrom = value; }
}
///
/// Gets or sets the scroll vertical to.
///
///
/// The scroll vertical to.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public double ScrollVerticalTo
{
get { return Base.ScrollVerticalTo; }
set { Base.ScrollVerticalTo = value; }
}
///
/// Gets or sets the scroll bar fill.
///
///
/// The scroll bar fill.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Brush ScrollBarFill
{
get { return Base.ScrollBarFill; }
set { Base.ScrollBarFill = value; }
}
///
/// Gets or sets the background.
///
///
/// The background.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Brush Background
{
get { return WpfBase.Background; }
set { WpfBase.Background = value; }
}
///
/// Gets or sets the visual elements.
///
///
/// The visual elements.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public VisualElementsCollection VisualElements
{
get { return WpfBase.VisualElements; }
set { WpfBase.VisualElements = value; }
}
///
/// Gets or sets the state of the updater.
///
///
/// The state of the updater.
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public UpdaterState UpdaterState
{
get { return WpfBase.UpdaterState; }
set { WpfBase.UpdaterState = value; }
}
#endregion
#region Methods
///
/// Updates the specified restart view.
///
/// if set to true [restart view].
/// if set to true [force].
public void Update(bool restartView, bool force)
{
WpfBase.Update(restartView, force);
}
#endregion
}
}