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(); }
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))); }