Ignore:
Timestamp:
01/11/09 23:25:59 (12 years ago)
Author:
gkronber
Message:

worked on presentation layer for CEDMA (brushing) (#419)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetView.cs

    r1106 r1109  
    2525using System.Drawing;
    2626using System.Data;
     27using System.Linq;
    2728using System.Text;
    2829using System.Windows.Forms;
     
    3839      set { dataSet = value; }
    3940    }
    40 
     41    private Results results;
    4142    public DataSetView() {
    4243      InitializeComponent();
     
    5556      problemControl.Dock = DockStyle.Fill;
    5657      editorGroupBox.Controls.Add(problemControl);
     58      PopulateViewComboBox();
     59      resultsButton.Enabled = viewComboBox.SelectedItem != null;
     60    }
     61
     62    private void PopulateViewComboBox() {
     63      DiscoveryService service = new DiscoveryService();
     64      IResultsViewFactory[] factories = service.GetInstances<IResultsViewFactory>();
     65      viewComboBox.DataSource = factories;
     66      viewComboBox.ValueMember = "Name";
    5767    }
    5868
     
    6373
    6474    private void resultsButton_Click(object sender, EventArgs e) {
    65       Results results = dataSet.GetResults();
    66       IControl resultsControl = new ResultsViewContainer(results);
    67       PluginManager.ControlManager.ShowControl(resultsControl);
     75      if (results == null)
     76        ReloadResults();
     77      try {
     78        IResultsViewFactory factory = (IResultsViewFactory)viewComboBox.SelectedItem;
     79        BackgroundWorker worker = new BackgroundWorker();
     80        worker.WorkerReportsProgress = true;
     81        worker.WorkerSupportsCancellation = true;
     82        worker.ProgressChanged += delegate(object progressChangedSender, ProgressChangedEventArgs progressChangedArgs) {
     83          progressBar.Value = progressChangedArgs.ProgressPercentage;
     84        };
     85        worker.DoWork += delegate(object doWorkSender, DoWorkEventArgs doWorkArgs) {
     86          worker.ReportProgress(10);
     87          results.GetEntries().Last(); // preload list by accessing last element
     88          worker.ReportProgress(100);
     89        };
     90        resultsButton.Enabled = false;
     91        worker.RunWorkerAsync();
     92        worker.RunWorkerCompleted += delegate(object completedSender, RunWorkerCompletedEventArgs compledArgs) {
     93          resultsButton.Enabled = true;
     94          progressBar.Value = 0;
     95          IControl control = factory.CreateView(results);
     96          PluginManager.ControlManager.ShowControl(control);
     97        };
     98      }
     99      catch (Exception ex) {
     100        string text = "Couldn't load selected view: " + viewComboBox.SelectedItem + "\n" + ex.Message;
     101        MessageBox.Show(text, "Unable to create view", MessageBoxButtons.OK, MessageBoxIcon.Error);
     102      }
     103    }
     104
     105    private void ReloadResults() {
     106      results = dataSet.GetResults();
    68107    }
    69108  }
Note: See TracChangeset for help on using the changeset viewer.