Changeset 7148 for trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarAllowedChildSymbolsControl.cs
- Timestamp:
- 12/07/11 13:31:42 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarAllowedChildSymbolsControl.cs
r7018 r7148 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) { … … 146 157 147 158 private void symbolicExpressionTreeChart_SymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) { 159 if (Grammar.ReadOnly) return; 148 160 if ((Control.ModifierKeys & Keys.Control) == 0) 149 161 selectedSymbolicExpressionTreeNodes.Clear(); … … 162 174 163 175 private void symbolicExpressionTreeChart_KeyDown(object sender, KeyEventArgs e) { 176 if (Grammar.ReadOnly) return; 164 177 if (e.KeyCode == Keys.Delete) { 165 178 var root = symbolicExpressionTreeChart.Tree.Root; … … 179 192 private void symbolicExpressionTreeChart_DragEnter(object sender, DragEventArgs e) { 180 193 validDragOperation = false; 194 if (Grammar.ReadOnly) return; 195 181 196 var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 182 197 var symbol = data as ISymbol; … … 258 273 decreaseMaximumSubtreeCountRectangle = new RectangleF(visualRootNode.X + visualRootNode.Width + spacing, visualRootNode.Y + size + 2 * spacing, size, size); 259 274 260 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; 261 276 graphics.DrawString("+", font, pen.Brush, increaseMinimumSubtreeCountRectangle, stringFormat); 262 277 graphics.DrawRectangle(pen, Rectangle.Round(increaseMinimumSubtreeCountRectangle)); 263 278 if (pen.Color == Color.LightGray) increaseMinimumSubtreeCountRectangle = RectangleF.Empty; 264 279 265 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; 266 281 graphics.DrawString("-", font, pen.Brush, decreaseMinimumSubtreeCountRectangle, stringFormat); 267 282 graphics.DrawRectangle(pen, Rectangle.Round(decreaseMinimumSubtreeCountRectangle)); 268 283 if (pen.Color == Color.LightGray) decreaseMinimumSubtreeCountRectangle = RectangleF.Empty; 269 284 270 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; 271 286 graphics.DrawRectangle(pen, Rectangle.Round(increaseMaximumSubtreeCountRectangle)); 272 287 graphics.DrawString("+", font, pen.Brush, increaseMaximumSubtreeCountRectangle, stringFormat); 273 288 if (pen.Color == Color.LightGray) increaseMaximumSubtreeCountRectangle = RectangleF.Empty; 274 289 275 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; 276 291 graphics.DrawRectangle(pen, Rectangle.Round(decreaseMaximumSubtreeCountRectangle)); 277 292 graphics.DrawString("-", font, pen.Brush, decreaseMaximumSubtreeCountRectangle, stringFormat); … … 282 297 283 298 private void allowedChildSymbolsControl_MouseDown(object sender, MouseEventArgs e) { 284 if (Grammar == null ) return;299 if (Grammar == null || Grammar.ReadOnly) return; 285 300 if (symbolicExpressionTreeChart.Tree == null) return; 286 301
Note: See TracChangeset
for help on using the changeset viewer.