public static void batchLoadBarriers(IApplication app)
{
bool fndAsLayer = false;
List<string> strFiles = new List<string>();
IEnumLayer pLays = null;
IProgressDialogFactory pProDFact = null;
IStepProgressor pStepPro = null;
IProgressDialog2 pProDlg = null;
ITrackCancel pTrkCan = null;
IFeatureLayer pFl = null;
IFeatureCursor featureCursor = null;
IFeature feature = null;
IFeatureLayerDefinition2 pFLD = null;
IQueryFilter pQF = null;
ILayer pLay = null;
bool boolCont = true;
int featCount = 0;
try
{
double seTol = ConfigUtil.GetConfigValue("Trace_Click_Point_Tolerence", 5.0);
pLays = Globals.GetLayers(app, "VECTOR");
if (pLays != null)
{
pLay = pLays.Next();
while (pLay != null)
{
if (pLay is IFeatureLayer)
{
if (((IFeatureLayer)pLay).FeatureClass != null)
{
if (((IFeatureLayer)pLay).FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint)
{
strFiles.Add(pLay.Name);
}
}
}
pLay = pLays.Next();
}
//MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsLbl_1") + "\n" + ex.Message, ex.Source);
string strRetVal = Globals.showOptionsForm(strFiles, A4LGSharedFunctions.Localizer.GetString("GeoNetToolsBatchBarrier"), ComboBoxStyle.DropDownList);
if (strRetVal != null && strRetVal != "||Cancelled||")
{
pFl = (IFeatureLayer)Globals.FindLayer(app, strRetVal, ref fndAsLayer);
if (pFl == null)
{
MessageBox.Show(strRetVal + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
return;
}
if (pFl.FeatureClass == null)
{
MessageBox.Show(strRetVal + A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_18d"));
return;
}
pFLD = (IFeatureLayerDefinition2)pFl;
// Create a CancelTracker
pTrkCan = new CancelTrackerClass();
// Create the ProgressDialog. This automatically displays the dialog
pProDFact = new ProgressDialogFactoryClass();
pProDlg = (IProgressDialog2)pProDFact.Create(pTrkCan, 0);
// Set the properties of the ProgressDialog
pProDlg.CancelEnabled = true;
pProDlg.Animation = esriProgressAnimationTypes.esriProgressGlobe;
// Set the properties of the Step Progressor
pStepPro = (IStepProgressor)pProDlg;
pStepPro.MinRange = 0;
pQF = new QueryFilterClass();
if (pFLD.DefinitionExpression.Trim() == "")
{
featCount = pFl.FeatureClass.FeatureCount(null);
}
else
{
pQF.WhereClause = pFLD.DefinitionExpression;
featCount = pFl.FeatureClass.FeatureCount(pQF);
}
if (featCount == 0) { return; }
pStepPro.MaxRange = featCount;
pStepPro.StepValue = 1;
pStepPro.Position = 0;
pStepPro.Message = A4LGSharedFunctions.Localizer.GetString("GeoNetToolsProc_6");
featureCursor = pFl.Search(null, false);
feature = featureCursor.NextFeature();
while (feature != null)
{
if (!boolCont)
{
pStepPro.Hide();
pProDlg.HideDialog();
pStepPro = null;
pProDlg = null;
pProDFact = null;
return;
}
if (A4WaterUtilities.GeoNetTools.AddBarrier(feature.Shape as IPoint, app, seTol, false) == false)
{
return;
}
feature = featureCursor.NextFeature();
pStepPro.Step();
boolCont = pTrkCan.Continue();
}
if (featureCursor != null)
{
Marshal.ReleaseComObject(featureCursor);
}
}
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.Write(ex.Message);
}
finally
{
if (pProDlg != null)
{
pProDlg.HideDialog();
}
pStepPro = null;
pProDlg = null;
pProDFact = null;
pTrkCan = null;
pLays = null;
pFl = null;
featureCursor = null;
feature = null;
pFLD = null;
pQF = null;
pLay = null;
}
}