Beispiel #1
0
        private GooTypeProxy FindOrCreateInfo(IGH_Param param)
        {
            Type findType = param.Type;

            if (param.VolatileData.AllData(true).Count() > 0)
            {
                switch (Owner.Accuracy)
                {
                case 0:
                    findType = param.Type;
                    break;

                case 1:
                    findType = param.VolatileData.AllData(true).ElementAt(0).GetType();
                    break;

                case 2:
                    var  relayList = param.VolatileData.AllData(true).GroupBy((x) => { return(x.GetType()); });
                    int  count     = 0;
                    Type relayName = null;
                    foreach (var item in relayList)
                    {
                        if (item.Count() >= count)
                        {
                            relayName = item.Key;
                            count     = item.Count();
                        }
                    }
                    findType = relayName ?? param.VolatileData.AllData(true).ElementAt(0).GetType();
                    break;

                case 3:
                    List <Type> types = param.VolatileData.AllData(true).Select((x) => x.GetType()).ToList();
                    findType = MinFatherType(types);
                    break;

                default:
                    findType = param.VolatileData.AllData(true).ElementAt(0).GetType();
                    break;
                }
            }

            foreach (var info in Owner.AllParamProxy)
            {
                if (info.DataType == findType)
                {
                    if (!Owner.ShowProxy.Contains(info))
                    {
                        Owner.ShowProxy.Add(info);
                    }
                    return(info);
                }
            }
            GooTypeProxy newInfo = new GooTypeProxy(findType, Owner);

            Owner.AllParamProxy.Add(newInfo);
            Owner.ShowProxy.Add(newInfo);
            return(newInfo);
        }
        private void DrawOneLegend(Graphics graphics, PointF pivot, GooTypeProxy info, float size, float mult)
        {
            float height  = size * mult;
            float padding = size * (1 - mult) / 2;

            RectangleF fillRect = new RectangleF(pivot.X, pivot.Y - size, size, size);

            fillRect.Inflate(-padding, -padding);
            graphics.FillPath(new SolidBrush(info.ShowColor), CanvasRenderEngine.GetRoundRectangle_Obsolete(fillRect, padding));

            graphics.DrawString(info.TypeName, new Font(GH_FontServer.Standard.FontFamily, height / 2), new SolidBrush(Owner.LegendTextColor), new PointF(pivot.X + size + padding, pivot.Y - height - padding));
        }