Visual Studio版で生成された3つのファイルのコードを紹介します。内容は別途C#5版で統合して解説しますので、ここでは単に「コピペ」だけです。

 

【Program.cs】

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TurtleGraphics01
{
    internal static class Program
    {
        /// <summary>
        /// アプリケーションのメイン エントリ ポイントです。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new TurtleGraphics01());
        }
    }
}
 

【TurtleGraphics01.Designer.cs】

namespace TurtleGraphics01
{
    partial class TurtleGraphics01
    {
        /// <summary>
        /// 必要なデザイナー変数です。
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// 使用中のリソースをすべてクリーンアップします。
        /// </summary>
        /// <param name="disposing">マネージド リソースを破棄する場合は true を指定し、その他の場合は false を指定します。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows フォーム デザイナーで生成されたコード

        /// <summary>
        /// デザイナー サポートに必要なメソッドです。このメソッドの内容を
        /// コード エディターで変更しないでください。
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TurtleGraphics01));
            this.Reset_Button = new System.Windows.Forms.Button();
            this.Hide_Button = new System.Windows.Forms.Button();
            this.Draw1_Button = new System.Windows.Forms.Button();
            this.Draw2_Button = new System.Windows.Forms.Button();
            this.Draw3_Button = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // Reset_Button
            // 
            this.Reset_Button.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.Reset_Button.Location = new System.Drawing.Point(718, 12);
            this.Reset_Button.Name = "Reset_Button";
            this.Reset_Button.Size = new System.Drawing.Size(65, 30);
            this.Reset_Button.TabIndex = 0;
            this.Reset_Button.Text = "リセット";
            this.Reset_Button.UseVisualStyleBackColor = true;
            this.Reset_Button.Click += new System.EventHandler(this.Reset_Button_Click);
            // 
            // Hide_Button
            // 
            this.Hide_Button.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.Hide_Button.Location = new System.Drawing.Point(718, 44);
            this.Hide_Button.Name = "Hide_Button";
            this.Hide_Button.Size = new System.Drawing.Size(65, 30);
            this.Hide_Button.TabIndex = 1;
            this.Hide_Button.Text = "亀表示";
            this.Hide_Button.UseVisualStyleBackColor = true;
            this.Hide_Button.Click += new System.EventHandler(this.Hide_Button_Click);
            // 
            // Draw1_Button
            // 
            this.Draw1_Button.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.Draw1_Button.Location = new System.Drawing.Point(718, 74);
            this.Draw1_Button.Name = "Draw1_Button";
            this.Draw1_Button.Size = new System.Drawing.Size(65, 30);
            this.Draw1_Button.TabIndex = 2;
            this.Draw1_Button.Text = "描画1";
            this.Draw1_Button.UseVisualStyleBackColor = true;
            this.Draw1_Button.Click += new System.EventHandler(this.Draw1_Button_Click);
            // 
            // Draw2_Button
            // 
            this.Draw2_Button.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.Draw2_Button.Location = new System.Drawing.Point(718, 104);
            this.Draw2_Button.Name = "Draw2_Button";
            this.Draw2_Button.Size = new System.Drawing.Size(65, 30);
            this.Draw2_Button.TabIndex = 3;
            this.Draw2_Button.Text = "描画2";
            this.Draw2_Button.UseVisualStyleBackColor = true;
            this.Draw2_Button.Click += new System.EventHandler(this.Draw2_Button_Click);
            // 
            // Draw3_Button
            // 
            this.Draw3_Button.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.Draw3_Button.Location = new System.Drawing.Point(718, 134);
            this.Draw3_Button.Name = "Draw3_Button";
            this.Draw3_Button.Size = new System.Drawing.Size(65, 30);
            this.Draw3_Button.TabIndex = 4;
            this.Draw3_Button.Text = "描画3";
            this.Draw3_Button.UseVisualStyleBackColor = true;
            this.Draw3_Button.Click += new System.EventHandler(this.Draw3_Button_Click);
            // 
            // TurtleGraphics01
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(800, 450);
            this.Controls.Add(this.Draw1_Button);
            this.Controls.Add(this.Draw3_Button);
            this.Controls.Add(this.Hide_Button);
            this.Controls.Add(this.Reset_Button);
            this.Controls.Add(this.Draw2_Button);
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Name = "TurtleGraphics01";
            this.Text = "TurtleGraphics01";
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Button Reset_Button;
        private System.Windows.Forms.Button Hide_Button;
        private System.Windows.Forms.Button Draw1_Button;
        private System.Windows.Forms.Button Draw2_Button;
        private System.Windows.Forms.Button Draw3_Button;
    }
}
 

【TurtleGraphics01.cs】

using Nakov.TurtleGraphics;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TurtleGraphics01
{
    public partial class TurtleGraphics01 : Form
    {
        public TurtleGraphics01()
        {
            InitializeComponent();
        }

        private void Reset_Button_Click(object sender, EventArgs e)
        {
            Turtle.Reset();
        }

        private void Hide_Button_Click(object sender, EventArgs e)
        {
            if (Turtle.ShowTurtle)
            {
                Turtle.ShowTurtle = false;
                this.Hide_Button.Text = "亀表示";
            }
            else
            {
                Turtle.ShowTurtle = true;
                this.Hide_Button.Text = "亀非表示";
            }
        }

        private void Draw1_Button_Click(object sender, EventArgs e)
        {
            // Assign a delay to visualize the drawing process
            Turtle.Delay = 200;

            // Draw a equilateral triangle
            Turtle.Rotate(30);
            Turtle.Forward(200);
            Turtle.Rotate(120);
            Turtle.Forward(200);
            Turtle.Rotate(120);
            Turtle.Forward(200);

            // Draw a line in the triangle
            Turtle.Rotate(-30);
            Turtle.PenUp();
            Turtle.Backward(50);
            Turtle.PenDown();
            Turtle.Backward(100);
            Turtle.PenUp();
            Turtle.Forward(150);
            Turtle.PenDown();
            Turtle.Rotate(30);
        }

        private void Draw2_Button_Click(object sender, EventArgs e)
        {
            // Assign a delay to visualize the drawing process
            Turtle.Delay = 150;
            Turtle.PenSize = 8;

            // Draw a equilateral triangle
            Turtle.PenColor = Color.Green;
            Turtle.Rotate(30);
            Turtle.Forward(200);
            Turtle.Rotate(120);
            Turtle.Forward(200);
            Turtle.Rotate(120);
            Turtle.Forward(200);

            // Draw a line in the triangle
            Turtle.Rotate(-30);
            Turtle.PenUp();
            Turtle.Backward(50);
            Turtle.PenDown();
            Turtle.PenColor = Color.Blue;
            Turtle.Backward(100);
            Turtle.PenUp();
            Turtle.Forward(150);
            Turtle.PenDown();
            Turtle.Rotate(30);
        }

        private void Draw3_Button_Click(object sender, EventArgs e)
        {
            Turtle.PenColor = Color.Red;
            Turtle.Delay = 50;
            for (int i = 0; i < 25; i++)
            {
                Turtle.Forward(i * 5);
                Turtle.Rotate(30 + i);
            }
        }
    }
}