Beispiel #1
0
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            scrollBar.Bounds = new Rectangle(this.ClientRectangle.Width - SCROLL_BAR_WIDTH,
                                             1,
                                             SCROLL_BAR_WIDTH,
                                             this.ClientRectangle.Height - 2);

            columnWidths.Clear();
            float availWidth = (float)(this.scrollBar.Left - fixedColumnWidths.Sum(w => Math.Max(0, w)));

            for (int i = 0; i < numColumns; i++)
            {
                if (fixedColumnWidths[i] > 0)
                {
                    columnWidths.Add(fixedColumnWidths[i]);
                }
                else
                {
                    columnWidths.Add((int)(columnWidthRatios[i] * availWidth));
                }
            }

            rowRectangles.Clear();
            cellRectangles.Clear();
            int height = this.ClientRectangle.Height - (rowHeight * 3 / 4);
            int width  = this.ClientRectangle.Width;
            int y      = 0;

            while (y < height)
            {
                rowRectangles.Add(new Rectangle(0, y, width, rowHeight));

                int      x  = 0;
                RowCells rc = new QListView <T> .RowCells();

                for (int i = 0; i < numColumns; i++)
                {
                    rc.Add(new Rectangle(x, y, columnWidths[i], rowHeight));
                    x += columnWidths[i];
                }
                y += rowHeight;
                cellRectangles.Add(rc);
            }
            numVisibleRows = rowRectangles.Count - 1;
            updateScrollBarMax();
            this.Invalidate();
        }
        public void PopulateAndSortWithNewEpisodes(QListView <PodcastEpisode> lvwEpisodes)
        {
            Refresh();
            List <PodcastEpisode> ppe;

            lock (episodeLock)
            {
                ppe = episodes.FindAll(e => !e.IsDeleted).ToList();
            }

            lvwEpisodes.Items = ppe;
            lvwEpisodes.Sort();

            if (ppe.Count > 0)
            {
                lvwEpisodes.SelectedItem = lvwEpisodes.Items[0];
            }
        }
Beispiel #3
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);
        }