Last post Oct 31, 2008 04:59 PM by Robert Barnes
Aug 31, 2008 07:34 AM|Robert Barnes|LINK
I am trying to create a genealogy chart, whose size could be many pages. My idea is to use GDI+ to draw the chart on a large canvas, zoom or scroll this to see as much as can be displayed on the physical display, and break this large "virtual page" into
physical pages when I come to print it. But I seem to be limited to the physical display size. In my VB program I calculate the X,Y coordinates of a rectangle:-
X = Position
ChartWidth = X + CellWidth
If Me.Width < ChartWidth Then
Me.Width = ChartWidth
This works perfectly provided that ChartWidth is < 1280 (approx), but if Chartwidth is larger then Me.Width is set to 1279. This is about the maximum width of the display on my laptop: the control panel shows my display as 1280 * 800 pixels.
Am I limited to a canvas of 1280 * 800, or can I work with a larger virtual canvas, perhaps by zooming it? Can somebody recommend some papers, or textbooks, that I should read?
Thank you, Robert Barnes.
Aug 31, 2008 07:40 AM|liammcmullen|LINK
Robert - this is a bit of the subject of asp.net etc but have a quick look at
http://www.yawah.com/ it may be of intrest.
Oct 31, 2008 09:17 AM|misfit815|LINK
I'm attempting a very similar project. Have you made any progress in this arena? Anything you can share?
Oct 31, 2008 09:42 AM|misfit815|LINK
It never fails. The best way to find the answer to your question is to post the question to a forum... *sigh*
The answer lies in the AutoScroll and AutoScrollMinSize properties.
There's also this little snippet (whose usefulness I'm still in the process of determining):
protected void _TabPage_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
e.Graphics.Transform = new System.Drawing.Drawing2D.Matrix(1, 0, 0, 1, base.AutoScrollPosition.X, base.AutoScrollPosition.Y);
Oct 31, 2008 04:59 PM|Robert Barnes|LINK
It ended up being quite easily solved. I learned by doing that if you draw an object outside the window, it is simply ignored. If you draw an object on the edge of your window, then you draw the part of the object that is in the window, the rest is ignored.
I don't know whether the software actually goes through the process of drawing the object and then discarding it, or whether it optimises the process to avoid the unnecessary processing, and there is a "region" parameter that sounds as if it's been designed
for this, but in any event my chart program is very fast even when drawing a 200 page chart and displaying 1 page, so I haven't been concerned with this.
I was able to solve my problem by using two variables, VOffset and HOffset, for the vertical and horizontal offset. Each object in my chart has an (X,Y) position, and is drawn at (X-HOffset, Y-VOffset). For example, here the position of an object is calculated:
X = (CurrentNode.Position) * CellSpace / 2 - XOffset
Y = (CurrentNode.LevelNbr * RowHeight + topmargin) - Yoffset
Initially the two offset variables are 0, but they are reset by the scroll bars. The same concept is used to print the chart: here the logic loops through "Print one page" increasing the value of HOffset and VOffset by the page size until all pages have