locked
How do I work with a canvas greater than the physical display? RRS feed

  • Question

  • User-1809947162 posted

    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
            End If

    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.

    Sunday, August 31, 2008 7:34 AM

All replies

  • User619027646 posted

    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.

    good luck

    Liam

    Sunday, August 31, 2008 7:40 AM
  • User-1688937434 posted

     I'm attempting a very similar project. Have you made any progress in this arena? Anything you can share?

     

    J

    Friday, October 31, 2008 9:17 AM
  • User-1688937434 posted

     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);
                this.Draw(e.Graphics);
            }
    
     
    
      
    Friday, October 31, 2008 9:42 AM
  • User-1809947162 posted

    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 been printed.

    Regards, Robert

    Friday, October 31, 2008 4:59 PM