- Timestamp:
- 07/28/09 19:24:23 (15 years ago)
- Location:
- branches/GP-Refactoring-713
- Files:
-
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/FunctionLibraryEditor.cs
r2183 r2202 35 35 36 36 namespace HeuristicLab.GP { 37 public partial class GPOperatorLibraryEditor : EditorBase {38 public IOperatorLibrary OperatorLibrary {39 get { return ( IOperatorLibrary)Item; }37 public partial class FunctionLibraryEditor : EditorBase { 38 public FunctionLibrary FunctionLibrary { 39 get { return (FunctionLibrary)Item; } 40 40 set { base.Item = value; } 41 41 } 42 42 43 public GPOperatorLibraryEditor(GPOperatorLibrary library)43 public FunctionLibraryEditor(FunctionLibrary library) 44 44 : base() { 45 45 InitializeComponent(); 46 OperatorLibrary = library; 47 operatorLibraryEditor.OperatorLibrary = library; 48 49 library.GPOperatorGroup.OperatorAdded += new EventHandler(GPOperatorLibraryView_OperatorAdded); 50 library.GPOperatorGroup.OperatorRemoved += new EventHandler(GPOperatorGroup_OperatorRemoved); 46 FunctionLibrary = library; 51 47 52 48 mutationVariableView.Enabled = false; 53 49 initVariableView.Enabled = false; 54 50 55 foreach (IOperator op in library.Group.Operators) {56 if (op.GetVariable(FunctionBase.MANIPULATION)!= null) {51 foreach (IFunction fun in library.Functions) { 52 if (fun.Manipulator != null) { 57 53 ListViewItem item = new ListViewItem(); 58 item.Text = op.Name;59 item.Name = op.Name;60 item.Tag = op;54 item.Text = fun.Name; 55 item.Name = fun.Name; 56 item.Tag = fun; 61 57 mutationListView.Items.Add(item); 62 58 } 63 if (op.GetVariable(FunctionBase.INITIALIZATION)!= null) {59 if (fun.Initializer != null) { 64 60 ListViewItem item = new ListViewItem(); 65 item.Name = op.Name;66 item.Text = op.Name;67 item.Tag = op;61 item.Name = fun.Name; 62 item.Text = fun.Name; 63 item.Tag = fun; 68 64 initListView.Items.Add(item); 69 65 } … … 71 67 } 72 68 73 74 private void GPOperatorLibraryView_OperatorAdded(object sender, EventArgs e) { 75 IOperator op = ((OperatorEventArgs)e).op; 76 if(op.GetVariable(FunctionBase.MANIPULATION) != null) { 77 ListViewItem operatorMutationItem = new ListViewItem(); 78 operatorMutationItem.Name = op.Name; 79 operatorMutationItem.Text = op.Name; 80 operatorMutationItem.Tag = op; 81 mutationListView.Items.Add(operatorMutationItem); 82 } 83 84 if(op.GetVariable(FunctionBase.INITIALIZATION) != null) { 85 ListViewItem operatorInitItem = new ListViewItem(); 86 operatorInitItem.Name = op.Name; 87 operatorInitItem.Text = op.Name; 88 operatorInitItem.Tag = op; 89 initListView.Items.Add(operatorInitItem); 90 } 91 92 op.NameChanged += new EventHandler(op_NameChanged); 93 Refresh(); 69 protected override void AddItemEvents() { 70 base.AddItemEvents(); 71 base.Item.Changed += (sender, args) => UpdateControls(); 94 72 } 95 73 96 private void op_NameChanged(object sender, EventArgs e) { 97 IOperator srcOp = (IOperator)sender; 98 foreach(ListViewItem item in mutationListView.Items) { 99 if(item.Tag == srcOp) { 100 item.Name = srcOp.Name; 101 item.Text = srcOp.Name; 102 break; 103 } 104 } 105 foreach(ListViewItem item in initListView.Items) { 106 if(item.Tag == srcOp) { 107 item.Name = srcOp.Name; 108 item.Text = srcOp.Name; 109 break; 110 } 111 } 74 protected override void UpdateControls() { 75 base.UpdateControls(); 112 76 } 113 77 78 //private void GPOperatorLibraryView_OperatorAdded(object sender, EventArgs e) { 79 // IOperator op = ((OperatorEventArgs)e).op; 80 // if(op.GetVariable(FunctionBase.MANIPULATION) != null) { 81 // ListViewItem operatorMutationItem = new ListViewItem(); 82 // operatorMutationItem.Name = op.Name; 83 // operatorMutationItem.Text = op.Name; 84 // operatorMutationItem.Tag = op; 85 // mutationListView.Items.Add(operatorMutationItem); 86 // } 114 87 115 private void GPOperatorGroup_OperatorRemoved(object sender, EventArgs e) { 116 IOperator op = ((OperatorEventArgs)e).op; 88 // if(op.GetVariable(FunctionBase.INITIALIZATION) != null) { 89 // ListViewItem operatorInitItem = new ListViewItem(); 90 // operatorInitItem.Name = op.Name; 91 // operatorInitItem.Text = op.Name; 92 // operatorInitItem.Tag = op; 93 // initListView.Items.Add(operatorInitItem); 94 // } 117 95 118 foreach(ListViewItem item in mutationListView.Items) { 119 if(item.Tag == op) { 120 mutationListView.Items.Remove(item); 121 break; 122 } 123 } 96 // op.NameChanged += new EventHandler(op_NameChanged); 97 // Refresh(); 98 //} 124 99 125 foreach(ListViewItem item in initListView.Items) { 126 if(item.Tag == op) { 127 initListView.Items.Remove(item); 128 break; 129 } 130 } 131 } 100 //private void op_NameChanged(object sender, EventArgs e) { 101 // IOperator srcOp = (IOperator)sender; 102 // foreach(ListViewItem item in mutationListView.Items) { 103 // if(item.Tag == srcOp) { 104 // item.Name = srcOp.Name; 105 // item.Text = srcOp.Name; 106 // break; 107 // } 108 // } 109 // foreach(ListViewItem item in initListView.Items) { 110 // if(item.Tag == srcOp) { 111 // item.Name = srcOp.Name; 112 // item.Text = srcOp.Name; 113 // break; 114 // } 115 // } 116 //} 117 118 119 //private void GPOperatorGroup_OperatorRemoved(object sender, EventArgs e) { 120 // IOperator op = ((OperatorEventArgs)e).op; 121 122 // foreach(ListViewItem item in mutationListView.Items) { 123 // if(item.Tag == op) { 124 // mutationListView.Items.Remove(item); 125 // break; 126 // } 127 // } 128 129 // foreach(ListViewItem item in initListView.Items) { 130 // if(item.Tag == op) { 131 // initListView.Items.Remove(item); 132 // break; 133 // } 134 // } 135 //} 132 136 133 137 private void mutationListView_SelectedIndexChanged(object sender, EventArgs e) { 134 if(mutationListView.SelectedItems.Count>0 && mutationListView.SelectedItems[0].Tag != null) {135 IVariable variable = ((IOperator)mutationListView.SelectedItems[0].Tag).GetVariable(FunctionBase.MANIPULATION);136 mutationVariableView.Enabled = true;137 mutationVariableView.Variable = variable;138 } else {139 mutationVariableView.Enabled = false;140 }138 //if(mutationListView.SelectedItems.Count>0 && mutationListView.SelectedItems[0].Tag != null) { 139 // IVariable variable = ((IFunction)mutationListView.SelectedItems[0].Tag).Manipulator; 140 // mutationVariableView.Enabled = true; 141 // mutationVariableView.Variable = variable; 142 //} else { 143 // mutationVariableView.Enabled = false; 144 //} 141 145 } 142 146 143 147 private void initListView_SelectedIndexChanged(object sender, EventArgs e) { 144 if(initListView.SelectedItems.Count>0 && initListView.SelectedItems[0].Tag != null) {145 IVariable variable = ((IOperator)initListView.SelectedItems[0].Tag).GetVariable(FunctionBase.INITIALIZATION);146 initVariableView.Enabled = true;147 initVariableView.Variable = variable;148 } else {149 initVariableView.Enabled = false;150 }148 //if(initListView.SelectedItems.Count>0 && initListView.SelectedItems[0].Tag != null) { 149 // IVariable variable = ((IFunction)initListView.SelectedItems[0].Tag).Initializer; 150 // initVariableView.Enabled = true; 151 // initVariableView.Variable = variable; 152 //} else { 153 // initVariableView.Enabled = false; 154 //} 151 155 } 152 156 }
Note: See TracChangeset
for help on using the changeset viewer.