Beispiel #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)
        {
            int Index = 0;

            if (!DA.GetData(0, ref Index))
            {
                return;
            }

            SelectedGradient = GradientSet[Index];

            wGraphic G = new wGraphic();

            G.Gradient = SelectedGradient;

            List <System.Drawing.Color> clrs = new List <System.Drawing.Color>();

            foreach (wColor C in SelectedGradient.ColorSet)
            {
                clrs.Add(C.ToDrawingColor());
            }

            DA.SetDataList(0, clrs);
            DA.SetDataList(1, SelectedGradient.ParameterSet);
            DA.SetData(2, SelectedGradient);
            DA.SetData(3, G);

            UpdateMessage();
        }
Beispiel #2
0
        public wFillGradient(wGradient WindGradient, int SetGradientMode)
        {
            GradientStopCollection gCollection = new GradientStopCollection();

            for (int i = 0; i < WindGradient.ColorSet.Count; i++)
            {
                gCollection.Add(new GradientStop(WindGradient.ColorSet[i].ToMediaColor(), WindGradient.ParameterSet[i]));
            }

            double R  = WindGradient.Angle / 180 * Math.PI;
            double XA = Math.Round(50 + Math.Sin(R) * 50) / 100.0;
            double YA = Math.Round(50 + Math.Cos(R) * 50) / 100.0;
            double XB = Math.Round(50 + Math.Sin(R + Math.PI) * 50) / 100.0;
            double YB = Math.Round(50 + Math.Cos(R + Math.PI) * 50) / 100.0;

            switch ((GradientMode)SetGradientMode)
            {
            case GradientMode.Radial:
                RadialGradientBrush RBrush = new RadialGradientBrush(gCollection);
                RBrush.MappingMode  = BrushMappingMode.RelativeToBoundingBox;
                RBrush.SpreadMethod = GradientSpreadMethod.Pad;

                RBrush.GradientOrigin = new Point(1 - WindGradient.Location.T0, 1 - WindGradient.Location.T1);
                RBrush.Center         = new Point(1 - WindGradient.Focus.T0, 1 - WindGradient.Focus.T1);
                RBrush.RadiusX        = WindGradient.Radius;
                RBrush.RadiusY        = WindGradient.Radius;

                GrdBrush = RBrush;
                break;

            default:
                LinearGradientBrush LBrush = new LinearGradientBrush(gCollection);
                LBrush.MappingMode  = BrushMappingMode.RelativeToBoundingBox;
                LBrush.SpreadMethod = GradientSpreadMethod.Pad;

                LBrush.StartPoint = new Point(XA, YA);
                LBrush.EndPoint   = new Point(XB, YB);

                GrdBrush = LBrush;
                break;
            }
        }
Beispiel #3
0
        public void SetDefaultMarkers(wGradient Pallet, wMarker.MarkerType MarkerType, bool IsRandom, bool BySeries)
        {
            int Total = Pallet.ColorSet.Count;

            if (IsRandom)
            {
                for (int i = 0; i < Sets.Count; i++)
                {
                    Random rnd = new Random();
                    for (int j = 0; j < Sets[i].Points.Count; j++)
                    {
                        int Index = rnd.Next(0, Total);
                        Sets[i].Points[j].Marker.Graphics.Background = Pallet.ColorSet[Index];
                        Sets[i].Points[j].Marker.Mode = MarkerType;
                    }
                }
            }
            else
            {
                int im = 0;
                int jm = 0;
                if (BySeries)
                {
                    im = 1;
                }
                else
                {
                    jm = 1;
                }

                for (int i = 0; i < Sets.Count; i++)
                {
                    for (int j = 0; j < Sets[i].Points.Count; j++)
                    {
                        Sets[i].Points[j].Marker.Graphics.Background = Pallet.ColorSet[((i * im) + (j * jm)) % Total];
                        Sets[i].Points[j].Marker.Mode = MarkerType;
                    }
                }
            }
        }
Beispiel #4
0
        public void SetDefaultStrokes(wStrokes.StrokeTypes StrokeType, wGradient Pallet, bool IsRandom, bool BySeries)
        {
            int Total = Pallet.ColorSet.Count;

            if (IsRandom)
            {
                for (int i = 0; i < Sets.Count; i++)
                {
                    Random rnd = new Random();
                    for (int j = 0; j < Sets[i].Points.Count; j++)
                    {
                        int Index = rnd.Next(0, Total);
                        Sets[i].Points[j].Graphics             = new wStrokes(Sets[i].Points[j].Graphics, StrokeType).GetGraphic();
                        Sets[i].Points[j].Graphics.StrokeColor = Pallet.ColorSet[Index];
                    }
                }
            }
            else
            {
                int im = 0;
                int jm = 0;
                if (BySeries)
                {
                    im = 1;
                }
                else
                {
                    jm = 1;
                }

                for (int i = 0; i < Sets.Count; i++)
                {
                    for (int j = 0; j < Sets[i].Points.Count; j++)
                    {
                        Sets[i].Points[j].Graphics             = new wStrokes(Sets[i].Points[j].Graphics, StrokeType).GetGraphic();
                        Sets[i].Points[j].Graphics.StrokeColor = Pallet.ColorSet[((i * im) + (j * jm)) % Total];
                    }
                }
            }
        }
        public hFillGradientRadial(int Index, wGradient WindGradient)
        {
            double CX = (WindGradient.Location.T0 * 100);
            double CY = (WindGradient.Location.T1 * 100);
            double FX = (WindGradient.Focus.T0 * 100);
            double FY = (WindGradient.Focus.T1 * 100);
            double R  = WindGradient.Radius * 100;

            GradientFillSpace = (GradientSpace)(int)WindGradient.FillMode;
            StringBuilder StyleAssembly = new StringBuilder();

            StyleAssembly.Append("<defs>" + Environment.NewLine);
            StyleAssembly.Append("<radialGradient id=\"grad" + Index + "\" cx=\"" + CX + "%\" cy=\"" + CY + "%\" fx=\"" + FX + "%\" fy=\"" + FY + "%\" r=\"" + R + "%\" gradientUnits=\"" + GradientFillSpace.ToString() + "\" >" + Environment.NewLine);
            for (int i = 0; i < WindGradient.ColorSet.Count; i++)
            {
                StyleAssembly.Append("<stop offset=\"" + (WindGradient.ParameterSet[i] * 100.00) + "%\" style=\"stop-color:rgb(" + WindGradient.ColorSet[i].R + "," + WindGradient.ColorSet[i].G + "," + WindGradient.ColorSet[i].B + ");stop-opacity:" + WindGradient.ColorSet[i].A / 255 + "\" />" + Environment.NewLine);
            }
            StyleAssembly.Append("</radialGradient>" + Environment.NewLine);
            StyleAssembly.Append("</defs>" + Environment.NewLine);

            Style = StyleAssembly.ToString();
            Value = "fill=\"url(#grad" + Index + ")\"" + Environment.NewLine;
        }
Beispiel #6
0
        public hFillGradientLinear(int Index, wGradient WindGradient)
        {
            double R  = WindGradient.Angle / 180 * Math.PI;
            double XA = Math.Round(50 + Math.Sin(R) * 50);
            double YA = Math.Round(50 + Math.Cos(R) * 50);
            double XB = Math.Round(50 + Math.Sin(R + Math.PI) * 50);
            double YB = Math.Round(50 + Math.Cos(R + Math.PI) * 50);

            GradientFillSpace = (GradientSpace)(int)WindGradient.FillMode;
            StringBuilder StyleAssembly = new StringBuilder();

            StyleAssembly.Append("<defs>" + Environment.NewLine);
            StyleAssembly.Append("<linearGradient id=\"grad" + Index + "\" x1=\"" + XA + "%\" y1=\"" + YA + "%\" x2=\"" + XB + "%\" y2=\"" + YB + "%\" gradientUnits=\"" + GradientFillSpace.ToString() + "\" >" + Environment.NewLine);
            for (int i = 0; i < WindGradient.ColorSet.Count; i++)
            {
                StyleAssembly.Append("<stop offset=\"" + (WindGradient.ParameterSet[i] * 100.00) + "%\" style=\"stop-color:rgb(" + WindGradient.ColorSet[i].R + "," + WindGradient.ColorSet[i].G + "," + WindGradient.ColorSet[i].B + ");stop-opacity:" + WindGradient.ColorSet[i].A / 255 + "\" />" + Environment.NewLine);
            }
            StyleAssembly.Append("</linearGradient>" + Environment.NewLine);
            StyleAssembly.Append("</defs>" + Environment.NewLine);

            Style = StyleAssembly.ToString();
            Value = "fill=\"url(#grad" + Index + ")\"" + Environment.NewLine;
        }
Beispiel #7
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);
        }