Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/17/10 10:26:55 (14 years ago)
Author:
cneumuel
Message:
  • Refactored HL.Hive.Experiment. JobItems are not called HiveJobs and OptimizerJobs do not contain a hierarchy anymore.
  • Dynamic generation of jobs on a slave are not reflected on the client user interface.
  • Optimizer-Trees are now strictly synchronized with the HiveJob-Trees (also the ComputeInParallel property is taken into account when the Child HiveJobs are created)
  • Improved the way a class can report progress and lock the UI (IProgressReporter, IProgress, Progress, ProgressView)
  • Changes were made to the config-files, so that server and clients work with blade12.hpc.fh-hagenberg.at
  • Lots of small changes and bugfixes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-Hive/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment.Views/3.3/ProgressView.cs

    r4368 r4423  
    1212namespace HeuristicLab.Hive.Experiment.Views {
    1313  public partial class ProgressView : HeuristicLab.MainForm.WindowsForms.View {
    14     private ContentView parentView = null;
    15     private bool simulateProgress = false;
     14    private ContentView parentView;
     15    private IProgress progress;
     16    public IProgress Progress {
     17      get {
     18        return this.progress;
     19      }
     20      set {
     21        if (this.progress != value) {
     22          if (this.progress != null) {
     23            DeregisterProgressEvents();
     24          }
     25          this.progress = value;
     26          RegisterProgressEvents();
     27          OnProgressChanged();
     28        }
     29      }
     30    }
    1631
    1732    public bool CancelEnabled {
     
    2843    }
    2944
    30     private string status;
    31     public string Status {
    32       get { return status; }
    33       set {
    34         if (InvokeRequired) {
    35           Invoke(new Action<string>((s) => { Status = s;}), value);
    36         } else {
    37           status = value;
    38           statusLabel.Text = status;
    39         }
    40        
    41       }
    42     }
    43 
    44     public ProgressView(ContentView parentView)
    45       : this(parentView, "", false, true) {
    46     }
    47 
    48     public ProgressView(ContentView parentView, string initialStatus)
    49       : this(parentView, initialStatus, false, true) {
    50     }
    51 
    52     public ProgressView(ContentView parentView, string initialStatus, bool simulateProgress)
    53       : this(parentView, initialStatus, simulateProgress, true) {
    54     }
    55 
    5645    /// <param name="parentView">This is the View which will be locked if lockParentView is true</param>
    57     /// <param name="initialStatus">Status message</param>
    58     /// <param name="simulateProgress">If true, the progress will be simulated by a timer which addes some progress every second</param>
    59     /// <param name="lockParentView">if true parentView will be locked</param>
    60     public ProgressView(ContentView parentView, string initialStatus, bool simulateProgress, bool lockParentView) {
     46    public ProgressView(ContentView parentView, IProgress progress) {
    6147      InitializeComponent();
    6248      this.parentView = parentView;
     49      this.Progress = progress;
     50
    6351      this.CancelEnabled = false;
    64       this.Status = initialStatus;
    65       this.simulateProgress = simulateProgress;
    6652
    67       if (simulateProgress) {
    68         Timer progressSimulator = new Timer();
    69         progressSimulator.Interval = 2000;
    70         progressSimulator.Tick += new EventHandler(progressSimulator_Tick);
    71         progressSimulator.Start();
    72       }
     53      progressBar.Style = ProgressBarStyle.Marquee;
    7354
    7455      this.Left = (parentView.ClientRectangle.Width / 2) - (this.Width / 2);
     
    7657      this.Anchor = AnchorStyles.Left | AnchorStyles.Top;
    7758
    78       if (lockParentView)
    79         LockBackground();
     59      LockBackground();
    8060
    8161      parentView.Controls.Add(this);
     
    8363    }
    8464
    85     private void progressSimulator_Tick(object sender, EventArgs e) {
    86       progressBar.Value = Math.Min(progressBar.Value + (progressBar.Maximum - progressBar.Value) / 10 + 1, progressBar.Maximum - 1);
     65    private void RegisterProgressEvents() {
     66      progress.Finished += new EventHandler(progress_Finished);
     67      progress.StatusChanged += new EventHandler(progress_StatusChanged);
     68      progress.ProgressValueChanged += new EventHandler(progress_ProgressChanged);
     69    }
     70
     71    private void DeregisterProgressEvents() {
     72      progress.Finished -= new EventHandler(progress_Finished);
     73      progress.StatusChanged -= new EventHandler(progress_StatusChanged);
     74      progress.ProgressValueChanged -= new EventHandler(progress_ProgressChanged);
     75    }
     76
     77    void progress_Finished(object sender, EventArgs e) {
     78      Finish();
     79    }
     80
     81    void progress_ProgressChanged(object sender, EventArgs e) {
     82      if (InvokeRequired) {
     83        Invoke(new EventHandler(progress_ProgressChanged), sender, e);
     84      } else {
     85        progressBar.Style = ProgressBarStyle.Blocks;
     86        this.progressBar.Value = Math.Min(this.progressBar.Maximum, (int)(progress.ProgressValue * progressBar.Maximum));
     87      }
     88    }
     89
     90    void progress_StatusChanged(object sender, EventArgs e) {
     91      if (InvokeRequired) {
     92        Invoke(new EventHandler(progress_StatusChanged), sender, e);
     93      } else {
     94        statusLabel.Text = progress.Status;
     95      }
    8796    }
    8897
    8998    private void LockBackground() {
    90       this.parentView.Locked = true;
    91       foreach (Control c in this.parentView.Controls) {
    92         c.Enabled = false;
    93       }
    94       this.Enabled = true;
    95       this.ReadOnly = false;
    96     }
    97 
    98     public void SetProgress(double progress) {
    9999      if (InvokeRequired) {
    100         Invoke(new Action<double>(SetProgress), progress);
     100        Invoke(new Action(LockBackground));
    101101      } else {
    102         this.progressBar.Value = Math.Max(this.progressBar.Value, (int)(progress * progressBar.Maximum));
     102        this.parentView.Locked = true;
     103        foreach (Control c in this.parentView.Controls) {
     104          c.Enabled = false;
     105        }
     106        this.Enabled = true;
     107        this.ReadOnly = false;
    103108      }
    104109    }
     
    122127    }
    123128
     129    private void OnProgressChanged() {
     130      progress_StatusChanged(this, EventArgs.Empty);
     131      progress_ProgressChanged(this, EventArgs.Empty);
     132    }
     133
    124134    public event EventHandler Canceled;
    125135    protected virtual void OnCanceled() {
Note: See TracChangeset for help on using the changeset viewer.