示例#1
0
        private void button5_Click(object sender, EventArgs e)
        {
            IGxDialog gxd = new GxDialog();

            gxd.AllowMultiSelect = false;
            gxd.ButtonCaption    = "Add";
            gxd.Title            = "Add a GDB";
            gxd.RememberLocation = true;

            IGxObjectFilter filter1 = new GxFilterFileGeodatabases();

            gxd.ObjectFilter = filter1;

            IEnumGxObject enumObj;

            if (gxd.DoModalOpen(ArcMap.Application.hWnd, out enumObj) == false) // show dialog
            {
                return;                                                         // return if clicking on cancel
            }
            IGxObject gxObj   = enumObj.Next();
            int       len1    = gxObj.FullName.Length;
            int       len2    = gxObj.Name.Length;
            string    shpPath = gxObj.FullName.Substring(0);

            IMxDocument mxdoc = ArcMap.Application.Document as IMxDocument;

            textBox5.Text = shpPath;
            output        = shpPath;
        }
示例#2
0
        private void button4_Click(object sender, EventArgs e)
        {
            IGxDialog gxd = new GxDialog();

            gxd.AllowMultiSelect = false;
            gxd.ButtonCaption    = "Add";
            gxd.Title            = "Add a shapefile";
            gxd.RememberLocation = true;

            IGxObjectFilter           filter1 = new GxFilterFileGeodatabases();
            IGxObjectFilter           filter2 = new GxFilterTables();
            IGxObjectFilterCollection filters = gxd as IGxObjectFilterCollection;

            filters.AddFilter(filter1, true);
            filters.AddFilter(filter2, false);

            IEnumGxObject enumObj;

            if (gxd.DoModalOpen(ArcMap.Application.hWnd, out enumObj) == false) // show dialog
            {
                return;                                                         // return if clicking on cancel
            }
            IGxObject gxObj    = enumObj.Next();
            int       len1     = gxObj.FullName.Length;
            int       len2     = gxObj.Name.Length;
            string    shpPath  = gxObj.FullName.Substring(0, len1 - len2);
            string    shpPath2 = gxObj.FullName.Substring(0);

            IMxDocument mxdoc = ArcMap.Application.Document as IMxDocument;

            textBox4.Text = shpPath2;
            population    = shpPath2;
        }
示例#3
0
        private void button2_Click(object sender, EventArgs e)
        {
            IGxDialog gxd = new GxDialog();

            gxd.AllowMultiSelect = false;
            gxd.ButtonCaption    = "Add";
            gxd.Title            = "Add a shapefile";
            gxd.RememberLocation = true;

            IGxObjectFilter           filter1 = new GxFilterFileGeodatabases();
            IGxObjectFilter           filter2 = new GxFilterShapefiles();
            IGxObjectFilterCollection filters = gxd as IGxObjectFilterCollection;

            filters.AddFilter(filter1, true);
            filters.AddFilter(filter2, false);

            IEnumGxObject enumObj;

            if (gxd.DoModalOpen(ArcMap.Application.hWnd, out enumObj) == false) // show dialog
            {
                return;                                                         // return if clicking on cancel
            }
            IGxObject gxObj    = enumObj.Next();
            int       len1     = gxObj.FullName.Length;
            int       len2     = gxObj.Name.Length;
            string    shpPath  = gxObj.FullName.Substring(0, len1 - len2);
            string    shpPath2 = gxObj.FullName.Substring(0);

            IMxDocument mxdoc = ArcMap.Application.Document as IMxDocument;

            IWorkspaceFactory wsf          = new ShapefileWorkspaceFactory();
            IWorkspace        ws           = wsf.OpenFromFile(shpPath, 0);
            IFeatureWorkspace fws          = ws as IFeatureWorkspace;
            IFeatureClass     featureClass = fws.OpenFeatureClass(gxObj.BaseName);
            IFeatureLayer     featureLayer = new FeatureLayer();

            featureLayer.FeatureClass = featureClass;
            ILayer layer = (ILayer)featureLayer;

            layer.Name = gxObj.BaseName;
            mxdoc.AddLayer(layer);
            mxdoc.ActiveView.Refresh();
            mxdoc.UpdateContents();

            textBox2.Text = shpPath2;
            tracts        = shpPath2;
        }
        private void gdbloc_btn_Click(object sender, EventArgs e)
        {
            IEnumGxObject   gxEnumGxObject;
            IGxObjectFilter gxObjectFilter = new GxFilterFileGeodatabases();

            IGxDialog gxDialog = new GxDialog {
                AllowMultiSelect = false, Title = "Select Output GDB", ButtonCaption = "Open"
            };

            gxDialog.ObjectFilter = gxObjectFilter;

            if (gxDialog.DoModalOpen(0, out gxEnumGxObject) && gxEnumGxObject != null)
            {
                IGxObject gxObj = gxEnumGxObject.Next();
                gdbToSaveToTxtBox.Text = gxObj.FullName.ToString();
            }
        }
示例#5
0
        private void cmdBrowse_Click(object sender, EventArgs e)
        {
            // Pick an output file GDB
            IGxDialog       pGxDialog = new GxDialogClass();
            IGxObjectFilter pFilter   = new GxFilterFileGeodatabases();

            pGxDialog.AllowMultiSelect = false;
            pGxDialog.RememberLocation = true;
            pGxDialog.ButtonCaption    = "Select";
            pGxDialog.Title            = "Select Output File Geodatabase";
            pGxDialog.ObjectFilter     = pFilter;

            IEnumGxObject pEnumGxObj;
            bool          pObjSelected = pGxDialog.DoModalOpen(0, out pEnumGxObj);

            if (pObjSelected)
            {
                pEnumGxObj.Reset();
                IGxObject pGxObj = pEnumGxObj.Next();
                txtPath.Text = pGxObj.FullName;
            }
        }
 private void setWorkspaceToolStripMenuItem_Click(object sender, EventArgs e)
 {
     IGxDialog gxDialog = new GxDialog();
     IGxObjectFilter gxObjectFilter_FGDB = new GxFilterFileGeodatabases();
     IGxObjectFilterCollection gxObjectFilterCollection = (IGxObjectFilterCollection)gxDialog;
     gxObjectFilterCollection.AddFilter(gxObjectFilter_FGDB, false);
     if (gxDialog.DoModalSave(0))
     {
         string workspaceName = gxDialog.FinalLocation.FullName + "/" + gxDialog.Name;
         this.label10.Text = workspaceName;
     }
 }