Example #1
0
        public void LoadLocalPresetStations()
        {
            _setting.PresetStations.Clear();
            for (var i = 0; i < Settings.LocalPresetsNumber; i++)
            {
                _setting.PresetStations.Add(new RadioTimeOutline());
            }
            var ii = 0;

            ShowWaitCursor();
            try
            {
                Process();
                grabber.GetData(_setting.PresetsUrl, false, false, Translation.Presets);

                var folderCount = 0;
                foreach (var body in grabber.Body)
                {
                    if (body.Type == RadioTimeOutline.OutlineType.link)
                    {
                        folderCount++;
                    }
                }

                if (folderCount == 0)
                {
                    GUIPropertyManager.SetProperty("#RadioTime.Presets.Folder.Name", string.Empty);
                }
                else
                {
                    var i = 0;
                    foreach (var body in grabber.Body)
                    {
                        if (body.GuidId == _setting.FolderId)
                        {
                            ii = i;
                        }
                        i++;
                    }
                    GUIPropertyManager.SetProperty("#RadioTime.Presets.Folder.Name", grabber.Body[ii].Text);
                    grabber.GetData(grabber.Body[ii].Url, false, false);
                }

                foreach (var body in grabber.Body)
                {
                    if (!string.IsNullOrEmpty(body.PresetNumber) &&
                        body.PresetNumberAsInt - 1 < Settings.LocalPresetsNumber)
                    {
                        _setting.PresetStations[body.PresetNumberAsInt - 1] = body;
                    }
                    Process();
                }

                PopulatePresetsLabels();
            }
            finally
            {
                HideWaitCursor();
            }
        }
Example #2
0
        public string GetPresetFolder()
        {
            var tempGrabber = new RadioTime();

            tempGrabber.Settings = _setting;
            tempGrabber.GetData(_setting.PresetsUrl, false, Translation.Presets);

            var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return(null);
            }
            dlg.Reset();
            dlg.SetHeading(Translation.SelectPresetFolder);

            var canShow = false;

            foreach (var body in tempGrabber.Body)
            {
                if (body.Type == RadioTimeOutline.OutlineType.link)
                {
                    dlg.Add(body.Text);
                    canShow = true;
                }
            }

            if (canShow)
            {
                dlg.DoModal(GetID);
                if (dlg.SelectedId == -1)
                {
                    return(null);
                }
                return(tempGrabber.Body[dlg.SelectedId - 1].GuidId);
            }
            else
            {
                return(noPresetFolders);
            }
        }
Example #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     set.User = textBoxUser.Text;
     grabber.GetData(set.StartupUrl);
     RefreshList();
 }
Example #4
0
        /// <summary>
        /// Adds to favorites.
        /// </summary>
        /// <param name="p">The station id.</param>
        private void AddToFavorites(string presetid)
        {
            List <RadioTimeOutline> tempresets = new List <RadioTimeOutline>();

            string    folderid    = "";
            string    selectedID  = "";
            RadioTime tempGrabber = new RadioTime();

            tempGrabber.Settings = _setting;
            tempGrabber.GetData(_setting.PresetsUrl, false, false, Translation.Presets);

            int folderCount = 0;

            foreach (RadioTimeOutline body in tempGrabber.Body)
            {
                if (body.Type == RadioTimeOutline.OutlineType.link)
                {
                    folderCount++;
                }
            }

            if (folderCount == 0) // only one preset folder (main) - plugin chooses first empty space to put preset
            {
                // first i have to fill the list with taken preset numbers
                List <int> takenPresets = new List <int>();
                foreach (RadioTimeOutline body in tempGrabber.Body)
                {
                    if (!string.IsNullOrEmpty(body.PresetNumber))
                    {
                        takenPresets.Add(body.PresetNumberAsInt);
                    }
                }

                int i = 1;
                while (takenPresets.Contains(i)) // find empty space
                {
                    i++;
                }

                selectedID = i.ToString();
            }
            else // more folders - ask user
            {
                var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                if (dlg == null)
                {
                    return;
                }
                dlg.Reset();
                dlg.SetHeading(Translation.SelectPresetFolder);

                foreach (RadioTimeOutline body in tempGrabber.Body)
                {
                    if (body.Type == RadioTimeOutline.OutlineType.link)
                    {
                        dlg.Add(body.Text);
                    }
                }

                dlg.DoModal(GetID);
                if (dlg.SelectedId == -1)
                {
                    return;
                }
                folderid = tempGrabber.Body[dlg.SelectedId - 1].GuidId;

                tempGrabber.GetData(tempGrabber.Body[dlg.SelectedId - 1].Url, false, false);

                // first i have to find out the largest preset number
                int biggestPresetNumber = 0;
                foreach (RadioTimeOutline body in tempGrabber.Body)
                {
                    if (!string.IsNullOrEmpty(body.PresetNumber) && body.PresetNumberAsInt > biggestPresetNumber)
                    {
                        biggestPresetNumber = body.PresetNumberAsInt;
                    }
                }

                // then i fill x number of presets
                for (int i = 0; i < (biggestPresetNumber + Settings.LOCAL_PRESETS_NUMBER); i++)
                {
                    tempresets.Add(new RadioTimeOutline());
                }

                // then i fill the list with existing presets from the folder
                foreach (RadioTimeOutline body in tempGrabber.Body)
                {
                    if (!string.IsNullOrEmpty(body.PresetNumber) && body.PresetNumberAsInt - 1 < tempresets.Count)
                    {
                        tempresets[body.PresetNumberAsInt - 1] = body;
                    }
                }

                dlg.Reset();
                dlg.SetHeading(Translation.SelectPresetNumber);

                for (int i = 0; i < tempresets.Count; i++)
                {
                    RadioTimeOutline outline = tempresets[i];
                    if (string.IsNullOrEmpty(outline.Text))
                    {
                        dlg.Add(string.Format("<{0}>", Translation.Empty));
                    }
                    else
                    {
                        dlg.Add(outline.Text);
                    }
                }

                dlg.DoModal(GetID);

                if (dlg.SelectedId == -1)
                {
                    return;
                }

                selectedID = dlg.SelectedId.ToString();
            }

            try
            {
                grabber.AddPreset(presetid, folderid, selectedID);
                //UpdateList();
            }
            catch (Exception)
            {
                ErrMessage(Translation.ComunicationError);
            }
        }
Example #5
0
        //// do the clicked action
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            ////
            //// look for button pressed
            ////
            //// record ?
            if (actionType == Action.ActionType.ACTION_RECORD)
            {
                //ExecuteRecord();
            }
            else if (control == btnSwitchView)
            {
                switch ((View)mapSettings.ViewAs)
                {
                case View.List:
                    mapSettings.ViewAs = (int)View.Icons;
                    break;

                case View.Icons:
                    mapSettings.ViewAs = (int)View.BigIcons;
                    break;

                case View.BigIcons:
                    mapSettings.ViewAs = (int)View.List;
                    break;
                }
                ShowPanel();
                // GUIControl.FocusControl(GetID, listControl.GetID);
            }
            else if (control == listControl)
            {
                // execute only for enter keys
                if (actionType == Action.ActionType.ACTION_SELECT_ITEM)
                {
                    // station selected
                    DoListSelection();
                }
            }
            else if (control == sortButton)
            {
                //sort button selected
                OnShowSortOptions();
                GUIControl.FocusControl(GetID, listControl.GetID);
            }
            else if (control == searchArtistButton)
            {
                DoSearchArtist();
                GUIControl.FocusControl(GetID, listControl.GetID);
            }
            else if (control == searchButton)
            {
                DoSearch();
                GUIControl.FocusControl(GetID, listControl.GetID);
            }
            else if (control == homeButton)
            {
                ShowPanel();
                DoHome();
                GUIControl.FocusControl(GetID, listControl.GetID);
            }
            else if (control == genresButton)
            {
                ShowPanel();
                DoGenres();
                GUIControl.FocusControl(GetID, listControl.GetID);
            }
            else if (control == presetsButton)
            {
                ShowPanel();
                DoPresets();
                GUIControl.FocusControl(GetID, listControl.GetID);
            }
            else if (control == nowPlayingButton)
            {
                GUIWindowManager.ActivateWindow(25652);
            }
            else if (control == localpresetsButton)
            {
                GUIWindowManager.ActivateWindow(25653);
            }
            else if (control == randomButton)
            {
                GUIControl.FocusControl(GetID, listControl.GetID);
                RadioTime gr = new RadioTime();
                gr.Settings = grabber.Settings;
                gr.GetData(grabber.CurentUrl + "&filter=random");
                if (gr.Body.Count == 1)
                {
                    if (!string.IsNullOrEmpty(gr.Body[0].GuidId))
                    {
                        DoPlay(gr.Body[0]);
                    }
                    else if (!string.IsNullOrEmpty(gr.Body[0].Text))
                    {
                        ErrMessage(gr.Body[0].Text);
                    }
                }
                else
                {
                    ErrMessage(Translation.NoStationsOrShowsAvailable);
                }
            }
            base.OnClicked(controlId, control, actionType);
        }