Changeset 6377 for branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4
- Timestamp:
- 06/07/11 12:49:03 (13 years ago)
- Location:
- branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.Designer.cs
r6337 r6377 31 31 this.imageList = new System.Windows.Forms.ImageList(this.components); 32 32 this.splitContainer2 = new System.Windows.Forms.SplitContainer(); 33 this.symbol ViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();33 this.symbolDetailsViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 34 34 this.showDetailsCheckBox = new System.Windows.Forms.CheckBox(); 35 35 this.removeButton = new System.Windows.Forms.Button(); 36 36 this.addButton = new System.Windows.Forms.Button(); 37 this. symbolicExpressionTreeChart= new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart();37 this.allowedChildSymbolsControl = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart(); 38 38 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 39 39 this.grpSymbols.SuspendLayout(); … … 60 60 // grpSymbols 61 61 // 62 this.grpSymbols.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 63 | System.Windows.Forms.AnchorStyles.Left) 62 this.grpSymbols.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 63 | System.Windows.Forms.AnchorStyles.Left) 64 64 | System.Windows.Forms.AnchorStyles.Right))); 65 65 this.grpSymbols.Controls.Add(this.splitContainer1); … … 93 93 // symbolsTreeView 94 94 // 95 this.symbolsTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 96 | System.Windows.Forms.AnchorStyles.Left) 95 this.symbolsTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 96 | System.Windows.Forms.AnchorStyles.Left) 97 97 | System.Windows.Forms.AnchorStyles.Right))); 98 98 this.symbolsTreeView.CheckBoxes = true; … … 123 123 // splitContainer2.Panel1 124 124 // 125 this.splitContainer2.Panel1.Controls.Add(this. symbolicExpressionTreeChart);125 this.splitContainer2.Panel1.Controls.Add(this.allowedChildSymbolsControl); 126 126 // 127 127 // splitContainer2.Panel2 128 128 // 129 this.splitContainer2.Panel2.Controls.Add(this.symbol ViewHost);129 this.splitContainer2.Panel2.Controls.Add(this.symbolDetailsViewHost); 130 130 this.splitContainer2.Size = new System.Drawing.Size(568, 359); 131 131 this.splitContainer2.SplitterDistance = 165; … … 134 134 // symbolViewHost 135 135 // 136 this.symbol ViewHost.Caption = "View";137 this.symbol ViewHost.Content = null;138 this.symbol ViewHost.Dock = System.Windows.Forms.DockStyle.Fill;139 this.symbol ViewHost.Enabled = false;140 this.symbol ViewHost.Location = new System.Drawing.Point(0, 0);141 this.symbol ViewHost.Name = "symbolViewHost";142 this.symbol ViewHost.ReadOnly = false;143 this.symbol ViewHost.Size = new System.Drawing.Size(568, 190);144 this.symbol ViewHost.TabIndex = 0;145 this.symbol ViewHost.ViewsLabelVisible = true;146 this.symbol ViewHost.ViewType = null;136 this.symbolDetailsViewHost.Caption = "View"; 137 this.symbolDetailsViewHost.Content = null; 138 this.symbolDetailsViewHost.Dock = System.Windows.Forms.DockStyle.Fill; 139 this.symbolDetailsViewHost.Enabled = false; 140 this.symbolDetailsViewHost.Location = new System.Drawing.Point(0, 0); 141 this.symbolDetailsViewHost.Name = "symbolViewHost"; 142 this.symbolDetailsViewHost.ReadOnly = false; 143 this.symbolDetailsViewHost.Size = new System.Drawing.Size(568, 190); 144 this.symbolDetailsViewHost.TabIndex = 0; 145 this.symbolDetailsViewHost.ViewsLabelVisible = true; 146 this.symbolDetailsViewHost.ViewType = null; 147 147 // 148 148 // showDetailsCheckBox … … 151 151 this.showDetailsCheckBox.Checked = true; 152 152 this.showDetailsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; 153 this.showDetailsCheckBox.Image = ((System.Drawing.Image)(resources.GetObject("showDetailsCheckBox.Image")));153 this.showDetailsCheckBox.Image = HeuristicLab.Common.Resources.VSImageLibrary.Properties; 154 154 this.showDetailsCheckBox.Location = new System.Drawing.Point(63, 3); 155 155 this.showDetailsCheckBox.Name = "showDetailsCheckBox"; … … 163 163 // 164 164 this.removeButton.Enabled = false; 165 this.removeButton.Image = ((System.Drawing.Image)(resources.GetObject("removeButton.Image")));165 this.removeButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Remove; 166 166 this.removeButton.Location = new System.Drawing.Point(33, 3); 167 167 this.removeButton.Name = "removeButton"; … … 174 174 // addButton 175 175 // 176 this.addButton.Image = ((System.Drawing.Image)(resources.GetObject("addButton.Image")));176 this.addButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Add; 177 177 this.addButton.Location = new System.Drawing.Point(3, 3); 178 178 this.addButton.Name = "addButton"; … … 185 185 // symbolicExpressionTreeChart 186 186 // 187 this. symbolicExpressionTreeChart.AllowDrop = true;188 this. symbolicExpressionTreeChart.BackgroundColor = System.Drawing.Color.White;189 this. symbolicExpressionTreeChart.Dock = System.Windows.Forms.DockStyle.Fill;190 this. symbolicExpressionTreeChart.LineColor = System.Drawing.Color.Black;191 this. symbolicExpressionTreeChart.Location = new System.Drawing.Point(0, 0);192 this. symbolicExpressionTreeChart.Name = "symbolicExpressionTreeChart";193 this. symbolicExpressionTreeChart.Size = new System.Drawing.Size(568, 165);194 this. symbolicExpressionTreeChart.Spacing = 5;195 this. symbolicExpressionTreeChart.TabIndex = 0;196 this. symbolicExpressionTreeChart.TextFont = new System.Drawing.Font("Times New Roman", 8F);197 this. symbolicExpressionTreeChart.Tree = null;198 this. symbolicExpressionTreeChart.SymbolicExpressionTreeNodeClicked += new System.Windows.Forms.MouseEventHandler(this.symbolicExpressionTreeChart_SymbolicExpressionTreeNodeClicked);199 this. symbolicExpressionTreeChart.DragDrop += new System.Windows.Forms.DragEventHandler(this.symbolicExpressionTreeChart_DragDrop);200 this. symbolicExpressionTreeChart.DragEnter += new System.Windows.Forms.DragEventHandler(this.symbolicExpressionTreeChart_DragEnter);201 this. symbolicExpressionTreeChart.DragOver += new System.Windows.Forms.DragEventHandler(this.symbolicExpressionTreeChart_DragOver);202 this. symbolicExpressionTreeChart.KeyDown += new System.Windows.Forms.KeyEventHandler(this.symbolicExpressionTreeChart_KeyDown);187 this.allowedChildSymbolsControl.AllowDrop = true; 188 this.allowedChildSymbolsControl.BackgroundColor = System.Drawing.Color.White; 189 this.allowedChildSymbolsControl.Dock = System.Windows.Forms.DockStyle.Fill; 190 this.allowedChildSymbolsControl.LineColor = System.Drawing.Color.Black; 191 this.allowedChildSymbolsControl.Location = new System.Drawing.Point(0, 0); 192 this.allowedChildSymbolsControl.Name = "symbolicExpressionTreeChart"; 193 this.allowedChildSymbolsControl.Size = new System.Drawing.Size(568, 165); 194 this.allowedChildSymbolsControl.Spacing = 5; 195 this.allowedChildSymbolsControl.TabIndex = 0; 196 this.allowedChildSymbolsControl.TextFont = new System.Drawing.Font("Times New Roman", 8F); 197 this.allowedChildSymbolsControl.Tree = null; 198 this.allowedChildSymbolsControl.SymbolicExpressionTreeNodeClicked += new System.Windows.Forms.MouseEventHandler(this.symbolicExpressionTreeChart_SymbolicExpressionTreeNodeClicked); 199 this.allowedChildSymbolsControl.DragDrop += new System.Windows.Forms.DragEventHandler(this.symbolicExpressionTreeChart_DragDrop); 200 this.allowedChildSymbolsControl.DragEnter += new System.Windows.Forms.DragEventHandler(this.symbolicExpressionTreeChart_DragEnter); 201 this.allowedChildSymbolsControl.DragOver += new System.Windows.Forms.DragEventHandler(this.symbolicExpressionTreeChart_DragOver); 202 this.allowedChildSymbolsControl.KeyDown += new System.Windows.Forms.KeyEventHandler(this.symbolicExpressionTreeChart_KeyDown); 203 203 // 204 204 // SymbolicExpressionGrammarEditorView … … 233 233 private System.Windows.Forms.TreeView symbolsTreeView; 234 234 private System.Windows.Forms.SplitContainer splitContainer2; 235 private SymbolicExpressionTreeChart symbolicExpressionTreeChart;236 private MainForm.WindowsForms.ViewHost symbol ViewHost;235 private SymbolicExpressionTreeChart allowedChildSymbolsControl; 236 private MainForm.WindowsForms.ViewHost symbolDetailsViewHost; 237 237 private System.Windows.Forms.ImageList imageList; 238 238 protected System.Windows.Forms.CheckBox showDetailsCheckBox; -
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.cs
r6337 r6377 82 82 if (symbol != null && Content.ContainsSymbol(symbol)) { 83 83 BuildAllowedChildSymbolsTree(symbol); 84 symbol ViewHost.Content = symbol;84 symbolDetailsViewHost.Content = symbol; 85 85 symbolsTreeView.SelectedNode = IterateSymbolTreeNodes().Where(n => n.Tag == symbol).ToList().FirstOrDefault(); 86 86 } … … 96 96 if (Content != null) { 97 97 RebuildSymbolsTreeView(); 98 symbolicExpressionTreeChart.Tree = null;99 symbol ViewHost.Content = null;98 allowedChildSymbolsControl.Tree = null; 99 symbolDetailsViewHost.Content = null; 100 100 } else { 101 101 symbolsTreeView.Nodes.Clear(); 102 symbolicExpressionTreeChart.Tree = null;103 symbol ViewHost.Content = null;102 allowedChildSymbolsControl.Tree = null; 103 symbolDetailsViewHost.Content = null; 104 104 } 105 105 } … … 121 121 if (e.Action != TreeViewAction.Unknown) { 122 122 var symbol = (ISymbol)e.Node.Tag; 123 symbol ViewHost.Content = symbol;123 symbolDetailsViewHost.Content = symbol; 124 124 selectedSymbolicExpressionTreeNodes.Clear(); 125 125 BuildAllowedChildSymbolsTree(symbol); … … 168 168 } 169 169 } 170 symbolicExpressionTreeChart.Tree = tree;170 allowedChildSymbolsControl.Tree = tree; 171 171 UpdateSelectedSymbolicExpressionTreeNodes(); 172 172 } … … 191 191 if (e.KeyCode == Keys.Delete) { 192 192 DeregisterContentEvents(); 193 var root = symbolicExpressionTreeChart.Tree.Root;193 var root = allowedChildSymbolsControl.Tree.Root; 194 194 foreach (var node in selectedSymbolicExpressionTreeNodes) { 195 195 int argIndex = root.IndexOfSubtree(node.Parent); … … 216 216 var symbol = data as ISymbol; 217 217 var symbols = data as IEnumerable<ISymbol>; 218 if (symbol != null && Content.ContainsSymbol(symbol)) validDragOperation = true; 219 else if (symbols != null && symbols.All(s => Content.ContainsSymbol(s))) validDragOperation = true; 220 } 221 218 if (symbol != null && !(symbol is IReadOnlySymbol) && !Content.ContainsSymbol(symbol)) validDragOperation = true; 219 else if (symbols != null && symbols.All(s => !(symbol is IReadOnlySymbol) && Content.ContainsSymbol(s))) validDragOperation = true; 220 } 222 221 223 222 private void symbolicExpressionTreeChart_DragOver(object sender, DragEventArgs e) { 224 223 e.Effect = DragDropEffects.None; 225 224 if (validDragOperation) { 226 Point coordinates = symbolicExpressionTreeChart.PointToClient(new Point(e.X, e.Y));227 var visualNode = symbolicExpressionTreeChart.FindVisualSymbolicExpressionTreeNodeAt(coordinates.X, coordinates.Y);225 Point coordinates = allowedChildSymbolsControl.PointToClient(new Point(e.X, e.Y)); 226 var visualNode = allowedChildSymbolsControl.FindVisualSymbolicExpressionTreeNodeAt(coordinates.X, coordinates.Y); 228 227 if (visualNode != null) { 229 228 var node = visualNode.SymbolicExpressionTreeNode; 230 var root = symbolicExpressionTreeChart.Tree.Root; 229 var root = allowedChildSymbolsControl.Tree.Root; 230 if (root.Symbol is ProgramRootSymbol) return; 231 231 if (node == root || node.Parent == root) e.Effect = DragDropEffects.Copy; 232 232 } … … 235 235 236 236 private void symbolicExpressionTreeChart_DragDrop(object sender, DragEventArgs e) { 237 Point coordinates = symbolicExpressionTreeChart.PointToClient(new Point(e.X, e.Y));238 var node = symbolicExpressionTreeChart.FindVisualSymbolicExpressionTreeNodeAt(coordinates.X, coordinates.Y);239 var root = symbolicExpressionTreeChart.Tree.Root;237 Point coordinates = allowedChildSymbolsControl.PointToClient(new Point(e.X, e.Y)); 238 var node = allowedChildSymbolsControl.FindVisualSymbolicExpressionTreeNodeAt(coordinates.X, coordinates.Y); 239 var root = allowedChildSymbolsControl.Tree.Root; 240 240 241 241 var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); … … 261 261 262 262 private void UpdateSelectedSymbolicExpressionTreeNodes() { 263 foreach (var node in symbolicExpressionTreeChart.Tree.IterateNodesPrefix()) {264 var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);263 foreach (var node in allowedChildSymbolsControl.Tree.IterateNodesPrefix()) { 264 var visualNode = allowedChildSymbolsControl.GetVisualSymbolicExpressionTreeNode(node); 265 265 if (!selectedSymbolicExpressionTreeNodes.Contains(node)) { 266 266 visualNode.FillColor = Color.White; … … 271 271 } 272 272 } 273 symbolicExpressionTreeChart.Repaint();273 allowedChildSymbolsControl.Repaint(); 274 274 } 275 275 … … 291 291 i++; 292 292 } 293 Content.AddSymbol(symbol); 293 294 var selectedNode = symbolsTreeView.SelectedNode; 295 GroupSymbol groupSymbol = null; 296 while (selectedNode != null) { 297 groupSymbol = selectedNode.Tag as GroupSymbol; 298 if (groupSymbol != null && Content.ContainsSymbol(groupSymbol)) break; 299 } 300 301 if (groupSymbol != null && Content.ContainsSymbol(groupSymbol)) groupSymbol.SymbolsCollection.Add(symbol); 302 else Content.AddSymbol(symbol); 294 303 } 295 304 catch (Exception ex) { … … 304 313 Content.RemoveSymbol(symbol); 305 314 removeButton.Enabled = false; 315 allowedChildSymbolsControl.Tree = null; 316 symbolDetailsViewHost.Content = null; 306 317 } 307 318 -
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs
r6337 r6377 24 24 using System.Drawing; 25 25 using System.Drawing.Imaging; 26 using System.Linq;27 26 using System.Windows.Forms; 28 27 … … 263 262 264 263 //draw terminal node 265 if (node.Subtrees .Count()== 0) {264 if (node.SubtreesCount == 0) { 266 265 graphics.FillRectangle(nodeFillBrush, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height); 267 266 graphics.DrawRectangle(nodeLinePen, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height); … … 281 280 //calculate areas for the subtrees according to their tree size and call drawFunctionTree 282 281 Point connectFrom = new Point(visualTreeNode.X + visualTreeNode.Width / 2, visualTreeNode.Y + visualTreeNode.Height); 283 int[] xBoundaries = new int[node.Subtrees .Count()+ 1];282 int[] xBoundaries = new int[node.SubtreesCount + 1]; 284 283 xBoundaries[0] = x; 285 for (int i = 0; i < node.Subtrees .Count(); i++) {286 xBoundaries[i + 1] = (int)(xBoundaries[i] + (width * (double)node. Subtrees.ElementAt(i).GetLength()) / (node.GetLength() - 1));287 DrawFunctionTree(node. Subtrees.ElementAt(i), graphics, xBoundaries[i], y + height,284 for (int i = 0; i < node.SubtreesCount; i++) { 285 xBoundaries[i + 1] = (int)(xBoundaries[i] + (width * (double)node.GetSubtree(i).GetLength()) / (node.GetLength() - 1)); 286 DrawFunctionTree(node.GetSubtree(i), graphics, xBoundaries[i], y + height, 288 287 xBoundaries[i + 1] - xBoundaries[i], height, connectFrom); 289 288 }
Note: See TracChangeset
for help on using the changeset viewer.