如何通过ArcObjects对象调用设置工作空间窗体?

AddIN开发,我想通过AO调用设置目标工作空间对话框,没有查到相关接口,求大神指点!
QQ截图20160928133445.png
已邀请:

llc3s

赞同来自: 朱新颖

public static IWorkspace BrowseWorkspace(int hwnd)
        {
            IGxObjectFilterCollection ipFilters = new GxDialogClass();
            IGxObjectFilter ipFilter1 = new GxFilterFeatureDatasetsClass();  //要素数据集
            ipFilters.AddFilter(ipFilter1,false);
            IGxObjectFilter ifilt2 = new GxFilterWorkspacesClass();  //数据库工作空间,此类比较含糊,不知道具体指啥
            ipFilters.AddFilter(ifilt2,false);
            IGxObjectFilter ipFilter3 = new GxFilterFileFolderClass();  //文件工作空间
            ipFilters.AddFilter(ipFilter3,false);


            IGxDialog pGDialog = (IGxDialog)ipFilters;
            pGDialog.RememberLocation = true;
            pGDialog.Title = "请选择工作空间";
            pGDialog.AllowMultiSelect = false;

            IEnumGxObject pResultEnum = null;
            IWorkspace ws = null;
            if (pGDialog.DoModalOpen(hwnd, out pResultEnum) && pResultEnum != null)
            {
                IGxObject gxObj = pResultEnum.Next();
                if (gxObj is IGxDatabase)
                {
                    IGxDatabase gxDB = gxObj as IGxDatabase;
                    if (gxDB != null)
                        ws = gxDB.Workspace;
                }
                else if (gxObj is IGxFolder)
                {
                    //Todo: figure out how to decide which workspace to get for
                    // a particular folder (shapefile, raster etc.)                    
                    //IEnumName enumName = ((IGxFolder)gxObj).FileSystemWorkspaceNames;

                    // for now just assume we want a shapefile ...
                    IWorkspaceFactory wsf = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass();
                    ws = wsf.OpenFromFile(((IGxFile)gxObj).Path, hwnd);
                }
                else if (gxObj is IGxDataset)
                {
                    //如果是数据集工作空间
                    IGxDataset gxDs = gxObj as IGxDataset;
                    if (gxDs != null)
                        ws = gxDs.Dataset.Workspace;
                }
                Marshal.FinalReleaseComObject(pResultEnum);
            }

            pGDialog.InternalCatalog.Close();
            Marshal.FinalReleaseComObject(pGDialog);
            return ws;
        }

朱新颖

赞同来自:

AO中没有提供可以调用该窗体的类。

要回复问题请先登录注册