setValue() public static method

Sets a registry value
public static setValue ( RegistryKey mainKey, string subKey, string valueName, object value ) : bool
mainKey Microsoft.Win32.RegistryKey A Windows.Win32.Registry value (Halo2 uses CurrentUser)
subKey string The path to the value (Halo 2 uses RegistryAccess.RegPaths)
valueName string The Label of the value (Halo 2 uses RegistryAccess.RegNames)
value object The new value
return bool
示例#1
0
 private void PluginSetSelector_FormClosed(object sender, FormClosedEventArgs e)
 {
     // Clear any old plugin listings
     RegistryAccess.removeKey(Microsoft.Win32.Registry.CurrentUser,
                              RegistryAccess.RegPaths.Halo2 + "PluginSets\\");
     // We must always have at least a Default plugin
     if (pluginInfo.Names.Count == 0)
     {
         pluginInfo.Names.Add("Default");
         pluginInfo.Paths.Add(Prefs.pathPluginsFolder);
     }
     // Write all the plugins back to the registry
     for (int i = 0; i < pluginInfo.Names.Count; i++)
     {
         RegistryAccess.setValue(Microsoft.Win32.Registry.CurrentUser,
                                 RegistryAccess.RegPaths.Halo2 + "PluginSets\\",
                                 pluginInfo.Names[i],
                                 pluginInfo.Paths[i]);
     }
 }
示例#2
0
        /// <summary>
        /// Saves this instance.
        /// </summary>
        /// <remarks></remarks>
        public static void Save()
        {
            #region Settings File
            XmlTextWriter writer = new XmlTextWriter(FilePath, Encoding.ASCII);
            writer.Formatting = Formatting.Indented;
            writer.WriteStartDocument();

            writer.WriteStartElement("entityUserSettings");
            writer.WriteElementString(XML_NODE_MAINMENUFILE, pathMainmenu);
            writer.WriteElementString(XML_NODE_MPSHAREDFILE, pathShared);
            writer.WriteElementString(XML_NODE_SPSHAREDFILE, pathSPShared);
            writer.WriteElementString(XML_NODE_BITMAPSFILE, pathBitmaps);

            writer.WriteElementString(XML_NODE_MAPSFOLDER, pathMapsFolder);
            writer.WriteElementString(XML_NODE_FONTSFOLDER, pathFontsFolder);
            writer.WriteElementString(XML_NODE_CLEANMAPSFOLDER, pathCleanMaps);
            writer.WriteElementString(XML_NODE_PLUGINSFOLDER, pathPluginsFolder);
            writer.WriteElementString(XML_NODE_BITMAPSFOLDER, pathBitmapsFolder);
            writer.WriteElementString(XML_NODE_EXTRACTSFOLDER, pathExtractsFolder);
            writer.WriteElementString(XML_NODE_PATCHFOLDER, pathPatchFolder);

            writer.WriteElementString(XML_NODE_USEDEFMAPS, useDefaultMaps.ToString());
            writer.WriteElementString(XML_NODE_USEREGISTRY, useRegistryEntries.ToString());
            writer.WriteElementString(XML_NODE_CHECKUPDATE, checkUpdate.ToString());
            writer.WriteElementString(XML_NODE_LASTUPDATECHECK, lastCheck.ToString());

            writer.WriteStartElement(XML_NODE_RECENTMAPSLIST);
            // Only keep a list of the last 10 used maps (Entity only uses 4)
            for (int i = 0; i < Math.Min(RecentOpenedMaps.Count, 10); i++)
            {
                writer.WriteElementString(XML_NODE_RECENTMAP, RecentOpenedMaps[i].Path);
            }
            writer.WriteEndElement();

            writer.WriteStartElement(XML_NODE_QUICKACCESSTAGSLIST);
            for (int i = 0; i < QuickAccessTagTypes.Count; i++)
            {
                writer.WriteStartElement(XML_NODE_QUICKACCESSTAG);
                writer.WriteAttributeString(XML_ATTR_TAGTYPENAME, QuickAccessTagTypes[i].TagType);
                foreach (string tagPath in QuickAccessTagTypes[i].TagPaths)
                {
                    writer.WriteElementString(XML_NODE_QUICKACCESSTAGPATH, tagPath);
                }
                writer.WriteEndElement();
            }
            writer.WriteEndElement();

            writer.WriteStartElement(XML_NODE_USERPLUGINMASKS);
            foreach (CustomPluginMask mask in CustomPluginMasks)
            {
                writer.WriteStartElement(XML_NODE_PLUGINMASK);
                writer.WriteAttributeString(XML_ATTR_PLUGINMASKNAME, mask.Name);
                foreach (string tagType in mask.VisibleTagTypes)
                {
                    writer.WriteStartElement(XML_NODE_PLUGINMASK_VISIBLETAGTYPE);
                    writer.WriteAttributeString(XML_ATTR_TAGTYPENAME, tagType);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
            writer.WriteEndElement();

            writer.WriteEndElement();
            writer.Close();
            #endregion

            #region Registry Entries
            if (useRegistryEntries)
            {
                //RegistryAccess.removeValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\UseSettingsFile\", Application.StartupPath);
                RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, "", "");

                // General Halo2 program settings
                RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.MainMenuFile, Prefs.pathMainmenu);
                RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.SharedFile, Prefs.pathShared);
                RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.SinglePlayerSharedFile, Prefs.pathSPShared);
                RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.BitmapsFile, Prefs.pathBitmaps);
                RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.MapsPath, Prefs.pathMapsFolder);
                RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.FontsPath, Prefs.pathFontsFolder);
                RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.CleanMapsPath, Prefs.pathCleanMaps);
                RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.PluginsPath, Prefs.pathPluginsFolder);
                RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.BitmapsPath, Prefs.pathBitmapsFolder);
                RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.ExtractsPath, Prefs.pathExtractsFolder);

                // Entity specific settings
                RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\", "PatchFolder", Prefs.pathPatchFolder);
                RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\", "UseDefaultMaps", Prefs.useDefaultMaps.ToString());
                RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\", "checkUpdate", Prefs.checkUpdate.ToString());
                RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\", "lastCheck", Prefs.lastCheck.ToString());

                // Save recently used maps list in the registry (max 10)
                for (int count = 0; count < Math.Min(RecentOpenedMaps.Count, 10); count++)
                {
                    RegistryAccess.setValue(
                        Registry.CurrentUser,
                        RegistryAccess.RegPaths.Halo2RecentFiles,
                        count.ToString(),
                        RecentOpenedMaps[count].Path);
                }
            }
            #endregion
        }