//保存配置文件
public void SaveXMLinit(string filename)
{
if (m_InitModified == false)
return;
if (System.IO.File.Exists(filename) == false)
{
XmlDocument xmlDoc = new XmlDocument();
XmlElement xmlroot = xmlDoc.CreateElement("Setting");
xmlDoc.AppendChild(xmlroot);
XmlElement xmlFocus=xmlDoc.CreateElement("FocusMode");
XmlElement xmlSub1 = xmlDoc.CreateElement("Locate");
xmlSub1.InnerText = m_FocusModeLocateID.ToString();
XmlElement xmlSub2 = xmlDoc.CreateElement("AddFeature");
xmlSub2.InnerText = m_FocusModeAddFeatureID.ToString();
xmlFocus.AppendChild(xmlSub1);
xmlFocus.AppendChild(xmlSub2);
xmlroot.AppendChild(xmlFocus);
xmlDoc.Save(filename);
}
else
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(filename);
XmlNode xmlRoot = xmlDoc.SelectSingleNode("/Setting/FocusMode");
XmlNodeList xmlList = xmlRoot.ChildNodes;
foreach (XmlNode xn in xmlList)
{
switch(xn.Name)
{
case "Locate":
xn.InnerText = m_FocusModeLocateID.ToString();
break;
case "AddFeature":
xn.InnerText = m_FocusModeAddFeatureID.ToString();
break;
}
}
xmlDoc.Save(filename);
}
}
//读取配置文件
public void LoadXMLinit(string filename)
{
if (System.IO.File.Exists(filename) == false)
return;
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(filename);
XmlNode xmlRoot = xmlDoc.SelectSingleNode("/Setting/FocusMode");
XmlNodeList xmlList = xmlRoot.ChildNodes;
foreach (XmlNode xn in xmlList)
{
switch (xn.Name)
{
case "Locate":
m_FocusModeLocateID = int.Parse(xn.InnerText);
break;
case "AddFeature":
m_FocusModeAddFeatureID = int.Parse(xn.InnerText);
break;
}
}
}