Changeset 7215 for branches/HeuristicLab.Hive.Azure/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarAllowedChildSymbolsControl.cs
- Timestamp:
- 12/20/11 13:54:57 (13 years ago)
- Location:
- branches/HeuristicLab.Hive.Azure
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive.Azure
- Property svn:ignore
-
old new 4 4 *.suo 5 5 *.vsp 6 Doxygen 6 7 Google.ProtocolBuffers-0.9.1.dll 7 8 HeuristicLab 3.3.5.1.ReSharper.user 8 9 HeuristicLab 3.3.6.0.ReSharper.user 9 10 HeuristicLab.4.5.resharper.user 11 HeuristicLab.ExtLibs.6.0.ReSharper.user 10 12 HeuristicLab.resharper.user 11 13 ProtoGen.exe … … 16 18 bin 17 19 protoc.exe 18 HeuristicLab.ExtLibs.6.0.ReSharper.user19 Doxygen
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/HeuristicLab.Hive.Azure/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarAllowedChildSymbolsControl.cs
r6803 r7215 66 66 private void RegisterGrammarEvents() { 67 67 grammar.Changed += new EventHandler(Grammar_Changed); 68 grammar.ReadOnlyChanged += new EventHandler(Grammar_ReadOnlyChanged); 68 69 } 69 70 private void DeregisterGrammarEvents() { 70 71 grammar.Changed -= new EventHandler(Grammar_Changed); 72 grammar.ReadOnlyChanged -= new EventHandler(Grammar_ReadOnlyChanged); 71 73 } 72 74 … … 78 80 } 79 81 82 private void Grammar_ReadOnlyChanged(object sender, EventArgs e) { 83 if (InvokeRequired) Invoke((MethodInvoker)BuildAllowedChildSymbolsTree); 84 else BuildAllowedChildSymbolsTree(); 85 } 86 80 87 private void OnGrammarChanged() { 81 88 if (Grammar == null) { … … 90 97 91 98 private void BuildAllowedChildSymbolsTree() { 99 if (Symbol == null) { 100 symbolicExpressionTreeChart.Tree = null; 101 return; 102 } 103 92 104 var tree = new SymbolicExpressionTree(new SymbolicExpressionTreeNode(Symbol)); 93 94 105 symbolicExpressionTreeChart.SuspendRepaint = true; 95 106 if (Grammar.GetMaximumSubtreeCount(Symbol) > 0) { 96 107 for (int i = 0; i < Grammar.GetMaximumSubtreeCount(Symbol); i++) { 97 108 var node = new DummySymbol("Subtree " + i).CreateTreeNode(); 109 var groupSymbols = grammar.GetAllowedChildSymbols(Symbol, i).OfType<GroupSymbol>().ToList(); 98 110 foreach (var childSymbol in Grammar.GetAllowedChildSymbols(Symbol, i)) { 99 node.AddSubtree(new SymbolicExpressionTreeNode(childSymbol)); 111 if (!groupSymbols.Any(g => g != childSymbol && g.Flatten().Contains(childSymbol))) 112 node.AddSubtree(new SymbolicExpressionTreeNode(childSymbol)); 100 113 } 101 114 tree.Root.AddSubtree(node); … … 144 157 145 158 private void symbolicExpressionTreeChart_SymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) { 159 if (Grammar.ReadOnly) return; 146 160 if ((Control.ModifierKeys & Keys.Control) == 0) 147 161 selectedSymbolicExpressionTreeNodes.Clear(); … … 160 174 161 175 private void symbolicExpressionTreeChart_KeyDown(object sender, KeyEventArgs e) { 176 if (Grammar.ReadOnly) return; 162 177 if (e.KeyCode == Keys.Delete) { 163 178 var root = symbolicExpressionTreeChart.Tree.Root; … … 177 192 private void symbolicExpressionTreeChart_DragEnter(object sender, DragEventArgs e) { 178 193 validDragOperation = false; 194 if (Grammar.ReadOnly) return; 195 179 196 var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 180 197 var symbol = data as ISymbol; … … 192 209 var node = visualNode.SymbolicExpressionTreeNode; 193 210 var root = symbolicExpressionTreeChart.Tree.Root; 194 if (root.Symbol is ProgramRootSymbol) return;195 211 if (node == root || node.Parent == root) e.Effect = DragDropEffects.Copy; 196 212 } … … 257 273 decreaseMaximumSubtreeCountRectangle = new RectangleF(visualRootNode.X + visualRootNode.Width + spacing, visualRootNode.Y + size + 2 * spacing, size, size); 258 274 259 pen.Color = Grammar. GetMaximumSubtreeCount(rootNode.Symbol) == Grammar.GetMinimumSubtreeCount(rootNode.Symbol) ? Color.LightGray : Color.Black;275 pen.Color = Grammar.ReadOnly || Grammar.GetMaximumSubtreeCount(rootNode.Symbol) == Grammar.GetMinimumSubtreeCount(rootNode.Symbol) ? Color.LightGray : Color.Black; 260 276 graphics.DrawString("+", font, pen.Brush, increaseMinimumSubtreeCountRectangle, stringFormat); 261 277 graphics.DrawRectangle(pen, Rectangle.Round(increaseMinimumSubtreeCountRectangle)); 262 278 if (pen.Color == Color.LightGray) increaseMinimumSubtreeCountRectangle = RectangleF.Empty; 263 279 264 pen.Color = Grammar. GetMinimumSubtreeCount(rootNode.Symbol) == rootNode.Symbol.MinimumArity ? Color.LightGray : Color.Black;280 pen.Color = Grammar.ReadOnly || Grammar.GetMinimumSubtreeCount(rootNode.Symbol) == rootNode.Symbol.MinimumArity ? Color.LightGray : Color.Black; 265 281 graphics.DrawString("-", font, pen.Brush, decreaseMinimumSubtreeCountRectangle, stringFormat); 266 282 graphics.DrawRectangle(pen, Rectangle.Round(decreaseMinimumSubtreeCountRectangle)); 267 283 if (pen.Color == Color.LightGray) decreaseMinimumSubtreeCountRectangle = RectangleF.Empty; 268 284 269 pen.Color = Grammar. GetMaximumSubtreeCount(rootNode.Symbol) == rootNode.Symbol.MaximumArity ? Color.LightGray : Color.Black;285 pen.Color = Grammar.ReadOnly || Grammar.GetMaximumSubtreeCount(rootNode.Symbol) == rootNode.Symbol.MaximumArity ? Color.LightGray : Color.Black; 270 286 graphics.DrawRectangle(pen, Rectangle.Round(increaseMaximumSubtreeCountRectangle)); 271 287 graphics.DrawString("+", font, pen.Brush, increaseMaximumSubtreeCountRectangle, stringFormat); 272 288 if (pen.Color == Color.LightGray) increaseMaximumSubtreeCountRectangle = RectangleF.Empty; 273 289 274 pen.Color = Grammar. GetMaximumSubtreeCount(rootNode.Symbol) == Grammar.GetMinimumSubtreeCount(rootNode.Symbol) ? Color.LightGray : Color.Black;290 pen.Color = Grammar.ReadOnly || Grammar.GetMaximumSubtreeCount(rootNode.Symbol) == Grammar.GetMinimumSubtreeCount(rootNode.Symbol) ? Color.LightGray : Color.Black; 275 291 graphics.DrawRectangle(pen, Rectangle.Round(decreaseMaximumSubtreeCountRectangle)); 276 292 graphics.DrawString("-", font, pen.Brush, decreaseMaximumSubtreeCountRectangle, stringFormat); … … 281 297 282 298 private void allowedChildSymbolsControl_MouseDown(object sender, MouseEventArgs e) { 283 if (Grammar == null ) return;299 if (Grammar == null || Grammar.ReadOnly) return; 284 300 if (symbolicExpressionTreeChart.Tree == null) return; 285 301
Note: See TracChangeset
for help on using the changeset viewer.