Esempio n. 1
0
 private void downloadSubscription(PodcastSubscription PS)
 {
     if (!this.Locked)
     {
         Clock.DoOnNewThread(PS.DownloadThisSubscription);
     }
 }
Esempio n. 2
0
 private void btnGetInfo_ButtonPressed(object sender)
 {
     if (!Locked)
     {
         Clock.DoOnNewThread(go);
     }
 }
        private static void startSync()
        {
            if (syncing)
            {
                return;
            }

            syncing = true;

            try
            {
                while (!cancelDownload)
                {
                    PodcastEpisode ep = null;

                    lock (syncQueueLock)
                    {
                        if (syncQueue.Count > 0)
                        {
                            ep = syncQueue[0];
                            syncQueue.RemoveAt(0);
                        }
                        else
                        {
                            cancelDownload = true;
                        }
                    }
                    if (ep != null)
                    {
                        lock (episodeLock)
                        {
                            downloadingEpisodes.Add(ep);
                        }
                        Clock.DoOnNewThread(ep.Download);
                        bool wait;
                        do
                        {
                            lock (episodeLock)
                            {
                                wait = downloadingEpisodes.Count >= Setting.PodcastMaxConcurrentDownloads;
                            }
                            System.Threading.Thread.Sleep(1000);
                        }while (wait);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
            finally
            {
                syncing = false;
            }
        }
Esempio n. 4
0
 private void downloadEpisode(PodcastEpisode PE)
 {
     if (PE.IsQueuedOrDownloading)
     {
         PodcastSubscription.CancelDownload(PE);
     }
     else
     {
         Clock.DoOnNewThread(PE.QueueForDownload);
     }
 }
Esempio n. 5
0
        private void onDragDrop(DragEventArgs drgevent)
        {
            base.OnDragDrop(drgevent);
            string url;

            if (
                (drgevent.Data.GetDataPresent(DataFormats.Text) &&
                 (url = drgevent.Data.GetData(DataFormats.Text).ToString()).StartsWith("http", StringComparison.OrdinalIgnoreCase)))
            {
                txtURL.Text = url;
                Clock.DoOnNewThread(go);
            }
        }
Esempio n. 6
0
        private void makePendingTrackCurrent()
        {
            setViewMode();

            lyrics           = String.Empty;
            albumInfo        = String.Empty;
            artistInfo       = String.Empty;
            albumURL         = String.Empty;
            artistURL        = String.Empty;
            albumReleaseDate = DateTime.MinValue;

            currentTrack = pendingCurrentTrack;

            this.View = AlbumDetailView.Lyrics;

            if (currentTrack == null)
            {
                artwork.CurrentTrack = null;
                txtDescription.SetTextThreadSafe(String.Empty);
                btnPlay.SetEnabledThreadSafe(false);
                btnLink.SetEnabledThreadSafe(false);
                this.Invalidate();
            }
            else
            {
                if (currentTrack.Cover == null)
                {
                    currentTrack.AllowAlbumCoverDownloadThisTrack = true;
                }
                if (currentTrack.Year > 1900 && currentTrack.Year < 2020)
                {
                    albumReleaseDate = new DateTime(currentTrack.Year, 1, 1);
                }
                artwork.CurrentTrack = currentTrack;

                this.Invalidate();

                txtDescription.SetTextThreadSafe(Environment.NewLine +
                                                 Environment.NewLine +
                                                 Localization.Get(UI_Key.Album_Details_Loading_Lyrics));


                btnLink.SetEnabledThreadSafe(false);
                btnPlay.SetEnabledThreadSafe(currentTrack.Album.Length > 0);

                Clock.DoOnNewThread(initUpdateLyrics);
                Clock.DoOnNewThread(initUpdateAlbum);
                Clock.DoOnNewThread(initUpdateArtist);
            }
        }
Esempio n. 7
0
        private void setupItems()
        {
            setupDelay = Clock.NULL_ALARM;

            if (this.Visible)
            {
                this.UseWaitCursor = true;
            }

            renderItem = null;

            Item.ClientArea = new Rectangle(0, btnGenres.Bottom + 5, this.ClientRectangle.Width, this.ClientRectangle.Height - btnGenres.Bottom - 10);
            Clock.DoOnNewThread(setupItemsAsync);
        }
Esempio n. 8
0
 private static void deleteFile()
 {
     try
     {
         if (filesToDelete.Count > 0)
         {
             File.Delete(filesToDelete[0]);
             filesToDelete.RemoveAt(0);
         }
     }
     catch
     {
         Clock.DoOnNewThread(deleteFile, 60000);
     }
 }
 public static void Download(PodcastEpisode PE)
 {
     cancelDownload = false;
     if (PE != null && PE.IsDownloadable)
     {
         PE.SetDownloadStatus(PodcastDownloadStatus.QueuedForDownload);
         lock (syncQueueLock)
         {
             if (!syncQueue.Contains(PE))
             {
                 syncQueue.Add(PE);
                 Clock.DoOnNewThread(startSync, 100);
             }
         }
     }
 }
Esempio n. 10
0
        public static void GetLibrary()
        {
            ITDETECTORLib.iTunesDetector iDetect = new ITDETECTORLib.iTunesDetector();
            if (iDetect.IsiTunesAvailable)
            {
                Controller.ShowMessage("Initializing iTunes...");

                Cancel = false;
                Busy   = true;

                Clock.DoOnNewThread(getLibrary, 200);
            }
            else
            {
                ShowError();
            }
        }
Esempio n. 11
0
        public static void CreatePlaylist(string Name, List <Track> Tracks)
        {
            ITDETECTORLib.iTunesDetector iDetect = new ITDETECTORLib.iTunesDetector();
            if (iDetect.IsiTunesAvailable)
            {
                Controller.ShowMessage("Initializing iTunes...");

                Cancel = false;
                Busy   = true;

                playlistName = Name;
                tracks       = Tracks.ToList();
                Clock.DoOnNewThread(createPlaylist, 200);
            }
            else
            {
                ShowError();
            }
        }
Esempio n. 12
0
        public AudioStreamRadio(RadioStation Station,
                                int PresumedFrequency,
                                Callback FrequencyMismatch,
                                float GainDB,
                                float[] Equalizer,
                                int NumEqBands,
                                bool EqualizerOn,
                                ReplayGainMode ReplayGain) : base(null, GainDB, Equalizer, NumEqBands, EqualizerOn, ReplayGain)
        {
            this.replayGainDB = -6.0f; // Radio is loud, clips a bunch

            controller = Controller.GetInstance();
            Controller.ShowMessageUntilReplaced(Localization.Get(UI_Key.Radio_Connecting));

            this.station = Station;

            presumedFreq = PresumedFrequency;
            frequencyMismatchDelegate = FrequencyMismatch;

            Clock.DoOnNewThread(setup);
        }
Esempio n. 13
0
        // IMAGES

        public static Image MakeSafeImage(Image Input)
        {
            Image i = null;

            System.Diagnostics.Debug.WriteLine(Input.RawFormat.ToString());

            Guid g = Input.RawFormat.Guid;

            if (g == ImageFormat.Jpeg.Guid ||
                g == ImageFormat.Gif.Guid ||
                g == ImageFormat.Png.Guid ||
                g == ImageFormat.Tiff.Guid ||
                g == ImageFormat.Bmp.Guid)
            {
                i = Input;
            }
            else
            {
                try
                {
                    i = convertToJpeg(Input);
                    System.Diagnostics.Debug.Assert(i.RawFormat.Guid == ImageFormat.Jpeg.Guid);

                    if (i == null)
                    {
                        string fn = Path.GetTempFileName();
                        Input.Save(fn, ImageFormat.Jpeg);

                        Clock.DoOnNewThread(deleteFile, 1000); // can't delete right away
                        i = Image.FromFile(fn);
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
                }
            }
            System.Diagnostics.Debug.Assert(i.RawFormat.Guid != ImageFormat.MemoryBmp.Guid);
            return(i);
        }
Esempio n. 14
0
        protected override void ok()
        {
            oldPath = Path.GetFullPath(track.FilePath);

            if (updateThisOnly())
            {
                btnOK.Enabled       = false;
                btnThisOnly.Enabled = false;
                btnCancel.Enabled   = false;
                btnFind.Enabled     = false;
                txtFilePath.Enabled = false;

                newPath = Path.GetFullPath(track.FilePath);

                Clock.DoOnNewThread(doBulkUpdate);
                //System.Threading.Thread t = new System.Threading.Thread(doBulkUpdate);
                //t.Name = "Find File Thread";
                //t.Priority = ThreadPriority.BelowNormal;
                //t.IsBackground = true;
                //t.Start();

                this.Close();
            }
        }
Esempio n. 15
0
 private void checkForNewEpisodes(PodcastSubscription PS)
 {
     Controller.ShowMessage("Checking for podcast updates...");
     Clock.DoOnNewThread(PS.UpdateEpisodeInfo);
 }
Esempio n. 16
0
        public void RequestAction(QActionType Type)
        {
            switch (Type)
            {
            case QActionType.MoveDown:
            case QActionType.MoveTracksDown:
            case QActionType.PageDown:
                txtDescription.FirstVisibleYPixel += 20;
                break;

            case QActionType.SelectNextItemGamePadRight:
                txtDescription.FirstVisibleYPixel += 5;
                break;

            case QActionType.MoveUp:
            case QActionType.MoveTracksUp:
            case QActionType.PageUp:
                txtDescription.FirstVisibleYPixel -= 20;
                break;

            case QActionType.SelectPreviousItemGamePadRight:
                txtDescription.FirstVisibleYPixel -= 5;
                break;

            case QActionType.SelectNextItemGamePadLeft:
            case QActionType.SelectPreviousItemGamePadLeft:
            case QActionType.ReleaseAllFilters:
            case QActionType.ReleaseCurrentFilter:
            case QActionType.NextFilter:
            case QActionType.PreviousFilter:
                // suppress
                break;

            case QActionType.HTPCMode:
                controller.RequestActionNoRedirect(QActionType.HTPCMode);
                setViewMode();
                break;

            case QActionType.AdvanceScreen:
            case QActionType.AdvanceScreenWithoutMouse:
            case QActionType.ShowTrackAndAlbumDetails:
                if (currentTrack == null)
                {
                    // no reason to stay here
                    controller.RequestActionNoRedirect(QActionType.AdvanceScreen);
                }
                else
                {
                    switch (View)
                    {
                    case AlbumDetailView.Lyrics:
                        if (currentTrack.Album.Length == 0)
                        {
                            this.View = AlbumDetailView.ArtistInfo;
                        }
                        else
                        {
                            this.View = AlbumDetailView.AlbumInfo;
                        }
                        break;

                    case AlbumDetailView.AlbumInfo:
                        this.View = AlbumDetailView.ArtistInfo;
                        break;

                    case AlbumDetailView.ArtistInfo:
                        this.View = AlbumDetailView.Lyrics;         // for when we come back
                        controller.RequestActionNoRedirect(QActionType.AdvanceScreen);
                        if (currentTrack != null)
                        {
                            Clock.DoOnNewThread(updateLyrics, 30);
                        }
                        break;
                    }
                }
                break;

            default:
                controller.RequestActionNoRedirect(Type);
                break;
            }
        }
Esempio n. 17
0
        public PodcastManager()
        {
            this.BackColor = Color.Black;
            instance       = this;

            List <string> subHeadings = new List <string>()
            {
                "Podcast Name", "Genre", "Last Download", "Count", "Status", "Reload", "Get All", "Edit", "Remove"
            };
            List <QListView <PodcastSubscription> .ClickDelegate> subActions = new List <QListView <PodcastSubscription> .ClickDelegate>()
            {
                checkForNewEpisodes,
                downloadSubscription,
                showSubscriptionEditPanel,
                removeSubscription
            };

            lvwSubscriptions = new QListView <PodcastSubscription>(subHeadings,
                                                                   subActions,
                                                                   new string[] { String.Empty, "GenreXXXXXX", "Last DownloadXX", "XXXX / XXXX", "XXXX Available", "Reload", "Get All", "Edit", "Remove" },
                                                                   PodcastSubscription.Compare);

            lvwSubscriptions.ContextMenuHook += new QListView <PodcastSubscription> .ContextMenuHookDelegate(lvwSubscriptions_ContextMenuHook);

            lvwSubscriptions.Sort((int)(PodcastSubscription.Columns.Name), true);
            this.Controls.Add(lvwSubscriptions);

            List <string> epHeadings = new List <string>()
            {
                "Title", "Description", "Episode Date", "Status", "Duration", "Download", "Play", "Remove"
            };

            lvwEpisodes = new QListView <PodcastEpisode>(epHeadings,
                                                         new List <QListView <PodcastEpisode> .ClickDelegate>()
            {
                downloadEpisode, playEpisode, removeEpisode
            },
                                                         new string[] { string.Empty, String.Empty, "Episode DateXX", "Downloading XXX%", "DurationXX", "Download", "Play", "Remove" },
                                                         PodcastEpisode.Compare);

            lvwEpisodes.ContextMenuHook += new QListView <PodcastEpisode> .ContextMenuHookDelegate(lvwEpisodes_ContextMenuHook);

            lvwEpisodes.Sort((int)(PodcastEpisode.Columns.Date), false);
            this.Controls.Add(lvwEpisodes);

            btnDone           = new QButton("Done", false, false);
            btnDone.BackColor = this.BackColor;
            this.Controls.Add(btnDone);
            btnDone.ButtonPressed += (s) => { controller.RequestAction(QActionType.AdvanceScreen); };

            btnStopDownloads           = new QButton("Stop Downloads", false, false);
            btnStopDownloads.BackColor = this.BackColor;
            this.Controls.Add(btnStopDownloads);
            btnStopDownloads.Enabled        = false;
            btnStopDownloads.ButtonPressed += (s) => { if (!Locked)
                                                       {
                                                           stopDownloads();
                                                       }
            };

            btnSetDownloadFolder           = new QButton("Set Download Folder...", false, false);
            btnSetDownloadFolder.BackColor = this.BackColor;
            this.Controls.Add(btnSetDownloadFolder);
            btnSetDownloadFolder.ButtonPressed += (s) => { if (!Locked)
                                                           {
                                                               setDownloadFolder();
                                                           }
            };

            btnRefreshAll           = new QButton("Refresh All Subscriptions", false, false);
            btnRefreshAll.BackColor = this.BackColor;
            this.Controls.Add(btnRefreshAll);
            btnRefreshAll.ButtonPressed += (s) => { if (!Locked)
                                                    {
                                                        Clock.DoOnNewThread(autoRefreshSubscriptions);
                                                    }
            };

            btnAutoManage           = new QButton("Auto Manage Options...", false, false);
            btnAutoManage.BackColor = this.BackColor;
            this.Controls.Add(btnAutoManage);
            btnAutoManage.ButtonPressed += (s) => { if (!Locked)
                                                    {
                                                        showAutoManageOptions();
                                                    }
            };

            txtURL = new QTextBoxFocusOnClick();
            this.Controls.Add(txtURL);
            txtURL.MaxLength = 2048;
            txtURL.Enter    += (s, e) => { keyPreviewChange(); };
            txtURL.Leave    += (s, e) => { keyPreviewChange(); };
            txtURL.KeyPress += (s, e) =>
            {
                if (!Locked)
                {
                    switch (e.KeyChar)
                    {
                    case '\r':
                        if (txtURL.Text.Length > 0)
                        {
                            btnGetInfo_ButtonPressed(btnGo);
                        }
                        e.Handled = true;
                        break;
                    }
                }
            };

            txtURL.EnableWatermark(this, "[Type or drag a podcast feed here.]", String.Empty);

            btnGo = new QButton("Add Podcast", false, true);
            btnGo.ButtonPressed += new QButton.ButtonDelegate(btnGetInfo_ButtonPressed);
            btnGo.BackColor      = this.BackColor;
            this.Controls.Add(btnGo);

            lblSubscriptions = new QLabel("Subscriptions", Styles.FontBold);
            this.Controls.Add(lblSubscriptions);

            lblEpisodes = new QLabel("Episodes", Styles.FontBold);
            this.Controls.Add(lblEpisodes);

            txtURL.DragEnter           += (s, e) => { onDragEnter(e); };
            txtURL.DragDrop            += (s, e) => { onDragDrop(e); };
            txtURL.AllowDrop            = true;
            txtURL.Watermark.DragEnter += (s, e) => { onDragEnter(e); };
            txtURL.Watermark.DragDrop  += (s, e) => { onDragDrop(e); };
            txtURL.Watermark.AllowDrop  = true;

            lvwSubscriptions.ClickCallback += new QListView <PodcastSubscription> .ClickDelegate(populateEpisodes);

            lvwSubscriptions.DoubleClickCallback += new QListView <PodcastSubscription> .ClickDelegate(lvwSubscriptions_DoubleClickCallback);

            lvwSubscriptions.DragEnter += (s, e) => { onDragEnter(e); };
            lvwSubscriptions.DragDrop  += (s, e) => { onDragDrop(e); };
            lvwSubscriptions.AllowDrop  = true;

            lvwEpisodes.DoubleClickCallback += new QListView <PodcastEpisode> .ClickDelegate(lvwEpisodes_DoubleClickCallback);

            lvwEpisodes.ClickCallback += new QListView <PodcastEpisode> .ClickDelegate(lvwEpisodes_ClickCallback);
        }