VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "ChanMgr"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
' -----------------------------------------------------------------------------
' This class defines the PropertyManagerPage and its controls.
' -----------------------------------------------------------------------------

Option Explicit

' The PropertyManagerPage
  Private ChanPage                  As SldWorks.PropertyManagerPage2

' The two groups that will contain the controls
  Private ChanGroup1                As SldWorks.PropertyManagerPageGroup

' The ID's for all of the controls
  Const ID_ChanGroup1                As Long = 1
  Const ID_NomSize                   As Long = 2
  Const ID_ChanLength                As Long = 3


' -----------------------------------------------------------------------------
' Create the page and place all of the controls on it.
' -----------------------------------------------------------------------------
Private Sub Layout()

    ' Objects needed to create the PropertyManagerPage
    Dim pageHdlr        As New ChanMgrHdlr
    Dim swControl       As SldWorks.PropertyManagerPageControl
    
    Dim title           As String
    Dim message         As String
    Dim caption         As String
    Dim tip             As String
    Dim listItems(60)   As String
    
    Dim buttonTypes     As Long
    Dim Id              As Long
    Dim options         As Long
    Dim filterArray(1)  As Long
    Dim errors          As Long
    
    Dim controlType     As Integer
    Dim alignment       As Integer
    
    Dim bRet            As Boolean
    
    Dim X               As Integer

    ' Initialize the Page Handler
    ' Pass it a reference to this PropertyManagerPage
    pageHdlr.Init Me
    
    ' Set some variables for the Page
    title = "Channel-Struct-PMP"
    buttonTypes = swPropertyManager_CancelButton + swPropertyManagerOptions_LockedPage
   
    ' Create the PropertyManagerPage
    Set ChanPage = swApp.CreatePropertyManagerPage(title, buttonTypes, pageHdlr, errors)
    
    ' broken:
    '   SPR 154819 - "PropertyManagerPage2::SetMessage returns TRUE but message is not set"
    bRet = ChanPage.SetMessage("Some Message String", swAnnotationVisible)
    Debug.Assert bRet
    
    'Make sure that it was created properly
    If errors = swPropertyManagerPage_Okay Then
        
        'Initial set up of the dialog.
        message = "Information message that can be displayed as necessary."
        ChanPage.SetMessage message, swImportantMessageBox

        'Begin adding the required controls to the dialog.

        'GROUP BOX ------------------------------------------------------------------
        Id = ID_ChanGroup1
        caption = "Channel Size Parameters"
        options = swGroupBoxOptions_Visible + swGroupBoxOptions_Expanded
        Set ChanGroup1 = ChanPage.AddGroupBox(Id, caption, options)
        If Not ChanGroup1 Is Nothing Then
            'Place these controls in the first Group
            
            'CONTROL Combo box  --------------------------------------------------------------------
            Id = ID_NomSize
            controlType = swControlType_Combobox
            caption = "Nominal"
            alignment = swControlAlign_Indent
            options = swControlOptions_Visible + swControlOptions_Enabled
            tip = "Select nominal size."
            Set swControl = ChanGroup1.AddControl(Id, controlType, caption, alignment, options, tip)
            If Not swControl Is Nothing Then
                Set ChanCombo = swControl
                ChanCombo.Height = 50
                listItems(X) = ""
                For X = 0 To ChannelCnt
                  listItems(X + 1) = ChannelDef(X, 0)
                Next X
                ChanCombo.AddItems (listItems)
                ChanCombo.CurrentSelection = 1
            End If

            'CONTROL Number box - Box Height ----------------------------------------
            Id = ID_ChanLength
            controlType = swControlType_Numberbox
            caption = "Length"
            alignment = swControlAlign_Indent
            options = swControlOptions_Visible + swControlOptions_Enabled
            tip = "Enter length."
            Set swControl = ChanGroup1.AddControl(Id, controlType, caption, alignment, options, tip)
            If Not swControl Is Nothing Then
                Set ChanNumbr = swControl
                ChanNumbr.SetRange swNumberBox_Length, -1000#, 1000#, 0.0001, True
                ChanNumbr.Value = Part.Parameter("Length@Channel").SystemValue
            End If

        End If
    Else
        swApp.SendMsgToUser2 "There was an error creating the Property Manager Page", _
                              swMbInformation, swMbOk
    End If
End Sub

' -----------------------------------------------------------------------------
' Update model based on user selections.
' -----------------------------------------------------------------------------
Public Sub UpdateChanSize(ChanSelect As Long)
    Part.Parameter("Height@Profile").SystemValue = ChannelDef(ChanSelect, 2) / 25.4
    Part.Parameter("WebThick@Profile").SystemValue = ChannelDef(ChanSelect, 4) / 25.4
    Part.Parameter("Width@Profile").SystemValue = ChannelDef(ChanSelect, 5) / 25.4
    Part.Parameter("ToeThick@Profile").SystemValue = ChannelDef(ChanSelect, 6) / 25.4
    ' Rebuild model
    Part.ForceRebuild3 True
    ' Zoom view to fit model
    Part.ViewZoomtofit
End Sub

' -----------------------------------------------------------------------------
' Update model based on user selections.
' -----------------------------------------------------------------------------
Public Sub UpdateChanLength()
    Part.Parameter("Length@Channel").SystemValue = ChanNumbr.Value
    ' Rebuild model
    Part.ForceRebuild3 True
    ' Zoom view to fit model
    Part.ViewZoomtofit
End Sub

' -----------------------------------------------------------------------------
' Display the Property Manager Page
' -----------------------------------------------------------------------------
Public Sub Show()
    Dim nRetVal             As Long
    Dim bRet                As Boolean
    nRetVal = ChanPage.Show
    ' broken:
    '   SPR 154819 - "PropertyManagerPage2::SetMessage returns TRUE but message is not set"
    bRet = ChanPage.SetMessage("Some Message String", swAnnotationVisible)
    Debug.Assert bRet
End Sub

' -----------------------------------------------------------------------------
' Initialize and generate the PropertyManagrePage and it's controls
' -----------------------------------------------------------------------------
Private Sub Class_Initialize()
    Layout
End Sub

Private Sub Class_Terminate()
    '
End Sub


