public Window3() { var brush = (Path)FindResource("WQ"); brush.Stroke = Brushes.LightGray;//new SolidColorBrush(Color.FromRgb(255, 255, 255)); brush.Opacity = 0.1; //brush.StrokeThickness = 1; canvas.Children.Add(brush); //var brush = (Brush)FindResource("MyGridBrushResource"); //canvas.Children.Add(brush); SizeToContent = SizeToContent.WidthAndHeight; this.Content = canvas; Button btn_test = new Button() { Content = "test" }; InitializeComponent(); var random = new Random(); var points = new List <Point>(); var heights = new List <double>(); var length = 0; var interval = width / (pageSize - 1); var totalLength = interval * totalCount; var alpha = height / totalLength; totalCount = ys.Count; pageSize = totalCount; var min = ys.Min(); var max = ys.Max(); for (int i = 0; i < ys.Count; i++) { var y = height - (ys[i] - min) / (max - min) * height; points.Add(new Point(width / ys.Count * i, y)); } //heights = heights.OrderByDescending(it => it).ToList(); //for (int i = 0; i < heights.Count; i++) //{ // points.Add(new Point(interval * i, heights[i])); //} //for (int i = 1; i < points.Count - 1; i++) //{ // var item = points[i]; // var t1 = (points[i].X - points[i - 1].X) / (points[i].Y - points[i - 1].Y); // var t2 = (points[i + 1].X - points[i].X) / (points[i + 1].Y - points[i].Y); // if (Math.Abs(t1 - t2) <= 10) // { // item.Y = item.Y - 50; // } //} //Polyline //Polyline polyline = new Polyline() { }; //StreamGeometry stream = new StreamGeometry(); //using (var ctx = stream.Open()) //{ // ctx.BeginFigure(points[0], false, false); // ctx.PolyLineTo(points, true, true); // ctx.Close(); //} //Path myPath = new Path(); //myPath.StrokeThickness = 1; //myPath.Stroke = Brushes.DarkRed; //canvas.Children.Add(myPath); //myPath.Fill = Brushes.Red; DrawingGroup drawingGroup = new DrawingGroup(); //GeometryGroup geometryGroup = new GeometryGroup() { FillRule = FillRule.Nonzero}; //Polyline polyline = new Polyline() { Stroke = Brushes.Red }; PathGeometry pathGeometry = new PathGeometry() { FillRule = FillRule.Nonzero }; pathGeometry.Figures.Add(pathFigure); PathGeometry pathGeometry2 = new PathGeometry() { FillRule = FillRule.Nonzero }; pathGeometry2.Figures.Add(pathFigure2); //geometryGroup.Children.Add(pathGeometry); //geometryGroup.Children.Add(pathGeometry2); LinearGradientBrush trendGradientBrush = new LinearGradientBrush() { StartPoint = new Point(0, 1), EndPoint = new Point(0, 0) }; trendGradientBrush.GradientStops.Add(new GradientStop() { Offset = 0, Color = Color.FromRgb(248, 50, 47) }); trendGradientBrush.GradientStops.Add(new GradientStop() { Offset = 0.5, Color = Color.FromRgb(248, 101, 68) }); trendGradientBrush.GradientStops.Add(new GradientStop() { Offset = 1, Color = Color.FromRgb(248, 101, 68) }); LinearGradientBrush backGradientBrush = new LinearGradientBrush() { StartPoint = new Point(0, 0), EndPoint = new Point(1, 1) }; backGradientBrush.GradientStops.Add(new GradientStop() { Offset = 0, Color = Color.FromRgb(249, 111, 56) }); var stop = new GradientStop() { Offset = 0.5, Color = Color.FromRgb(248, 50, 47) }; backGradientBrush.GradientStops.Add(stop); this.RegisterName("backGradientStop", stop); backGradientBrush.GradientStops.Add(new GradientStop() { Offset = 1, Color = Color.FromRgb(248, 50, 47) }); //DoubleAnimation offsetAnimation = new DoubleAnimation(); //offsetAnimation.From = 0.5; //offsetAnimation.To = 0.8; //offsetAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(during * totalCount)); //Storyboard.SetTargetName(offsetAnimation, "backGradientStop"); //Storyboard.SetTargetProperty(offsetAnimation, new PropertyPath(GradientStop.OffsetProperty)); //mainStoryborad.Children.Add(offsetAnimation); //GeometryDrawing line = new GeometryDrawing() { Geometry = pathGeometry, Pen = new Pen(Brushes.DarkRed, 0) }; var highlight = new SolidColorBrush(Color.FromRgb(249, 111, 56)); Path path = new Path() { Stroke = new SolidColorBrush(Color.FromArgb(30, 239, 215, 0) /*Color.FromArgb(255, 239, 215, 0)*/), StrokeThickness = 3 }; path.Effect = new BlurEffect() { Radius = 2, RenderingBias = RenderingBias.Performance, KernelType = KernelType.Gaussian }; //new BlurEffect() { Radius = 20, KernelType = KernelType.Gaussian }; GeometryDrawing polygon = new GeometryDrawing() { Geometry = pathGeometry2, Brush = trendGradientBrush, Pen = new Pen(highlight, 1) }; path.Data = pathGeometry; //path.; //geometryDrawing.Geometry = pathGeometry; //drawingGroup.Children.Add(line); drawingGroup.Children.Add(polygon); DrawingImage drawingImage = new DrawingImage(); drawingImage.Drawing = drawingGroup; Image image = new Image() { Source = drawingImage }; //btn_test.Effect = new BlurEffect() { Radius=5, KernelType= KernelType.Box }; //image.LayoutTransform = new RotateTransform(180, 0.5, 0.5); canvas.Children.Add(image); canvas.Children.Add(path); canvas.Background = backGradientBrush; Canvas.SetBottom(image, 0); //pathFigure.Segments.Add(new LineSegment(points[0], false)); //pathFigure.Segments.Add(new LineSegment(points[1], false)); //pathFigure.Segments.Add(new LineSegment(points[2], false)); //myPath.Data = drawingImage; //pathFigure.StartPoint = new Point(0,0); //var lineSegment = new LineSegment(points[0], true); //var startSegment = new LineSegment(points[0], true); //pathFigure.Segments.Add(startSegment); //RegisterName("lineSegment" + i, startSegment); //for (int i = 0; i < 200 - 1; ++) //{ // PointAnimation pointAnimation = new PointAnimation(points[i], points[i + 1], new Duration(TimeSpan.FromMilliseconds(1000))); // pointAnimation.BeginTime = TimeSpan.FromMilliseconds(i * 1010); // pointAnimation.Completed += (sender, e) => // { // startSegment = new LineSegment(points[i + 1], true); // pathFigure.Segments.Add(startSegment); // }; // Storyboard.SetTargetName(pointAnimation, "lineSegment" + i); // Storyboard.SetTargetProperty(pointAnimation, new PropertyPath(LineSegment.PointProperty)); // storyboard.Children.Add(pointAnimation); // //storyboard.FillBehavior = FillBehavior.HoldEnd; //storyboard.Begin(canvas); //} //canvas.Children.Add(polyline); //polyline.Points.Add(points[0]); //polyline.Points.Add(points[0]); //RegisterName("hevoPolyline", polyline); //var dx = new DoubleAnimation(); //dx.From = points[0].X; //dx.To = points[0 + 1].X; //dx.Duration = TimeSpan.FromMilliseconds(10000); //dx.BeginTime = TimeSpan.FromMilliseconds(10000 * 0); ////dx.Completed += (sender, e) => { polyline.Points.Add(points[0 + 1]); }; //Storyboard.SetTarget(dx, polyline); //GeometryGroup geometryGroup = new GeometryGroup(); //Path path = new Path(); //path.Data = geometryGroup; //Storyboard.SetTargetProperty(dx, new PropertyPath("Points[" + (1) + "].X")); //storyboard.Children.Add(dx); //var dx = new PointAnimation(); //dx.From = points[0]; //dx.To = points[0 + 1]; //dx.Duration = TimeSpan.FromMilliseconds(10000); //dx.BeginTime = TimeSpan.FromMilliseconds(10000 * 0); ////dx.Completed += (sender, e) => { polyline.Points.Add(points[0 + 1]); }; //Storyboard.SetTarget(dx, polyline); //Storyboard.SetTargetProperty(dx, new PropertyPath("Points[" + (1) + "]")); //storyboard.Children.Add(dx); //for (int i = 0; i < 200 - 1; i++) //{ // var dx = new DoubleAnimation(); // dx.From = points[i].X; // dx.To = points[i + 1].X; // dx.Duration = TimeSpan.FromMilliseconds(10000); // dx.BeginTime = TimeSpan.FromMilliseconds(10000 * i); // dx.Completed += (sender, e) => { polyline.Points.Add(points[i + 1]); }; // Storyboard.SetTargetName(dx, "hevoPolyline"); // Storyboard.SetTargetProperty(dx, new PropertyPath("Points[" + (i) + "].X")); // storyboard.Children.Add(dx); // var dy = new DoubleAnimation(); // dy.From = points[i].Y; // dy.To = points[i + 1].Y; // dy.Duration = TimeSpan.FromMilliseconds(10000); // dy.BeginTime = TimeSpan.FromMilliseconds(10000 * i); // dy.Completed += (sender, e) => { polyline.Points.Add(points[i + 1]); }; // Storyboard.SetTargetName(dy, "hevoPolyline"); // Storyboard.SetTargetProperty(dy, new PropertyPath("Points[" + (i) + "].Y")); // storyboard.Children.Add(dy); //} DoubleAnimation leftAnimation1 = new DoubleAnimation(); leftAnimation1.From = 0; leftAnimation1.To = -totalLength + interval + width; leftAnimation1.Duration = new Duration(TimeSpan.FromMilliseconds(during * totalCount)); mainStoryborad.Children.Add(leftAnimation1); Storyboard.SetTarget(leftAnimation1, image); Storyboard.SetTargetProperty(leftAnimation1, new PropertyPath(Canvas.LeftProperty)); DoubleAnimation leftAnimation2 = new DoubleAnimation(); leftAnimation2.From = 0; leftAnimation2.To = -totalLength + interval + width; leftAnimation2.Duration = new Duration(TimeSpan.FromMilliseconds(during * totalCount)); mainStoryborad.Children.Add(leftAnimation2); Storyboard.SetTarget(leftAnimation2, path); Storyboard.SetTargetProperty(leftAnimation2, new PropertyPath(Canvas.LeftProperty)); //AddPoint(points[0]); //Fill //Polygon polygon = new Polygon(); ////polygon.se //polygon.Margin = new Thickness(0, 50, 0, 0); //canvas.Children.Add(polygon); //polygon.Points.Add(new Point(0, 0)); //polygon.Points.Add(new Point(0, 0)); //polygon.Fill = Brushes.Black; pathFigure2.StartPoint = new Point(0, height); var first_seg = new LineSegment(new Point(0, height), false) { }; RegisterName("first_seg", first_seg); RegisterName("pathFigure2", pathFigure2); pathFigure2.Segments.Add(first_seg); pathFigure2.Segments.Add(new LineSegment(points[0], false) { }); //pathFigure2.Segments.Add(new LineSegment(points[1], false)); //pathFigure2.Segments.Add(new LineSegment(points[2], false)); trendStoryboard.Completed += (sender, e) => { if (CurrentPoints.Count == pageSize) { } if (CurrentPoints.Any()) { //pathFigure2.Segments.Add(new LineSegment(CurrentPoints.Last(), false)); } }; var j = 0; Timer timer = new Timer(); timer.Interval = during + pause; timer.Elapsed += (sender, e) => { Dispatcher.BeginInvoke(new Action(() => { if (j == pageSize) { //mainStoryborad.Begin(canvas); } if (j == points.Count) { timer.Stop(); return; } AddPoint(points[j]); j++; })); }; canvas.Children.Add(btn_test); timer.Start(); btn_test.Click += (sender, e) => { //polygon.Points.Add(points[j]); AddPoint(points[j]); j++; }; }