private void Generate_button_Click(object sender, RoutedEventArgs e) { myEngineBridge.ClearSprites(); foreach (Line line in myCurrentLines) { Canvas_CurvePoints.Children.Remove(line); } myCurrentLines.Clear(); switch (myCurveType) { case eCurve.None: break; case eCurve.CatmullRom: List <PointF> tempPoints = new List <PointF>(); tempPoints = myPoints; tempPoints.Insert(0, myPoints[0]); tempPoints.Insert(myPoints.Count - 1, myPoints[myPoints.Count - 1]); PointF[] points = Catmull_Rom_Sample.CatmullRomSpline.Generate(tempPoints.ToArray(), 60); for (int i = 0; i < points.Length; i++) { if (i < points.Length - 1) { Line line = new Line(); line.X1 = points[i].X; line.X2 = points[i + 1].X; line.Y1 = points[i].Y; line.Y2 = points[i + 1].Y; line.Stroke = System.Windows.Media.Brushes.Red; line.StrokeThickness = 1; myCurrentLines.Add(line); Canvas_CurvePoints.Children.Add(line); } myEngineBridge.SetSpritePosition((float)(points[i].X / Canvas_CurvePoints.Width), (float)(points[i].Y / Canvas_CurvePoints.Height)); } break; case eCurve.Bezier: int cpts = 80; double[] pointsBezier = new double[cpts * 2]; myBezierCurve.Generate(myPointsBezier.ToArray(), cpts, pointsBezier); for (int i = 0; i < pointsBezier.Length; i += 2) { if (i < pointsBezier.Length - 2) { Line line = new Line(); line.X1 = pointsBezier[i]; line.X2 = pointsBezier[i + 2]; line.Y1 = pointsBezier[i + 1]; line.Y2 = pointsBezier[i + 3]; line.Stroke = System.Windows.Media.Brushes.Red; line.StrokeThickness = 1; myCurrentLines.Add(line); Canvas_CurvePoints.Children.Add(line); myEngineBridge.SetSpritePosition((float)(pointsBezier[i] / Canvas_CurvePoints.Width), (float)(pointsBezier[i + 1] / Canvas_CurvePoints.Height)); } } break; default: break; } }