/// <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); }
/// <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; }