Thumbnails

Hi there



I’m trying to generate thumbnails for nodes on the palette.



The nodes inherit from GoIconicNode.



Because the nodes arent the same sizes, I cannot use DocScale, and have instead overridden the paint event:



public override void Paint(Graphics g,GoView view)

{

if (view is GoPalette)

{

g.ScaleTransform(0.5f,0.5f);

}

base.Paint(g,view);

}



It works fine, but as soon as I start dragging the nodes around on the palette, it resizes again.



Any ideas?



Many thanks

DF

It’s dangerous to modify the Graphics without restoring it afterwards.
Are you sure that’s the transform you want to do?
Why can’t you set GoView.DocScale? I guess I don’t understand the effect you want to achieve.

Walter



Thanks, I found another solution. Once I restored the graphics, the problem was fixed. However, since I then had to deal with modifying the selection handles, I decided to use this solution instead:



<br />private float originalHeight; <br />private float originalWidth; <br />public override void Paint(System.Drawing.Graphics g,GoView view) <br />{ <br /> if (view is GoPalette) <br /> { <br /> if (originalHeight>0) <br /> { <br /> // Do nothing <br /> } <br /> else <br /> { <br /> originalHeight = this.Height; <br /> originalWidth = this.Width; <br /> this.Width = 75; <br /> this.Height = 75; <br /> } <br /> } <br /> else <br /> { <br /> if (originalHeight>0) <br /> { <br /> this.Width = this.originalWidth; <br /> this.Height = this.originalHeight; <br /> this.originalHeight = 0; <br /> this.originalWidth = 0; <br /> } <br /> } <br /> base.Paint(g,view); <br />} <br />



I suppose I should’ve followed this route from the start. Also got the captions working.



Many thanks

Deon Fourie

It’s also dangerous to modify a GoObject (or GoDocument) in the Paint method, although what you are doing might happen to work.
Since there are going to be different instances of your GoObject class in your GoPalette and in your GoView, you could just have them be different sizes. Then when it is copied due to a drag-and-drop from the palette to the view, you can change the size appropriately. This is normally done in a GoView.ExternalObjectsDropped event handler, by modifying the objects that are in the GoView.Selection.

Great. Followed your advice, works better than my approach.



Thanks

Deon Fourie