Hi
I use this custom attributes but i can’t plug anything to the output grip
public class ButtonNewComponent : GH_Component
{
.............................
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
}
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddBooleanParameter("Bool", "", "Bool", GH_ParamAccess.item);
}
protected override void SolveInstance(IGH_DataAccess DA)
{
DA.SetData(0, Value);
}
...........................
public override void CreateAttributes()
{
m_attributes = new ButtonNewAttributes(this);
}
}
public class ButtonNewAttributes : GH_Attributes<ButtonNewComponent>
{
public ButtonNewAttributes(ButtonNewComponent owner)
: base(owner)
{
}
//public override bool HasInputGrip { get { return false; } }
public override bool HasOutputGrip { get { return true; } }
private const int ButtonSize = 34;
public Font font;
protected override void Layout()
{
Pivot = GH_Convert.ToPoint(Pivot);
Bounds = new RectangleF(Pivot, new SizeF((float)(ButtonSize * 2.5), ButtonSize));
GH_ComponentAttributes.LayoutOutputParams(Owner, Bounds);
}
private RectangleF TextBound()
{
int x = Convert.ToInt32(Pivot.X);
int y = Convert.ToInt32(Pivot.Y);
return new RectangleF(new PointF(x + 27, y), new SizeF(55, ButtonSize));
}
private Rectangle Button()
{
int x = Convert.ToInt32(Pivot.X);
int y = Convert.ToInt32(Pivot.Y);
return new Rectangle(x + 4, y + 4, ButtonSize - 8, ButtonSize - 8);
}
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
{
if (channel == GH_CanvasChannel.Objects)
{
//Render output grip.
//GH_CapsuleRenderEngine.RenderOutputGrip(graphics, canvas.Viewport.Zoom, OutputGrip, true);
Rectangle button = Button();
RectangleF bound = Bounds;
RectangleF text = TextBound();
font = new Font("Verdana", 9);
Color color;
if (Owner.Value == true)
{
color = Color.YellowGreen;
}
else
{
color = Color.LightGray;
}
// button bounds
GH_Capsule capsule = GH_Capsule.CreateTextCapsule(bound, text, GH_Palette.Transparent, Owner.Value.ToString().ToUpper(), font, 17, 1);
capsule.AddOutputGrip(Owner.Params.Output[0].Attributes.Pivot.Y);
capsule.HighlightShape.Reset();
capsule.HighlightShape.AddPath(capsule.OutlineShape, true);
capsule.Render(graphics, Color.DarkGray);
capsule.Dispose();
// toggle bounds
GH_Capsule buttonb = GH_Capsule.CreateCapsule(button, GH_Palette.Transparent, 16, 1);
buttonb.HighlightShape.Reset();
buttonb.HighlightShape.AddPie(button, 180f, 180f);
buttonb.Render(graphics, color);
buttonb.Dispose();
}
}
}