Esempio n. 1
0
        public int ExtractPicturesFromDescription()
        {
            int insert_index = 0;

            if (LongDescription != null)
            {
                string[] imgs = LongDescription.Split(new string[] { "<img " }, StringSplitOptions.RemoveEmptyEntries);
                if (imgs.Length > 1)
                {
                    for (int i = 1; i < imgs.Length; i++)
                    {
                        string[] src = imgs[i].Split(new string[] { "src=" }, StringSplitOptions.None);
                        if (src.Length > 1)
                        {
                            string[] path = src[1].Split(new char[] { '"' });
                            {
                                if (path.Length > 2)
                                {
                                    if (path[1].Length > 10)
                                    {
                                        bool duplicate = false;
                                        foreach (GeocachePicture gp in Pictures)
                                        {
                                            string cs1 = gp.Path;
                                            string cs2 = path[1];
                                            cs1 = cs1.Substring(cs1.Length - 10, 10);
                                            cs2 = cs2.Substring(cs2.Length - 10, 10);
                                            if (cs1.Equals(cs2))
                                            {
                                                duplicate = true;
                                            }
                                        }
                                        if (!duplicate)
                                        {
                                            GeocachePicture p = new GeocachePicture();
                                            p.OriginalPath = path[1];
                                            p.Path         = path[1];
                                            Pictures.Add(p); //.Insert(insert_index, p);
                                            insert_index++;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(insert_index);
        }