Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/3.2/DataExport/ExportDialog.cs @ 3001

Last change on this file since 3001 was 1980, checked in by mstoeger, 15 years ago

Data Export (PNG) #588

File size: 1.4 KB
Line 
1using System;
2using System.Reflection;
3using System.Windows.Forms;
4
5namespace HeuristicLab.Visualization.DataExport {
6  public partial class ExportDialog : Form {
7    public ExportDialog() {
8      InitializeComponent();
9
10      Type[] types = Assembly.GetExecutingAssembly().GetTypes();
11      foreach (Type type in types) {
12        if (type.GetInterface(typeof (IExporter).FullName) != null) {
13          IExporter exporter = (IExporter)Activator.CreateInstance(type);
14
15          lbExporters.Items.Add(CreateListBoxItem(exporter));
16        }
17      }
18    }
19
20    private static ListBoxItem CreateListBoxItem(IExporter exporter) {
21      return new ListBoxItem(exporter);
22    }
23
24    private void btnCancel_Click(object sender, EventArgs e) {
25      selectedExporter = null;
26      Close();
27    }
28
29    private void btnSelectExporter_Click(object sender, EventArgs e) {
30      selectedExporter = ((ListBoxItem)lbExporters.SelectedItem).Exporter;
31      Close();
32    }
33
34    private IExporter selectedExporter;
35
36    public IExporter SelectedExporter {
37      get { return selectedExporter; }
38    }
39
40    private class ListBoxItem {
41      private readonly IExporter exporter;
42
43      public ListBoxItem(IExporter exporter) {
44        this.exporter = exporter;
45      }
46
47      public IExporter Exporter {
48        get { return exporter; }
49      }
50
51      public override string ToString() {
52        return exporter.Name;
53      }
54    }
55  }
56}
Note: See TracBrowser for help on using the repository browser.