import System
import clr
import sys
import os

clr.AddReference("Ans.UI.Toolkit")
clr.AddReference("Ans.UI.Toolkit.Base")
from Ansys.UI.Toolkit import *

class FolderOpenObj:
    def __init__(self,api,load,prop):
        self.api = api
        self.load = load
        self.prop = prop

    def onactivate(self,load,prop):
        f = prop.Value
        if f==None:
            f=""
        dir = os.path.dirname(f)
        res = FolderBrowserDialog.ShowFolderBrowserDialog(None,dir)
        if res[0]==DialogResult.OK:
            prop.Value = res[1]
            prop.Validate()
        
