Changeset 2484
- Timestamp:
- 3/13/2012 9:45:41 AM (14 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/pluginsRewrite/Eraser.Manager/Task.cs
r2467 r2484 100 100 /// The Executor object which is managing this task. 101 101 /// </summary> 102 public Executor Executor { get; internal set; } 102 public Executor Executor 103 { 104 get 105 { 106 return executor; 107 } 108 internal set 109 { 110 if (value == null) 111 throw new ArgumentNullException(); 112 if (executor != null) 113 throw new InvalidOperationException(); 114 115 executor = value; 116 } 117 } 103 118 104 119 /// <summary> … … 111 126 /// The name of the task, used for display in UI elements. 112 127 /// </summary> 113 public string UIText 114 { 115 get 116 { 117 //Simple case, the task name was given by the user. 118 if (!string.IsNullOrEmpty(Name)) 119 return Name; 120 121 string result = string.Empty; 122 if (Targets.Count == 0) 123 return result; 124 else if (Targets.Count < 5) 125 { 126 //Simpler case, small set of data. 127 foreach (IErasureTarget tgt in Targets) 128 result += S._("{0}, ", tgt); 129 130 return result.Remove(result.Length - 2); 131 } 132 else 133 { 134 //Ok, we've quite a few entries, get the first, the mid and the end. 135 result = S._("{0}, ", Targets[0]); 136 result += S._("{0}, ", Targets[Targets.Count / 2]); 137 result += Targets[Targets.Count - 1]; 138 139 return S._("{0} and {1} other targets", result, Targets.Count - 3); 140 } 128 public string ToString() 129 { 130 //Simple case, the task name was given by the user. 131 if (!string.IsNullOrEmpty(Name)) 132 return Name; 133 134 string result = string.Empty; 135 if (Targets.Count == 0) 136 return result; 137 else if (Targets.Count < 5) 138 { 139 //Simpler case, small set of data. 140 foreach (IErasureTarget tgt in Targets) 141 result += S._("{0}, ", tgt); 142 143 return result.Remove(result.Length - 2); 144 } 145 else 146 { 147 //Ok, we've quite a few entries, get the first, the mid and the end. 148 result = S._("{0}, ", Targets[0]); 149 result += S._("{0}, ", Targets[Targets.Count / 2]); 150 result += Targets[Targets.Count - 1]; 151 152 return S._("{0} and {1} other targets", result, Targets.Count - 3); 141 153 } 142 154 } … … 230 242 } 231 243 244 private Executor executor; 232 245 private Schedule schedule; 233 246 private SteppedProgressManager progress; … … 243 256 /// </summary> 244 257 public EventHandler TaskStarted { get; set; } 245 246 /// <summary>247 /// The event object holding all event handlers.248 /// </summary>249 public EventHandler<ProgressChangedEventArgs> ProgressChanged { get; set; }250 258 251 259 /// <summary> … … 272 280 Executing = true; 273 281 Progress = new SteppedProgressManager(); 274 }275 276 /// <summary>277 /// Broadcasts a ProgressChanged event. The sender will be the erasure target278 /// which broadcast this event; e.UserState will contain extra information279 /// about the progress which is stored as a TaskProgressChangedEventArgs280 /// object.281 /// </summary>282 /// <param name="sender">The <see cref="IErasureTarget"/> which is reporting283 /// progress.</param>284 /// <param name="e">The new progress value.</param>285 /// <exception cref="ArgumentException">e.UserState must be of the type286 /// <see cref="TaskProgressEventargs"/></exception>287 /// <exception cref="ArgumentNullException">Both sender and e cannot be null.</exception>288 internal void OnProgressChanged(IErasureTarget sender, ProgressChangedEventArgs e)289 {290 if (sender == null)291 throw new ArgumentNullException("sender");292 if (e == null)293 throw new ArgumentNullException("sender");294 if (e.UserState.GetType() != typeof(TaskProgressChangedEventArgs))295 throw new ArgumentException("The Task.OnProgressChanged event expects a " +296 "TaskProgressEventArgs argument for the ProgressChangedEventArgs' UserState " +297 "object.", "e");298 299 if (ProgressChanged != null)300 ProgressChanged(sender, e);301 282 } 302 283 … … 333 314 public Task Task { get; private set; } 334 315 } 335 336 /// <summary>337 /// Stores extra information in the <see cref="ProgressChangedEventArgs"/>338 /// structure that is not conveyed in the ProgressManagerBase classes.339 /// </summary>340 public class TaskProgressChangedEventArgs341 {342 /// <summary>343 /// Constructor.344 /// </summary>345 /// <param name="itemName">The item whose erasure progress is being erased.</param>346 /// <param name="itemPass">The current pass number for this item.</param>347 /// <param name="itemTotalPasses">The total number of passes to complete erasure348 /// of this item.</param>349 public TaskProgressChangedEventArgs(string itemName, int itemPass,350 int itemTotalPasses)351 {352 ItemName = itemName;353 ItemPass = itemPass;354 ItemTotalPasses = itemTotalPasses;355 }356 357 /// <summary>358 /// The file name of the item being erased.359 /// </summary>360 public string ItemName { get; private set; }361 362 /// <summary>363 /// The pass number of a multi-pass erasure method.364 /// </summary>365 public int ItemPass { get; private set; }366 367 /// <summary>368 /// The total number of passes to complete before this erasure method is369 /// completed.370 /// </summary>371 public int ItemTotalPasses { get; private set; }372 }373 316 }
Note: See TracChangeset
for help on using the changeset viewer.
