home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / annotate / annotate.frm (.txt) next >
Encoding:
Visual Basic Form  |  1998-07-10  |  15.4 KB  |  506 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Begin VB.Form AnnotationsForm 
  4.    Caption         =   "Map Annotation"
  5.    ClientHeight    =   6090
  6.    ClientLeft      =   165
  7.    ClientTop       =   735
  8.    ClientWidth     =   8295
  9.    FillStyle       =   0  'Solid
  10.    BeginProperty Font 
  11.       Name            =   "Comic Sans MS"
  12.       Size            =   12
  13.       Charset         =   0
  14.       Weight          =   400
  15.       Underline       =   0   'False
  16.       Italic          =   0   'False
  17.       Strikethrough   =   0   'False
  18.    EndProperty
  19.    LinkTopic       =   "Form1"
  20.    PaletteMode     =   1  'UseZOrder
  21.    ScaleHeight     =   6090
  22.    ScaleWidth      =   8295
  23.    StartUpPosition =   3  'Windows Default
  24.    Visible         =   0   'False
  25.    Begin MSComDlg.CommonDialog CommonDialog1 
  26.       Left            =   0
  27.       Top             =   0
  28.       _ExtentX        =   847
  29.       _ExtentY        =   847
  30.       _Version        =   393216
  31.    End
  32.    Begin VB.PictureBox Picture1 
  33.       AutoRedraw      =   -1  'True
  34.       AutoSize        =   -1  'True
  35.       BeginProperty Font 
  36.          Name            =   "Comic Sans MS"
  37.          Size            =   9.75
  38.          Charset         =   0
  39.          Weight          =   400
  40.          Underline       =   0   'False
  41.          Italic          =   0   'False
  42.          Strikethrough   =   0   'False
  43.       EndProperty
  44.       FontTransparent =   0   'False
  45.       ForeColor       =   &H000000C0&
  46.       Height          =   5775
  47.       Left            =   120
  48.       ScaleHeight     =   381
  49.       ScaleMode       =   3  'Pixel
  50.       ScaleWidth      =   533
  51.       TabIndex        =   0
  52.       Top             =   120
  53.       Width           =   8055
  54.       Begin VB.PictureBox Bullet 
  55.          Appearance      =   0  'Flat
  56.          AutoRedraw      =   -1  'True
  57.          BackColor       =   &H00FFFFFF&
  58.          BorderStyle     =   0  'None
  59.          DrawWidth       =   2
  60.          FillColor       =   &H000000C0&
  61.          BeginProperty Font 
  62.             Name            =   "MS Sans Serif"
  63.             Size            =   8.25
  64.             Charset         =   0
  65.             Weight          =   400
  66.             Underline       =   0   'False
  67.             Italic          =   0   'False
  68.             Strikethrough   =   0   'False
  69.          EndProperty
  70.          ForeColor       =   &H00FF0000&
  71.          Height          =   225
  72.          Index           =   0
  73.          Left            =   480
  74.          ScaleHeight     =   15
  75.          ScaleMode       =   3  'Pixel
  76.          ScaleWidth      =   15
  77.          TabIndex        =   1
  78.          Top             =   120
  79.          Visible         =   0   'False
  80.          Width           =   225
  81.       End
  82.    End
  83.    Begin VB.Menu FileMenu 
  84.       Caption         =   "File"
  85.       Begin VB.Menu FileNew 
  86.          Caption         =   "New"
  87.       End
  88.       Begin VB.Menu FileOpen 
  89.          Caption         =   "Open"
  90.       End
  91.       Begin VB.Menu FileSaveAs 
  92.          Caption         =   "Save As"
  93.       End
  94.       Begin VB.Menu sep0 
  95.          Caption         =   "-"
  96.       End
  97.       Begin VB.Menu FileExit 
  98.          Caption         =   "Exit"
  99.       End
  100.    End
  101.    Begin VB.Menu AnnotationsMenu 
  102.       Caption         =   "Annotations"
  103.       Begin VB.Menu ColorMenu 
  104.          Caption         =   "Color"
  105.          Begin VB.Menu BlueDot 
  106.             Caption         =   "Blue"
  107.          End
  108.          Begin VB.Menu RedDot 
  109.             Caption         =   "Red"
  110.          End
  111.          Begin VB.Menu GreenDot 
  112.             Caption         =   "Green"
  113.          End
  114.          Begin VB.Menu YellowDot 
  115.             Caption         =   "Yellow"
  116.          End
  117.          Begin VB.Menu WhiteDot 
  118.             Caption         =   "White"
  119.          End
  120.          Begin VB.Menu BlackDot 
  121.             Caption         =   "Black"
  122.          End
  123.       End
  124.       Begin VB.Menu ShapeMenu 
  125.          Caption         =   "Shape"
  126.          Begin VB.Menu ShapeCircle 
  127.             Caption         =   "Circle"
  128.          End
  129.          Begin VB.Menu ShapeDot 
  130.             Caption         =   "Dot"
  131.          End
  132.          Begin VB.Menu ShapeBox 
  133.             Caption         =   "Box"
  134.          End
  135.          Begin VB.Menu ShapeXBox 
  136.             Caption         =   "XBox"
  137.          End
  138.       End
  139.       Begin VB.Menu sep1 
  140.          Caption         =   "-"
  141.       End
  142.       Begin VB.Menu DotsComments 
  143.          Caption         =   "Comments"
  144.       End
  145.       Begin VB.Menu sep2 
  146.          Caption         =   "-"
  147.       End
  148.       Begin VB.Menu DotsDelete 
  149.          Caption         =   "Delete"
  150.       End
  151.    End
  152.    Begin VB.Menu ImageMenu 
  153.       Caption         =   "Image"
  154.       Begin VB.Menu ImageShow 
  155.          Caption         =   "Show"
  156.       End
  157.       Begin VB.Menu ImageHide 
  158.          Caption         =   "Hide"
  159.       End
  160.       Begin VB.Menu sep3 
  161.          Caption         =   "-"
  162.       End
  163.       Begin VB.Menu ShowNotes 
  164.          Caption         =   "Notes"
  165.       End
  166.    End
  167. Attribute VB_Name = "AnnotationsForm"
  168. Attribute VB_GlobalNameSpace = False
  169. Attribute VB_Creatable = False
  170. Attribute VB_PredeclaredId = True
  171. Attribute VB_Exposed = False
  172. Dim maxMarks As Integer
  173. Dim MAPNAME As String
  174. Dim MARKCOLOR As Long
  175. Dim MARKSHAPE As String
  176. Dim selDotIndex As Integer
  177. Dim Notes(1000) As String
  178. Dim XStart As Single, YStart As Single
  179. Dim Dragging As Boolean
  180. Private Sub BlackDot_Click()
  181.     MARKCOLOR = RGB(0, 0, 0)
  182.     If selDotIndex = -1 Then
  183.         Exit Sub
  184.     Else
  185.         DrawBullet selDotIndex, MARKCOLOR, MARKSHAPE
  186.     End If
  187.     ClearColorChecks
  188.     BlackDot.Checked = True
  189. End Sub
  190. Private Sub BlueDot_Click()
  191.     MARKCOLOR = RGB(0, 0, 255)
  192.     If selDotIndex = -1 Then
  193.         Exit Sub
  194.     Else
  195.         DrawBullet selDotIndex, MARKCOLOR, MARKSHAPE
  196.     End If
  197.     ClearColorChecks
  198.     BlueDot.Checked = True
  199. End Sub
  200. Private Sub Bullet_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
  201.     If Button = vbLeftButton Then
  202.         Dragging = True
  203.         XStart = X
  204.         YStart = Y
  205.         Bullet(Index).ZOrder 0
  206.     End If
  207. End Sub
  208. Private Sub Bullet_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
  209.     If Not Dragging Or Button <> vbLeftButton Then Exit Sub
  210.     Bullet(Index).Visible = False
  211.     Bullet(Index).Move Bullet(Index).Left + (X - XStart), Bullet(Index).Top + (Y - YStart)
  212.     Bullet(Index).Visible = True
  213.     DrawBullet Index, Bullet(Index).FillColor, Bullet(Index).Tag
  214. End Sub
  215. Private Sub Bullet_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
  216.     If Button = vbRightButton Then
  217.         selDotIndex = Index
  218.         MARKSHAPE = Bullet(selDotIndex).Tag
  219.         PopupMenu AnnotationsMenu
  220.     ElseIf Button = vbLeftButton Then
  221.         Dragging = False
  222.     End If
  223. End Sub
  224. Private Sub DotsComments_Click()
  225.     If selDotIndex = -1 Then Exit Sub
  226.     CommentsForm.Text1.Text = Notes(selDotIndex)
  227.     CommentsForm.Show vbModal
  228.     Notes(selDotIndex) = CommentsForm!Text1.Text
  229.     Bullet(selDotIndex).ToolTipText = Notes(selDotIndex)
  230. End Sub
  231. Private Sub DotsDelete_Click()
  232.     Unload Bullet(selDotIndex)
  233.     selDotIndex = -1
  234. End Sub
  235. Private Sub FileNew_Click()
  236. StartAgain:
  237.     CommonDialog1.DialogTitle = "Select Map to Annotate"
  238.     CommonDialog1.Filter = "Images|*.BMP;*.GIF;*.JPG"
  239.     CommonDialog1.CancelError = True
  240.     On Error GoTo NoGasMapFile
  241.     CommonDialog1.ShowOpen
  242. On Error GoTo BadBMPFile
  243.     Picture1.Picture = LoadPicture(CommonDialog1.FileName)
  244.     DoEvents
  245.     MAPNAME = CommonDialog1.FileName
  246.     ClearDots
  247.     AnnotationsForm.Palette = Picture1.Picture
  248.     Picture1.Picture = LoadPicture(MAPNAME)
  249.     AnnotationsForm.Width = Picture1.Width + 3 * Picture1.Left
  250.     AnnotationsForm.Height = Picture1.Height + 60 * Screen.TwipsPerPixelY
  251.     AnnotationsForm.Refresh
  252. Exit Sub
  253. NoGasMapFile:
  254.     End
  255. BadBMPFile:
  256.     MsgBox CommonDialog1.FileName & " could not be opened." & vbCrLf & "Please try again with a different file"
  257.     GoTo StartAgain
  258. End Sub
  259. Private Sub FileOpen_Click()
  260.     CommonDialog1.DialogTitle = "Select Map to Annotate"
  261.     CommonDialog1.Filter = "Application Files|*.ANT"
  262.     CommonDialog1.InitDir = App.Path
  263.     CommonDialog1.CancelError = True
  264. On Error GoTo FileOpenError
  265.     CommonDialog1.ShowOpen
  266.     fNum = FreeFile()
  267.     Open CommonDialog1.FileName For Input As #fNum
  268.     Input #fNum, MAPNAME
  269.     On Error GoTo ImageNotFound
  270.     Picture1.Picture = LoadPicture(MAPNAME)
  271.     AnnotationsForm.Palette = Picture1.Picture
  272.     Picture1.Picture = LoadPicture(MAPNAME)
  273.     AnnotationsForm.Width = Picture1.Width + 3 * Picture1.Left
  274.     AnnotationsForm.Height = Picture1.Height + 60 * Screen.TwipsPerPixelY
  275.     AnnotationsForm.Refresh
  276.     ClearDots
  277.     On Error Resume Next
  278.     i = 0
  279.     While Not EOF(fNum)
  280.         i = i + 1
  281.         Load Bullet(i)
  282.         Bullet(i).Visible = True
  283.         Input #fNum, BLeft, BTop, BColor, BShape, BNote
  284.         Bullet(i).Left = BLeft
  285.         Bullet(i).Top = BTop
  286.         DrawBullet (i), (BColor), (BShape)
  287.         Notes(i) = BNote
  288.         Bullet(i).ToolTipText = BNote
  289.     Wend
  290.     maxMarks = i
  291.     Close #fNum
  292.     Exit Sub
  293. FileOpenError:
  294.     Exit Sub
  295. ImageNotFound:
  296.    MsgBox "Image file " & MAPNAME & " not found"
  297.    Exit Sub
  298. End Sub
  299. Private Sub FileSaveAs_Click()
  300. CommonDialog1.DialogTitle = "Select Project File to Open"
  301. CommonDialog1.DefaultExt = "ANT"
  302. CommonDialog1.Filter = "Application Files|*.ANT"
  303. CommonDialog1.CancelError = True
  304. On Error GoTo FileSaveError
  305. CommonDialog1.ShowSave
  306. fNumMap = FreeFile()
  307. Open CommonDialog1.FileName For Output As #fNumMap
  308.     Print #fNumMap, MAPNAME
  309.     On Error Resume Next
  310.     For i = 1 To maxMarks
  311.         thisDot = thisDot + 1
  312.         vtest = Bullet(i).Visible
  313.         If Err.Number = 0 Then
  314.             Print #fNumMap, Bullet(i).Left, Bullet(i).Top, Bullet(i).FillColor, Bullet(i).Tag
  315.             Print #fNumMap, Chr(34) & Notes(i) & Chr(34)
  316.         End If
  317.         Err.Clear
  318.     Next
  319.     Close #fNumMap
  320.     Exit Sub
  321. FileSaveError:
  322.     MsgBox "Error in saving annotation map!"
  323.     On Error Resume Next
  324.     Close #fNumMap
  325. End Sub
  326. Private Sub Form_Load()
  327.     Me.Show
  328.     maxMarks = 0
  329.     MARKCOLOR = RGB(255, 0, 0)
  330.     MARKSHAPE = "BOX"
  331.     msg = "Select New or Open from the File menu"
  332.     Picture1.Print msg
  333. End Sub
  334. Private Sub GreenDot_Click()
  335.     MARKCOLOR = RGB(0, 255, 0)
  336.     If selDotIndex = -1 Then
  337.         Exit Sub
  338.     Else
  339.         DrawBullet selDotIndex, MARKCOLOR, MARKSHAPE
  340.     End If
  341.     ClearColorChecks
  342.     GreenDot.Checked = True
  343. End Sub
  344. Private Sub ImageHide_Click()
  345.     Picture1.Picture = LoadPicture()
  346.     RedrawDots
  347. End Sub
  348. Private Sub ImageShow_Click()
  349.     Picture1.Picture = LoadPicture(MAPNAME)
  350.     RedrawDots
  351. End Sub
  352. Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  353.     If MAPNAME = "" Then Exit Sub
  354.     If Button = 2 Then
  355.         maxMarks = maxMarks + 1
  356.         Load Bullet(maxMarks)
  357.         Bullet(maxMarks).Move X - Bullet(maxMarks).ScaleWidth / 2, Y - Bullet(maxMarks).ScaleHeight / 2
  358.         Bullet(maxMarks).Visible = True
  359.         Bullet(maxMarks).ToolTipText = ""
  360.         Bullet(maxMarks).Tag = MARKSHAPE
  361.         DrawBullet maxMarks, MARKCOLOR, MARKSHAPE
  362.     End If
  363. End Sub
  364. Function DrawBullet(BulletIndex As Integer, FRCOLOR As Long, FRSHAPE As String)
  365.     Bullet(BulletIndex).PaintPicture Picture1.Image, _
  366.        0, 0, Bullet(BulletIndex).ScaleWidth, Bullet(BulletIndex).ScaleHeight, _
  367.        Bullet(BulletIndex).Left, Bullet(BulletIndex).Top, _
  368.        Bullet(BulletIndex).ScaleWidth, Bullet(BulletIndex).ScaleHeight, _
  369. 13369376
  370.     Bullet(BulletIndex).FillColor = FRCOLOR
  371.     Bullet(BulletIndex).ForeColor = FRCOLOR
  372.     Bullet(BulletIndex).Tag = FRSHAPE
  373.     If FRSHAPE = "CIRCLE" Then
  374.         X = Bullet(BulletIndex).ScaleWidth / 2
  375.         Y = Bullet(BulletIndex).ScaleHeight / 2
  376.         Bullet(BulletIndex).Circle (X, Y), X * 0.9
  377.     ElseIf FRSHAPE = "DOT" Then
  378.         X = Bullet(BulletIndex).ScaleWidth / 2
  379.         Y = Bullet(BulletIndex).ScaleHeight / 2
  380.         Bullet(BulletIndex).FillStyle = 0
  381.         Bullet(BulletIndex).Circle (X, Y), X * 0.9
  382.         Bullet(BulletIndex).FillStyle = 1
  383.     ElseIf FRSHAPE = "BOX" Or FRSHAPE = "XBOX" Then
  384.         X = Bullet(BulletIndex).ScaleWidth
  385.         Y = Bullet(BulletIndex).ScaleHeight
  386.         Bullet(BulletIndex).DrawWidth = 2
  387.         Bullet(BulletIndex).Line (2, 2)-(X - 2, Y - 2), , B
  388.         If FRSHAPE = "XBOX" Then
  389.             Bullet(BulletIndex).Line (2, 2)-(X - 2, Y - 2)
  390.             Bullet(BulletIndex).Line (2, Y - 2)-(X - 2, 2)
  391.         End If
  392.     Else
  393.  '       MsgBox "Application Error: Unknown shape requested!"
  394.         Exit Function
  395.     End If
  396.     Picture1.Refresh
  397. End Function
  398. Private Sub RedDot_Click()
  399.     MARKCOLOR = RGB(255, 0, 0)
  400.     If selDotIndex = -1 Then
  401.         Exit Sub
  402.     Else
  403.         DrawBullet selDotIndex, MARKCOLOR, MARKSHAPE
  404.     End If
  405.     ClearColorChecks
  406.     RedDot.Checked = True
  407. End Sub
  408. Function ClearDots()
  409.     On Error Resume Next
  410.     For i = 1 To maxMarks
  411.         Unload Bullet(i)
  412.         Notes(i) = ""
  413.     Next
  414.     maxMarks = 0
  415. End Function
  416. Function RedrawDots()
  417.     On Error Resume Next
  418.     For i = 1 To maxMarks
  419.         DrawBullet (i), Bullet(i).FillColor, Bullet(i).Tag
  420.     Next
  421. End Function
  422. Private Sub ShapeBox_Click()
  423.     MARKSHAPE = "BOX"
  424.     If selDotIndex = -1 Then
  425.         Exit Sub
  426.     Else
  427.         DrawBullet selDotIndex, MARKCOLOR, MARKSHAPE
  428.     End If
  429.     ClearShapeChecks
  430.     ShapeBox.Checked = True
  431. End Sub
  432. Private Sub ShapeCircle_Click()
  433.     MARKSHAPE = "CIRCLE"
  434.     If selDotIndex = -1 Then
  435.         Exit Sub
  436.     Else
  437.         DrawBullet selDotIndex, MARKCOLOR, "CIRCLE"
  438.     End If
  439.     ClearShapeChecks
  440.     ShapeCircle.Checked = True
  441. End Sub
  442. Private Sub ShapeDot_Click()
  443.     MARKSHAPE = "DOT"
  444.     If selDotIndex = -1 Then
  445.         Exit Sub
  446.     Else
  447.         DrawBullet selDotIndex, MARKCOLOR, MARKSHAPE
  448.     End If
  449.     ClearShapeChecks
  450.     ShapeDot.Checked = True
  451. End Sub
  452. Private Sub ShapeXBox_Click()
  453.     MARKSHAPE = "XBOX"
  454.     If selDotIndex = -1 Then
  455.         Exit Sub
  456.     Else
  457.         DrawBullet selDotIndex, MARKCOLOR, "XBOX"
  458.     End If
  459.     ClearShapeChecks
  460.     ShapeXBox.Checked = True
  461. End Sub
  462. Private Sub ShowNotes_Click()
  463. On Error Resume Next
  464.     Picture1.AutoRedraw = False
  465.     For i = 1 To maxMarks
  466.         Picture1.CurrentX = Bullet(i).Left + Bullet(i).ScaleWidth
  467.         Picture1.CurrentY = Bullet(i).Top
  468.         Picture1.Print Notes(i)
  469.     Next
  470.     Picture1.AutoRedraw = True
  471. End Sub
  472. Private Sub WhiteDot_Click()
  473.     MARKCOLOR = RGB(255, 255, 255)
  474.     If selDotIndex = -1 Then
  475.         Exit Sub
  476.     Else
  477.         DrawBullet selDotIndex, MARKCOLOR, Bullet(selDotIndex).Tag
  478.     End If
  479.     ClearColorChecks
  480.     WhiteDot.Checked = True
  481. End Sub
  482. Private Sub YellowDot_Click()
  483.     MARKCOLOR = RGB(255, 255, 0)
  484.     If selDotIndex = -1 Then
  485.         Exit Sub
  486.     Else
  487.         DrawBullet selDotIndex, MARKCOLOR, Bullet(selDotIndex).Tag
  488.     End If
  489.     ClearColorChecks
  490.     YellowDot.Checked = True
  491. End Sub
  492. Sub ClearShapeChecks()
  493.     ShapeBox.Checked = False
  494.     ShapeDot.Checked = False
  495.     ShapeCircle.Checked = False
  496.     ShapeXBox.Checked = False
  497. End Sub
  498. Sub ClearColorChecks()
  499.     RedDot.Checked = False
  500.     GreenDot.Checked = False
  501.     BlueDot.Checked = False
  502.     WhiteDot.Checked = False
  503.     BlackDot.Checked = False
  504.     YellowDot.Checked = False
  505. End Sub
  506.