Пример #1
0
        private bool AddRegion(TRegion Region)
        {
            if (m_xOverlay != null)
            {
                float[] p       = Region.p;
                XRegion xRegion = new XRegion(Region.m_eRShape, p[0], p[1], p[2], p[3], p[4]);
                m_xOverlay.Add(xRegion);
                xRegion.ID           = Region.m_nID;
                xRegion.BorderColor  = Color.FromArgb(Region.m_cBorderColor);
                xRegion.FillColor    = Color.FromArgb(Region.m_cFillColor);
                xRegion.BorderStyle  = Region.m_dBorderStyle;
                xRegion.ControlStyle = (REGION_CONTROL_STYLES)Region.m_RCS;
                xRegion.Caption      = Region.m_sCaption;

                string sImagePath = Region.m_sFillImagePath;
                if (sImagePath != null && sImagePath != "")
                {
                    Image FillImage = Image.FromFile(sImagePath);
                    if (xRegion.FillImage != null)
                    {
                        xRegion.FillImage.Dispose();
                    }
                    xRegion.FillImage = new Bitmap(FillImage);
                    FillImage.Dispose();
                }
                return(true);
            }
            return(false);
        }
Пример #2
0
        public bool SaveOverlay(string sPath)
        {
            if (sPath != null && sPath != "")
            {
                try
                {
                    sPath = sPath.ToLower();
                    string        sImagePath = sPath.Replace(".xml", "_");
                    XmlSerializer serializer = new XmlSerializer(typeof(TRegion[]));

                    TextWriter writer = new StreamWriter(sPath);

                    uint      nCount = m_xOverlay.Count;
                    TRegion[] Item   = new TRegion[nCount];
                    XRegion   Region = (XRegion)m_xOverlay.First();
                    for (int n = 0; n < nCount; n++)
                    {
                        if (Region != null)
                        {
                            Item[n] = new TRegion();
                            Item[n].Copy(Region);
                            if (Region.FillImage != null)
                            {
                                string sImageRegionPath = sImagePath + Region.ID.ToString() + ".bmp";


                                if (File.Exists(sImageRegionPath))
                                {
                                    File.Delete(sImageRegionPath);
                                }
                                Region.FillImage.Save(sImageRegionPath);

                                Item[n].m_sFillImagePath = sImageRegionPath;
                            }
                            Region = (XRegion)m_xOverlay.Next();
                        }
                    }
                    serializer.Serialize(writer, Item);
                    writer.Close();
                    return(true);
                }
                catch (Exception pe)
                {
                    string sMsg = pe.ToString();
                }
            }
            return(false);
        }