using System.Windows.Forms;
using System.Drawing;
using Drawing3d;
namespace Sample
{
    public partial class Form1 : Form
    {
        MyDevice Device = new MyDevice();
        public Form1()
        {
            InitializeComponent();
            Device.WinControl = this;
        }
    }
    public class MyDevice : OpenGlDevice
    {
        AnimatorSet AnimatorSet = new AnimatorSet();
        FaderAnimator FaderAnimatorOut = new FaderAnimator();
        FaderAnimator FaderAnimatorIn = new FaderAnimator();
        Sphere Sphere1 = new Sphere(new xyz(8, 0, 0), 1.5);
        Sphere Sphere2 = new Sphere(new xyz(-8, 0, 0), 1.5);
        Cone Cone = new Cone(4, 5);
        Torus Torus = new Torus(1, 5);
        BoxEntity Box = new BoxEntity(new xyz(-4, -9, 0), new xyz(8, 3, 3));
        public override void OnPaint()
        {
            base.OnPaint();
            Torus.Paint(this);
            Sphere1.Paint(this);
            Sphere2.Paint(this);
            Cone.Paint(this);
            Box.Paint(this);
        }
        protected override void OnCreated()
        {
            base.OnCreated();
            AnimatorSet.Device = this;
            AnimatorSet.ChildAnimations.Add(FaderAnimatorOut);
            AnimatorSet.ChildAnimations.Add(FaderAnimatorIn);
            FaderAnimatorIn.Device = this;
            FaderAnimatorIn.Duration = 5000;
            FaderAnimatorIn.FromOpacity = 0;
            FaderAnimatorIn.ToOpacity = 1;
            FaderAnimatorIn.Entities.Add(Cone);
            FaderAnimatorOut.Entities.Add(Cone);
            Cone.Material = Materials.Gold;
            FaderAnimatorOut.Device = this;
            FaderAnimatorOut.Duration = 5000;
            FaderAnimatorOut.FromOpacity = 1;
            FaderAnimatorOut.ToOpacity = 0;
            AnimatorSet.Start();
        }
    }
}