private void SaveRadioChannels()
 {
     using (var writer = new StreamWriter(AppDataFile))
     {
         var serializer = new XmlSerializer(typeof(List <RadioChannel>));
         serializer.Serialize(writer, RadioChannels.ToList());
     }
 }
        public void DeleteRadioChannel()
        {
            if (SelectedRadioChannel != null)
            {
                var result = dialogService.ShowMessageBox("Do you want to remove this channel?", "Remove channel", MessageBoxButton.YesNo);

                if (result == MessageBoxResult.Yes)
                {
                    RadioChannels.Remove(SelectedRadioChannel);
                    SaveRadioChannels();
                }
            }
        }
Esempio n. 3
0
    /// <summary>
    /// Given a (shy internal) channel number, get the Channel
    /// </summary>
    /// <param name="internalChannelNumber"></param>
    /// <returns></returns>
    private Channel GetChannelByInternalNumber(
        int internalChannelNumber)
    {
        if (AllChannels.ContainsKey(internalChannelNumber))
        {
            return(AllChannels[internalChannelNumber]);
        }

        if (RadioChannels.ContainsKey(internalChannelNumber))
        {
            return(RadioChannels[internalChannelNumber]);
        }

        return(null);
    }
        public void AddNewRadioChannel()
        {
            var channel = new RadioChannel
            {
                ChannelName = string.Empty,
            };

            var channelViewModel = new ChannelViewModel {
                RadioChannel = channel, DialogService = dialogService
            };

            if (dialogService.ShowDialog(channelViewModel) == true)
            {
                RadioChannels.Add(channel);
                SaveRadioChannels();
            }
        }
Esempio n. 5
0
        private void Init()
        {
            CheckForIllegalCrossThreadCalls = false;
            //
            // Set caption
            //
            Text = "MediaPortal - TV Server Configuration";

            //
            // Build options tree
            //
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(String.Format(@"{0}\gentle.config", PathManager.GetDataPath));
                XmlNode nodeKey      = doc.SelectSingleNode("/Gentle.Framework/DefaultProvider");
                XmlNode node         = nodeKey.Attributes.GetNamedItem("connectionString");
                XmlNode nodeProvider = nodeKey.Attributes.GetNamedItem("name");

                Gentle.Framework.ProviderFactory.ResetGentle(true);
                Gentle.Framework.GentleSettings.DefaultProviderName = nodeProvider.InnerText;
                Gentle.Framework.ProviderFactory.GetDefaultProvider();
                Gentle.Framework.ProviderFactory.SetDefaultProviderConnectionString(node.InnerText);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to open:" + String.Format(@"{0}\gentle.config", PathManager.GetDataPath));
                Log.Write(ex);
            }

            try
            {
                Server.ListAll();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to open database");
                Log.Error("Unable to get list of servers");
                Log.Write(ex);
            }

            Project project = new Project();

            AddSection(project);

            layer   = new TvBusinessLayer();
            servers = new Servers();
            AddSection(servers);
            IList <Server> dbsServers = Server.ListAll();

            if (dbsServers != null)
            {
                foreach (Server server in dbsServers)
                {
                    if (server.IsMaster)
                    {
                        bool connected = false;
                        while (!connected)
                        {
                            RemoteControl.HostName = server.HostName;

                            if (server.ReferringCard().Count > 0)
                            {
                                try
                                {
                                    Card c = (Card)server.ReferringCard()[0];
                                    RemoteControl.Instance.Type(c.IdCard);
                                    connected = true;
                                }
                                catch (Exception ex)
                                {
                                    string localHostname = Dns.GetHostName();
                                    if (localHostname != server.HostName)
                                    {
                                        DialogResult dlg = MessageBox.Show(String.Format("Unable to connect to <{0}>.\n" +
                                                                                         "Do you want to try the current comupter name ({1}) instead?",
                                                                                         server.HostName, localHostname),
                                                                           "Wrong config detected",
                                                                           MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                                        if (dlg == DialogResult.Yes)
                                        {
                                            Log.Info("Controller: server {0} changed to {1}", server.HostName, localHostname);
                                            server.HostName = localHostname;
                                            server.Persist();
                                            RemoteControl.Clear();
                                            ServiceHelper.Restart();
                                            ServiceHelper.WaitInitialized();
                                        }
                                        else
                                        {
                                            MessageBox.Show("Setup will now close");
                                            Environment.Exit(-1);
                                        }
                                    }
                                    else
                                    {
                                        Log.Error("Cannot connect to server {0}", server.HostName);
                                        Log.Write(ex);
                                        DialogResult dlg = MessageBox.Show("Unable to connect to <" + server.HostName + ">.\n" +
                                                                           "Please check the TV Server logs for details.\n\n" +
                                                                           "Setup will now close.");
                                        Environment.Exit(-1);
                                    }
                                }
                            }
                        }
                        break;
                    }
                }

                AddServerTvCards(servers, dbsServers, false);

                TvChannels tvChannels = new TvChannels();
                AddSection(tvChannels);
                AddChildSection(tvChannels, new TvCombinations("TV Combinations"));
                AddChildSection(tvChannels, new TvChannelMapping());

                RadioChannels radioChannels = new RadioChannels();
                AddSection(radioChannels);
                AddChildSection(radioChannels, new RadioCombinations("Radio Combinations"));
                AddChildSection(radioChannels, new RadioChannelMapping());

                Epg EpgSection = new Epg();
                AddSection(EpgSection);
                AddChildSection(EpgSection, new TvEpgGrabber());
                AddChildSection(EpgSection, new RadioEpgGrabber());

                AddSection(new EpgGenreMap());
                AddSection(new ScanSettings());
                AddSection(new TvRecording());
                AddSection(new TvTimeshifting());
                AddSection(new TvSchedules());
                AddSection(new StreamingServer());
                AddSection(new UserPriorities());

                AddSection(new TestService("Manual Control"));
                AddSection(new TestChannels("Test Channels"));

                _pluginLoader.Load();
                pluginsRoot = new Plugins("Plugins", _pluginLoader);
                AddSection(pluginsRoot);

                pluginsRoot.ChangedActivePlugins += SectChanged;

                foreach (ITvServerPlugin plugin in _pluginLoader.Plugins)
                {
                    SectionSettings settings = plugin.Setup;
                    if (settings != null)
                    {
                        Setting isActive = layer.GetSetting(String.Format("plugin{0}", plugin.Name), "false");
                        settings.Text = plugin.Name;
                        if (isActive.Value == "true")
                        {
                            AddChildSection(pluginsRoot, settings);
                        }
                    }
                }
                if (showAdvancedSettings)
                {
                    AddSection(new DebugOptions());
                }
                AddSection(new ImportExport());
                AddSection(new ThirdPartyChecks());

                sectionTree.SelectedNode = sectionTree.Nodes[0];
                // make sure window is in front of mediaportal
            }
            BringToFront();
        }