public string PromptUserWithGxDialog(int iParentWindow)
{
//Prep the dialog
if (m_ipSaveAsGxDialog == null)
{
m_ipSaveAsGxDialog = new GxDialog();
IGxObjectFilterCollection ipGxObjFilterCol = (IGxObjectFilterCollection)m_ipSaveAsGxDialog;
ipGxObjFilterCol.RemoveAllFilters();
// Add the filters
ipGxObjFilterCol.AddFilter(new GxFilterFGDBFeatureClasses(), false);
ipGxObjFilterCol.AddFilter(new GxFilterShapefilesClass(), false);
m_ipSaveAsGxDialog.AllowMultiSelect = false;
m_ipSaveAsGxDialog.Title = "Select output";
m_ipSaveAsGxDialog.ButtonCaption = "OK";
m_ipSaveAsGxDialog.RememberLocation = true;
}
else
{
m_ipSaveAsGxDialog.Name = "";
m_ipSaveAsGxDialog.FinalLocation.Refresh();
}
//Show the dialog and get the response
if (m_ipSaveAsGxDialog.DoModalSave(iParentWindow) == false)
return null;
else
{
IGxObject ipGxObject = m_ipSaveAsGxDialog.FinalLocation;
string nameString = m_ipSaveAsGxDialog.Name;
bool replacingObject = m_ipSaveAsGxDialog.ReplacingObject;
string path = m_ipSaveAsGxDialog.FinalLocation.FullName + "\\" + m_ipSaveAsGxDialog.Name;
IGxObject ipSelectedObject = m_ipSaveAsGxDialog.InternalCatalog.SelectedObject;
// user selected an existing featureclass
if (ipSelectedObject != null && ipSelectedObject is IGxDataset)
{
IGxDataset ipGxDataset = (IGxDataset)ipSelectedObject;
IDataset ipDataset = ipGxDataset.Dataset;
// User will be prompted if they select an existing shapefile
if ( ipDataset.Category.Equals("Shapefile Feature Class"))
{
return path;
}
while (DoesFeatureClassExist(ipDataset.Workspace.PathName, m_ipSaveAsGxDialog.Name))
{
if (System.Windows.Forms.MessageBox.Show("You've selected a feature class that already exists. Do you wish to replace it?", "Overwrite Feature Class", System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
{
return m_ipSaveAsGxDialog.FinalLocation.FullName + "\\" + m_ipSaveAsGxDialog.Name;
}
if (m_ipSaveAsGxDialog.DoModalSave(iParentWindow) == false)
{
return null;
}
if (ipSelectedObject != null && ipSelectedObject is IGxDataset)
{
ipGxDataset = (IGxDataset)ipSelectedObject;
ipDataset = ipGxDataset.Dataset;
}
}
return m_ipSaveAsGxDialog.FinalLocation.FullName + "\\" + m_ipSaveAsGxDialog.Name;
}
else
return path;
}
}