Esempio n. 1
0
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            GUIGraphicsContext.form = this;
            // Asynchronously pre-initialize the music engine if we're using the BassMusicPlayer
            if (BassMusicPlayer.IsDefaultMusicPlayer)
            {
                BassMusicPlayer.CreatePlayerAsync();
            }
            Log.Info("Load settings");

            // We load ALL sections - not just those which are visible currently
            foreach (KeyValuePair <string, ConfigPage> singleConfig in settingSections)
            {
                ConfigPage config   = singleConfig.Value;
                TreeNode   loadNode = new SectionTreeNode(config.ConfigSection) as TreeNode;
                if (loadNode != null)
                {
                    // LoadSectionSettings will recursively load all settings
                    if (loadNode.Parent == null)
                    {
                        LoadSectionSettings(loadNode);
                    }
                }
            }

            Log.Info("Load settings done");
        }
Esempio n. 2
0
        private void sectionTree_BeforeSelect(object sender, TreeViewCancelEventArgs e)
        {
            SectionTreeNode treeNode = e.Node as SectionTreeNode;

            if (treeNode != null)
            {
                e.Cancel = !treeNode.Section.CanActivate;
            }
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void sectionTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            SectionTreeNode treeNode = e.Node as SectionTreeNode;

            if (treeNode != null)
            {
                if (ActivateSection(treeNode.Section))
                {
                    headerLabel.Caption = treeNode.Section.Text;
                }
            }
        }
        public static SectionSettings GetSection(string name)
        {
            SectionSettings sectionSettings = null;
            SectionTreeNode sectionTreeNode = null;

            try
            {
                sectionTreeNode = new SectionTreeNode(SettingsForm.SettingSections[name].ConfigSection);
            }
            catch (KeyNotFoundException)
            {
                MessageBox.Show("Someone broke section handling specifying a non existing name for {0}!", name);
            }

            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 = enumerator.Value as SectionTreeNode;

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

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

            return(sectionSettings);
        }
Esempio n. 5
0
    public static SectionSettings GetSection(string name)
    {
      SectionSettings sectionSettings = null;
      SectionTreeNode sectionTreeNode = null;
      try
      {
        sectionTreeNode = new SectionTreeNode(SettingsForm.SettingSections[name].ConfigSection);
      }
      catch (KeyNotFoundException)
      {
        MessageBox.Show("Someone broke section handling specifying a non existing name for {0}!", name);
      }

      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 = enumerator.Value as SectionTreeNode;

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

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

      return sectionSettings;
    }
Esempio n. 6
0
 private void SaveSectionSettings(TreeNode currentNode)
 {
     if (currentNode != null)
     {
         // Save settings for current node
         SectionTreeNode treeNode = currentNode as SectionTreeNode;
         if (treeNode != null)
         {
             Log.Info("SaveSectionSettings() - {0}", treeNode.Text);
             treeNode.Section.SaveSettings();
         }
         // Load settings for all child nodes
         foreach (TreeNode childNode in treeNode.Nodes)
         {
             SaveSectionSettings(childNode);
         }
     }
     Log.Info("SaveSectionSettings done()");
 }
Esempio n. 7
0
        private void SaveAllSettings()
        {
            // We save ALL sections - not just those which are visible currently
            foreach (KeyValuePair <string, ConfigPage> singleConfig in settingSections)
            {
                ConfigPage config   = singleConfig.Value;
                TreeNode   saveNode = new SectionTreeNode(config.ConfigSection) as TreeNode;
                if (saveNode != null)
                {
                    // SaveSectionSettings recursively saves all subnodes as well
                    if (saveNode.Parent == null)
                    {
                        SaveSectionSettings(saveNode);
                    }
                }
            }

            Settings.SaveCache();
        }
Esempio n. 8
0
    private void SettingsForm_Load(object sender, EventArgs e)
    {
      GUIGraphicsContext.form = this;
      // Asynchronously pre-initialize the music engine if we're using the BassMusicPlayer
      if (BassMusicPlayer.IsDefaultMusicPlayer)
      {
        BassMusicPlayer.CreatePlayerAsync();
      }
      Log.Info("Load settings");

      // We load ALL sections - not just those which are visible currently
      foreach (KeyValuePair<string, ConfigPage> singleConfig in settingSections)
      {
        ConfigPage config = singleConfig.Value;
        TreeNode loadNode = new SectionTreeNode(config.ConfigSection) as TreeNode;
        if (loadNode != null)
        {
          // LoadSectionSettings will recursively load all settings
          if (loadNode.Parent == null)
          {
            LoadSectionSettings(loadNode);
          }
        }
      }

      Log.Info("Load settings done");
    }
Esempio n. 9
0
    private void ToggleSectionVisibility(bool aShowAdvancedOptions)
    {
      // using property so setter updates values..
      AdvancedMode = aShowAdvancedOptions;

      sectionTree.BeginUpdate();
      TreeNode currentSelected = (TreeNode)sectionTree.SelectedNode;
      sectionTree.Nodes.Clear();

      foreach (KeyValuePair<string, ConfigPage> singleConfig in settingSections)
      {
        ConfigPage currentSection = singleConfig.Value;

        // Add all loaded sections to the TreeView
        if (currentSection.IsVisible)
        {
          SectionTreeNode treeNode = new SectionTreeNode(currentSection.ConfigSection);
          // If not parent is specified we add the section as root node.
          if (currentSection.Parentsection == null)
          {
            // Add to the root
            sectionTree.Nodes.Add(treeNode);
          }
          else
          {
            // Find parent section (IndexOfKey is buggy)
            int parentPos = -1;
            // This limits usage to one level only - loop subitems if you want to build a tree
            for (int i = 0; i < sectionTree.Nodes.Count; i++)
            {
              if (sectionTree.Nodes[i].Text.CompareTo(currentSection.Parentsection.Text) == 0)
              {
                parentPos = i;
                break;
              }
            }

            if (parentPos > -1)
            {
              // Add to the parent node
              SectionTreeNode parentTreeNode = (SectionTreeNode)sectionTree.Nodes[parentPos];
              parentTreeNode.Nodes.Add(treeNode);
            }
          }
        }
      }
      if (currentSelected != null)
      {
        // Reselect the node we were editing before
        foreach (TreeNode parentNode in sectionTree.Nodes)
        {
          foreach (TreeNode node in parentNode.Nodes)
          {
            if (node.Text.CompareTo(currentSelected.Text) == 0)
            {
              sectionTree.SelectedNode = node;
              node.EnsureVisible();
              break;
            }
          }
        }
      }

      sectionTree.EndUpdate();
    }
Esempio n. 10
0
    private void SaveAllSettings()
    {
      // We save ALL sections - not just those which are visible currently
      foreach (KeyValuePair<string, ConfigPage> singleConfig in settingSections)
      {
        ConfigPage config = singleConfig.Value;
        TreeNode saveNode = new SectionTreeNode(config.ConfigSection) as TreeNode;
        if (saveNode != null)
        {
          // SaveSectionSettings recursively saves all subnodes as well
          if (saveNode.Parent == null)
          {
            SaveSectionSettings(saveNode);
          }
        }
      }

      Settings.SaveCache();
    }
Esempio n. 11
0
        private void ToggleSectionVisibility(bool aShowAdvancedOptions)
        {
            // using property so setter updates values..
            AdvancedMode = aShowAdvancedOptions;

            sectionTree.BeginUpdate();
            TreeNode currentSelected = (TreeNode)sectionTree.SelectedNode;

            sectionTree.Nodes.Clear();

            foreach (KeyValuePair <string, ConfigPage> singleConfig in settingSections)
            {
                ConfigPage currentSection = singleConfig.Value;

                // Add all loaded sections to the TreeView
                if (currentSection.IsVisible)
                {
                    SectionTreeNode treeNode = new SectionTreeNode(currentSection.ConfigSection);
                    // If not parent is specified we add the section as root node.
                    if (currentSection.Parentsection == null)
                    {
                        // Add to the root
                        sectionTree.Nodes.Add(treeNode);
                    }
                    else
                    {
                        // Find parent section (IndexOfKey is buggy)
                        int parentPos = -1;
                        // This limits usage to one level only - loop subitems if you want to build a tree
                        for (int i = 0; i < sectionTree.Nodes.Count; i++)
                        {
                            if (sectionTree.Nodes[i].Text.CompareTo(currentSection.Parentsection.Text) == 0)
                            {
                                parentPos = i;
                                break;
                            }
                        }

                        if (parentPos > -1)
                        {
                            // Add to the parent node
                            SectionTreeNode parentTreeNode = (SectionTreeNode)sectionTree.Nodes[parentPos];
                            parentTreeNode.Nodes.Add(treeNode);
                        }
                    }
                }
            }
            if (currentSelected != null)
            {
                // Reselect the node we were editing before
                foreach (TreeNode parentNode in sectionTree.Nodes)
                {
                    foreach (TreeNode node in parentNode.Nodes)
                    {
                        if (node.Text.CompareTo(currentSelected.Text) == 0)
                        {
                            sectionTree.SelectedNode = node;
                            node.EnsureVisible();
                            break;
                        }
                    }
                }
            }

            sectionTree.EndUpdate();
        }