1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.ComponentModel;
|
---|
25 | using System.Drawing;
|
---|
26 | using System.Data;
|
---|
27 | using System.Linq;
|
---|
28 | using System.Text;
|
---|
29 | using System.Windows.Forms;
|
---|
30 | using HeuristicLab.Core;
|
---|
31 | using System.Diagnostics;
|
---|
32 | using HeuristicLab.Data;
|
---|
33 | using HeuristicLab.Operators;
|
---|
34 | using HeuristicLab.Random;
|
---|
35 |
|
---|
36 | namespace HeuristicLab.GP {
|
---|
37 | public partial class FunctionLibraryEditor : EditorBase {
|
---|
38 | public FunctionLibrary FunctionLibrary {
|
---|
39 | get { return (FunctionLibrary)Item; }
|
---|
40 | set { base.Item = value; }
|
---|
41 | }
|
---|
42 |
|
---|
43 | public FunctionLibraryEditor(FunctionLibrary library)
|
---|
44 | : base() {
|
---|
45 | InitializeComponent();
|
---|
46 | FunctionLibrary = library;
|
---|
47 |
|
---|
48 | mutationVariableView.Enabled = false;
|
---|
49 | initVariableView.Enabled = false;
|
---|
50 |
|
---|
51 | foreach (IFunction fun in library.Functions) {
|
---|
52 | if (fun.Manipulator != null) {
|
---|
53 | ListViewItem item = new ListViewItem();
|
---|
54 | item.Text = fun.Name;
|
---|
55 | item.Name = fun.Name;
|
---|
56 | item.Tag = fun;
|
---|
57 | mutationListView.Items.Add(item);
|
---|
58 | }
|
---|
59 | if (fun.Initializer != null) {
|
---|
60 | ListViewItem item = new ListViewItem();
|
---|
61 | item.Name = fun.Name;
|
---|
62 | item.Text = fun.Name;
|
---|
63 | item.Tag = fun;
|
---|
64 | initListView.Items.Add(item);
|
---|
65 | }
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 | protected override void AddItemEvents() {
|
---|
70 | base.AddItemEvents();
|
---|
71 | base.Item.Changed += (sender, args) => UpdateControls();
|
---|
72 | }
|
---|
73 |
|
---|
74 | protected override void UpdateControls() {
|
---|
75 | base.UpdateControls();
|
---|
76 | }
|
---|
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 | // }
|
---|
87 |
|
---|
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 | // }
|
---|
95 |
|
---|
96 | // op.NameChanged += new EventHandler(op_NameChanged);
|
---|
97 | // Refresh();
|
---|
98 | //}
|
---|
99 |
|
---|
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 | //}
|
---|
136 |
|
---|
137 | private void mutationListView_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
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 | //}
|
---|
145 | }
|
---|
146 |
|
---|
147 | private void initListView_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
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 | //}
|
---|
155 | }
|
---|
156 | }
|
---|
157 | }
|
---|