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(); } } }
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); }
public bool PlayStart(ScrapedVideo video) { this.headerGroupVideoPlayer.ValuesPrimary.Heading = video.Title; this.currentPlayingVideo = video; UpdateFavouriteButton(DataService.Create().IsFavourite(this.currentPlayingVideo)); return(PlayStart(video.PlayUrl)); }
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(); } }
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); } }
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(); } }
public void ScrapVideosDetailsAsync(ScrapedVideo video, IScraperServiceCallback callback) { ThreadPool.QueueUserWorkItem(delegate { try { callback.OnScrapVideoDetailsCompleted(new XVideoScraper().ScrapeVideoDetails(video)); } catch (Exception ex) { callback.OnScrapError(ex); } }); }
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); }
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(); }
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); } }
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(); }); }
public ScrapedVideo ScrapVideoDetails(ScrapedVideo video) { var scraper = new XVideoScraper(); return(scraper.ScrapeVideoDetails(video)); }
protected virtual void OnAddItem(ScrapedVideo video, bool select) { }
public GalleryItemSelectedEventArgs(ScrapedVideo video) { Video = video; }
public void OnScrapVideoDetailsCompleted(ScrapedVideo video) { }
public void PlayVideo(ScrapedVideo video) { ChangeView(this.viewerWindow); this.viewerWindow.LoadVideo(video); }
public void AddItem(ScrapedVideo video, bool select) { OnAddItem(video, select); }