views:

56

answers:

2

In a WinForm I use rectangles, ovals and lines of Microsoft.VisualBasic.PowerPacks.

Is it possible to make a zoom on it? How?

+1  A: 

Assuming you are just using them to draw pictures, there are no input controls, do this.

1) Move them to a usercontrol
2) Put the usercontrol on the form - but set visible=false
3) In the load of the form, call the usercontrol's DrawToBitmap, saving it
4) In the paint ... Draw the bitmap to the form, scaling it per your zoom.
5) housekeeping...If the usercontrol changes, refresh the bitmap; if zoom or bitmap change, invalidate the form.

Good luck ;-)

FastAl
interesting approach :) I use the UserControl with shapes however to select and edit some of its properties.
serhio
A: 

OK since this is a completely different approach I am going to add another answer! (vb pseudocode):

Global variable for the form:

 Dim OrigSizes as new Generic.Dictionary (of Control,Rect)

In the form_load:

 SaveSizes(me)

New sub:

 Sub SaveSizes(c as Control)
     for each c as Control in c.Controls
         SaveSizes(c)
     next
     OrigSizes.Add(c,new rect(c.left,c.top,c.width,c.height)
 End Sub

When you zoom...

 Sub cboZoomAmount_Change(sender as object, etc...) Handles cboZoomAmount.Change
     dim ZoomFac as Double = math.max(0.1,val(cboZoomAmount.text)
     for each c as Control in OrigSizes.Keys
         c.Left = cint(ZoomFac*OrigSizes(c).Left)
         ... 3 more lines for top/width/height ...
     next c
 End Sub

Hack, I know, but if you want Pretty go to eHarmony.com (or better yet CatholicMatch.com ;-)

FastAl
a pity that the texts inside rectangles will not be scaled
serhio
No problem; For some reason the picture your app in my head didn't have text on the shapes!! If the items' fonts are not the same sizes, just make a new generic (of control, double) and save their font sizes; reset fonts using same philosophy (still looping on just OrigSizes, set the new sizes inside the same loop). If they are all using the default font of the form, add a line outsize the loop like dim fnt as new font(me.font,me.font.size*zoomfac) and set each control's font to fnt in the loop. viola! or Voila or whatever.
FastAl