home *** CD-ROM | disk | FTP | other *** search
/ Program Metropolis - Software Boutique 95 / SOFTWARECD.iso / visio3 / disk4 / progress.fr_ / progress.bin (.txt)
Encoding:
Visual Basic Form  |  1994-08-09  |  12.4 KB  |  381 lines

  1. VERSION 2.00
  2. Begin Form frmProgress 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    ClientHeight    =   1605
  6.    ClientLeft      =   5400
  7.    ClientTop       =   5955
  8.    ClientWidth     =   4455
  9.    ForeColor       =   &H00000000&
  10.    Height          =   2010
  11.    Left            =   5340
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   1605
  16.    ScaleWidth      =   4455
  17.    Top             =   5610
  18.    Width           =   4575
  19.    Begin SSPanel Panel3D1 
  20.       BackColor       =   &H00C0C0C0&
  21.       BevelOuter      =   1  'Inset
  22.       Caption         =   "Panel3D1"
  23.       FloodType       =   1  'Left To Right
  24.       Font3D          =   0  'None
  25.       ForeColor       =   &H00404040&
  26.       Height          =   375
  27.       Left            =   120
  28.       TabIndex        =   4
  29.       Top             =   1080
  30.       Width           =   4215
  31.    End
  32.    Begin CommandButton Cancel 
  33.       Caption         =   "&Cancel"
  34.       Height          =   375
  35.       Left            =   3360
  36.       TabIndex        =   1
  37.       Top             =   120
  38.       Width           =   975
  39.    End
  40.    Begin Label Label3 
  41.       BackStyle       =   0  'Transparent
  42.       ForeColor       =   &H00000000&
  43.       Height          =   255
  44.       Left            =   120
  45.       TabIndex        =   3
  46.       Top             =   600
  47.       Width           =   4215
  48.    End
  49.    Begin Label Label2 
  50.       BackStyle       =   0  'Transparent
  51.       ForeColor       =   &H00000000&
  52.       Height          =   255
  53.       Left            =   120
  54.       TabIndex        =   2
  55.       Top             =   360
  56.       Width           =   3135
  57.    End
  58.    Begin Label Label1 
  59.       BackStyle       =   0  'Transparent
  60.       Caption         =   "Creating report..."
  61.       ForeColor       =   &H00000000&
  62.       Height          =   255
  63.       Left            =   120
  64.       TabIndex        =   0
  65.       Top             =   120
  66.       Width           =   3135
  67.    End
  68. Option Explicit
  69. Sub Cancel_Click ()
  70.     End
  71. End Sub
  72. Sub DrawCreate ()
  73.     Dim stencil As Object             ' stencil document
  74.     Dim page As Object
  75.     Dim shape As Object
  76.     Dim master As Object
  77.     Dim masters As Object
  78.     Dim footerRight As Object
  79.     Dim label As Object
  80.     Dim text As Object
  81.     Dim inst As Object                  ' instance
  82.     Dim xLeft
  83.     Dim yTop
  84.     Dim xRight
  85.     Dim yBottom
  86.     Dim row
  87.     Dim col
  88.     Dim pageNumber
  89.     Dim masterIndex
  90.     Dim stencilName
  91.     Dim pageName
  92.     Dim stat
  93.     ' Get stencil
  94.     '
  95.     Set stencil = g_AppVisio.Documents(gDoc.filename)
  96.     If stencil.Title = "" Then
  97.         stencilName = stencil.Name
  98.     Else
  99.         stencilName = stencil.Title
  100.     End If
  101.         
  102.     stat = DrawYield(stencilName, STR_BACKGROUND, "")
  103.     ProgressGauge (5)
  104.     ' Compute page count
  105.     '
  106.     Set masters = stencil.masters
  107.     gDoc.masters = masters.Count
  108.     gDoc.pageCount = gDoc.masters \ gGrid.masters
  109.     If (gDoc.masters Mod gGrid.masters) > 0 Then
  110.         gDoc.pageCount = gDoc.pageCount + 1
  111.     End If
  112.     ' Draw header on background page
  113.     '
  114.     If gDoc.Header = True Then
  115.         xLeft = gPage.LeftMargin
  116.         xRight = gPage.PageWidth - gPage.RightMargin
  117.         yTop = gPage.PageHeight - gPage.TopMargin
  118.         yBottom = yTop - gPage.Header / 6
  119.         Set shape = gPageBack.DrawRectangle(xLeft, yTop, xRight, yBottom)
  120.         shape.FillStyle = "Black fill"
  121.         yTop = yBottom
  122.         yBottom = gPage.PageHeight - gPage.TopMargin - gPage.Header
  123.         Set shape = gPageBack.DrawRectangle(xLeft, yTop, xRight, yBottom)
  124.         shape.Style = "_Header"
  125.         shape.text = stencilName
  126.     End If
  127.     stat = DrawYield("", "", "")
  128.     ProgressGauge (10)
  129.     ' Draw left footer on background page.
  130.     ' The left footer includes the line at the bottom of the page.
  131.     '
  132.     If gDoc.Footer = True Then
  133.         xLeft = gPage.LeftMargin
  134.         xRight = gPage.PageWidth - gPage.RightMargin
  135.         yBottom = gPage.BottomMargin
  136.         yTop = yBottom + gPage.Footer
  137.         Set shape = gPageBack.DrawLine(xLeft, yTop, xRight, yTop)
  138.         shape.Style = "_FootLeft"
  139.         shape.text = UCase(gDoc.filename)
  140.     End If
  141.     stat = DrawYield("", "", "")
  142.     ProgressGauge (15)
  143.     ' Create property masters
  144.     '
  145.     If gDoc.properties = True Then
  146.         ' Create text master
  147.         '
  148.         xRight = gGrid.ColWidth - gPage.LabelWidth
  149.         Set shape = gPageBack.DrawRectangle(0, 0, xRight, 0)
  150.         shape.Style = "_PropText"
  151.         shape.text = "Name:" & Chr(10) & Chr(10) & "Prompt:"
  152.         
  153.         ' Drop text master into local stencil
  154.         '
  155.         Set text = gDocDraw.Drop(shape, 0, 0)
  156.         
  157.         ' Create label master
  158.         '
  159.         shape.Cells("Width").formula = gPage.LabelWidth
  160.         shape.Style = "_PropLabel"
  161.         ' Drop label master into local stencil
  162.         '
  163.         Set label = gDocDraw.Drop(shape, 0, 0)
  164.         shape.[delete]
  165.     End If
  166.     stat = DrawYield("", "", "")
  167.     ProgressGauge (20)
  168.     ' Draw grid
  169.     '
  170.     If gDoc.gridlines = True Then
  171.         ' Draw vertical gridlines
  172.         '
  173.         For col = 0 To gGrid.cols - 2
  174.             xLeft = gGridArray(0, col).Right
  175.             xRight = xLeft
  176.             yTop = gGridArray(gGrid.rows - 1, col).Top
  177.             yBottom = gGridArray(0, col).Bottom
  178.             Set shape = gPageBack.DrawLine(xLeft, yTop, xRight, yBottom)
  179.             shape.Style = "_Gridline"
  180.         Next
  181.         ' Draw horizontal gridlines
  182.         '
  183.         For row = 0 To gGrid.rows - 2
  184.             xLeft = gGridArray(row, 0).Left
  185.             xRight = gGridArray(row, gGrid.cols - 1).Right
  186.             yBottom = gGridArray(row, 0).Top
  187.             yTop = yBottom
  188.             Set shape = gPageBack.DrawLine(xLeft, yTop, xRight, yBottom)
  189.             shape.Style = "_Gridline"
  190.         Next
  191.     End If
  192.     stat = DrawYield("", "", "")
  193.     ProgressGauge (25)
  194.     ' Instance each master in stencil
  195.     '
  196.     masterIndex = 1
  197.     For pageNumber = 1 To gDoc.pageCount
  198.         pageName = "Page " & pageNumber & " of " & gDoc.pageCount
  199.         stat = DrawYield("", pageName, "")
  200.         ' Create new page and set its background
  201.         '
  202.         Set page = gDocDraw.Pages.Add
  203.         page.Name = pageName
  204.         page.Background = False
  205.         page.BackPage = gPageBack
  206.         ' Draw right footer on page
  207.         '
  208.         If gDoc.Footer = True Then
  209.             xLeft = gPage.PageWidth / 2
  210.             xRight = gPage.PageWidth - gPage.RightMargin
  211.             yTop = gPage.BottomMargin + gPage.Footer
  212.             Set shape = page.DrawLine(xLeft, yTop, xRight, yTop)
  213.             shape.Style = "_FootRight"
  214.             shape.text = page.Name
  215.         End If
  216.         ' Drop each master on page
  217.         '
  218.         For row = gGrid.rows - 1 To 0 Step -1
  219.             For col = 0 To gGrid.cols - 1
  220.                 If masterIndex > masters.Count Then
  221.                     GoTo fexit
  222.                 End If
  223.                 ' Drop master in the center of the grid
  224.                 '
  225.                 Set master = masters(masterIndex)
  226.                 stat = DrawYield("", "", master.Name)
  227.                 xLeft = gGridArray(row, col).Left + gGrid.ColWidth / 2
  228.                 yTop = gGridArray(row, col).Top - gGrid.RowHeight / 2
  229.                 Set inst = page.Drop(master, xLeft, yTop)
  230.                 If gDoc.properties = True Then
  231.                     ' Drop property label
  232.                     '
  233.                     xLeft = gGridArray(row, col).Left + gPage.LabelWidth / 2
  234.                     yTop = gGridArray(row, col).Top
  235.                     Set shape = page.Drop(label, xLeft, yTop)
  236.                     ' Drop property text
  237.                     '
  238.                     xLeft = gGridArray(row, col).Left + gPage.LabelWidth + (gGrid.ColWidth - gPage.LabelWidth) / 2
  239.                     yTop = gGridArray(row, col).Top
  240.                     Set shape = page.Drop(text, xLeft, yTop)
  241.                     shape.text = master.Name & Chr(10) & Chr(10) & master.prompt
  242.                 End If
  243.                 ' Fit in grid
  244.                 '
  245.                 If gDoc.resize = True Then
  246.                     ' Group the shape if not already a group
  247.                     '
  248.                     If inst.type <> 2 Then
  249.                         inst.Group
  250.                         'Set inst = gWinDraw.Selection.Item(1)
  251.                         Set inst = inst.Parent
  252.                     End If
  253.                     GridFit row, col, inst  ' Resize the shape to fit in grid
  254.                     GridPos row, col, inst  ' Reposition the shape
  255.                 End If
  256.                 ProgressGauge (25 + masterIndex / masters.Count * 75)
  257.                 masterIndex = masterIndex + 1
  258.             Next
  259.         Next
  260.     Next
  261. fexit:
  262.     g_AppVisio.ActiveWindow.DeselectAll
  263.     End
  264. End Sub
  265. Function DrawYield (ByVal stencil As String, ByVal page As String, ByVal master As String)
  266.     If stencil <> "" Then
  267.         label1.Caption = "Stencil:  " & stencil
  268.     End If
  269.     If page <> "" Then
  270.         label2.Caption = "Page:  " & page
  271.     End If
  272.     If master <> "" Then
  273.         label3.Caption = "Master:  " & master
  274.     End If
  275.     DoEvents
  276. End Function
  277. Sub Form_Load ()
  278.     ' Initialize the form.
  279.     '
  280.     formInit frmProgress
  281.     ' Center the form
  282.     '
  283.     Top = screen.Height - Height - 500
  284.     Left = screen.Width - Width - 500
  285. End Sub
  286. Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)
  287.     End
  288. End Sub
  289. Sub Form_Resize ()
  290.     DoEvents
  291.     'Turn off screen updating
  292.     g_AppVisio.ScreenUpdating = False
  293.     DrawCreate
  294.     'Turn off screen updating
  295.     g_AppVisio.ScreenUpdating = True
  296. End Sub
  297. '   Resize shape to fit in grid
  298. Sub GridFit (row, col, shape As Object)
  299.     Dim shapeWidth As Object    ' cell object
  300.     Dim shapeHeight As Object   ' cell object
  301.     Dim gridWidth
  302.     Dim gridHeight
  303.     Dim LabelHeight
  304.     Dim aspectRatio
  305.     ' General computations
  306.     '
  307.     Set shapeWidth = shape.Cells("Width")
  308.     Set shapeHeight = shape.Cells("Height")
  309.     LabelHeight = 0
  310.     If gDoc.properties = True Then
  311.         LabelHeight = gPage.LabelHeight
  312.     End If
  313.     gridWidth = gGrid.ColWidth - 2 * gPage.GridMargin
  314.     gridHeight = gGrid.RowHeight - LabelHeight - 2 * gPage.GridMargin
  315.     ' Is the shape too big for the grid
  316.     '
  317.     If shapeWidth <= gridWidth And shapeHeight <= gridHeight Then
  318.         Exit Sub      ' nothing to do
  319.     End If
  320.     ' Resize shape to fit in grid
  321.     '
  322.     aspectRatio = 1
  323.     If shapeHeight <> 0 Then
  324.         aspectRatio = shapeWidth / shapeHeight
  325.     End If
  326.     '   Adjust height
  327.     '
  328.     If shapeHeight > gridHeight Then
  329.         shapeHeight.FormulaForce = gridHeight
  330.         If shapeWidth > 0 Then
  331.             shapeWidth.FormulaForce = aspectRatio * gridHeight
  332.         End If
  333.     End If
  334.     '   Adjust width
  335.     '
  336.     If shapeWidth > gridWidth Then
  337.         shapeWidth.FormulaForce = gridWidth
  338.         If shapeHeight > 0 Then
  339.             shapeHeight.FormulaForce = gridWidth / aspectRatio
  340.         End If
  341.     End If
  342. End Sub
  343. ' Position shape in grid
  344. Sub GridPos (row, col, shape As Object)
  345.     Dim X
  346.     Dim Y
  347.     X = gGridArray(row, col).Left + gGrid.ColWidth / 2
  348.     Y = gGridArray(row, col).Bottom + gGrid.RowHeight / 2
  349.     If gDoc.properties = True Then
  350.         Y = Y - gPage.LabelHeight / 2
  351.     End If
  352.     shape.SetCenter X, Y
  353. End Sub
  354. Sub ProgressGauge (ByVal percent As Integer)
  355.     Dim X As Single
  356.     Dim Y As Single
  357.     Dim t As String
  358.     ' Set coordinates for the right end of the rectangle
  359.     ' that displays the progress bar.
  360.     '
  361.     'y = Picture1.ScaleHeight
  362.     'x = percent * Picture1.ScaleWidth / 100
  363.     ' Draw the rectangle
  364.     '
  365.     'Picture1.Line (0, 0)-(x, y), QBColor(1), BF
  366.     'Picture1.Line (x, 0)-(Picture1.ScaleWidth, y), QBColor(7), BF
  367.     ' Center and draw the text
  368.     '
  369.     't = percent & "%"
  370.     'Picture1.CurrentY = (Picture1.ScaleHeight - Picture1.TextHeight(t)) / 2
  371.     'Picture1.CurrentX = (Picture1.ScaleWidth - Picture1.TextWidth(t)) / 2
  372.     Panel3D1.FloodPercent = percent
  373.     If percent > 45 Then
  374.         'Picture1.ForeColor = QBColor(1)
  375.         Panel3D1.ForeColor = &HFFFFFF
  376.     'Else
  377.         'Picture1.ForeColor = RGB(255, 255, 255)
  378.     End If
  379.     'Picture1.Print t
  380. End Sub
  381.