Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/28/10 16:43:36 (14 years ago)
Author:
gkronber
Message:

Repaired FunctionLibraryEditor. #748 (FunctionLibraryView is empty)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP/3.3/FunctionLibraryEditor.cs

    r2222 r2701  
    4848    protected override void UpdateControls() {
    4949      base.UpdateControls();
     50      functionsListView.Clear();
     51      functionsComboBox.Items.Clear();
    5052      foreach (IFunction fun in FunctionLibrary.Functions) {
     53        functionsListView.Items.Add(CreateListViewItem(fun));
     54        functionsComboBox.Items.Add(fun);
    5155        if (fun.Manipulator != null) {
    5256          mutationListView.Items.Add(CreateListViewItem(fun));
     
    8286      if (chooseFunctionDialog.ShowDialog(this) == DialogResult.OK) {
    8387        FunctionLibrary.AddFunction((IFunction)chooseFunctionDialog.Item);
    84         functionsListView.Items.Add(CreateListViewItem((IFunction)chooseFunctionDialog.Item));
    85         functionsListView.Sort();
    8688      }
    8789    }
     
    8991    private void removeButton_Click(object sender, EventArgs e) {
    9092      // delete from the end of the list
    91       IEnumerable<int> removeIndices = functionsListView.SelectedIndices.OfType<int>().OrderBy(x => 1.0 / x);
     93      List<int> removeIndices = functionsListView.SelectedIndices.OfType<int>().OrderBy(x => 1.0 / x).ToList();
    9294      foreach (int selectedIndex in removeIndices) {
    93         FunctionLibrary.RemoveFunction((IFunction)functionsListView.Items[selectedIndex].Tag);
    94         functionsListView.Items.RemoveAt(selectedIndex);
     95        FunctionLibrary.RemoveFunction((IFunction)functionsListView.Items[selectedIndex].Tag);       
    9596      }
    9697    }
    9798
    9899    private void functionsListView_SelectedIndexChanged(object sender, EventArgs e) {
    99       removeButton.Enabled = functionsListView.SelectedIndices.Count > 0;
     100      if (functionsListView.SelectedIndices.Count > 0) {
     101        removeButton.Enabled = true;
     102      } else {
     103        removeButton.Enabled = false;
     104      }
    100105    }
    101106
     
    107112      return item;
    108113    }
     114
     115    private void functionsListView_ItemDrag(object sender, ItemDragEventArgs e) {
     116      ListViewItem item = (ListViewItem)e.Item;
     117      IFunction fun = (IFunction)item.Tag;
     118      DataObject data = new DataObject();
     119      data.SetData("IFunction", fun);
     120      data.SetData("DragSource", functionsListView);
     121      DoDragDrop(data, DragDropEffects.Link);
     122    }
     123
     124    private void functionsComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     125      if (functionsComboBox.SelectedItem != null) {
     126        IFunction selectedFun = (IFunction)functionsComboBox.SelectedItem;
     127        Control funView = (Control)selectedFun.CreateView();
     128        funView.Dock = DockStyle.Fill;
     129        functionDetailsPanel.Controls.Clear();
     130        functionDetailsPanel.Controls.Add(funView);
     131      }
     132    }
    109133  }
    110134}
Note: See TracChangeset for help on using the changeset viewer.