public void ShowRasterDatasetBrowser(int handle, out IEnumGxObject ipSelectedObjects) { IGxObjectFilterCollection ipFilterCollection = new GxDialogClass(); IGxObjectFilter ipFilter1 = new GxFilterRasterDatasetsClass(); ipFilterCollection.AddFilter(ipFilter1, true); IGxDialog ipGxDialog = (IGxDialog)(ipFilterCollection); ipGxDialog.RememberLocation = true; ipGxDialog.Title = "Open"; ipGxDialog.AllowMultiSelect = false; ipGxDialog.RememberLocation = true; ipGxDialog.DoModalOpen((int)(Handle.ToInt32()), out ipSelectedObjects); return; }
protected bool ShowOpenFileDialog(IGxDialog pGxDialog, out string path, out string name, out string genericName, out string datasetType) { IEnumGxObject pEnumGX; IGxObject pEnumGxObj; path = ""; name = ""; genericName = ""; datasetType = ""; pGxDialog.Title = "Save File as:"; if (!pGxDialog.DoModalOpen(0, out pEnumGX)) { return(false); } datasetType = pGxDialog.ObjectFilter.Name; pEnumGX.Reset(); pEnumGxObj = pEnumGX.Next(); genericName = pEnumGxObj.Name.Substring(0, pEnumGxObj.Name.IndexOf(".")); name = pEnumGxObj.Name; path = pGxDialog.FinalLocation.FullName; return(true); }
/// <summary> /// Runs a raster file dialog box with the specified owner. /// </summary> /// <returns></returns> public DialogResult ShowDialog() { fileName = ""; fileNames = null; switch (this.type) { case FileDialogType.Open: IEnumGxObject enumGxObject = new GxObjectArrayClass(); if (dialog.DoModalOpen(0, out enumGxObject)) { IGxObjectArray gxObjectArray = (IGxObjectArray)enumGxObject; fileName = gxObjectArray.Item(0).FullName; fileNames = new string[gxObjectArray.Count]; for (int i = 0; i < gxObjectArray.Count; i++) { fileNames[i] = gxObjectArray.Item(i).FullName; } return(DialogResult.OK); } break; case FileDialogType.Save: if (dialog.DoModalSave(0)) { fileName = dialog.Name; string extension = GetExtension(dialog.ObjectFilter.Name); if ((Path.GetExtension(fileName) != "") && (Path.GetExtension(fileName).ToLower() == extension.Substring(1))) { fileName = Path.GetFileNameWithoutExtension(fileName); } fileName = dialog.FinalLocation.FullName + "\\" + fileName + extension; return(DialogResult.OK); } break; } return(DialogResult.Cancel); }
private void btnSelect_Click(object sender, EventArgs e) { if (CheckGxObjectFilter(_filter)) { IGxDialog dialog = (GxDialog)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("EAB9CE2A-E777-11D1-AEE7-080009EC734B"))); dialog.AllowMultiSelect = false; dialog.ButtonCaption = "选择数据库"; ConvertToGxObjectFilterCollection(dialog, _filter); IEnumGxObject selection = null; if (dialog.DoModalOpen(0, out selection)) { IGxObject obj = selection.Next(); if (obj != null) { _fileName = obj.FullName; string ext = obj.Name.Substring(obj.Name.Length - 4).ToUpper(); if (ext.ToUpper() == ".GDB") { _workspace = new FileGDBWorkspaceFactoryClass().OpenFromFile(_fileName, 0); } else if (ext.ToUpper() == ".MDB") { _workspace = new AccessWorkspaceFactoryClass().OpenFromFile(_fileName, 0); } } txtPath.Text = _fileName; } } else { OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = false; dialog.Title = @"请选择文件"; dialog.Filter = _filter; if (dialog.ShowDialog() == DialogResult.OK) { _fileName = dialog.FileName; txtPath.Text = _fileName; } } }
private void btnBrowse_Click(object sender, System.EventArgs e) { try { IGxDialog dialog = GetGxDialog(); IEnumGxObject gxObjects; dialog.DoModalOpen(this.Handle.ToInt32(), out gxObjects); IGxDatabase gxDatabase = gxObjects.Next() as IGxDatabase; if (gxDatabase == null) { return; } connectionType = gxDatabase.IsRemoteDatabase ? ConnectionType.SDE : ConnectionType.PersonalGDB; _propSet = gxDatabase.WorkspaceName.ConnectionProperties; ReadNewConnectionProperties(_propSet); PopulateConnectionInfoLabel(); } catch (Exception exc) { Trace.WriteLine(exc.ToString()); } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { // if (context == null) { return(null); } if (context.Instance == null) { return(null); } if (provider == null) { return(null); } // Cannot handle multiple objects if (context.Instance is object[]) { return(null); } // Do ArcGIS Desktop Test object dialog = null; try { dialog = new GxDialogClass(); } catch { } if (dialog == null) { MessageBox.Show( Resources.TEXT_NO_ARCGIS_DESKTOP, Resources.TEXT_APPLICATION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); return(null); } // Create GxObjectFilter for GxDialog IGxObjectFilter gxObjectFilter = new GxFilterWorkspacesClass(); // Create GxDialog IGxDialog gxDialog = (IGxDialog)dialog; gxDialog.AllowMultiSelect = false; gxDialog.ButtonCaption = Resources.TEXT_SELECT; gxDialog.ObjectFilter = gxObjectFilter; gxDialog.RememberLocation = true; gxDialog.Title = Resources.TEXT_SELECT_EXISTING_GEODATABASE; // Declare Enumerator to hold selected objects IEnumGxObject enumGxObject = null; // Open Dialog if (!gxDialog.DoModalOpen(0, out enumGxObject)) { return(null); } if (enumGxObject == null) { return(null); } // Get Selected Object (if any) IGxObject gxObject = enumGxObject.Next(); if (gxObject == null) { return(null); } //if (!gxObject.IsValid) { return null; } // Get GxDatabase if (!(gxObject is IGxDatabase)) { return(null); } IGxDatabase gxDatabase = (IGxDatabase)gxObject; // Get IWorkspace ESRI.ArcGIS.Geodatabase.IWorkspaceName workspaceName = gxDatabase.WorkspaceName; // Return Arguments return(workspaceName); }