Esempio n. 1
0
        private bool onDragDrop(DragEventArgs drgevent, bool Play)
        {
            base.OnDragDrop(drgevent);
            string url;

            if (
                (drgevent.Data.GetDataPresent(DataFormats.Text) &&
                 (url = drgevent.Data.GetData(DataFormats.Text).ToString()).StartsWith("http", StringComparison.OrdinalIgnoreCase)))
            {
                Radio.AddStation(url, String.Empty, Play);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        private bool readTags(string[] Tags)
        {
            List <string> tags = new List <string>(Tags);

            if (station.Name.Length == 0)
            {
                string nameMarker = "icy-name:";
                string name       = tags.FirstOrDefault(s => s.StartsWith(nameMarker, StringComparison.OrdinalIgnoreCase));
                if (name != null)
                {
                    station.Name = name.Substring(nameMarker.Length).Trim();
                    Radio.StationNameChanged();
                }
            }
            if (station.BitRate == 0)
            {
                string bitRateMarker = "icy-br:";
                string bitRate       = tags.FirstOrDefault(s => s.StartsWith(bitRateMarker, StringComparison.OrdinalIgnoreCase));
                if (bitRate != null)
                {
                    int br;
                    if (Int32.TryParse(bitRate.Substring(bitRateMarker.Length).Trim(), out br))
                    {
                        station.BitRate = br;
                        Radio.InvalidateInstance();
                    }
                }
            }
            if (station.Genre.Length == 0)
            {
                string genreMarker = "icy-genre:";
                string genre       = tags.FirstOrDefault(s => s.StartsWith(genreMarker, StringComparison.OrdinalIgnoreCase));
                if (genre != null)
                {
                    station.Genre = genre.Substring(genreMarker.Length).Trim();
                    Radio.StationGenreChanged();
                }
            }
            return(false);
        }
Esempio n. 3
0
        private void getTagsFromURL()
        {
            if (BassTags.BASS_TAG_GetFromURL(streamRef, tagInfo))
            {
                int trackNum = 0;
                Int32.TryParse(tagInfo.track, out trackNum);
                int year = 0;
                Int32.TryParse(tagInfo.year, out year);
                Track t = new Track(0,
                                    tagInfo.title + tagInfo.artist, // need something since equals uses filepath
                                    Track.FileType.None,
                                    tagInfo.title,
                                    String.Empty,
                                    tagInfo.artist,
                                    tagInfo.albumartist,
                                    tagInfo.composer,
                                    String.Empty,
                                    String.Empty,
                                    0,
                                    trackNum,
                                    0,
                                    year,
                                    0,
                                    0,
                                    tagInfo.bitrate,
                                    0,
                                    false,
                                    DateTime.Now,
                                    DateTime.Now,
                                    DateTime.Now,
                                    tagInfo.encodedby,
                                    tagInfo.channelinfo.chans,
                                    tagInfo.channelinfo.sample,
                                    ChangeType.None,
                                    null,
                                    float.MinValue,
                                    float.MinValue);

                if (station.Name.Length == 0 && tagInfo.album.Trim().Length > 0)
                {
                    station.Name = tagInfo.album.Trim();
                    Radio.StationNameChanged();
                }
                if (station.Name.Length == 0 && tagInfo.title.Trim().Length > 0)
                {
                    station.Name = tagInfo.title.Trim();
                    Radio.StationNameChanged();
                }
                if (station.Genre.Length == 0 && tagInfo.genre.Trim().Length > 0)
                {
                    station.Genre = tagInfo.genre.Trim();
                    Radio.StationGenreChanged();
                }

                if (tagInfo.bitrate > 0)
                {
                    station.BitRate = tagInfo.bitrate;
                }

                Radio.InvalidateInstance();
                controller.RadioTrack = t;
                controller.Invalidate();
            }
        }
Esempio n. 4
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++;
        }