public bool Show(string title, RadioStationItem radioItem)
 {
     _title = title;
     txtName.Text = radioItem.Name;
     txtAddress.Text = radioItem.Address;
     if (base.Show() == MessageBoxResult.Ok)
     {
         radioItem.Name = txtName.Text;
         radioItem.Address = txtAddress.Text;
         return true;
     }
     return false;
 }
Exemple #2
0
        protected override void DrawItem(Bitmap screen, int x, int y, int width, int height, ref int index, object it, Style cStyle)
        {
            bool             selected = _selIndex == index;
            RadioStationItem item     = (RadioStationItem)it;

            if (selected)
            {
                screen.DrawRectangle(Colors.Blue, 0, x, y, width, height, 0, 0,
                                     cStyle.ListBoxSelectedItemBack1, x, y,
                                     cStyle.ListBoxSelectedItemBack2, x, y + height, Enabled ? (ushort)256 : (ushort)128);
            }

            Color textColor = item.IsConnecting ? Colors.Yellow : (item.IsPlaying ? Colors.LightGreen : (Enabled ? (selected ? cStyle.TextBoxPressedTextColor : cStyle.TextBoxEnabledTextColor) : cStyle.TextBoxDisabledTextColor));

            screen.DrawText(item.Name, nameFont, textColor, x + 5, y + 2);
            screen.DrawText(item.Address, textFont, textColor, x + 5, y + 2 + nameFont.Height + 2);
        }
 public void RemoveItem(RadioStationItem item)
 {
     _selIndex = -1;
     base.RemoveItem_(item);
 }
 public void AddItem(RadioStationItem item)
 {
     base.AddItem_(item);
 }
        private static void CreateRadioPanel(Panel panel)
        {
            Label title = new Label("Radio", 5, 5, 200, Fonts.ArialMediumBold.Height) { Font = Fonts.ArialMediumBold };
            panel.AddChild(title);

            const int btSize = 50;
            const int margin = 5;

            int y = title.X + title.Height + margin;
            RadioStationsList radioList = new RadioStationsList(margin, y, panel.Width - margin * 3 - btSize, panel.Height - y - margin * 2 - btSize);

            foreach (RadioStationItem item in AppSettings.Instance.RadioStations)
                radioList.AddItem(item);

            Mp.Ui.Controls.TouchControls.Button btAdd, btRemove, btEdit;
            panel.AddChild(btAdd = new ImageButton(Images.GetBitmap(Images.BitmapResources.imgAdd), radioList.X + radioList.Width + margin, radioList.Y, btSize, btSize));
            panel.AddChild(btRemove = new ImageButton(Images.GetBitmap(Images.BitmapResources.imgDelete), btAdd.X, btAdd.Y + btSize + margin, btSize, btSize));
            panel.AddChild(btEdit = new ImageButton(Images.GetBitmap(Images.BitmapResources.imgEdit), btAdd.X, btRemove.Y + btSize + margin, btSize, btSize));

            EditStationDialog esd = new EditStationDialog();

            #region add/remove/edit events
            btAdd.ButtonPressed += (s) =>
            {
                new Thread(() =>
                {
                    RadioStationItem item = new RadioStationItem("http://", string.Empty);
                    if (esd.Show("New Radio Station", item))
                    {
                        radioList.AddItem(item);
                        AppSettings.Instance.RadioStations.Add(item);
                        AppSettings.Instance.Save();
                    }
                }).Start();
            };

            btRemove.ButtonPressed += (s) =>
            {
                if (radioList.SelectedIndex != -1)
                {
                    RadioStationItem selItem = radioList.SelectedItem;
                    new Thread(() =>
                    {
                        using (MessageBox mb = new MessageBox("Are you sure you want to delete\n" + selItem.Name + "?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcons.Delete))
                            if (mb.Show() == MessageBoxResult.Yes)
                            {
                                radioList.RemoveItem(selItem);
                                AppSettings.Instance.RadioStations.Remove(selItem);
                                AppSettings.Instance.Save();
                            }
                    }).Start();
                }
            };

            btEdit.ButtonPressed += (s) =>
            {
                if (radioList.SelectedIndex != -1)
                {
                    RadioStationItem selItem = radioList.SelectedItem;
                    new Thread(() =>
                    {
                        if (esd.Show("Edit Radio Station", selItem))
                        {
                            radioList.Refresh();
                            AppSettings.Instance.Save();
                        }
                    }).Start();
                }
            };
            #endregion

            ImageButton btPlay, btStop;
            panel.AddChild(btPlay = new ImageButton(Images.GetBitmap(Images.BitmapResources.btPlay), radioList.X, radioList.Y + radioList.Height + margin, btSize, btSize));
            panel.AddChild(btStop = new ImageButton(Images.GetBitmap(Images.BitmapResources.btStop), btPlay.X + btPlay.Width + margin, radioList.Y + radioList.Height + margin, btSize, btSize));

            RadioStationItem playingItem = null;
            int playingIndex = 0;

            VsDriver.VsStatusChanged += (status) =>
            {
                if (playingItem == null) return;
                switch (status)
                {
                    case VsStatus.Connecting:
                        playingItem.IsConnecting = true;
                        radioList.RefreshItem(playingIndex);
                        break;

                    case VsStatus.PlayingRadio:
                        playingItem.IsConnecting = false;
                        playingItem.IsPlaying = true;
                        radioList.RefreshItem(playingIndex);
                        break;

                    case VsStatus.Stopped:
                        playingItem.IsPlaying = false;
                        playingItem.IsConnecting = false;
                        radioList.RefreshItem(playingIndex);
                        break;
                }
            };

            string metaData = null;

            GetRadioInfo += () =>
            {
                return VsDriver.Status == VsStatus.PlayingRadio ? metaData : null;
            };

            char[] metadataSeparators = new char[] { ';' };
            VsDriver.VsRadioMetaDataReceived += (newMetaData) =>
            {
                string[] metaDataParams = newMetaData.Split(metadataSeparators);
                metaData = newMetaData;
            };

            btPlay.ButtonPressed += (s) =>
            {
                if (radioList.SelectedIndex == -1) return;
                if (playingItem == null)
                {
                    playingItem = radioList.SelectedItem;
                    playingIndex = radioList.SelectedIndex;
                }
                else
                {
                    VsDriver.StopRadio();
                    playingItem = radioList.SelectedItem;
                    playingIndex = radioList.SelectedIndex;
                }
                VsDriver.ConnectToStation(playingItem.Address);
            };

            btStop.ButtonPressed += (s) =>
            {
                VsDriver.StopRadio();
                playingItem = null;
            };

            panel.AddChild(radioList);
        }
Exemple #6
0
 public void RemoveItem(RadioStationItem item)
 {
     _selIndex = -1;
     base.RemoveItem_(item);
 }
Exemple #7
0
 public void AddItem(RadioStationItem item)
 {
     base.AddItem_(item);
 }