Пример #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;
            IGH_Goo Shps    = null;
            double  Scale   = 1.0;

            if (!DA.GetData(0, ref Element))
            {
                return;
            }
            if (!DA.GetData(1, ref Shps))
            {
                return;
            }
            if (!DA.GetData(2, ref Scale))
            {
                return;
            }

            wObject W = new wObject();

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

            wShapeCollection S = new wShapeCollection();

            if (Shps != null)
            {
                Shps.CastTo(out S);
            }

            wFillSwatch Swatch = new wFillSwatch(S, Scale, TilingMode, S.X, S.Y, S.Width, S.Height);

            G.FillType     = wGraphic.FillTypes.Pattern;
            G.WpfPattern   = Swatch.DwgBrush;
            G.WpfFill      = Swatch.DwgBrush;
            G.CustomFills += 1;

            W.Graphics = G;

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

                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.SetPatternFill();

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

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

                Shapes.Graphics.WpfFill    = G.WpfFill;
                Shapes.Graphics.WpfPattern = G.WpfPattern;

                W.Element = Shapes;
                break;
            }

            DA.SetData(0, W);
            DA.SetData(1, G);
        }
Пример #2
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     Pattern = 0;
            double  Scale   = 1;

            System.Drawing.Color Background = wColors.VeryLightGray.ToDrawingColor();
            System.Drawing.Color ForeGround = wColors.LightGray.ToDrawingColor();

            if (!DA.GetData(0, ref Element))
            {
                return;
            }
            if (!DA.GetData(1, ref Pattern))
            {
                return;
            }
            if (!DA.GetData(2, ref Scale))
            {
                return;
            }
            if (!DA.GetData(3, ref ForeGround))
            {
                return;
            }
            if (!DA.GetData(4, ref Background))
            {
                return;
            }

            wObject W = new wObject();

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

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

            G.Background  = new wColor(Background);
            G.Foreground  = new wColor(ForeGround);
            G.StrokeColor = new wColor(ForeGround);

            G.SetUniformStrokeWeight(PatternWeight);

            wShapeCollection S = new wShapeCollection();

            S.Graphics = G;

            wPattern P = new wPattern(0, 0, 9, 9, S);

            if ((PatternModeStatus < 5) && (PatternModeStatus != 0))
            {
                P.SetStroke(Pattern);
            }
            else
            {
                P.SetStroke(0);
            }

            S = P.SetPattern(PatternModeStatus, Pattern, SpacingMode);

            G = S.Graphics;

            wFillSwatch Swatch = new wFillSwatch(S, Scale, 4, S.X, S.Y, S.Width, S.Height);


            G.WpfPattern = Swatch.DwgBrush;
            G.WpfFill    = Swatch.DwgBrush;

            W.Graphics = G;

            switch (W.Type)
            {
            case "Parrot":
                pElement E = (pElement)W.Element;
                pControl C = (pControl)E.ParrotControl;
                C.Graphics = G;

                C.SetFill();

                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.SetPatternFill();

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

            case "Hoopoe":
                wShapeCollection Shapes = (wShapeCollection)W.Element;
                Shapes.Graphics.FillType   = wGraphic.FillTypes.Pattern;
                Shapes.Graphics.WpfFill    = G.WpfFill;
                Shapes.Graphics.WpfPattern = G.WpfPattern;

                W.Element = Shapes;
                break;
            }

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