Esempio n. 1
0
        /// <summary>
        /// Reads Web Part's data and updates wp editor
        /// </summary>
        public override void SyncChanges()
        {
            GalleryWebPart galleryWebPart = this.WebPartToEdit as GalleryWebPart;

            AddVideo = (galleryWebPart.Type == GalleryWebPart.GalleryType.Video);
            MaxItems = galleryWebPart.MaxItemsCount;
            List <GalleryItem> gitems = galleryWebPart.GalleryItems;

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

            // Fill form fields
            for (int i = 0; i < gitems.Count; i++)
            {
                AddItem(-1);

                if (m_TextSmallImage.Count > 0)
                {
                    m_TextSmallImage[m_TextSmallImage.Count - 1].Text = gitems[i].Thumbnail;
                }
                if (m_TextBigImage.Count > 0)
                {
                    m_TextBigImage[m_TextBigImage.Count - 1].Text = gitems[i].Image;
                }
                if (AddVideo)
                {
                    if (m_TextVideo.Count > 0)
                    {
                        m_TextVideo[m_TextVideo.Count - 1].Text = gitems[i].Video;
                    }
                }
                else
                {
                    if (m_TextDescription.Count > 0)
                    {
                        m_TextDescription[m_TextDescription.Count - 1].Text = gitems[i].Description;
                    }
                }
            }
        }
Esempio 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);
        }