Changeset 6299 for branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.cs
- Timestamp:
- 05/26/11 15:11:48 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.cs
r6285 r6299 100 100 private void RebuildSymbolsTreeView() { 101 101 symbolsTreeView.Nodes.Clear(); 102 var start = new TreeNode(); 103 var symbols = new DummySymbol("Symbols"); 104 start.Name = "Symbols"; 105 start.Text = "Symbols"; 106 start.Tag = symbols; 107 start.Checked = true; 108 symbolsTreeView.Nodes.Add(start); 102 var symbols = Content.Symbols.ToList(); 103 var groupSymbols = symbols.OfType<GroupSymbol>().ToList(); 104 var topLevelSymbols = Content.Symbols.Where(s => !groupSymbols.Any(g => g.Symbols.Contains(s))); 105 AddChildTreeNodes(symbolsTreeView.Nodes, topLevelSymbols); 109 106 110 foreach (ISymbol symbol in Content.Symbols.Where(s => !(s is IReadOnlySymbol))) { 107 RebuildImageList(); 108 symbolsTreeView.ExpandAll(); 109 } 110 111 private void AddChildTreeNodes(TreeNodeCollection collection, IEnumerable<ISymbol> symbols) { 112 foreach (ISymbol symbol in symbols) { 111 113 var node = new TreeNode(); 112 114 node.Name = symbol.Name; 113 115 node.Text = symbol.Name; 114 116 node.Tag = symbol; 115 node.Checked = !symbol.InitialFrequency.IsAlmost(0.0); 116 start.Nodes.Add(node); 117 node.Checked = symbol.Enabled; 118 collection.Add(node); 119 var groupSymbol = symbol as GroupSymbol; 120 if (groupSymbol != null) AddChildTreeNodes(node.Nodes, groupSymbol.Symbols); 117 121 } 118 RebuildImageList();119 symbolsTreeView.ExpandAll();120 122 } 121 123 … … 134 136 if (e.Action != TreeViewAction.Unknown) { 135 137 DeregisterContentEvents(); 136 foreach (var symbol in IterateTreeNodes(e.Node).Select(n => n.Tag).OfType<ISymbol>()) { 137 if (e.Node.Checked) symbol.InitialFrequency = 1.0; 138 else symbol.InitialFrequency = 0.0; 139 } 138 var symbol = (ISymbol)e.Node.Tag; 139 symbol.Enabled = e.Node.Checked; 140 140 RegisterContentEvents(); 141 141 Content_Changed(Content, EventArgs.Empty); … … 176 176 protected virtual void RebuildImageList() { 177 177 symbolsTreeView.ImageList.Images.Clear(); 178 foreach (TreeNode treeNode in symbolsTreeView.Nodes) {178 foreach (TreeNode treeNode in IterateTreeNodes()) { 179 179 var symbol = (ISymbol)treeNode.Tag; 180 180 symbolsTreeView.ImageList.Images.Add(symbol == null ? HeuristicLab.Common.Resources.VSImageLibrary.Nothing : symbol.ItemImage); … … 183 183 } 184 184 } 185 #endregion 185 186 186 187 [NonDiscoverableType] … … 190 191 public override IDeepCloneable Clone(Cloner cloner) { return new DummySymbol(this, cloner); } 191 192 } 192 193 #endregion194 193 }
Note: See TracChangeset
for help on using the changeset viewer.