Changeset 5416 for trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.3/SymbolicExpressionView.cs
- Timestamp:
- 02/03/11 17:16:31 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.3/SymbolicExpressionView.cs
r4068 r5416 23 23 using HeuristicLab.MainForm; 24 24 using HeuristicLab.MainForm.WindowsForms; 25 using HeuristicLab.PluginInfrastructure; 26 using System.Collections.Generic; 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Formatters; 25 28 26 29 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views { … … 28 31 [Content(typeof(SymbolicExpressionTree), false)] 29 32 public partial class SymbolicExpressionView : AsynchronousContentView { 30 private SymbolicExpressionTreeStringFormatter treeFormatter; 33 34 List<ISymbolicExpressionTreeStringFormatter> treeFormattersList = new List<ISymbolicExpressionTreeStringFormatter>(); 31 35 32 36 public new SymbolicExpressionTree Content { … … 37 41 public SymbolicExpressionView() { 38 42 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; 40 53 } 41 54 42 55 protected override void OnContentChanged() { 43 56 base.OnContentChanged(); 44 if (Content == null) 57 UpdateTextbox(); 58 } 59 60 private void UpdateTextbox() { 61 if (Content == null || formattersComboBox.SelectedIndex < 0) 45 62 textBox.Text = string.Empty; 46 63 else 47 textBox.Text = treeFormatter .Format(Content);64 textBox.Text = treeFormattersList[formattersComboBox.SelectedIndex].Format(Content); 48 65 } 49 66 … … 53 70 textBox.ReadOnly = ReadOnly; 54 71 } 72 73 private void formattersComboBox_SelectedIndexChanged(object sender, System.EventArgs e) { 74 UpdateTextbox(); 75 } 55 76 } 56 77 }
Note: See TracChangeset
for help on using the changeset viewer.