Changeset 18068 for branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/StructureTemplate/StructureTemplateView.cs
- Timestamp:
- 10/15/21 17:00:28 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/StructureTemplate/StructureTemplateView.cs
r18067 r18068 24 24 public StructureTemplateView() { 25 25 InitializeComponent(); 26 errorLabel.Text = ""; 27 treeChart.SymbolicExpressionTreeNodeClicked += TreeChart_SymbolicExpressionTreeNodeClicked; 26 infoLabel.Text = ""; 27 treeChart.SymbolicExpressionTreeNodeClicked += SymbolicExpressionTreeNodeClicked; 28 28 29 } 29 30 30 private void TreeChart_SymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {31 private void SymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) { 31 32 var visualTreeNode = sender as VisualTreeNode<ISymbolicExpressionTreeNode>; 32 33 if(visualTreeNode != null) { 33 34 var subFunctionTreeNode = visualTreeNode.Content as SubFunctionTreeNode; 34 viewHost.Content = subFunctionTreeNode?.SubFunction; 35 if(Content.SubFunctions.TryGetValue(subFunctionTreeNode.Name, out SubFunction subFunction)) 36 viewHost.Content = subFunction; 35 37 } 36 38 } … … 39 41 base.OnContentChanged(); 40 42 if (Content == null) return; 41 42 43 expressionInput.Text = Content.Template; 43 symRegTreeChart.Content = Content.Tree; 44 45 treeChart.Tree = Content.Tree; 46 47 errorLabel.Text = ""; 48 44 PaintTree(); 45 infoLabel.Text = ""; 49 46 } 50 47 51 private void parseButton_Click(object sender, EventArgs e) {48 private void ParseButtonClick(object sender, EventArgs e) { 52 49 if(!string.IsNullOrEmpty(expressionInput.Text)) { 53 50 try { 54 51 Content.Template = expressionInput.Text; 55 symRegTreeChart.Content = Content.Tree; 56 treeChart.Tree = Content.Tree; 57 58 errorLabel.Text = "Template structure successfully parsed."; 59 errorLabel.ForeColor = Color.DarkGreen; 52 PaintTree(); 53 infoLabel.Text = "Template structure successfully parsed."; 54 infoLabel.ForeColor = Color.DarkGreen; 60 55 } catch (Exception ex) { 61 errorLabel.Text = ex.Message;62 errorLabel.ForeColor = Color.DarkRed;56 infoLabel.Text = ex.Message; 57 infoLabel.ForeColor = Color.DarkRed; 63 58 } 64 59 } 65 60 } 66 61 67 private void expressionInput_TextChanged(object sender, EventArgs e) {68 errorLabel.Text = "Unparsed changes! Press parse button to save changes.";69 errorLabel.ForeColor = Color.DarkOrange;62 private void ExpressionInputTextChanged(object sender, EventArgs e) { 63 infoLabel.Text = "Unparsed changes! Press parse button to save changes."; 64 infoLabel.ForeColor = Color.DarkOrange; 70 65 } 71 66 67 68 private void PaintTree() { 69 if(Content != null && Content.Tree != null) { 70 treeChart.Tree = Content.Tree; 71 foreach (var n in Content.Tree.IterateNodesPrefix()) { 72 if (n.Symbol is SubFunctionSymbol) { 73 var visualNode = treeChart.GetVisualSymbolicExpressionTreeNode(n); 74 visualNode.FillColor = Color.LightCyan; 75 visualNode.LineColor = Color.SlateGray; 76 } 77 } 78 treeChart.RepaintNodes(); 79 } 80 } 72 81 } 73 82 }
Note: See TracChangeset
for help on using the changeset viewer.