Example #1
0
        public override bool Init()
        {
            grabber = new RadioTime();

            updateStationLogoTimer.AutoReset = true;
            updateStationLogoTimer.Enabled   = false;
            updateStationLogoTimer.Elapsed  -= OnDownloadTimedEvent;
            updateStationLogoTimer.Elapsed  += OnDownloadTimedEvent;
            Client.DownloadFileCompleted    += Client_DownloadFileCompleted;
            return(Load(GUIGraphicsContext.Skin + @"\RadioTimePresets.xml"));
        }
Example #2
0
        public override bool Init()
        {
            grabber = new RadioTime();

            updateStationLogoTimer.AutoReset = true;
            updateStationLogoTimer.Enabled   = false;
            updateStationLogoTimer.Elapsed  -= new ElapsedEventHandler(OnDownloadTimedEvent);
            updateStationLogoTimer.Elapsed  += new ElapsedEventHandler(OnDownloadTimedEvent);
            Client.DownloadFileCompleted    += new System.ComponentModel.AsyncCompletedEventHandler(Client_DownloadFileCompleted);
            return(Load(GUIGraphicsContext.Skin + @"\RadioTimePresets.xml"));
        }
Example #3
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 #4
0
 public Form1()
 {
     InitializeComponent();
     grabber = new RadioTime();
 }
Example #5
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 #6
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);
        }
 public RadioTimeViewModel(RadioTime rt, bool isReadOnly)
 {
     this.AllowEdit    = !isReadOnly;
     this.RadioTimeObj = rt;
     RejectChanges();
 }