コード例 #1
0
        private void comboBoxGroups_DropDown(object sender, EventArgs e)
        {
            // Save current cursor and display wait cursor
            Cursor currentCursor = Cursor.Current;

            Cursor.Current = Cursors.WaitCursor;

            // Fill comboBox with radio channel names
            comboBoxGroups.Items.Clear();
            comboBoxGroups.Items.Add("(none)");
            int selectedIdx = 0;

            if (string.IsNullOrEmpty(TVRadio.Hostname))
            {
                MessageBox.Show("Unable to get radio channel groups from the TV Server." +
                                Environment.NewLine + "No valid hostname specified in the \"TV/Radio\" section.",
                                "Radio Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                TvServerRemote.HostName = TVRadio.Hostname;
                List <string> groupNames = TvServerRemote.GetRadioChannelGroupNames();
                if (groupNames.Count == 0)
                {
                    MessageBox.Show(string.Format("Unable to get radio channel groups from the TV Server on host \"{0}\".", TVRadio.Hostname) +
                                    Environment.NewLine + "Version incompatibility of MP Client and TV Server?",
                                    "Radio Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    foreach (string groupName in groupNames)
                    {
                        int idx = comboBoxGroups.Items.Add(groupName);
                        if (groupName == _rootGroup)
                        {
                            selectedIdx = idx;
                        }
                    }
                }
            }
            comboBoxGroups.SelectedIndex = selectedIdx;

            // Reset cursor
            Cursor.Current = currentCursor;
        }