'==============================================================================
'   WARNING!!  This file is overwritten by the UIStyler each time the Styler
'   file is saved.
'
'       Filename:  Box.vb
'
'        This file was generated by the NX User Interface Styler
'        Created by: Thomas
'        Version: NX 5
'              Date: 09-25-2007
'              Time: 23:41
'
'   This template file is overwritten each time the UIStyler dialog is
'   saved.  Any modifications to this file will be lost.
'==============================================================================


'==============================================================================
'  Purpose:  This TEMPLATE file contains VB.NET source to guide you in the
'  construction of your NX Open application dialog. The generation of your
'  dialog file (.dlg extension) is the first step towards dialog construction
'  within NX.  You must now create a NX Open application that
'  utilizes this file (.dlg).


'  The information in this file provides you with the following:
'
'  1.  Help on how to load and display your UIStyler dialog in NX
'      using APIs provided in NXOpen.UIStyler namespace
'  2.  The empty callback methods (stubs) associated with your dialog items
'      have also been placed in this file. These empty methods have been
'      created simply to start you along with your coding requirements.
'      The method name, argument list and possible return values have already
'      been provided for you.
'==============================================================================


'------------------------------------------------------------------------------
' These imports are needed for the following template code
'------------------------------------------------------------------------------
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UIStyler


'------------------------------------------------------------------------------
' Represents UI Styler application class
'------------------------------------------------------------------------------
Public Class Box
    ' class members
    Private Shared theSession As Session
    Private Shared theUI As UI
    Public Shared theBox As Box
    Private theDialog As Dialog
    Private roomDialogfenster As NXOpen.UIStyler.UnknownType
    Private roomRoomheight As NXOpen.UIStyler.IntegerItem
    Private roomHeight As NXOpen.UIStyler.LabelItem
    Private roomRoomwidth As NXOpen.UIStyler.IntegerItem
    Private roomWidth As NXOpen.UIStyler.LabelItem
    Private roomRoomlength As NXOpen.UIStyler.IntegerItem
    Private roomLength As NXOpen.UIStyler.LabelItem
    Public Shared isDisposeCalled As Boolean
    

#Region " UI Styler Dialog Designer generator code " 
'------------------------------------------------------------------------------
' Constructor for NX Styler class
'------------------------------------------------------------------------------
    Public Sub New()
        Try
            theSession = Session.GetSession()
            theUI = UI.GetUI()
            theDialog = theUI.Styler.CreateStylerDialog("box.dlg")
            InitializeUIStylerDialog()
            isDisposeCalled = False
        Catch ex As NXException
            ' ---- Enter your exception handling code here -----
            ' theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message)
        End Try
    End Sub

'------------------------------------------------------------------------------
' This method is required for UI styler dialog creation
'------------------------------------------------------------------------------
    Private Sub InitializeUIStylerDialog()
    '------------------------------------------------------------------------------
    ' The following code snippets initializes all the styler items and associate
    ' respective callbacks. Attributes of the styler item can be accessed and
    ' modified only after calling Show() or RegisterWithUiMenu().
    '------------------------------------------------------------------------------
        Try
            roomDialogfenster = theDialog.GetStylerItem("Dialogfenster", NXOpen.UIStyler.Dialog.ItemType.UnknownType)
            roomDialogfenster.AddConstructHandler(AddressOf Refresh, False)
            roomDialogfenster.AddApplyHandler(AddressOf ROOM, False)
            roomRoomheight = theDialog.GetStylerItem("ROOMHEIGHT", NXOpen.UIStyler.Dialog.ItemType.IntegerItem)
            roomHeight = theDialog.GetStylerItem("HEIGHT", NXOpen.UIStyler.Dialog.ItemType.LabelItem)
            roomRoomwidth = theDialog.GetStylerItem("ROOMWIDTH", NXOpen.UIStyler.Dialog.ItemType.IntegerItem)
            roomWidth = theDialog.GetStylerItem("WIDTH", NXOpen.UIStyler.Dialog.ItemType.LabelItem)
            roomRoomlength = theDialog.GetStylerItem("ROOMLENGTH", NXOpen.UIStyler.Dialog.ItemType.IntegerItem)
            roomLength = theDialog.GetStylerItem("LENGTH", NXOpen.UIStyler.Dialog.ItemType.LabelItem)
        Catch ex As NXException
            ' ---- Enter your exception handling code here -----
            ' theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message)
        End Try
    End Sub

#End Region

' -------------------------- MENUBAR HOOKUP HELP Example ----------------------
' To launch this dialog from a NX menubar, you must follow the steps below:


'      1)Add the following lines to your MenuScript file in order to
'        associate a menu bar button with your dialog.  In this
'        example, a cascade menu will be created and will be
'        located just before the Help button on the main menubar.
'        The button, BOX_BTN is set up to launch your dialog and
'        will be positioned as the first button on your pulldown menu.
'        If you wish to add the button to an existing cascade, simply
'        add the 3 lines between MENU LAUNCH_CASCADE and END_OF_MENU
'        to your menuscript file.

'        The MenuScript file requires an extension of ".men".
'        Make sure that you add the extension to the file and place
'        the file in your startup directory:
'             $UGII_USER_DIR/startup or
'             $UGII_SITE_DIR/startup or
'             $UGII_VENDOR_DIR/startup directory

'        Move the contents between the dashed lines to your Menuscript file.
'        !-----------------------------------------------------------------------------
'        VERSION 120
' 
'        EDIT UG_GATEWAY_MAIN_MENUBAR
' 
'        BEFORE UG_HELP
'        CASCADE_BUTTON UISTYLER_DLG_CASCADE_BTN
'        LABEL Dialog Launcher
'        END_OF_BEFORE
' 
'        MENU UISTYLER_DLG_CASCADE_BTN
'        BUTTON BOX_BTN
'        LABEL Display Box dialog
'        ACTIONS box.dlg
'        END_OF_MENU
'        !-----------------------------------------------------------------------------

'      2)Issue a call to the function, RegisterWithUiMenu() from the Startup()
'        as shown below.
'        To use this call, remove the conditional definitions:
'             #If MENUBAR_COMMENTED_OUT Then
'             #End If

'      3)Place your compiled and linked DLL in 
'             $UGII_USER_DIR/startup or
'             $UGII_SITE_DIR/startup or
'             $UGII_VENDOR_DIR/startup directory.

'       NOTE:  The shared libraries must contain the proper extension .dll
'       to make ensure that it is recognized by the MenuScript.  If it does not
'       have the proper extension, it will NOT be recognized by MenuScript.

'       The action name you have provided in your MenuScript must correspond to
'       to the dialog name provided in the action structure.  This MUST match inorder
'       to bind your dlg file to your MenuScript button.

'      4)Copy your UIStyler dialog file to the proper directory.
'        All dialog files (.dlg) must be located in 
'             $UGII_USER_DIR/application or
'             $UGII_SITE_DIR/application or
'             $UGII_VENDOR_DIR/application directory
'------------------------------------------------------------------------------
#If MENUBAR_COMMENTED_OUT Then

    Public Shared Function Startup() As Integer
        Try
            theBox = New Box()
            ' The following method registers the dialog with a menu item
            theBox.RegisterWithUiMenu()

            Startup = 0

        Catch ex As NXException
            ' ---- Enter your exception handling code here -----
            ' theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message)
        End Try
    End Function ' Startup ends

    '------------------------------------------------------------------------------
    ' The flag "isTopDialog", informs menubar about the dialog location.
    ' This flag MUST match the resource set in the dialog.
    ' DO NOT ASSUME that changing this field will update the location of the dialog.
    ' Please use the UIStyler to indicate the position of the dialog.
    '------------------------------------------------------------------------------
    Public Sub RegisterWithUiMenu()
        Try
            Dim isTopDialog As boolean = False
            theDialog.RegisterWithUiMenu(isTopDialog)
        Catch ex As NXException
            ' ---- Enter your exception handling code here -----
            ' theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message)
        End Try
    End Sub
#End If ' MENUBAR_COMMENTED_OUT


' --------------- DIALOG CREATION FROM A CALLBACK HELP Example -----------------
' If you wish to have this dialog displayed from the callback of another
' UIStyler dialog, you should:


'      1)Make sure that the callback of your UIStyler dialog is
'        designated as a dialog building callback.
'      2)Remove the conditional definitions:
'             #If DISPLAY_FROM_CALLBACK Then
'             #End If

'      3)Your callback should issue a call to this method.


' All dialog files must be located in
'             $UGII_USER_DIR/application or
'             $UGII_SITE_DIR/application or
'             $UGII_VENDOR_DIR/application directory
'------------------------------------------------------------------------------
#If DISPLAY_FROM_CALLBACK Then

    Public Shared Sub <enter the name of your function>(ByRef response As NXOpen.UIStyler.DialogResponse)
        Try
            theBox = New Box()
            ' The following method shows the dialog immediately
            response = theBox.Show()
            Box.theBox.Dispose()
        Catch ex As NXException
            ' ---- Enter your exception handling code here -----
            ' theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message)
        End Try
    End Sub

#End If ' DISPLAY_FROM_CALLBACK


'---------------- DIALOG CREATION FROM A USER EXIT HELP Example ---------------
' An example is shown below to create this dialog from a user exit.
' All dialog files must be located in
'             $UGII_USER_DIR/application or
'             $UGII_SITE_DIR/application or
'             $UGII_VENDOR_DIR/application directory


'      1)Remove the conditional definitions:
'             #If DISPLAY_FROM_USER_EXIT Then
'             #End If

'      2)Add a user exit to the method name below, for example, Main().
'      3)Consider how your shared library will be unloaded.  Take a look
'        at the method GetUnloadOption().
'------------------------------------------------------------------------------
#If DISPLAY_FROM_USER_EXIT Then

    Public Shared Sub <enter a valid user exit here> ()
        Try
            Dim response As NXOpen.UIStyler.DialogResponse
            ' For Journal play back uncommet calls for LockAccess and UnlockAccess
            ' UI.GetUI().LockAccess()
            theBox = New Box()
            ' The following method shows the dialog immediately
            response = theBox.Show()
            theBox.Dispose()
        Catch ex As NXException
            ' ---- Enter your exception handling code here -----
            ' theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message)
        Finally
            ' theUI.UnlockAccess()
        End Try
    End Sub ' User exit ends

    '------------------------------------------------------------------------------
    ' This method specifies how a shared image is unloaded from memory
    ' within NX. This method gives you the capability to unload an
    ' internal NX Open application or user  exit from NX. Specify any
    ' one of the three constants as a return value to determine the type
    ' of unload to perform:
    

    '    Immediately : unload the library as soon as the automation program has completed
    '    Explicitly  : unload the library from the "Unload Shared Image" dialog
    '    AtTermination : unload the library when the NX session terminates
    

    ' NOTE:  A program which associates NX Open applications with the menubar
    ' MUST NOT use this option since it will UNLOAD your NX Open application image
    ' from the menubar.
    '------------------------------------------------------------------------------
    Public Shared Function GetUnloadOption(ByVal arg As String) As Integer
        ' Return code to indicate this library can be unloaded
        ' by the user.
        Return CType(Session.LibraryUnloadOption.Explicitly, Integer)
        ' Return CType(Session.LibraryUnloadOption.Immediately, Integer)
        ' Return CType(Session.LibraryUnloadOption.AtTermination, Integer)
    End Function

    '------------------------------------------------------------------------------
    ' Following method cleanup any housekeeping chores that may be needed.
    ' This method is automatically called by NX.
    '------------------------------------------------------------------------------
    Public Shared Function UnloadLibrary(ByVal arg As String) As Integer
        Try
            theBox.Dispose()
            Return 0
        Catch ex As NXException
            ' ---- Enter your exception handling code here -----
            ' theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message)
        End Try
    End Function

#End If ' DISPLAY_FROM_USER_EXIT


    '------------------------------------------------------------------------------
    ' This method shows the dialog on the screen
    '------------------------------------------------------------------------------
    Public Function Show() As NXOpen.UIStyler.DialogResponse
        Try
            Show = theDialog.Show()
        Catch ex As NXException
            ' ---- Enter your exception handling code here -----
            ' theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message)
        End Try
    End Function


    '------------------------------------------------------------------------------
    ' Following method disposes all the class members
    '------------------------------------------------------------------------------
    Sub Dispose()
        Try
            If (isDisposeCalled = False) Then
                roomDialogfenster.Dispose()
                roomRoomheight.Dispose()
                roomHeight.Dispose()
                roomRoomwidth.Dispose()
                roomWidth.Dispose()
                roomRoomlength.Dispose()
                roomLength.Dispose()
                theDialog.Dispose()
            End If
            isDisposeCalled = True
        Catch ex As NXException
            ' ---- Enter your exception handling code here -----
            ' theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message)
        End Try
    End Sub

    '------------------------------------------------------------------------------
    '------------------------- UIStyler Callback Functions ------------------------
    '------------------------------------------------------------------------------


    '------------------------------------------------------------------------------
    ' Callback Name: Refresh
    ' Following callback is associated with the "roomDialogfenster" Styler item.
    ' Input: eventObject - object of UIStyler.StylerEvent class
    '------------------------------------------------------------------------------
    Public Function Refresh(ByVal eventObject As NXOpen.UIStyler.StylerEvent) As NXOpen.UIStyler.DialogState
        Try
            

            ' ---- Enter your callback code here -----
            

        Catch ex As NXException
            ' ---- Enter your exception handling code here -----
            ' theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message)
        End Try
        ' Callback acknowledged, do not terminate dialog
        Refresh = NXOpen.UIStyler.DialogState.ContinueDialog
        ' A return value of NXOpen.UIStyler.DialogState.ExitDialog will not be accepted
        ' for this callback type. You must continue dialog construction.
    End Function

    '------------------------------------------------------------------------------
    ' Callback Name: ROOM
    ' Following callback is associated with the "roomDialogfenster" Styler item.
    ' Input: eventObject - object of UIStyler.StylerEvent class
    '------------------------------------------------------------------------------
    Public Function ROOM(ByVal eventObject As NXOpen.UIStyler.StylerEvent) As NXOpen.UIStyler.DialogState
        Try
            

            ' ---- Enter your callback code here -----
            

        Catch ex As NXException
            ' ---- Enter your exception handling code here -----
            ' theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message)
        End Try
        ' Callback acknowledged, do not terminate dialog
        ' A return value of NXOpen.UIStyler.DialogState.ExitDialog will not be accepted
        ' for this callback type. You must respond to your apply button.
        ROOM = NXOpen.UIStyler.DialogState.ContinueDialog
    End Function

End Class
