3

I have am building a program that basically lets you create a document by dragging and dropping components, built in C# Windows Forms.

The document's "canvas" is a panel, and all the elements of the document are panels, labels, pictureBoxes or any other Control that might be interesting to add to it.

My question is, is there an easy/automated way of performing zoom in/out in that panel, zooming a positioning correctly all it's children as well? Or do I have to, manually, multiply the sizes by a zooming factor and also the position of elements?

In the case that the later option would be the only one available, what about labels? Would I have to also multiply the font size by that factor? Would this even be correct or possible?

Any kind of help or directions is much appreciated in advance.

Best regards

viper
  • 974
  • 6
  • 13
  • Just in case you're interested in skipping all the hellish suffering and torture and pain that it would represent to do what you're describing here in an obsolete technology such as winforms, please see my examples [1](http://stackoverflow.com/a/15580293/643085) [2](http://stackoverflow.com/a/15469477/643085) [3](http://stackoverflow.com/a/15821573/643085), and most notably [4](http://stackoverflow.com/a/16947081/643085) with support for zoom & pan. All done with current relevant .Net UI technologies (WPF), and using a much happier approach (MVVM) than the traditional winforms code behind crap – Federico Berasategui Jun 11 '13 at 15:48
  • (not to mention) that even if you go thru all the hell, in the end you'll realize it was all in vain due to the lack of usability of the end product caused by constant flickering. – Federico Berasategui Jun 11 '13 at 15:50
  • (which) can only be solved by rewriting the whole application in a technology that supports hardware rendering, such as WPF. – Federico Berasategui Jun 11 '13 at 15:55
  • @HighCore thanks for your input, I shall look at your examples, but as they are in WPF I am not sure that they will help me. The flickering is solved by using the double buffer, and it has been working so far (the zooming isn't the first "moving" feature I am introducing to my program). Apparently, if nobody suggests a better solution, I will have to go through the hell of resizing and moving everything, just as you described. In any case, how hard/doable is it to transform a windows forms application into a WPF one? Is there some automated way of doing this? Thanks again. – viper Jun 12 '13 at 08:49
  • you could integrate WPF content into an existing winforms application by using the `ElementHost` (see MSDN). I suggest you develop this specific functionality (and probably everything onwards) in WPF, while retaining your legacy stuff. This way you don't have to redo the entire application. BTW double buffer is not going to help, winforms is still software rendered, thus slow. – Federico Berasategui Jun 12 '13 at 12:40

0 Answers0