Exemple #1
0
        private int ComputeW_ico(IGH_Component owner)
        {
            GH_SwitcherComponent gH_SwitcherComponent = (GH_SwitcherComponent)owner;
            int num  = 24;
            int num2 = 0;
            int num3 = 0;

            foreach (IGH_Param componentInput in gH_SwitcherComponent.StaticData.GetComponentInputs())
            {
                int val = ((List <IGH_StateTag>)componentInput.StateTags).Count * 20;
                num3 = Math.Max(num3, val);
                num2 = Math.Max(num2, GH_FontServer.StringWidth(componentInput.NickName, StandardFont.font()));
            }
            num2  = Math.Max(num2 + 6, 12);
            num2 += num3;
            int num4 = 0;
            int num5 = 0;

            foreach (IGH_Param componentOutput in gH_SwitcherComponent.StaticData.GetComponentOutputs())
            {
                int val2 = ((List <IGH_StateTag>)componentOutput.StateTags).Count * 20;
                num5 = Math.Max(num5, val2);
                num4 = Math.Max(num4, GH_FontServer.StringWidth(componentOutput.NickName, StandardFont.font()));
            }
            num4  = Math.Max(num4 + 6, 12);
            num4 += num5;
            return(num2 + num + num4 + 6);
        }
Exemple #2
0
        protected void FixLayout(List <ExtendedPlug> outs)
        {
            GH_SwitcherComponent gH_SwitcherComponent = (GH_SwitcherComponent)base.Owner;
            float width = this.Bounds.Width;

            if (_minWidth > width)
            {
                this.Bounds = (new RectangleF(this.Bounds.X, this.Bounds.Y, _minWidth, this.Bounds.Height));
            }
            float num = this.Bounds.Width - width;

            foreach (IGH_Param componentOutput in gH_SwitcherComponent.StaticData.GetComponentOutputs())
            {
                PointF     pivot  = componentOutput.Attributes.Pivot;
                RectangleF bounds = componentOutput.Attributes.Bounds;
                componentOutput.Attributes.Pivot  = (new PointF(pivot.X + num, pivot.Y));
                componentOutput.Attributes.Bounds = (new RectangleF(bounds.Location.X + num, bounds.Location.Y, bounds.Width, bounds.Height));
            }
            foreach (IGH_Param componentInput in gH_SwitcherComponent.StaticData.GetComponentInputs())
            {
                PointF     pivot2  = componentInput.Attributes.Pivot;
                RectangleF bounds2 = componentInput.Attributes.Bounds;
                componentInput.Attributes.Pivot  = (new PointF(pivot2.X + num, pivot2.Y));
                componentInput.Attributes.Bounds = (new RectangleF(bounds2.Location.X + num, bounds2.Location.Y, bounds2.Width, bounds2.Height));
            }
        }
Exemple #3
0
        public void InitializeUnitParameters()
        {
            GH_SwitcherComponent gH_SwitcherComponent = (GH_SwitcherComponent)base.Owner;

            if (gH_SwitcherComponent.EvalUnits != null)
            {
                foreach (EvaluationUnit evalUnit in gH_SwitcherComponent.EvalUnits)
                {
                    foreach (ExtendedPlug input in evalUnit.Inputs)
                    {
                        if (input.Parameter.Attributes == null)
                        {
                            input.Parameter.Attributes = (new GH_LinkedParamAttributes(input.Parameter, this));
                        }
                    }
                    foreach (ExtendedPlug output in evalUnit.Outputs)
                    {
                        if (output.Parameter.Attributes == null)
                        {
                            output.Parameter.Attributes = (new GH_LinkedParamAttributes(output.Parameter, this));
                        }
                    }
                }
            }
        }
Exemple #4
0
 public GH_SwitcherComponentAttributes(GH_SwitcherComponent component)
     : base(component)
 {
     collection         = new GH_MenuCollection();
     composedCollection = new GH_MenuCollection();
     composedCollection.Merge(collection);
     CreateUnitDropDown();
     InitializeUnitParameters();
 }
Exemple #5
0
 public GH_SwitchAction(GH_SwitcherComponent component, string newUnit)
     : base()
 {
     if (component == null)
     {
         throw new ArgumentNullException("component");
     }
     oldState     = GH_SwitcherConnectivity.Create(component);
     this.newUnit = newUnit;
 }
Exemple #6
0
        protected override void Internal_Undo(GH_Document doc)
        {
            IGH_DocumentObject val = doc.FindObject(oldState.ComponentId, true);

            if (val == null || !(val is GH_SwitcherComponent))
            {
                throw new GH_UndoException("Switcher component with id[" + oldState.ComponentId + "] not found");
            }
            GH_SwitcherComponent component = (GH_SwitcherComponent)val;

            oldState.Apply(component, doc);
        }
Exemple #7
0
        public RectangleF LayoutComponentBox2(IGH_Component owner)
        {
            GH_SwitcherComponent gH_SwitcherComponent = (GH_SwitcherComponent)owner;
            int val = Math.Max(gH_SwitcherComponent.StaticData.GetComponentInputSection().Count, gH_SwitcherComponent.StaticData.GetComponentOutputSection().Count) * 20;

            val = Math.Max(val, 24);
            int num = 24;

            if (!GH_Attributes <IGH_Component> .IsIconMode(owner.IconDisplayMode))
            {
                val = Math.Max(val, GH_Convert.ToSize((SizeF)GH_FontServer.MeasureString(owner.NickName, StandardFont.largeFont())).Width + 6);
            }
            return(GH_Convert.ToRectangle(new RectangleF(owner.Attributes.Pivot.X - 0.5f * (float)num, owner.Attributes.Pivot.Y - 0.5f * (float)val, num, val)));
        }
Exemple #8
0
        protected override void Layout()
        {
            this.Pivot = ((PointF)GH_Convert.ToPoint(this.Pivot));
            LayoutBaseComponent();
            GH_SwitcherComponent gH_SwitcherComponent = (GH_SwitcherComponent)base.Owner;
            List <ExtendedPlug>  inputs  = new List <ExtendedPlug>();
            List <ExtendedPlug>  outputs = new List <ExtendedPlug>();

            composedCollection.GetMenuPlugs(ref inputs, ref outputs, onlyVisible: true);
            LayoutMenuInputs(base.m_innerBounds);
            LayoutMenuOutputs(base.m_innerBounds);
            this.Bounds = (LayoutExtBounds(base.m_innerBounds, inputs, outputs));
            FixLayout(outputs);
            LayoutMenu();
        }
Exemple #9
0
        public RectangleF LayoutBounds2(IGH_Component owner, RectangleF bounds)
        {
            GH_SwitcherComponent gH_SwitcherComponent = (GH_SwitcherComponent)owner;

            foreach (IGH_Param item in gH_SwitcherComponent.StaticData.GetComponentInputSection())
            {
                bounds = RectangleF.Union(bounds, item.Attributes.Bounds);
            }
            foreach (IGH_Param item2 in gH_SwitcherComponent.StaticData.GetComponentOutputSection())
            {
                bounds = RectangleF.Union(bounds, item2.Attributes.Bounds);
            }
            bounds.Inflate(2f, 2f);
            return(bounds);
        }
Exemple #10
0
 public void Apply(GH_SwitcherComponent component, GH_Document document)
 {
     if (noUnit)
     {
         component.ClearUnit(recompute: true, recordEvent: false);
     }
     else
     {
         component.SwitchUnit(unit, recompute: true, recordEvent: false);
     }
     for (int i = 0; i < inputs.Count; i++)
     {
         GH_SwitcherParamState gH_SwitcherParamState = inputs[i];
         int num = component.Params.IndexOfInputParam(gH_SwitcherParamState.ParameterId);
         if (num == -1)
         {
             continue;
         }
         IGH_Param val = component.Params.Input[num];
         for (int j = 0; j < gH_SwitcherParamState.Targets.Count; j++)
         {
             IGH_Param val2 = document.FindParameter(gH_SwitcherParamState.Targets[j]);
             if (val2 != null)
             {
                 val.AddSource(val2);
             }
         }
     }
     for (int k = 0; k < outputs.Count; k++)
     {
         GH_SwitcherParamState gH_SwitcherParamState2 = outputs[k];
         int num2 = component.Params.IndexOfOutputParam(gH_SwitcherParamState2.ParameterId);
         if (num2 == -1)
         {
             continue;
         }
         IGH_Param val3 = component.Params.Output[num2];
         for (int l = 0; l < gH_SwitcherParamState2.Targets.Count; l++)
         {
             IGH_Param val4 = document.FindParameter(gH_SwitcherParamState2.Targets[l]);
             if (val4 != null)
             {
                 val4.AddSource(val3);
             }
         }
     }
 }
Exemple #11
0
        protected void LayoutBaseComponent()
        {
            GH_SwitcherComponent gH_SwitcherComponent = (GH_SwitcherComponent)base.Owner;

            this.Pivot         = ((PointF)GH_Convert.ToPoint(this.Pivot));
            base.m_innerBounds = LayoutComponentBox2(base.Owner);
            int   num        = ComputeW_ico(base.Owner);
            float width      = composedCollection.GetMinLayoutSize().Width;
            float num2       = Math.Max(MinWidth, width);
            int   add_offset = 0;

            if (num2 > (float)num)
            {
                add_offset = (int)((double)(num2 - (float)num) / 2.0);
            }
            LayoutInputParams2(base.Owner, base.m_innerBounds, add_offset);
            LayoutOutputParams2(base.Owner, base.m_innerBounds, add_offset);
            this.Bounds = (LayoutBounds2(base.Owner, base.m_innerBounds));
        }
Exemple #12
0
        protected override void Internal_Redo(GH_Document doc)
        {
            IGH_DocumentObject val = doc.FindObject(oldState.ComponentId, true);

            if (val == null || !(val is GH_SwitcherComponent))
            {
                throw new GH_UndoException("Switcher component with id[" + oldState.ComponentId + "] not found");
            }
            GH_SwitcherComponent gH_SwitcherComponent = (GH_SwitcherComponent)val;

            if (newUnit != null)
            {
                gH_SwitcherComponent.SwitchUnit(newUnit, recompute: true, recordEvent: false);
            }
            else
            {
                gH_SwitcherComponent.ClearUnit(recompute: false);
            }
        }
Exemple #13
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();
            }
        }
 public RuntimeComponentData(GH_SwitcherComponent component)
 {
     this.component    = component;
     cachedName        = component.Name;
     cachedNickname    = component.NickName;
     cachedDescription = component.Description;
     cachedIcon        = component.Icon_24x24;
     dynInputs         = new List <IGH_Param>();
     dynOutputs        = new List <IGH_Param>();
     stcInputs         = new List <IGH_Param>();
     stcOutputs        = new List <IGH_Param>();
     foreach (IGH_Param item in component.Params.Input)
     {
         stcInputs.Add(item);
     }
     foreach (IGH_Param item2 in component.Params.Output)
     {
         stcOutputs.Add(item2);
     }
 }
Exemple #15
0
        private void ComposeMenu()
        {
            GH_SwitcherComponent gH_SwitcherComponent = (GH_SwitcherComponent)base.Owner;

            composedCollection = new GH_MenuCollection();
            EvaluationUnit activeUnit = gH_SwitcherComponent.ActiveUnit;

            if (activeUnit != null && activeUnit.Context.Collection != null)
            {
                composedCollection.Merge(gH_SwitcherComponent.ActiveUnit.Context.Collection);
            }
            if (collection != null)
            {
                composedCollection.Merge(collection);
            }
            if (unitMenuCollection != null)
            {
                composedCollection.Merge(unitMenuCollection);
            }
        }
Exemple #16
0
        protected void CreateUnitDropDown()
        {
            GH_SwitcherComponent gH_SwitcherComponent = (GH_SwitcherComponent)base.Owner;

            if (gH_SwitcherComponent.EvalUnits != null && gH_SwitcherComponent.EvalUnits.Count != 0 && (gH_SwitcherComponent.EvalUnits.Count != 1 || gH_SwitcherComponent.UnitlessExistence))
            {
                MenuPanel menuPanel = new MenuPanel(0, "panel_units");
                menuPanel.Header = "Unit selection";
                string text = gH_SwitcherComponent.UnitMenuName;
                if (text == null)
                {
                    text = "Evaluation Units";
                }
                string text2 = gH_SwitcherComponent.UnitMenuHeader;
                if (text2 == null)
                {
                    text2 = "Select evaluation unit";
                }
                unitMenuCollection = new GH_MenuCollection();
                GH_ExtendableMenu gH_ExtendableMenu = new GH_ExtendableMenu(0, "menu_units");
                gH_ExtendableMenu.Name   = text;
                gH_ExtendableMenu.Header = text2;
                gH_ExtendableMenu.AddControl(menuPanel);
                _UnitDrop = new MenuDropDown(0, "dropdown_units", "units");
                _UnitDrop.VisibleItemCount = 10;
                _UnitDrop.ValueChanged    += _UnitDrop__valueChanged;
                _UnitDrop.Header           = "Evaluation unit selector";
                menuPanel.AddControl(_UnitDrop);
                List <EvaluationUnit> evalUnits = gH_SwitcherComponent.EvalUnits;
                if (gH_SwitcherComponent.UnitlessExistence)
                {
                    _UnitDrop.AddItem("--NONE--", null);
                }
                for (int i = 0; i < evalUnits.Count; i++)
                {
                    _UnitDrop.AddItem(evalUnits[i].Name, evalUnits[i].DisplayName, evalUnits[i]);
                }
                gH_ExtendableMenu.Expand();
                unitMenuCollection.AddMenu(gH_ExtendableMenu);
            }
        }
Exemple #17
0
        public RectangleF LayoutExtBounds(RectangleF bounds, List <ExtendedPlug> ins, List <ExtendedPlug> outs)
        {
            GH_SwitcherComponent gH_SwitcherComponent = (GH_SwitcherComponent)base.Owner;

            foreach (IGH_Param componentInput in gH_SwitcherComponent.StaticData.GetComponentInputs())
            {
                RectangleF bounds2 = componentInput.Attributes.Bounds;
                if (bounds2.X < bounds.X)
                {
                    float num = bounds.X - bounds2.X;
                    bounds.X      = bounds2.X;
                    bounds.Width += num;
                }
                if (bounds2.X + bounds2.Width > bounds.X + bounds.Width)
                {
                    float num2 = bounds2.X + bounds2.Width - (bounds.X + bounds.Width);
                    bounds.Width += num2;
                }
            }
            foreach (IGH_Param componentOutput in gH_SwitcherComponent.StaticData.GetComponentOutputs())
            {
                RectangleF bounds3 = componentOutput.Attributes.Bounds;
                if (bounds3.X < bounds.X)
                {
                    float num3 = bounds.X - bounds3.X;
                    bounds.X      = bounds3.X;
                    bounds.Width += num3;
                }
                if (bounds3.X + bounds3.Width > bounds.X + bounds.Width)
                {
                    float num4 = bounds3.X + bounds3.Width - (bounds.X + bounds.Width);
                    bounds.Width += num4;
                }
            }
            bounds.Inflate(2f, 2f);
            return(bounds);
        }
Exemple #18
0
            public static GH_SwitcherConnectivity Create(GH_SwitcherComponent component)
            {
                GH_SwitcherConnectivity gH_SwitcherConnectivity = new GH_SwitcherConnectivity();

                gH_SwitcherConnectivity.componentId = component.InstanceGuid;
                EvaluationUnit activeUnit = component.ActiveUnit;

                if (activeUnit != null)
                {
                    gH_SwitcherConnectivity.noUnit = false;
                    gH_SwitcherConnectivity.unit   = activeUnit.Name;
                }
                else if (component.UnitlessExistence)
                {
                    gH_SwitcherConnectivity.noUnit = true;
                }
                foreach (IGH_Param item in component.Params.Input)
                {
                    GH_SwitcherParamState gH_SwitcherParamState = new GH_SwitcherParamState(0, item.InstanceGuid);
                    gH_SwitcherConnectivity.inputs.Add(gH_SwitcherParamState);
                    foreach (IGH_Param source in item.Sources)
                    {
                        gH_SwitcherParamState.Targets.Add(source.InstanceGuid);
                    }
                }
                foreach (IGH_Param item2 in component.Params.Output)
                {
                    GH_SwitcherParamState gH_SwitcherParamState2 = new GH_SwitcherParamState(GH_ParameterSide.Output, item2.InstanceGuid);
                    gH_SwitcherConnectivity.outputs.Add(gH_SwitcherParamState2);
                    foreach (IGH_Param recipient in item2.Recipients)
                    {
                        gH_SwitcherParamState2.Targets.Add(recipient.InstanceGuid);
                    }
                }
                return(gH_SwitcherConnectivity);
            }
Exemple #19
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);
                }
            }
        }
Exemple #20
0
        protected void RenderComponentCapsule2(GH_Canvas canvas, Graphics graphics, bool drawComponentBaseBox, bool drawComponentNameBox, bool drawJaggedEdges, bool drawParameterGrips, bool drawParameterNames, bool drawZuiElements)
        {
            GH_SwitcherComponent gH_SwitcherComponent = (GH_SwitcherComponent)base.Owner;
            RectangleF           bounds = this.Bounds;

            this.Bounds = (bounds);
            if (!canvas.Viewport.IsVisible(ref bounds, 10f))
            {
                return;
            }
            GH_Palette val = GH_CapsuleRenderEngine.GetImpliedPalette(base.Owner);

            if ((int)val == 0 && !base.Owner.IsPreviewCapable)
            {
                val = GH_Palette.Hidden;
            }
            GH_Capsule val2 = GH_Capsule.CreateCapsule(this.Bounds, val);
            bool       flag = base.Owner.Params.Input
                              .Count == 0;
            bool flag2 = base.Owner.Params.Output
                         .Count == 0;

            val2.SetJaggedEdges(flag, flag2);
            GH_PaletteStyle impliedStyle = GH_CapsuleRenderEngine.GetImpliedStyle(val, this.Selected, base.Owner.Locked, base.Owner.Hidden);

            if (drawParameterGrips)
            {
                foreach (IGH_Param staticInput in gH_SwitcherComponent.StaticData.StaticInputs)
                {
                    val2.AddInputGrip(staticInput.Attributes.InputGrip.Y);
                }
                foreach (IGH_Param dynamicInput in gH_SwitcherComponent.StaticData.DynamicInputs)
                {
                    val2.AddInputGrip(dynamicInput.Attributes.InputGrip.Y);
                }
                foreach (IGH_Param staticOutput in gH_SwitcherComponent.StaticData.StaticOutputs)
                {
                    val2.AddOutputGrip(staticOutput.Attributes.OutputGrip.Y);
                }
                foreach (IGH_Param dynamicOutput in gH_SwitcherComponent.StaticData.DynamicOutputs)
                {
                    val2.AddOutputGrip(dynamicOutput.Attributes.OutputGrip.Y);
                }
            }
            graphics.SmoothingMode = SmoothingMode.HighQuality;
            canvas.SetSmartTextRenderingHint();
            if (GH_Attributes <IGH_Component> .IsIconMode(base.Owner.IconDisplayMode))
            {
                if (drawComponentBaseBox)
                {
                    if (base.Owner.Message != null)
                    {
                        val2.RenderEngine.RenderMessage(graphics, base.Owner.Message, impliedStyle);
                    }
                    val2.Render(graphics, impliedStyle);
                }
                if (drawComponentNameBox && base.Owner.Icon_24x24 != null)
                {
                    if (base.Owner.Locked)
                    {
                        val2.RenderEngine.RenderIcon(graphics, (Image)base.Owner.Icon_24x24_Locked, base.m_innerBounds, 0, 0);
                    }
                    else
                    {
                        val2.RenderEngine.RenderIcon(graphics, (Image)base.Owner.Icon_24x24, base.m_innerBounds, 0, 0);
                    }
                }
            }
            else
            {
                if (drawComponentBaseBox)
                {
                    if (base.Owner.Message != null)
                    {
                        val2.RenderEngine.RenderMessage(graphics, base.Owner.Message, impliedStyle);
                    }
                    val2.Render(graphics, impliedStyle);
                }
                if (drawComponentNameBox)
                {
                    GH_Capsule obj = GH_Capsule.CreateTextCapsule(base.m_innerBounds, base.m_innerBounds, GH_Palette.Black, base.Owner.NickName, StandardFont.largeFont(), GH_Orientation.vertical_center, 3, 6);
                    obj.Render(graphics, this.Selected, base.Owner.Locked, false);
                    obj.Dispose();
                }
            }
            if (drawComponentNameBox && base.Owner.Obsolete && Grasshopper.CentralSettings.CanvasObsoleteTags && (int)canvas.DrawingMode == 0)
            {
                GH_GraphicsUtil.RenderObjectOverlay(graphics, Owner, base.m_innerBounds);
            }
            if (drawParameterNames)
            {
                RenderComponentParameters2(canvas, graphics, base.Owner, impliedStyle);
            }
            if (drawZuiElements)
            {
                this.RenderVariableParameterUI(canvas, graphics);
            }
            val2.Dispose();
        }
Exemple #21
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;
            }
        }
 public EvaluationUnitManager(GH_SwitcherComponent component)
 {
     units          = new List <EvaluationUnit>();
     this.component = component;
 }