- Timestamp:
- 01/28/10 16:43:36 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP/3.3/FunctionLibraryEditor.cs
r2222 r2701 48 48 protected override void UpdateControls() { 49 49 base.UpdateControls(); 50 functionsListView.Clear(); 51 functionsComboBox.Items.Clear(); 50 52 foreach (IFunction fun in FunctionLibrary.Functions) { 53 functionsListView.Items.Add(CreateListViewItem(fun)); 54 functionsComboBox.Items.Add(fun); 51 55 if (fun.Manipulator != null) { 52 56 mutationListView.Items.Add(CreateListViewItem(fun)); … … 82 86 if (chooseFunctionDialog.ShowDialog(this) == DialogResult.OK) { 83 87 FunctionLibrary.AddFunction((IFunction)chooseFunctionDialog.Item); 84 functionsListView.Items.Add(CreateListViewItem((IFunction)chooseFunctionDialog.Item));85 functionsListView.Sort();86 88 } 87 89 } … … 89 91 private void removeButton_Click(object sender, EventArgs e) { 90 92 // 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(); 92 94 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); 95 96 } 96 97 } 97 98 98 99 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 } 100 105 } 101 106 … … 107 112 return item; 108 113 } 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 } 109 133 } 110 134 }
Note: See TracChangeset
for help on using the changeset viewer.