Changeset 944
- Timestamp:
- 5/1/2009 3:14:31 AM (4 years ago)
- Location:
- branches/eraser6
- Files:
-
- 10 edited
-
Eraser/MainForm.cs (modified) (3 diffs)
-
Eraser/ProgressForm.cs (modified) (2 diffs)
-
Eraser/SchedulerPanel.cs (modified) (8 diffs)
-
Eraser/SettingsPanel.cs (modified) (4 diffs)
-
Manager/DirectExecutor.cs (modified) (5 diffs)
-
Manager/EntropySource.cs (modified) (5 diffs)
-
Manager/Executor.cs (modified) (1 diff)
-
Manager/Method.cs (modified) (9 diffs)
-
Manager/RemoteExecutor.cs (modified) (3 diffs)
-
Manager/Task.cs (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/Eraser/MainForm.cs
r917 r944 48 48 49 49 //Connect to the executor task processing and processed events. 50 Program.eraserClient.TaskProcessing += 51 new Executor.TaskProcessingEvent(OnTaskProcessing); 52 Program.eraserClient.TaskProcessed += 53 new Executor.TaskProcessedEvent(OnTaskProcessed); 50 Program.eraserClient.TaskProcessing += OnTaskProcessing; 51 Program.eraserClient.TaskProcessed += OnTaskProcessed; 54 52 55 53 //Check the notification area context menu's minimise to tray item. … … 257 255 258 256 #region Task processing code (for notification area animation) 259 void OnTaskProcessing( Eraser.Manager.Task task)257 void OnTaskProcessing(object sender, TaskEventArgs e) 260 258 { 261 259 if (InvokeRequired) 262 260 { 263 Invoke(new E xecutor.TaskProcessingEvent(OnTaskProcessing), task);261 Invoke(new EventHandler<TaskEventArgs>(OnTaskProcessing), sender, e); 264 262 return; 265 263 } 266 264 267 string iconText = S._("Eraser") + " - " + S._("Processing:") + ' ' + task.UIText;265 string iconText = S._("Eraser") + " - " + S._("Processing:") + ' ' + e.Task.UIText; 268 266 if (iconText.Length >= 64) 269 267 iconText = iconText.Remove(60) + "..."; … … 274 272 } 275 273 276 void OnTaskProcessed( Eraser.Manager.Task task)274 void OnTaskProcessed(object sender, TaskEventArgs e) 277 275 { 278 276 if (InvokeRequired) 279 277 { 280 Invoke(new E xecutor.TaskProcessedEvent(OnTaskProcessed), task);278 Invoke(new EventHandler<TaskEventArgs>(OnTaskProcessed), sender, e); 281 279 return; 282 280 } -
branches/eraser6/Eraser/ProgressForm.cs
r920 r944 45 45 //Register the event handlers 46 46 jobTitle.Text = task.UIText; 47 task.ProgressChanged += new Task.ProgressEventFunction(task_ProgressChanged);48 task.TaskFinished += new Task.TaskEventFunction(task_TaskFinished);47 task.ProgressChanged += task_ProgressChanged; 48 task.TaskFinished += task_TaskFinished; 49 49 } 50 50 51 51 private void ProgressForm_FormClosed(object sender, FormClosedEventArgs e) 52 52 { 53 task.ProgressChanged -= new Task.ProgressEventFunction(task_ProgressChanged);54 task.TaskFinished -= new Task.TaskEventFunction(task_TaskFinished);53 task.ProgressChanged -= task_ProgressChanged; 54 task.TaskFinished -= task_TaskFinished; 55 55 } 56 56 57 void task_ProgressChanged( TaskProgressEventArgs e)57 void task_ProgressChanged(object sender, TaskProgressEventArgs e) 58 58 { 59 59 if (InvokeRequired) 60 60 { 61 Task.ProgressEventFunction func = 62 new Task.ProgressEventFunction(task_ProgressChanged); 63 Invoke(func, new object[] {e}); 61 Invoke(new EventHandler<TaskProgressEventArgs>(task_ProgressChanged), sender, e); 64 62 return; 65 63 } … … 83 81 } 84 82 85 void task_TaskFinished( TaskEventArgs e)83 void task_TaskFinished(object sender, TaskEventArgs e) 86 84 { 87 85 if (InvokeRequired) 88 86 { 89 Task.TaskEventFunction func = 90 new Task.TaskEventFunction(task_TaskFinished); 91 Invoke(func, new object[] { e }); 87 Invoke(new EventHandler<TaskEventArgs>(task_TaskFinished), sender, e); 92 88 return; 93 89 } -
branches/eraser6/Eraser/SchedulerPanel.cs
r920 r944 65 65 66 66 //Add our event handlers to the task 67 task.TaskStarted += new Task.TaskEventFunction(task_TaskStarted);68 task.ProgressChanged += new Task.ProgressEventFunction(task_ProgressChanged);69 task.TaskFinished += new Task.TaskEventFunction(task_TaskFinished);67 task.TaskStarted += task_TaskStarted; 68 task.ProgressChanged += task_ProgressChanged; 69 task.TaskFinished += task_TaskFinished; 70 70 71 71 //Show the fields on the list view … … 111 111 } 112 112 113 private void TaskAdded(Task task) 113 /// <summary> 114 /// Handles the Task Added event. 115 /// </summary> 116 private void TaskAdded(object sender, TaskEventArgs e) 114 117 { 115 118 if (InvokeRequired) 116 119 { 117 Invoke(new E xecutor.TaskAddedEvent(TaskAdded), new object[] { task });120 Invoke(new EventHandler<TaskEventArgs>(TaskAdded), sender, e); 118 121 return; 119 122 } … … 124 127 { 125 128 parent.ShowNotificationBalloon(S._("New task added"), S._("{0} " + 126 "has just been added to the list of tasks.", task.UIText),129 "has just been added to the list of tasks.", e.Task.UIText), 127 130 ToolTipIcon.Info); 128 131 } 129 132 130 DisplayTask( task);133 DisplayTask(e.Task); 131 134 } 132 135 … … 134 137 /// Handles the task deleted event. 135 138 /// </summary> 136 /// <param name="task">The task being deleted.</param> 137 private void TaskDeleted(Task task) 139 private void TaskDeleted(object sender, TaskEventArgs e) 138 140 { 139 141 if (InvokeRequired) 140 142 { 141 Invoke(new E xecutor.TaskDeletedEvent(TaskDeleted), new object[] { task });143 Invoke(new EventHandler<TaskEventArgs>(TaskDeleted), sender, e); 142 144 return; 143 145 } 144 146 145 147 foreach (ListViewItem item in scheduler.Items) 146 if (((Task)item.Tag) == task)148 if (((Task)item.Tag) == e.Task) 147 149 { 148 150 scheduler.Items.Remove(item); … … 155 157 /// </summary> 156 158 /// <param name="e">The task event object.</param> 157 void task_TaskStarted( TaskEventArgs e)159 void task_TaskStarted(object sender, TaskEventArgs e) 158 160 { 159 161 if (scheduler.InvokeRequired) 160 162 { 161 Task.TaskEventFunction func = 162 new Task.TaskEventFunction(task_TaskStarted); 163 Invoke(func, new object[] { e }); 163 Invoke(new EventHandler<TaskEventArgs>(task_TaskStarted), sender, e); 164 164 return; 165 165 } … … 181 181 /// Handles the progress event by the task. 182 182 /// </summary> 183 /// <param name="e">Event Argument.</param> 184 void task_ProgressChanged(TaskProgressEventArgs e) 183 void task_ProgressChanged(object sender, TaskProgressEventArgs e) 185 184 { 186 185 //Make sure we handle the event in the main thread as this requires … … 188 187 if (scheduler.InvokeRequired) 189 188 { 190 Task.ProgressEventFunction func = 191 new Task.ProgressEventFunction(task_ProgressChanged); 192 Invoke(func, new object[] { e }); 189 Invoke(new EventHandler<TaskProgressEventArgs>(task_ProgressChanged), sender, e); 193 190 return; 194 191 } … … 201 198 /// Handles the task completion event. 202 199 /// </summary> 203 /// <param name="e">The task event object.</param> 204 void task_TaskFinished(TaskEventArgs e) 200 void task_TaskFinished(object sender, TaskEventArgs e) 205 201 { 206 202 if (InvokeRequired) 207 203 { 208 Task.TaskEventFunction func = 209 new Task.TaskEventFunction(task_TaskFinished); 210 Invoke(func, new object[] { e }); 204 Invoke(new EventHandler<TaskEventArgs>(task_TaskFinished), sender, e); 211 205 return; 212 206 } -
branches/eraser6/Eraser/SettingsPanel.cs
r939 r944 46 46 47 47 //For new plugins, register the callback. 48 Host.Instance.PluginLoaded += new EventHandler<PluginLoadedEventArgs>(OnNewPluginLoaded); 49 ErasureMethodManager.MethodRegistered += 50 new ErasureMethodManager.MethodRegisteredFunction(OnMethodRegistered); 51 ErasureMethodManager.MethodUnregistered += 52 new ErasureMethodManager.MethodUnregisteredFunction(OnMethodUnregistered); 48 Host.Instance.PluginLoaded += OnNewPluginLoaded; 49 ErasureMethodManager.MethodRegistered += OnMethodRegistered; 50 ErasureMethodManager.MethodUnregistered += OnMethodUnregistered; 53 51 54 52 //Load the values … … 88 86 } 89 87 90 private void OnMethodRegistered( Guid guid)91 { 92 ErasureMethod method = ErasureMethodManager.GetInstance( guid);88 private void OnMethodRegistered(object sender, ErasureMethodRegistrationEventArgs e) 89 { 90 ErasureMethod method = ErasureMethodManager.GetInstance(e.Guid); 93 91 eraseFilesMethod.Items.Add(method); 94 92 if (method is UnusedSpaceErasureMethod) … … 96 94 } 97 95 98 private void OnMethodUnregistered( Guid guid)96 private void OnMethodUnregistered(object sender, ErasureMethodRegistrationEventArgs e) 99 97 { 100 98 foreach (object obj in eraseFilesMethod.Items) 101 if (((ErasureMethod)obj).Guid == guid)99 if (((ErasureMethod)obj).Guid == e.Guid) 102 100 { 103 101 eraseFilesMethod.Items.Remove(obj); … … 106 104 107 105 foreach (object obj in eraseUnusedMethod.Items) 108 if (((ErasureMethod)obj).Guid == guid)106 if (((ErasureMethod)obj).Guid == e.Guid) 109 107 { 110 108 eraseUnusedMethod.Items.Remove(obj); -
branches/eraser6/Manager/DirectExecutor.cs
r943 r944 154 154 task.Canceled = false; 155 155 task.OnTaskStarted(new TaskEventArgs(task)); 156 OnTaskProcessing( task);156 OnTaskProcessing(new TaskEventArgs(task)); 157 157 158 158 //Start a new log session to separate this session's events … … 161 161 162 162 //Run the task 163 TaskProgressManager progress = new TaskProgressManager( currentTask);163 TaskProgressManager progress = new TaskProgressManager(task); 164 164 foreach (ErasureTarget target in task.Targets) 165 165 try … … 207 207 //And the task finished event. 208 208 task.OnTaskFinished(new TaskEventArgs(task)); 209 OnTaskProcessed( currentTask);209 OnTaskProcessed(new TaskEventArgs(task)); 210 210 } 211 211 … … 936 936 //Call all the event handlers who registered to be notified of tasks 937 937 //being added. 938 Owner.OnTaskAdded( item);938 Owner.OnTaskAdded(new TaskEventArgs(item)); 939 939 940 940 //If the task is scheduled to run now, break the waiting thread and … … 962 962 963 963 //Call all event handlers registered to be notified of task deletions. 964 Owner.OnTaskDeleted( task);964 Owner.OnTaskDeleted(new TaskEventArgs(task)); 965 965 } 966 966 } -
branches/eraser6/Manager/EntropySource.cs
r931 r944 164 164 /// Allows plugins to register EntropySources with the main program. Thread-safe. 165 165 /// </summary> 166 /// <param name=" method"></param>166 /// <param name="source">The source of entropy to add.</param> 167 167 public static void Register(EntropySource source) 168 168 { … … 171 171 manager.sources.Add(source.Guid, source); 172 172 manager.entropyThread.AddEntropySource(source); 173 } 174 175 /// <summary> 176 /// Performs the MethodUnregistered event handlers. 177 /// </summary> 178 /// <param name="guid">The GUID of the unregistered erasure method.</param> 179 private static void OnEntropySourceActivated(Guid guid) 180 { 181 if (EntropySourceActivated != null) 182 EntropySourceActivated(guid); 173 174 OnEntropySourceRegistered(new EntropySourceRegistrationEventArgs(source.Guid)); 175 } 176 177 /// <summary> 178 /// Calls the EntropySourceRegistered event handlers. 179 /// </summary> 180 private static void OnEntropySourceRegistered(EntropySourceRegistrationEventArgs e) 181 { 182 if (EntropySourceRegistered != null) 183 EntropySourceRegistered(ManagerLibrary.Instance.EntropySourceManager, e); 183 184 } 184 185 … … 193 194 } 194 195 } 195 196 /// <summary>197 /// The delegate prototype of Entropy Source Registered event198 /// </summary>199 /// <param name="value"></param>200 public delegate void OnEntropySourceActivatedEventHandler(Guid value);201 196 202 197 /// <summary> … … 204 199 /// called whenever the EntropySourceManager.Register is invoked. 205 200 /// </summary> 206 public static event OnEntropySourceActivatedEventHandler EntropySourceActivated; 201 public static EventHandler<EntropySourceRegistrationEventArgs> 202 EntropySourceRegistered { get; set; } 207 203 208 204 /// <summary> … … 216 212 private EntropyPoller entropyThread = new EntropyPoller(); 217 213 }; 214 215 public class EntropySourceRegistrationEventArgs : EventArgs 216 { 217 /// <summary> 218 /// Constructor. 219 /// </summary> 220 /// <param name="value">The GUID of the newly registered/unregistered entropy 221 /// source.</param> 222 public EntropySourceRegistrationEventArgs(Guid value) 223 { 224 Guid = value; 225 } 226 227 /// <summary> 228 /// The GUID of the newly registered/unregistered entropy source. 229 /// </summary> 230 public Guid Guid { get; private set; } 231 } 218 232 219 233 /// <summary> -
branches/eraser6/Manager/Executor.cs
r926 r944 90 90 91 91 /// <summary> 92 /// The prototype of functions handing the Task Added event.93 /// </summary>94 /// <param name="task">The task which has been added</param>95 public delegate void TaskAddedEvent(Task task);96 97 /// <summary>98 92 /// The task added event object. 99 93 /// </summary> 100 public event TaskAddedEvent TaskAdded;94 public EventHandler<TaskEventArgs> TaskAdded { get; set; } 101 95 102 96 /// <summary> 103 97 /// Helper function for the task added event. 104 98 /// </summary> 105 /// <param name="task">The task that has just been added</param> 106 internal void OnTaskAdded(Task task) 99 internal void OnTaskAdded(TaskEventArgs e) 107 100 { 108 101 if (TaskAdded != null) 109 TaskAdded(task); 110 } 111 112 /// <summary> 113 /// The prototype of functions handing the Task Deleted event. 114 /// </summary> 115 /// <param name="task">The task which has been deleted</param> 116 public delegate void TaskDeletedEvent(Task task); 102 TaskAdded(this, e); 103 } 117 104 118 105 /// <summary> 119 106 /// The task added event object. 120 107 /// </summary> 121 public event TaskDeletedEvent TaskDeleted;108 public EventHandler<TaskEventArgs> TaskDeleted { get; set; } 122 109 123 110 /// <summary> 124 111 /// Helper function for the task deleted event. 125 112 /// </summary> 126 /// <param name="task">The task that has just been deleted</param> 127 internal void OnTaskDeleted(Task task) 113 internal void OnTaskDeleted(TaskEventArgs e) 128 114 { 129 115 if (TaskDeleted != null) 130 TaskDeleted(task); 131 } 132 133 /// <summary> 134 /// The delegate for handling the task processing event from the executor. 135 /// </summary> 136 /// <param name="task">The currently processing task.</param> 137 public delegate void TaskProcessingEvent(Task task); 116 TaskDeleted(this, e); 117 } 138 118 139 119 /// <summary> 140 120 /// The task processing event object. 141 121 /// </summary> 142 public event TaskProcessingEvent TaskProcessing;122 public EventHandler<TaskEventArgs> TaskProcessing { get; set; } 143 123 144 124 /// <summary> 145 125 /// Helper function for the Task processing event. 146 126 /// </summary> 147 protected void OnTaskProcessing(Task task)127 protected void OnTaskProcessing(TaskEventArgs e) 148 128 { 149 129 if (TaskProcessing != null) 150 TaskProcessing(task); 151 } 152 153 /// <summary> 154 /// The delegate for handling the task processed event from the executor. 155 /// </summary> 156 /// <param name="task">The processed task.</param> 157 public delegate void TaskProcessedEvent(Task task); 130 TaskProcessing(this, e); 131 } 158 132 159 133 /// <summary> 160 134 /// The task processed event object. 161 135 /// </summary> 162 public event TaskProcessedEvent TaskProcessed;136 public EventHandler<TaskEventArgs> TaskProcessed { get; set; } 163 137 164 138 /// <summary> 165 139 /// Helper function for the Task processed event. 166 140 /// </summary> 167 protected void OnTaskProcessed(Task task)141 protected void OnTaskProcessed(TaskEventArgs e) 168 142 { 169 143 if (TaskProcessed != null) 170 TaskProcessed(t ask);144 TaskProcessed(this, e); 171 145 } 172 146 } -
branches/eraser6/Manager/Method.cs
r938 r944 301 301 } 302 302 303 public override void Erase(Stream str m, long erasureLength, Prng prng,303 public override void Erase(Stream stream, long erasureLength, Prng prng, 304 304 ProgressFunction callback) 305 305 { … … 310 310 311 311 //Remember the starting position of the stream. 312 long strmStart = str m.Position;313 long strmLength = Math.Min(str m.Length - strmStart, erasureLength);312 long strmStart = stream.Position; 313 long strmLength = Math.Min(stream.Length - strmStart, erasureLength); 314 314 315 315 //Allocate memory for a buffer holding data for the pass. … … 324 324 325 325 //Start from the beginning again 326 str m.Seek(strmStart, SeekOrigin.Begin);326 stream.Seek(strmStart, SeekOrigin.Begin); 327 327 328 328 //Write the buffer to disk. … … 343 343 344 344 //Write the data. 345 str m.Write(buffer, dataStopped, amount);346 str m.Flush();345 stream.Write(buffer, dataStopped, amount); 346 stream.Flush(); 347 347 toWrite -= amount; 348 348 … … 499 499 500 500 //Broadcast the event 501 OnMethodRegistered( method.Guid);501 OnMethodRegistered(new ErasureMethodRegistrationEventArgs(method.Guid)); 502 502 } 503 503 … … 513 513 514 514 ManagerLibrary.Instance.ErasureMethodManager.methods.Remove(value); 515 OnMethodUnregistered( value);515 OnMethodUnregistered(new ErasureMethodRegistrationEventArgs(value)); 516 516 } 517 517 … … 539 539 540 540 /// <summary> 541 /// The delegate prototype of the Method Registered event.542 /// </summary>543 /// <param name="value">The GUID of the method being registered.</param>544 public delegate void MethodRegisteredFunction(Guid value);545 546 /// <summary>547 541 /// Called whenever an erasure method is registered. 548 542 /// </summary> 549 public static event MethodRegisteredFunction MethodRegistered; 543 public static EventHandler<ErasureMethodRegistrationEventArgs> 544 MethodRegistered { get; set; } 550 545 551 546 /// <summary> 552 /// The delegate prototype of the Method Unregistered event.553 /// </summary>554 /// <param name="value">The GUID of the method being registered.</param>555 public delegate void MethodUnregisteredFunction(Guid value);556 557 /// <summary>558 547 /// Called whenever an erasure method is unregistered. 559 548 /// </summary> 560 public static event MethodUnregisteredFunction MethodUnregistered; 549 public static EventHandler<ErasureMethodRegistrationEventArgs> 550 MethodUnregistered { get; set; } 561 551 562 552 /// <summary> … … 564 554 /// </summary> 565 555 /// <param name="guid">The GUID of the newly registered erasure method.</param> 566 private static void OnMethodRegistered( Guid guid)556 private static void OnMethodRegistered(ErasureMethodRegistrationEventArgs e) 567 557 { 568 558 if (MethodRegistered != null) 569 MethodRegistered( guid);559 MethodRegistered(ManagerLibrary.Instance.ErasureMethodManager, e); 570 560 } 571 561 … … 574 564 /// </summary> 575 565 /// <param name="guid">The GUID of the unregistered erasure method.</param> 576 private static void OnMethodUnregistered( Guid guid)566 private static void OnMethodUnregistered(ErasureMethodRegistrationEventArgs e) 577 567 { 578 568 if (MethodUnregistered != null) 579 MethodUnregistered( guid);569 MethodUnregistered(ManagerLibrary.Instance.ErasureMethodManager, e); 580 570 } 581 571 #endregion 582 572 } 573 574 public class ErasureMethodRegistrationEventArgs : EventArgs 575 { 576 /// <summary> 577 /// Constructor. 578 /// </summary> 579 /// <param name="value">The GUID of the newly registered/unregistered 580 /// erasure method.</param> 581 public ErasureMethodRegistrationEventArgs(Guid value) 582 { 583 Guid = value; 584 } 585 586 /// <summary> 587 /// The GUID of the newly registsered/unregistered erasure method. 588 /// </summary> 589 public Guid Guid { get; private set; } 590 } 583 591 } -
branches/eraser6/Manager/RemoteExecutor.cs
r943 r944 65 65 /// List of supported functions 66 66 /// </summary> 67 public enum RemoteExecutorFunction : uint67 public enum RemoteExecutorFunction 68 68 { 69 69 QueueTask, … … 456 456 //Call all the event handlers who registered to be notified of tasks 457 457 //being added. 458 Owner.OnTaskAdded( item);458 Owner.OnTaskAdded(new TaskEventArgs(item)); 459 459 } 460 460 … … 486 486 487 487 //Call all event handlers registered to be notified of task deletions. 488 Owner.OnTaskDeleted( item);488 Owner.OnTaskDeleted(new TaskEventArgs(item)); 489 489 return true; 490 490 } -
branches/eraser6/Manager/Task.cs
r942 r944 160 160 #region Events 161 161 /// <summary> 162 /// The prototype for events handling just a task object as the event argument.163 /// </summary>164 /// <param name="e">The task object.</param>165 public delegate void TaskEventFunction(TaskEventArgs e);166 167 /// <summary>168 /// The prototype for events handling the progress changed event.169 /// </summary>170 /// <param name="e">The new progress value.</param>171 public delegate void ProgressEventFunction(TaskProgressEventArgs e);172 173 /// <summary>174 162 /// The start of the execution of a task. 175 163 /// </summary> 176 public event TaskEventFunction TaskStarted;164 public EventHandler<TaskEventArgs> TaskStarted { get; set; } 177 165 178 166 /// <summary> 179 167 /// The event object holding all event handlers. 180 168 /// </summary> 181 public event ProgressEventFunction ProgressChanged;169 public EventHandler<TaskProgressEventArgs> ProgressChanged { get; set; } 182 170 183 171 /// <summary> 184 172 /// The completion of the execution of a task. 185 173 /// </summary> 186 public event TaskEventFunction TaskFinished;174 public EventHandler<TaskEventArgs> TaskFinished { get; set; } 187 175 188 176 /// <summary> … … 193 181 { 194 182 if (TaskStarted != null) 195 TaskStarted( e);183 TaskStarted(this, e); 196 184 Executing = true; 197 185 } … … 204 192 { 205 193 if (ProgressChanged != null) 206 ProgressChanged( e);194 ProgressChanged(this, e); 207 195 } 208 196 … … 214 202 { 215 203 if (TaskFinished != null) 216 TaskFinished( e);204 TaskFinished(this, e); 217 205 Executing = false; 218 206 } … … 905 893 /// Constructor. 906 894 /// </summary> 907 /// <param name="task">The task being r un.</param>895 /// <param name="task">The task being referred to by this event.</param> 908 896 public TaskEventArgs(Task task) 909 897 { 910 this.task = task;898 Task = task; 911 899 } 912 900 … … 914 902 /// The executing task. 915 903 /// </summary> 916 public Task Task 917 { 918 get { return task; } 919 } 920 921 private Task task; 904 public Task Task { get; private set; } 922 905 } 923 906
Note: See TracChangeset
for help on using the changeset viewer.
