Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/16/13 18:52:52 (11 years ago)
Author:
gkronber
Message:

#2102 moved "shrink data analysis solutions" and "create ensemble" to a "data analysis" sub-menu in the "Edit" menu. And added an export button to the views for data analysis solution that automatically discovers supported exporters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.cs

    r9456 r9973  
    2222using System;
    2323using System.Collections.Generic;
     24using System.ComponentModel;
    2425using System.Drawing;
    2526using System.Linq;
     
    3031using HeuristicLab.Optimization;
    3132using HeuristicLab.Optimization.Views;
     33using HeuristicLab.PluginInfrastructure;
    3234
    3335namespace HeuristicLab.Problems.DataAnalysis.Views {
     36
    3437  [View("DataAnalysisSolution View")]
    3538  [Content(typeof(DataAnalysisSolution), false)]
    36   public partial class DataAnalysisSolutionView : NamedItemCollectionView<IResult> {
     39  public partial class DataAnalysisSolutionView : Bla {
    3740    public DataAnalysisSolutionView() {
    3841      InitializeComponent();
     
    4952      addButton.Enabled = false;
    5053      removeButton.Enabled = false;
     54      if (Content == null) {
     55        exportButton.Enabled = false;
     56      } else {
     57        exportButton.Enabled = !Locked;
     58      }
    5159    }
    5260
     
    117125      } else
    118126        base.itemsListView_SelectedIndexChanged(sender, e);
     127    }
     128
     129
     130    private void exportButton_Click(object sender, EventArgs e) {
     131      var exporters = ApplicationManager.Manager.GetInstances<IDataAnalysisSolutionExporter>()
     132        .Where(exporter => exporter.Supports(Content)).ToArray();
     133      exportFileDialog.Filter = exporters.Skip(1)
     134        .Aggregate(exporters.First().FileTypeFilter, (s, exporter) => s + "|" + exporter.FileTypeFilter);
     135      var result = exportFileDialog.ShowDialog();
     136      if (result == DialogResult.OK) {
     137
     138        var name = exportFileDialog.FileName;
     139        var selectedExporter = exporters.Single(exporter => exporter.FileTypeFilter == exportFileDialog.Filter);
     140
     141        using (BackgroundWorker bg = new BackgroundWorker()) {
     142          MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Exportion solution to " + name + ".");
     143          bg.DoWork += (_, __) => selectedExporter.Export(Content, name);
     144          bg.RunWorkerCompleted += (_, __) => MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
     145          bg.RunWorkerAsync();
     146        }
     147      }
    119148    }
    120149
     
    190219    #endregion
    191220  }
     221
     222  public class Bla : NamedItemCollectionView<IResult> {
     223
     224  }
     225
    192226}
Note: See TracChangeset for help on using the changeset viewer.