/// <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); }
/// <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); }
/// <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); }
/// <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; System.Drawing.Color Background = wColors.VeryLightGray.ToDrawingColor(); if (!DA.GetData(0, ref Element)) { return; } if (!DA.GetData(1, ref Background)) { return; } wObject W = new wObject(); if (Element != null) { Element.CastTo(out W); } wGraphic G = W.Graphics; G.FillType = wGraphic.FillTypes.Solid; G.Background = new wColor(Background); G.Foreground = new wColor(Background); G.WpfFill = new wFillSolid(G.Background).FillBrush; 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.SetSolidFill(); pE.PollenControl = pC; W.Element = pE; break; } break; case "Hoopoe": wShapeCollection Shapes = (wShapeCollection)W.Element; Shapes.Graphics.FillType = wGraphic.FillTypes.Solid; Shapes.Graphics.WpfFill = G.WpfFill; Shapes.Graphics.Background = new wColor(Background); Shapes.Graphics.Foreground = new wColor(Background); W.Element = Shapes; break; } DA.SetData(0, W); DA.SetData(1, G); }
/// <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) { // Declare variables IGH_Goo Element = null; IGH_Goo Z = null; int A = 6; int T = 4; int F = 1; double R = 0; // Access the input parameters if (!DA.GetData(0, ref Element)) { return; } if (!DA.GetData(1, ref Z)) { return; } if (!DA.GetData(2, ref A)) { return; } if (!DA.GetData(3, ref F)) { return; } if (!DA.GetData(4, ref T)) { return; } if (!DA.GetData(5, ref R)) { return; } wObject W = new wObject(); if (Element != null) { Element.CastTo(out W); } wGraphic G = W.Graphics; Bitmap B = null; if (Z != null) { Z.CastTo(out B); } G.FillType = wGraphic.FillTypes.Bitmap; G.FillBitmap = new wImage(B, (wImage.FillSpace)FillSpace, IsEmbedded, (wImage.AlignMode)A, (wImage.FitMode)F, R); G.WpfFill = new wFillBitmap(B, A, F, T, R, ScaleFactor).FillBrush; G.CustomFills += 1; 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; } break; case "Hoopoe": wShapeCollection Shapes = (wShapeCollection)W.Element; Shapes.Graphics.FillType = wGraphic.FillTypes.Bitmap; Shapes.Graphics.WpfFill = G.WpfFill; Shapes.Graphics.FillBitmap = new wImage(B, (wImage.FillSpace)FillSpace, IsEmbedded, (wImage.AlignMode)A, (wImage.FitMode)F, R); W.Element = Shapes; break; } } DA.SetData(0, W); DA.SetData(1, G); }