File size: 1,866 Bytes
e26fba6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Client.Scraper;

namespace BlueTube.Viewer
{
    public partial class HorizontalSingleRowGalleryWidget : GalleryWidgetBase
    {
        #region Constructor

        public HorizontalSingleRowGalleryWidget()
        {
            InitializeComponent();
        }

        #endregion

        #region Methods


        protected override void OnAddItems(ScrapedPage page)
        {
            if (this.kryptonPanel1.Controls.Contains(this.kryptonLabelPrivacy))
                this.kryptonPanel1.Controls.Remove(this.kryptonLabelPrivacy);
            
            for (var i = 0; i < Constants.GetMaxDisplayCount(page.Videos.Count); i++)
            {
                var video = page.Videos[i];
                var widget = new WebViewWidget(video,
                    Properties.Resources.TestHtml.Replace("{0}", video.Url).Replace("{1}", video.ImageUrl).
                       Replace("{2}", video.Title).Replace("{3}", video.Duration.ToString()));
                this.flowLayoutPanel.Controls.Add(widget);
                widget.ViewSelected += delegate(object sender, GalleryItemSelectedEventArgs e)
                {
                    OnItemSelected(sender, e);
                };

                if (Constants.ShowAds && i % 4 == 0)
                {
                    var ad = CreateAdWidget(Constants.HorizontalAdId);
                    this.flowLayoutPanel.Controls.Add(ad);
                }
            }
        }

        protected override Control WidgetContainer
        {
            get
            {
                return this.flowLayoutPanel;
            }
        }
       
        #endregion
    }
}