Exemplo n.º 1
0
 public EnvVariable AddVariable(string variable)
 {
     EnvVariable newVar = new EnvVariable(variable, "", true);
     Variables[variable] = newVar;
     return newVar;
 }
Exemplo n.º 2
0
 private Color GetIndicatorColor(EnvVariable value)
 {
     return (value.Deleted) ? Color.Pink :
            (value.Added) ? Color.LightGreen :
            (value.Edited) ? Color.LightBlue :
            Color.White;
 }
Exemplo n.º 3
0
        private void Load()
        {
            Variables.Clear();

            RegistryKey root = null;
            string location = null;

            switch (EnvTarget)
            {
                case EnvironmentVariableTarget.Machine:
                    root = Registry.LocalMachine;
                    location = LocalMachineEnvironmentLocation;
                    break;
                case EnvironmentVariableTarget.User:
                    root = Registry.CurrentUser;
                    location = CurrentUserEnvironmentLocation;
                    break;
                case EnvironmentVariableTarget.Process:
                    throw new NotSupportedException("Process environment variables will have no other effects.");
            }

            using (RegistryKey key = root.OpenSubKey(location))
            {
                foreach (string variable in key.GetValueNames())
                {
                    Variables[variable] = new EnvVariable(variable, key.GetValue(variable, "", RegistryValueOptions.DoNotExpandEnvironmentNames) as string, false);
                }
            }
        }