views:

473

answers:

4

Hi,

I want to display data on a Windows Forms project in C#.

The general sketch for the GUI is similar to Acrobat Reader or MS Word - meaning i want to display the data on several pages, and let the user navigate between the pages. The data i`m displaying isn't special, i just want to give the user a "page" feeling when viewing it.

I`m searching for a good starting point, preferably open-source.

I thought about using some kind of a reporting tool, such as Crystal Reports, is that a good idea?

Also, is better to use WPF then WinForms for this?

Any thought and recommendations are welcome.

Thanks.

+2  A: 

It sounds like you would be better off going the WPF route. You have MUCH better control over how your "form" looks.

What you would want to do is define each "page" in a user control or something, then you can display each one however you like. WPF can handle the zooming for you, all you have to do is hook it up (look into transforms). I can't see WinForms doing this. I would suggest looking at this project on codeplex.

Muad'Dib
How would pages be done? Do you have a simple example?
Robert Harvey
@Chris: you could do this sort of thing *easily* with WinForms and GDI+. It was possible to do graphics in Windows before WPF came along.
MusiGenesis
A: 

TabControl doesn't do what you want?

MNZ
no, tab control has a very different display. what i like to achieve is more like a book
Am
+1  A: 

If this project is just for fun, and if you already are using Visual Studio 2008, then WPF is a good choice for this.

If you intend to make this a commercial project, however, I would recommend making it a WinForms application. WPF requires Visual Studio 2008 and .Net 3.5. Many Windows users (especially corporate customers) are still using .Net 2.0 and don't plan to upgrade soon. Some are even still on .Net 1.1 (or no .Net at all). .Net 2.0 comes pre-installed now on new PCs, and the installer for 2.0 is only 23 MB (versus close to 200 MB for the somewhat-buggy .Net 3.5 installer). Also, .Net apps can (potentially) be made to run on Mac, Linux and the iPhone thanks to Mono, but Mono now is somewhere between .Net 2.0 and .Net 3.5, so WPF applications can't be cross-platform yet.

Here is a previous answer to a sort-of-similar question about doing a zoom effect in .Net with GDI+:

http://stackoverflow.com/questions/1140360/auto-sizing-zoom-on-an-image-in-net/1140538#1140538

This should give you a start on doing this kind of graphics work in .Net (and it's as open source as it gets).

Update: If you want to render XPS documents (easily), then you should use WPF. However, this choice would effectively eliminate the possibility of making your application cross-platform via Mono, at least in the short-term.

An alternative would be to export your documents as PDF files, or use Adobe Acrobat to convert your XPS documents into PDF files. Here is a link to a CodeProject sample that renders PDFs entirely in C#/.Net 2.0 or older:

http://www.codeproject.com/KB/showcase/pdfrasterizer.aspx

This code would allow your WinForms application to render a PDF file as a collection of Bitmaps (one for each page), and from there it's a relatively simple matter to display these Bitmaps in the manner you describe (with zoom and everything). Because the project would use .Net 2.0, it should work in Mono without any modifications.

MusiGenesis
this is part of an open-source project, and Mono is definitely in issue here.
Am
the advantage I see for WPF is exporting my content as a XPS and then using the document control to the rest for me. Are there known techniques for this in WinForms?
Am
@Am: no, I think you'd have to write your own XPS-to-Bitmap rendering routine, or purchase a third-party component to do this. An alternative is to use PDF files (see my update).
MusiGenesis
A: 

It sounds like what your trying to do is make an application behave like a web page. Would just adding a WebBrowser control suffice ?

Andrew Keith
Am