Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/21/18 15:02:52 (6 years ago)
Author:
pfleck
Message:

#2845 Moved the entire progress API to the Progress class and made the progress API within the MainForm internal.

Location:
branches/2845_EnhancedProgress
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/2845_EnhancedProgress/HeuristicLab.Algorithms.Benchmarks/3.3/BenchmarkAlgorithm.cs

    r16311 r16314  
    3939  [Creatable(CreatableAttribute.Categories.TestingAndAnalysis, Priority = 130)]
    4040  [StorableClass]
    41   public sealed class BenchmarkAlgorithm : IAlgorithm {
     41  public sealed class BenchmarkAlgorithm : IAlgorithm, IStorableContent {
    4242    private CancellationTokenSource cancellationTokenSource;
     43
     44    public string Filename { get; set; }
    4345
    4446    public string ItemName {
  • branches/2845_EnhancedProgress/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectJobsView.cs

    r16312 r16314  
    8181      base.RegisterContentEvents();
    8282      matrixView.DataGridView.SelectionChanged += DataGridView_SelectionChanged;
    83       MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddProgressToView(this, progress);
     83      MainForm.Progress.AddProgressToView(this, progress);
    8484    }
    8585
    8686    protected override void DeregisterContentEvents() {
    8787      matrixView.DataGridView.SelectionChanged -= DataGridView_SelectionChanged;
    88       MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveProgressFromView(this, false);
     88      MainForm.Progress.RemoveProgressFromView(this, false);
    8989      base.DeregisterContentEvents();
    9090    }
     
    191191
    192192        if (result == DialogResult.Yes) {
    193           progress.Start("Resuming job(s)...");
     193          progress.StartMarquee("Resuming job(s)...");
    194194          SetEnabledStateOfControls();
    195195          var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobsAsync, jobs);
  • branches/2845_EnhancedProgress/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r16311 r16314  
    7575      Content.Loaded += new EventHandler(Content_Loaded);
    7676      Content.TaskReceived += new EventHandler(Content_TaskReceived);
    77       MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddProgressToView(this, Content.Progress);
     77      Progress.AddProgressToView(this, Content.Progress);
    7878    }
    7979
     
    9090      Content.Loaded -= new EventHandler(Content_Loaded);
    9191      Content.TaskReceived -= new EventHandler(Content_TaskReceived);
    92       MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveProgressFromView(this, false);
     92      Progress.RemoveProgressFromView(this, false);
    9393      DeregisterHiveExperimentEvents();
    9494      DeregisterHiveTasksEvents();
     
    133133          stateLogViewHost.Content = null;
    134134        } else {
    135           if(Content.Job != null
    136             && Content.Job.Id != Guid.Empty 
     135          if (Content.Job != null
     136            && Content.Job.Id != Guid.Empty
    137137            && !originalJobProjectAssignment.ContainsKey(Content.Job.Id)) {
    138138            originalJobProjectAssignment.Add(Content.Job.Id, Content.Job.ProjectId);
     
    159159                projectNameTextBox.Text = HiveClient.Instance.GetProjectAncestry(Content.Job.ProjectId);
    160160                projectNameTextBox.Text += "   (" + (cores.HasValue ? cores.Value.ToString() : "0") + " cores)";
    161               }               
     161              }
    162162            }
    163163          } else if (Content.Job != null && Content.Job.ProjectId != Guid.Empty) {
     
    167167            }
    168168
    169             if(hiveResourceSelectorDialog == null)
     169            if (hiveResourceSelectorDialog == null)
    170170              hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId);
    171171
     
    203203          executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    204204          refreshAutomaticallyCheckBox.Checked = Content.RefreshAutomatically;
    205          
     205
    206206          logView.Content = Content.Log;
    207207          lock (runCollectionViewLocker) {
     
    408408      if (hiveResourceSelectorDialog == null) {
    409409        hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId);
    410       } else if(hiveResourceSelectorDialog.JobId != Content.Job.Id) {
     410      } else if (hiveResourceSelectorDialog.JobId != Content.Job.Id) {
    411411        hiveResourceSelectorDialog.JobId = Content.Job.Id;
    412412        hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId;
     
    418418          hiveResourceSelectorDialog.ProjectId = Guid.Empty;
    419419        }
    420       } else if(hiveResourceSelectorDialog.JobId == Guid.Empty && Content.Job.Id == Guid.Empty) {
     420      } else if (hiveResourceSelectorDialog.JobId == Guid.Empty && Content.Job.Id == Guid.Empty) {
    421421        hiveResourceSelectorDialog.JobId = Content.Job.Id;
    422422        hiveResourceSelectorDialog.ProjectId = Guid.Empty;
     
    430430      if (hiveResourceSelectorDialog.ShowDialog(this) == DialogResult.OK) {
    431431        selectedProject = hiveResourceSelectorDialog.SelectedProject;
    432         if(selectedProject != null) {       
     432        if (selectedProject != null) {
    433433          Content.Job.ProjectId = selectedProject.Id;
    434434          Content.Job.ResourceIds = hiveResourceSelectorDialog.SelectedResources.Select(x => x.Id).ToList();
     
    582582        startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = false;
    583583      } else {
    584         startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0 
    585           && Content.Job.ProjectId != Guid.Empty && Content.Job.ResourceIds != null  && Content.Job.ResourceIds.Any()
     584        startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0
     585          && Content.Job.ProjectId != Guid.Empty && Content.Job.ResourceIds != null && Content.Job.ResourceIds.Any()
    586586          && (Content.ExecutionState == ExecutionState.Prepared || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
    587587        pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing;
     
    589589      }
    590590    }
    591    
     591
    592592    private Project GetProject(Guid projectId) {
    593593      return HiveServiceLocator.Instance.CallHiveService(s => s.GetProject(projectId));
     
    595595
    596596    private void UpdateSelectorDialog() {
    597       if(hiveResourceSelectorDialog != null) {
     597      if (hiveResourceSelectorDialog != null) {
    598598        hiveResourceSelectorDialog = null;
    599599        //hiveResourceSelectorDialog.JobId = Content.Job.Id;
  • branches/2845_EnhancedProgress/HeuristicLab.Clients.Hive.Views/3.3/HiveTasks/OptimizerHiveTaskView.cs

    r16311 r16314  
    5858      base.RegisterContentEvents();
    5959      Content.IsControllableChanged += new EventHandler(Content_IsControllableChanged);
    60       MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddProgressToView(this, Content.Progress);
     60      Progress.AddProgressToView(this, Content.Progress);
    6161    }
    6262
    6363    protected override void DeregisterContentEvents() {
    6464      Content.IsControllableChanged -= new EventHandler(Content_IsControllableChanged);
    65       MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveProgressFromView(this, false);
     65      Progress.RemoveProgressFromView(this, false);
    6666      base.DeregisterContentEvents();
    6767    }
  • branches/2845_EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs

    r16311 r16314  
    353353    /// Adds a <see cref="ProgressView"/> to the <see cref="ContentView"/>s showing the specified content.
    354354    /// </summary>
    355     public void AddProgressToContent(IContent content, IProgress progress, bool addToObjectGraphObjects = true) {
     355    internal void AddProgressToContent(IContent content, IProgress progress, bool addToObjectGraphObjects = true) {
    356356      if (InvokeRequired) {
    357357        Invoke((Action<IContent, IProgress, bool>)AddProgressToContent, content, progress, addToObjectGraphObjects);
     
    381381    /// Adds a <see cref="ProgressView"/> to the specified view.
    382382    /// </summary>
    383     public void AddProgressToView(Control control, IProgress progress) {
     383    internal void AddProgressToView(Control control, IProgress progress) {
    384384      if (InvokeRequired) {
    385385        Invoke((Action<Control, IProgress>)AddProgressToView, control, progress);
     
    405405    /// Removes an existing <see cref="ProgressView"/> from the <see cref="ContentView"/>s showing the specified content.
    406406    /// </summary>
    407     public void RemoveProgressFromContent(IContent content, bool finishProgress = true) {
     407    internal void RemoveProgressFromContent(IContent content, bool finishProgress = true) {
    408408      if (InvokeRequired) {
    409409        Invoke((Action<IContent, bool>)RemoveProgressFromContent, content, finishProgress);
     
    426426    /// Removes an existing <see cref="ProgressView"/> from the specified view.
    427427    /// </summary>
    428     public void RemoveProgressFromView(Control control, bool finishProgress = true) {
     428    internal void RemoveProgressFromView(Control control, bool finishProgress = true) {
    429429      if (InvokeRequired) {
    430430        Invoke((Action<Control, bool>)RemoveProgressFromView, control, finishProgress);
  • branches/2845_EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/Progress.cs

    r16311 r16314  
    140140      var progress = new Progress();
    141141      progress.Start(progressMessage, initialProgressValue);
     142      AddProgressToContent(content, progress, addToObjectGraphObjects);
     143      return progress;
     144    }
     145    /// <summary>
     146    /// Shows a started Progress in Marquee-mode on all Views of the specified content.
     147    /// </summary>
     148    public static IProgress ShowMarquee(IContent content, string progressMessage, bool addToObjectGraphObjects = true) {
     149      var progress = new Progress();
     150      progress.StartMarquee(progressMessage);
     151      AddProgressToContent(content, progress, addToObjectGraphObjects);
     152      return progress;
     153    }
     154
     155    /// <summary>
     156    /// Shows a started Progress in Continuous-mode on the specified view.
     157    /// </summary>
     158    public static IProgress Show(Control control, string progressMessage, double initialProgressValue = 0) {
     159      var progress = new Progress();
     160      progress.Start(progressMessage, initialProgressValue);
     161      AddProgressToView(control, progress);
     162      return progress;
     163    }
     164    /// <summary>
     165    /// Shows a started Progress in Marquee-mode on the specified view.
     166    /// </summary>
     167    public static IProgress ShowMarquee(Control control, string progressMessage) {
     168      var progress = new Progress();
     169      progress.StartMarquee(progressMessage);
     170      AddProgressToView(control, progress);
     171      return progress;
     172    }
     173
     174    /// <summary>
     175    /// Hides the Progress from all Views of the specified content.
     176    /// </summary>
     177    public static void Hide(IContent content) {
     178      RemoveProgressFromContent(content);
     179    }
     180    /// <summary>
     181    /// Hides the Progress from the specified view.
     182    /// </summary>
     183    public static void Hide(Control control) {
     184      RemoveProgressFromView(control);
     185    }
     186    #endregion
     187
     188    #region Interface to from MainForm
     189    public static IProgress AddProgressToContent(IContent content, IProgress progress, bool addToObjectGraphObjects = true) {
    142190      MainFormManager.GetMainForm<WindowsForms.MainForm>().AddProgressToContent(content, progress, addToObjectGraphObjects);
    143191      return progress;
    144192    }
    145     /// <summary>
    146     /// Shows a started Progress in Marquee-mode on all Views of the specified content.
    147     /// </summary>
    148     public static IProgress ShowMarquee(IContent content, string progressMessage, bool addToObjectGraphObjects = true) {
    149       var progress = new Progress();
    150       progress.StartMarquee(progressMessage);
    151       MainFormManager.GetMainForm<WindowsForms.MainForm>().AddProgressToContent(content, progress, addToObjectGraphObjects);
    152       return progress;
    153     }
    154 
    155     /// <summary>
    156     /// Shows a started Progress in Continuous-mode on the specified view.
    157     /// </summary>
    158     public static IProgress Show(Control control, string progressMessage, double initialProgressValue = 0) {
    159       var progress = new Progress();
    160       progress.Start(progressMessage, initialProgressValue);
     193    public static IProgress AddProgressToView(Control control, IProgress progress) {
    161194      MainFormManager.GetMainForm<WindowsForms.MainForm>().AddProgressToView(control, progress);
    162195      return progress;
    163196    }
    164     /// <summary>
    165     /// Shows a started Progress in Marquee-mode on the specified view.
    166     /// </summary>
    167     public static IProgress ShowMarquee(Control control, string progressMessage) {
    168       var progress = new Progress();
    169       progress.StartMarquee(progressMessage);
    170       MainFormManager.GetMainForm<WindowsForms.MainForm>().AddProgressToView(control, progress);
    171       return progress;
    172     }
    173 
    174     /// <summary>
    175     /// Hides the Progress fom all Views of the specified content.
    176     /// </summary>
    177     public static void Hide(IContent content) {
    178       MainFormManager.GetMainForm<WindowsForms.MainForm>().RemoveProgressFromContent(content);
    179     }
    180     /// <summary>
    181     /// Hides the Progress fom the specified view.
    182     /// </summary>
    183     public static void Hide(Control control) {
    184       MainFormManager.GetMainForm<WindowsForms.MainForm>().RemoveProgressFromView(control);
     197
     198    public static void RemoveProgressFromContent(IContent content, bool finishProgress = true) {
     199      MainFormManager.GetMainForm<WindowsForms.MainForm>().RemoveProgressFromContent(content, finishProgress);
     200    }
     201    public static void RemoveProgressFromView(Control control, bool finishProgress = true) {
     202      MainFormManager.GetMainForm<WindowsForms.MainForm>().RemoveProgressFromView(control, finishProgress);
    185203    }
    186204    #endregion
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs

    r16311 r16314  
    154154      Content.ProblemDataChanged += Content_Changed;
    155155      treeChart.Repainted += treeChart_Repainted;
    156       MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddProgressToView(grpSimplify, progress);
     156      Progress.AddProgressToView(grpSimplify, progress);
    157157      progress.StopRequested += progress_StopRequested;
    158158    }
     
    162162      Content.ProblemDataChanged -= Content_Changed;
    163163      treeChart.Repainted -= treeChart_Repainted;
    164       MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveProgressFromView(grpSimplify, false);
     164      Progress.RemoveProgressFromView(grpSimplify, false);
    165165      progress.StopRequested -= progress_StopRequested;
    166166    }
Note: See TracChangeset for help on using the changeset viewer.