Changeset 8165 for trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs
- Timestamp:
- 06/29/12 23:12:32 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs
r8160 r8165 42 42 [Content(typeof(RefreshableJob), true)] 43 43 public partial class RefreshableHiveJobView : HeuristicLab.Core.Views.ItemView { 44 private Progress progress; 44 45 private ProgressView progressView; 45 46 private HiveResourceSelectorDialog hiveResourceSelectorDialog; … … 55 56 public RefreshableHiveJobView() { 56 57 InitializeComponent(); 57 progressView = new ProgressView(this); 58 progress = new Progress() { 59 CanBeCanceled = true, 60 ProgressState = ProgressState.Finished 61 }; 58 62 } 59 63 … … 73 77 Content.Loaded += new EventHandler(Content_Loaded); 74 78 Content.TaskReceived += new EventHandler(Content_TaskReceived); 79 progressView = new ProgressView(this, progress); 75 80 } 76 81 … … 88 93 Content.Loaded -= new EventHandler(Content_Loaded); 89 94 Content.TaskReceived -= new EventHandler(Content_TaskReceived); 95 if (progressView != null) { 96 progressView.Content = null; 97 progressView.Dispose(); 98 progressView = null; 99 } 90 100 base.DeregisterContentEvents(); 91 101 } … … 356 366 var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobAsync, Content); 357 367 task.ContinueWith((t) => { 358 FinishProgressView();368 progress.Finish(); 359 369 MessageBox.Show("An error occured resuming the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error); 360 370 Content.Log.LogException(t.Exception); … … 368 378 var task = System.Threading.Tasks.Task.Factory.StartNew(PauseJobAsync, Content); 369 379 task.ContinueWith((t) => { 370 FinishProgressView();380 progress.Finish(); 371 381 MessageBox.Show("An error occured pausing the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error); 372 382 Content.Log.LogException(t.Exception); … … 377 387 var task = System.Threading.Tasks.Task.Factory.StartNew(StopJobAsync, Content); 378 388 task.ContinueWith((t) => { 379 FinishProgressView();389 progress.Finish(); 380 390 MessageBox.Show("An error occured stopping the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error); 381 391 Content.Log.LogException(t.Exception); … … 385 395 386 396 private void PauseJobAsync(object job) { 387 IProgress prog = new Progress(); 388 prog.Status = "Pausing job..."; 389 SetProgressView(prog); 397 progress.Status = "Pausing job..."; 398 progress.ProgressState = ProgressState.Started; 390 399 HiveClient.PauseJob((RefreshableJob)job); 391 FinishProgressView();392 400 } 393 401 394 402 private void StopJobAsync(object job) { 395 IProgress prog = new Progress(); 396 prog.Status = "Stopping job..."; 397 SetProgressView(prog); 403 progress.Status = "Stopping job..."; 404 progress.ProgressState = ProgressState.Started; 398 405 HiveClient.StopJob((RefreshableJob)job); 399 FinishProgressView();400 406 } 401 407 402 408 private void ResumeJobAsync(object job) { 403 IProgress prog = new Progress(); 404 prog.Status = "Resuming job..."; 405 SetProgressView(prog); 409 progress.Status = "Resuming job..."; 410 progress.ProgressState = ProgressState.Started; 406 411 HiveClient.ResumeJob((RefreshableJob)job); 407 FinishProgressView();408 412 } 409 413 … … 466 470 } else { 467 471 if (Content != null && Content.Progress != null && Content.IsProgressing) { 468 SetProgressView();472 progressView.Content = Content.Progress; 469 473 } else { 470 progressView.Progress = null; 471 } 472 } 473 } 474 475 private void SetProgressView() { 476 if (InvokeRequired) { 477 Invoke(new Action(SetProgressView)); 478 } else { 479 progressView.Progress = Content.Progress; 480 } 481 } 482 483 private void SetProgressView(IProgress progress) { 484 if (InvokeRequired) { 485 Invoke(new Action<IProgress>(SetProgressView), progress); 486 } else { 487 progressView.Progress = progress; 488 } 489 } 490 491 private void FinishProgressView() { 492 if (InvokeRequired) { 493 Invoke(new Action(FinishProgressView)); 494 } else { 495 if (Content != null && Content.Progress != null) 496 Content.Progress.Finish(); 474 progressView.Content = progress; 475 } 497 476 } 498 477 }
Note: See TracChangeset
for help on using the changeset viewer.