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)
StartTransaction()
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.Document.Add(node)
Me.Selection.[Select](node)
Me.Selection.HotSpot = New SizeF(node.Width / 2, node.Height / 2)
FinishTransaction("Insert from Palette")
Return Me.Selection
Else
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.
Jake,
doc.Add(CreatePalletteNode(andshape, "AndShape", width)); // add a shape to the palette
// create an icon for the palette.
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.Wrapping = true;
iconNode.Label.Clipping = true;
iconNode.Label.StringTrimming = StringTrimming.EllipsisCharacter;
return iconNode;
}
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;
}