using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace RealTimeGraphEx.Components
{
public class YAxisWave : YAxisScroll
{
private Grid innerGrid;
public YAxisWave()
: base()
{
}
public override void Render(RealTimeGraphExBase graph, bool animate = false)
{
if (graph == null) return;
if (innerGrid == null)
{
innerGrid = new Grid();
}
if (Interval == 0) return;
if (Interval % 2 != 0) Interval += 1;
var grid = innerGrid;
var renderBounds = Graph.GetGraphRenderBounds();
double animationTime = animate ? 0.2 : 0;
DoubleAnimation heightAnimation = new DoubleAnimation() { Duration = new Duration(TimeSpan.FromSeconds(animationTime)) };
heightAnimation.To = double.IsNaN(Graph.gridLinesAndImageWrapperGrid.Height) ? Graph.gridLinesAndImageWrapperGrid.ActualHeight : Graph.gridLinesAndImageWrapperGrid.Height;
if (!double.IsNaN(grid.Height))
{
grid.BeginAnimation(Grid.HeightProperty, heightAnimation);
}
else
{
grid.Height = Graph.gridLinesAndImageWrapperGrid.ActualHeight;
}
grid.VerticalAlignment = System.Windows.VerticalAlignment.Top;
ThicknessAnimation marginAni = new ThicknessAnimation() { Duration = new Duration(TimeSpan.FromSeconds(animationTime)) };
marginAni.To = new Thickness(0, Graph.gridLinesAndImageWrapperGrid.Margin.Top, 0, 0);
if (!double.IsNaN(grid.Height))
{
grid.BeginAnimation(MarginProperty, marginAni);
}
else
{
grid.Margin = new Thickness(0, Graph.gridLinesAndImageWrapperGrid.Margin.Top, 0, 0);
}
this.ClipToBounds = true;
this.Content = grid;
double height = double.IsNaN(Graph.gridLinesAndImageWrapperGrid.Height) ? Graph.gridLinesAndImageWrapperGrid.ActualHeight