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
    {
      
        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));
        LinearAnimator LinearAnimator1 = new LinearAnimator();
        LinearAnimator LinearAnimator2 = new LinearAnimator();
        LinearAnimator LinearAnimator3 = new LinearAnimator();
        LinearAnimator LinearAnimator4 = new LinearAnimator();
        LinearAnimator LinearAnimator5 = new LinearAnimator();
        AnimatorSet AnimatorSet = new AnimatorSet();
        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();
            Cone.Material = Materials.Gold;
            AnimatorSet.Device = this;
            LinearAnimator1.Device = this;
            LinearAnimator2.Device = this;
            LinearAnimator3.Device = this;
            LinearAnimator4.Device = this;
            LinearAnimator5.Device = this;
            Sphere1.CompileEnable = false;
            AnimatorSet.ChildAnimations.Add(LinearAnimator1);
            LinearAnimator1.FromValue = new xyz(8, 0, 0);
            LinearAnimator1.ToValue = new xyz(8, 8, 0);
            LinearAnimator1.Animate += LinearAnimator_Animate;
            AnimatorSet.ChildAnimations.Add(LinearAnimator2);
            LinearAnimator2.Device = this;
            LinearAnimator2.FromValue = new xyz(8, 8, 0);
            LinearAnimator2.ToValue = new xyz(-8, 8, 0);
            LinearAnimator2.Animate += LinearAnimator_Animate;
            AnimatorSet.ChildAnimations.Add(LinearAnimator3);
            LinearAnimator3.Device = this;
            LinearAnimator3.FromValue = new xyz(-8, 8, 0);
            LinearAnimator3.ToValue = new xyz(-8, -8, 0);
            LinearAnimator3.Animate += LinearAnimator_Animate;
            AnimatorSet.ChildAnimations.Add(LinearAnimator4);
            LinearAnimator4.Device = this;
            LinearAnimator4.FromValue = new xyz(-8, -8, 0);
            LinearAnimator4.ToValue = new xyz(8, -8, 0);
            LinearAnimator4.Animate += LinearAnimator_Animate;
            AnimatorSet.ChildAnimations.Add(LinearAnimator5);
            LinearAnimator5.Device = this;
            LinearAnimator5.FromValue = new xyz(8, -8, 0);
            LinearAnimator5.ToValue = new xyz(8,0, 0);
            LinearAnimator5.Animate += LinearAnimator_Animate;
            AnimatorSet.Start();
        }
        private void LinearAnimator_Animate(object sender, System.EventArgs e)
        {
            Sphere1.Center = (sender as LinearAnimator).Value;
        }
       
    }
}