예제 #1
0
        public bool Play(RadioStation Station)
        {
            bool newStation = false;

            if (Stream.URL != Station.URL)
            {
                controller.RadioTrack = null;

                newStation = true;

                Stream s = Stream;
                Stream = new AudioStreamRadio(Station,
                                              output.Frequency,
                                              matchFrequencies,
                                              gainDB + volumeDB,
                                              equalizer,
                                              numEqBands,
                                              equalizerOn,
                                              controller.ReplayGain);
                s.Close();
                s.Dispose();
            }

            playMode = PlayMode.Radio;
            Paused   = false;
            return(newStation);
        }
예제 #2
0
        public override bool Equals(object obj)
        {
            RadioStation other = obj as RadioStation;

            if (other == null)
            {
                return(false);
            }
            else
            {
                return(String.Compare(this.URL, other.URL, StringComparison.OrdinalIgnoreCase) == 0);
            }
        }
예제 #3
0
        public void genreDoubleClick()
        {
            if (!Locked)
            {
                if (selectedStation == null)
                {
                    if (filteredStations.Count == 0)
                    {
                        return;
                    }

                    SelectedStation = filteredStations[0];
                }
                InvokeSelectedStation();
            }
        }
예제 #4
0
        private void removeStation(RadioStation RS)
        {
            if (RS != null)
            {
                lock (@lock)
                {
                    stations.Remove(RS);
                    filteredStations.Remove(RS);
                }
                if (RS.Equals(SelectedStation))
                {
                    SelectedStation = null;
                }

                populateStations();
                populateGenres();
            }
        }
예제 #5
0
        public static void AddStation(string URL, string Name, bool Play)
        {
            RadioStation rs;

            lock (@lock)
            {
                rs = stations.FirstOrDefault(s => String.Compare(s.URL, URL, StringComparison.OrdinalIgnoreCase) == 0);
            }
            if (rs == null)
            {
                rs = new RadioStation(URL, Name);
                lock (@lock)
                {
                    stations.Add(rs);
                }
            }
            else if (rs.Name.Length == 0)
            {
                rs.Name = Name;
            }

            instance.SelectedStation = rs;

            sort();

            instance.populateStations();

            if (!filteredStations.Contains(rs))
            {
                instance.genrePanel.Value = String.Empty;
                instance.txtFilter.Text   = String.Empty;
                instance.populateStations();
            }
            instance.populateGenres();

            instance.SelectedStation = rs;

            if (Play)
            {
                instance.InvokeSelectedStation();
            }
            instance.ensureSelectedStationVisible();
        }
예제 #6
0
 private void onDragDropGenre(DragEventArgs drgevent)
 {
     if (!Locked)
     {
         if (onDragDrop(drgevent, false))
         {
             string genre = genrePanel.GetValueAt(genrePanel.PointToClient(new Point(drgevent.X, drgevent.Y)).Y);
             if (genre.Length > 0)
             {
                 string       url = drgevent.Data.GetData(DataFormats.Text).ToString();
                 RadioStation rs  = stations.FirstOrDefault(s => String.Compare(s.URL, url, StringComparison.OrdinalIgnoreCase) == 0);
                 if (rs != null)
                 {
                     rs.Genre = genre;
                     populateGenres();
                 }
             }
         }
     }
 }
예제 #7
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);
        }
예제 #8
0
        public RadioEditPanel(RadioStation Station, string[] GenreList, Radio.StationEditComplete Callback) : base()
        {
            SPACING = 8;

            station  = Station;
            callback = Callback;

            lblName = new QLabel("&Name");
            lblName.ShowAccellerator();
            this.Controls.Add(lblName);

            lblGenre = new QLabel("&Genre");
            lblGenre.ShowAccellerator();
            this.Controls.Add(lblGenre);

            lblBitRate = new QLabel("&Bit Rate");
            lblBitRate.ShowAccellerator();
            this.Controls.Add(lblBitRate);

            lblStreamType = new QLabel("&Stream Type");
            lblStreamType.ShowAccellerator();
            this.Controls.Add(lblStreamType);

            lblURL = new QLabel("&URL");
            lblURL.ShowAccellerator();
            this.Controls.Add(lblURL);

            txtName           = new QTextBox();
            txtName.Width     = 1000;
            txtName.MaxLength = 140;
            txtName.GotFocus += (s, e) => txtName.SelectAll();
            this.Controls.Add(txtName);

            cboGenre           = new QComboBox(true);
            cboGenre.MaxLength = 30;
            cboGenre.Items.AddRange(GenreList);
            this.Controls.Add(cboGenre);

            txtBitrate             = new QTextBox();
            txtBitrate.NumericOnly = true;
            txtBitrate.MaxLength   = 3;
            this.Controls.Add(txtBitrate);

            cboStreamType = new QComboBox(false);
            cboStreamType.Items.AddRange(RadioStation.StreamTypeArray);
            this.Controls.Add(cboStreamType);

            txtURL           = new QTextBox();
            txtURL.MaxLength = 2048;
            this.Controls.Add(txtURL);

            txtName.Text  = station.Name;
            cboGenre.Text = station.Genre;
            if (station.BitRate > 0)
            {
                txtBitrate.Text = station.BitRate.ToString();
            }
            else
            {
                txtBitrate.Text = String.Empty;
            }

            cboStreamType.SelectedIndex = (int)station.StreamType;
            txtURL.Text = station.URL;

            btnOK = new QButton(Localization.OK, false, false);
            AddButton(btnOK, ok);
            btnCancel = new QButton(Localization.CANCEL, false, false);
            AddButton(btnCancel, cancel);

            resize();

            this.ClientSize = new Size(this.ClientRectangle.Width, btnOK.Bottom + MARGIN);

            int tabIndex = 0;

            lblName.TabIndex       = tabIndex++;
            txtName.TabIndex       = tabIndex++;
            lblGenre.TabIndex      = tabIndex++;
            cboGenre.TabIndex      = tabIndex++;
            lblURL.TabIndex        = tabIndex++;
            txtURL.TabIndex        = tabIndex++;
            lblBitRate.TabIndex    = tabIndex++;
            txtBitrate.TabIndex    = tabIndex++;
            lblStreamType.TabIndex = tabIndex++;
            cboStreamType.TabIndex = tabIndex++;
            btnOK.TabIndex         = tabIndex++;
            btnCancel.TabIndex     = tabIndex++;

            setWrapAroundTabControl(tabIndex, txtName, null);

            initialized = true;
        }
예제 #9
0
 public Cell(Rectangle Rectangle, RadioStation Station) : this(Rectangle)
 {
     this.Station = Station;
 }
예제 #10
0
        private void renderStation(Graphics g, Cell Cell, RadioStation Station)
        {
            if (Station != null)
            {
                string name = Station.Name;

                if (name.Length == 0)
                {
                    name = Localization.Get(UI_Key.Radio_Blank_Name);
                }

                Color c = (Station.Equals(playingStation)) ? Styles.Playing : Styles.LightText;

                if (htpcMode == HTPCMode.HTPC)
                {
                    TextRenderer.DrawText(g, name, Styles.FontHTPC, Cell.MainRectangle, c, tff);
                }
                else
                {
                    TextRenderer.DrawText(g, name, Styles.FontBold, Cell.FirstRow, c, tff);
                }

                if (this.HTPCMode == HTPCMode.Normal)
                {
                    TextRenderer.DrawText(g, Station.Genre, Styles.Font, Cell.FirstRow, Styles.LightText, tffr);

                    if (Cell.Equals(hoverCell))
                    {
                        TextRenderer.DrawText(g, Station.URL, Styles.FontItalic, Cell.SecondRow, Styles.LightText, tff);
                        if (object.Equals(Cell.Station, SelectedStation))
                        {
                            if (removeHover)
                            {
                                TextRenderer.DrawText(g, "Remove", Styles.FontUnderline, Cell.SecondRow, Styles.LightText, tffr);
                            }
                            else
                            {
                                TextRenderer.DrawText(g, "Remove", Styles.Font, Cell.SecondRow, Styles.LightText, tffr);
                            }
                        }
                        else
                        if (removeHover)
                        {
                            TextRenderer.DrawText(g, "Remove", Styles.FontUnderline, Cell.SecondRow, Styles.VeryLight, tffr);
                        }
                        else
                        {
                            TextRenderer.DrawText(g, "Remove", Styles.Font, Cell.SecondRow, Styles.Light, tffr);
                        }
                    }
                    else
                    {
                        TextRenderer.DrawText(g, Station.URL, Styles.FontItalic, Cell.SecondRow, Styles.Light, tff);
                        if (Station.BitRate > 0)
                        {
                            if (Cell.Equals(hoverCell))
                            {
                                TextRenderer.DrawText(g, Station.BitRateString, Styles.Font, Cell.SecondRow, Styles.Medium, tffr);
                            }
                            else
                            {
                                TextRenderer.DrawText(g, Station.BitRateString, Styles.Font, Cell.SecondRow, Styles.LightText, tffr);
                            }
                        }
                    }
                }
            }
        }