VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Application"
Attribute VB_GlobalNameSpace = True
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
' $8  07/14/02 Corrected menu misspelling.
' $7  07/10/02 Final Release 1.
' $6  07/09/02 Added C.O.V. coordinate system.
' $5  06/28/02 Beta 4. Converted to an addin DLL.
'              Previous versions were SW macro files.
' $4  06/27/02 Beta 3.
' $3  06/25/02 Beta 2.
' $2  06/24/02 Beta 1.
' $1  06/10/02 Created.
' ====================================================================
'  Description: Application
'               Main module for the Volume Properties application.
'       Author: Ray Gorman, Engineering Studio
'               raygorman@att.net, rgorman@EngrStudio.com
'
' ====================================================================
'  Copyright 2002 BlueFin Robotics Corp.
' ====================================================================
'

Implements SWPublished.SwAddin

' SW constants
Const swDocASSEMBLY = 2
'
' application constants
Const asmMenuPosition = 5       ' between Tool and Window on the Assembly menubar
'

' ====================================================================
'  Implementation of methods in SwAddin interface
' ====================================================================

Private Function SwAddin_ConnectToSW(ByVal ThisSW As Object, ByVal Cookie As Long) As Boolean

    ' this is the first method called when SW connects to this add-in

    ' store the application object
    Set swApp = ThisSW
    
    ' store cookie
    iCookie = Cookie

    ' Inform SW about the object that contains the callbacks
    swApp.SetAddinCallbackInfo App.hInstance, Me, iCookie

    AddMenuItems
    GetRegistryOptions

    SwAddin_ConnectToSW = True
End Function

Private Function SwAddin_DisconnectFromSW() As Boolean

    SetRegistryOptions
    RemoveMenuItems

    Set swApp = Nothing
    SwAddin_DisconnectFromSW = True

End Function

' ====================================================================
'  Callback Methods
' ====================================================================

Public Sub OnVolumeProps()
    
    VolumePropsDlg.Show

End Sub

Public Sub OnOptions()
    
    OptionsDlg.Show

End Sub

' ====================================================================
'  Helper Methods
' ====================================================================

Private Sub AddMenuItems()

    swApp.AddMenu swDocASSEMBLY, "BlueFin", asmMenuPosition
    swApp.AddMenuItem2 swDocASSEMBLY, iCookie, "Volume Properties...@BlueFin", -1, "OnVolumeProps", "", "Calculates mass properties including center of volume."
    swApp.AddMenuItem2 swDocASSEMBLY, iCookie, "Options...@BlueFin", -1, "OnOptions", "", "Set mass property options."

End Sub

Private Sub RemoveMenuItems()

    swApp.RemoveMenu swDocASSEMBLY, "BlueFin", ""

End Sub

Private Sub GetRegistryOptions()
   
    ' initializes public variables

    ' get registry options

    iUseLightweight = GetSetting("BlueFin", "Startup", "Lightweight", 0)
    iUseSuppressed = GetSetting("BlueFin", "Startup", "Suppressed", 0)
    iUseCoordSys = GetSetting("BlueFin", "Startup", "CoordSys", 0)

    iUnitsIndex = GetSetting("BlueFin", "Startup", "Units", 2)
    iDecimalPlaces = GetSetting("BlueFin", "Startup", "Decimals", 4)

End Sub

Private Sub SetRegistryOptions()

    ' save registry options

    SaveSetting "BlueFin", "Startup", "Lightweight", iUseLightweight
    SaveSetting "BlueFin", "Startup", "Suppressed", iUseSuppressed
    SaveSetting "BlueFin", "Startup", "CoordSys", iUseCoordSys
    
    SaveSetting "BlueFin", "Startup", "Units", iUnitsIndex
    SaveSetting "BlueFin", "Startup", "Decimals", iDecimalPlaces

End Sub

' End
