/// <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); } }
protected override void OnClick() { IGxObjectFilter myFilter = new GxFilterFileGeodatabasesClass(); string sResult = OpenGXDialog("Open File Geodatabase", myFilter, true); string[] sWorkspaces = sResult.Split(new char[] { ';' }); foreach (string myWorkspace in sWorkspaces) { IWorkspace pWorkspace = OpenWorkspace(myWorkspace); ITable pTable = GetTable(pWorkspace, "Vessel"); if (pTable != null) { RegisterWithGeodatabase(pTable, "OID"); } pTable = GetTable(pWorkspace, "Voyage"); if (pTable != null) { RegisterWithGeodatabase(pTable, "OID"); } CreateRelationshipClass(pWorkspace); CreateCargoDomain(pWorkspace); CreateStatusDomain(pWorkspace); CreateTypeDomain(pWorkspace); } }
private void ConvertToGxObjectFilterCollection(IGxDialog gxDialog, string filter) { IGxObjectFilterCollection filterCollection = gxDialog as IGxObjectFilterCollection; if (filterCollection == null) { return; } if (filter.ToUpper().Contains(".MDB")) { IGxObjectFilter objectFilter = new GxFilterPersonalGeodatabasesClass(); filterCollection.AddFilter(objectFilter, true); } if (filter.ToUpper().Contains(".GDB")) { IGxObjectFilter objectFilter = new GxFilterFileGeodatabasesClass(); filterCollection.AddFilter(objectFilter, true); } }
public static string GetGeodatabaseFromUser() { try { IEnumGxObject enumGxObject = null; IGxObjectFilter gxObjectFilterFGBs = new GxFilterFileGeodatabasesClass(); IGxDialog gxDialog = new GxDialogClass(); IGxObjectFilterCollection gxObjectFilterCollection = (IGxObjectFilterCollection)gxDialog; gxObjectFilterCollection.AddFilter(gxObjectFilterFGBs, false); gxDialog.Title = "Locate Geodatabase"; gxDialog.AllowMultiSelect = false; gxDialog.DoModalOpen(0, out enumGxObject); if (!(enumGxObject == null)) { //we don't allow multiple select so grab the first one IGxObject gxObj = enumGxObject.Next(); string pathToFGDB = gxObj.FullName; return pathToFGDB; } else { //user cancelled return ""; } } catch { return ""; } }