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