Changeset 1509


Ignore:
Timestamp:
1/12/2010 7:52:44 AM (5 years ago)
Author:
lowjoel
Message:

Factor out the progress updating code to a separate function because upon construction of the form we can already query the task for progress

Location:
branches/eraser6/SpeedMeter/Eraser
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/SpeedMeter/Eraser/ProgressForm.cs

    r1507 r1509  
    5151            task.ProgressChanged += task_ProgressChanged; 
    5252            task.TaskFinished += task_TaskFinished; 
     53 
     54            //Set the current progress 
     55            if (task.Progress.CurrentStep != null) 
     56                UpdateProgress((SteppedProgressManager)task.Progress.CurrentStep.Progress, null); 
    5357        } 
    5458 
     
    7377 
    7478            ErasureTarget target = sender as ErasureTarget; 
     79            if (target == null) 
     80                return; 
     81 
    7582            SteppedProgressManager progress = target.Progress as SteppedProgressManager; 
    76             status.Text = progress.CurrentStep.Name; 
    77             item.Text = WrapItemName(e.ItemName); 
    78             pass.Text = e.ItemTotalPasses != 0 ? 
    79                 S._("{0} out of {1}", e.ItemPass, e.ItemTotalPasses) : 
    80                 e.ItemPass.ToString(CultureInfo.CurrentCulture); 
    81  
    82             if (target.Progress.TimeLeft >= TimeSpan.Zero) 
    83                 timeLeft.Text = S._("About {0} left", RoundToSeconds(target.Progress.TimeLeft)); 
    84             else 
    85                 timeLeft.Text = S._("Unknown"); 
    86  
    87             if (target.Progress.Progress >= 0.0f) 
    88             { 
    89                 itemProgress.Style = ProgressBarStyle.Continuous; 
    90                 itemProgress.Value = (int)(target.Progress.Progress * 1000); 
    91                 itemProgressLbl.Text = target.Progress.Progress.ToString("#0%", 
    92                     CultureInfo.CurrentCulture); 
    93             } 
    94             else 
    95             { 
    96                 itemProgress.Style = ProgressBarStyle.Marquee; 
    97                 itemProgressLbl.Text = string.Empty; 
    98             } 
    99  
    100             overallProgress.Value = (int)(e.Task.Progress.Progress * 1000); 
    101             overallProgressLbl.Text = S._("Total: {0,2:#0.00%}", e.Task.Progress.Progress); 
     83            if (progress == null) 
     84                return; 
     85 
     86            UpdateProgress(progress, e); 
    10287        } 
    10388 
     
    157142                task.Cancel(); 
    158143            Close(); 
     144        } 
     145 
     146        private void UpdateProgress(SteppedProgressManager targetProgress, TaskProgressEventArgs e) 
     147        { 
     148            status.Text = targetProgress.CurrentStep.Name; 
     149 
     150            if (e != null) 
     151            { 
     152                item.Text = WrapItemName(e.ItemName); 
     153                pass.Text = e.ItemTotalPasses != 0 ? 
     154                    S._("{0} out of {1}", e.ItemPass, e.ItemTotalPasses) : 
     155                    e.ItemPass.ToString(CultureInfo.CurrentCulture); 
     156            } 
     157 
     158            if (targetProgress.TimeLeft >= TimeSpan.Zero) 
     159                timeLeft.Text = S._("About {0} left", RoundToSeconds(targetProgress.TimeLeft)); 
     160            else 
     161                timeLeft.Text = S._("Unknown"); 
     162 
     163            if (targetProgress.Progress >= 0.0f) 
     164            { 
     165                itemProgress.Style = ProgressBarStyle.Continuous; 
     166                itemProgress.Value = (int)(targetProgress.Progress * 1000); 
     167                itemProgressLbl.Text = targetProgress.Progress.ToString("#0%", 
     168                    CultureInfo.CurrentCulture); 
     169            } 
     170            else 
     171            { 
     172                itemProgress.Style = ProgressBarStyle.Marquee; 
     173                itemProgressLbl.Text = string.Empty; 
     174            } 
     175 
     176            overallProgress.Value = (int)(task.Progress.Progress * 1000); 
     177            overallProgressLbl.Text = S._("Total: {0,2:#0.00%}", task.Progress.Progress); 
    159178        } 
    160179 
  • branches/eraser6/SpeedMeter/Eraser/Strings.NL.resx

    r1507 r1509  
    154154    <value>(Untranslated)</value> 
    155155  </data> 
     156  <data name="Total: {0,2:#0.00%}" xml:space="preserve"> 
     157    <value>(Untranslated)</value> 
     158  </data> 
     159  <data name="Completed with warnings" xml:space="preserve"> 
     160    <value>Afgerond met waarschuwingen</value> 
     161  </data> 
     162  <data name="Completed with errors" xml:space="preserve"> 
     163    <value>Afgerond met fouten</value> 
     164  </data> 
     165  <data name="Not completed" xml:space="preserve"> 
     166    <value>Niet afgerond</value> 
     167  </data> 
     168  <data name="Completed" xml:space="preserve"> 
     169    <value>Afgerond</value> 
     170  </data> 
     171  <data name="Close" xml:space="preserve"> 
     172    <value>Sluiten</value> 
     173  </data> 
    156174  <data name="{0} out of {1}" xml:space="preserve"> 
    157175    <value>{0} van {1}</value> 
     
    163181    <value>(Untranslated)</value> 
    164182  </data> 
    165   <data name="Total: {0,2:#0.00%}" xml:space="preserve"> 
    166     <value>(Untranslated)</value> 
    167   </data> 
    168   <data name="Completed with warnings" xml:space="preserve"> 
    169     <value>Afgerond met waarschuwingen</value> 
    170   </data> 
    171   <data name="Completed with errors" xml:space="preserve"> 
    172     <value>Afgerond met fouten</value> 
    173   </data> 
    174   <data name="Not completed" xml:space="preserve"> 
    175     <value>Niet afgerond</value> 
    176   </data> 
    177   <data name="Completed" xml:space="preserve"> 
    178     <value>Afgerond</value> 
    179   </data> 
    180   <data name="Close" xml:space="preserve"> 
    181     <value>Sluiten</value> 
    182   </data> 
    183183  <data name="Queued for execution" xml:space="preserve"> 
    184184    <value>In wachtrij geplaatst voor operatie</value> 
  • branches/eraser6/SpeedMeter/Eraser/Strings.en.resx

    r1507 r1509  
    154154    <value>Another instance of Eraser is already running but it is running with higher privileges than this instance of Eraser.\n\nEraser will now exit.</value> 
    155155  </data> 
     156  <data name="Total: {0,2:#0.00%}" xml:space="preserve"> 
     157    <value>Total: {0,2:#0.00%}</value> 
     158  </data> 
     159  <data name="Completed with warnings" xml:space="preserve"> 
     160    <value>Completed with warnings</value> 
     161  </data> 
     162  <data name="Completed with errors" xml:space="preserve"> 
     163    <value>Completed with errors</value> 
     164  </data> 
     165  <data name="Not completed" xml:space="preserve"> 
     166    <value>Not completed</value> 
     167  </data> 
     168  <data name="Completed" xml:space="preserve"> 
     169    <value>Completed</value> 
     170  </data> 
     171  <data name="Close" xml:space="preserve"> 
     172    <value>Close</value> 
     173  </data> 
    156174  <data name="{0} out of {1}" xml:space="preserve"> 
    157175    <value>{0} out of {1}</value> 
     
    163181    <value>Unknown</value> 
    164182  </data> 
    165   <data name="Total: {0,2:#0.00%}" xml:space="preserve"> 
    166     <value>Total: {0,2:#0.00%}</value> 
    167   </data> 
    168   <data name="Completed with warnings" xml:space="preserve"> 
    169     <value>Completed with warnings</value> 
    170   </data> 
    171   <data name="Completed with errors" xml:space="preserve"> 
    172     <value>Completed with errors</value> 
    173   </data> 
    174   <data name="Not completed" xml:space="preserve"> 
    175     <value>Not completed</value> 
    176   </data> 
    177   <data name="Completed" xml:space="preserve"> 
    178     <value>Completed</value> 
    179   </data> 
    180   <data name="Close" xml:space="preserve"> 
    181     <value>Close</value> 
    182   </data> 
    183183  <data name="Queued for execution" xml:space="preserve"> 
    184184    <value>Queued for execution</value> 
  • branches/eraser6/SpeedMeter/Eraser/Strings.it.resx

    r1507 r1509  
    154154    <value>Un'altra occorrenza di Eraser è già in esecuzione, ma con privilegi più elevati di questa.\n\nEraser adesso si chiuderà.</value> 
    155155  </data> 
     156  <data name="Total: {0,2:#0.00%}" xml:space="preserve"> 
     157    <value>Totale: {0,2:#0.00%}</value> 
     158  </data> 
     159  <data name="Completed with warnings" xml:space="preserve"> 
     160    <value>Completata con avvisi</value> 
     161  </data> 
     162  <data name="Completed with errors" xml:space="preserve"> 
     163    <value>Completata con errori</value> 
     164  </data> 
     165  <data name="Not completed" xml:space="preserve"> 
     166    <value>Non completata</value> 
     167  </data> 
     168  <data name="Completed" xml:space="preserve"> 
     169    <value>Completata</value> 
     170  </data> 
     171  <data name="Close" xml:space="preserve"> 
     172    <value>Chiudi</value> 
     173  </data> 
    156174  <data name="{0} out of {1}" xml:space="preserve"> 
    157175    <value>{0} di {1}</value> 
     
    163181    <value>Sconosciuto</value> 
    164182  </data> 
    165   <data name="Total: {0,2:#0.00%}" xml:space="preserve"> 
    166     <value>Totale: {0,2:#0.00%}</value> 
    167   </data> 
    168   <data name="Completed with warnings" xml:space="preserve"> 
    169     <value>Completata con avvisi</value> 
    170   </data> 
    171   <data name="Completed with errors" xml:space="preserve"> 
    172     <value>Completata con errori</value> 
    173   </data> 
    174   <data name="Not completed" xml:space="preserve"> 
    175     <value>Non completata</value> 
    176   </data> 
    177   <data name="Completed" xml:space="preserve"> 
    178     <value>Completata</value> 
    179   </data> 
    180   <data name="Close" xml:space="preserve"> 
    181     <value>Chiudi</value> 
    182   </data> 
    183183  <data name="Queued for execution" xml:space="preserve"> 
    184184    <value>Pianificata per l'esecuzione</value> 
  • branches/eraser6/SpeedMeter/Eraser/Strings.resx

    r1507 r1509  
    154154    <value>Another instance of Eraser is already running but it is running with higher privileges than this instance of Eraser.\n\nEraser will now exit.</value> 
    155155  </data> 
     156  <data name="Total: {0,2:#0.00%}" xml:space="preserve"> 
     157    <value>Total: {0,2:#0.00%}</value> 
     158  </data> 
     159  <data name="Completed with warnings" xml:space="preserve"> 
     160    <value>Completed with warnings</value> 
     161  </data> 
     162  <data name="Completed with errors" xml:space="preserve"> 
     163    <value>Completed with errors</value> 
     164  </data> 
     165  <data name="Not completed" xml:space="preserve"> 
     166    <value>Not completed</value> 
     167  </data> 
     168  <data name="Completed" xml:space="preserve"> 
     169    <value>Completed</value> 
     170  </data> 
     171  <data name="Close" xml:space="preserve"> 
     172    <value>Close</value> 
     173  </data> 
    156174  <data name="{0} out of {1}" xml:space="preserve"> 
    157175    <value>{0} out of {1}</value> 
     
    163181    <value>Unknown</value> 
    164182  </data> 
    165   <data name="Total: {0,2:#0.00%}" xml:space="preserve"> 
    166     <value>Total: {0,2:#0.00%}</value> 
    167   </data> 
    168   <data name="Completed with warnings" xml:space="preserve"> 
    169     <value>Completed with warnings</value> 
    170   </data> 
    171   <data name="Completed with errors" xml:space="preserve"> 
    172     <value>Completed with errors</value> 
    173   </data> 
    174   <data name="Not completed" xml:space="preserve"> 
    175     <value>Not completed</value> 
    176   </data> 
    177   <data name="Completed" xml:space="preserve"> 
    178     <value>Completed</value> 
    179   </data> 
    180   <data name="Close" xml:space="preserve"> 
    181     <value>Close</value> 
    182   </data> 
    183183  <data name="Queued for execution" xml:space="preserve"> 
    184184    <value>Queued for execution</value> 
Note: See TracChangeset for help on using the changeset viewer.