using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Drawing3d;
using Drawing3d.Math;
using Drawing3d.Devices;
using Drawing3d.Curves;
using Drawing3d.Surfaces;

namespace HelloWorld
{
    public partial class Form1 : Form
    {
        OpenGlDevice Device = new OpenGlDevice();
        Torus MyTorus = new Torus();
        Torus MyTorusLines = new Torus();
      
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {   Device.WinControl = this;
            Device.OnPaint += new EventHandler(Device_OnPaint);
            Device.Navigate = NavigateKind.ZoomRotateTrans;
            Device.BackColor = Color.White;
            MyTorus.InnerRadius = 1;
            MyTorus.OuterRadius = 3;
            CurveArray Curves = new CurveArray();
            // In clockwise sense
            Curves.Add(new Line(new xy(0.1, 0.1), new xy(0.2, 0.5)));
            Curves.Add(new Line(new xy(0.2, 0.5), new xy(0.5, 0.4)));
            Curves.Add(new Line(new xy(0.5, 0.4), new xy(0.1, 0.1)));
            // Set curves as bounding curves
            MyTorus.BoundedCurves = Curves;

            // only to show the lines of the torus
            MyTorusLines.InnerRadius = 1;
            MyTorusLines.OuterRadius = 3;
       
         }
        void Device_OnPaint(object sender, EventArgs e)
        {
            Device.Material = Drawing3d.Materials.Materials.Gold;
            // draw bounded surface
            Device.drawSurface(MyTorus);
            Device.Culling = false;
            // draw skeleton
            Device.PolygonMode = PolygonMode.Line;
            Device.drawSurface(MyTorusLines);
            Device.PolygonMode = PolygonMode.Fill;
        }
    }
}