Exemplo n.º 1
0
        public static void RenderComponentParameters2(GH_Canvas canvas, Graphics graphics, IGH_Component owner, GH_PaletteStyle style)
        {
            GH_SwitcherComponent gH_SwitcherComponent = (GH_SwitcherComponent)owner;
            int zoomFadeLow = GH_Canvas.ZoomFadeLow;

            if (zoomFadeLow >= 5)
            {
                StringFormat farCenter = GH_TextRenderingConstants.FarCenter;
                canvas.SetSmartTextRenderingHint();
                SolidBrush solidBrush = new SolidBrush(Color.FromArgb(zoomFadeLow, style.Text));
                foreach (IGH_Param staticInput in gH_SwitcherComponent.StaticData.StaticInputs)
                {
                    RectangleF bounds = staticInput.Attributes.Bounds;
                    if (bounds.Width >= 1f)
                    {
                        graphics.DrawString(staticInput.NickName, StandardFont.font(), solidBrush, bounds, farCenter);
                        GH_LinkedParamAttributes obj = (GH_LinkedParamAttributes)staticInput.Attributes;
                        GH_StateTagList          val = (GH_StateTagList)typeof(GH_LinkedParamAttributes).GetField("m_renderTags", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(obj);
                        if (val != null)
                        {
                            val.RenderStateTags(graphics);
                        }
                    }
                }
                farCenter = GH_TextRenderingConstants.NearCenter;
                foreach (IGH_Param staticOutput in gH_SwitcherComponent.StaticData.StaticOutputs)
                {
                    RectangleF bounds2 = staticOutput.Attributes.Bounds;
                    if (bounds2.Width >= 1f)
                    {
                        graphics.DrawString(staticOutput.NickName, StandardFont.font(), solidBrush, bounds2, farCenter);
                        GH_LinkedParamAttributes obj2 = (GH_LinkedParamAttributes)staticOutput.Attributes;
                        GH_StateTagList          val2 = (GH_StateTagList)typeof(GH_LinkedParamAttributes).GetField("m_renderTags", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(obj2);
                        if (val2 != null)
                        {
                            val2.RenderStateTags(graphics);
                        }
                    }
                }
                solidBrush.Dispose();
            }
        }
Exemplo n.º 2
0
        public static void ChangeRenderTags(GH_LinkedParamAttributes gH_LinkedParamAttributes, PointF rectMove)
        {
            if (gH_LinkedParamAttributes == null)
            {
                return;
            }
            FieldInfo field = typeof(GH_LinkedParamAttributes).GetRuntimeFields().Where(m => m.Name.Contains("m_renderTags")).First();

            if (field == null)
            {
                System.Windows.Forms.MessageBox.Show("Can't find the Tags!");
                return;
            }
            GH_StateTagList tagList = field.GetValue(gH_LinkedParamAttributes) as GH_StateTagList;

            if (tagList == null)
            {
                return;
            }
            foreach (var tag in tagList)
            {
                tag.Stage = new Rectangle(new System.Drawing.Point(tag.Stage.X + (int)rectMove.X, tag.Stage.Y + (int)rectMove.Y), tag.Stage.Size);
            }
        }
Exemplo n.º 3
0
 public void RenderMenuParameters(GH_Canvas canvas, Graphics graphics)
 {
     if (Math.Max(inputs.Count, outputs.Count) != 0)
     {
         int zoomFadeLow = GH_Canvas.ZoomFadeLow;
         if (zoomFadeLow >= 5)
         {
             StringFormat farCenter = GH_TextRenderingConstants.FarCenter;
             canvas.SetSmartTextRenderingHint();
             SolidBrush solidBrush = new SolidBrush(Color.FromArgb(zoomFadeLow, style.Text));
             List <ExtendedPlug> .Enumerator enumerator = inputs.GetEnumerator();
             try
             {
                 while (enumerator.MoveNext())
                 {
                     IGH_Param  parameter = enumerator.Current.Parameter;
                     RectangleF bounds    = parameter.Attributes.Bounds;
                     if (bounds.Width >= 1f)
                     {
                         graphics.DrawString(parameter.NickName, StandardFont.font(), solidBrush, bounds, farCenter);
                         GH_LinkedParamAttributes obj = (GH_LinkedParamAttributes)parameter.Attributes;
                         FieldInfo field = typeof(GH_LinkedParamAttributes).GetField("m_renderTags", BindingFlags.Instance | BindingFlags.NonPublic);
                         if (field != (FieldInfo)null)
                         {
                             GH_StateTagList value = (GH_StateTagList)field.GetValue(obj);
                             if (value != null)
                             {
                                 value.RenderStateTags(graphics);
                             }
                         }
                     }
                 }
             }
             finally
             {
                 ((IDisposable)enumerator).Dispose();
             }
             farCenter  = GH_TextRenderingConstants.NearCenter;
             enumerator = outputs.GetEnumerator();
             try
             {
                 while (enumerator.MoveNext())
                 {
                     IGH_Param  parameter2 = enumerator.Current.Parameter;
                     RectangleF bounds2    = parameter2.Attributes.Bounds;
                     if (bounds2.Width >= 1f)
                     {
                         graphics.DrawString(parameter2.NickName, StandardFont.font(), solidBrush, bounds2, farCenter);
                         GH_LinkedParamAttributes obj2 = (GH_LinkedParamAttributes)parameter2.Attributes;
                         FieldInfo field2 = typeof(GH_LinkedParamAttributes).GetField("m_renderTags", BindingFlags.Instance | BindingFlags.NonPublic);
                         if (field2 != (FieldInfo)null)
                         {
                             GH_StateTagList value2 = (GH_StateTagList)field2.GetValue(obj2);
                             if (value2 != null)
                             {
                                 value2.RenderStateTags(graphics);
                             }
                         }
                     }
                 }
             }
             finally
             {
                 ((IDisposable)enumerator).Dispose();
             }
             solidBrush.Dispose();
         }
     }
 }
Exemplo n.º 4
0
        public void LayoutMenuOutputs(RectangleF componentBox)
        {
            GH_SwitcherComponent obj = (GH_SwitcherComponent)base.Owner;
            float num  = 0f;
            int   num2 = 0;

            foreach (IGH_Param componentOutput in obj.StaticData.GetComponentOutputs())
            {
                int val = 20 * ((List <IGH_StateTag>)componentOutput.StateTags).Count;
                num2 = Math.Max(num2, val);
                num  = Math.Max(num, GH_FontServer.StringWidth(componentOutput.NickName, StandardFont.font()));
            }
            num  = Math.Max(num + 6f, 12f);
            num += (float)num2;
            float num3 = this.Bounds.Height;

            for (int i = 0; i < composedCollection.Menus.Count; i++)
            {
                float num4     = -1f;
                float num5     = 0f;
                bool  expanded = composedCollection.Menus[i].Expanded;
                if (expanded)
                {
                    num4 = num3 + composedCollection.Menus[i].Height;
                    num5 = Math.Max(composedCollection.Menus[i].Inputs.Count, composedCollection.Menus[i].Outputs.Count) * 20;
                }
                else
                {
                    num4 = num3 + 5f;
                    num5 = 0f;
                }
                List <ExtendedPlug> outputs = composedCollection.Menus[i].Outputs;
                int count = outputs.Count;
                if (count != 0)
                {
                    float num6 = num5 / (float)count;
                    for (int j = 0; j < count; j++)
                    {
                        IGH_Param parameter = outputs[j].Parameter;
                        if (parameter.Attributes == null)
                        {
                            parameter.Attributes = (new GH_LinkedParamAttributes(parameter, this));
                        }
                        float  num7   = componentBox.Right + 3f;
                        float  num8   = num4 + componentBox.Y + (float)j * num6;
                        float  width  = num;
                        float  height = num6;
                        PointF pivot  = new PointF(num7 + 0.5f * num, num8 + 0.5f * num6);
                        parameter.Attributes.Pivot = (pivot);
                        RectangleF rectangleF = new RectangleF(num7, num8, width, height);
                        parameter.Attributes.Bounds = ((RectangleF)GH_Convert.ToRectangle(rectangleF));
                    }
                    for (int k = 0; k < count; k++)
                    {
                        IGH_Param parameter2          = outputs[k].Parameter;
                        GH_LinkedParamAttributes val2 = (GH_LinkedParamAttributes)parameter2.Attributes;
                        FieldInfo       field         = typeof(GH_LinkedParamAttributes).GetField("m_renderTags", BindingFlags.Instance | BindingFlags.NonPublic);
                        GH_StateTagList val3          = parameter2.StateTags;
                        if (field != null)
                        {
                            if (((List <IGH_StateTag>)val3).Count == 0)
                            {
                                val3 = null;
                                field.SetValue(val2, val3);
                            }
                            if (val3 != null)
                            {
                                Rectangle rectangle = GH_Convert.ToRectangle(val2.Bounds);
                                rectangle.Width -= num2;
                                val3.Layout(rectangle, GH_StateTagLayoutDirection.Right);
                                rectangle = val3.BoundingBox;
                                if (!rectangle.IsEmpty)
                                {
                                    val2.Bounds = (RectangleF.Union(val2.Bounds, rectangle));
                                }
                                field.SetValue(val2, val3);
                            }
                        }
                        if (!expanded)
                        {
                            val2.Bounds = (new RectangleF(val2.Bounds.X + val2.Bounds.Width - 5f, val2.Bounds.Y, 5f, val2.Bounds.Height));
                        }
                    }
                }
                num3 += composedCollection.Menus[i].TotalHeight;
            }
        }
Exemplo n.º 5
0
        public void LayoutOutputParams2(IGH_Component owner, RectangleF componentBox, int add_offset)
        {
            GH_SwitcherComponent gH_SwitcherComponent   = (GH_SwitcherComponent)owner;
            List <IGH_Param>     componentOutputSection = gH_SwitcherComponent.StaticData.GetComponentOutputSection();
            int count = componentOutputSection.Count;

            if (count == 0)
            {
                return;
            }
            int num  = 0;
            int num2 = 0;

            foreach (IGH_Param componentOutput in gH_SwitcherComponent.StaticData.GetComponentOutputs())
            {
                int val = ((List <IGH_StateTag>)componentOutput.StateTags).Count * 20;
                num2 = Math.Max(num2, val);
                num  = Math.Max(num, GH_FontServer.StringWidth(componentOutput.NickName, StandardFont.font()));
            }
            num  = Math.Max(num + 6, 12);
            num += num2 + add_offset;
            float num3 = componentBox.Height / (float)count;

            for (int i = 0; i < count; i++)
            {
                IGH_Param val2 = componentOutputSection[i];
                if (val2.Attributes == null)
                {
                    val2.Attributes = (new GH_LinkedParamAttributes(val2, owner.Attributes));
                }
                float  num4   = componentBox.Right + 3f;
                float  num5   = componentBox.Y + (float)i * num3;
                float  width  = num;
                float  height = num3;
                PointF pivot  = new PointF(num4 + 0.5f * (float)num, num5 + 0.5f * num3);
                val2.Attributes.Pivot = (pivot);
                RectangleF rectangleF = new RectangleF(num4, num5, width, height);
                val2.Attributes.Bounds = ((RectangleF)GH_Convert.ToRectangle(rectangleF));
            }
            bool flag = false;

            for (int j = 0; j < count; j++)
            {
                IGH_Param val3 = componentOutputSection[j];
                GH_LinkedParamAttributes val4 = (GH_LinkedParamAttributes)val3.Attributes;
                FieldInfo       field         = typeof(GH_LinkedParamAttributes).GetField("m_renderTags", BindingFlags.Instance | BindingFlags.NonPublic);
                GH_StateTagList val5          = val3.StateTags;
                if (!(field != null))
                {
                    continue;
                }
                if (((List <IGH_StateTag>)val5).Count == 0)
                {
                    val5 = null;
                    field.SetValue(val4, val5);
                }
                if (val5 != null)
                {
                    flag = true;
                    Rectangle rectangle = GH_Convert.ToRectangle(val4.Bounds);
                    rectangle.Width -= num2;
                    val5.Layout(rectangle, GH_StateTagLayoutDirection.Right);
                    rectangle = val5.BoundingBox;
                    if (!rectangle.IsEmpty)
                    {
                        val4.Bounds = (RectangleF.Union(val4.Bounds, rectangle));
                    }
                    field.SetValue(val4, val5);
                }
            }
            if (flag)
            {
                float num6 = float.MinValue;
                for (int k = 0; k < count; k++)
                {
                    IGH_Attributes attributes = componentOutputSection[k].Attributes;
                    num6 = Math.Max(num6, attributes.Bounds.Right);
                }
                for (int l = 0; l < count; l++)
                {
                    IGH_Attributes attributes2 = componentOutputSection[l].Attributes;
                    RectangleF     bounds      = attributes2.Bounds;
                    bounds.Width       = num6 - bounds.X;
                    attributes2.Bounds = (bounds);
                }
            }
        }