Example #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;
            int     X       = 0;
            int     P       = 0;
            double  A       = 0;
            bool    L       = true;

            System.Drawing.Color C = System.Drawing.Color.Transparent;
            System.Drawing.Color F = System.Drawing.Color.Transparent;
            double T = 0;

            if (!DA.GetData(0, ref Element))
            {
                return;
            }
            if (!DA.GetData(1, ref X))
            {
                return;
            }
            if (!DA.GetData(2, ref P))
            {
                return;
            }
            if (!DA.GetData(3, ref A))
            {
                return;
            }
            if (!DA.GetData(4, ref C))
            {
                return;
            }
            if (!DA.GetData(5, ref F))
            {
                return;
            }
            if (!DA.GetData(6, ref T))
            {
                return;
            }

            wObject W;

            Element.CastTo(out W);

            wLabel CustomLabel = new wLabel();

            wGraphic G = CustomLabel.Graphics;

            if (P == 0)
            {
                L = false;
            }

            CustomLabel.HasLeader = L;
            CustomLabel.Graphics  = new wGraphic(new wColor(C), G.Foreground, new wColor(F), T);
            CustomLabel.Position  = (wLabel.LabelPosition)P;
            CustomLabel.Alignment = (wLabel.LabelAlignment)X;

            CustomLabel.Graphics = G;

            switch (W.Type)
            {
            case "Pollen":

                switch (W.SubType)
                {
                case "DataPoint":
                    DataPt Pt = (DataPt)W.Element;

                    Pt.Graphics.FontObject.Angle = A;

                    Pt.Label.HasLeader = L;
                    Pt.Label.Graphics  = new wGraphic(new wColor(C), G.Foreground, new wColor(F), T);
                    Pt.Label.Position  = (wLabel.LabelPosition)P;
                    Pt.Label.Alignment = (wLabel.LabelAlignment)X;
                    Pt.CustomLabels   += 1;

                    W.Element = Pt;
                    break;

                case "DataSet":
                    DataSetCollection St = (DataSetCollection)W.Element;
                    St.SetUniformLabel(CustomLabel, A);

                    St.Graphics.FontObject.Angle = A;

                    St.Label.HasLeader = L;
                    St.Label.Graphics  = new wGraphic(new wColor(C), G.Foreground, new wColor(F), T);
                    St.Label.Position  = (wLabel.LabelPosition)P;
                    St.Label.Alignment = (wLabel.LabelAlignment)X;

                    W.Element = St;
                    break;
                }
                break;
            }

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