dlloyd
December 2, 2008, 10:09am
1
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,
Dave
Jake
December 2, 2008, 4:39pm
2
Did you start with GraphNode in FlowCharter?
dlloyd
December 2, 2008, 4:43pm
3
All my Blocks have one common ancestor that inherits from GoTextNode.
dlloyd
December 2, 2008, 5:12pm
4
I’m not sure what you are asking? Do you mean which demo did I start from? If that is the question None really.
Jake
December 2, 2008, 5:20pm
5
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);
walter
December 2, 2008, 6:58pm
6
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.
dlloyd
December 3, 2008, 8:26am
7
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?
Jake
December 3, 2008, 9:20am
8
Yes. Look at ChartNode in the FlowGrammers sample (3.0).
Did AutoResizes = false give you the behavior you wanted?
dlloyd
December 3, 2008, 9:31am
9
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?
Jake
December 3, 2008, 10:06am
10
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"; doc.Add(stop);
dlloyd
December 3, 2008, 11:27am
11
I can’t even find GoDrawing I am using 2.6
Is GoDrawing in this release?
Jake
December 3, 2008, 11:51am
12
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.
dlloyd
December 3, 2008, 2:45pm
13
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?
Jake
December 3, 2008, 3:07pm
14
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 = "";
dlloyd
December 3, 2008, 3:34pm
15
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;
}
}
Jake
December 3, 2008, 4:53pm
16
I think because you’re setting the background before setting AutoResizes.
Step through and check the Size after you set it.
dlloyd
December 3, 2008, 7:49pm
17
That made the difference.
Thanks
dlloyd
December 3, 2008, 11:37pm
18
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?
Jake
December 3, 2008, 11:58pm
19
I don’t see how that can happen if you haven’t overridden LayoutChildren. Have you done that?
dlloyd
December 4, 2008, 12:22am
20
I have not overridden layout children.