public static Bookmark[] GetPodcastBookmarks(Podcast podcast) { var ret = new List <Bookmark>(); foreach (Bookmark b in bookmarks) { if (b.podcast == podcast.id) { ret.Add(b); } } return(ret.ToArray()); }
public void UpdateDescription() { if (lst_podcasts.SelectedIndex < 0 || lst_podcasts.SelectedIndex >= currentPodcasts.Count()) { edt_description.Text = ""; return; } Podcast p = currentPodcasts[lst_podcasts.SelectedIndex]; if (p.description != null) { edt_description.Text = p.description.Replace("\n", "\r\n"); } }
public void SearchResults(Podcast[] results, string term = "") { if (results.Count() == 0) { return; } var lresults = new List <Podcast>(); var ids = new List <int>(); Podcast l = new Podcast(); l.id = 0; foreach (Podcast p in results) { if (ids.Contains(p.id)) { continue; } int n = lresults.Count(); if (l.id != 0) { for (; n > 0; --n) { if (lresults[n - 1].time > p.time) { break; } } } lresults.Insert(n, p); ids.Add(p.id); l = p; } if (wnd != null) { wnd.AddCustomCollection("Szukaj: " + term, lresults.ToArray(), true); } }
public static (string, Dictionary <string, string>) GetCommentsNonce(Podcast podcast) { try { if (apiClient == null) { Init(); } String u = jsonurl + "/posts/" + podcast.id.ToString(); var response = apiClient.GetAsync(u).Result; var json = response.Content.ReadAsStringAsync().Result; dynamic j = JsonConvert.DeserializeObject(json); string link = j.link; var pageResponse = apiClient.GetAsync(link).Result; var page = pageResponse.Content.ReadAsStringAsync().Result; var doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(page); var cmt = doc.GetElementbyId("commentform"); string action = cmt.GetAttributeValue("action", ""); var fields = new Dictionary <string, string>(); if (cmt == null) { return(null, null); } var nodes = cmt.Descendants("input"); foreach (var node in nodes) { if (node.GetAttributeValue("type", "").ToLower() == "hidden") { fields[node.GetAttributeValue("name", "")] = node.GetAttributeValue("value", ""); } } return(action, fields); } catch { return(null, null); } }
public PlayerWindow(Podcast tpodcast, Controller tcontroller) { podcast = tpodcast; controller = tcontroller; this.FormBorderStyle = FormBorderStyle.FixedDialog; this.ShowInTaskbar = false; this.Size = new Size(480, 360); this.StartPosition = FormStartPosition.CenterScreen; name = podcast.name; artist = null; UpdateWindowCaption(); lb_timer = new Label(); lb_timer.Text = "Pobieranie informacji o strumieniu..."; lb_timer.Size = new Size(50, 50); lb_timer.Location = new Point(20, 20); this.Controls.Add(lb_timer); tb_timer = new TyfloTrackBar(); tb_timer.Size = new Size(130, 50); tb_timer.Location = new Point(70, 20); tb_timer.Minimum = 0; tb_timer.Maximum = 0; tb_timer.TickFrequency = 15; tb_timer.LargeChange = 60; tb_timer.SmallChange = 10; tb_timer.PreviewKeyDown += tb_timer_keyfilter; tb_timer.Scroll += (sender, e) => { controller.SetPosition((double)tb_timer.Value); }; this.Controls.Add(tb_timer); lb_volume = new Label(); lb_volume.Text = "Głośność"; lb_volume.Size = new Size(50, 50); lb_volume.Location = new Point(20, 90); this.Controls.Add(lb_volume); tb_volume = new TyfloTrackBar(); tb_volume.Size = new Size(130, 50); tb_volume.Location = new Point(70, 90); tb_volume.Minimum = 0; tb_volume.Maximum = 100; tb_volume.TickFrequency = 5; tb_volume.LargeChange = 20; tb_volume.SmallChange = 5; tb_volume.Scroll += (sender, e) => { controller.SetVolume(tb_volume.Value); }; this.Controls.Add(tb_volume); lb_tempo = new Label(); lb_tempo.Text = "Tempo odtwarzania"; lb_tempo.Size = new Size(50, 50); lb_tempo.Location = new Point(20, 160); this.Controls.Add(lb_tempo); tb_tempo = new TyfloTrackBar(); tb_tempo.Size = new Size(130, 50); tb_tempo.Location = new Point(70, 160); tb_tempo.Minimum = -50; tb_tempo.Maximum = 50; tb_tempo.TickFrequency = 5; tb_tempo.LargeChange = 10; tb_tempo.SmallChange = 1; tb_tempo.Scroll += (sender, e) => { controller.SetTempo(tb_tempo.Value); }; this.Controls.Add(tb_tempo); lb_chapters = new Label(); lb_chapters.Text = "Rozdziały"; lb_chapters.Size = new Size(240, 50); lb_chapters.Location = new Point(220, 20); lb_chapters.Visible = false; this.Controls.Add(lb_chapters); lst_chapters = new ListBox(); lst_chapters.Size = new Size(240, 140); lst_chapters.Location = new Point(220, 80); lst_chapters.Visible = false; lst_chapters.DoubleClick += (sender, e) => { GoToChapter(); }; this.Controls.Add(lst_chapters); tb_timer.KeyDown += TBKeyDown; tb_volume.KeyDown += TBKeyDown; tb_tempo.KeyDown += TBKeyDown; lst_chapters.KeyDown += TBKeyDown; btn_play = new Button(); btn_play.Text = "Play/Pauza"; btn_play.Size = new Size(50, 100); btn_play.Location = new Point(20, 240); btn_play.Click += (sender, e) => controller.TogglePlayback(); this.Controls.Add(btn_play); btn_bookmarks = new Button(); btn_bookmarks.Text = "Zakładki"; btn_bookmarks.Size = new Size(50, 100); btn_bookmarks.Location = new Point(90, 240); btn_bookmarks.Click += (sender, e) => controller.Bookmarks(podcast, tb_timer.Value); this.Controls.Add(btn_bookmarks); btn_download = new Button(); btn_download.Text = "Pobierz"; btn_download.Size = new Size(50, 100); btn_download.Location = new Point(160, 240); btn_download.Click += (sender, e) => controller.DownloadPodcast(podcast); this.Controls.Add(btn_download); btn_comments = new Button(); btn_comments.Text = "Pokaż komentarze"; btn_comments.Size = new Size(50, 100); btn_comments.Location = new Point(230, 240); btn_comments.Click += (sender, e) => controller.ShowComments(podcast); this.Controls.Add(btn_comments); btn_close = new Button(); btn_close.Text = "Zamknij"; btn_close.Size = new Size(50, 100); btn_close.Location = new Point(300, 240); btn_close.Click += (sender, e) => this.Close(); this.Controls.Add(btn_close); this.CancelButton = btn_close;; if (podcast.id == 0) { btn_download.Enabled = false; btn_comments.Enabled = false; } }
public CommentsWindow(Podcast tpodcast, Comment[] tcomments, Controller tcontroller) { podcast = tpodcast; controller = tcontroller; comments = tcomments; this.FormBorderStyle = FormBorderStyle.FixedDialog; this.ShowInTaskbar = false; this.Size = new Size(480, 360); this.StartPosition = FormStartPosition.CenterScreen; this.Text = "Komentarze do podcastu " + podcast.name + " - Tyflopodcast"; lb_comments = new Label(); lb_comments.Text = "Komentarze"; lb_comments.Size = new Size(150, 50); lb_comments.Location = new Point(20, 20); this.Controls.Add(lb_comments); lst_comments = new ListBox(); lst_comments.Size = new Size(150, 200); lst_comments.Location = new Point(20, 80); this.Controls.Add(lst_comments); lb_comment = new Label(); lb_comment.Text = "Treść komentarza"; lb_comment.Size = new Size(250, 50); lb_comments.Location = new Point(190, 20); this.Controls.Add(lb_comments); edt_comment = new TextBox(); edt_comment.Size = new Size(250, 200); edt_comment.Location = new Point(190, 80); edt_comment.ReadOnly = true; edt_comment.Multiline = true; this.Controls.Add(edt_comment); btn_close = new Button(); btn_close.Text = "Zamknij"; btn_close.Size = new Size(60, 40); btn_close.Location = new Point(155, 300); btn_close.Click += (sender, e) => this.Close(); this.Controls.Add(btn_close); btn_write = new Button(); btn_write.Text = "Napisz"; btn_write.Size = new Size(60, 40); btn_write.Location = new Point(215, 300); btn_write.Click += (sender, e) => controller.WriteComment(podcast); this.Controls.Add(btn_write); lst_comments.SelectedIndexChanged += (sender, e) => { if (lst_comments.SelectedIndex < comments.Count()) { ShowComment(comments[lst_comments.SelectedIndex]); } }; this.CancelButton = btn_close; SetComments(comments); }
public void AddBookmark(Podcast podcast, string name, double time) { Podcasts.AddBookmark(podcast, name, (float)time); wnd_bookmarks.UpdateBookmarks(); UpdateAudioInfo(podcast); }
public void Bookmarks(Podcast podcast, double time) { wnd_bookmarks = new BookmarksWindow(podcast, time, this); wnd_bookmarks.ShowDialog(wnd_player); }
private static int fetchPodcastsConverter(int page, HttpResponseMessage response, ref Podcast[] podcasts, bool reset = false) { var json = response.Content.ReadAsStringAsync().Result; dynamic j = JsonConvert.DeserializeObject(json); var headers = response.Headers; IEnumerable <string> values; if (podcasts == null) { if (headers.TryGetValues("X-WP-Total", out values)) { podcasts = new Podcast[int.Parse(values.First())]; } else { return(-1); } } int maxid = 0; if (localPodcasts != null) { maxid = localPodcasts[0].id; } int index = 0; foreach (dynamic r in j) { if (page == 1 && r.id <= maxid && !reset) { foreach (Podcast o in localPodcasts) { podcasts[index] = o; ++index; } return(0); } Podcast p = new Podcast(); p.name = WebUtility.HtmlDecode((String)r.title.rendered); p.time = r.date; p.description = HTMLToText((string)r.content.rendered); p.id = r.id; var cs = new List <int>(); if (categories != null) { foreach (Category c in categories) { foreach (dynamic cid in r.categories) { if (((int)cid) == c.id) { cs.Add(c.id); } } } } p.categories = cs.ToArray(); podcasts[(page - 1) * 100 + index] = p; ++index; } if (headers.TryGetValues("X-WP-TotalPages", out values)) { return(int.Parse(values.First())); } return(0); }
public CommentWriteWindow(Controller tcontroller, Podcast tpodcast, string taction, Dictionary <string, string> tfields) { controller = tcontroller; podcast = tpodcast; action = taction; fields = tfields; this.FormBorderStyle = FormBorderStyle.FixedDialog; this.ShowInTaskbar = false; this.Size = new Size(640, 480); this.StartPosition = FormStartPosition.CenterScreen; this.Text = "Skomentuj podcast " + podcast.name; lb_name = new Label(); lb_name.Text = "Podpis"; lb_name.Size = new Size(100, 50); lb_name.Location = new Point(20, 20); this.Controls.Add(lb_name); edt_name = new TextBox(); edt_name.Size = new Size(340, 50); edt_name.Location = new Point(480, 20); this.Controls.Add(edt_name); lb_mail = new Label(); lb_mail.Text = "Adres E-mail (nie zostanie opublikowany)"; lb_mail.Size = new Size(100, 50); lb_mail.Location = new Point(20, 90); this.Controls.Add(lb_mail); edt_mail = new TextBox(); edt_mail.Size = new Size(480, 50); edt_mail.Location = new Point(140, 90); this.Controls.Add(edt_mail); lb_url = new Label(); lb_url.Text = "Witryna Internetowa"; lb_url.Size = new Size(100, 50); lb_url.Location = new Point(20, 160); this.Controls.Add(lb_url); edt_url = new TextBox(); edt_url.Size = new Size(480, 50); edt_url.Location = new Point(140, 160); this.Controls.Add(edt_url); lb_message = new Label(); lb_message.Text = "Komentarz"; lb_message.Size = new Size(50, 160); lb_message.Location = new Point(20, 230); this.Controls.Add(lb_message); edt_message = new TextBox(); edt_message.Size = new Size(480, 160); edt_message.Location = new Point(90, 230); edt_message.Multiline = true; this.Controls.Add(edt_message); btn_send = new Button(); btn_send.Text = "Wyślij"; btn_send.Size = new Size(300, 50); btn_send.Location = new Point(20, 410); btn_send.Click += (sender, e) => Send(); this.Controls.Add(btn_send); btn_cancel = new Button(); btn_cancel.Text = "Anuluj"; btn_cancel.Size = new Size(300, 50); btn_cancel.Location = new Point(320, 410); this.Controls.Add(btn_cancel); this.CancelButton = btn_cancel; //this.AcceptButton=btn_send; }
public void AddPodcast(Podcast podcast) { podcasts.Add(podcast); }