public bool LoadOverlay(string sPath) { if (sPath != null && sPath != "") { uint uCount = m_xOverlay.Count; XRegion Region = (XRegion)m_xOverlay.First(); for (int n = 0; n < uCount; n++) { if (Region != null) { if (Region.FillImage != null) { Region.FillImage.Dispose(); } Region = (XRegion)m_xOverlay.Next(); } } m_xOverlay.Empty(); XmlSerializer serializer = new XmlSerializer(typeof(TRegion[])); FileStream fs = null; try { fs = new FileStream(sPath, FileMode.Open); if (fs != null) { TRegion[] pItem = (TRegion[])serializer.Deserialize(fs); fs.Close(); if (pItem != null) { int n; int nCount = pItem.Length; for (n = 0; n < nCount; n++) { AddRegion(pItem[n]); } for (n = 0; n < nCount; n++) { int nTargetID = pItem[n].m_TargetRegionID; if (nTargetID > 0) { XRegion xRegion = (XRegion)m_xOverlay.Find(pItem[n].m_nID); if (xRegion != null) { XRegion xTargetRegion = (XRegion)m_xOverlay.Find(nTargetID); if (xTargetRegion != null) { xRegion.SetAlign(xTargetRegion, pItem[n].m_eAlignTarget, pItem[n].m_eAlignObject); } } } } } Refresh(); return(true); } } catch (Exception pe) { if (fs != null) { fs.Close(); } string sMsg = pe.ToString(); Refresh(); } } return(false); }