亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

SSD04 Exercise08 個(gè)人解答

系統(tǒng) 1577 0

?

Programming: Drawing

Description

This assignment requires you to complete the dynamic drawing components of the Date/Time Control Panel from the previous two programming assignments.? In particular, you will be moving the map found in the "Time Zone" tab when the time zone changes and will be drawing a clock face corresponding to the time setting.

Recall that the image used for displaying the map (in a PictureBox control) has been prepared with one pixel corresponding to each degree of longitude and has been drawn long enough to be displayed at any setting from 0 to 360 degrees.? Each time the time zone is changed, you should redraw the PictureBox control containing the map to indicate the approximate position of the time zone on the globe.? This can be done by converting the number of minutes offset from GMT into degrees of rotation of the earth.? Recall that 24 hours (= 1440 minutes) of offset corresponds to 360 degrees and that the map image has been drawn with one pixel for each degree.?? Finally, note that the map image has been prepared so that displaying its left edge at 0 corresponds to centering the image at 0 degrees (= GMT - 12 hours).

You should assign the map image (see the resources below) to the Image property of the PictureBox control using the Properties editor in Visual Basic.? This will allow you to access the image easily when it needs to be redrawn in a new position.? Each time the time zone offset changes you should redraw the Image in the PictureBox control.? This can be done by first computing a drawing offset for the image.? To do this, first compute a rotation from the GMT offset, and then convert that rotation into pixels.? A rotation of N degrees corresponds to an offset of -N pixels indicating that the left edge of the image appears N pixel to the left of the PictureBox origin.? Once a drawing offset has been computed the actual map image may be drawn using the Graphics DrawImage routine.? If the PictureBox is called mapPicture and the computed offset is screenOffset , then drawing would be done with the statement:

e.Graphics.DrawImage(mapPicture.Image, screenOffset, 0)

The second portion of this assignment is to draw a clock face in the PictureBox found on the "Date & Time" tab.? As shown below, this clock face should reflect the current time setting.? Consequently, it should be redrawn whenever the hour, minute, or second setting changes.


In drawing the clock face, you may find the following Graphics methods to be useful:

  • DrawLine
  • FillPolygon
  • FillEllipse

Finally, the routines clockX() and clockY()( which are provided in the resources section below) may be useful.? These routines compute the x and y positions of a point on the clock face at a given minute and at a given distance from the center of the clock (assuming that the center of the clock is at location 0,0).? The following example code draws a small black circle at the 35-minute position of a clock centered in a PictureBox given as a parameter.

Public Sub drawDotAt35Minutes(ByVal onObj As PictureBox, ByVal e as Windows.Forms.PaintEventArgs)
??? Const clockInset As Integer = 100 ??? ??? ' distance from clock edge to box edge
??? Const dotRadius As Integer = 15?? ??? ??? ' size of the dot
??? Dim smallDim As Integer?????????? ??? ??? ' smaller of width and height of box
??? Dim clockRadius As Integer??????? ??? ??? ' radius of the clock
??? Dim centerX As Integer??????????? ??? ??? ' x for center of the clock
??? Dim centerY As Integer??????????? ?? ?? ? ' y for center of the clock
??? Dim x As Integer????????????????? ??? ??? ' x position of dot
??? Dim y As Integer????????????????? ??? ??? ' y position of dot
??? Dim brush As new SolidBrush(Color.Black)? 'brush

??? ' calculate the center of the clock and its radius so it fits in the box
??? centerX = onObj.Width / 2
??? centerY = onObj.Height / 2
??? smallDim = onObj.Width
??? If (onObj.Height < smallDim) Then
??? ??? smallDim = onObj.Height

??? End If
??? clockRadius = smallDim / 2 - clockInset

??? ' calculate the position of the dot
??? x = centerX + clockX(35, clockRadius - dotRadius)
??? y = centerY + clockY(35, clockRadius - dotRadius)

??? ' draw a filled black circle
??? e.Graphics.FillEllipse(brush, x, y, dotRadius, dotRadius)

End Sub

Resources

  • Map image


This image is scaled with each pixel corresponding to one degree of longitude.? You can download the image here: time_zone_map.gif

  • Clock drawing helper routines

The following routines compute the x and y positions of a point on a clock face, assuming that the clock is centered at 0,0.? They each take a minute value to define a location along the clock, as well as a radius that defines how far away from the center of the clock the point should be.

Public Function clockDrawX(minuteVal As Integer, radius As Integer)
??? Const PI As Double = 3.14159265
??? Dim angle As Double

??? angle = (PI * 2 * minuteVal) / 60 - PI / 2
??? Return CInt(radius * Cos(angle))
End Function

Public Function clockDrawY(minuteVal As Integer, radius As Integer)
??? Dim angle As Double
??? Dim PI As Double
??? PI = 3.14159265

??? angle = (PI * 2 * minuteVal) / 60 - PI / 2
??? Return CInt(radius * Sin(angle))
End Function

  • Sample Solution

An executable like the application you are asked to create, click Ex8.zip

.

Submission

Submit the following files:

  • A project archive named Exercise8.zip

SSD04 Exercise08 個(gè)人解答


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫(xiě)作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫(xiě)作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 亚洲专区区免费 | 国产主播在线播放 | 久操免费视频 | 黄色小视频免费看 | 97在线播放| 久久精品视 | 日本高清h色视频在线观看 日本高清不卡二区 | 天天鲁天天爱天天鲁天天 | www欧美| 久久免费在线观看 | 日韩一区二区三区不卡视频 | 色猫咪av在线网址 | 亚洲瑟瑟网 | 国产色婷婷亚洲 | 日韩 亚洲 中文 图片 小说 | 黄色在线免费网站 | 精品一区精品二区 | 97在线视频免费播放 | 国产精品99久久久久久宅男 | 国产一区在线mmai | 国产末成年女av片 | 亚洲欧美综合精品成 | 久久国产这里只有精品 | 在线免费亚洲 | 亚洲午夜一级毛片 | 欧美色精品 | 欧美在线一区二区三区精品 | 成人欧美一区二区三区视频xxx | 久久久久久一级毛片免费无遮挡 | 亚洲视频高清 | 狠狠热精品免费观看 | 国产精品成人免费综合 | 免费看成人国产一区二区三区 | 国内精品久久久久影 | 大陆国产精品视频 | 欧美日韩一区二区三区久久 | 97视频资源站 | 四虎在线免费观看视频 | 婷婷激情五月综合 | 日日夜夜嗷嗷叫 | 一级黄色a毛片 |