AddKey() public method

public AddKey ( string sKey ) : IniKey
sKey string
return IniKey
Ejemplo n.º 1
0
        void addKey()
        {
            try
            {
                ExtendedTreeNode selected = (ExtendedTreeNode)iniSectionTreeView.SelectedNode;

                switch (selected.GetIntegerType())
                {
                case (0):
                    ExtendedTreeNode addKey = new ExtendedTreeNode(String.Format("NewKey{0}", keyNumber), 1);
                    selected.Nodes.Add(addKey);
                    IniFile.IniSection selectedSection = ini.GetSection(selected.Text);
                    selectedSection.AddKey(String.Format("NewKey{0}", keyNumber));
                    keyNumber++;
                    break;

                case (1):
                    MessageBox.Show("Please select a section node", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;

                case (2):
                    MessageBox.Show("Please select a section node", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }
            }
            catch
            {
                MessageBox.Show("Please select a section node!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 2
0
 public sKey Key(Setting incKey)
 {
     IniFile.IniSection.IniKey key = section.GetKey(incKey.ToString());
     if (key == null)
     {
         if (defaultSets.ContainsKey(incKey))
         {
             key       = section.AddKey(incKey.ToString());
             key.Value = defaultSets[incKey];
         }
     }
     if (key != null)
     {
         if (key.Value == null)
         {
             if (defaultSets.ContainsKey(incKey))
             {
                 key.Value = defaultSets[incKey];
             }
         }
     }
     return(new sKey(key, defaultSets[incKey]));
 }
Ejemplo n.º 3
0
        static string SoundVolumeAdjust()
        {
            string  sectionName = "Sound";
            bool    NeedToSave  = false;
            var     fileOptions = PublicData.FindFileInTreeBySection(sectionName);
            IniFile ini         = new IniFile();

            ini.Load(fileOptions);
            IniFile.IniSection sectionVolume = ini.GetSection(sectionName);
            var vol_key = sectionVolume.GetAddKey("volume");

            if (vol_key == null)
            {
                vol_key = sectionVolume.AddKey("volume"); NeedToSave = true;
            }
            int dec_volume = 20;

            try
            {
                dec_volume = int.Parse(vol_key.Value);
            }
            catch (Exception)
            {
                dec_volume = 20;
                NeedToSave = true;
            }
            if (dec_volume > 100)
            {
                dec_volume = 20; NeedToSave = true;
            }
            vol_key.SetValue(dec_volume.ToString());
            if (NeedToSave)
            {
                ini.SaveShowMessage(fileOptions);
            }
            return(dec_volume.ToString("X2"));
        }