コード例 #1
0
 public virtual void NormalizeItems()
 {
     if (Items.Any() && Items.Select(i => i.Percentage).Sum() < 100)
     {
         ProgressBarItem maxItem = Items.Where(i => i.Value > 0 && i.GetFractionalValue() > 0).OrderByDescending(i => i.Percentage).FirstOrDefault();
         if (maxItem == null)
         {
             maxItem = Items.Where(i => i.Value > 0).OrderBy(i => i.Percentage).FirstOrDefault();
         }
         if (maxItem != null)
         {
             NormalizeItem(maxItem, Items.Where(i => i.Id != maxItem.Id).Select(i => i.Percentage).Sum());
         }
     }
 }
コード例 #2
0
 private void NormalizeItem(ProgressBarItem maxItem, double otherItemsSum)
 {
     maxItem.SetPercentage(100 - otherItemsSum);
 }