using System;
using System.Collections.Generic;

using Grasshopper.Kernel;
using Rhino.Geometry;

namespace Workshop.Pyramid
{
    public class GhcCreatePyramid : GH_Component
    {
        public GhcCreatePyramid()
            : base("Create Pyramid", "Create Pyramid",
                "Create Pyramid from position, length, width and height",
                "Workshop", "Pyramid")
        {
        }


        protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
        {
            pManager.AddPlaneParameter("Base Plane", "Base Plane", "Base Plane", GH_ParamAccess.item, Plane.WorldXY);
            pManager.AddNumberParameter("Height", "Height", "Height", GH_ParamAccess.item, 1.0);
            pManager.AddNumberParameter("Width", "Width", "Width", GH_ParamAccess.item, 1.0);
            pManager.AddNumberParameter("Length", "Length", "Length", GH_ParamAccess.item, 1.0);
        }


        protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
        {
            pManager.AddGenericParameter("Pyramid", "Pyramid", "Pyramid", GH_ParamAccess.item);
        }


        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Plane iBasePlane = Plane.Unset;
            double iHeight = double.NaN;
            double iLength = double.NaN;
            double iWidth = double.NaN;

            DA.GetData("Base Plane", ref iBasePlane);
            DA.GetData("Height", ref iHeight);
            DA.GetData("Width", ref iWidth);
            DA.GetData("Length", ref iLength);

            Pyramid pyramid = new Pyramid(iBasePlane, iLength, iWidth, iLength);

            DA.SetData("Pyramid", pyramid);
        }


        protected override System.Drawing.Bitmap Icon
        {
            get
            {
                return Workshop.Properties.Resources.Icon_PyramidCreate;
            }
        }


        public override Guid ComponentGuid
        {
            get { return new Guid("{9114a364-9739-4e7e-bccb-ecfd4238cae0}"); }
        }
    }
}