Changeset 9933


Ignore:
Timestamp:
09/03/13 15:55:36 (8 years ago)
Author:
ascheibe
Message:

#1042 merged r9849, r9851, r9865, r9867, r9868, r9893, r9894, r9895, r9896, r9900, r9901, r9905, r9907 into stable branch

Location:
stable
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Clients.Access.Views/3.3/ClientViews/ClientView.cs

    r9456 r9933  
    2020#endregion
    2121
    22 using System;
    2322using HeuristicLab.Core.Views;
    2423using HeuristicLab.MainForm;
     
    3433    }
    3534
    36     private ProgressView progressView;
    37     private Progress progress;
    38 
    3935    public ClientView() {
    4036      InitializeComponent();
    41       progress = new Progress() {
    42         CanBeCanceled = false,
    43         ProgressState = ProgressState.Finished
    44       };
    45     }
    46 
    47     protected override void DeregisterContentEvents() {
    48       if (progressView != null) {
    49         progressView.Content = null;
    50         progressView.Dispose();
    51         progressView = null;
    52       }
    53       base.DeregisterContentEvents();
    54     }
    55 
    56     protected override void RegisterContentEvents() {
    57       base.RegisterContentEvents();
    58       progressView = new ProgressView(this, progress);
    5937    }
    6038
     
    9876
    9977    public void StartProgressView() {
    100       if (InvokeRequired) {
    101         Invoke(new Action(StartProgressView));
    102       } else {
    103         progress.Status = "Downloading client information. Please be patient.";
    104         progress.ProgressState = ProgressState.Started;
    105       }
     78      var message = "Downloading client information. Please be patient.";
     79      MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message);
    10680    }
    10781
    10882    public void FinishProgressView() {
    109       if (InvokeRequired) {
    110         Invoke(new Action(FinishProgressView));
    111       } else {
    112         progress.Finish();
    113       }
     83      MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
    11484    }
    11585  }
  • stable/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs

    r9456 r9933  
    4242    private ISet<TreeNode> filteredTreeNodes;
    4343    private ISet<TreeNode> nodeStore;
    44     private Progress progress;
    45     private ProgressView progressView;
    46 
     44   
    4745    private ISet<Resource> selectedResources;
    4846    public ISet<Resource> SelectedResources {
     
    6462      imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.MonitorLarge);
    6563      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);
    84     }
    85 
     64    }
     65 
    8666    public void StartProgressView() {
    8767      if (InvokeRequired) {
    8868        Invoke(new Action(StartProgressView));
    8969      } else {
    90         progress.Status = "Downloading resources. Please be patient.";
    91         progress.ProgressState = ProgressState.Started;
     70        var message = "Downloading resources. Please be patient.";
     71        MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message);
    9272      }
    9373    }
     
    9777        Invoke(new Action(FinishProgressView));
    9878      } else {
    99         progress.Finish();
     79        MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
    10080      }
    10181    }
  • stable/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobListView.cs

    r9559 r9933  
    3434  [Content(typeof(ItemCollection<RefreshableJob>), false)]
    3535  public partial class RefreshableHiveJobListView : HeuristicLab.Core.Views.ItemCollectionView<RefreshableJob> {
    36     private Progress progress;
    37     private ProgressView progressView;
    38 
    3936    public RefreshableHiveJobListView() {
    4037      InitializeComponent();
     
    4946
    5047      this.itemsListView.ListViewItemSorter = new ListViewItemDateComparer(0, SortOrder.Ascending);
    51 
    52       progress = new Progress() {
    53         CanBeCanceled = false,
    54         ProgressState = ProgressState.Finished
    55       };
    56       progressView = new ProgressView(this, progress);
    5748    }
    5849
     
    118109
    119110        task.ContinueWith((t) => {
    120           progress.Finish();
     111          MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
    121112          ErrorHandling.ShowErrorDialog("An error occured while deleting the job. ", t.Exception);
    122113        }, TaskContinuationOptions.OnlyOnFaulted);
     
    129120
    130121    private void DeleteHiveJobsAsync(object items) {
    131       progress.Status = "Deleting job...";
    132       progress.ProgressState = ProgressState.Started;
    133       progress.ProgressValue = 0.0;
     122      MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Deleting job...");
    134123      foreach (RefreshableJob item in (List<RefreshableJob>)items) {
    135124        Content.Remove(item);
    136125      }
    137       progress.Finish();
     126      MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
    138127    }
    139128
     
    227216      if (disposing) {
    228217        if (components != null) components.Dispose();
    229         progressView.Content = null;
    230         progressView.Dispose();
    231218      }
    232219      base.Dispose(disposing);
  • stable/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r9722 r9933  
    4242  [Content(typeof(RefreshableJob), true)]
    4343  public partial class RefreshableHiveJobView : HeuristicLab.Core.Views.ItemView {
    44     private Progress progress;
    45     private ProgressView progressView;
    4644    private HiveResourceSelectorDialog hiveResourceSelectorDialog;
    4745    private bool SuppressEvents { get; set; }
     
    5856    public RefreshableHiveJobView() {
    5957      InitializeComponent();
    60       progress = new Progress() {
    61         CanBeCanceled = false,
    62         ProgressState = ProgressState.Finished
    63       };
    6458    }
    6559
     
    7266      Content.ExceptionOccured += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccured);
    7367      Content.StateLogListChanged += new EventHandler(Content_StateLogListChanged);
    74       Content.IsProgressingChanged += new EventHandler(Content_IsProgressingChanged);
    7568      Content.HiveTasksChanged += new EventHandler(Content_HiveTasksChanged);
    7669      Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged);
     
    7871      Content.Loaded += new EventHandler(Content_Loaded);
    7972      Content.TaskReceived += new EventHandler(Content_TaskReceived);
    80       progressView = new ProgressView(this, progress);
     73      MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, Content.Progress);
    8174    }
    8275
     
    8881      Content.ExceptionOccured -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccured);
    8982      Content.StateLogListChanged -= new EventHandler(Content_StateLogListChanged);
    90       Content.IsProgressingChanged -= new EventHandler(Content_IsProgressingChanged);
    9183      Content.HiveTasksChanged -= new EventHandler(Content_HiveTasksChanged);
    9284      Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged);
     
    9486      Content.Loaded -= new EventHandler(Content_Loaded);
    9587      Content.TaskReceived -= new EventHandler(Content_TaskReceived);
    96       if (progressView != null) {
    97         progressView.Content = null;
    98         progressView.Dispose();
    99         progressView = null;
    100       }
     88      MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this, false);
    10189      DeregisterHiveExperimentEvents();
    10290      DeregisterHiveTasksEvents();
     
    159147      Content_HiveExperimentChanged(this, EventArgs.Empty);
    160148      Content_HiveTasksChanged(this, EventArgs.Empty);
    161       Content_IsProgressingChanged(this, EventArgs.Empty);
    162149      Content_StateLogListChanged(this, EventArgs.Empty);
    163150      HiveExperiment_PropertyChanged(this, new PropertyChangedEventArgs("Id"));
     
    260247        SetEnabledStateOfControls();
    261248    }
    262     private void Content_Prepared(object sender, EventArgs e) {
    263       if (InvokeRequired)
    264         Invoke(new EventHandler(Content_Prepared), sender, e);
    265       else {
    266         nameTextBox.Enabled = true;
    267         Locked = false;
    268         SetEnabledStateOfControls();
    269       }
    270     }
    271     private void Content_Started(object sender, EventArgs e) {
    272       if (InvokeRequired)
    273         Invoke(new EventHandler(Content_Started), sender, e);
    274       else {
    275         nameTextBox.Enabled = false;
    276         SetEnabledStateOfControls();
    277       }
    278     }
    279     private void Content_Paused(object sender, EventArgs e) {
    280       if (InvokeRequired)
    281         Invoke(new EventHandler(Content_Paused), sender, e);
    282       else {
    283         nameTextBox.Enabled = true;
    284         SetEnabledStateOfControls();
    285       }
    286     }
    287     private void Content_Stopped(object sender, EventArgs e) {
    288       if (InvokeRequired)
    289         Invoke(new EventHandler(Content_Stopped), sender, e);
    290       else {
    291         nameTextBox.Enabled = true;
    292         Locked = false;
    293         SetEnabledStateOfControls();
    294       }
    295     }
     249
    296250    private void Content_ExecutionTimeChanged(object sender, EventArgs e) {
    297251      if (InvokeRequired)
     
    336290      if (Content != null && Content.Job != null) {
    337291        RegisterHiveExperimentEvents();
    338         Content_IsProgressingChanged(sender, e);
    339292      }
    340293    }
     
    410363        var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobAsync, Content);
    411364        task.ContinueWith((t) => {
    412           progress.Finish();
     365          Content.Progress.Finish();
    413366          MessageBox.Show("An error occured resuming the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
    414367          Content.Log.LogException(t.Exception);
     
    422375      var task = System.Threading.Tasks.Task.Factory.StartNew(PauseJobAsync, Content);
    423376      task.ContinueWith((t) => {
    424         progress.Finish();
     377        Content.Progress.Finish();
    425378        MessageBox.Show("An error occured pausing the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
    426379        Content.Log.LogException(t.Exception);
     
    431384      var task = System.Threading.Tasks.Task.Factory.StartNew(StopJobAsync, Content);
    432385      task.ContinueWith((t) => {
    433         progress.Finish();
     386        Content.Progress.Finish();
    434387        MessageBox.Show("An error occured stopping the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
    435388        Content.Log.LogException(t.Exception);
     
    439392
    440393    private void PauseJobAsync(object job) {
    441       progress.Status = "Pausing job...";
    442       progress.ProgressState = ProgressState.Started;
     394      Content.Progress.Start("Pausing job...");
    443395      HiveClient.PauseJob((RefreshableJob)job);
    444       progress.Finish();
     396      Content.Progress.Finish();
    445397    }
    446398
    447399    private void StopJobAsync(object job) {
    448       progress.Status = "Stopping job...";
    449       progress.ProgressState = ProgressState.Started;
     400      Content.Progress.Start("Stopping job...");
    450401      HiveClient.StopJob((RefreshableJob)job);
    451       progress.Finish();
     402      Content.Progress.Finish();
    452403    }
    453404
    454405    private void ResumeJobAsync(object job) {
    455       progress.Status = "Resuming job...";
    456       progress.ProgressState = ProgressState.Started;
     406      Content.Progress.Start("Resuming job...");
    457407      HiveClient.ResumeJob((RefreshableJob)job);
    458       progress.Finish();
     408      Content.Progress.Finish();
    459409    }
    460410
     
    507457        stopButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing;
    508458        resetButton.Enabled = false;
    509       }
    510     }
    511     #endregion
    512 
    513     #region Progress reporting
    514     private void Content_IsProgressingChanged(object sender, EventArgs e) {
    515       if (this.InvokeRequired) {
    516         Invoke(new EventHandler(Content_IsProgressingChanged), sender, e);
    517       } else {
    518         if (Content != null && Content.Progress != null && Content.IsProgressing) {
    519           progressView.Content = Content.Progress;
    520         } else if (Content != null) {
    521           progressView.Content = progress;
    522         }
    523459      }
    524460    }
  • stable/HeuristicLab.Clients.Hive.Views/3.3/HiveTasks/OptimizerHiveTaskView.cs

    r9456 r9933  
    3131  [Content(typeof(OptimizerHiveTask), true)]
    3232  public partial class OptimizerHiveTaskView : HiveTaskView {
    33     private Progress progress;
    34     private ProgressView progressView;
    35 
    3633    public new OptimizerHiveTask Content {
    3734      get { return (OptimizerHiveTask)base.Content; }
     
    4542    public OptimizerHiveTaskView() {
    4643      InitializeComponent();
    47       progress = new Progress() {
    48         CanBeCanceled = false,
    49         ProgressState = ProgressState.Finished
    50       };
    5144    }
    5245
     
    6053      }
    6154    }
     55
    6256    #region Content Events
    6357    protected override void RegisterContentEvents() {
    6458      base.RegisterContentEvents();
    6559      Content.IsControllableChanged += new EventHandler(Content_IsControllableChanged);
    66       progressView = new ProgressView(this, progress);
     60      MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, Content.Progress);
    6761    }
    6862
    6963    protected override void DeregisterContentEvents() {
    7064      Content.IsControllableChanged -= new EventHandler(Content_IsControllableChanged);
    71       if (progressView != null) {
    72         progressView.Content = null;
    73         progressView.Dispose();
    74         progressView = null;
    75       }
     65      MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this, false);
    7666      base.DeregisterContentEvents();
    7767    }
     
    8070      SetEnabledStateOfControls();
    8171    }
    82 
    8372    #endregion
    8473
     
    8776      var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeTaskAsync);
    8877      task.ContinueWith((t) => {
    89         progress.Finish();
     78        Content.Progress.Finish();
    9079        ErrorHandling.ShowErrorDialog(this, "An error occured while resuming the task.", t.Exception);
    9180      }, TaskContinuationOptions.OnlyOnFaulted);
     
    9584      var task = System.Threading.Tasks.Task.Factory.StartNew(PauseTaskAsync);
    9685      task.ContinueWith((t) => {
    97         progress.Finish();
     86        Content.Progress.Finish();
    9887        ErrorHandling.ShowErrorDialog(this, "An error occured while pausing the task.", t.Exception);
    9988      }, TaskContinuationOptions.OnlyOnFaulted);
     
    10392      var task = System.Threading.Tasks.Task.Factory.StartNew(StopTaskAsync);
    10493      task.ContinueWith((t) => {
    105         progress.Finish();
     94        Content.Progress.Finish();
    10695        ErrorHandling.ShowErrorDialog(this, "An error occured while stopping the task.", t.Exception);
    10796      }, TaskContinuationOptions.OnlyOnFaulted);
     
    11099
    111100    private void PauseTaskAsync() {
    112       progress.Status = "Pausing task. Please be patient for the command to take effect.";
    113       progress.ProgressState = ProgressState.Started;
     101      Content.Progress.Start("Pausing task. Please be patient for the command to take effect.");
    114102      Content.Pause();
    115       progress.Finish();
     103      Content.Progress.Finish();
    116104    }
    117105
    118106    private void StopTaskAsync() {
    119       progress.Status = "Stopping task. Please be patient for the command to take effect.";
    120       progress.ProgressState = ProgressState.Started;
     107      Content.Progress.Start("Stopping task. Please be patient for the command to take effect.");
    121108      Content.Stop();
    122       progress.Finish();
     109      Content.Progress.Finish();
    123110    }
    124111
    125112    private void ResumeTaskAsync() {
    126       progress.Status = "Resuming task. Please be patient for the command to take effect.";
    127       progress.ProgressState = ProgressState.Started;
     113      Content.Progress.Start("Resuming task. Please be patient for the command to take effect.");
    128114      Content.Restart();
    129       progress.Finish();
     115      Content.Progress.Finish();
    130116    }
    131117
  • stable/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r9456 r9933  
    265265      try {
    266266        refreshableJob.IsProgressing = true;
    267         refreshableJob.Progress = new Progress("Connecting to server...");
     267        refreshableJob.Progress.Start("Connecting to server...");
    268268        IEnumerable<string> resourceNames = ToResourceNameList(refreshableJob.Job.ResourceNames);
    269269        var resourceIds = new List<Guid>();
     
    424424      var hiveExperiment = refreshableJob.Job;
    425425      refreshableJob.IsProgressing = true;
    426       refreshableJob.Progress = new Progress();
    427426      TaskDownloader downloader = null;
    428427
     
    431430        IEnumerable<LightweightTask> allTasks;
    432431
    433         refreshableJob.Progress.Status = "Connecting to Server...";
    434432        // fetch all task objects to create the full tree of tree of HiveTask objects
    435         refreshableJob.Progress.Status = "Downloading list of tasks...";
     433        refreshableJob.Progress.Start("Downloading list of tasks...");
    436434        allTasks = HiveServiceLocator.Instance.CallHiveService(s => s.GetLightweightJobTasksWithoutStateLog(hiveExperiment.Id));
    437435        totalJobCount = allTasks.Count();
  • stable/HeuristicLab.Clients.Hive/3.3/HiveTasks/OptimizerHiveTask.cs

    r9456 r9933  
    2626using HeuristicLab.Collections;
    2727using HeuristicLab.Common;
     28using HeuristicLab.MainForm;
    2829using HeuristicLab.Optimization;
    2930using HeuristicLab.PluginInfrastructure;
     
    3132namespace HeuristicLab.Clients.Hive {
    3233  public class OptimizerHiveTask : HiveTask<OptimizerTask> {
     34    public Progress Progress { get; private set; }
     35
    3336    #region Constructors and Cloning
    34     public OptimizerHiveTask() { }
     37    public OptimizerHiveTask() {
     38      Progress = new Progress();
     39    }
    3540    public OptimizerHiveTask(IOptimizer optimizer)
    3641      : this() {
     
    4348    protected OptimizerHiveTask(OptimizerHiveTask original, Cloner cloner)
    4449      : base(original, cloner) {
     50      Progress = new Progress();
    4551    }
    4652    public override IDeepCloneable Clone(Cloner cloner) {
  • stable/HeuristicLab.Clients.Hive/3.3/RefreshableJob.cs

    r9456 r9933  
    178178    #region Constructors and Cloning
    179179    public RefreshableJob() {
     180      this.progress = new Progress();
    180181      this.refreshAutomatically = false;
    181182      this.Job = new Job();
     
    186187    }
    187188    public RefreshableJob(Job hiveJob) {
     189      this.progress = new Progress();
    188190      this.refreshAutomatically = true;
    189191      this.Job = hiveJob;
  • stable/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBExperimentUploadView.cs

    r9456 r9933  
    5454    Algorithm selectedAlgorithm = null;
    5555    Problem selectedProblem = null;
    56     private ProgressView progressView;
    57     private Progress progress;
    5856
    5957    public OKBExperimentUploadView() {
    6058      InitializeComponent();
    61       progress = new Progress() {
    62         CanBeCanceled = false,
    63         ProgressState = ProgressState.Finished
    64       };
    6559    }
    6660
     
    9690      RunCreationClient.Instance.Refreshing += new EventHandler(RunCreationClient_Refreshing);
    9791      RunCreationClient.Instance.Refreshed += new EventHandler(RunCreationClient_Refreshed);
    98       progressView = new ProgressView(this, progress);
    9992    }
    10093
     
    10295      RunCreationClient.Instance.Refreshing -= new EventHandler(RunCreationClient_Refreshing);
    10396      RunCreationClient.Instance.Refreshed -= new EventHandler(RunCreationClient_Refreshed);
    104       if (progressView != null) {
    105         progressView.Content = null;
    106         progressView.Dispose();
    107         progressView = null;
    108       }
     97
    10998      base.DeregisterContentEvents();
    11099    }
     
    198187        Invoke(new EventHandler(RunCreationClient_Refreshing), sender, e);
    199188      } else {
    200         progress.Status = "Refreshing algorithms and problems...";
    201         progress.ProgressState = ProgressState.Started;
     189        var message = "Refreshing algorithms and problems...";
     190        MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message);
    202191      }
    203192    }
     
    207196        Invoke(new EventHandler(RunCreationClient_Refreshed), sender, e);
    208197      } else {
    209         progress.Finish();
     198        MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
    210199        SetEnabledStateOfControls();
    211200      }
     
    215204      var task = System.Threading.Tasks.Task.Factory.StartNew(UploadAsync);
    216205      task.ContinueWith((t) => {
    217         progress.Finish();
     206        MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
    218207        PluginInfrastructure.ErrorHandling.ShowErrorDialog("An exception occured while uploading the runs to the OKB.", t.Exception);
    219208      }, TaskContinuationOptions.OnlyOnFaulted);
     
    221210
    222211    private void UploadAsync() {
    223       progress.Status = "Uploading runs to OKB...";
    224       progress.ProgressValue = 0;
    225       progress.ProgressState = ProgressState.Started;
     212      var message = "Uploading runs to OKB...";
     213      IProgress progress = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message);
    226214      double count = dataGridView.Rows.Count;
    227215      int i = 0;
     
    238226        progress.ProgressValue = ((double)i) / count;
    239227      }
    240       progress.Finish();
     228      MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
    241229      ClearRuns();
    242230    }
  • stable/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ProgressView.cs

    r9456 r9933  
    2121
    2222using System;
    23 using System.ComponentModel;
    2423using System.Windows.Forms;
    2524
    2625namespace HeuristicLab.MainForm.WindowsForms {
    27   [View("ProgressView")]
    28   [Content(typeof(IProgress), true)]
    29   public partial class ProgressView : AsynchronousContentView {
    30     private const int DefaultCancelTimeoutMs = 3000;
    31     private ContentView parentView;
     26  internal sealed partial class ProgressView : UserControl {
     27    private const int defaultControlHeight = 88;
     28    private const int collapsedControlHeight = 55;
    3229
    33     [Category("Custom"), Description("The time that the process is allowed to exit.")]
    34     [DefaultValue(DefaultCancelTimeoutMs)]
    35     public int CancelTimeoutMs { get; set; }
    36     private bool ShouldSerializeCancelTimeoutMs() { return CancelTimeoutMs != DefaultCancelTimeoutMs; }
    37 
    38     public new IProgress Content {
    39       get { return (IProgress)base.Content; }
    40       set { base.Content = value; }
     30    private readonly Control control;
     31    public Control Control {
     32      get { return control; }
    4133    }
    4234
    43     public ProgressView() {
    44       InitializeComponent();
    45     }
    46     public ProgressView(IProgress progress)
    47       : this() {
    48       Content = progress;
    49     }
    50     public ProgressView(ContentView parentView)
    51       : this() {
    52       if (parentView == null) throw new ArgumentNullException("parentView", "The parent view is null.");
    53       this.parentView = parentView;
    54     }
    55     public ProgressView(ContentView parentView, IProgress progress)
    56       : this(parentView) {
    57       Content = progress;
     35    private readonly IProgress content;
     36    public IProgress Content {
     37      get { return content; }
    5838    }
    5939
    60     protected override void RegisterContentEvents() {
    61       Content.StatusChanged += new EventHandler(progress_StatusChanged);
    62       Content.ProgressValueChanged += new EventHandler(progress_ProgressValueChanged);
    63       Content.ProgressStateChanged += new EventHandler(Content_ProgressStateChanged);
    64       Content.CanBeCanceledChanged += new EventHandler(Content_CanBeCanceledChanged);
    65       base.RegisterContentEvents();
     40    public ProgressView(Control control, IProgress content)
     41      : base() {
     42      if (control == null) throw new ArgumentNullException("control", "The control is null.");
     43      if (content == null) throw new ArgumentNullException("content", "The passed progress is null.");
     44      InitializeComponent();
     45
     46      this.control = control;
     47      this.content = content;
     48      if (content.ProgressState == ProgressState.Started)
     49        ShowProgress();
     50      RegisterContentEvents();
    6651    }
    6752
    68     protected override void DeregisterContentEvents() {
    69       base.DeregisterContentEvents();
    70       Content.StatusChanged -= new EventHandler(progress_StatusChanged);
    71       Content.ProgressValueChanged -= new EventHandler(progress_ProgressValueChanged);
    72       Content.ProgressStateChanged -= new EventHandler(Content_ProgressStateChanged);
    73       Content.CanBeCanceledChanged -= new EventHandler(Content_CanBeCanceledChanged);
     53    /// <summary>
     54    /// Clean up any resources being used.
     55    /// </summary>
     56    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
     57    protected override void Dispose(bool disposing) {
     58      DeregisterContentEvents();
     59      HideProgress();
     60
     61      if (disposing && (components != null)) {
     62        components.Dispose();
     63      }
     64      base.Dispose(disposing);
    7465    }
    7566
    76     protected override void OnContentChanged() {
    77       base.OnContentChanged();
    78       if (Content == null) {
    79         HideProgress();
    80       } else {
    81         if (Content.ProgressState == ProgressState.Started)
    82           ShowProgress();
    83       }
     67    private void RegisterContentEvents() {
     68      content.StatusChanged += new EventHandler(progress_StatusChanged);
     69      content.ProgressValueChanged += new EventHandler(progress_ProgressValueChanged);
     70      content.ProgressStateChanged += new EventHandler(Content_ProgressStateChanged);
     71      content.CanBeCanceledChanged += new EventHandler(Content_CanBeCanceledChanged);
    8472    }
    85 
    86     protected override void SetEnabledStateOfControls() {
    87       base.SetEnabledStateOfControls();
    88       cancelButton.Visible = Content != null && Content.CanBeCanceled;
    89       cancelButton.Enabled = Content != null && Content.CanBeCanceled && !ReadOnly;
     73    private void DeregisterContentEvents() {
     74      content.StatusChanged -= new EventHandler(progress_StatusChanged);
     75      content.ProgressValueChanged -= new EventHandler(progress_ProgressValueChanged);
     76      content.ProgressStateChanged -= new EventHandler(Content_ProgressStateChanged);
     77      content.CanBeCanceledChanged -= new EventHandler(Content_CanBeCanceledChanged);
    9078    }
    9179
    9280    private void ShowProgress() {
    93       if (InvokeRequired) Invoke((Action)ShowProgress);
    94       else {
    95         if (parentView != null) {
    96           this.Left = (parentView.ClientRectangle.Width / 2) - (this.Width / 2);
    97           this.Top = (parentView.ClientRectangle.Height / 2) - (this.Height / 2);
    98           this.Anchor = AnchorStyles.None;
     81      if (Control.InvokeRequired) {
     82        Control.Invoke((Action)ShowProgress);
     83        return;
     84      }
     85      int height = Content.CanBeCanceled ? Height : collapsedControlHeight;
    9986
    100           LockBackground();
     87      Left = (Control.ClientRectangle.Width / 2) - (Width / 2);
     88      Top = (Control.ClientRectangle.Height / 2) - (height / 2);
     89      Anchor = AnchorStyles.None;
    10190
    102           if (!parentView.Controls.Contains(this))
    103             parentView.Controls.Add(this);
     91      control.Enabled = false;
     92      Parent = Control.Parent;
     93      BringToFront();
    10494
    105           BringToFront();
    106         }
    107         UpdateProgressValue();
    108         UpdateProgressStatus();
    109         Visible = true;
    110       }
     95      UpdateProgressValue();
     96      UpdateProgressStatus();
     97      UpdateCancelButton();
     98      Visible = true;
    11199    }
    112100
     
    114102      if (InvokeRequired) Invoke((Action)HideProgress);
    115103      else {
    116         if (parentView != null) {
    117           if (parentView.Controls.Contains(this))
    118             parentView.Controls.Remove(this);
    119 
    120           UnlockBackground();
    121         }
     104        control.Enabled = true;
     105        Parent = null;
    122106        Visible = false;
    123107      }
     
    133117
    134118    private void Content_ProgressStateChanged(object sender, EventArgs e) {
    135       if (Content.ProgressState == ProgressState.Finished
    136         || Content.ProgressState == ProgressState.Canceled)
    137         HideProgress();
    138       if (Content.ProgressState == ProgressState.Started)
    139         ShowProgress();
     119      switch (content.ProgressState) {
     120        case ProgressState.Finished: HideProgress(); break;
     121        case ProgressState.Canceled: HideProgress(); break;
     122        case ProgressState.Started: ShowProgress(); break;
     123        default: throw new NotSupportedException("The progress state " + content.ProgressState + " is not supported by the ProgressView.");
     124      }
    140125    }
    141126
    142127    private void Content_CanBeCanceledChanged(object sender, EventArgs e) {
    143       SetEnabledStateOfControls();
     128      UpdateCancelButton();
    144129    }
    145130
    146     private void LockBackground() {
    147       if (InvokeRequired) {
    148         Invoke((Action)LockBackground);
    149       } else {
    150         parentView.Locked = true;
    151         parentView.ReadOnly = true;
    152         Locked = false;
    153         ReadOnly = false;
    154       }
    155     }
     131    private void UpdateCancelButton() {
     132      cancelButton.Visible = content != null && content.CanBeCanceled;
     133      cancelButton.Enabled = content != null && content.CanBeCanceled;
    156134
    157     private void UnlockBackground() {
    158       if (InvokeRequired) Invoke((Action)UnlockBackground);
    159       else {
    160         parentView.Locked = false;
    161         parentView.ReadOnly = false;
    162         Locked = true;
    163         ReadOnly = true;
     135      if (content != null && content.CanBeCanceled) {
     136        Height = defaultControlHeight;
     137      } else if (content != null && !content.CanBeCanceled) {
     138        Height = collapsedControlHeight;
    164139      }
    165140    }
     
    168143      if (InvokeRequired) Invoke((Action)UpdateProgressValue);
    169144      else {
    170         if (Content != null) {
    171           double progressValue = Content.ProgressValue;
     145        if (content != null) {
     146          double progressValue = content.ProgressValue;
    172147          if (progressValue <= 0.0 || progressValue > 1.0) {
    173             if (progressBar.Style != ProgressBarStyle.Marquee)
    174               progressBar.Style = ProgressBarStyle.Marquee;
     148            progressBar.Style = ProgressBarStyle.Marquee;
    175149          } else {
    176             if (progressBar.Style != ProgressBarStyle.Blocks)
    177               progressBar.Style = ProgressBarStyle.Blocks;
     150            progressBar.Style = ProgressBarStyle.Blocks;
    178151            progressBar.Value = (int)Math.Round(progressBar.Minimum + progressValue * (progressBar.Maximum - progressBar.Minimum));
    179152          }
     
    184157    private void UpdateProgressStatus() {
    185158      if (InvokeRequired) Invoke((Action)UpdateProgressStatus);
    186       else if (Content != null)
    187         statusLabel.Text = Content.Status;
     159      else if (content != null)
     160        statusLabel.Text = content.Status;
    188161    }
    189162
    190163    private void cancelButton_Click(object sender, EventArgs e) {
    191       if (Content != null) {
    192         try {
    193           Content.Cancel(CancelTimeoutMs);
    194           ReadOnly = true;
    195           cancelButtonTimer.Interval = CancelTimeoutMs;
    196           cancelButtonTimer.Start();
    197         } catch (NotSupportedException nse) {
    198           PluginInfrastructure.ErrorHandling.ShowErrorDialog(nse);
    199         }
    200       }
    201     }
    202 
    203     private void cancelButtonTimer_Tick(object sender, EventArgs e) {
    204       cancelButtonTimer.Stop();
    205       if (Visible) ReadOnly = false;
     164      content.Cancel();
    206165    }
    207166  }
  • stable/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ProgressView.designer.cs

    r9456 r9933  
    2727    private System.ComponentModel.IContainer components = null;
    2828
    29     /// <summary>
    30     /// Clean up any resources being used.
    31     /// </summary>
    32     /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    33     protected override void Dispose(bool disposing) {
    34       if (disposing && (components != null)) {
    35         components.Dispose();
    36       }
    37       base.Dispose(disposing);
    38     }
    39 
     29   
    4030    #region Component Designer generated code
    4131
     
    4535    /// </summary>
    4636    private void InitializeComponent() {
    47       this.components = new System.ComponentModel.Container();
    4837      this.progressBar = new System.Windows.Forms.ProgressBar();
    4938      this.statusLabel = new System.Windows.Forms.Label();
    5039      this.cancelButton = new System.Windows.Forms.Button();
    5140      this.panel = new System.Windows.Forms.Panel();
    52       this.cancelButtonTimer = new System.Windows.Forms.Timer(this.components);
    5341      this.panel.SuspendLayout();
    5442      this.SuspendLayout();
     
    5644      // progressBar
    5745      //
    58       this.progressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    59                   | System.Windows.Forms.AnchorStyles.Right)));
     46      this.progressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     47            | System.Windows.Forms.AnchorStyles.Right)));
    6048      this.progressBar.Location = new System.Drawing.Point(3, 3);
    6149      this.progressBar.Name = "progressBar";
     
    6654      // statusLabel
    6755      //
    68       this.statusLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    69                   | System.Windows.Forms.AnchorStyles.Right)));
     56      this.statusLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     57            | System.Windows.Forms.AnchorStyles.Right)));
    7058      this.statusLabel.Location = new System.Drawing.Point(3, 33);
    7159      this.statusLabel.Name = "statusLabel";
     
    8674      // panel
    8775      //
    88       this.panel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    89                   | System.Windows.Forms.AnchorStyles.Right)));
     76      this.panel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     77            | System.Windows.Forms.AnchorStyles.Left)
     78            | System.Windows.Forms.AnchorStyles.Right)));
    9079      this.panel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    9180      this.panel.Controls.Add(this.progressBar);
     
    9685      this.panel.Size = new System.Drawing.Size(360, 88);
    9786      this.panel.TabIndex = 3;
    98       //
    99       // cancelButtonTimer
    100       //
    101       this.cancelButtonTimer.Tick += new System.EventHandler(this.cancelButtonTimer_Tick);
    10287      //
    10388      // ProgressView
     
    118103    private System.Windows.Forms.Button cancelButton;
    119104    private System.Windows.Forms.Panel panel;
    120     private System.Windows.Forms.Timer cancelButtonTimer;
    121105  }
    122106}
  • stable/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs

    r9931 r9933  
    345345    #endregion
    346346
     347    #region progress views
     348    private readonly Dictionary<IContent, IProgress> contentProgressLookup = new Dictionary<IContent, IProgress>();
     349    private readonly Dictionary<Control, IProgress> viewProgressLookup = new Dictionary<Control, IProgress>();
     350    private readonly List<ProgressView> progressViews = new List<ProgressView>();
     351
     352    /// <summary>
     353    /// Adds a <see cref="ProgressView"/> to the <see cref="ContentView"/>s showing the specified content.
     354    /// </summary>
     355    public IProgress AddOperationProgressToContent(IContent content, string progressMessage, bool addToObjectGraphObjects = true) {
     356      if (InvokeRequired) {
     357        IProgress result = (IProgress)Invoke((Func<IContent, string, bool, IProgress>)AddOperationProgressToContent, content, progressMessage, addToObjectGraphObjects);
     358        return result;
     359      }
     360      if (contentProgressLookup.ContainsKey(content))
     361        throw new ArgumentException("A progress is already registered for the specified content.", "content");
     362
     363      var contentViews = views.Keys.OfType<ContentView>();
     364      if (!contentViews.Any(v => v.Content == content))
     365        throw new ArgumentException("The content is not displayed in a top-level view", "content");
     366
     367      if (addToObjectGraphObjects) {
     368        var containedObjects = content.GetObjectGraphObjects();
     369        contentViews = contentViews.Where(v => containedObjects.Contains(v.Content));
     370      } else
     371        contentViews = contentViews.Where(v => v.Content == content);
     372
     373      var progress = new Progress(progressMessage, ProgressState.Started);
     374      foreach (var contentView in contentViews) {
     375        progressViews.Add(new ProgressView(contentView, progress));
     376      }
     377
     378      contentProgressLookup[content] = progress;
     379      return progress;
     380    }
     381
     382    /// <summary>
     383    /// Adds a <see cref="ProgressView"/> to the specified view.
     384    /// </summary>
     385    public IProgress AddOperationProgressToView(Control control, string progressMessage) {
     386      var progress = new Progress(progressMessage, ProgressState.Started);
     387      AddOperationProgressToView(control, progress);
     388      return progress;
     389    }
     390
     391    public void AddOperationProgressToView(Control control, IProgress progress) {
     392      if (InvokeRequired) {
     393        Invoke((Action<Control, IProgress>)AddOperationProgressToView, control, progress);
     394        return;
     395      }
     396      if (control == null) throw new ArgumentNullException("control", "The view must not be null.");
     397      if (progress == null) throw new ArgumentNullException("progress", "The progress must not be null.");
     398
     399      IProgress oldProgress;
     400      if (viewProgressLookup.TryGetValue(control, out oldProgress)) {
     401        foreach (var progressView in progressViews.Where(v => v.Content == oldProgress).ToList()) {
     402          progressView.Dispose();
     403          progressViews.Remove(progressView);
     404        }
     405        viewProgressLookup.Remove(control);
     406      }
     407
     408      progressViews.Add(new ProgressView(control, progress));
     409      viewProgressLookup[control] = progress;
     410    }
     411
     412    /// <summary>
     413    /// Removes an existing <see cref="ProgressView"/> from the <see cref="ContentView"/>s showing the specified content.
     414    /// </summary>
     415    public void RemoveOperationProgressFromContent(IContent content, bool finishProgress = true) {
     416      if (InvokeRequired) {
     417        Invoke((Action<IContent, bool>)RemoveOperationProgressFromContent, content, finishProgress);
     418        return;
     419      }
     420
     421      IProgress progress;
     422      if (!contentProgressLookup.TryGetValue(content, out progress))
     423        throw new ArgumentException("No progress is registered for the specified content.", "content");
     424
     425      if (finishProgress) progress.Finish();
     426      foreach (var progressView in progressViews.Where(v => v.Content == progress).ToList()) {
     427        progressView.Dispose();
     428        progressViews.Remove(progressView);
     429      }
     430      contentProgressLookup.Remove(content);
     431
     432    }
     433
     434    /// <summary>
     435    /// Removes an existing <see cref="ProgressView"/> from the specified view.
     436    /// </summary>
     437    public void RemoveOperationProgressFromView(Control control, bool finishProgress = true) {
     438      IProgress progress;
     439      if (!viewProgressLookup.TryGetValue(control, out progress))
     440        throw new ArgumentException("No progress is registered for the specified control.", "control");
     441
     442      if (finishProgress) progress.Finish();
     443      foreach (var progressView in progressViews.Where(v => v.Content == progress).ToList()) {
     444        progressView.Dispose();
     445        progressViews.Remove(progressView);
     446      }
     447      viewProgressLookup.Remove(control);
     448    }
     449    #endregion
     450
    347451    #region create menu and toolbar
    348452    private void CreateGUI() {
  • stable/HeuristicLab.MainForm/3.3/Interfaces/IProgress.cs

    r9456 r9933  
    2828  public interface IProgress : IContent {
    2929    /// <summary>
    30     /// Gets the currently associated status text with the progress.
     30    /// Gets or sets the currently associated status text with the progress.
    3131    /// </summary>
    32     string Status { get; }
     32    string Status { get; set; }
    3333    /// <summary>
    34     /// Gets the currently associated progress value in the range (0;1].
     34    /// Gets or sets the currently associated progress value in the range (0;1].
    3535    ///  Values outside this range are permitted and need to be handled in some feasible manner.
    3636    /// </summary>
    37     double ProgressValue { get; }
     37    double ProgressValue { get; set; }
    3838    /// <summary>
    39     /// Gets the current state of the progress. Every progress starts in state
     39    /// Gets or sets the current state of the progress. Every progress starts in state
    4040    /// Started and then becomes either Canceled or Finished.
    4141    /// If it is reused it may be Started again.
     
    5454    /// </summary>
    5555    /// <exception cref="NotSupportedException">Thrown when cancellation is not supported.</exception>
    56     /// <param name="timeoutMs">The operation is given a certain timeout to cancel. If the operation doesn't cancel in this time it will be forcibly closed.</param>
    57     void Cancel(int timeoutMs);
     56    void Cancel();
     57    /// <summary>
     58    /// Sets the ProgressValue to 1 and the ProgressState to Finished.
     59    /// </summary>
     60    void Finish();
     61
     62    /// <summary>
     63    /// Starts or restarts a Progress.
     64    /// </summary>
     65    void Start();
     66
     67    void Start(string status);
    5868
    5969    /// <summary>
     
    7484    event EventHandler CanBeCanceledChanged;
    7585    /// <summary>
    76     /// A cancelation is requested with a certain timeout (in ms) in which it should occur gracefully. If the timeout is surpassed, it should be forcibly canceled.
     86    /// A cancelation is requested.
    7787    /// </summary>
    78     event EventHandler<EventArgs<int>> CancelRequested;
     88    event EventHandler CancelRequested;
    7989  }
    8090}
  • stable/HeuristicLab.MainForm/3.3/Progress.cs

    r9456 r9933  
    2121
    2222using System;
    23 using HeuristicLab.Common;
    2423
    2524namespace HeuristicLab.MainForm {
     
    5049    public ProgressState ProgressState {
    5150      get { return progressState; }
    52       set {
     51      private set {
    5352        if (progressState != value) {
    5453          progressState = value;
     
    7069
    7170    public Progress() {
    72       progressState = ProgressState.Started;
     71      progressState = ProgressState.Finished;
     72      canBeCanceled = false;
    7373    }
    7474    public Progress(string status)
     
    7676      this.status = status;
    7777    }
    78     public Progress(string status, double progressValue)
    79       : this(status) {
    80       this.progressValue = progressValue;
     78    public Progress(string status, ProgressState state)
     79      : this() {
     80      this.status = status;
     81      this.progressState = state;
    8182    }
    8283
    83     public void Cancel(int timeoutMs) {
     84    public void Cancel() {
    8485      if (canBeCanceled)
    85         OnCancelRequested(timeoutMs);
     86        OnCancelRequested();
    8687    }
    8788
    88     /// <summary>
    89     /// Sets the ProgressValue to 1 and the ProgressState to Finished.
    90     /// </summary>
    9189    public void Finish() {
    9290      if (ProgressValue != 1.0) ProgressValue = 1.0;
    9391      ProgressState = ProgressState.Finished;
     92    }
     93
     94    public void Start() {
     95      ProgressValue = 0.0;
     96      ProgressState = ProgressState.Started;
     97    }
     98
     99    public void Start(string status) {
     100      Start();
     101      Status = status;
    94102    }
    95103
     
    98106    private void OnStatusChanged() {
    99107      var handler = StatusChanged;
    100       try {
    101         if (handler != null) handler(this, EventArgs.Empty);
    102       } catch { }
     108      if (handler != null) handler(this, EventArgs.Empty);
    103109    }
    104110
     
    106112    private void OnProgressChanged() {
    107113      var handler = ProgressValueChanged;
    108       try {
    109         if (handler != null) handler(this, EventArgs.Empty);
    110       } catch { }
     114      if (handler != null) handler(this, EventArgs.Empty);
    111115    }
    112116
     
    114118    private void OnProgressStateChanged() {
    115119      var handler = ProgressStateChanged;
    116       try {
    117         if (handler != null) handler(this, EventArgs.Empty);
    118       } catch { }
     120      if (handler != null) handler(this, EventArgs.Empty);
    119121    }
    120122
     
    122124    private void OnCanBeCanceledChanged() {
    123125      var handler = CanBeCanceledChanged;
    124       try {
    125         if (handler != null) handler(this, EventArgs.Empty);
    126       } catch { }
     126      if (handler != null) handler(this, EventArgs.Empty);
    127127    }
    128128
    129     public event EventHandler<EventArgs<int>> CancelRequested;
    130     private void OnCancelRequested(int timeoutMs) {
     129    public event EventHandler CancelRequested;
     130    private void OnCancelRequested() {
    131131      var handler = CancelRequested;
    132       try {
    133         if (handler == null) throw new NotSupportedException("Cancel request was ignored.");
    134         else handler(this, new EventArgs<int>(timeoutMs));
    135       } catch { }
     132      if (handler != null) throw new NotSupportedException("Cancel request was ignored.");
     133      else handler(this, EventArgs.Empty);
    136134    }
    137135    #endregion
  • stable/HeuristicLab.Optimizer/3.3/FileManager.cs

    r9456 r9933  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Linq;
     24using System.IO;
    2525using System.Windows.Forms;
    2626using HeuristicLab.Common;
     
    9898          SaveAs(view);
    9999        else {
    100           ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).SetAppStartingCursor();
    101           SetEnabledStateOfContentViews(content, false);
     100          MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().SetAppStartingCursor();
     101          SetSaveOperationProgressInContentViews(content, true);
    102102          ContentManager.SaveAsync(content, content.Filename, true, SavingCompleted);
    103103        }
     
    123123
    124124        if (saveFileDialog.ShowDialog() == DialogResult.OK) {
    125           ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).SetAppStartingCursor();
    126           SetEnabledStateOfContentViews(content, false);
     125          MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().SetAppStartingCursor();
     126          SetSaveOperationProgressInContentViews(content, true, saveFileDialog.FileName);
    127127          if (saveFileDialog.FilterIndex == 1) {
    128128            ContentManager.SaveAsync(content, saveFileDialog.FileName, false, SavingCompleted);
     
    135135    private static void SavingCompleted(IStorableContent content, Exception error) {
    136136      try {
    137         SetEnabledStateOfContentViews(content, true);
    138137        if (error != null) throw error;
    139138        MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().UpdateTitle();
     
    143142      }
    144143      finally {
    145         ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).ResetAppStartingCursor();
     144        SetSaveOperationProgressInContentViews(content, false);
     145        MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().ResetAppStartingCursor();
    146146      }
    147147    }
    148148
    149     private static void SetEnabledStateOfContentViews(IStorableContent content, bool enabled) {
     149    private static void SetSaveOperationProgressInContentViews(IStorableContent content, bool showProgress, string fileName = null) {
    150150      HeuristicLab.MainForm.WindowsForms.MainForm mainForm = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>();
    151151      #region Mono Compatibility
    152152      // removed the InvokeRequired check because of Mono
    153153      mainForm.Invoke((Action)delegate {
    154         var views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == content).ToList();
    155         views.ForEach(v => v.Enabled = enabled);
     154        if (showProgress) {
     155          mainForm.AddOperationProgressToContent(content, string.Format("Saving to file \"{0}\"...", Path.GetFileName(fileName ?? content.Filename)));
     156        } else
     157          mainForm.RemoveOperationProgressFromContent(content);
    156158      });
    157159      #endregion
  • stable/HeuristicLab.Optimizer/3.3/StartPage.Designer.cs

    r9456 r9933  
    5050      this.titleLabel = new System.Windows.Forms.Label();
    5151      this.samplesGroupBox = new System.Windows.Forms.GroupBox();
    52       this.loadingPanel = new System.Windows.Forms.Panel();
    53       this.loadingProgressBar = new System.Windows.Forms.ProgressBar();
    54       this.loadingLabel = new System.Windows.Forms.Label();
    5552      this.samplesListView = new System.Windows.Forms.ListView();
    56       this.nameColumnHeader = new System.Windows.Forms.ColumnHeader();
    57       this.descriptionColumnHeader = new System.Windows.Forms.ColumnHeader();
     53      this.nameColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
     54      this.descriptionColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
    5855      this.imageList = new System.Windows.Forms.ImageList(this.components);
    5956      this.splitContainer = new System.Windows.Forms.SplitContainer();
    6057      this.samplesGroupBox.SuspendLayout();
    61       this.loadingPanel.SuspendLayout();
     58      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    6259      this.splitContainer.Panel1.SuspendLayout();
    6360      this.splitContainer.Panel2.SuspendLayout();
     
    8077      // firstStepsRichTextBox
    8178      //
    82       this.firstStepsRichTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    83                   | System.Windows.Forms.AnchorStyles.Left)
    84                   | System.Windows.Forms.AnchorStyles.Right)));
     79      this.firstStepsRichTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     80            | System.Windows.Forms.AnchorStyles.Left)
     81            | System.Windows.Forms.AnchorStyles.Right)));
    8582      this.firstStepsRichTextBox.BackColor = System.Drawing.SystemColors.Control;
    8683      this.firstStepsRichTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
     
    9693      // titleLabel
    9794      //
    98       this.titleLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    99                   | System.Windows.Forms.AnchorStyles.Right)));
     95      this.titleLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     96            | System.Windows.Forms.AnchorStyles.Right)));
    10097      this.titleLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    10198      this.titleLabel.Location = new System.Drawing.Point(-1, 0);
     
    108105      // samplesGroupBox
    109106      //
    110       this.samplesGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    111                   | System.Windows.Forms.AnchorStyles.Left)
    112                   | System.Windows.Forms.AnchorStyles.Right)));
    113       this.samplesGroupBox.Controls.Add(this.loadingPanel);
     107      this.samplesGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     108            | System.Windows.Forms.AnchorStyles.Left)
     109            | System.Windows.Forms.AnchorStyles.Right)));
    114110      this.samplesGroupBox.Controls.Add(this.samplesListView);
    115111      this.samplesGroupBox.Location = new System.Drawing.Point(0, 3);
     
    119115      this.samplesGroupBox.TabStop = false;
    120116      this.samplesGroupBox.Text = "Samples";
    121       //
    122       // loadingPanel
    123       //
    124       this.loadingPanel.Anchor = System.Windows.Forms.AnchorStyles.None;
    125       this.loadingPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    126       this.loadingPanel.Controls.Add(this.loadingProgressBar);
    127       this.loadingPanel.Controls.Add(this.loadingLabel);
    128       this.loadingPanel.Enabled = false;
    129       this.loadingPanel.Location = new System.Drawing.Point(189, 89);
    130       this.loadingPanel.Name = "loadingPanel";
    131       this.loadingPanel.Size = new System.Drawing.Size(350, 62);
    132       this.loadingPanel.TabIndex = 1;
    133       //
    134       // loadingProgressBar
    135       //
    136       this.loadingProgressBar.Anchor = System.Windows.Forms.AnchorStyles.None;
    137       this.loadingProgressBar.Location = new System.Drawing.Point(101, 19);
    138       this.loadingProgressBar.Name = "loadingProgressBar";
    139       this.loadingProgressBar.Size = new System.Drawing.Size(229, 23);
    140       this.loadingProgressBar.Step = 1;
    141       this.loadingProgressBar.TabIndex = 1;
    142       //
    143       // loadingLabel
    144       //
    145       this.loadingLabel.Anchor = System.Windows.Forms.AnchorStyles.None;
    146       this.loadingLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    147       this.loadingLabel.Location = new System.Drawing.Point(12, 19);
    148       this.loadingLabel.Name = "loadingLabel";
    149       this.loadingLabel.Size = new System.Drawing.Size(83, 23);
    150       this.loadingLabel.TabIndex = 0;
    151       this.loadingLabel.Text = "Loading ...";
    152117      //
    153118      // samplesListView
     
    168133      this.samplesListView.UseCompatibleStateImageBehavior = false;
    169134      this.samplesListView.View = System.Windows.Forms.View.Details;
     135      this.samplesListView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.samplesListView_ItemDrag);
    170136      this.samplesListView.DoubleClick += new System.EventHandler(this.samplesListView_DoubleClick);
    171       this.samplesListView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.samplesListView_ItemDrag);
    172137      //
    173138      // nameColumnHeader
     
    189154      // splitContainer
    190155      //
    191       this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    192                   | System.Windows.Forms.AnchorStyles.Left)
    193                   | System.Windows.Forms.AnchorStyles.Right)));
     156      this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     157            | System.Windows.Forms.AnchorStyles.Left)
     158            | System.Windows.Forms.AnchorStyles.Right)));
    194159      this.splitContainer.Location = new System.Drawing.Point(0, 0);
    195160      this.splitContainer.Name = "splitContainer";
     
    210175      // StartPage
    211176      //
    212       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    213177      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    214178      this.Controls.Add(this.splitContainer);
     
    217181      this.Size = new System.Drawing.Size(728, 640);
    218182      this.samplesGroupBox.ResumeLayout(false);
    219       this.loadingPanel.ResumeLayout(false);
    220183      this.splitContainer.Panel1.ResumeLayout(false);
    221184      this.splitContainer.Panel2.ResumeLayout(false);
     185      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
    222186      this.splitContainer.ResumeLayout(false);
    223187      this.ResumeLayout(false);
     
    236200    private System.Windows.Forms.ImageList imageList;
    237201    private System.Windows.Forms.ColumnHeader descriptionColumnHeader;
    238     private System.Windows.Forms.Panel loadingPanel;
    239     private System.Windows.Forms.ProgressBar loadingProgressBar;
    240     private System.Windows.Forms.Label loadingLabel;
    241202    private System.Windows.Forms.SplitContainer splitContainer;
    242203  }
  • stable/HeuristicLab.Optimizer/3.3/StartPage.cs

    r9456 r9933  
    3434  [View("Start Page")]
    3535  public partial class StartPage : HeuristicLab.MainForm.WindowsForms.View {
     36    private IProgress progress;
     37
    3638    public StartPage() {
    3739      InitializeComponent();
     
    6769
    6870    private void LoadSamples(object state) {
     71      progress = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(samplesListView, "Loading...");
    6972      Assembly assembly = Assembly.GetExecutingAssembly();
    7073      var samples = assembly.GetManifestResourceNames().Where(x => x.EndsWith(".hl"));
     
    7780            WriteStreamToTempFile(stream, path);
    7881            INamedItem item = XmlParser.Deserialize<INamedItem>(path);
    79             OnSampleLoaded(item, loadingProgressBar.Maximum / count);
     82            OnSampleLoaded(item, 1.0 / count);
    8083          }
    8184        }
    82         catch (Exception) { }
     85        catch (Exception) {
     86          MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(samplesListView);
     87        }
    8388      }
    8489      OnAllSamplesLoaded();
    8590    }
    86     private void OnSampleLoaded(INamedItem sample, int progress) {
     91    private void OnSampleLoaded(INamedItem sample, double progress) {
    8792      if (InvokeRequired)
    88         Invoke(new Action<INamedItem, int>(OnSampleLoaded), sample, progress);
     93        Invoke(new Action<INamedItem, double>(OnSampleLoaded), sample, progress);
    8994      else {
    9095        ListViewItem item = new ListViewItem(new string[] { sample.Name, sample.Description });
     
    9499        item.Tag = sample;
    95100        samplesListView.Items.Add(item);
    96         loadingProgressBar.Value += progress;
     101        this.progress.ProgressValue += progress;
    97102      }
    98103    }
     
    106111            samplesListView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
    107112        }
    108         loadingPanel.Visible = false;
     113        MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(samplesListView);
    109114      }
    110115    }
  • stable/HeuristicLab.Problems.DataAnalysis.Views

  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/MenuItems/ShrinkDataAnalysisRunsMenuItem.cs

    r9932 r9933  
    7676    public override void Execute() {
    7777      IContentView activeView = (IContentView)MainFormManager.MainForm.ActiveView;
    78       Progress progress = new Progress("Removing duplicate datasets.");
    7978      var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
    80       mainForm.AddOperationProgressToContent(activeView.Content, progress);
     79      mainForm.AddOperationProgressToContent(activeView.Content, "Removing duplicate datasets.");
    8180
    8281      Action<IContentView> action = (view) => {
Note: See TracChangeset for help on using the changeset viewer.