Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/29/12 23:12:32 (12 years ago)
Author:
abeham
Message:

#1762: Some changes to progress handling, see the ticket for more details

Location:
trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs

    r8160 r8165  
    4242    private ISet<TreeNode> filteredTreeNodes;
    4343    private ISet<TreeNode> nodeStore;
    44     private IProgress currentProgress;
     44    private Progress progress;
     45    private ProgressView progressView;
    4546
    4647    private ISet<Resource> selectedResources;
     
    4849      get { return selectedResources; }
    4950      set { selectedResources = value; }
    50     }
    51 
    52     private ProgressView progressView;
    53     public ProgressView ProgressView {
    54       get { return progressView; }
    55       set { progressView = value; }
    5651    }
    5752
     
    6964      imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.MonitorLarge);
    7065      imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.NetworkCenterLarge);
     66      progress = new Progress() {
     67        CanBeCanceled = false,
     68        ProgressState = ProgressState.Finished
     69      };
     70    }
     71
     72    protected override void DeregisterContentEvents() {
     73      if (progressView != null) {
     74        progressView.Content = null;
     75        progressView.Dispose();
     76        progressView = null;
     77      }
     78      base.DeregisterContentEvents();
     79    }
     80
     81    protected override void RegisterContentEvents() {
     82      base.RegisterContentEvents();
     83      progressView = new ProgressView(this, progress);
    7184    }
    7285
     
    7588        Invoke(new Action(StartProgressView));
    7689      } else {
    77         currentProgress = new Progress();
    78         currentProgress.Status = "Downloading resources. Please be patient.";
    79         if (progressView == null) {
    80           progressView = new ProgressView(this);
    81         }
    82         progressView.Progress = currentProgress;
     90        progress.Status = "Downloading resources. Please be patient.";
     91        progress.ProgressState = ProgressState.Started;
    8392      }
    8493    }
     
    8897        Invoke(new Action(FinishProgressView));
    8998      } else {
    90         currentProgress.Finish();
     99        progress.Finish();
    91100      }
    92101    }
  • trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelectorDialog.Designer.cs

    r7967 r8165  
    7373      this.hiveResourceSelector.Location = new System.Drawing.Point(12, 12);
    7474      this.hiveResourceSelector.Name = "hiveResourceSelector";
    75       this.hiveResourceSelector.ProgressView = null;
    7675      this.hiveResourceSelector.ReadOnly = false;
    7776      this.hiveResourceSelector.Size = new System.Drawing.Size(549, 591);
  • trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r8160 r8165  
    4242  [Content(typeof(RefreshableJob), true)]
    4343  public partial class RefreshableHiveJobView : HeuristicLab.Core.Views.ItemView {
     44    private Progress progress;
    4445    private ProgressView progressView;
    4546    private HiveResourceSelectorDialog hiveResourceSelectorDialog;
     
    5556    public RefreshableHiveJobView() {
    5657      InitializeComponent();
    57       progressView = new ProgressView(this);
     58      progress = new Progress() {
     59        CanBeCanceled = true,
     60        ProgressState = ProgressState.Finished
     61      };
    5862    }
    5963
     
    7377      Content.Loaded += new EventHandler(Content_Loaded);
    7478      Content.TaskReceived += new EventHandler(Content_TaskReceived);
     79      progressView = new ProgressView(this, progress);
    7580    }
    7681
     
    8893      Content.Loaded -= new EventHandler(Content_Loaded);
    8994      Content.TaskReceived -= new EventHandler(Content_TaskReceived);
     95      if (progressView != null) {
     96        progressView.Content = null;
     97        progressView.Dispose();
     98        progressView = null;
     99      }
    90100      base.DeregisterContentEvents();
    91101    }
     
    356366        var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobAsync, Content);
    357367        task.ContinueWith((t) => {
    358           FinishProgressView();
     368          progress.Finish();
    359369          MessageBox.Show("An error occured resuming the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
    360370          Content.Log.LogException(t.Exception);
     
    368378      var task = System.Threading.Tasks.Task.Factory.StartNew(PauseJobAsync, Content);
    369379      task.ContinueWith((t) => {
    370         FinishProgressView();
     380        progress.Finish();
    371381        MessageBox.Show("An error occured pausing the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
    372382        Content.Log.LogException(t.Exception);
     
    377387      var task = System.Threading.Tasks.Task.Factory.StartNew(StopJobAsync, Content);
    378388      task.ContinueWith((t) => {
    379         FinishProgressView();
     389        progress.Finish();
    380390        MessageBox.Show("An error occured stopping the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
    381391        Content.Log.LogException(t.Exception);
     
    385395
    386396    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;
    390399      HiveClient.PauseJob((RefreshableJob)job);
    391       FinishProgressView();
    392400    }
    393401
    394402    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;
    398405      HiveClient.StopJob((RefreshableJob)job);
    399       FinishProgressView();
    400406    }
    401407
    402408    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;
    406411      HiveClient.ResumeJob((RefreshableJob)job);
    407       FinishProgressView();
    408412    }
    409413
     
    466470      } else {
    467471        if (Content != null && Content.Progress != null && Content.IsProgressing) {
    468           SetProgressView();
     472          progressView.Content = Content.Progress;
    469473        } 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        }
    497476      }
    498477    }
Note: See TracChangeset for help on using the changeset viewer.