Beispiel #1
0
        protected override void OnAddItem(ScrapedVideo video, bool select)
        {
            var found = false;

            LogManager.Log("Adding items to Veritcal gallery");
            foreach (Control c in this.tableLayoutPanel.Controls)
            {
                var widget = c as WebViewWidget;
                if (widget != null)
                {
                    if (widget.Video.Url == video.Url)
                    {
                        widget.SelectView();
                        found = true;
                    }
                    else
                    {
                        widget.DeselectView();
                    }
                }
            }
            if (!found)
            {
                var widget = AddItem(video);
                this.tableLayoutPanel.Controls.SetChildIndex(widget, 0);
                if (select)
                {
                    widget.SelectView();
                }
            }
        }
Beispiel #2
0
        public ScrapedVideo GetNextVideo(ScrapedVideo current)
        {
            int index = -1;

            for (var i = 0; i < WidgetContainer.Controls.Count; i++)
            {
                var v = WidgetContainer.Controls[i] as WebViewWidget;
                if (v != null && v.Video == current)
                {
                    index = i;
                    break;
                }
            }

            if (WidgetContainer.Controls.Count > 0)
            {
                if (index == -1 || index == GetWidgetLastIndex())
                {
                    return(((WebViewWidget)WidgetContainer.Controls[0]).Video);
                }
                else
                {
                    return(((WebViewWidget)WidgetContainer.Controls[GetNextWidget(index)]).Video);
                }
            }
            return(null);
        }
Beispiel #3
0
 public bool PlayStart(ScrapedVideo video)
 {
     this.headerGroupVideoPlayer.ValuesPrimary.Heading = video.Title;
     this.currentPlayingVideo = video;
     UpdateFavouriteButton(DataService.Create().IsFavourite(this.currentPlayingVideo));
     return(PlayStart(video.PlayUrl));
 }
Beispiel #4
0
 public void DeleteFromFavourite(ScrapedVideo video)
 {
     using (var cmd = new SQLiteCommand(connection))
     {
         cmd.CommandText = String.Format("DELETE FROM VIDEO WHERE Url = '{0}'", Sanitize(video.Url));
         cmd.ExecuteNonQuery();
     }
 }
Beispiel #5
0
 public bool IsFavourite(ScrapedVideo video)
 {
     using (var cmd = new SQLiteCommand(connection))
     {
         cmd.CommandText = String.Format("SELECT COUNT(*) FROM VIDEO WHERE Url = '{0}'", Sanitize(video.Url));
         var count = Convert.ToInt32(cmd.ExecuteScalar());
         return(count > 0);
     }
 }
Beispiel #6
0
 public void AddToFavourite(ScrapedVideo video)
 {
     using (var cmd = new SQLiteCommand(connection))
     {
         cmd.CommandText = String.Format("INSERT INTO VIDEO(Url,Title,ImageUrl,Duration,PlayUrl,Quality,IsFavourite) " +
                                         "VALUES('{0}','{1}','{2}',{3},'{4}',{5},{6})", Sanitize(video.Url),
                                         Sanitize(video.Title), Sanitize(video.ImageUrl),
                                         video.Duration.TotalSeconds, Sanitize(video.PlayUrl), 99, 1);
         cmd.ExecuteNonQuery();
     }
 }
Beispiel #7
0
 public void ScrapVideosDetailsAsync(ScrapedVideo video, IScraperServiceCallback callback)
 {
     ThreadPool.QueueUserWorkItem(delegate {
         try
         {
             callback.OnScrapVideoDetailsCompleted(new XVideoScraper().ScrapeVideoDetails(video));
         }
         catch (Exception ex)
         {
             callback.OnScrapError(ex);
         }
     });
 }
Beispiel #8
0
        private WebViewWidget AddItem(ScrapedVideo video)
        {
            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()));

            widget.Anchor = AnchorStyles.Left | AnchorStyles.Right;
            widget.Width  = this.Width;
            this.tableLayoutPanel.Controls.Add(widget);
            Application.DoEvents();
            widget.ViewSelected += delegate(object sender, GalleryItemSelectedEventArgs e)
            {
                OnItemSelected(sender, e);
            };
            return(widget);
        }
Beispiel #9
0
 public WebViewWidget(ScrapedVideo video, string html)
     : this()
 {
     this.SuspendLayout();
     this.pictureBox.Visible = DataService.Create().IsFavourite(video);
     this.video                              = video;
     this.htmlPanel.Text                     = html;
     this.htmlPanel.AutoScroll               = false;
     this.AutoScroll                         = false;
     this.htmlPanel.VerticalScroll.Enabled   = false;
     this.htmlPanel.HorizontalScroll.Enabled = false;
     this.htmlPanel.VerticalScroll.Visible   = false;
     this.htmlPanel.HorizontalScroll.Visible = false;
     this.ResumeLayout();
 }
Beispiel #10
0
        public void LoadVideo(ScrapedVideo video)
        {
            if (this.currentRequestedVideo == video && !video.FullyLoaded)
            {
                return;
            }
            Program.SetBusy();
            this.videoPlayerWidget.PlayStop();

            this.currentRequestedVideo = video;
            if (video.FullyLoaded)
            {
                OnScrapVideoDetailsCompleted(video);
            }
            else
            {
                new ScraperService().ScrapVideosDetailsAsync(video, this);
            }
        }
Beispiel #11
0
        public void OnScrapVideoDetailsCompleted(ScrapedVideo video)
        {
            this.InvokeEx(() =>
            {
                if (this.currentRequestedVideo == video)
                {
                    var played = this.videoPlayerWidget.PlayStart(video);

                    if (played)
                    {
                        this.verticalSingleColumnGalleryWidget1.AddItem(video, true);
                        this.relatedVideoGalleryWidget.ClearItems();
                        this.relatedVideoGalleryWidget.AddItems(new ScrapedPage {
                            Videos = video.RelatedVideos
                        });
                    }
                    else
                    {
                        this.currentRequestedVideo = null;
                    }
                }
                Program.SetIdle();
            });
        }
Beispiel #12
0
        public ScrapedVideo ScrapVideoDetails(ScrapedVideo video)
        {
            var scraper = new XVideoScraper();

            return(scraper.ScrapeVideoDetails(video));
        }
Beispiel #13
0
 protected virtual void OnAddItem(ScrapedVideo video, bool select)
 {
 }
Beispiel #14
0
 public GalleryItemSelectedEventArgs(ScrapedVideo video)
 {
     Video = video;
 }
Beispiel #15
0
 public void OnScrapVideoDetailsCompleted(ScrapedVideo video)
 {
 }
Beispiel #16
0
 public void PlayVideo(ScrapedVideo video)
 {
     ChangeView(this.viewerWindow);
     this.viewerWindow.LoadVideo(video);
 }
Beispiel #17
0
 public void AddItem(ScrapedVideo video, bool select)
 {
     OnAddItem(video, select);
 }