笛卡尔-心形图 源代码 分析,该怎么处理

笛卡尔-心形图 源代码 分析
笛卡尔-心形图 源代码 分析,该怎么处理
java的代码如下,谁能帮我用C#改写一下啊,谢谢,感激不尽
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

/**
 * 笛卡尔情书的秘密r=a(1-sinθ)
 *
 * @author crazykay
 * @see 《趣味编程100例》心形图
 */
public class JavaFXApplicationHeart extends Application {

    @Override
    public void start(Stage primaryStage) {
        int width, height;
        Canvas canvas = new Canvas(350, 350);
        width = (int) canvas.getWidth();
        height = (int) canvas.getHeight();

        GraphicsContext gc = canvas.getGraphicsContext2D();
        double x, y, r;
        for (int i = 0; i <= 90; i++) {
            for (int j = 0; j <= 90; j++) {
                //转换为直角坐标系,设置偏移量,使图像居中
                r = Math.PI / 45 * i * (1 - Math.sin(Math.PI / 45 * j)) * 19;
                x = r * Math.cos(Math.PI / 45 * j) * Math.sin(Math.PI / 45 * i) + width / 2;
                y = -r * Math.sin(Math.PI / 45 * j) + height / 4;

                gc.setFill(Color.RED);
                gc.fillOval(x, y, 2, 2);
                gc.fillOval(x, y, 1, 1);
            }
        }


        StackPane root = new StackPane();
        root.getChildren().add(canvas);

        Scene scene = new Scene(root, Color.BLACK);

        primaryStage.setTitle("r=a(1-sinθ)");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
源地址http://www.oschina.net/code/snippet_104514_18581

------解决方案--------------------
private void Form4_Load(object sender, EventArgs e)
        {
            this.BackColor = Color.Black;
            this.Size = new Size(400, 400);
            Panel panel = new Panel();
            panel.Size = new Size(350, 350);
            panel.Paint += new PaintEventHandler(panel_Paint);
            panel.Location = new Point((this.ClientRectangle.Width - panel.Width) / 2, (this.ClientRectangle.Height - panel.Height) / 2);
            this.Controls.Add(panel);
        }



        void panel_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            double x, y, r;
            int w = e.ClipRectangle.Width;
            int h = e.ClipRectangle.Height;
            for (int i = 0; i <= 90; i++)