Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/07/11 01:15:31 (13 years ago)
Author:
mkommend
Message:

#1555: Enabled editing of node labels and optimized drag over method.

Location:
trunk/sources/HeuristicLab.Optimization.Views/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentTreeView.Designer.cs

    r6524 r6526  
    4949      this.ExpandToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5050      this.CollapseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     51      this.EditNodeLabelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5152      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    5253      this.optimizersGroupBox.SuspendLayout();
     
    162163      this.treeView.ImageIndex = 0;
    163164      this.treeView.ImageList = this.imageList;
     165      this.treeView.LabelEdit = true;
    164166      this.treeView.Location = new System.Drawing.Point(4, 34);
    165167      this.treeView.Name = "optimizerTreeView";
     
    167169      this.treeView.Size = new System.Drawing.Size(191, 402);
    168170      this.treeView.TabIndex = 10;
     171      this.treeView.AfterLabelEdit += new System.Windows.Forms.NodeLabelEditEventHandler(treeView_AfterLabelEdit);
     172      this.treeView.BeforeLabelEdit += new System.Windows.Forms.NodeLabelEditEventHandler(treeView_BeforeLabelEdit);
    169173      this.treeView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.optimizerTreeView_ItemDrag);
    170174      this.treeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.optimizerTreeview_NodeMouseClick);
     
    215219      //
    216220      this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
     221            this.EditNodeLabelToolStripMenuItem,
    217222            this.ExpandToolStripMenuItem,
    218223            this.CollapseToolStripMenuItem});
     
    233238      this.CollapseToolStripMenuItem.Text = "Collapse";
    234239      this.CollapseToolStripMenuItem.Click += new System.EventHandler(this.CollapseToolStripMenuItem_Click);
     240      //
     241      // EditNodeLabelToolStripMenuItem
     242      //
     243      this.EditNodeLabelToolStripMenuItem.Name = "EditNodeLabelToolStripMenuItem";
     244      this.EditNodeLabelToolStripMenuItem.Size = new System.Drawing.Size(119, 22);
     245      this.EditNodeLabelToolStripMenuItem.Text = "Edit Name";
     246      this.EditNodeLabelToolStripMenuItem.Click += new System.EventHandler(this.EditNodeLabelToolStripMenuItem_Click);
     247
    235248      //
    236249      // ExperimentTreeView
     
    268281    private System.Windows.Forms.ToolStripMenuItem ExpandToolStripMenuItem;
    269282    private System.Windows.Forms.ToolStripMenuItem CollapseToolStripMenuItem;
     283    private System.Windows.Forms.ToolStripMenuItem EditNodeLabelToolStripMenuItem;
    270284
    271285  }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentTreeView.cs

    r6524 r6526  
    454454            else throw new NotSupportedException("Handling for specific type not implemented" + parentOptimizer.GetType());
    455455          }
    456           SetEnabledStateOfControls();
    457           UpdateDetailsViewHost();
    458           RebuildImageList();
    459456        }
    460457      }
     
    493490          if (optimizer == null) return;
    494491          if (batchRun.Optimizer != null) return;
    495           if (optimizer.GetObjectGraphObjects().OfType<IOptimizer>().Contains(batchRun)) return;
     492          if (optimizer.NestedOptimizers.Contains(batchRun)) return;
    496493        }
    497494
     
    503500          if (enumerable != null) optimizers = enumerable.Cast<IOptimizer>();
    504501
    505           if (optimizer != null && optimizer.GetObjectGraphObjects().OfType<IOptimizer>().Contains(experiment)) return;
    506           if (optimizers != null && optimizers.GetObjectGraphObjects().OfType<IOptimizer>().Contains(experiment)) return;
     502          if (optimizer != null && optimizer.NestedOptimizers.Contains(experiment)) return;
     503          if (optimizers != null && optimizers.Any(x => x.NestedOptimizers.Contains(experiment))) return;
    507504        }
    508505
     
    611608        CollapseToolStripMenuItem.Enabled = toolStripMenuNode.IsExpanded;
    612609        CollapseToolStripMenuItem.Visible = toolStripMenuNode.IsExpanded;
     610        EditNodeLabelToolStripMenuItem.Enabled = toolStripMenuNode.Tag != null && toolStripMenuNode.Tag is INamedItem;
     611        EditNodeLabelToolStripMenuItem.Visible = toolStripMenuNode.Tag != null && toolStripMenuNode.Tag is INamedItem;
    613612        if (contextMenuStrip.Items.Cast<ToolStripMenuItem>().Any(item => item.Enabled))
    614613          contextMenuStrip.Show(Cursor.Position);
     
    621620    private void CollapseToolStripMenuItem_Click(object sender, EventArgs e) {
    622621      if (toolStripMenuNode != null) toolStripMenuNode.Collapse();
     622    }
     623    private void EditNodeLabelToolStripMenuItem_Click(object sender, EventArgs e) {
     624      if (toolStripMenuNode != null) {
     625        if (!toolStripMenuNode.IsEditing) toolStripMenuNode.BeginEdit();
     626      }
     627    }
     628
     629
     630    private void treeView_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e) {
     631      if (e.Node.Tag == null || !(e.Node.Tag is INamedItem)) {
     632        e.CancelEdit = true;
     633        return;
     634      }
     635    }
     636    private void treeView_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) {
     637      if (e.Label == null) return;
     638
     639      e.Node.EndEdit(false);
     640      var namedItem = (INamedItem)e.Node.Tag;
     641      namedItem.Name = e.Label;
    623642    }
    624643
Note: See TracChangeset for help on using the changeset viewer.