ArcGIS AddIn Development: How to invoke a form that selects workspaces in ArcMap

Source: Internet
Author: User

The sample code is as follows:

  Public StaticIworkspacename Browseworkspace (inthwnd outiworkspace ws) {igxobjectfiltercollection ipfilters=NewGxdialogclass (); //igxobjectfilter ipFilter1 = new Gxfilterfeaturedatasetsclass (); //feature DataSet, when exporting, the Ifeatureclassconverter object cannot be written to the dataset, where it is hidden//Ipfilters.addfilter (ipfilter1,false);Igxobjectfilter IFILT2 =NewGxfilterworkspacesclass ();//Database workspace, this class is ambiguous, do not know what the specific pointIpfilters.addfilter (IFILT2,false); Igxobjectfilter IpFilter3=NewGxfilterfilefolderclass ();//File WorkspaceIpfilters.addfilter (IpFilter3,false); Igxdialog Pgdialog=(Igxdialog) ipfilters; Pgdialog.rememberlocation=true; Pgdialog.title="Please select a working space"; Pgdialog.allowmultiselect=false; Ienumgxobject Presultenum=NULL; //iworkspace ws = NULL;WS =NULL; Iworkspacename WSN=NULL; if(Pgdialog.domodalopen (hwnd, outPresultenum) && Presultenum! =NULL) {Igxobject gxobj=Presultenum.next (); if(Gxobj isigxdatabase) {igxdatabase Gxdb= Gxobj asigxdatabase; if(Gxdb! =NULL) {ws=Gxdb.workspace; WSN=Gxdb.workspacename; }                  }                Else if(Gxobj isIgxfolder) {                    //Todo:figure out what to decide which workspace to get for//a particular folder (Shapefiles, raster etc.) //Ienumname enumname = ((Igxfolder) gxobj).                    Filesystemworkspacenames; //For now just assume we want a shapefile ...Iworkspacefactory WSF =NewESRI.                    ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass (); WS=wsf. Openfromfile (((igxfile) gxobj).                    Path, HWND); Idataset Poutdataset= ws asIdataset; WSN= Poutdataset.fullname asIworkspacename; }                Else if(Gxobj isIgxdataset) {                    //If the dataset workspaceIgxdataset Gxds = Gxobj asIgxdataset; if(Gxds! =NULL) {ws=GxDs.Dataset.Workspace; WSN=GxDs.DatasetName.WorkspaceName;            }} marshal.finalreleasecomobject (Presultenum);            } pGDialog.InternalCatalog.Close ();                        Marshal.finalreleasecomobject (Pgdialog); returnWSN; }

The code above can be expanded to call the ArcMap Add Layer window, etc.

ArcGIS AddIn Development: How to invoke a form that selects workspaces in ArcMap

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.