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:
4 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis.Views

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

    r9456 r9999  
    4444    /// </summary>
    4545    private void InitializeComponent() {
     46      this.exportButton = new System.Windows.Forms.Button();
     47      this.exportFileDialog = new System.Windows.Forms.SaveFileDialog();
    4648      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    4749      this.splitContainer.Panel1.SuspendLayout();
     
    5456      // splitContainer
    5557      //
     58      //
     59      // splitContainer.Panel2
     60      //
     61      this.splitContainer.Panel2.Controls.Add(this.exportButton);
    5662      //
    5763      // itemsGroupBox
     
    6773      this.toolTip.SetToolTip(this.removeButton, "Remove");
    6874      //
     75      // exportButton
     76      //
     77      this.exportButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     78      this.exportButton.Location = new System.Drawing.Point(215, 4);
     79      this.exportButton.Name = "exportButton";
     80      this.exportButton.Size = new System.Drawing.Size(54, 23);
     81      this.exportButton.TabIndex = 6;
     82      this.exportButton.Text = "Export";
     83      this.exportButton.UseVisualStyleBackColor = true;
     84      this.exportButton.Click += new System.EventHandler(this.exportButton_Click);
     85      //
    6986      // DataAnalysisSolutionView
    7087      //
    71       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    7288      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    7389      this.Name = "DataAnalysisSolutionView";
     
    84100    #endregion
    85101
     102    private System.Windows.Forms.SaveFileDialog exportFileDialog;
     103    protected System.Windows.Forms.Button exportButton;
     104
    86105  }
    87106}
  • 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.