Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/StructureTemplate/StructureTemplateView.cs @ 18063

Last change on this file since 18063 was 18063, checked in by dpiringe, 3 years ago

#3136

  • added view components and classes for sub functions
File size: 1.7 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Drawing;
4using System.Text;
5using System.Windows.Forms;
6using HeuristicLab.Collections;
7using HeuristicLab.Core;
8using HeuristicLab.Data;
9using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
10using HeuristicLab.MainForm;
11using HeuristicLab.MainForm.WindowsForms;
12
13namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
14
15  [View("StructureTemplate View")]
16  [Content(typeof(StructureTemplate), true)]
17  public partial class StructureTemplateView : AsynchronousContentView {
18    public new StructureTemplate Content {
19      get => (StructureTemplate)base.Content;
20      set => base.Content = value;
21    }
22
23
24    public StructureTemplateView() {
25      InitializeComponent();
26      errorLabel.Text = "";
27    }
28
29    private void parseButton_Click(object sender, EventArgs e) {
30      if(!string.IsNullOrEmpty(expressionInput.Text)) {
31        try {
32          Content.Template = expressionInput.Text;
33          symRegTreeChart.Content = Content.Tree;
34
35          var subFunctionList = new ItemList<SubFunction>();
36          foreach (var func in Content.SubFunctions)
37            subFunctionList.Add(func);
38          subFunctionListView.Content = subFunctionList.AsReadOnly();
39
40          errorLabel.Text = "Template structure successfully parsed.";
41          errorLabel.ForeColor = Color.DarkGreen;
42        } catch (Exception ex) {
43          errorLabel.Text = ex.Message;
44          errorLabel.ForeColor = Color.DarkRed;
45        }
46      }
47    }
48
49    private void expressionInput_TextChanged(object sender, EventArgs e) {
50      errorLabel.Text = "Unparsed changes! Press parse button to save changes.";
51      errorLabel.ForeColor = Color.DarkOrange;
52    }
53
54  }
55}
Note: See TracBrowser for help on using the repository browser.