- Timestamp:
- 10/14/08 22:33:29 (16 years ago)
- Location:
- branches/GpPluginsRefactoringBranch/HeuristicLab.GP
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GpPluginsRefactoringBranch/HeuristicLab.GP/FunctionView.Designer.cs
r654 r655 51 51 this.components = new System.ComponentModel.Container(); 52 52 this.funTreeView = new System.Windows.Forms.TreeView(); 53 this.representationContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);54 53 this.splitContainer = new System.Windows.Forms.SplitContainer(); 55 54 this.variablesGroupBox = new System.Windows.Forms.GroupBox(); … … 59 58 this.templateTextBox = new System.Windows.Forms.TextBox(); 60 59 this.editButton = new System.Windows.Forms.Button(); 61 this.treeNodeContextMenu = new System.Windows.Forms.ContextMenu Strip(this.components);60 this.treeNodeContextMenu = new System.Windows.Forms.ContextMenu(); 62 61 this.splitContainer.Panel1.SuspendLayout(); 63 62 this.splitContainer.Panel2.SuspendLayout(); … … 70 69 // funTreeView 71 70 // 72 this.funTreeView.ContextMenuStrip = this.representationContextMenu;73 71 this.funTreeView.Dock = System.Windows.Forms.DockStyle.Fill; 74 72 this.funTreeView.HideSelection = false; … … 79 77 this.funTreeView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.funTreeView_MouseUp); 80 78 this.funTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.functionTreeView_AfterSelect); 81 //82 // representationContextMenu83 //84 this.representationContextMenu.Name = "representationContextMenu";85 this.representationContextMenu.Size = new System.Drawing.Size(61, 4);86 79 // 87 80 // splitContainer … … 172 165 // 173 166 this.treeNodeContextMenu.Name = "treeNodeContextMenu"; 174 this.treeNodeContextMenu.Size = new System.Drawing.Size(61, 4);175 167 // 176 168 // FunctionTreeView … … 202 194 private System.Windows.Forms.ListBox variablesListBox; 203 195 private System.Windows.Forms.Label label1; 204 private System.Windows.Forms.ContextMenuStrip treeNodeContextMenu; 205 private System.Windows.Forms.ContextMenuStrip representationContextMenu; 206 196 private System.Windows.Forms.ContextMenu treeNodeContextMenu; 207 197 } 208 198 } -
branches/GpPluginsRefactoringBranch/HeuristicLab.GP/FunctionView.cs
r654 r655 40 40 private IFunctionTreeNameGenerator nameGenerator; 41 41 private IFunctionTreeNameGenerator[] allNameGenerators; 42 private MenuItem representationsMenu; 42 43 43 44 public FunctionTreeView() { … … 47 48 DiscoveryService discoveryService = new DiscoveryService(); 48 49 allNameGenerators = discoveryService.GetInstances<IFunctionTreeNameGenerator>(); 49 50 representationsMenu = new MenuItem(); 51 representationsMenu.Text = "Tree representation"; 52 representationsMenu.Name = "Tree representation"; 50 53 foreach(IFunctionTreeNameGenerator generator in allNameGenerators) { 51 ToolStripButton button = new ToolStripButton(generator.Name, null,54 MenuItem mi = new MenuItem(generator.Name, 52 55 delegate(object source, EventArgs args) { 53 this.nameGenerator = generator; 54 foreach(ToolStripButton otherButton in representationContextMenu.Items) otherButton.Checked = false; 55 ((ToolStripButton)source).Checked = true; 56 IFunctionTreeNameGenerator g = (IFunctionTreeNameGenerator)((MenuItem)source).Tag; 57 this.nameGenerator = g; 58 foreach(MenuItem otherMenuItem in representationsMenu.MenuItems) otherMenuItem.Checked = false; 59 ((MenuItem)source).Checked = true; 56 60 UpdateControls(); 57 }); 58 if(generator is DefaultFunctionTreeNameGenerator) button.Checked = true; 59 else button.Checked = false; 60 representationContextMenu.Items.Add(button); 61 }, Shortcut.None); 62 if(generator is DefaultFunctionTreeNameGenerator) mi.Checked = true; 63 else mi.Checked = false; 64 mi.Tag = generator; 65 representationsMenu.MenuItems.Add(mi); 61 66 } 62 67 } … … 74 79 rootNode.Text = nameGenerator.GetName(functionTree); 75 80 rootNode.Tag = functionTree; 76 treeNodeContextMenu.Items.Clear(); 81 treeNodeContextMenu.MenuItems.Clear(); 82 treeNodeContextMenu.MenuItems.Add(representationsMenu); 77 83 DiscoveryService discoveryService = new DiscoveryService(); 78 84 IFunctionTreeExporter[] exporters = discoveryService.GetInstances<IFunctionTreeExporter>(); 79 if(exporters.Length>0)80 treeNodeContextMenu.Items.Add(new ToolStripSeparator());81 85 foreach(IFunctionTreeExporter exporter in exporters) { 82 86 string result; 83 87 // register a menu item for the exporter 84 ToolStripItem item = new ToolStripButton("Copy to clip-board (" + exporter.Name + ")", null,88 MenuItem item = new MenuItem("Copy to clip-board (" + exporter.Name + ")", 85 89 delegate(object source, EventArgs args) { 86 90 TreeNode node = funTreeView.SelectedNode; 87 91 if(node == null || node.Tag == null) return; 88 92 Clipboard.SetText(exporter.Export((IFunctionTree)node.Tag)); 89 } );93 }, Shortcut.None); 90 94 // try to export the whole tree 91 95 if(exporter.TryExport(functionTree, out result)) { … … 95 99 item.Enabled = false; 96 100 } 97 treeNodeContextMenu. Items.Add(item);101 treeNodeContextMenu.MenuItems.Add(item); 98 102 } 99 rootNode.ContextMenu Strip= treeNodeContextMenu;103 rootNode.ContextMenu = treeNodeContextMenu; 100 104 funTreeView.Nodes.Add(rootNode); 101 105 … … 111 115 node.Text = nameGenerator.GetName(functionTree); 112 116 node.Tag = functionTree; 113 node.ContextMenu Strip= treeNodeContextMenu;117 node.ContextMenu = treeNodeContextMenu; 114 118 rootNode.Nodes.Add(node); 115 119 foreach(IFunctionTree subTree in functionTree.SubTrees) {
Note: See TracChangeset
for help on using the changeset viewer.