コード例 #1
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);
        }
コード例 #2
0
        public Radio()
        {
            this.Visible        = false;
            this.DoubleBuffered = true;

            stationPanel = new StationPanel();
            this.Panel2.Controls.Add(stationPanel);
            stationPanel.AllowDrop = true;

            instance              = this;
            scrollBar             = new QScrollBar(false);
            scrollBar.Width       = SCROLL_BAR_WIDTH;
            scrollBar.UserScroll += new QScrollBar.ScrollDelegate(scroll);
            stationPanel.Controls.Add(scrollBar);

            txtURL = new QTextBoxFocusOnClick();
            stationPanel.Controls.Add(txtURL);
            txtURL.EnableWatermark(stationPanel, Localization.Get(UI_Key.Radio_URL_Watermark), String.Empty);
            txtURL.MaxLength = 2048;
            txtURL.Enter    += (s, e) => { keyPreviewChange(); };
            txtURL.Leave    += (s, e) => { keyPreviewChange(); };
            txtURL.KeyPress += (s, e) =>
            {
                switch (e.KeyChar)
                {
                case '\r':
                    if (txtURL.Text.Length > 0)
                    {
                        go(btnGo);
                    }
                    e.Handled = true;
                    break;
                }
            };

            txtFilter = new QTextBox();
            stationPanel.Controls.Add(txtFilter);
            txtFilter.EnableWatermark(stationPanel, Localization.Get(UI_Key.Radio_Filter_Watermark), String.Empty);
            txtFilter.Enter       += (s, e) => { keyPreviewChange(); };
            txtFilter.Leave       += (s, e) => { keyPreviewChange(); };
            txtFilter.TextChanged += (s, e) => { populateStations(); };

            btnClear = new QButton("X", false, true);
            btnClear.ButtonPressed += new QButton.ButtonDelegate(clear);
            btnClear.BackColor      = stationPanel.BackColor;
            stationPanel.Controls.Add(btnClear);

            btnGo = new QButton(Localization.Get(UI_Key.Radio_Add_And_Play), false, true);
            btnGo.ButtonPressed += new QButton.ButtonDelegate(go);
            btnGo.BackColor      = stationPanel.BackColor;
            stationPanel.Controls.Add(btnGo);

            genrePanel            = new RadioGenreSelectPanel();
            genrePanel.Location   = Point.Empty;
            genrePanel.HeaderText = Localization.Get(UI_Key.Radio_Genres);
            this.Panel1.Controls.Add(genrePanel);

            cells = new List <Cell>();
            setupCells();

            this.Panel1.Resize += (s, e) => { arrangeSelectPanel(); };
            this.Panel2.Resize += (s, e) => { arrangeStationPanel(); };

            stationPanel.MouseMove        += new MouseEventHandler(stationPanelMouseMove);
            stationPanel.MouseDown        += new MouseEventHandler(stationPanelMouseDown);
            stationPanel.MouseUp          += new MouseEventHandler(stationPanelMouseUp);
            stationPanel.Paint            += new PaintEventHandler(stationPanelPaint);
            stationPanel.MouseDoubleClick += new MouseEventHandler(stationPanelDoubleClick);
            stationPanel.MouseWheel       += new MouseEventHandler(stationPanelMouseWheel);
            stationPanel.MouseEnter       += (s, e) => { if (!txtURL.Focused && !txtFilter.Focused)
                                                         {
                                                             stationPanel.Focus();
                                                         }
            };
            stationPanel.MouseLeave += (s, e) => { hoverCell = null; };
            stationPanel.Resize     += (s, e) => { setupCells(); };
            stationPanel.GotFocus   += (s, e) => { stationPanel.Active = true; keyPreviewChange(); };
            stationPanel.LostFocus  += (s, e) => { stationPanel.Active = false; };
            stationPanel.DragEnter  += (s, e) => { onDragEnter(e); };
            stationPanel.DragDrop   += (s, e) => { onDragDrop(e, true); };

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

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

            genrePanel.AllowDrop             = true;
            genrePanel.SelectedIndexChanged += () => { populateStations(); };
            genrePanel.ValueChanged         += new QSelectPanel.ValueEditDelegate(selectPanel_ValueChanged);
            genrePanel.DragEnter            += (s, e) =>
            {
                onDragEnter(e);
            };
            genrePanel.DragDrop         += (s, e) => { onDragDropGenre(e); };
            this.genrePanel.MouseEnter  += (s, e) => { genrePanel.Focus(); };
            this.genrePanel.GotFocus    += (s, e) => { genrePanel.Active = true; };
            this.genrePanel.LostFocus   += (s, e) => { genrePanel.Active = false; };
            this.genrePanel.DoubleClick += (s, e) => { genreDoubleClick(); };

            int tabIndex = 0;

            txtFilter.TabIndex = tabIndex++;
            btnClear.TabIndex  = tabIndex++;
            txtURL.TabIndex    = tabIndex++;
            btnGo.TabIndex     = tabIndex++;
        }