Example #1
0
 /// <summary>
 ///     Deregisters the specified weight.
 /// </summary>
 /// <param name="weight">
 ///     The weight.
 /// </param>
 public void Deregister(IWeightItem weight)
 {
     if (this.pItems.Select(p => p.Item).Contains(weight))
     {
         this.pItems.Remove(this.pItems.FirstOrDefault(w => w.Item.Equals(weight)));
         this.weightsMenu.Remove(this.weightsMenu[weight.Name].GetValue <MenuBool>());
     }
 }
Example #2
0
        /// <summary>
        ///     Overwrites the specified old weight.
        /// </summary>
        /// <param name="oldWeight">
        ///     The old weight.
        /// </param>
        /// <param name="newWeight">
        ///     The new weight.
        /// </param>
        public void Overwrite(IWeightItem oldWeight, IWeightItem newWeight)
        {
            var index = this.Items.Select(p => p.Item).ToList().IndexOf(oldWeight);

            if (index >= 0)
            {
                this.pItems[index] = new WeightItemWrapper(newWeight);
                var slider = this.weightsMenu[oldWeight.Name].GetValue <MenuSlider>();
                slider.Name        = newWeight.Name;
                slider.DisplayName = newWeight.DisplayName;
                slider.Value       = Math.Min(MaxWeight, Math.Max(MinWeight, newWeight.DefaultWeight));
            }
        }
Example #3
0
 /// <summary>
 ///     Registers the specified weight.
 /// </summary>
 /// <param name="weight">
 ///     The weight.
 /// </param>
 public void Register(IWeightItem weight)
 {
     if (!this.Items.Any(m => m.Name.Equals(weight.Name)) && !string.IsNullOrEmpty(weight.DisplayName))
     {
         this.pItems.Add(new WeightItemWrapper(weight));
         this.weightsMenu.Add(
             new MenuSlider(
                 weight.Name,
                 weight.DisplayName,
                 Math.Min(MaxWeight, Math.Max(MinWeight, weight.DefaultWeight)),
                 MinWeight,
                 MaxWeight));
     }
 }
Example #4
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="WeightItemWrapper" /> class.
 /// </summary>
 /// <param name="item">
 ///     The item.
 /// </param>
 public WeightItemWrapper(IWeightItem item)
 {
     this.Item   = item;
     this.Weight = item.DefaultWeight;
 }
Example #5
0
 /// <summary>
 ///     Registers the specified weight.
 /// </summary>
 /// <param name="weight">
 ///     The weight.
 /// </param>
 public void Register(IWeightItem weight)
 {
     if (!this.Items.Any(m => m.Name.Equals(weight.Name)) && !string.IsNullOrEmpty(weight.DisplayName))
     {
         this.pItems.Add(new WeightItemWrapper(weight));
         this.weightsMenu.Add(
             new MenuSlider(
                 weight.Name,
                 weight.DisplayName,
                 Math.Min(MaxWeight, Math.Max(MinWeight, weight.DefaultWeight)),
                 MinWeight,
                 MaxWeight));
     }
 }
Example #6
0
 /// <summary>
 ///     Overwrites the specified old weight.
 /// </summary>
 /// <param name="oldWeight">
 ///     The old weight.
 /// </param>
 /// <param name="newWeight">
 ///     The new weight.
 /// </param>
 public void Overwrite(IWeightItem oldWeight, IWeightItem newWeight)
 {
     var index = this.Items.Select(p => p.Item).ToList().IndexOf(oldWeight);
     if (index >= 0)
     {
         this.pItems[index] = new WeightItemWrapper(newWeight);
         var slider = this.weightsMenu[oldWeight.Name].GetValue<MenuSlider>();
         slider.Name = newWeight.Name;
         slider.DisplayName = newWeight.DisplayName;
         slider.Value = Math.Min(MaxWeight, Math.Max(MinWeight, newWeight.DefaultWeight));
     }
 }
Example #7
0
 /// <summary>
 ///     Deregisters the specified weight.
 /// </summary>
 /// <param name="weight">
 ///     The weight.
 /// </param>
 public void Deregister(IWeightItem weight)
 {
     if (this.pItems.Select(p => p.Item).Contains(weight))
     {
         this.pItems.Remove(this.pItems.FirstOrDefault(w => w.Item.Equals(weight)));
         this.weightsMenu.Remove(this.weightsMenu[weight.Name].GetValue<MenuBool>());
     }
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="WeightItemWrapper" /> class.
 /// </summary>
 /// <param name="item">
 ///     The item.
 /// </param>
 public WeightItemWrapper(IWeightItem item)
 {
     this.Item = item;
     this.Weight = item.DefaultWeight;
 }