Exemplo n.º 1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            IGH_Goo Element = null;

            List <System.Drawing.Color> Colors = new List <System.Drawing.Color>();
            List <double> Parameters           = new List <double>();
            double        GradientAngle        = 0;

            if (!DA.GetData(0, ref Element))
            {
                return;
            }
            if (!DA.GetDataList(1, Colors))
            {
                return;
            }
            if (!DA.GetDataList(2, Parameters))
            {
                return;
            }
            if (!DA.GetData(3, ref GradientAngle))
            {
                return;
            }

            wObject W = new wObject();

            if (Element != null)
            {
                Element.CastTo(out W);
            }
            wGraphic G = W.Graphics;

            G.FillType     = wGraphic.FillTypes.LinearGradient;
            G.CustomFills += 1;

            if (Parameters.Count < 1)
            {
                G.Gradient = new wGradient(Colors);
            }
            else
            {
                if (Parameters.Count < Colors.Count)
                {
                    for (int i = Parameters.Count; i < Colors.Count; i++)
                    {
                        Parameters.Add(Parameters[Parameters.Count - 1]);
                    }
                }

                G.Gradient = new wGradient(Colors, Parameters, GradientAngle, (wGradient.GradientSpace)GradientSpace);
            }

            G.WpfFill = new wFillGradient(G.Gradient, GradientType).GrdBrush;

            W.Graphics = G;

            if (Element != null)
            {
                switch (W.Type)
                {
                case "Parrot":
                    pElement E = (pElement)W.Element;
                    pControl C = (pControl)E.ParrotControl;
                    C.SetFill();

                    C.Graphics = G;
                    break;

                case "Pollen":
                    switch (W.SubType)
                    {
                    case "DataPoint":
                        DataPt tDataPt = (DataPt)W.Element;
                        tDataPt.Graphics = G;

                        tDataPt.Graphics.WpfFill    = G.WpfFill;
                        tDataPt.Graphics.WpfPattern = G.WpfPattern;

                        W.Element = tDataPt;
                        break;

                    case "DataSet":
                        DataSetCollection tDataSet = (DataSetCollection)W.Element;
                        tDataSet.Graphics = G;

                        tDataSet.Graphics.WpfFill    = G.WpfFill;
                        tDataSet.Graphics.WpfPattern = G.WpfPattern;

                        W.Element = tDataSet;
                        break;

                    case "Chart":
                    case "Table":

                        pElement pE = (pElement)W.Element;
                        pChart   pC = pE.PollenControl;
                        pC.Graphics = G;

                        pC.Graphics.WpfFill    = G.WpfFill;
                        pC.Graphics.WpfPattern = G.WpfPattern;

                        pC.SetGradientFill();

                        pE.PollenControl = pC;
                        W.Element        = pE;
                        break;
                    }
                    break;

                case "Hoopoe":
                    wShapeCollection Shapes = (wShapeCollection)W.Element;
                    Shapes.Graphics.FillType = wGraphic.FillTypes.LinearGradient;

                    wGradient GRD = new wGradient();

                    if (Parameters.Count < 1)
                    {
                        GRD = new wGradient(Colors, GradientAngle, (wGradient.GradientSpace)GradientSpace);
                    }
                    else
                    {
                        GRD = new wGradient(Colors, Parameters, GradientAngle, (wGradient.GradientSpace)GradientSpace);
                    }

                    Shapes.Graphics.Gradient = GRD;
                    Shapes.Graphics.WpfFill  = new wFillGradient(G.Gradient, GradientType).GrdBrush;



                    W.Element = Shapes;
                    break;
                }
            }

            DA.SetData(0, W);
            DA.SetData(1, G);
        }