예제 #1
0
        private void UpdateAudioInfo(Podcast p)
        {
            if (stream == 0)
            {
                return;
            }
            AudioInfo ai;

            try {
                ai = new AudioInfo(stream);
            } catch (Exception) { return; }
            if (ai == null)
            {
                return;
            }
            wnd_player.SetName(ai.title);
            wnd_player.SetArtist(ai.artist);
            var chapters = new List <AudioInfo.Chapter>();

            foreach (AudioInfo.Chapter ch in ai.chapters)
            {
                chapters.Add(ch);
            }
            foreach (Bookmark b in Podcasts.GetPodcastBookmarks(p))
            {
                var ch = new AudioInfo.Chapter();
                ch.name        = "Zakładka: " + b.name;
                ch.time        = b.time;
                ch.userDefined = true;
                chapters.Add(ch);
            }
            wnd_player.SetChapters(chapters.ToArray());
        }
예제 #2
0
 public void ShowComments(Podcast podcast)
 {
     Comment[] comments;
     if (Podcasts.GetPodcastComments(podcast.id, out comments))
     {
         wnd_comments = new CommentsWindow(podcast, comments, this);
         wnd_comments.ShowDialog(wnd_player);
     }
 }
예제 #3
0
 public void WriteComment(Podcast podcast)
 {
     (string action, Dictionary <string, string> fields) = Podcasts.GetCommentsNonce(podcast);
     if (action == null)
     {
         return;
     }
     wnd_commentwrite = new CommentWriteWindow(this, podcast, action, fields);
     wnd_commentwrite.ShowDialog(wnd_comments);
 }
예제 #4
0
 public void DeleteBookmark(Podcast podcast, Bookmark bookmark)
 {
     if (bookmark.podcast != podcast.id)
     {
         return;
     }
     Podcasts.DeleteBookmark(bookmark);
     wnd_bookmarks.UpdateBookmarks();
     UpdateAudioInfo(podcast);
 }
예제 #5
0
 public void UpdateBookmarks()
 {
     bookmarks = Podcasts.GetPodcastBookmarks(podcast);
     lst_bookmarks.Items.Clear();
     foreach (Bookmark b in bookmarks)
     {
         lst_bookmarks.Items.Add(b.name);
     }
     edt_name.Text = "";
 }
예제 #6
0
 public void SetLikedPodcast(Podcast podcast, bool liked)
 {
     if (liked)
     {
         Podcasts.LikePodcast(podcast);
     }
     else
     {
         Podcasts.DislikePodcast(podcast);
     }
     wnd.SetLikedPodcasts(Podcasts.GetLikedPodcasts());
 }
예제 #7
0
 public void ContactRadioBrowser()
 {
     (bool available, string title, string meeting) = Podcasts.GetRadioContactInfo();
     if (available && meeting != null)
     {
         ShowURL("https://zoom.us/wc/join/" + meeting.ToString());
     }
     else
     {
         MessageBox.Show("W tej chwili opcja kontaktu głosowego nie jest dostępna.", "Kontakt niemożliwy", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #8
0
 public void ContactRadio()
 {
     (bool available, string title, string meeting) = Podcasts.GetRadioContactInfo();
     if (available)
     {
         wnd_radio.ShowContactRadioContext(meeting != null);
     }
     else
     {
         MessageBox.Show("W tej chwili możliwość kontaktu jest wyłączona, możliwe, że nie trwa teraz żadna audycja interaktywna lub prowadzący nie umożliwił jeszcze komunikacji.", "Kontakt niemożliwy", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #9
0
 public void PublishComment(Podcast podcast, string action, Dictionary <string, string> fields, string name, string mail, string url, string comment)
 {
     if (Podcasts.WriteComment(action, fields, name, mail, url, comment))
     {
         wnd_commentwrite.Close();
     }
     Comment[] comments;
     if (Podcasts.GetPodcastComments(podcast.id, out comments) && wnd_comments != null)
     {
         wnd_comments.SetComments(comments);
     }
 }
예제 #10
0
 public void SendRadioContact(string name, string message)
 {
     (bool suc, string error) = Podcasts.SendRadioContact(name, message);
     if (suc)
     {
         wnd_contact.Close();
         wnd_contact = null;
     }
     else
     {
         MessageBox.Show(error, "Wysłanie wiadomości nie powiodło się", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #11
0
 public void ContactRadioPhone()
 {
     (bool available, string title, string meeting) = Podcasts.GetRadioContactInfo();
     if (available && meeting != null)
     {
         wnd_contactphone = new ContactRadioPhoneWindow(this, meeting);
         wnd_contactphone.ShowDialog(wnd_radio);
     }
     else
     {
         MessageBox.Show("W tej chwili opcja kontaktu głosowego nie jest dostępna.", "Kontakt niemożliwy", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #12
0
 public void ShowRadioProgram()
 {
     (bool available, string text) = Podcasts.GetRadioProgram();
     if (available)
     {
         wnd_program = new RadioProgramWindow(this, text);
         wnd_program.ShowDialog(wnd);
     }
     else
     {
         MessageBox.Show("W tej chwili ramówka nie jest dostępna.", "Ramówka niedostępna", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #13
0
 public void CheckForUpdates(bool confirm = false)
 {
     (bool available, string text) = Podcasts.CheckForUpdates();
     if (available)
     {
         if (MessageBox.Show("Dostępna jest nowa wersja programu. Czy chcesz przejść teraz do strony pobierania?", "Dostępna aktualizacja", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             ShowURL("https://github.com/dawidpieper/tyflopodcast/releases");
         }
     }
     else if (confirm)
     {
         MessageBox.Show("Używasz najnowszej wersji programu.", "Nie znaleziono dostępnych aktualizacji", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #14
0
        public void Search()
        {
            string term = edt_term.Text;

            if (term == "")
            {
                return;
            }
            string lterm      = term.ToLower();
            int    searchtype = lst_searchin.SelectedIndex;
            var    result     = new List <Podcast>();

            foreach (Podcast p in podcasts)
            {
                if ((searchtype == 0 || searchtype == 1 || searchtype == 4) && p.name.ToLower().Contains(lterm))
                {
                    result.Add(p);
                }
                else if ((searchtype == 0 || searchtype == 2 || searchtype == 4) && p.description.ToLower().Contains(lterm))
                {
                    result.Add(p);
                }
            }
            if (searchtype == 3 || searchtype == 4)
            {
                try {
                    Podcast[] pd = null;
                    Podcasts.LoadPodcastsWithComments(term, out pd);
                    if (pd != null)
                    {
                        foreach (Podcast p in pd)
                        {
                            if (!result.Contains(p))
                            {
                                result.Add(p);
                            }
                        }
                    }
                }
                catch {}
            }
            controller.SearchResults(result.ToArray(), term);
            this.Close();
        }
예제 #15
0
 public void ContactRadioZoom()
 {
     (bool available, string title, string meeting) = Podcasts.GetRadioContactInfo();
     if (available && meeting != null)
     {
         RegistryKey key = Registry.ClassesRoot.OpenSubKey("zoommtg");
         if (key == null)
         {
             if (MessageBox.Show("Aplikacja Zoom nie została zainstalowana na tym komputerze. Czy chcesz teraz przejść do jej strony pobierania?", "Nie znaleziono aplikacji Zoom", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
             {
                 ShowURL("https://zoom.us/download");
             }
         }
         else
         {
             ShowURL("zoommtg://zoom.us/join?action=join&confno=" + meeting.ToString());
         }
     }
     else
     {
         MessageBox.Show("W tej chwili opcja kontaktu głosowego nie jest dostępna.", "Kontakt niemożliwy", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #16
0
        public void UpdateDatabase(bool reset = false)
        {
            if (wnd == null)
            {
                return;
            }
            bool cancelled = true;
            var  l         = new LoadingWindow("Pobieranie bazy podcastów");

            l.SetStatus("Inicjowanie...");
            Podcast[] podcasts       = null;
            bool      localLoaded    = Podcasts.GetLocalPodcasts(out podcasts);
            bool      downloadRemote = true;

            if (localLoaded && !reset)
            {
                if (MessageBox.Show("Czy chcesz zaktualizować listę dostępnych podcastów?", "Tyflopodcast", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    downloadRemote = false;
                }
            }
            if (downloadRemote)
            {
                int totalPages = -1, leftPages = -1;
                CancellationTokenSource cts = new CancellationTokenSource();
                CancellationToken       ct  = cts.Token;
                Task.Factory.StartNew(async() => {
                    l.SetStatus("Łączenie...");
                    bool s = false;
                    int p  = -1;
                    for (;;)
                    {
                        await Task.Delay(250);
                        if (!s && totalPages != -1)
                        {
                            s = true;
                            l.SetStatus("Pobieranie informacji o bazie podcastów...");
                        }
                        else if (s && p != leftPages)
                        {
                            l.SetStatus("Pobieranie strony " + (totalPages - leftPages).ToString() + " z " + totalPages.ToString() + "...");
                            p      = leftPages;
                            int pr = (int)((double)(totalPages - leftPages) / totalPages * 100.0);
                            l.SetPercentage(pr);
                            if (leftPages == 0)
                            {
                                break;
                            }
                        }
                        if (ct.IsCancellationRequested)
                        {
                            return;
                        }
                    }
                }, ct);
                Task.Factory.StartNew(() => {
                    podcasts = Podcasts.FetchPodcasts(ref leftPages, ref totalPages, reset);
                    l.SetStatus("Czyszczenie...");
                    Podcasts.CleanUp();
                    cancelled = false;
                    l.Close();
                });
                l.ShowDialog(wnd);
                cts.Cancel();
                if (cancelled || podcasts == null)
                {
                    return;            //Environment.Exit(0);
                }
            }
            wnd.Clear();
            foreach (Category c in Podcasts.categories)
            {
                wnd.AddCategory(c);
            }
            foreach (Podcast p in podcasts)
            {
                wnd.AddPodcast(p);
            }
            wnd.UpdatePodcasts();
            wnd.SetLikedPodcasts(Podcasts.GetLikedPodcasts());
        }
예제 #17
0
 public void AddBookmark(Podcast podcast, string name, double time)
 {
     Podcasts.AddBookmark(podcast, name, (float)time);
     wnd_bookmarks.UpdateBookmarks();
     UpdateAudioInfo(podcast);
 }