Beispiel #1
0
        private static void LoadBooleanSettings()
        {
            using (Settings xmlReader = new SKSettings())
            {
                IDictionary <string, bool> allBooleanSettings = xmlReader.GetSection <bool>("booleansettings");

                if (allBooleanSettings == null)
                {
                    return;
                }

                lock (_skinBoolSettings)
                {
                    var enumerator = allBooleanSettings.GetEnumerator();
                    if (enumerator != null)
                    {
                        while (enumerator.MoveNext())
                        {
                            // Create the new boolean setting.
                            SkinBool newBool = new SkinBool();
                            newBool.Name  = enumerator.Current.Key;
                            newBool.Value = enumerator.Current.Value;
                            newBool.Kind  = Kind.PERSISTENT;

                            // Add the setting to the dictionary.
                            int key = _skinBoolSettings.Count;
                            _skinBoolSettings[key] = newBool;

                            // Create the setting as a property.  The boolean value is converted as a string representation.
                            GUIPropertyManager.SetProperty(newBool.Name, newBool.Value.ToString());
                        }
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Retrieve a skin boolean using the specified key.
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static bool GetSkinBool(int key)
        {
            SkinBool skinBool = null;

            if (_skinBoolSettings.TryGetValue(key, out skinBool))
            {
                return(skinBool.Value);
            }
            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// Set all skin booleans to false.  Does not save to disk; call Save() afterward.
        /// </summary>
        public static void ResetAllSkinBool()
        {
            Dictionary <int, SkinBool> .Enumerator enumer = _skinBoolSettings.GetEnumerator();
            while (enumer.MoveNext())
            {
                SkinBool skin = enumer.Current.Value;
                skin.Value = false;

                // Save the setting as a property if specified as such.  The boolean value is converted as a string representation.
                GUIPropertyManager.SetProperty(skin.Name, skin.Value.ToString());
            }
        }
Beispiel #4
0
        /// <summary>
        /// Translate the skin boolean, create the skin boolean if not found.
        /// </summary>
        /// <param name="setting"></param>
        /// <param name="kind"></param>
        /// <returns></returns>
        public static int TranslateSkinBool(string setting, Kind kind)
        {
            lock (_skinBoolSettings)
            {
                foreach (int iKey in _skinBoolSettings.Keys.ToList())
                {
                    SkinBool skin = _skinBoolSettings[iKey];
                    if (skin.Name == setting)
                    {
                        if (skin.Kind == Kind.TRANSIENT && kind == Kind.PERSISTENT)
                        {
                            skin.Kind = kind;
                            _skinBoolSettings[iKey] = skin;
                        }
                        return(iKey);
                    }
                }
            }

            SkinBool newBool = new SkinBool();

            newBool.Name  = setting;
            newBool.Value = false;
            newBool.Kind  = kind;

            // Create the setting as a property if not already present.  The boolean value is converted as a string representation.
            if (!GUIPropertyManager.PropertyIsDefined(newBool.Name))
            {
                GUIPropertyManager.SetProperty(newBool.Name, newBool.Value.ToString());
            }
            else
            {
                try
                {
                    newBool.Value = bool.Parse(GUIPropertyManager.GetProperty(newBool.Name));
                }
                catch (FormatException ex)
                {
                    // Value is set to false.
                    Log.Warn("SkinSettings: Boolean setting value is not a valid boolean name={0} value={1} {2}", newBool.Name, newBool.Value, ex.Message);
                }
            }

            int key;

            lock (_skinBoolSettings) // Lock dictionary, we might be saving, should not alter structre
            {
                key = _skinBoolSettings.Count;
                _skinBoolSettings[key] = newBool;
            }
            return(key);
        }
Beispiel #5
0
        /// <summary>
        /// Set a skin boolean using the specified key.  Saves changes to disk immediatley.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="newValue"></param>
        public static void SetSkinBool(int key, bool newValue)
        {
            SkinBool skinBool = null;

            if (_skinBoolSettings.TryGetValue(key, out skinBool))
            {
                skinBool.Value         = newValue;
                _skinBoolSettings[key] = skinBool;

                // Save the setting as a property.  The boolean value is converted as a string representation.
                GUIPropertyManager.SetProperty(skinBool.Name, skinBool.Value.ToString());

                // Save change to disk immediately.
                Save();
            }
        }
        /// <summary>
        /// Translate the skin boolean, create the skin boolean if not found.
        /// </summary>
        /// <param name="setting"></param>
        /// <param name="kind"></param>
        /// <returns></returns>
        public static int TranslateSkinBool(string setting, Kind kind)
        {
            Dictionary <int, SkinBool> .Enumerator enumer = _skinBoolSettings.GetEnumerator();
            while (enumer.MoveNext())
            {
                SkinBool skin = enumer.Current.Value;
                if (skin.Name == setting)
                {
                    return(enumer.Current.Key);
                }
            }
            SkinBool newBool = new SkinBool();

            newBool.Name  = setting;
            newBool.Value = false;
            newBool.Kind  = kind;

            // Create the setting as a property if not already present.  The boolean value is converted as a string representation.
            if (!GUIPropertyManager.PropertyIsDefined(newBool.Name))
            {
                GUIPropertyManager.SetProperty(newBool.Name, newBool.Value.ToString());
            }
            else
            {
                try
                {
                    newBool.Value = bool.Parse(GUIPropertyManager.GetProperty(newBool.Name));
                }
                catch (FormatException)
                {
                    // Value is set to false.
                    Log.Warn("SkinSettings: Boolean setting value is not a valid boolean name={0} value={1}", newBool.Name, newBool.Value);
                }
            }

            int key;

            lock (_skinBoolSettings) // Lock dictionary, we might be saving, should not alter structre
            {
                key = _skinBoolSettings.Count;
                _skinBoolSettings[key] = newBool;
            }
            return(key);
        }
 public static int TranslateSkinBool(string setting)
 {
   Dictionary<int, SkinBool>.Enumerator enumer = _skinBoolSettings.GetEnumerator();
   while (enumer.MoveNext())
   {
     SkinBool skin = enumer.Current.Value;
     if (skin.Name == setting)
     {
       return enumer.Current.Key;
     }
   }
   SkinBool newBool = new SkinBool();
   newBool.Name = setting;
   newBool.Value = false;
   newBool.Value = false;
   int key = _skinBoolSettings.Count;
   _skinBoolSettings[key] = newBool;
   return key;
 }
        public static int TranslateSkinBool(string setting)
        {
            Dictionary <int, SkinBool> .Enumerator enumer = _skinBoolSettings.GetEnumerator();
            while (enumer.MoveNext())
            {
                SkinBool skin = enumer.Current.Value;
                if (skin.Name == setting)
                {
                    return(enumer.Current.Key);
                }
            }
            SkinBool newBool = new SkinBool();

            newBool.Name  = setting;
            newBool.Value = false;
            newBool.Value = false;
            int key = _skinBoolSettings.Count;

            _skinBoolSettings[key] = newBool;
            return(key);
        }
Beispiel #9
0
    private static void LoadBooleanSettings()
    {
      using (Settings xmlReader = new SKSettings())
      {
        IDictionary<string, bool> allBooleanSettings = xmlReader.GetSection<bool>("booleansettings");

        if (allBooleanSettings == null)
        {
          return;
        }

        lock (_skinBoolSettings)
        {
          var enumerator = allBooleanSettings.GetEnumerator();
          if (enumerator != null)
          {
            while (enumerator.MoveNext())
            {
              // Create the new boolean setting.
              SkinBool newBool = new SkinBool();
              newBool.Name = enumerator.Current.Key;
              newBool.Value = enumerator.Current.Value;
              newBool.Kind = Kind.PERSISTENT;

              // Add the setting to the dictionary.
              int key = _skinBoolSettings.Count;
              _skinBoolSettings[key] = newBool;

              // Create the setting as a property.  The boolean value is converted as a string representation.
              GUIPropertyManager.SetProperty(newBool.Name, newBool.Value.ToString());
            }
          }
        }
      }
    }
Beispiel #10
0
    /// <summary>
    /// Translate the skin boolean, create the skin boolean if not found.
    /// </summary>
    /// <param name="setting"></param>
    /// <param name="kind"></param>
    /// <returns></returns>
    public static int TranslateSkinBool(string setting, Kind kind)
    {
      Dictionary<int, SkinBool>.Enumerator enumer = _skinBoolSettings.GetEnumerator();
      while (enumer.MoveNext())
      {
        SkinBool skin = enumer.Current.Value;
        if (skin.Name == setting)
        {
          return enumer.Current.Key;
        }
      }
      SkinBool newBool = new SkinBool();
      newBool.Name = setting;
      newBool.Value = false;
      newBool.Kind = kind;

      // Create the setting as a property if not already present.  The boolean value is converted as a string representation.
      if (!GUIPropertyManager.PropertyIsDefined(newBool.Name))
      {
        GUIPropertyManager.SetProperty(newBool.Name, newBool.Value.ToString());
      }
      else
      {
        try
        {
          newBool.Value = bool.Parse(GUIPropertyManager.GetProperty(newBool.Name));
        }
        catch (FormatException)
        {
          // Value is set to false.
          Log.Warn("SkinSettings: Boolean setting value is not a valid boolean name={0} value={1}", newBool.Name, newBool.Value);
        }
      }

      int key;
      lock (_skinBoolSettings) // Lock dictionary, we might be saving, should not alter structre
      {
        key = _skinBoolSettings.Count;
        _skinBoolSettings[key] = newBool;
      }
      return key;
    }