Exemplo n.º 1
0
        /// <summary>
        /// Updates Web Part data with what the User has selected in the wp editor
        /// </summary>
        /// <returns></returns>
        public override bool ApplyChanges()
        {
            GalleryWebPart galleryWebPart = this.WebPartToEdit as GalleryWebPart;

            // sync with the new property changes here
            EnsureChildControls();

            AddVideo = (galleryWebPart.Type == GalleryWebPart.GalleryType.Video);
            MaxItems = galleryWebPart.MaxItemsCount;

            // Read out form fields
            List <GalleryItem> gitems = new List <GalleryItem>();
            List <int>         ids    = ItemIDCollection;

            foreach (int id in ids)
            {
                string      sId           = id.ToString();
                string      imageSmallID  = "textBoxSmallImage" + sId;
                string      imageBigID    = "textBoxBigImage" + sId;
                string      videoID       = "textBoxVideo" + sId;
                string      descriptionID = "textBoxDescription" + sId;
                GalleryItem item          = new GalleryItem();

                // Small image
                foreach (TextBox textBox in m_TextSmallImage)
                {
                    if (textBox.ID == imageSmallID)
                    {
                        item.Thumbnail = textBox.Text.Trim();
                        break;
                    }
                }
                // Big image
                foreach (TextBox textBox in m_TextBigImage)
                {
                    if (textBox.ID == imageBigID)
                    {
                        item.Image = textBox.Text.Trim();
                        break;
                    }
                }
                // Video
                if (AddVideo)
                {
                    foreach (TextBox textBox in m_TextVideo)
                    {
                        if (textBox.ID == videoID)
                        {
                            item.Video = textBox.Text.Trim();
                            break;
                        }
                    }

                    if ((item.Image.Length > 0 || item.Thumbnail.Length > 0) && item.Video.Length > 0)
                    {
                        gitems.Add(item);
                    }
                }
                else
                {
                    foreach (TextBox textBox in m_TextDescription)
                    {
                        if (textBox.ID == descriptionID)
                        {
                            item.Description = textBox.Text.Trim();
                            break;
                        }
                    }

                    if (item.Image.Length > 0 || item.Thumbnail.Length > 0)
                    {
                        gitems.Add(item);
                    }
                }
            }
            galleryWebPart.GalleryItems = gitems;
            galleryWebPart.SaveChanges();

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates Web Part data with what the User has selected in the wp editor
        /// </summary>
        /// <returns></returns>
        public override bool ApplyChanges()
        {
            GalleryWebPart galleryWebPart = this.WebPartToEdit as GalleryWebPart;

            // sync with the new property changes here
            EnsureChildControls();

            AddVideo = (galleryWebPart.Type == GalleryWebPart.GalleryType.Video);
            MaxItems = galleryWebPart.MaxItemsCount;

            // Read out form fields
            List<GalleryItem> gitems = new List<GalleryItem>();
            List<int> ids = ItemIDCollection;
            foreach (int id in ids)
            {
                string sId = id.ToString();
                string imageSmallID = "textBoxSmallImage" + sId;
                string imageBigID = "textBoxBigImage" + sId;
                string videoID = "textBoxVideo" + sId;
                string descriptionID = "textBoxDescription" + sId;
                GalleryItem item = new GalleryItem();

                // Small image
                foreach (TextBox textBox in m_TextSmallImage)
                {
                    if (textBox.ID == imageSmallID)
                    {
                        item.Thumbnail = textBox.Text.Trim();
                        break;
                    }
                }
                // Big image
                foreach (TextBox textBox in m_TextBigImage)
                {
                    if (textBox.ID == imageBigID)
                    {
                        item.Image = textBox.Text.Trim();
                        break;
                    }
                }
                // Video
                if (AddVideo)
                {
                    foreach (TextBox textBox in m_TextVideo)
                    {
                        if (textBox.ID == videoID)
                        {
                            item.Video = textBox.Text.Trim();
                            break;
                        }
                    }

                    if ((item.Image.Length > 0 || item.Thumbnail.Length > 0) && item.Video.Length > 0)
                        gitems.Add(item);
                }
                else
                {
                    foreach (TextBox textBox in m_TextDescription)
                    {
                        if (textBox.ID == descriptionID)
                        {
                            item.Description = textBox.Text.Trim();
                            break;
                        }
                    }

                    if (item.Image.Length > 0 || item.Thumbnail.Length > 0)
                        gitems.Add(item);
                }
            }
            galleryWebPart.GalleryItems = gitems;
            galleryWebPart.SaveChanges();

            return true;
        }