Exemple #1
0
        /// <summary>
        /// Добавляет к библиотеке Images изображение и возвращает его библиотченое описание
        /// </summary>
        /// <param name="image"></param>
        /// <param name="Name"></param>
        /// <param name="Description"></param>
        /// <returns></returns>
        public ImageItem AddImage(Image image, string Name, string Description)
        {
            ImageItem OUT = new ImageItem();

            FileStream fs = new FileStream(pathImageBase, FileMode.Append);

            using (MemoryStream ms = new MemoryStream())
            {
                image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                byte[] arrayImage = ms.ToArray();

                OUT.uid          = Guid.NewGuid();
                OUT.Name         = Name;
                OUT.Description  = Description;
                OUT.FilePosition = fs.Length;
                OUT.LengthFile   = ms.Length;
                fs.Write(arrayImage, 0, arrayImage.Length);
                fs.Close();
            }
            Images.Add(OUT);
            return(OUT);
        }
Exemple #2
0
        public ImageFile()
        {
            Images = new List <ImageItem>();

            XmlDocument doc = new XmlDocument();

            if (!File.Exists(pathImageBaseDescription))
            {
                return;
            }
            doc.Load(pathImageBaseDescription);
            foreach (XmlNode XMLImageDescription in doc.GetElementsByTagName("Image"))
            {
                ImageItem item = new ImageItem
                {
                    uid          = Guid.Parse(XMLImageDescription.SelectSingleNode("UID").InnerText),
                    Name         = XMLImageDescription.SelectSingleNode("Name").InnerText,
                    Description  = XMLImageDescription.SelectSingleNode("Description").InnerText,
                    FilePosition = long.Parse(XMLImageDescription.SelectSingleNode("FilePosition").InnerText),
                    LengthFile   = long.Parse(XMLImageDescription.SelectSingleNode("LengthFile").InnerText)
                };
                Images.Add(item);
            }
        }