- Timestamp:
- 10/15/21 17:00:28 (3 years ago)
- Location:
- branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/StructureTemplate
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/StructureTemplate/StructureTemplateView.Designer.cs
r18067 r18068 30 30 this.expressionInput = new System.Windows.Forms.TextBox(); 31 31 this.parseButton = new System.Windows.Forms.Button(); 32 this.errorLabel = new System.Windows.Forms.Label(); 33 this.symRegTreeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.GraphicalSymbolicExpressionTreeView(); 32 this.infoLabel = new System.Windows.Forms.Label(); 34 33 this.templateStructureGroupBox = new System.Windows.Forms.GroupBox(); 35 34 this.treeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart(); 36 35 this.splitContainer = new System.Windows.Forms.SplitContainer(); 36 this.detailsGroupBox = new System.Windows.Forms.GroupBox(); 37 37 this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 38 38 this.templateStructureGroupBox.SuspendLayout(); … … 41 41 this.splitContainer.Panel2.SuspendLayout(); 42 42 this.splitContainer.SuspendLayout(); 43 this.detailsGroupBox.SuspendLayout(); 43 44 this.SuspendLayout(); 44 45 // … … 51 52 this.expressionInput.Size = new System.Drawing.Size(288, 20); 52 53 this.expressionInput.TabIndex = 1; 53 this.expressionInput.TextChanged += new System.EventHandler(this. expressionInput_TextChanged);54 this.expressionInput.TextChanged += new System.EventHandler(this.ExpressionInputTextChanged); 54 55 // 55 56 // parseButton … … 61 62 this.parseButton.Text = "Parse"; 62 63 this.parseButton.UseVisualStyleBackColor = true; 63 this.parseButton.Click += new System.EventHandler(this. parseButton_Click);64 this.parseButton.Click += new System.EventHandler(this.ParseButtonClick); 64 65 // 65 66 // errorLabel 66 67 // 67 this.errorLabel.AutoSize = true; 68 this.errorLabel.Location = new System.Drawing.Point(155, 50); 69 this.errorLabel.Name = "errorLabel"; 70 this.errorLabel.Size = new System.Drawing.Size(54, 13); 71 this.errorLabel.TabIndex = 4; 72 this.errorLabel.Text = "errorLabel"; 73 // 74 // symRegTreeChart 75 // 76 this.symRegTreeChart.AllowDrop = true; 77 this.symRegTreeChart.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 78 | System.Windows.Forms.AnchorStyles.Right))); 79 this.symRegTreeChart.Caption = "Graphical SymbolicExpressionTree View"; 80 this.symRegTreeChart.Content = null; 81 this.symRegTreeChart.Location = new System.Drawing.Point(6, 74); 82 this.symRegTreeChart.Name = "symRegTreeChart"; 83 this.symRegTreeChart.ReadOnly = false; 84 this.symRegTreeChart.Size = new System.Drawing.Size(288, 153); 85 this.symRegTreeChart.TabIndex = 6; 68 this.infoLabel.AutoSize = true; 69 this.infoLabel.Location = new System.Drawing.Point(155, 50); 70 this.infoLabel.Name = "errorLabel"; 71 this.infoLabel.Size = new System.Drawing.Size(54, 13); 72 this.infoLabel.TabIndex = 4; 73 this.infoLabel.Text = "errorLabel"; 86 74 // 87 75 // templateStructureGroupBox 88 76 // 89 77 this.templateStructureGroupBox.Controls.Add(this.treeChart); 90 this.templateStructureGroupBox.Controls.Add(this.symRegTreeChart);91 78 this.templateStructureGroupBox.Controls.Add(this.parseButton); 92 this.templateStructureGroupBox.Controls.Add(this. errorLabel);79 this.templateStructureGroupBox.Controls.Add(this.infoLabel); 93 80 this.templateStructureGroupBox.Controls.Add(this.expressionInput); 94 81 this.templateStructureGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; … … 102 89 // treeChart 103 90 // 104 this.treeChart.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 91 this.treeChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 92 | System.Windows.Forms.AnchorStyles.Left) 105 93 | System.Windows.Forms.AnchorStyles.Right))); 106 94 this.treeChart.BackgroundColor = System.Drawing.Color.White; 107 95 this.treeChart.LineColor = System.Drawing.Color.Black; 108 this.treeChart.Location = new System.Drawing.Point(6, 233);96 this.treeChart.Location = new System.Drawing.Point(6, 74); 109 97 this.treeChart.MinimumHorizontalDistance = 30; 110 98 this.treeChart.MinimumHorizontalPadding = 20; … … 114 102 this.treeChart.PreferredNodeHeight = 46; 115 103 this.treeChart.PreferredNodeWidth = 70; 116 this.treeChart.Size = new System.Drawing.Size(288, 150);104 this.treeChart.Size = new System.Drawing.Size(288, 320); 117 105 this.treeChart.SuspendRepaint = false; 118 106 this.treeChart.TabIndex = 7; … … 134 122 // splitContainer.Panel2 135 123 // 136 this.splitContainer.Panel2.Controls.Add(this. viewHost);124 this.splitContainer.Panel2.Controls.Add(this.detailsGroupBox); 137 125 this.splitContainer.Panel2MinSize = 5; 138 126 this.splitContainer.Size = new System.Drawing.Size(600, 400); 139 127 this.splitContainer.SplitterDistance = 300; 140 128 this.splitContainer.TabIndex = 10; 129 // 130 // detailsGroupBox 131 // 132 this.detailsGroupBox.Controls.Add(this.viewHost); 133 this.detailsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; 134 this.detailsGroupBox.Location = new System.Drawing.Point(0, 0); 135 this.detailsGroupBox.Name = "detailsGroupBox"; 136 this.detailsGroupBox.Size = new System.Drawing.Size(296, 400); 137 this.detailsGroupBox.TabIndex = 9; 138 this.detailsGroupBox.TabStop = false; 139 this.detailsGroupBox.Text = "Details"; 141 140 // 142 141 // viewHost … … 146 145 this.viewHost.Dock = System.Windows.Forms.DockStyle.Fill; 147 146 this.viewHost.Enabled = false; 148 this.viewHost.Location = new System.Drawing.Point( 0, 0);147 this.viewHost.Location = new System.Drawing.Point(3, 16); 149 148 this.viewHost.Name = "viewHost"; 150 149 this.viewHost.ReadOnly = false; 151 this.viewHost.Size = new System.Drawing.Size(29 6, 400);150 this.viewHost.Size = new System.Drawing.Size(290, 381); 152 151 this.viewHost.TabIndex = 8; 153 152 this.viewHost.ViewsLabelVisible = true; … … 167 166 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit(); 168 167 this.splitContainer.ResumeLayout(false); 168 this.detailsGroupBox.ResumeLayout(false); 169 169 this.ResumeLayout(false); 170 170 … … 174 174 private System.Windows.Forms.TextBox expressionInput; 175 175 private System.Windows.Forms.Button parseButton; 176 private System.Windows.Forms.Label errorLabel; 177 private Encodings.SymbolicExpressionTreeEncoding.Views.GraphicalSymbolicExpressionTreeView symRegTreeChart; 176 private System.Windows.Forms.Label infoLabel; 178 177 private System.Windows.Forms.GroupBox templateStructureGroupBox; 179 178 private System.Windows.Forms.SplitContainer splitContainer; 180 179 private Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart treeChart; 181 180 private MainForm.WindowsForms.ViewHost viewHost; 181 private System.Windows.Forms.GroupBox detailsGroupBox; 182 182 } 183 183 } -
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.