Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/23/13 08:08:55 (11 years ago)
Author:
gkronber
Message:

#2102 merged r9973:9975 and r9994 from trunk to stable

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis.Views

  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.cs

    r9456 r9999  
    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)]
     
    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
Note: See TracChangeset for help on using the changeset viewer.