SSD04 Practical Quiz 4 个人解答


Scrolling a Map

Description

Exercise 8, requires that you learn to scroll the world map from the Date /Time Control Panel of Windows/Windows NT. In the current quiz, Quiz 4, you must scroll a map, starting with only a map in jpg format. The map used is a digitized version of a hand-colored engraving, originally published in 1856. It depicts the Roman Empire at its greatest extent.

Since this is the Roman Empire, center the map on Roma and choose three more points. The executable uses Gaul, Palestine, and India. When a location is selected, the map should scroll to that approximate position.

Note: the scrolling map will look odd to the modern eye since, in all settings but Roma, the tip of the Iberian Peninsula will reach to the west, wrapping around and touching India!

Map courtesy of Baldwin's Old Maps & Prints, PO Box 3515 Norfolk, Virginia 23514 (757) 625-1888.

Resources

  • An executable like the application you are asked to create: click QPr4.exe . (From Internet Explorer, select the "Run this program" option of the "File download" dialog box that appears—from Netscape, save and double-click the file QPr4.exe.)
  • The JPEG image of the map of the Roman Empire

Submission

Submit the following files:

  • QPr4.resx
  • QPr4.vb
  • QPr4.vbproj
  • Any image files your project uses directly

--------------------------------------------------------------------------------------------------------------------------------

我认为这个题目的难度在于如何将事件放置好,我在刚开始的时候将redraw放在了selectchanged里面,导致每次在redraw时被一些控件覆盖了。

Public Class MainForm


    Private Sub redrawImage(ByVal sender As System.Object, ByVal e As Windows.Forms.PaintEventArgs) Handles MainPB.Paint

        Dim l As Integer
        Select Case Me.LocationCB.SelectedIndex
            Case 0
                l = (160)
            Case 1
                l = (0)
            Case 2
                l = (220)
            Case 3
                l = (80)
        End Select

        Dim r As Rectangle
        r.Y = 0
        r.X = l
        r.Width = My.Resources.RomanEmpire.Width
        r.Height = My.Resources.RomanEmpire.Height
        e.Graphics.DrawImage(My.Resources.RomanEmpire, r)
        r.X = -r.Width + l
        e.Graphics.DrawImage(My.Resources.RomanEmpire, r)

    End Sub

    Private Sub LocationCB_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LocationCB.SelectedIndexChanged
        Me.MainPB.Refresh()
    End Sub

End Class

 关键点:

  1. MainPB是picture box 控件
  2. 每次不是直接redraw而是调用refresh 方法
  3. 让redraw在paint even 中被调用
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值