Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/03/11 17:16:31 (13 years ago)
Author:
gkronber
Message:

Merged changes to symbolic expression encoding related to refactoring text-based export formats for symbolic expression trees. #1152 #1270 #1314

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.3/SymbolicExpressionView.cs

    r4068 r5416  
    2323using HeuristicLab.MainForm;
    2424using HeuristicLab.MainForm.WindowsForms;
     25using HeuristicLab.PluginInfrastructure;
     26using System.Collections.Generic;
     27using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Formatters;
    2528
    2629namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
     
    2831  [Content(typeof(SymbolicExpressionTree), false)]
    2932  public partial class SymbolicExpressionView : AsynchronousContentView {
    30     private SymbolicExpressionTreeStringFormatter treeFormatter;
     33
     34    List<ISymbolicExpressionTreeStringFormatter> treeFormattersList = new List<ISymbolicExpressionTreeStringFormatter>();
    3135
    3236    public new SymbolicExpressionTree Content {
     
    3741    public SymbolicExpressionView() {
    3842      InitializeComponent();
    39       treeFormatter = new SymbolicExpressionTreeStringFormatter();
     43      IEnumerable<ISymbolicExpressionTreeStringFormatter> formatters = ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeStringFormatter>();
     44      treeFormattersList = new List<ISymbolicExpressionTreeStringFormatter>();
     45      int selectedIndex = -1;
     46      foreach (ISymbolicExpressionTreeStringFormatter formatter in formatters) {
     47        if (formatter is SymbolicExpressionTreeStringFormatter)
     48          selectedIndex = treeFormattersList.Count;
     49        treeFormattersList.Add(formatter);
     50        formattersComboBox.Items.Add(formatter.Name);
     51      }
     52      formattersComboBox.SelectedIndex = selectedIndex;
    4053    }
    4154
    4255    protected override void OnContentChanged() {
    4356      base.OnContentChanged();
    44       if (Content == null)
     57      UpdateTextbox();
     58    }
     59
     60    private void UpdateTextbox() {
     61      if (Content == null || formattersComboBox.SelectedIndex < 0)
    4562        textBox.Text = string.Empty;
    4663      else
    47         textBox.Text = treeFormatter.Format(Content);
     64        textBox.Text = treeFormattersList[formattersComboBox.SelectedIndex].Format(Content);
    4865    }
    4966
     
    5370      textBox.ReadOnly = ReadOnly;
    5471    }
     72
     73    private void formattersComboBox_SelectedIndexChanged(object sender, System.EventArgs e) {
     74      UpdateTextbox();
     75    }
    5576  }
    5677}
Note: See TracChangeset for help on using the changeset viewer.