Changeset 1504


Ignore:
Timestamp:
01/12/10 05:40:14 (5 years ago)
Author:
lowjoel
Message:

Fixed a few behaviours in the ProgressManager? classes:
-for ProgressManager?, if the Total field is zero, always return 0 for progress (prevents division by zero)
-for SteppedProgressManager?, the Speed property is dependent on the CurrentStep? property; if that is null, the speed should be zero.
-for SteppedProgressManager?, the TimeLeft? property is dependent on the StartTime? of the task, if it is invalid, the TimeLeft? property will now return TimeSpan?.MinValue?
-for SteppedProgressManager?, the CurrentStep? property will return the last completed step if all the steps have been completed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/SpeedMeter/Eraser.Manager/ProgressManager.cs

    r1503 r1504  
    100100            get 
    101101            { 
     102                if (Total == 0) 
     103                    return 0.0f; 
     104 
    102105                return (float)((double)Completed / Total); 
    103106            } 
     
    408411            get 
    409412            { 
    410                 float totalWeight = (float)Steps.TotalWeights; 
    411413                float result = 0.0f; 
    412  
    413414                foreach (Step step in Steps) 
    414415                    result += step.Progress.Progress * step.Weight; 
     
    422423            get 
    423424            { 
     425                if (CurrentStep == null) 
     426                    return 0; 
     427 
    424428                return CurrentStep.Progress.Speed; 
    425429            } 
     
    430434            get 
    431435            { 
     436                if (StartTime == DateTime.MinValue) 
     437                    return TimeSpan.MinValue; 
     438 
    432439                long ticksElapsed = (DateTime.Now - StartTime).Ticks; 
    433440                float progressRemaining = 1.0f - Progress; 
     
    457464                    return null; 
    458465 
     466                if (Steps.Count == 0) 
     467                    return null; 
     468 
    459469                foreach (Step step in Steps) 
    460470                    if (step.Progress.Progress < 1.0f) 
    461471                        return step; 
    462472 
    463                 return null; 
     473                //Return the last step since we don't have any 
     474                return Steps[Steps.Count - 1]; 
    464475            } 
    465476        } 
Note: See TracChangeset for help on using the changeset viewer.