Changeset 7148
- Timestamp:
- 12/07/11 13:31:42 (13 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4
- Files:
-
- 3 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 -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.Designer.cs
r6803 r7148 162 162 this.symbolsTreeView.TabIndex = 0; 163 163 this.symbolsTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.symbolsTreeView_AfterCheck); 164 this.symbolsTreeView.BeforeCheck += new System.Windows.Forms.TreeViewCancelEventHandler(symbolsTreeView_BeforeCheck); 164 165 this.symbolsTreeView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.symbolsTreeView_ItemDrag); 165 166 this.symbolsTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.symbolsTreeView_AfterSelect); -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.cs
r7018 r7148 54 54 } 55 55 56 private Color treeViewBackColor = Color.Empty; 56 57 protected override void SetEnabledStateOfControls() { 57 58 base.SetEnabledStateOfControls(); 58 addButton.Enabled = Content != null && !Content.ReadOnly; 59 removeButton.Enabled = Content != null && !Content.ReadOnly && symbolsTreeView.SelectedNode != null && !(symbolsTreeView.SelectedNode.Tag is IReadOnlySymbol); 60 copyButton.Enabled = Content != null && !Content.ReadOnly && symbolsTreeView.SelectedNode != null && !(symbolsTreeView.SelectedNode.Tag is IReadOnlySymbol); 59 if (Content == null || Content.ReadOnly || ReadOnly || Locked) { 60 addButton.Enabled = false; 61 removeButton.Enabled = false; 62 copyButton.Enabled = false; 63 treeViewBackColor = symbolsTreeView.BackColor; 64 symbolsTreeView.BackColor = Color.FromArgb(255,240,240,240); 65 } else { 66 addButton.Enabled = true; 67 if (symbolsTreeView.SelectedNode != null && !(symbolsTreeView.SelectedNode.Tag is IReadOnlySymbol)) { 68 removeButton.Enabled = true; 69 copyButton.Enabled = true; 70 } 71 treeViewBackColor = Color.Empty; 72 symbolsTreeView.BackColor = treeViewBackColor; 73 } 61 74 } 62 75 … … 112 125 #endregion 113 126 127 private bool internalTreeViewUpdateInProgress = false; 114 128 private void UpdateSymbolsTreeView() { 129 internalTreeViewUpdateInProgress = true; 115 130 var symbols = Content.Symbols.ToList(); 116 131 foreach (var treeNode in IterateTreeNodes().ToList()) { … … 125 140 126 141 RebuildImageList(); 142 internalTreeViewUpdateInProgress = false; 127 143 } 128 144 … … 148 164 private void symbolsTreeView_AfterSelect(object sender, TreeViewEventArgs e) { 149 165 if (e.Action != TreeViewAction.Unknown) UpdateSymbolDetailsViews(); 150 151 removeButton.Enabled = symbolsTreeView.SelectedNode != null && !(symbolsTreeView.SelectedNode.Tag is IReadOnlySymbol); 152 copyButton.Enabled = symbolsTreeView.SelectedNode != null && !(symbolsTreeView.SelectedNode.Tag is IReadOnlySymbol); 166 SetEnabledStateOfControls(); 153 167 } 154 168 … … 164 178 Content.FinishedGrammarManipulation(); 165 179 } 180 } 181 182 private void symbolsTreeView_BeforeCheck(object sender, TreeViewCancelEventArgs e) { 183 if (internalTreeViewUpdateInProgress) return; 184 if (Content == null || Content.ReadOnly) e.Cancel = true; 185 if (ReadOnly || Locked) e.Cancel = true; 166 186 } 167 187 … … 183 203 private void symbolsTreeView_DragEnter(object sender, DragEventArgs e) { 184 204 validDragOperation = false; 185 if (Content == null ) return;205 if (Content == null || Content.ReadOnly || ReadOnly || Locked) return; 186 206 187 207 var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); … … 230 250 Point coordinates = new Point(e.X, e.Y); 231 251 TreeNode node = symbolsTreeView.GetNodeAt(coordinates); 232 if (e.Button == System.Windows.Forms.MouseButtons.Left && node == null) {252 if (e.Button == MouseButtons.Left && node == null) { 233 253 symbolsTreeView.SelectedNode = null; 234 254 symbolDetailsViewHost.Content = null; … … 238 258 239 259 private void symbolsTreeView_KeyDown(object sender, KeyEventArgs e) { 240 if ( ReadOnly) return;260 if (Content == null || Content.ReadOnly || ReadOnly || Locked) return; 241 261 if (symbolsTreeView.SelectedNode == null) return; 242 262 if (e.KeyCode != Keys.Delete) return;
Note: See TracChangeset
for help on using the changeset viewer.