GoPallete Align IconsImages

Hi All, I am new to GoDiagram and need I some help. I have been able to add all my icons to the pallete and was able to resize the Pallete window but my icons still seem to be crowded and not evenly spaced out. Does anyone know how to evenly space out images or icons in the Pallete so they are aligned and do not look like they are running into each other? also how would you increase the sizes of these icons?


The GoPalette basics (from the FAQ)

You can control the Orientation and GridCellSize and alignment, as well as whether the items are sorted and in what order with the Sorting property. You can even turn off the automatic positioning of items in the palette’s document by setting the AutomaticLayout property to false.

Depending on the level of control you want, you may not get what you want from the simple grid-layout provided by AutomaticLayout.

GoPalette's layout works best when all the objects are the same size, similar to what Visio does. With GoDiagram, it's not hard to have an application that looks like this:

also how would you increase the sizes of these icons?

You can set the objects to any size you want in the palette. I’m assuming you mean “how do I make the objects bigger when they are dropped?”.

I don’t have an exact sample of that, but the code below is from DrawDemo, to make the GoIconicNodes we put in the palette to drop as GoShapes. (we use GoIconicNode in the palette because it is an easy way to add a label.) The code extracts the GoShape from the GoIconicNode and makes it 3x larger than it was in the palette…

Protected Overloads Overrides Function DoExternalDrop(ByVal evt As DragEventArgs) As IGoCollection
  Dim data As IDataObject = evt.Data
  Dim clipsel As GoSelection = TryCast(data.GetData(GetType(GoSelection)), GoSelection)

  If clipsel IsNot Nothing AndAlso TypeOf clipsel.Primary Is GoIconicNode Then
    Dim ic As GoIconicNode = DirectCast(clipsel.Primary, GoIconicNode)
    Dim screenPnt As New Point(evt.X, evt.Y)
    Dim viewPnt As Point = PointToClient(screenPnt)
    Dim docPnt As PointF = ConvertViewToDoc(viewPnt)

    Dim node As GoShape = TryCast(Me.Document.AddCopy(ic.Icon, docPnt), GoShape)
    node.Size = New SizeF(node.Size.Width * 3, node.Size.Height * 3)
    node.Selectable = True
    node.Shadowed = False
    node.Resizable = True
    node.Reshapable = True
    node.ResizesRealtime = True
    Me.Selection.HotSpot = New SizeF(node.Width / 2, node.Height / 2)
    FinishTransaction("Insert from Palette")
    Return Me.Selection
    Return MyBase.DoExternalDrop(evt)
  End If
End Function

(DrawDemo will be in V4… we’re broken up “Demo1” into a Drawing bit and a Node/Link sampler.)

You can also set the GoPalette.DocScale to a value smaller than the default of 1.0f, if you want those objects to look smaller there than they will appear when dropped into a GoView that has DocScale == 1.0f.

That way you don’t need to implement any code to fiddle with the objects that were dropped from a drag-and-drop.

Thanks Walter, the default value is set to 0.65f but I am still they still aren’t aligned in the Palette.


Thank you for your help but I need a little more explanation on this.
In the Palette, I tried making the images the same size but they looked distorted, is there a sample I can see where they sized objects to the same size in the Palette so they are aligned like the Visio image you showed me? This would be great help. Currently the palette looks very inconsistent.
Our project is imitating the Processor sample, thanks to the last developer, which highlights the images on the Canvas with a green box. I investigated the Demo1 example and I wanted to ask how is it that their highlighting allows them to resize images on the Canvas.
I am very new to this and appreciate all your help in this.
GoPalette is really simple to use, because, by default, you put an object X into it, and you get copies of object X when you drag and drop.
The problem is, when you have X, Y and Z, it may be appropriate for them to be different sizes and shapes in you application window, but it looks a little funky when you put them all in a palette together.
So, you can also do what Visio and lots of palette oriented programs do... the palette is a visual cue for what will be dropped, but not an exact copy.
This DoExternalDrop I provided above takes a GoIconicNode and just pulls out the GoShape and uses that. That's TOO SIMPLE for what you want to do.... you're going to want to map the iconic nodes into whatever ActivityNode you want.
OK... here's the code for the "Draw Demo" palette icons that you see earlier in this thread.
float width = palGoFigures.GridCellSizeWidth - 2; // width is for labels.
doc.Add(CreatePalletteNode(andshape, "AndShape", width)); // add a shape to the palette

// create an icon for the palette.
private static GoIconicNode CreatePalletteNode(GoShape shape, string label, float width) {
GoIconicNode iconNode = new GoIconicNode();
iconNode.Initialize(null, "", AddBreak(label));
shape.Size = new SizeF(24, 24);
shape.Selectable = false;
shape.BrushColor = Color.White;
iconNode.Icon = shape;
iconNode.Icon.Shadowed = true;
iconNode.Label.FontSize = 7;
iconNode.Label.WrappingWidth = width;
iconNode.Label.Wrapping = true;
iconNode.Label.Clipping = true;
iconNode.Label.StringTrimming = StringTrimming.EllipsisCharacter;
return iconNode;
private static string AddBreak(string label) {
string s = "";
int lastchar = 0;
// add a space before each upper case char
for (int i = 1; i < label.Length; i++) {
if (label.Substring(i, 1).ToUpper() == label.Substring(i, 1)) {
if (s.Length > 0) s += " ";
s = s + label.Substring(lastchar, i - lastchar);
lastchar = i;
if (s.Length > 0) s += " ";
s = s + label.Substring(lastchar, label.Length - lastchar);
return s;
(oops, I started with VB, and this is C#... if you want the VB, let me know)