Free cookie consent management tool by TermsFeed Policy Generator

Changeset 655


Ignore:
Timestamp:
10/14/08 22:33:29 (16 years ago)
Author:
gkronber
Message:

fixed contextmenu for tree representation (#177)

Location:
branches/GpPluginsRefactoringBranch/HeuristicLab.GP
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GpPluginsRefactoringBranch/HeuristicLab.GP/FunctionView.Designer.cs

    r654 r655  
    5151      this.components = new System.ComponentModel.Container();
    5252      this.funTreeView = new System.Windows.Forms.TreeView();
    53       this.representationContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
    5453      this.splitContainer = new System.Windows.Forms.SplitContainer();
    5554      this.variablesGroupBox = new System.Windows.Forms.GroupBox();
     
    5958      this.templateTextBox = new System.Windows.Forms.TextBox();
    6059      this.editButton = new System.Windows.Forms.Button();
    61       this.treeNodeContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
     60      this.treeNodeContextMenu = new System.Windows.Forms.ContextMenu();
    6261      this.splitContainer.Panel1.SuspendLayout();
    6362      this.splitContainer.Panel2.SuspendLayout();
     
    7069      // funTreeView
    7170      //
    72       this.funTreeView.ContextMenuStrip = this.representationContextMenu;
    7371      this.funTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
    7472      this.funTreeView.HideSelection = false;
     
    7977      this.funTreeView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.funTreeView_MouseUp);
    8078      this.funTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.functionTreeView_AfterSelect);
    81       //
    82       // representationContextMenu
    83       //
    84       this.representationContextMenu.Name = "representationContextMenu";
    85       this.representationContextMenu.Size = new System.Drawing.Size(61, 4);
    8679      //
    8780      // splitContainer
     
    172165      //
    173166      this.treeNodeContextMenu.Name = "treeNodeContextMenu";
    174       this.treeNodeContextMenu.Size = new System.Drawing.Size(61, 4);
    175167      //
    176168      // FunctionTreeView
     
    202194    private System.Windows.Forms.ListBox variablesListBox;
    203195    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;
    207197  }
    208198}
  • branches/GpPluginsRefactoringBranch/HeuristicLab.GP/FunctionView.cs

    r654 r655  
    4040    private IFunctionTreeNameGenerator nameGenerator;
    4141    private IFunctionTreeNameGenerator[] allNameGenerators;
     42    private MenuItem representationsMenu;
    4243
    4344    public FunctionTreeView() {
     
    4748      DiscoveryService discoveryService = new DiscoveryService();
    4849      allNameGenerators = discoveryService.GetInstances<IFunctionTreeNameGenerator>();
    49 
     50      representationsMenu = new MenuItem();
     51      representationsMenu.Text = "Tree representation";
     52      representationsMenu.Name = "Tree representation";
    5053      foreach(IFunctionTreeNameGenerator generator in allNameGenerators) {
    51         ToolStripButton button = new ToolStripButton(generator.Name, null,
     54        MenuItem mi = new MenuItem(generator.Name,
    5255          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;
    5660            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);
    6166      }
    6267    }
     
    7479      rootNode.Text = nameGenerator.GetName(functionTree);
    7580      rootNode.Tag = functionTree;
    76       treeNodeContextMenu.Items.Clear();
     81      treeNodeContextMenu.MenuItems.Clear();
     82      treeNodeContextMenu.MenuItems.Add(representationsMenu);
    7783      DiscoveryService discoveryService = new DiscoveryService();
    7884      IFunctionTreeExporter[] exporters = discoveryService.GetInstances<IFunctionTreeExporter>();
    79       if(exporters.Length>0)
    80         treeNodeContextMenu.Items.Add(new ToolStripSeparator());
    8185      foreach(IFunctionTreeExporter exporter in exporters) {
    8286        string result;
    8387        // 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 + ")",
    8589          delegate(object source, EventArgs args) {
    8690            TreeNode node = funTreeView.SelectedNode;
    8791            if(node == null || node.Tag == null) return;
    8892            Clipboard.SetText(exporter.Export((IFunctionTree)node.Tag));
    89           });
     93          }, Shortcut.None);
    9094        // try to export the whole tree
    9195        if(exporter.TryExport(functionTree, out result)) {
     
    9599          item.Enabled = false;
    96100        }
    97         treeNodeContextMenu.Items.Add(item);
     101        treeNodeContextMenu.MenuItems.Add(item);
    98102      }
    99       rootNode.ContextMenuStrip = treeNodeContextMenu;
     103      rootNode.ContextMenu = treeNodeContextMenu;
    100104      funTreeView.Nodes.Add(rootNode);
    101105
     
    111115      node.Text = nameGenerator.GetName(functionTree);
    112116      node.Tag = functionTree;
    113       node.ContextMenuStrip = treeNodeContextMenu;
     117      node.ContextMenu = treeNodeContextMenu;
    114118      rootNode.Nodes.Add(node);
    115119      foreach(IFunctionTree subTree in functionTree.SubTrees) {
Note: See TracChangeset for help on using the changeset viewer.