1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Drawing;
|
---|
4 | using System.Text;
|
---|
5 | using System.Windows.Forms;
|
---|
6 | using HeuristicLab.Collections;
|
---|
7 | using HeuristicLab.Core;
|
---|
8 | using HeuristicLab.Data;
|
---|
9 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
10 | using HeuristicLab.MainForm;
|
---|
11 | using HeuristicLab.MainForm.WindowsForms;
|
---|
12 |
|
---|
13 | namespace 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 | }
|
---|