I have a form with 3 file paths displayed - before they are displayed there is a function that checks to see if all filepaths are valid - if not an error provider is invoked and flashes a red symbol by the offending filepath. There is a button next to each file path so you can change it to a valid path. All filepath info is stored in XML file too.
I want other controls to be activated if all filepaths are correct - would I use delegate methodology to run many methods at the same time to check filepaths, enable buttons, remove flashing error symbols etc? It doesnt seem right to keep specifiying in my click events etc, to run my ParseFileLoactions() method. See below:
I want other controls to be activated if all filepaths are correct - would I use delegate methodology to run many methods at the same time to check filepaths, enable buttons, remove flashing error symbols etc? It doesnt seem right to keep specifiying in my click events etc, to run my ParseFileLoactions() method. See below:
Code:
private void ParseFileLocations()
{
XmlNodeList xmlNodeList = _doc.SelectNodes("//filesettings");
foreach (XmlNode item in xmlNodeList)
{
XmlElement element = (XmlElement) item;
string type = element.GetAttribute("type");
string path = element.GetAttribute("path");
switch (type)
{
case "baseLayer":
txtBaseLayer.Text = path;
if (CommonLib.DoesFileExist(path) == false)
errorProvider1.SetError(txtBaseLayer, "File not found");
else
errorProvider1.SetError(txtBaseLayer, "");
_dataGeneration.BaseLayerLocation = path;
break;
case "habitatGroupsDbf":
txtHabitatGroupsDbf.Text = path;
if (CommonLib.DoesFileExist(path) == false)
errorProvider1.SetError(txtHabitatGroupsDbf, "File not found");
else
errorProvider1.SetError(txtHabitatGroupsDbf, "");
_dataGeneration.DbfLocation = path;
break;
case "outputShapefiles":
txtShpOutputDir.Text = path;
if (CommonLib.DoesDirExist(path) == false)
errorProvider1.SetError(txtShpOutputDir, "Directory not found");
else
errorProvider1.SetError(txtShpOutputDir, "");
_dataGeneration.OutputLocation = path;
break;
}
}
}