Changeset 17380


Ignore:
Timestamp:
12/18/19 14:19:49 (12 months ago)
Author:
pfleck
Message:

#3042 Moved code for enabling/disabling the Optimize-Button to SetEnabledStateOfControls and called SetEnabledStateOfControls after the Model is changed.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs

    r17378 r17380  
    3838    }
    3939
     40    protected override void SetEnabledStateOfControls() {
     41      base.SetEnabledStateOfControls();
     42
     43      var tree = Content?.Model?.SymbolicExpressionTree;
     44      btnOptimizeConstants.Enabled = tree != null && SymbolicRegressionConstantOptimizationEvaluator.CanOptimizeConstants(tree);
     45    }
     46
    4047    protected override void UpdateModel(ISymbolicExpressionTree tree) {
    4148      var model = new SymbolicRegressionModel(Content.ProblemData.TargetVariable, tree, Content.Model.Interpreter, Content.Model.LowerEstimationLimit, Content.Model.UpperEstimationLimit);
    4249      model.Scale(Content.ProblemData);
    4350      Content.Model = model;
    44     }
    45 
    46     protected override void UpdateView() {
    47       base.UpdateView();
    48       var tree = Content?.Model?.SymbolicExpressionTree;
    49       btnOptimizeConstants.Enabled = tree != null && SymbolicRegressionConstantOptimizationEvaluator.CanOptimizeConstants(tree);
    5051    }
    5152
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs

    r17378 r17380  
    168168    private void Content_Changed(object sender, EventArgs e) {
    169169      UpdateView();
     170      SetEnabledStateOfControls();
    170171    }
    171172
     
    186187    }
    187188
    188     protected virtual async void UpdateView() {
     189    private async void UpdateView() {
    189190      if (Content == null || Content.Model == null || Content.ProblemData == null) return;
    190191      var tree = Content.Model.SymbolicExpressionTree;
     
    317318        var newTree = await Task.Run(() => OptimizeConstants(tree, progress));
    318319        await Task.Delay(500); // wait for progressbar to finish animation
    319         UpdateModel(newTree); // UpdateModel calls Progress.Finish (via Content_Changed)
    320       } catch (Exception) {
     320        UpdateModel(newTree);
     321      } finally {
    321322        progress.Finish();
    322         throw;
    323323      }
    324324    }
Note: See TracChangeset for help on using the changeset viewer.