public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart) { var center = Left + Width / 2; if (IsNew) { HighToLowLine.X1 = center; HighToLowLine.X2 = center; HighToLowLine.Y1 = StartReference; HighToLowLine.Y2 = StartReference; Canvas.SetTop(OpenToCloseRectangle, (Open + Close) / 2); Canvas.SetLeft(OpenToCloseRectangle, Left); OpenToCloseRectangle.Width = Width; OpenToCloseRectangle.Height = 0; } if (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel))) { Canvas.SetTop(DataLabel, current.ChartLocation.Y); Canvas.SetLeft(DataLabel, current.ChartLocation.X); } if (HoverShape != null) { var h = Math.Abs(High - Low); HoverShape.Width = Width; HoverShape.Height = h > 10 ? h : 10; Canvas.SetLeft(HoverShape, Left); Canvas.SetTop(HoverShape, High); } var candleSeries = (CandleSeries)current.SeriesView; if (candleSeries.ColoringRules == null) { if (current.Open <= current.Close) { HighToLowLine.Stroke = candleSeries.IncreaseBrush; OpenToCloseRectangle.Fill = candleSeries.IncreaseBrush; OpenToCloseRectangle.Stroke = candleSeries.IncreaseBrush; } else { HighToLowLine.Stroke = candleSeries.DecreaseBrush; OpenToCloseRectangle.Fill = candleSeries.DecreaseBrush; OpenToCloseRectangle.Stroke = candleSeries.DecreaseBrush; } } else { foreach (var rule in candleSeries.ColoringRules) { if (!rule.Condition(current, previousDrawn)) { continue; } HighToLowLine.Stroke = rule.Stroke; OpenToCloseRectangle.Fill = rule.Fill; OpenToCloseRectangle.Stroke = rule.Stroke; break; } } if (chart.View.DisableAnimations) { HighToLowLine.Y1 = High; HighToLowLine.Y2 = Low; HighToLowLine.X1 = center; HighToLowLine.X2 = center; double Abs = Math.Abs(Open - Close); OpenToCloseRectangle.Width = Width; OpenToCloseRectangle.Height = Abs > 1 ? Abs : 1; Canvas.SetTop(OpenToCloseRectangle, Math.Min(Open, Close)); Canvas.SetLeft(OpenToCloseRectangle, Left); if (DataLabel != null) { DataLabel.UpdateLayout(); var cx = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualHeight * .5, chart); var cy = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualWidth * .5, chart); Canvas.SetTop(DataLabel, cy); Canvas.SetLeft(DataLabel, cx); } return; } var animSpeed = chart.View.AnimationsSpeed; if (DataLabel != null) { DataLabel.UpdateLayout(); var cx = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart); var cy = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart); DataLabel.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(cx, animSpeed)); DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(cy, animSpeed)); } HighToLowLine.BeginAnimation(Line.X1Property, new DoubleAnimation(center, animSpeed)); HighToLowLine.BeginAnimation(Line.X2Property, new DoubleAnimation(center, animSpeed)); HighToLowLine.BeginAnimation(Line.Y1Property, new DoubleAnimation(High, animSpeed)); HighToLowLine.BeginAnimation(Line.Y2Property, new DoubleAnimation(Low, animSpeed)); OpenToCloseRectangle.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(Left, animSpeed)); OpenToCloseRectangle.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(Math.Min(Open, Close), animSpeed)); OpenToCloseRectangle.BeginAnimation(FrameworkElement.WidthProperty, new DoubleAnimation(Width, animSpeed)); OpenToCloseRectangle.BeginAnimation(FrameworkElement.HeightProperty, new DoubleAnimation(Math.Max(Math.Abs(Open - Close), OpenToCloseRectangle.StrokeThickness), animSpeed)); }
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart) { var center = Left + Width / 2; if (IsNew) { HighToLowLine.X1 = center; HighToLowLine.X2 = center; HighToLowLine.Y1 = StartReference; HighToLowLine.Y2 = StartReference; Canvas.SetTop(OpenToCloseRectangle, (Open + Close) / 2); Canvas.SetLeft(OpenToCloseRectangle, Left); OpenToCloseRectangle.Width = Width; OpenToCloseRectangle.Height = 0; if (DataLabel != null) { Canvas.SetTop(DataLabel, current.ChartLocation.Y); Canvas.SetLeft(DataLabel, current.ChartLocation.X); } } if (HoverShape != null) { var h = Math.Abs(High - Low); HoverShape.Width = Width; HoverShape.Height = h > 10 ? h : 10; Canvas.SetLeft(HoverShape, Left); Canvas.SetTop(HoverShape, High); } if (chart.View.DisableAnimations) { HighToLowLine.Y1 = High; HighToLowLine.Y2 = Low; OpenToCloseRectangle.Width = Width; OpenToCloseRectangle.Height = Math.Abs(Open - Close); Canvas.SetTop(OpenToCloseRectangle, Math.Min(Open, Close)); Canvas.SetLeft(OpenToCloseRectangle, Left); if (DataLabel != null) { DataLabel.UpdateLayout(); var cx = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualHeight * .5, chart); var cy = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualWidth * .5, chart); Canvas.SetTop(DataLabel, cy); Canvas.SetLeft(DataLabel, cx); } return; } var animSpeed = chart.View.AnimationsSpeed; if (DataLabel != null) { DataLabel.UpdateLayout(); var cx = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart); var cy = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart); DataLabel.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(cx, animSpeed)); DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(cy, animSpeed)); } HighToLowLine.BeginAnimation(Line.X1Property, new DoubleAnimation(center, animSpeed)); HighToLowLine.BeginAnimation(Line.X2Property, new DoubleAnimation(center, animSpeed)); HighToLowLine.BeginAnimation(Line.Y1Property, new DoubleAnimation(High, animSpeed)); HighToLowLine.BeginAnimation(Line.Y2Property, new DoubleAnimation(Low, animSpeed)); OpenToCloseRectangle.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(Left, animSpeed)); OpenToCloseRectangle.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(Math.Min(Open, Close), animSpeed)); OpenToCloseRectangle.BeginAnimation(FrameworkElement.WidthProperty, new DoubleAnimation(Width, animSpeed)); OpenToCloseRectangle.BeginAnimation(FrameworkElement.HeightProperty, new DoubleAnimation(Math.Max(Math.Abs(Open - Close), OpenToCloseRectangle.StrokeThickness), animSpeed)); }