Beispiel #1
0
 /// <summary>
 /// Opens a dialog so the user can select an output workspace.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void outputWorkspaceButton_Click(object sender, EventArgs e)
 {
     try
     {
         IGxObjectFilter           geodatabaseFilter = new GxFilterFileGeodatabasesClass();
         IGxDialog                 dlg     = new GxDialogClass();
         IGxObjectFilterCollection filters = (IGxObjectFilterCollection)dlg;
         filters.AddFilter(geodatabaseFilter, false);
         dlg.Title         = "Select the file geodatabase for the output";
         dlg.ButtonCaption = "Select";
         IEnumGxObject objects = null;
         if (dlg.DoModalOpen(0, out objects))
         {
             IGxObject          obj = objects.Next();
             IWorkspaceFactory2 workspaceFactory = new FileGDBWorkspaceFactoryClass();
             IFeatureWorkspace  workspace        = (IFeatureWorkspace)workspaceFactory.OpenFromFile(obj.FullName, 0);
             _transform.SetWorkspace(workspace);
             outputWorkspaceTextBox.Text = obj.Name;
             EnableSave();
         }
     }
     catch (Exception ex)
     {
         ShowError(ex.Message);
     }
 }
        /// <summary>
        /// Opens a dialog so the user can select a workspace.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonOutWS_Click(object sender, EventArgs e)
        {
            try
            {
                IGxObjectFilter           wsFilter = new GxFilterWorkspacesClass();
                IGxDialog                 dlg      = new GxDialogClass();
                IGxObjectFilterCollection filters  = (IGxObjectFilterCollection)dlg;
                filters.AddFilter(wsFilter, false);
                dlg.Title         = "Select File Geodatabase or Shapefile Folder";
                dlg.ButtonCaption = "Select";
                IEnumGxObject objects = null;
                if (dlg.DoModalOpen(0, out objects))
                {
                    IGxObject          obj = objects.Next();
                    IWorkspaceFactory2 workspaceFactory;
                    if (obj.Category == "File Geodatabase")
                    {
                        workspaceFactory = new FileGDBWorkspaceFactoryClass();
                    }
                    else if (obj.Category == "Folder")
                    {
                        workspaceFactory = new ShapefileWorkspaceFactoryClass();
                    }
                    else
                    {
                        ShowError("Not a file geodatabase or shapefile folder.");
                        return;
                    }
                    IFeatureWorkspace workspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile(obj.FullName, 0);
                    _transform.SetWorkspace(workspace);
                    textBoxOutWS.Text = obj.BaseName;
                    _workspaceOK      = true;

                    List <IDatasetName> allNames = _transform.GetFeatureClassNames();
                    listViewData.Items.Clear();
                    for (int i = 0; i < allNames.Count; i++)
                    {
                        AddItemToListViewData(allNames[i]);
                    }
                    FillControlComboBox();
                    SelectComboBoxItem(comboBoxControlPts, _transform.GetWorkspacePath(),
                                       "Control_Points_Unprojected");
                }
                EnableSelectInputs();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }