Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/07/16 15:26:47 (9 years ago)
Author:
abeham
Message:

#2457: Added toolbar, fixed some bugs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/0_Config/30_DownloadFromOkbMenuItem.cs

    r13720 r13748  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Common.Resources;
     24using HeuristicLab.MainForm;
    2325using System;
    2426using System.Collections.Generic;
     
    4143    }
    4244
    43     public override string ToolTipText { get { return "Download relevant runs from the knowledge base."; } }
     45    public override string ToolTipText {
     46      get {
     47        return @"Download relevant runs, including algorithm instances
     48and problem instances from the OKB server.";
     49      }
     50    }
    4451
    4552    public override void Execute() {
     
    5158      ToolStripItem.Enabled = MainForm.ExpertSystem.Problem.ProblemId != -1;
    5259      MainForm.ExpertSystem.Problem.ProblemChanged += OnProblemChanged;
     60      MainForm.ExpertSystem.DownloadStarted += OnDownloadStarted;
    5361    }
    5462
     
    5664      ToolStripItem.Enabled = MainForm.ExpertSystem.Problem.ProblemId != -1;
    5765    }
     66
     67    private void OnDownloadStarted(object sender, EventArgs<IProgress> e) {
     68      ToolStripItem.Enabled = false;
     69      e.Value.ProgressStateChanged += DownloadProgressOnStateChanged;
     70    }
     71
     72    private void DownloadProgressOnStateChanged(object sender, EventArgs eventArgs) {
     73      var progress = (IProgress)sender;
     74      if (progress.ProgressState == ProgressState.Finished || progress.ProgressState == ProgressState.Canceled) {
     75        ToolStripItem.Enabled = true;
     76        progress.ProgressStateChanged -= DownloadProgressOnStateChanged;
     77      }
     78    }
    5879  }
    5980}
Note: See TracChangeset for help on using the changeset viewer.