• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

scrolling map

Please see this diagram:

http://www.knowltonsoftware.com/junk/scrollingmap.bmp



What I want is to create a windows application in C#.  On the Form I will have a PictureBox control that shows PART of a map at any given time.  But the map will be so big that you have to scroll to see the rest of the map.

I want to use GDI+   ....   no DirectX.
0
Tom Knowlton
Asked:
Tom Knowlton
1 Solution
 
softplusCommented:
I did this in vb.net (actually for the .net compact framework), but it should be straightforward to translate (here's hoping I did it the "correct" way, at least it works :)), it's not GDI+ but maybe it will give you some ideas; it was/is part of a moving map display:
            Dim rectDest, rectSrc As Rectangle
            ' source + destination rectangle, note: it can stretch as well...
            rectDest = New Rectangle(intSX1, intSY1, intSX2 - intSX1, intSY2 - intSY1)
            rectSrc = New Rectangle(intOX1, intOY1, intOX2 - intOX1, intOY2 - intOY1)
            If Not p_Map.BmpLoaded Then ' p_Map is a global variable, *gasp*, used to cache the map so that I don't need to reload it each time
                Try
                    p_Map.BmpMap = New Bitmap(p_Map.Filename)
                         ' p_Map.BmpMap is of type System.Drawing.Bitmap
                    p_Map.BmpLoaded = True
                Catch ex As Exception
                    ' no file found or other problem ...!! abort!
                    MsgBox("Error loading file " & p_Map.Filename & ": error=" & ex.ToString)
                End Try
            End If
            If Not p_Map.BmpMap Is Nothing Then
                p_Graph.DrawImage(p_Map.BmpMap, rectDest, rectSrc, GraphicsUnit.Pixel)
                ' p_Graph is of type System.Drawing.Graphics
            End If

Hope it gives you some ideas :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now