示例#1
0
        /// <summary>
        /// Called when a plugin is selected or deselected for activation in the plugins setting
        /// </summary>
        /// <param name="sender">a Setting parameter passed as object</param>
        /// <param name="e">eventarg will always retrun empty</param>
        public void SectChanged(object sender, EventArgs e)
        {
            string name = ((Setting)sender).Tag.Substring(6);

            foreach (ITvServerPlugin plugin in _pluginLoader.Plugins)
            {
                SectionSettings settings = plugin.Setup;
                if (settings != null && plugin.Name == name)
                {
                    Setting isActive = layer.GetSetting(((Setting)sender).Tag, "false");
                    settings.Text = name;

                    if (isActive.Value == "true")
                    {
                        AddChildSection(pluginsRoot, settings);
                        LoadChildSettingsFromNode(pluginsRoot, settings);
                    }
                    else
                    {
                        RemoveChildSection(pluginsRoot, settings);
                        SaveChildSettingsFromNode(pluginsRoot, settings);
                    }

                    break;
                }
            }
        }
示例#2
0
 public SectionHolder(SectionSettings section, string topic, string information, string expression)
 {
     Section     = section;
     Topic       = topic;
     Information = information;
     Expression  = expression;
 }
示例#3
0
    public virtual void AddChildSection(SectionSettings parentSection, SectionSettings section)
    {
      //
      // Make sure this section doesn't already exist
      //

      //
      // Add section to tree
      //
      SectionTreeNode treeNode = new SectionTreeNode(section);

      if (parentSection == null)
      {
        //
        // Add to the root
        //
        sectionTree.Nodes.Add(treeNode);
      }
      else
      {
        //
        // Add to the parent node
        //
        SectionTreeNode parentTreeNode = (SectionTreeNode)settingSections[parentSection.Text];
        parentTreeNode.Nodes.Add(treeNode);
      }

      settingSections.Add(section.Text, treeNode);

      //treeNode.EnsureVisible();
    }
示例#4
0
        public override void AddChildSection(SectionSettings parentSection, SectionSettings section)
        {
            //
            // Make sure this section doesn't already exist
            //

            //
            // Add section to tree
            //
            SectionTreeNode treeNode = new SectionTreeNode(section);

            if (parentSection == null)
            {
                //
                // Add to the root
                //
                sectionTree.Nodes.Add(treeNode);
            }
            else
            {
                //
                // Add to the parent node
                //
                SectionTreeNode parentTreeNode = (SectionTreeNode)settingSections[parentSection.Text];
                treeNode.Name = section.Text;
                parentTreeNode.Nodes.Add(treeNode);
            }

            settingSections.Add(section.Text, treeNode);

            //treeNode.EnsureVisible();
        }
示例#5
0
 public void SaveChildSettingsFromNode(SectionSettings parentSection, SectionSettings section)
 {
     if (parentSection != null)
     {
         SaveSectionSettings(GetChildNode(parentSection, section));
     }
 }
示例#6
0
 public SectionHolder(SectionSettings section, string topic, string information, string expression)
 {
   Section = section;
   Topic = topic;
   Information = information;
   Expression = expression;
 }
示例#7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="section"></param>
        private void ActivateSection(SectionSettings section)
        {
            section.Dock = DockStyle.Fill;

            section.OnSectionActivated();

            holderPanel.Controls.Clear();
            holderPanel.Controls.Add(section);
        }
示例#8
0
        public SectionTreeNode GetChildNode(SectionSettings parentSection, SectionSettings section)
        {
            SectionTreeNode treeNode       = new SectionTreeNode(section);
            SectionTreeNode parentTreeNode = (SectionTreeNode)settingSections[parentSection.Text];

            for (int i = 0; i < parentTreeNode.GetNodeCount(true); i++)
            {
                if (parentTreeNode.Nodes[i].Name == section.Text)
                {
                    return(treeNode);
                }
            }
            return(null);
        }
示例#9
0
        public void RemoveAllChildSections(SectionSettings parentSection)
        {
            // Remove section from tree
            if (parentSection != null)
            {
                SectionTreeNode parentTreeNode = (SectionTreeNode)settingSections[parentSection.Text];
                foreach (SectionTreeNode childNode in parentTreeNode.Nodes)
                {
                    // recursive delete all children
                    RemoveAllChildSections(childNode);

                    //Remove the section from the hashtable in case we add it again
                    settingSections.Remove(childNode.Text);
                    parentTreeNode.Nodes.Remove(childNode);
                }
            }
        }
示例#10
0
        public void RemoveChildSection(SectionSettings parentSection, SectionSettings section)
        {
            // Remove section from tree
            if (parentSection != null)
            {
                SectionTreeNode parentTreeNode = (SectionTreeNode)settingSections[parentSection.Text];

                for (int i = 0; i < parentTreeNode.GetNodeCount(true); i++)
                {
                    if (parentTreeNode.Nodes[i].Name == section.Text)
                    {
                        //Remove the section from the hashtable in case we add it again
                        settingSections.Remove(section.Text);
                        parentTreeNode.Nodes.Remove(parentTreeNode.Nodes[i]);
                    }
                }
            }
        }
示例#11
0
        /// <summary>
        /// Creates a section class from the specified name
        /// </summary>
        /// <param name="sectionName"></param>
        /// <returns></returns>
        private static SectionSettings CreateSection(string sectionName)
        {
            Type sectionType = Type.GetType("MediaPortal.Configuration.Sections." + sectionName);

            if (sectionType != null)
            {
                //
                // Create the instance of the section settings class, pass the section name as argument
                // to the constructor. We do this to be able to use the same name on <name> as in the <dependency> tag.
                //
                SectionSettings section = (SectionSettings)Activator.CreateInstance(sectionType, new object[] { sectionName });
                return(section);
            }

            //
            // Section was not found
            //
            return(null);
        }
示例#12
0
        public static SectionSettings GetSection(string name)
        {
            SectionSettings sectionSettings = null;
            SectionTreeNode sectionTreeNode = SettingsForm.SettingSections[name] as SectionTreeNode;

            if (sectionTreeNode != null)
            {
                sectionSettings = sectionTreeNode.Section;
            }
            else
            {
                //
                // Failed to locate the specified section, loop through and try to match
                // a section against the type name instead, as this is the way the wizard names
                // its sections.
                //
                IDictionaryEnumerator enumerator = SettingsForm.SettingSections.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    SectionTreeNode treeNode = enumerator.Value as SectionTreeNode;

                    if (treeNode != null)
                    {
                        Type sectionType = treeNode.Section.GetType();

                        if (sectionType.Name.Equals(name))
                        {
                            sectionSettings = treeNode.Section;
                            break;
                        }
                    }
                }
            }

            return(sectionSettings);
        }
示例#13
0
        public override bool ActivateSection(SectionSettings section)
        {
            try
            {
                if (section.CanActivate == false)
                {
                    return(false);
                }
                try
                {
                    RemoteControl.Instance.EpgGrabberEnabled = false;
                }
                catch (Exception) {}
                //DatabaseManager.Instance.SaveChanges();
                //DatabaseManager.Instance.ClearQueryCache();
                Cursor       = Cursors.WaitCursor;
                section.Dock = DockStyle.Fill;
                section.OnSectionActivated();
                if (section != _previousSection && _previousSection != null)
                {
                    _previousSection.OnSectionDeActivated();
                }
                _previousSection = section;

                holderPanel.Controls.Clear();
                holderPanel.Controls.Add(section);
            }
            catch (Exception ex)
            {
                Log.Write(ex);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
            return(true);
        }
示例#14
0
        public void AddChildSection(SectionSettings parentSection, SectionSettings section, int imageIndex)
        {
            //
            // Make sure this section doesn't already exist
            //

            //
            // Add section to tree
            //
            SectionTreeNode treeNode = new SectionTreeNode(section);

            if (parentSection == null)
            {
                //
                // Add to the root
                //
                treeNode.ImageIndex         = imageIndex;
                treeNode.SelectedImageIndex = imageIndex;
                sectionTree.Nodes.Add(treeNode);
            }
            else
            {
                //
                // Add to the parent node
                //
                SectionTreeNode parentTreeNode = (SectionTreeNode)settingSections[parentSection.Text];

                treeNode.ImageIndex         = imageIndex;
                treeNode.SelectedImageIndex = imageIndex;
                parentTreeNode.Nodes.Add(treeNode);
            }

            settingSections.Add(section.Text, treeNode);

            //treeNode.EnsureVisible();
        }
示例#15
0
 public virtual void AddSection(SectionSettings section)
 {
   AddChildSection(null, section);
 }
示例#16
0
 public override void AddSection(SectionSettings section)
 {
     AddChildSection(null, section);
 }
示例#17
0
 public void AddSection(SectionSettings section, int imageIndex)
 {
     AddChildSection(null, section, imageIndex);
 }
示例#18
0
 public void AddSection(SectionSettings settings, string topic, string information, string expression)
 {
     wizardPages.Add(new SectionHolder(settings, topic, information, expression));
 }
示例#19
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();
        }
示例#20
0
 public void AddSection(SectionSettings settings, string topic, string information, string expression)
 {
   wizardPages.Add(new SectionHolder(settings, topic, information, expression));
 }
    public SectionTreeNode GetChildNode(SectionSettings parentSection, SectionSettings section)
    {
      SectionTreeNode treeNode = new SectionTreeNode(section);
      SectionTreeNode parentTreeNode = (SectionTreeNode)settingSections[parentSection.Text];

      for (int i = 0; i < parentTreeNode.GetNodeCount(true); i++)
      {
        if (parentTreeNode.Nodes[i].Name == section.Text)
          return treeNode;
      }
      return null;
    }
    public override bool ActivateSection(SectionSettings section)
    {
      try
      {
        if (section.CanActivate == false)
        {
          return false;
        }
        try
        {
          RemoteControl.Instance.EpgGrabberEnabled = false;
        }
        catch (Exception) {}
        //DatabaseManager.Instance.SaveChanges();
        //DatabaseManager.Instance.ClearQueryCache();
        Cursor = Cursors.WaitCursor;
        section.Dock = DockStyle.Fill;
        section.OnSectionActivated();
        if (section != _previousSection && _previousSection != null)
        {
          _previousSection.OnSectionDeActivated();
        }
        _previousSection = section;

        holderPanel.Controls.Clear();
        holderPanel.Controls.Add(section);
      }
      catch (Exception ex)
      {
        Log.Write(ex);
      }
      finally
      {
        Cursor = Cursors.Default;
      }
      return true;
    }
 public override void AddSection(SectionSettings section)
 {
   AddChildSection(null, section);
 }
示例#24
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="section"></param>
    private void ActivateSection(SectionSettings section)
    {
      section.Dock = DockStyle.Fill;

      section.OnSectionActivated();

      holderPanel.Controls.Clear();
      holderPanel.Controls.Add(section);
    }
    public void RemoveChildSection(SectionSettings parentSection, SectionSettings section)
    {
      // Remove section from tree
      if (parentSection != null)
      {
        SectionTreeNode parentTreeNode = (SectionTreeNode)settingSections[parentSection.Text];

        for (int i = 0; i < parentTreeNode.GetNodeCount(true); i++)
        {
          if (parentTreeNode.Nodes[i].Name == section.Text)
          {
            //Remove the section from the hashtable in case we add it again
            settingSections.Remove(section.Text);
            parentTreeNode.Nodes.Remove(parentTreeNode.Nodes[i]);
          }
        }
      }
    }
    public void RemoveAllChildSections(SectionSettings parentSection)
    {
      // Remove section from tree
      if (parentSection != null)
      {
        SectionTreeNode parentTreeNode = (SectionTreeNode)settingSections[parentSection.Text];
        foreach (SectionTreeNode childNode in parentTreeNode.Nodes)
        {
          // recursive delete all children
          RemoveAllChildSections(childNode);

          //Remove the section from the hashtable in case we add it again
          settingSections.Remove(childNode.Text);
          parentTreeNode.Nodes.Remove(childNode);
        }
      }
    }
 public SectionTreeNode(SectionSettings section)
 {
     this.section = section;
     Text         = section.Text;
 }
示例#28
0
 public virtual bool ActivateSection(SectionSettings section)
 {
   return true;
 }
 public void SaveChildSettingsFromNode(SectionSettings parentSection, SectionSettings section)
 {
   if (parentSection != null)
     SaveSectionSettings(GetChildNode(parentSection, section));
 }
示例#30
0
        /// <summary>
        /// Loads, parses and creates the defined sections in the section xml.
        /// </summary>
        /// <param name="xmlFile"></param>
        private void LoadSections(string xmlFile)
        {
            XmlDocument document = new XmlDocument();

            try
            {
                //
                // Load the xml document
                //
                document.Load(xmlFile);

                XmlElement rootElement = document.DocumentElement;

                //
                // Make sure we're loading a wizard file
                //
                if (rootElement != null && rootElement.Name.Equals("wizard"))
                {
                    //
                    // Fetch wizard settings
                    //
                    XmlNode wizardTopicNode = rootElement.SelectSingleNode("/wizard/caption");
                    if (wizardTopicNode != null)
                    {
                        wizardCaption = wizardTopicNode.InnerText;
                    }

                    //
                    // Fetch sections
                    //
                    XmlNodeList nodeList = rootElement.SelectNodes("/wizard/sections/section");

                    if (nodeList != null)
                    {
                        foreach (XmlNode node in nodeList)
                        {
                            //
                            // Fetch section information
                            //
                            XmlNode nameNode       = node.SelectSingleNode("name");
                            XmlNode topicNode      = node.SelectSingleNode("topic");
                            XmlNode infoNode       = node.SelectSingleNode("information");
                            XmlNode dependencyNode = node.SelectSingleNode("dependency");

                            if (nameNode != null && nameNode.InnerText.Length > 0)
                            {
                                //
                                // Allocate new wizard page
                                //
                                SectionSettings section = CreateSection(nameNode.InnerText);

                                if (section != null)
                                {
                                    //
                                    // Load wizard specific settings
                                    //
                                    section.LoadWizardSettings(node);

                                    //
                                    // Add the section to the sections list
                                    //
                                    if (dependencyNode == null)
                                    {
                                        AddSection(section, topicNode != null ? topicNode.InnerText : String.Empty,
                                                   infoNode != null ? infoNode.InnerText : String.Empty);
                                    }
                                    else
                                    {
                                        AddSection(section, topicNode != null ? topicNode.InnerText : String.Empty,
                                                   infoNode != null ? infoNode.InnerText : String.Empty, dependencyNode.InnerText);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }
        }
示例#31
0
 public void AddSection(SectionSettings settings, string topic, string information)
 {
   AddSection(settings, topic, information, String.Empty);
 }
示例#32
0
 public SectionTreeNode(SectionSettings section)
 {
   this.section = section;
   Text = section.Text;
 }
 public void AddSection(SectionSettings section, int imageIndex)
 {
   AddChildSection(null, section, imageIndex);
 }
示例#34
0
 public void AddSection(SectionSettings settings, string topic, string information)
 {
     AddSection(settings, topic, information, String.Empty);
 }