Go Shapes

I am using serveal basic Go Shapes.

GoOctagon, GoTriangle, GoDiamond, GoRoundedRectangle.
Is there a simple way to set their dimensions. I can't seem to change the size easily. it always seems to depend on the label or TopLeftMargin and BottomRightMargin.
I just want to set the dimentions height and width. I want an Octagon to look like a stop sign.
See image of shapes I am working with.
Thanks for your help,

Did you start with GraphNode in FlowCharter?

All my Blocks have one common ancestor that inherits from GoTextNode.

I’m not sure what you are asking? Do you mean which demo did I start from? If that is the question None really.

I emailed you the LayoutChildren code from GoTextNode, so you can see what is happening. But basically… the size of the background shape is the size of the label plus the margins. To change that, you have to do your own LayoutChildren.

but... it's probably easier to just change the margins based on the background shape -- like ChartNode in FlowGrammer does.
on the Stop sign... set the Corner on the GoOctagon to be larger, or use
GoDrawing s = new GoDrawing(GoFigure.StopSign);

Set GoTextNode.AutoResizes to false. That will cause the label (a GoText object) to be sized to fit inside the Background object, minus the margins.

I never got the email, I’ll check my spam folder.

About the Stop Sign:
GoDrawing s = new GoDrawing(GoFigure.StopSign);
what is s being assigned to? Is this the background?

Yes. Look at ChartNode in the FlowGrammers sample (3.0).

Did AutoResizes = false give you the behavior you wanted?

First the Stop Sign.

I have a class that inherites from GoOctagon.
It's taken from one of your samples and gives me a gradiant fill back ground.
Then in my block class I override CreateBackground like this.
protected override GoObject CreateBackground()
WaitUntilBlockUI backGround = new WaitUntilBlockUI();
backGround.Selectable = false;
return backGround;
Where does this fit in?
GoDrawing s = new GoDrawing(GoFigure.StopSign);
Is my background GoOctagon or GoDrawing?

GoDrawing (and the predefined GoFigures) are a way of having 2D shapes without having a specific class (like GoOctagon) to implement them.

GoTextNode.Background takes any GoObject.
GoTextNode stop = new GoTextNode();
stop.AutoResizes = false;
GoDrawing s = new GoDrawing(GoFigure.StopSign);
s.Reshapable = false;
s.Size = new SizeF(50, 50);
s.FillShadedGradient(Color.Red, GoObject.TopLeft);
stop.Background = s;
stop.Location = new PointF(200, 200);
stop.Label.Bold = true;
stop.Label.Alignment = GoObject.Middle;
stop.Text = "Stop";

I can’t even find GoDrawing I am using 2.6

Is GoDrawing in this release?

No, it was new in 3.0. I looked at to see if you were licensed for 3.0, and you were, so I assumed you had that.

OK so lets start over.

I have a GoTextNode (Lets assume I can't change that type.)
I am using v2.6
I make the background a of the type GoImage
I want to set the size of the image myself.
I do not want a label.
Can I do this?

Even in 2.6, GoTextNode uses “GoObject” for Background, so you can use a GoImage, or a GoOctagon… anything derived from GoObject.

Setting AutoResizes = false lets you set the size of the background.
You can set the .Label = null or .Text = "";

ok so then why does this not work. When I drag this onto my diagram it shows up small not 48 x 48. I have tried up to 256x256.

public class MyBlock : GoTextNode
public MyBlock()
: base()
GoImage background = new GoImage();
background.Image = Properties.Resources.MyImage;
background.AutoResizes = false;
background.Size = new SizeF(48, 48);
this.Background = background;
this.Editable = false;
this.AutoResizes = false;
this.Selectable = true;
this.Deletable = false;
this.Moveable = false;
this.Label = null;

I think because you’re setting the background before setting AutoResizes.

Step through and check the Size after you set it.

That made the difference.


So now the Image is the size I want but it looks like the ports are still where they would be if the image was small.

I added this line of code hoping it would help.
this.bounds = background.bounds;
That didn't work.
Can you tell me what is happening here?

I don’t see how that can happen if you haven’t overridden LayoutChildren. Have you done that?

I have not overridden layout children.