Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/26/12 09:51:13 (12 years ago)
Author:
jkarder
Message:

#1331: merged r8086:8330 from trunk

Location:
branches/ScatterSearch (trunk integration)
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/ScatterSearch (trunk integration)

  • branches/ScatterSearch (trunk integration)/HeuristicLab.Clients.Hive.Views/3.3/HiveTasks/OptimizerHiveTaskView.cs

    r7582 r8331  
    3131  [Content(typeof(OptimizerHiveTask), true)]
    3232  public partial class OptimizerHiveTaskView : HiveTaskView {
     33    private Progress progress;
    3334    private ProgressView progressView;
    3435
     
    4445    public OptimizerHiveTaskView() {
    4546      InitializeComponent();
     47      progress = new Progress() {
     48        CanBeCanceled = false,
     49        ProgressState = ProgressState.Finished
     50      };
    4651    }
    4752
     
    5762      base.RegisterContentEvents();
    5863      Content.IsControllableChanged += new EventHandler(Content_IsControllableChanged);
     64      progressView = new ProgressView(this, progress);
    5965    }
    6066
    6167    protected override void DeregisterContentEvents() {
    6268      Content.IsControllableChanged -= new EventHandler(Content_IsControllableChanged);
     69      if (progressView != null) {
     70        progressView.Content = null;
     71        progressView.Dispose();
     72        progressView = null;
     73      }
    6374      base.DeregisterContentEvents();
    6475    }
     
    7485      var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeTaskAsync);
    7586      task.ContinueWith((t) => {
    76         FinishProgressView();
     87        progress.Finish();
    7788        ErrorHandling.ShowErrorDialog(this, "An error occured while resuming the task.", t.Exception);
    7889      }, TaskContinuationOptions.OnlyOnFaulted);
     
    8293      var task = System.Threading.Tasks.Task.Factory.StartNew(PauseTaskAsync);
    8394      task.ContinueWith((t) => {
    84         FinishProgressView();
     95        progress.Finish();
    8596        ErrorHandling.ShowErrorDialog(this, "An error occured while pausing the task.", t.Exception);
    8697      }, TaskContinuationOptions.OnlyOnFaulted);
     
    90101      var task = System.Threading.Tasks.Task.Factory.StartNew(StopTaskAsync);
    91102      task.ContinueWith((t) => {
    92         FinishProgressView();
     103        progress.Finish();
    93104        ErrorHandling.ShowErrorDialog(this, "An error occured while stopping the task.", t.Exception);
    94105      }, TaskContinuationOptions.OnlyOnFaulted);
     
    97108
    98109    private void PauseTaskAsync() {
    99       IProgress prog = new Progress();
    100       prog.Status = "Pausing task. Please be patient for the command to take effect.";
    101       SetProgressView(prog);
     110      progress.Status = "Pausing task. Please be patient for the command to take effect.";
     111      progress.ProgressState = ProgressState.Started;
    102112      Content.Pause();
    103       FinishProgressView();
     113      progress.Finish();
    104114    }
    105115
    106116    private void StopTaskAsync() {
    107       IProgress prog = new Progress();
    108       prog.Status = "Stopping task. Please be patient for the command to take effect.";
    109       SetProgressView(prog);
     117      progress.Status = "Stopping task. Please be patient for the command to take effect.";
     118      progress.ProgressState = ProgressState.Started;
    110119      Content.Stop();
    111       FinishProgressView();
     120      progress.Finish();
    112121    }
    113122
    114123    private void ResumeTaskAsync() {
    115       IProgress prog = new Progress();
    116       prog.Status = "Resuming task. Please be patient for the command to take effect.";
    117       SetProgressView(prog);
     124      progress.Status = "Resuming task. Please be patient for the command to take effect.";
     125      progress.ProgressState = ProgressState.Started;
    118126      Content.Restart();
    119       FinishProgressView();
    120     }
    121 
    122     private void SetProgressView(IProgress progress) {
    123       if (InvokeRequired) {
    124         Invoke(new Action<IProgress>(SetProgressView), progress);
    125       } else {
    126         if (progressView == null) {
    127           progressView = new ProgressView(this, progress);
    128         } else {
    129           progressView.Progress = progress;
    130         }
    131       }
    132     }
    133 
    134     private void FinishProgressView() {
    135       if (InvokeRequired) {
    136         Invoke(new Action(FinishProgressView));
    137       } else {
    138         if (progressView != null) {
    139           progressView.Finish();
    140           progressView = null;
    141           SetEnabledStateOfControls();
    142         }
    143       }
     127      progress.Finish();
    144128    }
    145129
Note: See TracChangeset for help on using the changeset viewer.